예제 #1
0
void compileStatements(void) {
  compileStatement();
  while (lookAhead->tokenType == SB_SEMICOLON) {
    eat(SB_SEMICOLON);
    compileStatement();
  }
}
예제 #2
0
파일: parser.c 프로젝트: BichVN/Compiler
void compileDoWhileSt(void) {
  assert("Parsing a do..while statement ....");
  // TODO
    eat(KW_DO); 
    compileStatement();  
    eat(KW_WHILE);
    compileCondition();  

  assert("Do..While statement parsed ....");
void compileForSt(void) {
  Type* varType;
  Type *type;

  eat(KW_FOR);

  varType = compileLValue();
  eat(SB_ASSIGN);
  type = compileExpression();
  checkTypeEquality(varType, type);

  eat(KW_TO);
  type = compileExpression();
  checkTypeEquality(varType, type);

  eat(KW_DO);
  compileStatement();

}
예제 #3
0
파일: parser.c 프로젝트: BichVN/Compiler
void compileIfSt(void) {
  eat(KW_IF);
  compileCondition();
  eat(KW_THEN);
  compileStatement();
  if (lookAhead->tokenType == KW_ELSE) {
    eat(KW_ELSE);
    compileStatement();
  }
}
예제 #4
0
void compileWhileSt(void) {
  assert("Parsing a while statement ....");
  eat(KW_WHILE);
  compileCondition();
  eat(KW_DO);
  compileStatement();
  assert("While statement pased ....");
}
예제 #5
0
int CppSQLite3DB::insertBlob(const CString& szSQL, const unsigned char *data, int dataLength)
{
    CppSQLite3Statement statement = compileStatement(szSQL);

    statement.bind(1, data, dataLength);

    return statement.execDML();
}
예제 #6
0
void compileForSt(void) {
    eat(KW_FOR);
    eat(TK_IDENT);
    eat(SB_ASSIGN);
    compileExpression();
    eat(KW_TO);
    compileExpression();
    eat(KW_DO);
    compileStatement();
}
예제 #7
0
파일: parser.c 프로젝트: minh93/thctd
void compileWhileSt(void) {
  assert("Parsing a while statement ....");
  // TODO
  eat(KW_WHILE);
  compileCondition();
  eat(KW_DO);
  compileStatement();
  //chu y check lai cho nay
  assert("While statement parsed ....");
}
예제 #8
0
int CppSQLite3DB::updateBlob(const CString& szTableName, const CString& szFieldName, const unsigned char* data, int dataLength, const CString& szWhere)
{

    CString sql = CString("update ") + szTableName + " set " + szFieldName + "=? where " + szWhere;

    CppSQLite3Statement statement = compileStatement(sql);
    statement.bind(1, data, dataLength);

    return statement.execDML();
}
예제 #9
0
파일: parser.c 프로젝트: BichVN/Compiler
void compileIfSt(void) {
  assert("Parsing an if statement ....");
  eat(KW_IF);
  compileCondition();
  eat(KW_THEN);
  compileStatement();
  if (lookAhead->tokenType == KW_ELSE)
    compileElseSt();
  assert("If statement parsed ....");
}
예제 #10
0
파일: parser.c 프로젝트: BichVN/Compiler
void compileDoWhileSt(void) {
  assert("Parsing a do..while statement ....");
  // TODO
    eat(KW_DO); 
    compileStatement();  
    eat(KW_WHILE);
    compileCondition();  

  assert("Do..While statement parsed ....");
}
예제 #11
0
파일: parser.c 프로젝트: minh93/thctd
void compileStatements2(void) {
  // TODO
  if(lookAhead->tokenType==SB_SEMICOLON)
    {
      eat(SB_SEMICOLON);
      compileStatement();
      compileStatements2();
    }
  else if(lookAhead->tokenType!=KW_END)
    eat(SB_SEMICOLON);
}
예제 #12
0
파일: parser.c 프로젝트: kiendt07/ctd
void compileIfSt(void) {
  Instruction* fjInstruction;
  Instruction* jInstruction;

  eat(KW_IF);
  compileCondition();
  eat(KW_THEN);

  fjInstruction = genFJ(DC_VALUE);
  compileStatement();
  if (lookAhead->tokenType == KW_ELSE) {
    jInstruction = genJ(DC_VALUE);
    updateFJ(fjInstruction, getCurrentCodeAddress());
    eat(KW_ELSE);
    compileStatement();
    updateJ(jInstruction, getCurrentCodeAddress());
  } else {
    updateFJ(fjInstruction, getCurrentCodeAddress());
  }
}
예제 #13
0
void compileForSt(void) {
  assert("Parsing a for statement ....");
        eat(KW_FOR);
        eat(TK_IDENT);
        eat(SB_ASSIGN);
        compileExpression();
        eat(KW_TO);
        compileExpression();
        eat(KW_DO);
        compileStatement();
  assert("For statement parsed ....");
}
예제 #14
0
파일: parser.c 프로젝트: kiendt07/ctd
void compileWhileSt(void) {
  CodeAddress beginWhile;
  Instruction* fjInstruction;

  beginWhile = getCurrentCodeAddress();
  eat(KW_WHILE);
  compileCondition();
  fjInstruction = genFJ(DC_VALUE);
  eat(KW_DO);
  compileStatement();
  genJ(beginWhile);
  updateFJ(fjInstruction, getCurrentCodeAddress());
}
예제 #15
0
파일: parser.c 프로젝트: BichVN/Compiler
void compileForSt(void) {
  eat(KW_FOR);
  eat(TK_IDENT);

  // TODO: check if the identifier is a variable

  eat(SB_ASSIGN);
  compileExpression();

  eat(KW_TO);
  compileExpression();

  eat(KW_DO);
  compileStatement();
}
예제 #16
0
파일: parser.c 프로젝트: BichVN/Compiler
void compileStatements2(void) {
  // TODO
    switch(lookAhead->tokenType){
        case SB_SEMICOLON:
            eat(SB_SEMICOLON);
            compileStatement();
            compileStatements2();
            break;
        case KW_END:
            break;
        default:
           missingToken(SB_SEMICOLON,lookAhead->lineNo,lookAhead->colNo);
        break;

        }
}
예제 #17
0
void compileForSt(void) {
  eat(KW_FOR);
  eat(TK_IDENT);

  // TODO: check if the identifier is a variable
  checkDeclaredVariable(currentToken->string);

  eat(SB_ASSIGN);
  compileExpression();

  eat(KW_TO);
  compileExpression();

  eat(KW_DO);
  compileStatement();
}
예제 #18
0
void compileForSt(void) {
  eat(KW_FOR);
  eat(TK_IDENT);

  // check if the identifier is a variable
  if (checkDeclaredVariable(currentToken->string) == NULL)
      error(ERR_UNDECLARED_VARIABLE, currentToken->lineNo, currentToken->colNo);

  eat(SB_ASSIGN);
  compileExpression();

  eat(KW_TO);
  compileExpression();

  eat(KW_DO);
  compileStatement();
}
예제 #19
0
파일: parser.c 프로젝트: kiendt07/ctd
void compileStatements2(void) {
  // TODO
  switch (lookAhead->tokenType) {
  case SB_SEMICOLON:
      eat(SB_SEMICOLON);
      compileStatement();
      compileStatements2();
      break;
  // Follow
  case KW_END:
      break;
  // Error
  default:
      error(ERR_INVALIDSTATEMENT, lookAhead->lineNo, lookAhead->colNo);
      break;
  }
}
예제 #20
0
파일: parser.c 프로젝트: NPHiep/Compiler
void compileForSt(void) {
  // DONE: Check type consistency of FOR's variable
  Type* varType;
  Type *type;

  eat(KW_FOR);
  varType = compileLValue();

  eat(SB_ASSIGN);
  type = compileExpression();
  checkTypeEquality(varType, type);

  eat(KW_TO);
  type = compileExpression();
  checkTypeEquality(varType, type);

  eat(KW_DO);
  compileStatement();
}
예제 #21
0
파일: parser.c 프로젝트: kiendt07/ctd
void compileForSt(void) {
  CodeAddress beginLoop;
  Instruction* fjInstruction;
  Type* varType;
  Type *type;

  eat(KW_FOR);

  varType = compileLValue();
  eat(SB_ASSIGN);

  genCV();
  type = compileExpression();
  checkTypeEquality(varType, type);
  genST();
  genCV();
  genLI();
  beginLoop = getCurrentCodeAddress();
  eat(KW_TO);

  type = compileExpression();
  checkTypeEquality(varType, type);
  genLE();
  fjInstruction = genFJ(DC_VALUE);

  eat(KW_DO);
  compileStatement();

  genCV();  
  genCV();
  genLI();
  genLC(1);
  genAD();
  genST();

  genCV();
  genLI();

  genJ(beginLoop);
  updateFJ(fjInstruction, getCurrentCodeAddress());
  genDCT(1);

}
예제 #22
0
파일: parser.c 프로젝트: minh93/thctd
void compileStatements(void) {
  // TODO
  switch(lookAhead->tokenType){
  case TK_IDENT:
  case KW_CALL:
  case KW_BEGIN:
  case KW_IF:
  case KW_WHILE:
  case KW_FOR:
  case SB_SEMICOLON:
  case KW_END:
  case KW_ELSE:
    compileStatement();
    break;
    //check sau
  default:
    break;
  }
  compileStatements2();
}
예제 #23
0
void compileForSt(void) {
  // TODO: Check type consistency of FOR's variable
  Type* varType;
  Type *type;

  eat(KW_FOR);
  //eat(TK_IDENT);

  // check if the identifier is a variable
  //checkDeclaredVariable(currentToken->string);
  varType = compileLValue();
  eat(SB_ASSIGN);
  type = compileExpression();
  checkTypeEquality(varType, type);

  eat(KW_TO);
  type = compileExpression();
  checkTypeEquality(varType, type);

  eat(KW_DO);
  compileStatement();
}
예제 #24
0
void compileForSt(void) {
  // Check type consistency of FOR's variable
  eat(KW_FOR);
  eat(TK_IDENT);

  // check if the identifier is a variable
  Object *var = checkDeclaredVariable(currentToken->string);
  checkBasicType(var->varAttrs->type);

  eat(SB_ASSIGN);
  Type *exp1Type = compileExpression();
  checkBasicType(exp1Type);

  eat(KW_TO);
  Type *exp2Type = compileExpression();
  checkBasicType(exp2Type);

  // Compare 3 types
  checkTypeEquality(var->varAttrs->type, exp1Type);
  checkTypeEquality(exp1Type, exp2Type);

  eat(KW_DO);
  compileStatement();
}
예제 #25
0
void compileWhileSt(void) {
  eat(KW_WHILE);
  compileCondition();
  eat(KW_DO);
  compileStatement();
}
예제 #26
0
void compileElseSt(void) {
  eat(KW_ELSE);
  compileStatement();
}
예제 #27
0
파일: parser.c 프로젝트: BichVN/Compiler
void compileStatements(void) {
  // TODO
    compileStatement();
    compileStatements2();
}
예제 #28
0
void compileStatements(void) {
    //while(lookAhead->tokenType == TK_IDENT || lookAhead->tokenType == KW_CALL || lookAhead->tokenType == KW_BEGIN ||lookAhead->tokenType == KW_WHILE || lookAhead->tokenType == KW_FOR)
    compileStatement();
    compileStatements2();
}