parse.y: should allow newline after `...`.

parent 885a87e4
...@@ -56,7 +56,7 @@ enum mrb_lex_state_enum { ...@@ -56,7 +56,7 @@ enum mrb_lex_state_enum {
EXPR_ENDFN, /* ditto, and unbound braces. */ EXPR_ENDFN, /* ditto, and unbound braces. */
EXPR_ARG, /* newline significant, +/- is an operator. */ EXPR_ARG, /* newline significant, +/- is an operator. */
EXPR_CMDARG, /* 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_FNAME, /* ignore newline, no reserved words. */
EXPR_DOT, /* right after '.' or '::', no reserved words. */ EXPR_DOT, /* right after '.' or '::', no reserved words. */
EXPR_CLASS, /* immediate after 'class', no here document. */ EXPR_CLASS, /* immediate after 'class', no here document. */
......
...@@ -5693,7 +5693,7 @@ parser_yylex(parser_state *p) ...@@ -5693,7 +5693,7 @@ parser_yylex(parser_state *p)
case '.': case '.':
{ {
int is_beg = IS_BEG(); int is_beg = IS_BEG();
p->lstate = EXPR_BEG; p->lstate = EXPR_MID;
if ((c = nextc(p)) == '.') { if ((c = nextc(p)) == '.') {
if ((c = nextc(p)) == '.') { if ((c = nextc(p)) == '.') {
return is_beg ? tBDOT3 : tDOT3; return is_beg ? tBDOT3 : tDOT3;
...@@ -5702,6 +5702,7 @@ parser_yylex(parser_state *p) ...@@ -5702,6 +5702,7 @@ parser_yylex(parser_state *p)
return is_beg ? tBDOT2 : tDOT2; return is_beg ? tBDOT2 : tDOT2;
} }
pushback(p, c); pushback(p, c);
p->lstate = EXPR_BEG;
if (c >= 0 && ISDIGIT(c)) { if (c >= 0 && ISDIGIT(c)) {
yyerror(p, "no .<digit> floating literal anymore; put 0 before dot"); yyerror(p, "no .<digit> floating literal anymore; put 0 before dot");
} }
......
...@@ -11916,7 +11916,7 @@ parser_yylex(parser_state *p) ...@@ -11916,7 +11916,7 @@ parser_yylex(parser_state *p)
case '.': case '.':
{ {
int is_beg = IS_BEG(); int is_beg = IS_BEG();
p->lstate = EXPR_BEG; p->lstate = EXPR_MID;
if ((c = nextc(p)) == '.') { if ((c = nextc(p)) == '.') {
if ((c = nextc(p)) == '.') { if ((c = nextc(p)) == '.') {
return is_beg ? tBDOT3 : tDOT3; return is_beg ? tBDOT3 : tDOT3;
...@@ -11925,6 +11925,7 @@ parser_yylex(parser_state *p) ...@@ -11925,6 +11925,7 @@ parser_yylex(parser_state *p)
return is_beg ? tBDOT2 : tDOT2; return is_beg ? tBDOT2 : tDOT2;
} }
pushback(p, c); pushback(p, c);
p->lstate = EXPR_BEG;
if (c >= 0 && ISDIGIT(c)) { if (c >= 0 && ISDIGIT(c)) {
yyerror(p, "no .<digit> floating literal anymore; put 0 before dot"); yyerror(p, "no .<digit> floating literal anymore; put 0 before dot");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment