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

ruby-changes:34767

From: nobu <ko1@a...>
Date: Thu, 17 Jul 2014 13:31:09 +0900 (JST)
Subject: [ruby-changes:34767] nobu:r46849 (trunk): parse.y: parse_atmark

nobu	2014-07-17 13:30:38 +0900 (Thu, 17 Jul 2014)

  New Revision: 46849

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

  Log:
    parse.y: parse_atmark
    
    * parse.y (parse_atmark): extract from parser_yylex().

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 46848)
+++ parse.y	(revision 46849)
@@ -7461,6 +7461,32 @@ parse_gvar(struct parser_params *parser, https://github.com/ruby/ruby/blob/trunk/parse.y#L7461
 }
 
 static int
+parse_atmark(struct parser_params *parser, const enum lex_state_e last_state)
+{
+    int result = tIVAR;
+    register int c = nextc();
+
+    newtok();
+    tokadd('@');
+    if (c == '@') {
+	result = tCVAR;
+	tokadd('@');
+	c = nextc();
+    }
+    if (c != -1 && (ISDIGIT(c) || !parser_is_identchar())) {
+	pushback(c);
+	if (tokidx == 1) {
+	    compile_error(PARSER_ARG "`@%c' is not allowed as an instance variable name", c);
+	}
+	else {
+	    compile_error(PARSER_ARG "`@@%c' is not allowed as a class variable name", c);
+	}
+	return 0;
+    }
+    return -c;
+}
+
+static int
 parse_ident(struct parser_params *parser, int c, int cmd_state)
 {
     int result = 0;
@@ -8224,23 +8250,9 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8250
 	break;
 
       case '@':
-	c = nextc();
-	newtok();
-	tokadd('@');
-	if (c == '@') {
-	    tokadd('@');
-	    c = nextc();
-	}
-	if (c != -1 && (ISDIGIT(c) || !parser_is_identchar())) {
-	    pushback(c);
-	    if (tokidx == 1) {
-		compile_error(PARSER_ARG "`@%c' is not allowed as an instance variable name", c);
-	    }
-	    else {
-		compile_error(PARSER_ARG "`@@%c' is not allowed as a class variable name", c);
-	    }
-	    return 0;
-	}
+	c = parse_atmark(parser, last_state);
+	if (c >= 0) return c;
+	c = -c;
 	break;
 
       case '_':

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

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