Beispiel #1
0
void compileBlock3(void) {
  if (lookAhead->tokenType == KW_VAR) {
    eat(KW_VAR);
    compileVarDecl();
    compileVarDecls();
    compileBlock4();
  }
  else compileBlock4();
}
Beispiel #2
0
void compileVarDecls(void) {
  // TODO
  if(lookAhead->tokenType == TK_IDENT)
    {
      compileVarDecl();
      compileVarDecls();
    }
  //else 
  //error(ERR_INVALIDVARDECL, lookAhead->lineNo, lookAhead->colNo);
}
Beispiel #3
0
void compileBlock(void) {
  compileConstDecls();
  compileTypeDecls();
  compileVarDecls();
  compileSubDecls();

  eat(KW_BEGIN);
  compileStatements();
  eat(KW_END);
}
Beispiel #4
0
void compileBlock(void) {
  Instruction* jmp;
  
  jmp = genJ(DC_VALUE);

  compileConstDecls();
  compileTypeDecls();
  compileVarDecls();
  compileSubDecls();

  updateJ(jmp,getCurrentCodeAddress());
  genINT(symtab->currentScope->frameSize);

  eat(KW_BEGIN);
  compileStatements();
  eat(KW_END);
}
Beispiel #5
0
void compileVarDecls(void) {
  // TODO
  switch (lookAhead->tokenType) {
  case TK_IDENT:
    compileVarDecl();
    compileVarDecls();
    break;
    // EmptySt needs to check FOLLOW tokens
  case KW_BEGIN:
  case KW_FUNCTION:
  case KW_PROCEDURE:
    break;
    // Error occurs
  default:
    error(ERR_INVALIDVARDECL, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
}
Beispiel #6
0
void compileBlock(void) {
  Instruction* jmp;
  // Jump to the body of the block
  jmp = genJ(DC_VALUE);

  compileConstDecls();
  compileTypeDecls();
  compileVarDecls();
  compileSubDecls();

  // Update the jmp label
  updateJ(jmp,getCurrentCodeAddress());
  // Skip the stack frame
  genINT(symtab->currentScope->frameSize);

  eat(KW_BEGIN);
  compileStatements();
  eat(KW_END);
}