Avoid syntax error regarding colons in the expression; fix #5290

Reported and inspired by @hasumikin; based on CRuby's `parse.y`.
parent 28d5daba
...@@ -5882,14 +5882,14 @@ parser_yylex(parser_state *p) ...@@ -5882,14 +5882,14 @@ parser_yylex(parser_state *p)
p->lstate = EXPR_BEG; p->lstate = EXPR_BEG;
return tLABEL_TAG; return tLABEL_TAG;
} }
if (!ISSPACE(c) || IS_BEG()) { if (IS_END() || ISSPACE(c) || c == '#') {
pushback(p, c); pushback(p, c);
p->lstate = EXPR_FNAME; p->lstate = EXPR_BEG;
return tSYMBEG; return ':';
} }
pushback(p, c); pushback(p, c);
p->lstate = EXPR_BEG; p->lstate = EXPR_FNAME;
return ':'; return tSYMBEG;
case '/': case '/':
if (IS_BEG()) { if (IS_BEG()) {
......
...@@ -11883,14 +11883,14 @@ parser_yylex(parser_state *p) ...@@ -11883,14 +11883,14 @@ parser_yylex(parser_state *p)
p->lstate = EXPR_BEG; p->lstate = EXPR_BEG;
return tLABEL_TAG; return tLABEL_TAG;
} }
if (!ISSPACE(c) || IS_BEG()) { if (IS_END() || ISSPACE(c) || c == '#') {
pushback(p, c); pushback(p, c);
p->lstate = EXPR_FNAME; p->lstate = EXPR_BEG;
return tSYMBEG; return ':';
} }
pushback(p, c); pushback(p, c);
p->lstate = EXPR_BEG; p->lstate = EXPR_FNAME;
return ':'; return tSYMBEG;
case '/': case '/':
if (IS_BEG()) { if (IS_BEG()) {
......
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