This module implements the Generalized-LR parsing engine and provides the supporting data structures and helper functions.
Parse trees are composed of alternating levels of symnode and rulenode instances. The root of the parse tree is a symnode for the start symbol of the grammar.
sym, possibilities, cover) |
sym
field is either
a tuple of the token name and value for terminals or a non-terminal
symbol. The possibilities
field holds a list of all possible
derivations of the current symbol. Each element in possibilities
is a rulenode instance.
rule, elements, cover) |
rule
member specifies which production
in the grammar the rulenode represents. It is a tuple
of the left hand side symbol, a count of right hand side elements and
the production number in the grammar. The elements
member
is a list of symnodes for the right hand side of the
production.
tree, printcover=0) |
tree
. If printcover
is true, the
token positions each tree node covers is also displayed.
gram) |
lex) |
lex
. This must be called
before parsing is started.
) |
This method may raise pyggy.PaseError or pyggy.InternalError.
See the PyGgy Home Page.