mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-14 11:21:02 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@13 e7d03fd6-7b0d-0410-9947-9c21f3af8025
171 lines
8.7 KiB
Python
171 lines
8.7 KiB
Python
"""
|
|
./Parsers/GrammarParser.py -- created Sun Feb 27 11:42:48 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 GrammarParser which will use this engine. It's usage
|
|
is indicated in GrammarParser's doc-string.
|
|
"""
|
|
#
|
|
# this section contains source code added by the user
|
|
# plus 'import PyLR'
|
|
#
|
|
|
|
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
|
|
# (excluding symbols with Lexer.SKIPTOK of course).
|
|
# Lexer symbols are:
|
|
# ['EOF', 'LEX', 'CODE', 'CLASS', 'ID', 'COLON', 'SCOLON', 'OR', 'LPAREN', 'RPAREN', 'GDEL']
|
|
#
|
|
_actiontable = [
|
|
[('', -1), ('s', 1), ('s', 2), ('s', 3), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 4)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('a', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)]
|
|
]
|
|
|
|
|
|
|
|
#
|
|
# the goto table, each row represents a state
|
|
# and each column the nonterminal that was on the lhs of the
|
|
# reduction
|
|
#
|
|
_gototable = [
|
|
[5, 6, 7, 8, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, 10, 11, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, 12, None, 13, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, 16, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, 18, 19, 20, 21],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, 26, 20, 21],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, None, None, None],
|
|
[None, None, None, None, None, None, None, 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 GrammarParser class below that gets called
|
|
# when that production occurs, and the index of the lhs in the
|
|
# nonterminals (as in the gototable)
|
|
#
|
|
_prodinfo = [
|
|
(1, 'unspecified', 0), # pspec: gspec (unspecified)
|
|
(2, 'unspecified', 0), # pspec: pydefs gspec (unspecified)
|
|
(3, 'unspecified', 1), # gspec: 10 lhsdeflist 10 (unspecified)
|
|
(2, 'unspecified', 2), # pydefs: pydefs pydef (unspecified)
|
|
(1, 'unspecified', 2), # pydefs: pydef (unspecified)
|
|
(1, 'lexdef', 3), # pydef: 1 (lexdef)
|
|
(1, 'addcode', 3), # pydef: 2 (addcode)
|
|
(1, 'classname', 3), # pydef: 3 (classname)
|
|
(2, 'unspecified', 4), # lhsdeflist: lhsdeflist lhsdef (unspecified)
|
|
(1, 'unspecified', 4), # lhsdeflist: lhsdef (unspecified)
|
|
(4, 'lhsdef', 5), # lhsdef: 4 5 rhslist 6 (lhsdef)
|
|
(1, 'singletolist', 6), # rhslist: rhs (singletolist)
|
|
(3, 'rhslist_OR_rhs', 6), # rhslist: rhslist 7 rhs (rhslist_OR_rhs)
|
|
(1, 'rhs_idlist', 7), # rhs: rhsidlist (rhs_idlist)
|
|
(4, 'rhs_idlist_func', 7), # rhs: rhsidlist 8 4 9 (rhs_idlist_func)
|
|
(1, 'unspecified', 8), # rhsidlist: idlist (unspecified)
|
|
(0, 'rhseps', 8), # rhsidlist: (rhseps)
|
|
(2, 'idl_idlistID', 9), # idlist: idlist 4 (idl_idlistID)
|
|
(1, 'idlistID', 9), # idlist: 4 (idlistID)
|
|
]
|
|
|
|
|
|
|
|
|
|
class GrammarParser(PyLR.Parser.Parser):
|
|
"""
|
|
this class was produced automatically by the PyLR parser generator.
|
|
It is meant to be subclassed to produce a parser for the grammar
|
|
|
|
pspec: gspec (unspecified);
|
|
pspec: pydefs gspec (unspecified);
|
|
gspec: GDEL lhsdeflist GDEL (unspecified);
|
|
pydefs: pydefs pydef (unspecified);
|
|
pydefs: pydef (unspecified);
|
|
pydef: LEX (lexdef);
|
|
pydef: CODE (addcode);
|
|
pydef: CLASS (classname);
|
|
lhsdeflist: lhsdeflist lhsdef (unspecified);
|
|
lhsdeflist: lhsdef (unspecified);
|
|
lhsdef: ID COLON rhslist SCOLON (lhsdef);
|
|
rhslist: rhs (singletolist);
|
|
rhslist: rhslist OR rhs (rhslist_OR_rhs);
|
|
rhs: rhsidlist (rhs_idlist);
|
|
rhs: rhsidlist LPAREN ID RPAREN (rhs_idlist_func);
|
|
rhsidlist: idlist (unspecified);
|
|
rhsidlist: (rhseps);
|
|
idlist: idlist ID (idl_idlistID);
|
|
idlist: ID (idlistID);
|
|
|
|
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 MyGrammarParser(GrammarParser):
|
|
# ...define the methods for the productions...
|
|
|
|
p = MyGrammarParser(); p.parse(text)
|
|
"""
|
|
def __init__(self):
|
|
lexer = PyLR.Lexers.GrammarLex()
|
|
PyLR.Parser.Parser.__init__(self, lexer, _actiontable, _gototable, _prodinfo)
|