зеркало из https://github.com/github/ruby.git
parse.y: moved pipeline to expr
To allow arguments without parentheses.
This commit is contained in:
Родитель
f169043d81
Коммит
043f010c28
48
parse.y
48
parse.y
|
@ -1496,6 +1496,37 @@ expr : command_call
|
|||
$$ = call_uni_op(p, method_cond(p, $2, &@2), '!', &@1, &@$);
|
||||
}
|
||||
| arg
|
||||
| pipeline
|
||||
;
|
||||
|
||||
pipeline : expr tPIPE operation2 opt_paren_args
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, Qnull, &@3, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
|
||||
}
|
||||
| expr tPIPE operation2 opt_paren_args brace_block
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, $5, &@3, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: method_add_block!(command_call!($1, ID2VAL(idPIPE), $3, $4), $5) %*/
|
||||
}
|
||||
| expr tPIPE operation2 command_args
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, Qnull, &@3, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
|
||||
}
|
||||
| expr tPIPE operation2 command_args do_block
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, $5, &@3, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: method_add_block!(command_call!($1, ID2VAL(idPIPE), $3, $4), $5) %*/
|
||||
}
|
||||
;
|
||||
|
||||
expr_value : expr
|
||||
|
@ -2271,29 +2302,12 @@ arg : lhs '=' arg_rhs
|
|||
/*% %*/
|
||||
/*% ripper: ifop!($1, $3, $6) %*/
|
||||
}
|
||||
| pipeline
|
||||
| primary
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
pipeline : arg tPIPE operation2 opt_paren_args
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, Qnull, &@3, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
|
||||
}
|
||||
| arg tPIPE operation2 opt_paren_args brace_block
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, $5, &@3, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: method_add_block!(command_call!($1, ID2VAL(idPIPE), $3, $4), $5) %*/
|
||||
}
|
||||
;
|
||||
|
||||
relop : '>' {$$ = '>';}
|
||||
| '<' {$$ = '<';}
|
||||
| tGEQ {$$ = idGE;}
|
||||
|
|
|
@ -1382,7 +1382,7 @@ eom
|
|||
def test_pipeline_operator
|
||||
assert_valid_syntax('x |> y')
|
||||
x = nil
|
||||
assert_equal("121", eval('x = 12 |> pow(2) |> to_s(11)'))
|
||||
assert_equal("121", eval('x = 12 |> pow(2) |> to_s 11'))
|
||||
assert_equal(12, x)
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче