mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Use %printer directive for Bison 3.8 (used release flow)
This is backport of fa05697e48
This commit is contained in:
parent
ee8dc8a2f3
commit
168ec2b1e5
2 changed files with 30 additions and 46 deletions
74
parse.y
74
parse.y
|
@ -46,7 +46,6 @@
|
||||||
#define YYCALLOC(nelem, size) rb_parser_calloc(p, (nelem), (size))
|
#define YYCALLOC(nelem, size) rb_parser_calloc(p, (nelem), (size))
|
||||||
#define YYFREE(ptr) rb_parser_free(p, (ptr))
|
#define YYFREE(ptr) rb_parser_free(p, (ptr))
|
||||||
#define YYFPRINTF rb_parser_printf
|
#define YYFPRINTF rb_parser_printf
|
||||||
#define YYPRINT(out, tok, val) parser_token_value_print(p, (tok), &(val))
|
|
||||||
#define YY_LOCATION_PRINT(File, loc) \
|
#define YY_LOCATION_PRINT(File, loc) \
|
||||||
rb_parser_printf(p, "%d.%d-%d.%d", \
|
rb_parser_printf(p, "%d.%d-%d.%d", \
|
||||||
(loc).beg_pos.lineno, (loc).beg_pos.column,\
|
(loc).beg_pos.lineno, (loc).beg_pos.column,\
|
||||||
|
@ -602,7 +601,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_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 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);
|
|
||||||
static ID formal_argument(struct parser_params*, ID);
|
static ID formal_argument(struct parser_params*, ID);
|
||||||
static ID shadowing_lvar(struct parser_params*,ID);
|
static ID shadowing_lvar(struct parser_params*,ID);
|
||||||
static void new_bv(struct parser_params*,ID);
|
static void new_bv(struct parser_params*,ID);
|
||||||
|
@ -969,6 +967,35 @@ static int looking_at_eol_p(struct parser_params *p);
|
||||||
%expect 0
|
%expect 0
|
||||||
%define api.pure
|
%define api.pure
|
||||||
%define parse.error verbose
|
%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}
|
%lex-param {struct parser_params *p}
|
||||||
%parse-param {struct parser_params *p}
|
%parse-param {struct parser_params *p}
|
||||||
%initial-action
|
%initial-action
|
||||||
|
@ -10424,49 +10451,6 @@ rb_parser_set_location(struct parser_params *p, YYLTYPE *yylloc)
|
||||||
}
|
}
|
||||||
#endif /* !RIPPER */
|
#endif /* !RIPPER */
|
||||||
|
|
||||||
static void
|
|
||||||
parser_token_value_print(struct parser_params *p, enum yytokentype type, const YYSTYPE *valp)
|
|
||||||
{
|
|
||||||
VALUE v;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case tIDENTIFIER: case tFID: case tGVAR: case tIVAR:
|
|
||||||
case tCONSTANT: case tCVAR: case tLABEL: case tOP_ASGN:
|
|
||||||
#ifndef RIPPER
|
|
||||||
v = rb_id2str(valp->id);
|
|
||||||
#else
|
|
||||||
v = valp->node->nd_rval;
|
|
||||||
#endif
|
|
||||||
rb_parser_printf(p, "%"PRIsVALUE, v);
|
|
||||||
break;
|
|
||||||
case tINTEGER: case tFLOAT: case tRATIONAL: case tIMAGINARY:
|
|
||||||
case tSTRING_CONTENT: case tCHAR:
|
|
||||||
#ifndef RIPPER
|
|
||||||
v = valp->node->nd_lit;
|
|
||||||
#else
|
|
||||||
v = valp->val;
|
|
||||||
#endif
|
|
||||||
rb_parser_printf(p, "%+"PRIsVALUE, v);
|
|
||||||
break;
|
|
||||||
case tNTH_REF:
|
|
||||||
#ifndef RIPPER
|
|
||||||
rb_parser_printf(p, "$%ld", valp->node->nd_nth);
|
|
||||||
#else
|
|
||||||
rb_parser_printf(p, "%"PRIsVALUE, valp->val);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case tBACK_REF:
|
|
||||||
#ifndef RIPPER
|
|
||||||
rb_parser_printf(p, "$%c", (int)valp->node->nd_nth);
|
|
||||||
#else
|
|
||||||
rb_parser_printf(p, "%"PRIsVALUE, valp->val);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
assignable0(struct parser_params *p, ID id, const char **err)
|
assignable0(struct parser_params *p, ID id, const char **err)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||||
#define RUBY_VERSION_TEENY 7
|
#define RUBY_VERSION_TEENY 7
|
||||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||||
#define RUBY_PATCHLEVEL 220
|
#define RUBY_PATCHLEVEL 221
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2022
|
#define RUBY_RELEASE_YEAR 2022
|
||||||
#define RUBY_RELEASE_MONTH 11
|
#define RUBY_RELEASE_MONTH 11
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue