AST: Handle ternary operators
This commit is contained in:
parent
de29991c11
commit
dde46527f3
|
@ -566,16 +566,26 @@ static void compileLogicOr(Token *&tok, std::stack<Token*> &op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compileAssign(Token *&tok, std::stack<Token*> &op)
|
static void compileTernaryOp(Token *&tok, std::stack<Token*> &op)
|
||||||
{
|
{
|
||||||
compileLogicOr(tok,op);
|
compileLogicOr(tok,op);
|
||||||
while (tok) {
|
while (tok) {
|
||||||
if (tok->str() == "=") {
|
if (Token::Match(tok, "[?:]")) {
|
||||||
compileBinOp(tok, compileLogicOr, op);
|
compileBinOp(tok, compileLogicOr, op);
|
||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void compileAssign(Token *&tok, std::stack<Token*> &op)
|
||||||
|
{
|
||||||
|
compileTernaryOp(tok,op);
|
||||||
|
while (tok) {
|
||||||
|
if (tok->str() == "=") {
|
||||||
|
compileBinOp(tok, compileTernaryOp, op);
|
||||||
|
} else break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void compileComma(Token *&tok, std::stack<Token*> &op)
|
static void compileComma(Token *&tok, std::stack<Token*> &op)
|
||||||
{
|
{
|
||||||
compileAssign(tok,op);
|
compileAssign(tok,op);
|
||||||
|
|
Loading…
Reference in New Issue