Package org.jparsec
Class ParseContext
java.lang.Object
org.jparsec.ParseContext
- Direct Known Subclasses:
ParserState,ScannerState
Represents the context state during parsing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum(package private) static interfaceAllows tracing of parsing progress during error condition, to ease debugging. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) intThe current position of the input.private intprivate intprivate TreeNodeprivate ParseContext.ErrorTypeprivate String(package private) static final Stringprivate boolean(package private) final SourceLocator(package private) final Stringprivate ParseContext.ErrorType(package private) ObjectThe current parse result.(package private) final CharSequence(package private) intThe current logical step.private ParseContext.ParserTrace -
Constructor Summary
ConstructorsConstructorDescriptionParseContext(CharSequence source, int at, String module, SourceLocator locator) ParseContext(CharSequence source, Object ret, int at, String module, SourceLocator locator) -
Method Summary
Modifier and TypeMethodDescription(package private) final booleanapplyAsDelimiter(Parser<?> parser) Runsparserwith error recording suppressed.(package private) final booleanapplyNested(Parser<?> parser, ParseContext nestedState) (package private) final booleanapplyNewNode(Parser<?> parser, String name) Appliesparseras a new tree node withname, and if fails, reports "expecting $name".(package private) final ParseTree(package private) final ParseTree(package private) abstract CharSequenceReads the characters as input.private voidcopyErrorFrom(ParseContext that) (package private) final voidenableTrace(String rootName) Enables parse tree tracing withrootNameas the name of the root node.(package private) final intThe physical index of the current most relevant error,0if none.(package private) final void(package private) final voidprivate String(package private) final intgetIndex()Returns the current index in the original source.(package private) abstract StringgetInputName(int pos) Returns the string representation of the current input (character or token).(package private) abstract TokengetToken()Returns the current token.(package private) final ParseContext.ParserTracegetTrace()(package private) abstract booleanisEof()(package private) final void(package private) final voidnext()(package private) final voidnext(int n) (package private) abstract charpeekChar()Peeks the current character.(package private) final voidraise(ParseContext.ErrorType type, Object subject) (package private) final ParseErrorDetailsOnly called when rendering the error inParserException.(package private) final boolean(package private) final <T> booleanrepeat(Parser<? extends T> parser, int n, Collection<T> collection) (package private) final void(package private) final voidsetAt(int step, int at) private voidsetErrorState(int errorAt, int errorIndex, ParseContext.ErrorType errorType) private voidsetErrorState(int errorAt, int errorIndex, ParseContext.ErrorType errorType, List<Object> errors) (package private) final booleanstillThere(int wasAt, int originalStep) (package private) abstract inttoIndex(int pos) Translates the logical position to physical index in the original source.toString()(package private) final voidunexpected(String what) (package private) final booleanwithErrorSuppressed(Parser<?> parser) Runsparserwith error recording suppressed.
-
Field Details
-
EOF
- See Also:
-
module
-
source
-
locator
-
at
int atThe current position of the input. Points to the token array for token level. -
step
int stepThe current logical step. -
result
Object resultThe current parse result. -
trace
-
currentErrorType
-
currentErrorAt
private int currentErrorAt -
currentErrorIndex
private int currentErrorIndex -
errors
-
encountered
-
currentErrorNode
-
errorSuppressed
private boolean errorSuppressed -
overrideErrorType
-
-
Constructor Details
-
ParseContext
ParseContext(CharSequence source, int at, String module, SourceLocator locator) -
ParseContext
ParseContext(CharSequence source, Object ret, int at, String module, SourceLocator locator)
-
-
Method Details
-
withErrorSuppressed
Runsparserwith error recording suppressed. -
applyAsDelimiter
Runsparserwith error recording suppressed. -
applyNewNode
Appliesparseras a new tree node withname, and if fails, reports "expecting $name". -
applyNested
-
repeat
-
repeat
-
getTrace
-
errorIndex
final int errorIndex()The physical index of the current most relevant error,0if none. -
buildParseTree
-
buildErrorParseTree
-
renderError
Only called when rendering the error inParserException. -
getEncountered
-
getInputName
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
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. -
raise
-
fail
-
missing
-
expected
-
unexpected
-
stillThere
final boolean stillThere(int wasAt, int originalStep) -
set
-
setAt
final void setAt(int step, int at) -
next
final void next() -
next
final void next(int n) -
enableTrace
Enables parse tree tracing withrootNameas the name of the root node. -
setErrorState
private void setErrorState(int errorAt, int errorIndex, ParseContext.ErrorType errorType, List<Object> errors) -
setErrorState
-
copyErrorFrom
-
characters
Reads the characters as input. Only applicable to character level parsers. -
toString
-