AST: handle concatening of strings better. this is not ideal but better.
This commit is contained in:
parent
64b72bd6e5
commit
35eb1a393d
|
@ -517,7 +517,9 @@ static void compileTerm(Token *&tok, AST_state& state)
|
|||
|
||||
if (tok->isLiteral()) {
|
||||
state.op.push(tok);
|
||||
tok = tok->next();
|
||||
do {
|
||||
tok = tok->next();
|
||||
} while (Token::Match(tok, "%name%|%str%"));
|
||||
} else if (tok->isName() && tok->str() != "case") {
|
||||
if (tok->str() == "return") {
|
||||
compileUnaryOp(tok, state, compileExpression);
|
||||
|
@ -529,9 +531,13 @@ static void compileTerm(Token *&tok, AST_state& state)
|
|||
while (tok->next() && tok->next()->isName())
|
||||
tok = tok->next();
|
||||
state.op.push(tok);
|
||||
if (tok->next() && tok->linkAt(1) && Token::Match(tok, "%name% <"))
|
||||
if (Token::Match(tok, "%name% <") && tok->linkAt(1))
|
||||
tok = tok->linkAt(1);
|
||||
tok = tok->next();
|
||||
if (Token::Match(tok, "%str%")) {
|
||||
while (Token::Match(tok, "%name%|%str%"))
|
||||
tok = tok->next();
|
||||
}
|
||||
}
|
||||
} else if (tok->str() == "{") {
|
||||
if (!state.inArrayAssignment && tok->strAt(-1) != "=") {
|
||||
|
|
|
@ -8431,6 +8431,10 @@ private:
|
|||
|
||||
ASSERT_EQUALS("a*b***", testAst("*a * **b;")); // Correctly distinguish between unary and binary operator*
|
||||
|
||||
// strings
|
||||
ASSERT_EQUALS("f\"A\"1,(",testAst("f(\"A\" B, 1);"));
|
||||
ASSERT_EQUALS("fA1,(",testAst("f(A \"B\", 1);"));
|
||||
|
||||
// for
|
||||
ASSERT_EQUALS("for;;(", testAst("for(;;)"));
|
||||
ASSERT_EQUALS("fora0=a8<a++;;(", testAst("for(a=0;a<8;a++)"));
|
||||
|
|
Loading…
Reference in New Issue