Java 类org.antlr.v4.runtime.LexerInterpreter 实例源码

项目:intellij-plugin-v4    文件:ParsingUtils.java   
public static ParsingResult parseText(Grammar g,
                                      LexerGrammar lg,
                                      String startRuleName,
                                      final VirtualFile grammarFile,
                                      String inputText)
    throws IOException
{
    ANTLRInputStream input = new ANTLRInputStream(inputText);
    LexerInterpreter lexEngine;
    lexEngine = lg.createLexerInterpreter(input);
    SyntaxErrorListener syntaxErrorListener = new SyntaxErrorListener();
    lexEngine.removeErrorListeners();
    lexEngine.addErrorListener(syntaxErrorListener);
    CommonTokenStream tokens = new TokenStreamSubset(lexEngine);
    return parseText(g, lg, startRuleName, grammarFile, syntaxErrorListener, tokens, 0);
}
项目:codebuff    文件:Grammar.java   
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, getVocabulary(), Arrays.asList(getRuleNames()), ((LexerGrammar)this).modes.keySet(), deserialized, input);
}