void compileStatements(void) { compileStatement(); while (lookAhead->tokenType == SB_SEMICOLON) { eat(SB_SEMICOLON); compileStatement(); } }
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(); }
void compileIfSt(void) { eat(KW_IF); compileCondition(); eat(KW_THEN); compileStatement(); if (lookAhead->tokenType == KW_ELSE) { eat(KW_ELSE); compileStatement(); } }
void compileWhileSt(void) { assert("Parsing a while statement ...."); eat(KW_WHILE); compileCondition(); eat(KW_DO); compileStatement(); assert("While statement pased ...."); }
int CppSQLite3DB::insertBlob(const CString& szSQL, const unsigned char *data, int dataLength) { CppSQLite3Statement statement = compileStatement(szSQL); statement.bind(1, data, dataLength); return statement.execDML(); }
void compileForSt(void) { eat(KW_FOR); eat(TK_IDENT); eat(SB_ASSIGN); compileExpression(); eat(KW_TO); compileExpression(); eat(KW_DO); compileStatement(); }
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 ...."); }
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(); }
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 ...."); }
void compileDoWhileSt(void) { assert("Parsing a do..while statement ...."); // TODO eat(KW_DO); compileStatement(); eat(KW_WHILE); compileCondition(); assert("Do..While statement parsed ...."); }
void compileStatements2(void) { // TODO if(lookAhead->tokenType==SB_SEMICOLON) { eat(SB_SEMICOLON); compileStatement(); compileStatements2(); } else if(lookAhead->tokenType!=KW_END) eat(SB_SEMICOLON); }
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()); } }
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 ...."); }
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()); }
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(); }
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; } }
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(); }
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(); }
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; } }
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(); }
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); }
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(); }
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(); }
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(); }
void compileWhileSt(void) { eat(KW_WHILE); compileCondition(); eat(KW_DO); compileStatement(); }
void compileElseSt(void) { eat(KW_ELSE); compileStatement(); }
void compileStatements(void) { // TODO compileStatement(); compileStatements2(); }
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(); }