Exemplo n.º 1
0
  public LexerInterpreter createLexerInterpreter(CharStream input) {
    if (this.isParser()) {
      throw new IllegalStateException(
          "A lexer interpreter can only be created for a lexer or combined grammar.");
    }

    if (this.isCombined()) {
      return implicitLexer.createLexerInterpreter(input);
    }

    char[] serializedAtn = ATNSerializer.getSerializedAsChars(atn);
    ATN deserialized = new ATNDeserializer().deserialize(serializedAtn);
    return new LexerInterpreter(
        fileName,
        Arrays.asList(getTokenDisplayNames()),
        Arrays.asList(getRuleNames()),
        ((LexerGrammar) this).modes.keySet(),
        deserialized,
        input);
  }