linkchecker/PyLR/parsertemplate.py
2000-02-27 20:45:44 +00:00

74 lines
2.1 KiB
Python

#
# this file's doc string is used as a template for producing PyLRtables.py.
# PyLRtables.py containes the source code to produce the engine part of a
# parser.
#
'''\
"""
%(filename)s -- created %(date)s
This file was automatically generated by the PyLR parser generator.
It defines the tables 'actiontable', 'gototable', and 'prodinfo'. These
tables are used to give functionality to a parsing engine. It also defines
A Parser class called %(parsername)s which will use this engine. It's usage
is indicated in %(parsername)s's doc-string.
"""
#
# this section contains source code added by the user
# plus 'import PyLR'
#
%(extrasource)s
import PyLR
#
# the action table means
# ('s', -1) shift
# ('r', <n>) reduce with production n
# ('a', -1) accept
# ('', -1) error
# each row represents a state and each column a terminal lookahead symbol
# Lexer symbols are:
# %(symbols)s
#
_actiontable = %(actiontable)s
#
# the goto table, each row represents a state
# and each column the nonterminal that was on the lhs of the
# reduction
#
_gototable = %(gototable)s
#
# This is the prodinfo table. each row represents a production
# the entries are the length of the production, the name of a method
# in an instance of the %(parsername)s class below that gets called
# when that production occurs, and the index of the lhs in the
# nonterminals (as in the gototable)
#
_prodinfo = %(prodinfo)s
class %(parsername)s(PyLR.Parser):
"""
this class was produced automatically by the PyLR parser generator.
It is meant to be subclassed to produce a parser for the grammar
%(grammar)s
While parsing input, if one of the above productions is recognized,
a method of your sub-class (whose name is indicated in parens to the
right) will be invoked. Names marked 'unspecified' should be ignored.
usage:
class My%(parsername)s(%(parsername)s):
# ...define the methods for the productions...
p = My%(parsername)s(); p.parse(text)
"""
def __init__(self):
lexer = %(lexerinit)s
PyLR.Parser.__init__(self, lexer, _actiontable, _gototable, _prodinfo)
'''