summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-18 06:42:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-18 06:42:19 +0000
commit17018d4c31a86af2b47e09b3229dab2e80d3db6d (patch)
tree2c2eef2266495ad04d78735d931c09ed1d0cc9ff /parse.y
parent908b5301124cf673a2ee44de652968aa5360afd1 (diff)
parse.y: continue after invalid name
* parse.y (set_yylval_noname): continue after an invalid global, instance, class variable name, without "unexpected end-of-file" error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y11
1 files changed, 8 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index 5bb3200734..6f8b01b56c 100644
--- a/parse.y
+++ b/parse.y
@@ -4555,6 +4555,8 @@ ripper_yylval_id(struct parser_params *p, ID x)
# define _cur_loc NULL_LOC /* dummy */
#endif
+#define set_yylval_noname() set_yylval_id(keyword_nil)
+
#ifndef RIPPER
#define literal_flush(p, ptr) ((p)->lex.ptok = (ptr))
#define dispatch_scan_event(p, t) ((void)0)
@@ -7617,7 +7619,8 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state)
compile_error(p, "`$%c' is not allowed as a global variable name", c);
}
parser_show_error_line(p, &loc);
- return 0;
+ set_yylval_noname();
+ return tGVAR;
}
case '0':
tokadd(p, '$');
@@ -7671,7 +7674,8 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state)
compile_error(p, "`@@' without identifiers is not allowed as a class variable name");
}
parser_show_error_line(p, &loc);
- return 0;
+ set_yylval_noname();
+ return result;
}
else if (ISDIGIT(c)) {
if (result == tIVAR) {
@@ -7697,7 +7701,8 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state)
compile_error(p, "`@@%c' is not allowed as a class variable name", c);
}
parser_show_error_line(p, &loc);
- return 0;
+ set_yylval_noname();
+ return result;
}
if (tokadd_ident(p, c)) return 0;