AST: Fixed 'a[1][2]'
This commit is contained in:
parent
7fe51eb58b
commit
673400920d
|
@ -436,13 +436,21 @@ static void compileTerm(Token *& tok, std::stack<Token*> &op)
|
||||||
name->next()->astOperand1(name);
|
name->next()->astOperand1(name);
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
} else {
|
} else {
|
||||||
compileExpression(tok,op);
|
Token *prev = name;
|
||||||
tok = tok->next(); // skip ')' or ']'
|
tok = tok->previous();
|
||||||
|
while (Token::Match(tok, "(|[")) {
|
||||||
|
Token *tok1 = tok;
|
||||||
|
tok = tok->next();
|
||||||
|
compileExpression(tok, op);
|
||||||
if (!op.empty()) {
|
if (!op.empty()) {
|
||||||
name->next()->astOperand2(op.top());
|
tok1->astOperand2(op.top());
|
||||||
op.pop();
|
op.pop();
|
||||||
}
|
}
|
||||||
name->next()->astOperand1(name);
|
tok1->astOperand1(prev);
|
||||||
|
prev = tok1;
|
||||||
|
if (Token::Match(tok, "]|)"))
|
||||||
|
tok = tok->next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
op.push(name->next());
|
op.push(name->next());
|
||||||
}
|
}
|
||||||
|
|
|
@ -9985,6 +9985,7 @@ private:
|
||||||
|
|
||||||
void astbrackets() const { // []
|
void astbrackets() const { // []
|
||||||
ASSERT_EQUALS("a23+[4+", testAst("a[2+3]+4"));
|
ASSERT_EQUALS("a23+[4+", testAst("a[2+3]+4"));
|
||||||
|
ASSERT_EQUALS("a1[0[", testAst("a[1][0]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void astunaryop() const { // unary operators
|
void astunaryop() const { // unary operators
|
||||||
|
|
Loading…
Reference in New Issue