[前][次][番号順一覧][スレッド一覧]

ruby-changes:41760

From: nobu <ko1@a...>
Date: Mon, 15 Feb 2016 15:06:11 +0900 (JST)
Subject: [ruby-changes:41760] nobu:r53834 (trunk): parse.y: simplify local ID condition

nobu	2016-02-15 15:06:31 +0900 (Mon, 15 Feb 2016)

  New Revision: 53834

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53834

  Log:
    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().

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 53833)
+++ parse.y	(revision 53834)
@@ -7792,16 +7792,14 @@ tokadd_ident(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L7792
     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 https://github.com/ruby/ruby/blob/trunk/parse.y#L7970
     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 https://github.com/ruby/ruby/blob/trunk/parse.y#L8070
 	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;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]