mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-22 08:50:24 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@14 e7d03fd6-7b0d-0410-9947-9c21f3af8025
86 lines
2.2 KiB
Python
86 lines
2.2 KiB
Python
"""
|
|
tests/SimpleParser.py -- created Mon Feb 28 13:13:57 2000
|
|
|
|
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 SimpleParser which will use this engine. It's usage
|
|
is indicated in SimpleParser's doc-string.
|
|
"""
|
|
#
|
|
# this section contains source code added by the user
|
|
# plus 'import PyLR'
|
|
#
|
|
import SimpleLexer
|
|
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:
|
|
# ['EOF', 'c', 'd']
|
|
#
|
|
_actiontable = [
|
|
[('r', 2), ('r', 2), ('', -1)],
|
|
[('a', -1), ('s', 2), ('', -1)],
|
|
[('a', -1), ('', -1), ('s', 3)],
|
|
[('r', 1), ('r', 1), ('', -1)]
|
|
]
|
|
|
|
|
|
|
|
#
|
|
# the goto table, each row represents a state
|
|
# and each column the nonterminal that was on the lhs of the
|
|
# reduction
|
|
#
|
|
_gototable = [
|
|
[1],
|
|
[None],
|
|
[None],
|
|
[None]
|
|
]
|
|
|
|
|
|
|
|
#
|
|
# 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 SimpleParser class below that gets called
|
|
# when that production occurs, and the index of the lhs in the
|
|
# nonterminals (as in the gototable)
|
|
#
|
|
_prodinfo = [
|
|
(3, 'unspecified', 0), # S: S 1 2 (unspecified)
|
|
(0, 'unspecified', 0), # S: (unspecified)
|
|
]
|
|
|
|
|
|
|
|
|
|
class SimpleParser(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
|
|
|
|
S: S c d (unspecified);
|
|
S: (unspecified);
|
|
|
|
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 MySimpleParser(SimpleParser):
|
|
# ...define the methods for the productions...
|
|
|
|
p = MySimpleParser(); p.parse(text)
|
|
"""
|
|
def __init__(self):
|
|
lexer = SimpleLexer.SimpleLexer()
|
|
PyLR.Parser.__init__(self, lexer, _actiontable, _gototable, _prodinfo)
|