Tweaked parser to allow implicit conversion of type checks to bool
This commit is contained in:
parent
473af8d54e
commit
eab4d51f25
|
@ -139,6 +139,8 @@ enum SyntaxOps {
|
|||
OP_BITNOT, // Invert a number bitwise
|
||||
OP_BOOLNOT, // Invert a statement
|
||||
|
||||
OP_BOOLCONV, // Convert an expression to a boolean.s
|
||||
|
||||
OP_ADDRESS, // Fetch the address of a var
|
||||
OP_DEREF, // Get the value of the address in a pointer
|
||||
|
||||
|
|
|
@ -227,8 +227,9 @@ struct ASTNode* WhileStatement() {
|
|||
|
||||
Condition = ParsePrecedenceASTNode(0);
|
||||
|
||||
|
||||
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, ")");
|
||||
|
||||
|
@ -257,7 +258,8 @@ struct ASTNode* ForStatement() {
|
|||
Condition = ParsePrecedenceASTNode(0);
|
||||
|
||||
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, ";");
|
||||
|
||||
Postop = ParseStatement();
|
||||
|
|
Loading…
Reference in New Issue
Block a user