DynGenPar
Dynamic Generalized Parser
|
Public Member Functions | |
TokenSource () | |
virtual | ~TokenSource () |
Cat | nextToken () |
get the next token from the input, increment current position, save parse tree More... | |
Node | parseTree () |
get the parse tree for the last shifted token More... | |
virtual bool | matchParseTree (const Node &treeToMatch) |
match the parse tree for the last shifted token against the given tree More... | |
int | currentPosition () |
get the current input position More... | |
virtual bool | rewindTo (int pos, const LexerState &=LexerState()) |
rewind to an older position (requires buffering) More... | |
bool | rewindTo (int pos, const Node &parseTree, const LexerState &lexerState=LexerState()) |
rewind to an older position (requires buffering) and restore the parse tree (needed for lookahead) More... | |
virtual LexerState | saveState () |
saves the current lexer state, by default a null LexerState More... | |
Protected Member Functions | |
virtual Cat | readToken ()=0 |
get the next token from the input, to be implemented by subclasses More... | |
bool | simpleRewind (int pos, bool rewindOnly=false) |
basic implementation of rewindTo for subclasses which support it More... | |
Protected Attributes | |
int | currPos |
Node | tree |
sub-parse-tree for hierarchical parsing More... | |
Definition at line 813 of file dyngenpar.h.
|
inline |
Definition at line 815 of file dyngenpar.h.
|
inlinevirtual |
Definition at line 816 of file dyngenpar.h.
|
inline |
get the current input position
Definition at line 849 of file dyngenpar.h.
|
inlinevirtual |
match the parse tree for the last shifted token against the given tree
true
if they should be considered identical for the purposes of a PMCFG rule using the same variable twice, false
otherwiseThe default implementation compares only the category. Other token sources may want to also look at the data and children fields.
Definition at line 845 of file dyngenpar.h.
|
inline |
get the next token from the input, increment current position, save parse tree
An epsilon token is returned and currPos is not incremented if the end of input was reached.
Definition at line 822 of file dyngenpar.h.
|
inline |
get the parse tree for the last shifted token
Definition at line 834 of file dyngenpar.h.
|
protectedpure virtual |
get the next token from the input, to be implemented by subclasses
Implemented in DynGenPar::ListTokenSource, DynGenPar::TextByteTokenSource, DynGenPar::ByteTokenSource, and DynGenPar::FlexLexerTokenSource.
|
inlinevirtual |
rewind to an older position (requires buffering)
true
if successful, false
otherwisein all cases, destroys the saved parse tree
By default, only succeeds if the position is the current one, otherwise always returns false
. Can be overridden by subclasses.
Some subclasses (e.g., file-backed ones) can wind both forward and backward, some can only rewind, some cannot wind at all. The method will return false
if seeking to the new position is not possible.
Reimplemented in DynGenPar::ListTokenSource, DynGenPar::TextByteTokenSource, and DynGenPar::ByteTokenSource.
Definition at line 862 of file dyngenpar.h.
|
inline |
rewind to an older position (requires buffering) and restore the parse tree (needed for lookahead)
true
if successful, false
otherwisein all cases, restores the saved parse tree to the passed parseTree
Relies on the virtual rewindTo to do its actual work.
Definition at line 874 of file dyngenpar.h.
|
inlinevirtual |
saves the current lexer state, by default a null LexerState
Reimplemented in DynGenPar::TextByteTokenSource.
Definition at line 881 of file dyngenpar.h.
|
inlineprotected |
basic implementation of rewindTo for subclasses which support it
some subclasses may need additional processing
Definition at line 887 of file dyngenpar.h.
|
protected |
Definition at line 894 of file dyngenpar.h.
|
protected |
sub-parse-tree for hierarchical parsing
This variable can be set by readToken to a subtree produced by a hierarchical parser, which will be attached to the resulting parse tree in lieu of a leaf node.
If this variable is left unset, a leaf node is automatically produced.
Definition at line 902 of file dyngenpar.h.