void compileConstant(void) { // TODO switch(lookAhead->tokenType){ case SB_PLUS: case SB_MINUS: eat(lookAhead->tokenType); compileConstant2(); break; case TK_IDENT: case TK_NUMBER: compileConstant2(); break; case TK_STRING: eat(TK_STRING); break; case TK_CHAR: eat(TK_CHAR); break; default: error(ERR_INVALIDCONSTANT,lookAhead->lineNo,lookAhead->colNo); break; } }
void compileConstant(void) { switch(lookAhead->tokenType){ case SB_PLUS: eat(SB_PLUS); compileConstant2(); break; case SB_MINUS: eat(SB_MINUS); compileConstant2(); break; case TK_CHAR: eat(TK_CHAR); break; default : compileConstant2(); break; } }
void compileConstant(void) { assert("Parsing a constant..."); // TODO switch(lookAhead->tokenType) { case SB_PLUS: eat(SB_PLUS); compileConstant2(); break; case SB_MINUS: eat(SB_MINUS); compileConstant2(); break; case TK_CHAR: eat(TK_CHAR); break; default: compileConstant2(); break; } assert("Constant parsed!"); }
ConstantValue* compileConstant(void) { ConstantValue* constValue; switch (lookAhead->tokenType) { case SB_PLUS: eat(SB_PLUS); constValue = compileConstant2(); break; case SB_MINUS: eat(SB_MINUS); constValue = compileConstant2(); constValue->intValue = - constValue->intValue; break; case TK_CHAR: eat(TK_CHAR); constValue = makeCharConstant(currentToken->string[0]); break; default: constValue = compileConstant2(); break; } return constValue; }