void compileFactor(void) { // TODO switch (lookAhead->tokenType) { case TK_NUMBER: case TK_CHAR: compileUnsignedConstant(); break; case SB_LPAR: eat(SB_LPAR); compileExpression(); eat(SB_RPAR); break; case TK_IDENT: eat(TK_IDENT); switch(lookAhead->tokenType) { case SB_LSEL: compileIndexes(); break; case SB_LPAR: compileArguments(); break; default: break; } break; default: error(ERR_INVALIDFACTOR, lookAhead->lineNo, lookAhead->colNo); break; } }
void compileFactor(void) { // TODO Token *tmp=lookAhead; //de chuyen tiep lookAhead o duoi switch(tmp->tokenType) { case TK_NUMBER: case TK_CHAR: compileUnsignedConstant(); break; case SB_LPAR: eat(SB_LPAR); compileExpression(); eat(SB_RPAR); break; case TK_IDENT: eat(TK_IDENT); if(lookAhead->tokenType==SB_LPAR) { compileArguments(); } else if(lookAhead->tokenType==SB_LSEL) { compileIndexes(); } //else //compileUnsignedConstant(); break; default: error(ERR_INVALIDFACTOR, lookAhead->lineNo, lookAhead->colNo); break; } //free(tmp); }
void compileFactor(void) { if(lookAhead->tokenType == TK_NUMBER || lookAhead->tokenType == TK_CHAR ){ compileUnsignedConstant(); } else if (lookAhead->tokenType == TK_IDENT){ eat(TK_IDENT); if( lookAhead->tokenType == SB_LSEL){ compileIndexes(); } else if(lookAhead->tokenType == SB_LPAR){ compileArguments(); } } else if(lookAhead->tokenType == SB_LPAR){ eat(SB_LPAR); compileExpression(); eat(SB_RPAR); } else error(ERR_INVALIDFACTOR, lookAhead->lineNo, lookAhead->colNo); }