Example #1
0
void compileBlock2(void) {
  if (lookAhead->tokenType == KW_TYPE) {
    eat(KW_TYPE);
    compileTypeDecl();
    compileTypeDecls();
    compileBlock3();
  }
  else compileBlock3();
}
Example #2
0
void compileTypeDecls(void) {
  // TODO
  if(lookAhead->tokenType == TK_IDENT)
    {
      compileTypeDecl();
      compileTypeDecls();
    }
  //else 
  //error(ERR_INVALIDTYPEDECL, lookAhead->lineNo, lookAhead->colNo);
}
Example #3
0
void compileBlock(void) {
  compileConstDecls();
  compileTypeDecls();
  compileVarDecls();
  compileSubDecls();

  eat(KW_BEGIN);
  compileStatements();
  eat(KW_END);
}
Example #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);
}
Example #5
0
void compileTypeDecls(void) {
  // TODO
  switch (lookAhead->tokenType) {
  case TK_IDENT:
    compileTypeDecl();
    compileTypeDecls();
    break;
    // EmptySt needs to check FOLLOW tokens
  case KW_VAR:
  case KW_BEGIN:
  case KW_FUNCTION:
  case KW_PROCEDURE:
    break;
    // Error occurs
  default:
    error(ERR_INVALIDTYPEDECL, lookAhead->lineNo, lookAhead->colNo);
    break;
}
}
Example #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);
}