summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-15 06:06:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-15 06:06:31 +0000
commit5e59be3eddd2ce28610ec8d1b42845cde0080833 (patch)
tree96f5fddd094acd4a7a6bcb5ce4f5ef20060a4827
parentc3554cdea6a1a4993034e1846546d9cb4c0a933d (diff)
parse.y: simplify local ID condition
* parse.y (tokenize_ident, parse_ident): ident in tokenize_ident() can be a local id only when called from parse_ident(), but never from parse_gvar() and parse_atmark(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--parse.y15
1 files changed, 9 insertions, 6 deletions
diff --git a/parse.y b/parse.y
index 5f3a8e3..3cbb282 100644
--- a/parse.y
+++ b/parse.y
@@ -7792,16 +7792,14 @@ tokadd_ident(struct parser_params *parser, int c)
return 0;
}
-static void
+static ID
tokenize_ident(struct parser_params *parser, const enum lex_state_e last_state)
{
ID ident = TOK_INTERN();
set_yylval_name(ident);
- if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
- is_local_id(ident) && lvar_defined(ident)) {
- SET_LEX_STATE(EXPR_END);
- }
+
+ return ident;
}
static int
@@ -7972,6 +7970,7 @@ parse_ident(struct parser_params *parser, int c, int cmd_state)
int result = 0;
int mb = ENC_CODERANGE_7BIT;
const enum lex_state_e last_state = lex_state;
+ ID ident;
do {
if (!ISASCII(c)) mb = ENC_CODERANGE_UNKNOWN;
@@ -8071,7 +8070,11 @@ parse_ident(struct parser_params *parser, int c, int cmd_state)
SET_LEX_STATE(EXPR_END);
}
- tokenize_ident(parser, last_state);
+ ident = tokenize_ident(parser, last_state);
+ if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
+ lvar_defined(ident)) {
+ SET_LEX_STATE(EXPR_END);
+ }
return result;
}