1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

parse.y: set ripper event ID symbols to operators

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-10-03 01:38:52 +00:00
parent 4fb1438b9d
commit e8e5a45020

67
parse.y
View file

@ -636,13 +636,16 @@ static int lvar_defined_gen(struct parser_params*, ID);
#define nd_paren(node) (char)((node)->u2.id >> CHAR_BIT*2) #define nd_paren(node) (char)((node)->u2.id >> CHAR_BIT*2)
#define nd_nest u3.cnt #define nd_nest u3.cnt
#define TOKEN2ID(tok) ( \ #define TOKEN2ID_OR(tok, or) ( \
tTOKEN_LOCAL_BEGIN<(tok)&&(tok)<tTOKEN_LOCAL_END ? TOKEN2LOCALID(tok) : \ tTOKEN_LOCAL_BEGIN<(tok)&&(tok)<tTOKEN_LOCAL_END ? TOKEN2LOCALID(tok) : \
tTOKEN_INSTANCE_BEGIN<(tok)&&(tok)<tTOKEN_INSTANCE_END ? TOKEN2INSTANCEID(tok) : \ tTOKEN_INSTANCE_BEGIN<(tok)&&(tok)<tTOKEN_INSTANCE_END ? TOKEN2INSTANCEID(tok) : \
tTOKEN_GLOBAL_BEGIN<(tok)&&(tok)<tTOKEN_GLOBAL_END ? TOKEN2GLOBALID(tok) : \ tTOKEN_GLOBAL_BEGIN<(tok)&&(tok)<tTOKEN_GLOBAL_END ? TOKEN2GLOBALID(tok) : \
tTOKEN_CONST_BEGIN<(tok)&&(tok)<tTOKEN_CONST_END ? TOKEN2CONSTID(tok) : \ tTOKEN_CONST_BEGIN<(tok)&&(tok)<tTOKEN_CONST_END ? TOKEN2CONSTID(tok) : \
tTOKEN_CLASS_BEGIN<(tok)&&(tok)<tTOKEN_CLASS_END ? TOKEN2CLASSID(tok) : \ tTOKEN_CLASS_BEGIN<(tok)&&(tok)<tTOKEN_CLASS_END ? TOKEN2CLASSID(tok) : \
tTOKEN_ATTRSET_BEGIN<(tok)&&(tok)<tTOKEN_ATTRSET_END ? TOKEN2ATTRSETID(tok) : \ tTOKEN_ATTRSET_BEGIN<(tok)&&(tok)<tTOKEN_ATTRSET_END ? TOKEN2ATTRSETID(tok) : \
or)
#define TOKEN2ID(tok) TOKEN2ID_OR(tok, \
((tok) / ((tok)<tPRESERVED_ID_END && ((tok)>=128 || rb_ispunct(tok))))) ((tok) / ((tok)<tPRESERVED_ID_END && ((tok)>=128 || rb_ispunct(tok)))))
/****** Ripper *******/ /****** Ripper *******/
@ -677,6 +680,7 @@ static void ripper_error_gen(struct parser_params *parser);
#define ID2VAL(id) STATIC_ID2SYM(id) #define ID2VAL(id) STATIC_ID2SYM(id)
#define TOKEN2VAL(t) ID2VAL(TOKEN2ID(t)) #define TOKEN2VAL(t) ID2VAL(TOKEN2ID(t))
#define TOKEN2EID(t) ID2SYM(TOKEN2ID_OR(t, ripper_token2eventid(t)))
#define arg_new() dispatch0(args_new) #define arg_new() dispatch0(args_new)
#define arg_add(l,a) dispatch2(args_add, (l), (a)) #define arg_add(l,a) dispatch2(args_add, (l), (a))
@ -733,6 +737,7 @@ static VALUE parser_heredoc_dedent(struct parser_params*,VALUE);
#else #else
#define ID2VAL(id) ((VALUE)(id)) #define ID2VAL(id) ((VALUE)(id))
#define TOKEN2VAL(t) ID2VAL(t) #define TOKEN2VAL(t) ID2VAL(t)
#define TOKEN2EID(t) (t)
#endif /* RIPPER */ #endif /* RIPPER */
#ifndef RIPPER #ifndef RIPPER
@ -1918,36 +1923,36 @@ undef_list : fitem
} }
; ;
op : '|' { ifndef_ripper($$ = '|'); } op : '|' { $$ = TOKEN2EID('|'); }
| '^' { ifndef_ripper($$ = '^'); } | '^' { $$ = TOKEN2EID('^'); }
| '&' { ifndef_ripper($$ = '&'); } | '&' { $$ = TOKEN2EID('&'); }
| tCMP { ifndef_ripper($$ = tCMP); } | tCMP { $$ = TOKEN2EID(tCMP); }
| tEQ { ifndef_ripper($$ = tEQ); } | tEQ { $$ = TOKEN2EID(tEQ); }
| tEQQ { ifndef_ripper($$ = tEQQ); } | tEQQ { $$ = TOKEN2EID(tEQQ); }
| tMATCH { ifndef_ripper($$ = tMATCH); } | tMATCH { $$ = TOKEN2EID(tMATCH); }
| tNMATCH { ifndef_ripper($$ = tNMATCH); } | tNMATCH { $$ = TOKEN2EID(tNMATCH); }
| '>' { ifndef_ripper($$ = '>'); } | '>' { $$ = TOKEN2EID('>'); }
| tGEQ { ifndef_ripper($$ = tGEQ); } | tGEQ { $$ = TOKEN2EID(tGEQ); }
| '<' { ifndef_ripper($$ = '<'); } | '<' { $$ = TOKEN2EID('<'); }
| tLEQ { ifndef_ripper($$ = tLEQ); } | tLEQ { $$ = TOKEN2EID(tLEQ); }
| tNEQ { ifndef_ripper($$ = tNEQ); } | tNEQ { $$ = TOKEN2EID(tNEQ); }
| tLSHFT { ifndef_ripper($$ = tLSHFT); } | tLSHFT { $$ = TOKEN2EID(tLSHFT); }
| tRSHFT { ifndef_ripper($$ = tRSHFT); } | tRSHFT { $$ = TOKEN2EID(tRSHFT); }
| '+' { ifndef_ripper($$ = '+'); } | '+' { $$ = TOKEN2EID('+'); }
| '-' { ifndef_ripper($$ = '-'); } | '-' { $$ = TOKEN2EID('-'); }
| '*' { ifndef_ripper($$ = '*'); } | '*' { $$ = TOKEN2EID('*'); }
| tSTAR { ifndef_ripper($$ = '*'); } | tSTAR { $$ = TOKEN2EID('*'); }
| '/' { ifndef_ripper($$ = '/'); } | '/' { $$ = TOKEN2EID('/'); }
| '%' { ifndef_ripper($$ = '%'); } | '%' { $$ = TOKEN2EID('%'); }
| tPOW { ifndef_ripper($$ = tPOW); } | tPOW { $$ = TOKEN2EID(tPOW); }
| tDSTAR { ifndef_ripper($$ = tDSTAR); } | tDSTAR { $$ = TOKEN2EID(tDSTAR); }
| '!' { ifndef_ripper($$ = '!'); } | '!' { $$ = TOKEN2EID('!'); }
| '~' { ifndef_ripper($$ = '~'); } | '~' { $$ = TOKEN2EID('~'); }
| tUPLUS { ifndef_ripper($$ = tUPLUS); } | tUPLUS { $$ = TOKEN2EID(tUPLUS); }
| tUMINUS { ifndef_ripper($$ = tUMINUS); } | tUMINUS { $$ = TOKEN2EID(tUMINUS); }
| tAREF { ifndef_ripper($$ = tAREF); } | tAREF { $$ = TOKEN2EID(tAREF); }
| tASET { ifndef_ripper($$ = tASET); } | tASET { $$ = TOKEN2EID(tASET); }
| '`' { ifndef_ripper($$ = '`'); } | '`' { $$ = TOKEN2EID('`'); }
; ;
reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__ reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__