DSL: introduce x?y:z

This commit is contained in:
Alexander A. Klimov 2019-08-23 11:05:55 +02:00
parent b3eb9c6a07
commit 5c347ef7bd
1 changed files with 5 additions and 0 deletions

View File

@ -197,6 +197,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
%right T_INCLUDE T_INCLUDE_RECURSIVE T_INCLUDE_ZONES T_OBJECT T_TEMPLATE T_APPLY T_IMPORT T_ASSIGN T_IGNORE T_WHERE
%right T_FUNCTION T_FOR
%left T_SET T_SET_ADD T_SET_SUBTRACT T_SET_MULTIPLY T_SET_DIVIDE T_SET_MODULO T_SET_XOR T_SET_BINARY_AND T_SET_BINARY_OR
%right '?' ':'
%left T_LOGICAL_OR
%left T_LOGICAL_AND
%left T_RETURN T_BREAK T_CONTINUE
@ -831,6 +832,10 @@ rterm_side_effect: rterm '(' rterm_items ')'
$$ = new ConditionalExpression(std::unique_ptr<Expression>($3), std::unique_ptr<Expression>($5), std::move(afalse), @$);
}
| rterm '?' rterm ':' rterm
{
$$ = new ConditionalExpression(std::unique_ptr<Expression>($1), std::unique_ptr<Expression>($3), std::unique_ptr<Expression>($5), @$);
}
;
rterm_no_side_effect_no_dict: T_STRING