diff options
author | nagachika <nagachika@ruby-lang.org> | 2021-10-02 11:22:19 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-10-02 11:22:19 +0900 |
commit | efa1ba15fd5007210f819e6d11002ca829c989bf (patch) | |
tree | 2be10312a01c4a93a7751e53728026ef1cd4f5b4 /parse.y | |
parent | 976569d94536614e97fa06b1f663a92aab9736cd (diff) |
merge revision(s) fa05697e4832fbd67a4f91b9bb362471902faab3: [Backport #18166]
Use `%printer` directive for Bison 3.8
---
parse.y | 74 ++++++++++++++++++++++++++---------------------------------------
1 file changed, 29 insertions(+), 45 deletions(-)
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 31 |
1 files changed, 29 insertions, 2 deletions
@@ -89,7 +89,6 @@ struct lex_context { #define YYCALLOC(nelem, size) rb_parser_calloc(p, (nelem), (size)) #define YYFREE(ptr) rb_parser_free(p, (ptr)) #define YYFPRINTF rb_parser_printf -#define YYPRINT(out, tok, val) parser_token_value_print(p, (tok), &(val)) #define YY_LOCATION_PRINT(File, loc) \ rb_parser_printf(p, "%d.%d-%d.%d", \ (loc).beg_pos.lineno, (loc).beg_pos.column,\ @@ -654,7 +653,6 @@ RUBY_SYMBOL_EXPORT_END static void error_duplicate_pattern_variable(struct parser_params *p, ID id, const YYLTYPE *loc); static void error_duplicate_pattern_key(struct parser_params *p, ID id, const YYLTYPE *loc); -static void parser_token_value_print(struct parser_params *p, enum yytokentype type, const YYSTYPE *valp); #ifndef RIPPER static ID formal_argument(struct parser_params*, ID); #else @@ -1084,6 +1082,35 @@ static int looking_at_eol_p(struct parser_params *p); %expect 0 %define api.pure %define parse.error verbose +%printer { +#ifndef RIPPER + rb_parser_printf(p, "%"PRIsVALUE, rb_id2str($$)); +#else + rb_parser_printf(p, "%"PRIsVALUE, RNODE($$)->nd_rval); +#endif +} tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL tOP_ASGN +%printer { +#ifndef RIPPER + rb_parser_printf(p, "%+"PRIsVALUE, $$->nd_lit); +#else + rb_parser_printf(p, "%+"PRIsVALUE, get_value($$)); +#endif +} tINTEGER tFLOAT tRATIONAL tIMAGINARY tSTRING_CONTENT tCHAR +%printer { +#ifndef RIPPER + rb_parser_printf(p, "$%ld", $$->nd_nth); +#else + rb_parser_printf(p, "%"PRIsVALUE, $$); +#endif +} tNTH_REF +%printer { +#ifndef RIPPER + rb_parser_printf(p, "$%c", (int)$$->nd_nth); +#else + rb_parser_printf(p, "%"PRIsVALUE, $$); +#endif +} tBACK_REF + %lex-param {struct parser_params *p} %parse-param {struct parser_params *p} %initial-action |