Skip to content
Snippets Groups Projects
Verified Commit 6cf9a410 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

macro processor: oblige parens for tuple passed as variable in for loop

parent a3e63101
No related branches found
No related tags found
No related merge requests found
Pipeline #1435 passed
...@@ -152,10 +152,19 @@ directive_multiline : for ...@@ -152,10 +152,19 @@ directive_multiline : for
{ $$ = $1; } { $$ = $1; }
; ;
for : FOR { driver.pushContext(); } comma_name IN expr EOL statements ENDFOR for : FOR { driver.pushContext(); } NAME IN expr EOL statements ENDFOR
{
vector<VariablePtr> vvnp = {make_shared<Variable>($3, driver.env, @3)};
auto vdp = driver.popContext();
vdp.emplace_back(make_shared<TextNode>("\n", driver.env, @8));
$$ = make_shared<For>(vvnp, $5, vdp, driver.env, @$);
}
;
for : FOR { driver.pushContext(); } LPAREN comma_name RPAREN IN expr EOL statements ENDFOR
{ {
vector<VariablePtr> vvnp; vector<VariablePtr> vvnp;
for (auto & it : $3) for (auto & it : $4)
{ {
auto vnp = dynamic_pointer_cast<Variable>(it); auto vnp = dynamic_pointer_cast<Variable>(it);
if (!vnp) if (!vnp)
...@@ -163,8 +172,8 @@ for : FOR { driver.pushContext(); } comma_name IN expr EOL statements ENDFOR ...@@ -163,8 +172,8 @@ for : FOR { driver.pushContext(); } comma_name IN expr EOL statements ENDFOR
vvnp.push_back(vnp); vvnp.push_back(vnp);
} }
auto vdp = driver.popContext(); auto vdp = driver.popContext();
vdp.emplace_back(make_shared<TextNode>("\n", driver.env, @8)); vdp.emplace_back(make_shared<TextNode>("\n", driver.env, @10));
$$ = make_shared<For>(vvnp, $5, vdp, driver.env, @$); $$ = make_shared<For>(vvnp, $7, vdp, driver.env, @$);
} }
; ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment