parse.y: moved pipeline to expr

To allow arguments without parentheses.
This commit is contained in:
Nobuyoshi Nakada 2019-06-13 22:03:10 +09:00
Родитель f169043d81
Коммит 043f010c28
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4BC7D6DF58D8DF60
2 изменённых файлов: 32 добавлений и 18 удалений

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