Tweaked parser to allow implicit conversion of type checks to bool
This commit is contained in:
parent
473af8d54e
commit
eab4d51f25
|
@ -138,6 +138,8 @@ enum SyntaxOps {
|
||||||
|
|
||||||
OP_BITNOT, // Invert a number bitwise
|
OP_BITNOT, // Invert a number bitwise
|
||||||
OP_BOOLNOT, // Invert a statement
|
OP_BOOLNOT, // Invert a statement
|
||||||
|
|
||||||
|
OP_BOOLCONV, // Convert an expression to a boolean.s
|
||||||
|
|
||||||
OP_ADDRESS, // Fetch the address of a var
|
OP_ADDRESS, // Fetch the address of a var
|
||||||
OP_DEREF, // Get the value of the address in a pointer
|
OP_DEREF, // Get the value of the address in a pointer
|
||||||
|
|
|
@ -227,8 +227,9 @@ struct ASTNode* WhileStatement() {
|
||||||
|
|
||||||
Condition = ParsePrecedenceASTNode(0);
|
Condition = ParsePrecedenceASTNode(0);
|
||||||
|
|
||||||
|
|
||||||
if(Condition->Operation < OP_EQUAL || Condition->Operation > OP_GREATE)
|
if(Condition->Operation < OP_EQUAL || Condition->Operation > OP_GREATE)
|
||||||
Die("Bad Comparison inside while()");
|
Condition = ConstructASTBranch(OP_BOOLCONV, Condition->ExprType, Condition, 0);
|
||||||
|
|
||||||
VerifyToken(LI_RPARE, ")");
|
VerifyToken(LI_RPARE, ")");
|
||||||
|
|
||||||
|
@ -257,7 +258,8 @@ struct ASTNode* ForStatement() {
|
||||||
Condition = ParsePrecedenceASTNode(0);
|
Condition = ParsePrecedenceASTNode(0);
|
||||||
|
|
||||||
if(Condition->Operation < OP_EQUAL || Condition->Operation > OP_GREATE)
|
if(Condition->Operation < OP_EQUAL || Condition->Operation > OP_GREATE)
|
||||||
Die("Bad comparison in for");
|
Condition = ConstructASTBranch(OP_BOOLCONV, Condition->ExprType, Condition, 0);
|
||||||
|
|
||||||
VerifyToken(LI_SEMIC, ";");
|
VerifyToken(LI_SEMIC, ";");
|
||||||
|
|
||||||
Postop = ParseStatement();
|
Postop = ParseStatement();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user