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 interface
Allows tracing of parsing progress during error condition, to ease debugging. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
The current position of the input.private int
private int
private TreeNode
private ParseContext.ErrorType
private String
(package private) static final String
private boolean
(package private) final SourceLocator
(package private) final String
private ParseContext.ErrorType
(package private) Object
The current parse result.(package private) final CharSequence
(package private) int
The 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 boolean
applyAsDelimiter
(Parser<?> parser) Runsparser
with error recording suppressed.(package private) final boolean
applyNested
(Parser<?> parser, ParseContext nestedState) (package private) final boolean
applyNewNode
(Parser<?> parser, String name) Appliesparser
as a new tree node withname
, and if fails, reports "expecting $name".(package private) final ParseTree
(package private) final ParseTree
(package private) abstract CharSequence
Reads the characters as input.private void
copyErrorFrom
(ParseContext that) (package private) final void
enableTrace
(String rootName) Enables parse tree tracing withrootName
as the name of the root node.(package private) final int
The physical index of the current most relevant error,0
if none.(package private) final void
(package private) final void
private String
(package private) final int
getIndex()
Returns the current index in the original source.(package private) abstract String
getInputName
(int pos) Returns the string representation of the current input (character or token).(package private) abstract Token
getToken()
Returns the current token.(package private) final ParseContext.ParserTrace
getTrace()
(package private) abstract boolean
isEof()
(package private) final void
(package private) final void
next()
(package private) final void
next
(int n) (package private) abstract char
peekChar()
Peeks the current character.(package private) final void
raise
(ParseContext.ErrorType type, Object subject) (package private) final ParseErrorDetails
Only called when rendering the error inParserException
.(package private) final boolean
(package private) final <T> boolean
repeat
(Parser<? extends T> parser, int n, Collection<T> collection) (package private) final void
(package private) final void
setAt
(int step, int at) private void
setErrorState
(int errorAt, int errorIndex, ParseContext.ErrorType errorType) private void
setErrorState
(int errorAt, int errorIndex, ParseContext.ErrorType errorType, List<Object> errors) (package private) final boolean
stillThere
(int wasAt, int originalStep) (package private) abstract int
toIndex
(int pos) Translates the logical position to physical index in the original source.toString()
(package private) final void
unexpected
(String what) (package private) final boolean
withErrorSuppressed
(Parser<?> parser) Runsparser
with 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
Runsparser
with error recording suppressed. -
applyAsDelimiter
Runsparser
with error recording suppressed. -
applyNewNode
Appliesparser
as 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,0
if 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 withrootName
as 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
-