예제 #1
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();

}
예제 #2
0
void compileIfSt(void) {
  eat(KW_IF);
  compileCondition();
  eat(KW_THEN);
  compileStatement();
  if (lookAhead->tokenType == KW_ELSE) 
    compileElseSt();
}
예제 #3
0
void compileWhileSt(void) {
  assert("Parsing a while statement ....");
  eat(KW_WHILE);
  compileCondition();
  eat(KW_DO);
  compileStatement();
  assert("While statement pased ....");
}
예제 #4
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 ....");
}
예제 #5
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 ....");
}
예제 #6
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 ....");
}
예제 #7
0
Op* RegularExpression::compile(const Token* const token, Op* const next,
							   const bool reverse) {

	Op* ret = 0;

	const unsigned short tokenType = token->getTokenType();

	switch(tokenType) {
	case Token::T_DOT:
	case Token::T_CHAR:
	case Token::T_ANCHOR:
	case Token::T_RANGE:
	case Token::T_NRANGE:
	case Token::T_STRING:
	case Token::T_BACKREFERENCE:
	case Token::T_EMPTY:
		ret = compileSingle(token, next, tokenType);
		break;
	case Token::T_CONCAT:
		ret = compileConcat(token, next, reverse);
		break;
	case Token::T_UNION:
		ret = compileUnion(token, next, reverse);
		break;
	case Token::T_CLOSURE:
	case Token::T_NONGREEDYCLOSURE:
		ret = compileClosure(token, next, reverse, tokenType);
		break;
	case Token::T_PAREN:
		ret = compileParenthesis(token, next, reverse);
		break;
	case Token::T_LOOKAHEAD:
	case Token::T_NEGATIVELOOKAHEAD:
		ret = compileLook(token, next, false, tokenType);
		break;
	case Token::T_LOOKBEHIND:
	case Token::T_NEGATIVELOOKBEHIND:
		ret = compileLook(token, next, true, tokenType);
		break;
	case Token::T_INDEPENDENT:
	case Token::T_MODIFIERGROUP:
		ret = compileLook(token, next, reverse, tokenType);
		break;
	case Token::T_CONDITION:
		ret = compileCondition(token, next, reverse);
		break;
	default:
		ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_UnknownTokenType, fMemoryManager);
		break; // this line to be deleted
	}

	return ret;
}
예제 #8
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());
}
예제 #9
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());
  }
}
예제 #10
0
void compileWhileSt(void) {
  eat(KW_WHILE);
  compileCondition();
  eat(KW_DO);
  compileStatement();
}