diff options
| author | ydah <t.yudai92@gmail.com> | 2025-04-14 02:13:58 +0900 |
|---|---|---|
| committer | Yudai Takada <t.yudai92@gmail.com> | 2025-04-14 03:01:01 +0900 |
| commit | 088fd968ed8af169964bed47cde2b25b58004396 (patch) | |
| tree | 816a068f74f9c1efcb5bd8fec378d4b88c8c67ee /parse.y | |
| parent | e9966998200ba4786f5b6912047832c8889999bd (diff) | |
Add a new non-terminal symbol `ternary` to tidy up
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13110
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -2764,7 +2764,7 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary) %type <node_def_temp> defn_head defs_head k_def %type <node_exits> block_open k_while k_until k_for allow_exits %type <node> top_stmts top_stmt begin_block endless_arg endless_command -%type <node> bodystmt stmts stmt_or_begin stmt expr arg primary +%type <node> bodystmt stmts stmt_or_begin stmt expr arg ternary primary %type <node> command command_call command_call_value method_call %type <node> expr_value expr_value_do arg_value primary_value rel_expr %type <node_fcall> fcall @@ -4039,15 +4039,18 @@ arg : asgn(arg_rhs) $$ = new_defined(p, $4, &@$); /*% ripper: defined!($:4) %*/ } - | arg '?' arg '\n'? ':' arg + | def_endless_method(endless_arg) + | ternary + | primary + ; + +ternary : arg '?' arg '\n'? ':' arg { value_expr($1); $$ = new_if(p, $1, $3, $6, &@$, &NULL_LOC, &@5, &NULL_LOC); fixpos($$, $1); /*% ripper: ifop!($:1, $:3, $:6) %*/ } - | def_endless_method(endless_arg) - | primary ; endless_arg : arg %prec modifier_rescue |
