예제 #1
0
void compileExpression(void) {
    switch (lookAhead->tokenType) {
    case SB_PLUS:
        eat(SB_PLUS);
        compileExpression2();
        break;
    case SB_MINUS:
        eat(SB_MINUS);
        compileExpression2();
        break;
    default:
        compileExpression2();
    }
}
예제 #2
0
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");
}
예제 #3
0
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;
}
예제 #4
0
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;
}
예제 #5
0
파일: parser.c 프로젝트: BichVN/Compiler
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");
}