Ejemplo n.º 1
0
void compileStatements(void) {
  compileStatement();
  while (lookAhead->tokenType == SB_SEMICOLON) {
    eat(SB_SEMICOLON);
    compileStatement();
  }
}
Ejemplo n.º 2
0
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();

}
Ejemplo n.º 3
0
void compileIfSt(void) {
  eat(KW_IF);
  compileCondition();
  eat(KW_THEN);
  compileStatement();
  if (lookAhead->tokenType == KW_ELSE) {
    eat(KW_ELSE);
    compileStatement();
  }
}
Ejemplo n.º 4
0
void compileWhileSt(void) {
  assert("Parsing a while statement ....");
  eat(KW_WHILE);
  compileCondition();
  eat(KW_DO);
  compileStatement();
  assert("While statement pased ....");
}
Ejemplo n.º 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();
}
Ejemplo n.º 6
0
void compileForSt(void) {
    eat(KW_FOR);
    eat(TK_IDENT);
    eat(SB_ASSIGN);
    compileExpression();
    eat(KW_TO);
    compileExpression();
    eat(KW_DO);
    compileStatement();
}
Ejemplo n.º 7
0
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 ....");
}
Ejemplo n.º 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();
}
Ejemplo n.º 9
0
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 ....");
}
Ejemplo n.º 10
0
void compileDoWhileSt(void) {
  assert("Parsing a do..while statement ....");
  // TODO
    eat(KW_DO); 
    compileStatement();  
    eat(KW_WHILE);
    compileCondition();  

  assert("Do..While statement parsed ....");
}
Ejemplo n.º 11
0
void compileStatements2(void) {
  // TODO
  if(lookAhead->tokenType==SB_SEMICOLON)
    {
      eat(SB_SEMICOLON);
      compileStatement();
      compileStatements2();
    }
  else if(lookAhead->tokenType!=KW_END)
    eat(SB_SEMICOLON);
}
Ejemplo n.º 12
0
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());
  }
}
Ejemplo n.º 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 ....");
}
Ejemplo n.º 14
0
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());
}
Ejemplo n.º 15
0
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();
}
Ejemplo n.º 16
0
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;

        }
}
Ejemplo n.º 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();
}
Ejemplo n.º 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();
}
Ejemplo n.º 19
0
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;
  }
}
Ejemplo n.º 20
0
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();
}
Ejemplo n.º 21
0
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);

}
Ejemplo n.º 22
0
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();
}
Ejemplo n.º 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();
}
Ejemplo n.º 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();
}
Ejemplo n.º 25
0
void compileWhileSt(void) {
  eat(KW_WHILE);
  compileCondition();
  eat(KW_DO);
  compileStatement();
}
Ejemplo n.º 26
0
void compileElseSt(void) {
  eat(KW_ELSE);
  compileStatement();
}
Ejemplo n.º 27
0
void compileStatements(void) {
  // TODO
    compileStatement();
    compileStatements2();
}
Ejemplo n.º 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();
}