Search in sources :

Example 11 with ATNDeserializer

use of org.antlr.v4.runtime.atn.ATNDeserializer in project antlr4 by antlr.

the class Grammar method createParserInterpreter.

public ParserInterpreter createParserInterpreter(TokenStream tokenStream) {
    if (this.isLexer()) {
        throw new IllegalStateException("A parser interpreter can only be created for a parser or combined grammar.");
    }
    char[] serializedAtn = ATNSerializer.getSerializedAsChars(atn);
    ATN deserialized = new ATNDeserializer().deserialize(serializedAtn);
    return new ParserInterpreter(fileName, getVocabulary(), Arrays.asList(getRuleNames()), deserialized, tokenStream);
}
Also used : ATNDeserializer(org.antlr.v4.runtime.atn.ATNDeserializer) ParserInterpreter(org.antlr.v4.runtime.ParserInterpreter) ATN(org.antlr.v4.runtime.atn.ATN)

Example 12 with ATNDeserializer

use of org.antlr.v4.runtime.atn.ATNDeserializer in project antlr4 by antlr.

the class Grammar method createGrammarParserInterpreter.

/** @since 4.5.1 */
public GrammarParserInterpreter createGrammarParserInterpreter(TokenStream tokenStream) {
    if (this.isLexer()) {
        throw new IllegalStateException("A parser interpreter can only be created for a parser or combined grammar.");
    }
    char[] serializedAtn = ATNSerializer.getSerializedAsChars(atn);
    ATN deserialized = new ATNDeserializer().deserialize(serializedAtn);
    return new GrammarParserInterpreter(this, deserialized, tokenStream);
}
Also used : ATNDeserializer(org.antlr.v4.runtime.atn.ATNDeserializer) ATN(org.antlr.v4.runtime.atn.ATN)

Aggregations

ATN (org.antlr.v4.runtime.atn.ATN)12 ATNDeserializer (org.antlr.v4.runtime.atn.ATNDeserializer)12 LexerATNFactory (org.antlr.v4.automata.LexerATNFactory)6 ParserATNFactory (org.antlr.v4.automata.ParserATNFactory)6 LexerGrammar (org.antlr.v4.tool.LexerGrammar)6 ParserInterpreter (org.antlr.v4.runtime.ParserInterpreter)2 ArrayList (java.util.ArrayList)1 BailErrorStrategy (org.antlr.v4.runtime.BailErrorStrategy)1 InputMismatchException (org.antlr.v4.runtime.InputMismatchException)1 LexerInterpreter (org.antlr.v4.runtime.LexerInterpreter)1 RecognitionException (org.antlr.v4.runtime.RecognitionException)1 ATNDeserializationOptions (org.antlr.v4.runtime.atn.ATNDeserializationOptions)1