void compileExpression(void) { switch (lookAhead->tokenType) { case SB_PLUS: eat(SB_PLUS); compileExpression2(); break; case SB_MINUS: eat(SB_MINUS); compileExpression2(); break; default: compileExpression2(); } }
void compileExpression(void) { assert("Parsing an expression"); switch(lookAhead->tokenType){ case SB_PLUS: eat(SB_PLUS); compileExpression2(); break; case SB_MINUS: eat(SB_MINUS); compileExpression2(); break; default : compileExpression2(); break; } assert("Expression parsed"); }
Type* compileExpression(void) { Type* type; switch (lookAhead->tokenType) { case SB_PLUS: eat(SB_PLUS); type = compileExpression2(); checkIntType(type); break; case SB_MINUS: eat(SB_MINUS); type = compileExpression2(); checkIntType(type); break; default: type = compileExpression2(); } return type; }
Type* compileExpression(void) { // TODO: generate code for expression Type* type; switch (lookAhead->tokenType) { case SB_PLUS: eat(SB_PLUS); type = compileExpression2(); checkIntType(type); break; case SB_MINUS: eat(SB_MINUS); type = compileExpression2(); checkIntType(type); genNEG(); break; default: type = compileExpression2(); } return type; }
void compileExpression(void) { assert("Parsing an expression"); // TODO switch (lookAhead->tokenType) { case SB_PLUS: case SB_MINUS: eat(lookAhead->tokenType); compileExpression2(); break; case TK_IDENT: case TK_CHAR: case TK_NUMBER: case SB_LPAR: case TK_STRING: compileExpression2(); break; default: error(ERR_INVALIDEXPRESSION, lookAhead->lineNo, lookAhead->colNo); break; } assert("Expression parsed"); }