Package org.jparsec

Class ParseContext

  • Direct Known Subclasses:
    ParserState, ScannerState

    abstract class ParseContext
    extends java.lang.Object
    Represents the context state during parsing.
    • Field Detail

      • module

        final java.lang.String module
      • source

        final java.lang.CharSequence source
      • at

        int at
        The current position of the input. Points to the token array for token level.
      • step

        int step
        The current logical step.
      • result

        java.lang.Object result
        The current parse result.
      • currentErrorAt

        private int currentErrorAt
      • currentErrorIndex

        private int currentErrorIndex
      • errors

        private final java.util.ArrayList<java.lang.Object> errors
      • encountered

        private java.lang.String encountered
      • currentErrorNode

        private TreeNode currentErrorNode
      • errorSuppressed

        private boolean errorSuppressed
    • Constructor Detail

      • ParseContext

        ParseContext​(java.lang.CharSequence source,
                     int at,
                     java.lang.String module,
                     SourceLocator locator)
      • ParseContext

        ParseContext​(java.lang.CharSequence source,
                     java.lang.Object ret,
                     int at,
                     java.lang.String module,
                     SourceLocator locator)
    • Method Detail

      • withErrorSuppressed

        final boolean withErrorSuppressed​(Parser<?> parser)
        Runs parser with error recording suppressed.
      • applyAsDelimiter

        final boolean applyAsDelimiter​(Parser<?> parser)
        Runs parser with error recording suppressed.
      • applyNewNode

        final boolean applyNewNode​(Parser<?> parser,
                                   java.lang.String name)
        Applies parser as a new tree node with name, and if fails, reports "expecting $name".
      • applyNested

        final boolean applyNested​(Parser<?> parser,
                                  ParseContext nestedState)
      • repeat

        final boolean repeat​(Parser<?> parser,
                             int n)
      • repeat

        final <T> boolean repeat​(Parser<? extends T> parser,
                                 int n,
                                 java.util.Collection<T> collection)
      • errorIndex

        final int errorIndex()
        The physical index of the current most relevant error, 0 if none.
      • buildParseTree

        final ParseTree buildParseTree()
      • buildErrorParseTree

        final ParseTree buildErrorParseTree()
      • getEncountered

        private java.lang.String getEncountered()
      • getInputName

        abstract java.lang.String getInputName​(int pos)
        Returns the string representation of the current input (character or token).
      • isEof

        abstract boolean isEof()
      • getIndex

        final int getIndex()
        Returns the current index in the original source.
      • getToken

        abstract Token getToken()
        Returns the current token. Only applicable to token level parser.
      • peekChar

        abstract char peekChar()
        Peeks the current character. Only applicable to character level parser.
      • toIndex

        abstract int toIndex​(int pos)
        Translates the logical position to physical index in the original source.
      • fail

        final void fail​(java.lang.String message)
      • missing

        final void missing​(java.lang.Object what)
      • expected

        final void expected​(java.lang.Object what)
      • unexpected

        final void unexpected​(java.lang.String what)
      • stillThere

        final boolean stillThere​(int wasAt,
                                 int originalStep)
      • set

        final void set​(int step,
                       int at,
                       java.lang.Object ret)
      • setAt

        final void setAt​(int step,
                         int at)
      • next

        final void next()
      • next

        final void next​(int n)
      • enableTrace

        final void enableTrace​(java.lang.String rootName)
        Enables parse tree tracing with rootName as the name of the root node.
      • setErrorState

        private void setErrorState​(int errorAt,
                                   int errorIndex,
                                   ParseContext.ErrorType errorType,
                                   java.util.List<java.lang.Object> errors)
      • setErrorState

        private void setErrorState​(int errorAt,
                                   int errorIndex,
                                   ParseContext.ErrorType errorType)
      • copyErrorFrom

        private void copyErrorFrom​(ParseContext that)
      • characters

        abstract java.lang.CharSequence characters()
        Reads the characters as input. Only applicable to character level parsers.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object