Esempio n. 1
0
  // No return value for this function.
  static void getFormals(SamTokenizer f) throws TokenizerException {
    try {
      // The only type for formals is int.
      myCheck(f, "int");
      String paramName = f.getWord();

      // Check if the name already exists.
      if (symTables.lastElement().containsKey(paramName))
        throw new TokenizerException("Error: Duplicate declaration of " + paramName + ".");
      params.add(paramName);
      if (f.check(',')) {
        getFormals(f);
      }
      return;
    } catch (Exception e) {
      System.out.println(e.getMessage());
      throw new TokenizerException("Error: Invalid formals");
    }
  }