Class SourceExceptionParser


  • @Beta
    @NonNullByDefault
    public final class SourceExceptionParser
    extends Object
    Utility class for converting ANTLRErrorListener errors to SourceExceptions. This class is NOT thread-safe.
    Author:
    Robert Varga
    • Method Detail

      • parse

        public static <T> T parse​(org.antlr.v4.runtime.Recognizer<?,​?> recognizer,
                                  Supplier<T> parseMethod,
                                  StatementSourceReference ref)
        Parse a Recognizer extracting its root item.
        Parameters:
        recognizer - Recognizer to use
        parseMethod - Root item extractor method
        ref - Source reference
        Returns:
        Parsed item
        Throws:
        NullPointerException - if any argument is null
        SourceException - if a parser error occurs
      • parse

        public static <T> T parse​(org.antlr.v4.runtime.Lexer lexer,
                                  org.antlr.v4.runtime.Parser parser,
                                  Supplier<T> parseMethod,
                                  StatementSourceReference ref)
        Use a Lexer/Parser pair extracting the parser's root item.
        Parameters:
        lexer - lexer to use
        parser - parser to use
        parseMethod - Root item extractor method
        ref - Source reference
        Returns:
        Parsed item
        Throws:
        NullPointerException - if any argument is null
        SourceException - if a parser error occurs