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@15 e7d03fd6-7b0d-0410-9947-9c21f3af8025
117 lines
3.9 KiB
Python
117 lines
3.9 KiB
Python
"""
|
|
GMLBaseParser.py -- created Mon Feb 28 14:20:00 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 GMLBaseParser which will use this engine. It's usage
|
|
is indicated in GMLBaseParser's doc-string.
|
|
"""
|
|
#
|
|
# this section contains source code added by the user
|
|
# plus 'import PyLR'
|
|
#
|
|
|
|
import GML
|
|
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', 'REAL', 'INTEGER', 'LSQB', 'RSQB', 'STRING', 'KEY']
|
|
#
|
|
_actiontable = [
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 6)],
|
|
[('a', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
|
[('r', 1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 6)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('s', 12), ('', -1), ('s', 6)],
|
|
[('r', 2), ('', -1), ('', -1), ('', -1), ('r', 2), ('', -1), ('r', 2)],
|
|
[('r', 3), ('', -1), ('', -1), ('', -1), ('r', 3), ('', -1), ('r', 3)],
|
|
[('', -1), ('s', 9), ('s', 8), ('s', 11), ('', -1), ('s', 10), ('', -1)],
|
|
[('r', 4), ('', -1), ('', -1), ('', -1), ('r', 4), ('', -1), ('r', 4)],
|
|
[('r', 5), ('', -1), ('', -1), ('', -1), ('r', 5), ('', -1), ('r', 5)],
|
|
[('r', 6), ('', -1), ('', -1), ('', -1), ('r', 6), ('', -1), ('r', 6)],
|
|
[('r', 7), ('', -1), ('', -1), ('', -1), ('r', 7), ('', -1), ('r', 7)],
|
|
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 6)],
|
|
[('r', 8), ('', -1), ('', -1), ('', -1), ('r', 8), ('', -1), ('r', 8)]
|
|
]
|
|
|
|
|
|
|
|
#
|
|
# the goto table, each row represents a state
|
|
# and each column the nonterminal that was on the lhs of the
|
|
# reduction
|
|
#
|
|
_gototable = [
|
|
[1, 2, 5, None],
|
|
[None, None, None, None],
|
|
[None, None, 4, None],
|
|
[None, None, 4, None],
|
|
[None, None, None, None],
|
|
[None, None, None, None],
|
|
[None, None, None, 7],
|
|
[None, None, None, None],
|
|
[None, None, None, None],
|
|
[None, None, None, None],
|
|
[None, None, None, None],
|
|
[None, 3, 5, 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 GMLBaseParser class below that gets called
|
|
# when that production occurs, and the index of the lhs in the
|
|
# nonterminals (as in the gototable)
|
|
#
|
|
_prodinfo = [
|
|
(1, 'feddich', 0), # gml: list (feddich)
|
|
(2, 'gml_key_value', 1), # list: list keyvalue (gml_key_value)
|
|
(1, 'unspecified', 1), # list: keyvalue (unspecified)
|
|
(2, 'key_value', 2), # keyvalue: 6 value (key_value)
|
|
(1, 'unspecified', 3), # value: 2 (unspecified)
|
|
(1, 'unspecified', 3), # value: 1 (unspecified)
|
|
(1, 'unspecified', 3), # value: 5 (unspecified)
|
|
(3, 'gmllist', 3), # value: 3 list 4 (gmllist)
|
|
]
|
|
|
|
|
|
|
|
|
|
class GMLBaseParser(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
|
|
|
|
gml: list (feddich);
|
|
list: list keyvalue (gml_key_value);
|
|
list: keyvalue (unspecified);
|
|
keyvalue: KEY value (key_value);
|
|
value: INTEGER (unspecified);
|
|
value: REAL (unspecified);
|
|
value: STRING (unspecified);
|
|
value: LSQB list RSQB (gmllist);
|
|
|
|
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 MyGMLBaseParser(GMLBaseParser):
|
|
# ...define the methods for the productions...
|
|
|
|
p = MyGMLBaseParser(); p.parse(text)
|
|
"""
|
|
def __init__(self):
|
|
lexer = GML.GMLLexer()
|
|
PyLR.Parser.__init__(self, lexer, _actiontable, _gototable, _prodinfo)
|