aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-16 02:00:16 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-16 02:00:16 +0000
commit62de1bf86311d5a3c0d3bd5c3fa42db6b3663d7b (patch)
treefc700df9f18dcee80f06cd1c58ce1904c3a2d5bb /parse.y
parent1389a636b851fa275d848f4efc8a26d61b0e945f (diff)
downloadruby-62de1bf86311d5a3c0d3bd5c3fa42db6b3663d7b.tar.gz
parse.y: set location of string/literals in the lexer instead of actions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y50
1 files changed, 10 insertions, 40 deletions
diff --git a/parse.y b/parse.y
index 92c0c875e6..786309695c 100644
--- a/parse.y
+++ b/parse.y
@@ -3489,12 +3489,6 @@ strings : string
;
string : tCHAR
- {
- /*%%%*/
- nd_set_loc($$, &@$);
- /*%
- %*/
- }
| string1
| string string1
{
@@ -3633,7 +3627,6 @@ qword_list : /* none */
| 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 */
| 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 */
;
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
;
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_document(struct parser_params*,rb_strterm_he
# 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