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

ruby-changes:49745

From: mame <ko1@a...>
Date: Tue, 16 Jan 2018 11:00:22 +0900 (JST)
Subject: [ruby-changes:49745] mame:r61863 (trunk): parse.y: set location of string/literals in the lexer instead of actions

mame	2018-01-16 11:00:16 +0900 (Tue, 16 Jan 2018)

  New Revision: 61863

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

  Log:
    parse.y: set location of string/literals in the lexer instead of actions

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 61862)
+++ parse.y	(revision 61863)
@@ -3489,12 +3489,6 @@ strings		: string https://github.com/ruby/ruby/blob/trunk/parse.y#L3489
 		;
 
 string		: tCHAR
-		    {
-		    /*%%%*/
-			nd_set_loc($$, &@$);
-		    /*%
-		    %*/
-		    }
 		| string1
 		| string string1
 		    {
@@ -3633,7 +3627,6 @@ qword_list	: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L3627
 		| qword_list tSTRING_CONTENT ' '
 		    {
 		    /*%%%*/
-			nd_set_loc($2, &@2);
 			$$ = list_append(p, $1, $2);
 		    /*%
 			$$ = dispatch2(qwords_add, $1, $2);
@@ -3652,7 +3645,6 @@ qsym_list	: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L3645
 		| qsym_list tSTRING_CONTENT ' '
 		    {
 		    /*%%%*/
-			nd_set_loc($2, &@2);
 			$$ = symbol_append(p, $1, $2);
 		    /*%
 			$$ = dispatch2(qsymbols_add, $1, $2);
@@ -3746,12 +3738,6 @@ regexp_contents: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L3738
 		;
 
 string_content	: tSTRING_CONTENT
-		    {
-		    /*%%%*/
-			nd_set_loc($$, &@$);
-		    /*%
-		    %*/
-		    }
 		| tSTRING_DVAR
 		    {
 			/* need to backup p->lex.strterm so that a string literal `%&foo,#$&,bar&` can be parsed */
@@ -3879,33 +3865,9 @@ numeric 	: simple_numeric https://github.com/ruby/ruby/blob/trunk/parse.y#L3865
 		;
 
 simple_numeric	: tINTEGER
-		    {
-		    /*%%%*/
-			nd_set_loc($$, &@$);
-		    /*%
-		    %*/
-		    }
 		| tFLOAT
-		    {
-		    /*%%%*/
-			nd_set_loc($$, &@$);
-		    /*%
-		    %*/
-		    }
 		| tRATIONAL
-		    {
-		    /*%%%*/
-			nd_set_loc($$, &@$);
-		    /*%
-		    %*/
-		    }
 		| tIMAGINARY
-		    {
-		    /*%%%*/
-			nd_set_loc($$, &@$);
-		    /*%
-		    %*/
-		    }
 		;
 
 user_variable	: tIDENTIFIER
@@ -4664,11 +4626,19 @@ static enum yytokentype parser_here_docu https://github.com/ruby/ruby/blob/trunk/parse.y#L4626
 # define set_integer_literal(v, f)    parser_set_integer_literal(p, (v), (f))
 
 #ifndef RIPPER
-# define set_yylval_str(x) (yylval.node = NEW_STR(x, &NULL_LOC))
+# define set_yylval_str(x) {		\
+  YYLTYPE loc;				\
+  rb_parser_set_location(p, &loc);	\
+  yylval.node = NEW_STR(x, &loc);	\
+}
+# define set_yylval_literal(x) {	\
+  YYLTYPE loc;				\
+  rb_parser_set_location(p, &loc);	\
+  yylval.node = NEW_LIT(x, &loc);	\
+}
 # define set_yylval_num(x) (yylval.num = (x))
 # define set_yylval_id(x)  (yylval.id = (x))
 # define set_yylval_name(x)  (yylval.id = (x))
-# define set_yylval_literal(x) (yylval.node = NEW_LIT(x, &NULL_LOC))
 # define set_yylval_node(x) (yylval.node = (x))
 # define yylval_id() (yylval.id)
 #else

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

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