ruby-changes:55082
From: nobu <ko1@a...>
Date: Mon, 18 Mar 2019 10:18:32 +0900 (JST)
Subject: [ruby-changes:55082] nobu:r67289 (trunk): parse.y: parser_numbered_param
nobu 2019-03-18 10:18:25 +0900 (Mon, 18 Mar 2019) New Revision: 67289 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67289 Log: parse.y: parser_numbered_param * parse.y (parser_numbered_param): hoisted out the contextual check for numbered parameters. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 67288) +++ parse.y (revision 67289) @@ -7629,6 +7629,22 @@ parse_gvar(struct parser_params *p, cons https://github.com/ruby/ruby/blob/trunk/parse.y#L7629 return tGVAR; } +static bool +parser_numbered_param(struct parser_params *p, unsigned long n) +{ + if (DVARS_TERMINAL_P(p->lvtbl->args) || DVARS_TERMINAL_P(p->lvtbl->args->prev)) { + compile_error(p, "numbered parameter outside block"); + return false; + } + if (p->max_numparam < 0) { + compile_error(p, "ordinary parameter is defined"); + return false; + } + set_yylval_num((int)n); + SET_LEX_STATE(EXPR_ARG); + return true; +} + static enum yytokentype parse_atmark(struct parser_params *p, const enum lex_state_e last_state) { @@ -7671,15 +7687,7 @@ parse_atmark(struct parser_params *p, co https://github.com/ruby/ruby/blob/trunk/parse.y#L7687 else if (overflow || n > NUMPARAM_MAX) { compile_error(p, "too large numbered parameter"); } - else if (DVARS_TERMINAL_P(p->lvtbl->args) || DVARS_TERMINAL_P(p->lvtbl->args->prev)) { - compile_error(p, "numbered parameter outside block"); - } - else if (p->max_numparam < 0) { - compile_error(p, "ordinary parameter is defined"); - } - else { - set_yylval_num((int)n); - SET_LEX_STATE(EXPR_ARG); + else if (parser_numbered_param(p, n)) { return tNUMPARAM; } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/