Allow if/else in rterms

refs #8074
This commit is contained in:
Gunnar Beutner 2014-12-14 14:08:41 +01:00
parent b40e95d9b6
commit 262bfb7fc9
1 changed files with 18 additions and 18 deletions

View File

@ -141,8 +141,8 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
%token T_LESS_THAN "< (T_LESS_THAN)"
%token T_GREATER_THAN "> (T_GREATER_THAN)"
%token T_CONST "const (T_CONST)"
%token T_LOCAL "local (T_LOCAL)"
%token T_GLOBAL "global (T_GLOBAL)"
%token T_USE "use (T_USE)"
%token <type> T_TYPE_DICTIONARY "dictionary (T_TYPE_DICTIONARY)"
%token <type> T_TYPE_ARRAY "array (T_TYPE_ARRAY)"
@ -642,23 +642,6 @@ lterm: type
$$ = new ForExpression($3, "", $5, aexpr, DebugInfoRange(@1, @7));
free($3);
}
| T_IF '(' rterm ')' rterm_scope
{
DictExpression *atrue = dynamic_cast<DictExpression *>($5);
atrue->MakeInline();
$$ = new ConditionalExpression($3, atrue, NULL, DebugInfoRange(@1, @5));
}
| T_IF '(' rterm ')' rterm_scope T_ELSE rterm_scope
{
DictExpression *atrue = dynamic_cast<DictExpression *>($5);
atrue->MakeInline();
DictExpression *afalse = dynamic_cast<DictExpression *>($7);
afalse->MakeInline();
$$ = new ConditionalExpression($3, atrue, afalse, DebugInfoRange(@1, @7));
}
| T_FUNCTION identifier '(' identifier_items ')' use_specifier rterm_scope
{
DictExpression *aexpr = dynamic_cast<DictExpression *>($7);
@ -864,6 +847,23 @@ rterm: T_STRING
$$ = new FunctionExpression(*$2, new std::map<String, Expression *>(), $5, DebugInfoRange(@1, @5));
delete $2;
}
| T_IF '(' rterm ')' rterm_scope
{
DictExpression *atrue = dynamic_cast<DictExpression *>($5);
atrue->MakeInline();
$$ = new ConditionalExpression($3, atrue, NULL, DebugInfoRange(@1, @5));
}
| T_IF '(' rterm ')' rterm_scope T_ELSE rterm_scope
{
DictExpression *atrue = dynamic_cast<DictExpression *>($5);
atrue->MakeInline();
DictExpression *afalse = dynamic_cast<DictExpression *>($7);
afalse->MakeInline();
$$ = new ConditionalExpression($3, atrue, afalse, DebugInfoRange(@1, @7));
}
;
target_type_specifier: /* empty */