|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Context<V>
A Context object is available to parser actions methods during their runtime and provides various support functionalities.
Method Summary | |
---|---|
boolean |
fastStringMatching()
Returns true if fast string matching is enabled for this parsing run. |
char |
getCurrentChar()
Returns the character at the current index.. |
int |
getCurrentIndex()
Returns the current index in the input buffer. |
char |
getFirstMatchChar()
Returns the first character of the input text matched by the context immediately preceding the action expression that is currently being evaluated. |
InputBuffer |
getInputBuffer()
Returns the InputBuffer the parser is currently running against |
int |
getLevel()
Returns the current matcher level, with 0 being the root level, 1 being one level below the root and so on. |
java.lang.String |
getMatch()
Returns the input text matched by the context immediately preceding the action expression that is currently being evaluated. |
int |
getMatchEndIndex()
Returns the end index of the context immediately preceding the action expression that is currently being evaluated. |
Matcher |
getMatcher()
Returns the Matcher of this context or null, if this context is not valid anymore. |
int |
getMatchStartIndex()
Returns the start index of the context immediately preceding the action expression that is currently being evaluated. |
Context<V> |
getParent()
Returns the parent context, i.e. |
java.util.List<ParseError> |
getParseErrors()
Returns the list of parse errors for the entire parsing run. |
MatcherPath |
getPath()
Returns the MatcherPath to the currently running matcher. |
int |
getStartIndex()
Returns the index into the underlying input buffer where the matcher of this context started its match. |
java.util.List<Node<V>> |
getSubNodes()
Returns the parse tree subnodes already created in the current context scope. |
ValueStack<V> |
getValueStack()
Returns the value stack instance used during this parsing run. |
boolean |
hasError()
Returns true if this context or any sub node recorded a parse error. |
boolean |
inPredicate()
Returns true if the current rule is running somewhere underneath a Test/TestNot rule. |
boolean |
isNodeSuppressed()
Returns true if the current context is for or below a rule marked @SuppressNode or below one marked @SuppressSubnodes. |
Method Detail |
---|
Context<V> getParent()
InputBuffer getInputBuffer()
Matcher getMatcher()
int getStartIndex()
int getCurrentIndex()
char getCurrentChar()
java.util.List<ParseError> getParseErrors()
MatcherPath getPath()
MatcherPath
to the currently running matcher.
int getLevel()
boolean fastStringMatching()
Returns true if fast string matching is enabled for this parsing run.
Fast string matching "short-circuits" the default practice of treating string rules as simple Sequence of
character rules. When fast string matching is enabled strings are matched at once, without relying on inner
CharacterMatchers. Even though this can lead to significant increases of parsing performance it does not play
well with error reporting and recovery, which relies on character level matches.
Therefore the ReportingParseRunner
and RecoveringParseRunner
implementations only enable fast
string matching during their basic first parsing run and disable it once the input has proven to contain errors.
java.util.List<Node<V>> getSubNodes()
boolean inPredicate()
boolean isNodeSuppressed()
boolean hasError()
java.lang.String getMatch()
Returns the input text matched by the context immediately preceding the action expression that is currently being evaluated. This call can only be used in actions that are part of a Sequence rule and are not at first position in this Sequence.
char getFirstMatchChar()
Returns the first character of the input text matched by the context immediately preceding the action expression that is currently being evaluated. This call can only be used in actions that are part of a Sequence rule and are not at first position in this Sequence.
If the immediately preceding rule did not match anything this method throws a GrammarException. If you need to able to handle that case use the getMatch() method.
int getMatchStartIndex()
Returns the start index of the context immediately preceding the action expression that is currently being evaluated. This call can only be used in actions that are part of a Sequence rule and are not at first position in this Sequence.
int getMatchEndIndex()
Returns the end index of the context immediately preceding the action expression that is currently being evaluated. This call can only be used in actions that are part of a Sequence rule and are not at first position in this Sequence.
ValueStack<V> getValueStack()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |