Exemple #1
0
void compileSubDecls(void) {
  assert("Parsing subtoutines ....");
  // TODO
  if (lookAhead->tokenType == KW_FUNCTION) {
      compileFuncDecl();
      compileSubDecls();
  } else if (lookAhead->tokenType == KW_PROCEDURE) {
      compileProcDecl();
      compileSubDecls();
  }
  assert("Subtoutines parsed ....");
}
Exemple #2
0
void compileSubDecls(void) {
  assert("Parsing subtoutines ....");
  // TODO
  if(lookAhead->tokenType==KW_FUNCTION)
    {
      compileFuncDecl();
      compileSubDecls();
    }
  else if(lookAhead->tokenType==KW_PROCEDURE)
    {
      compileProcDecl();
      compileSubDecls();
    }
  //else 
  //error(ERR_INVALIDSUBDECL, lookAhead->lineNo, lookAhead->colNo);
  assert("Subtoutines parsed ....");
}
Exemple #3
0
void compileBlock(void) {
  compileConstDecls();
  compileTypeDecls();
  compileVarDecls();
  compileSubDecls();

  eat(KW_BEGIN);
  compileStatements();
  eat(KW_END);
}
Exemple #4
0
void compileSubDecls(void) {
  assert("Parsing subtoutines ....");
  // TODO
  switch(lookAhead->tokenType){
      case KW_FUNCTION:
        compileFuncDecl();
        compileSubDecls();
        break;
    case KW_PROCEDURE:
        compileProcDecl();
        compileSubDecls();
        break;
    case KW_BEGIN:
        break;
    default:
        error(ERR_INVALIDSUBDECL,lookAhead->lineNo,lookAhead->colNo);
        break;
      }
  assert("Subtoutines parsed ....");
}
Exemple #5
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);
}
Exemple #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);
}
void compileBlock4(void) {
  compileSubDecls();
  compileBlock5();
}