Fix parsing of 'launch' so that angle brackets can be removed.
Issue #6.
This commit is contained in:
61
parse.yy
61
parse.yy
@@ -194,7 +194,7 @@ struct ForeachDimension {
|
||||
%token TOKEN_CCONTINUE TOKEN_CRETURN TOKEN_SYNC TOKEN_PRINT TOKEN_ASSERT
|
||||
|
||||
%type <expr> primary_expression postfix_expression
|
||||
%type <expr> unary_expression cast_expression launch_expression
|
||||
%type <expr> unary_expression cast_expression funcall_expression launch_expression
|
||||
%type <expr> multiplicative_expression additive_expression shift_expression
|
||||
%type <expr> relational_expression equality_expression and_expression
|
||||
%type <expr> exclusive_or_expression inclusive_or_expression
|
||||
@@ -302,20 +302,45 @@ primary_expression
|
||||
;
|
||||
|
||||
launch_expression
|
||||
: TOKEN_LAUNCH '<' postfix_expression '(' argument_expression_list ')' '>'
|
||||
: TOKEN_LAUNCH postfix_expression '(' argument_expression_list ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @3);
|
||||
$$ = new FunctionCallExpr($3, $5, Union(@3, @6), true, oneExpr);
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @2);
|
||||
$$ = new FunctionCallExpr($2, $4, Union(@2, @5), true, oneExpr);
|
||||
}
|
||||
| TOKEN_LAUNCH '<' postfix_expression '(' ')' '>'
|
||||
| TOKEN_LAUNCH postfix_expression '(' ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @3);
|
||||
$$ = new FunctionCallExpr($3, new ExprList(Union(@4,@5)), Union(@3, @5), true, oneExpr);
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @2);
|
||||
$$ = new FunctionCallExpr($2, new ExprList(Union(@3,@4)), Union(@2, @4), true, oneExpr);
|
||||
}
|
||||
| TOKEN_LAUNCH '[' expression ']' postfix_expression '(' argument_expression_list ')'
|
||||
{ $$ = new FunctionCallExpr($5, $7, Union(@5,@8), true, $3); }
|
||||
| TOKEN_LAUNCH '[' expression ']' postfix_expression '(' ')'
|
||||
{ $$ = new FunctionCallExpr($5, new ExprList(Union(@5,@6)), Union(@5,@7), true, $3); }
|
||||
|
||||
| TOKEN_LAUNCH '<' postfix_expression '(' argument_expression_list ')' '>'
|
||||
{
|
||||
Error(Union(@2, @7), "\"launch\" expressions no longer take '<' '>' "
|
||||
"around function call expression.");
|
||||
$$ = NULL;
|
||||
}
|
||||
| TOKEN_LAUNCH '<' postfix_expression '(' ')' '>'
|
||||
{
|
||||
Error(Union(@2, @6), "\"launch\" expressions no longer take '<' '>' "
|
||||
"around function call expression.");
|
||||
$$ = NULL;
|
||||
}
|
||||
| TOKEN_LAUNCH '[' expression ']' '<' postfix_expression '(' argument_expression_list ')' '>'
|
||||
{ $$ = new FunctionCallExpr($6, $8, Union(@6,@9), true, $3); }
|
||||
{
|
||||
Error(Union(@5, @10), "\"launch\" expressions no longer take '<' '>' "
|
||||
"around function call expression.");
|
||||
$$ = NULL;
|
||||
}
|
||||
| TOKEN_LAUNCH '[' expression ']' '<' postfix_expression '(' ')' '>'
|
||||
{ $$ = new FunctionCallExpr($6, new ExprList(Union(@6,@7)), Union(@6,@8), true, $3); }
|
||||
{
|
||||
Error(Union(@5, @9), "\"launch\" expressions no longer take '<' '>' "
|
||||
"around function call expression.");
|
||||
$$ = NULL;
|
||||
}
|
||||
;
|
||||
|
||||
postfix_expression
|
||||
@@ -324,12 +349,6 @@ postfix_expression
|
||||
{ $$ = new IndexExpr($1, $3, Union(@1,@4)); }
|
||||
| postfix_expression '[' error ']'
|
||||
{ $$ = NULL; }
|
||||
| postfix_expression '(' ')'
|
||||
{ $$ = new FunctionCallExpr($1, new ExprList(Union(@1,@2)), Union(@1,@3)); }
|
||||
| postfix_expression '(' argument_expression_list ')'
|
||||
{ $$ = new FunctionCallExpr($1, $3, Union(@1,@4)); }
|
||||
| postfix_expression '(' error ')'
|
||||
{ $$ = NULL; }
|
||||
| launch_expression
|
||||
| postfix_expression '.' TOKEN_IDENTIFIER
|
||||
{ $$ = MemberExpr::create($1, yytext, Union(@1,@3), @3, false); }
|
||||
@@ -341,6 +360,16 @@ postfix_expression
|
||||
{ $$ = new UnaryExpr(UnaryExpr::PostDec, $1, Union(@1,@2)); }
|
||||
;
|
||||
|
||||
funcall_expression
|
||||
: postfix_expression
|
||||
| postfix_expression '(' ')'
|
||||
{ $$ = new FunctionCallExpr($1, new ExprList(Union(@1,@2)), Union(@1,@3)); }
|
||||
| postfix_expression '(' argument_expression_list ')'
|
||||
{ $$ = new FunctionCallExpr($1, $3, Union(@1,@4)); }
|
||||
| postfix_expression '(' error ')'
|
||||
{ $$ = NULL; }
|
||||
;
|
||||
|
||||
argument_expression_list
|
||||
: assignment_expression { $$ = new ExprList($1, @1); }
|
||||
| argument_expression_list ',' assignment_expression
|
||||
@@ -357,7 +386,7 @@ argument_expression_list
|
||||
;
|
||||
|
||||
unary_expression
|
||||
: postfix_expression
|
||||
: funcall_expression
|
||||
| TOKEN_INC_OP unary_expression
|
||||
{ $$ = new UnaryExpr(UnaryExpr::PreInc, $2, Union(@1, @2)); }
|
||||
| TOKEN_DEC_OP unary_expression
|
||||
|
||||
Reference in New Issue
Block a user