From 7c1878669a3efe02e3a0c530805d553e7f7cf1ea Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 11 Nov 2021 22:22:26 +0900 Subject: parse.y: should allow newline after `...`. --- include/mruby/compile.h | 2 +- mrbgems/mruby-compiler/core/parse.y | 3 ++- mrbgems/mruby-compiler/core/y.tab.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/mruby/compile.h b/include/mruby/compile.h index 6732625c1..aa1739ef1 100644 --- a/include/mruby/compile.h +++ b/include/mruby/compile.h @@ -56,7 +56,7 @@ enum mrb_lex_state_enum { EXPR_ENDFN, /* ditto, and unbound braces. */ EXPR_ARG, /* newline significant, +/- is an operator. */ EXPR_CMDARG, /* newline significant, +/- is an operator. */ - EXPR_MID, /* newline significant, +/- is an operator. */ + EXPR_MID, /* newline significant, +/- is a sign. */ EXPR_FNAME, /* ignore newline, no reserved words. */ EXPR_DOT, /* right after '.' or '::', no reserved words. */ EXPR_CLASS, /* immediate after 'class', no here document. */ diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 0a86a5c19..e70621723 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -5693,7 +5693,7 @@ parser_yylex(parser_state *p) case '.': { int is_beg = IS_BEG(); - p->lstate = EXPR_BEG; + p->lstate = EXPR_MID; if ((c = nextc(p)) == '.') { if ((c = nextc(p)) == '.') { return is_beg ? tBDOT3 : tDOT3; @@ -5702,6 +5702,7 @@ parser_yylex(parser_state *p) return is_beg ? tBDOT2 : tDOT2; } pushback(p, c); + p->lstate = EXPR_BEG; if (c >= 0 && ISDIGIT(c)) { yyerror(p, "no . floating literal anymore; put 0 before dot"); } diff --git a/mrbgems/mruby-compiler/core/y.tab.c b/mrbgems/mruby-compiler/core/y.tab.c index d316eaefa..e35bb7aa6 100644 --- a/mrbgems/mruby-compiler/core/y.tab.c +++ b/mrbgems/mruby-compiler/core/y.tab.c @@ -11916,7 +11916,7 @@ parser_yylex(parser_state *p) case '.': { int is_beg = IS_BEG(); - p->lstate = EXPR_BEG; + p->lstate = EXPR_MID; if ((c = nextc(p)) == '.') { if ((c = nextc(p)) == '.') { return is_beg ? tBDOT3 : tDOT3; @@ -11925,6 +11925,7 @@ parser_yylex(parser_state *p) return is_beg ? tBDOT2 : tDOT2; } pushback(p, c); + p->lstate = EXPR_BEG; if (c >= 0 && ISDIGIT(c)) { yyerror(p, "no . floating literal anymore; put 0 before dot"); } -- cgit v1.2.3