Пример #1
0
void compileBlock3(void) {
  Object* varObj;
  Type* varType;

  if (lookAhead->tokenType == KW_VAR) {
    eat(KW_VAR);

    do {
      eat(TK_IDENT);
      
      checkFreshIdent(currentToken->string);
      varObj = createVariableObject(currentToken->string);

      eat(SB_COLON);
      varType = compileType();
      
      varObj->varAttrs->type = varType;
      declareObject(varObj);
      
      eat(SB_SEMICOLON);
    } while (lookAhead->tokenType == TK_IDENT);

    compileBlock4();
  } 
  else compileBlock4();
}
Пример #2
0
void compileBlock3(void) {
  Object* varObj;
  Type* varType;
  
  if (lookAhead->tokenType == KW_VAR) {
    eat(KW_VAR);
    
    do {
      eat(TK_IDENT);
      // TODO: Check if a variable identifier is fresh in the block
      checkFreshIdent(currentToken->string);
      // Create a variable object      
      varObj = createVariableObject(currentToken->string);
      
      eat(SB_COLON);
      // Get the variable type
      varType = compileType();
      varObj->varAttrs->type = varType;
      // Declare the variable object
      declareObject(varObj);
      
      eat(SB_SEMICOLON);
    } while (lookAhead->tokenType == TK_IDENT);
    
    compileBlock4();
  } 
  else compileBlock4();
}
Пример #3
0
void compileBlock3(void) {
  if (lookAhead->tokenType == KW_VAR) {
    eat(KW_VAR);
    compileVarDecl();
    compileVarDecls();
    compileBlock4();
  }
  else compileBlock4();
}
Пример #4
0
void compileBlock3(void) {
    // TODO: create and declare variable objects#
    Object* obj = NULL;
    if (lookAhead->tokenType == KW_VAR) {
        eat(KW_VAR);

        do {
            eat(TK_IDENT);
            obj = createVariableObject(currentToken->string);

            eat(SB_COLON);
            obj->varAttrs->type = compileType();

            eat(SB_SEMICOLON);
            declareObject(obj);
        } while (lookAhead->tokenType == TK_IDENT);

        compileBlock4();
    }
    else compileBlock4();
}