diff --git a/include/Defs.h b/include/Defs.h index 08b676a..4052a51 100644 --- a/include/Defs.h +++ b/include/Defs.h @@ -138,6 +138,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 diff --git a/src/Statements.c b/src/Statements.c index 6e8396c..32a7de9 100644 --- a/src/Statements.c +++ b/src/Statements.c @@ -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();