ast: fixed hang for weird loop: 'for (each_window(list,p))'

This commit is contained in:
Daniel Marjamäki 2014-01-16 16:58:50 +01:00
parent fb4695fcb4
commit 85b73f7c24
2 changed files with 3 additions and 2 deletions

View File

@ -699,14 +699,14 @@ void TokenList::createAst()
init1 = tok2;
std::stack<Token *> operands;
compileExpression(tok2, operands);
if (tok2->str() == ";")
if (tok2->str() == ";" || tok2->str() == ")")
break;
init1 = 0;
}
tok2 = tok2->next();
}
if (!tok2 || tok2->str() != ";") {
tok = tok->next();
tok = tok2;
continue;
}

View File

@ -10103,6 +10103,7 @@ private:
ASSERT_EQUALS("for;;(", testAst("for(;;)"));
ASSERT_EQUALS("fora0=a8<a++;;(", testAst("for(a=0;a<8;a++)"));
TODO_ASSERT_EQUALS("fori1=current0=,iNUM<=i++;;(", "fori1=current0=,i<NUM=i++;;(", testAst("for(i = (1), current = 0; i <= (NUM); ++i)"));
ASSERT_EQUALS("eachxy,(", testAst("for(each(x,y)){}")); // it's not well-defined what this ast should be
}
void astpar() const { // parentheses