diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-14 05:57:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-14 05:57:42 +0000 |
commit | 9c077bbed94307d67c82a6e805dd6cc486433df2 (patch) | |
tree | 21df48dcd1cb13c4fc6531a0f7d40b825ac30472 /parse.y | |
parent | ccc933d4a6873d9be359c8ab04b1f242ed64c1e5 (diff) |
parse.y: show invalid global variable line
* parse.y (parse_gvar): show the source line erred by invalid
global variable, and indicate the variable including the wrong
punctuation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -7480,9 +7480,11 @@ parse_numvar(struct parser_params *p) static enum yytokentype parse_gvar(struct parser_params *p, const enum lex_state_e last_state) { + const char *ptr = p->lex.pcur; register int c; SET_LEX_STATE(EXPR_END); + p->lex.ptok = ptr - 1; /* from '$' */ newtok(p); c = nextc(p); switch (c) { @@ -7560,6 +7562,7 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state) default: if (!parser_is_identchar(p)) { + YYLTYPE loc = RUBY_INIT_YYLLOC(); if (c == -1 || ISSPACE(c)) { compile_error(p, "`$' without identifiers is not allowed as a global variable name"); } @@ -7567,6 +7570,7 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state) pushback(p, c); compile_error(p, "`$%c' is not allowed as a global variable name", c); } + parser_show_error_line(p, &loc); return 0; } case '0': |