- allow multiple expressions in 'for' iteration part.

This commit is contained in:
Christoph Oelckers 2017-03-29 22:18:52 +02:00
parent b38934b532
commit 3f9ad55432
2 changed files with 10 additions and 1 deletions

View file

@ -1859,6 +1859,7 @@ for_init(X) ::= for_bump(A). { X = A /*X-overwrites-A*/; }
%type for_bump{ZCC_Statement *} %type for_bump{ZCC_Statement *}
for_bump(X) ::= . { X = NULL; } for_bump(X) ::= . { X = NULL; }
for_bump(X) ::= expression_statement(A). { X = A; /*X-overwrites-A*/ } for_bump(X) ::= expression_statement(A). { X = A; /*X-overwrites-A*/ }
for_bump(X) ::= for_bump(A) COMMA expression_statement(B). { X = A; /*X-overwrites-A*/ AppendTreeNodeSibling(X, B); }
/*----- If Statements -----*/ /*----- If Statements -----*/

View file

@ -3482,7 +3482,15 @@ FxExpression *ZCCCompiler::ConvertNode(ZCC_TreeNode *ast)
} }
else if (iter->LoopBumper != nullptr) else if (iter->LoopBumper != nullptr)
{ {
return new FxForLoop(nullptr, ConvertNode(iter->LoopCondition), ConvertNode(iter->LoopBumper), ConvertNode(iter->LoopStatement), *ast); FArgumentList bumper;
ConvertNodeList(bumper, iter->LoopBumper);
FxCompoundStatement *bumps = new FxCompoundStatement(*ast);
for (auto &ex : bumper)
{
bumps->Add(ex);
ex = nullptr;
}
return new FxForLoop(nullptr, ConvertNode(iter->LoopCondition), bumps, ConvertNode(iter->LoopStatement), *ast);
} }
else else
{ {