Exemple #1
0
 private int directive() {
   nextChar();
   if (c == 37) {
     nextChar();
     return token = 1;
   }
   if (Character.isJavaIdentifierStart((char) c)) {
     identifier();
     if (lexemeText.equals("token")) return token = 8;
     if (lexemeText.equals("type")) return token = 9;
     if (lexemeText.equals("prec")) return token = 10;
     if (lexemeText.equals("left")) return token = 11;
     if (lexemeText.equals("right")) return token = 12;
     if (lexemeText.equals("nonassoc")) return token = 13;
     if (lexemeText.equals("start")) return token = 14;
     if (lexemeText.equals("package")) return token = 15;
     if (lexemeText.equals("extends")) return token = 18;
     if (lexemeText.equals("implements")) return token = 19;
     if (lexemeText.equals("semantic")) return token = 20;
     if (lexemeText.equals("get")) return token = 21;
     if (lexemeText.equals("next")) return token = 22;
     if (lexemeText.equals("class")) return token = 16;
     if (lexemeText.equals("interface")) {
       return token = 17;
     } else {
       report(new Failure(getPos(), "Unrecognized directive"));
       return -1;
     }
   }
   if (c == 123) {
     nextChar();
     return code();
   } else {
     report(new Failure(getPos(), "Illegal directive syntax"));
     return -1;
   }
 }
Exemple #2
0
  public int nextToken() {
    do {
      skipWhitespace();
      markPosition();
      lexemeText = null;
      switch (c) {
        case -1:
          return token = 0;

        case 58: // ':'
          nextChar();
          return token = 58;

        case 59: // ';'
          nextChar();
          return token = 59;

        case 124: // '|'
          nextChar();
          return token = 124;

        case 60: // '<'
          nextChar();
          return token = 60;

        case 62: // '>'
          nextChar();
          return token = 62;

        case 91: // '['
          nextChar();
          return token = 91;

        case 93: // ']'
          nextChar();
          return token = 93;

        case 46: // '.'
          nextChar();
          return token = 46;

        case 37: // '%'
          if (directive() != -1) return token;
          break;

        case 34: // '"'
          if (string() != -1) return token;
          break;

        case 39: // '\''
          if (literal() != -1) return token;
          break;

        case 123: // '{'
          if (action() != -1) return token;
          break;

        case 47: // '/'
          skipComment();
          break;

        default:
          if (Character.isJavaIdentifierStart((char) c)) return identifier();
          if (Character.isDigit((char) c)) return number();
          illegalCharacter();
          nextChar();
          break;
      }
    } while (true);
  }