mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-14 17:43:11 +00:00
cleaned files
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@16 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
d6507eddb9
commit
c6ae3ba589
9 changed files with 0 additions and 583 deletions
|
|
@ -1,31 +0,0 @@
|
|||
"""
|
||||
this file contains the Lexer that is used in parsing Grammar specifications
|
||||
"""
|
||||
|
||||
import re,PyLR
|
||||
|
||||
def _retlex(mo):
|
||||
return mo.group("lex")
|
||||
|
||||
def _retcode(mo):
|
||||
return mo.group("code")
|
||||
|
||||
def _retclass(mo):
|
||||
return mo.group("class")
|
||||
|
||||
class GrammarLex(PyLR.Lexer):
|
||||
def __init__(self):
|
||||
PyLR.Lexer.__init__(self)
|
||||
self.addpat(r"_lex\s+(?P<lex>[^\n]*)", "LEX", _retlex)
|
||||
self.addpat(r"_code\s+(?P<code>[^\n]*)", "CODE", _retcode)
|
||||
self.addpat(r"_class\s+(?P<class>[a-zA-Z_][a-zA-Z_0-9]*)", "CLASS", _retclass)
|
||||
self.addpat(r"[a-zA-Z_][a-zA-Z_0-9]*", "ID")
|
||||
self.addpat(r":", "COLON")
|
||||
self.addpat(r";", "SCOLON")
|
||||
self.addpat(r"\|", "OR")
|
||||
self.addpat(r"\(", "LPAREN")
|
||||
self.addpat(r"\)", "RPAREN")
|
||||
self.addpat(r'"""', "GDEL")
|
||||
self.addpat(r"\s*#[^\n]*", "", None, 1)
|
||||
self.addpat(r"\s+", "", None, 1)
|
||||
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
"""
|
||||
this file contains the Lexer that is used in parsing Grammar specifications
|
||||
"""
|
||||
|
||||
import re,PyLR
|
||||
|
||||
def _retlex(mo):
|
||||
return mo.group("lex")
|
||||
|
||||
def _retcode(mo):
|
||||
return mo.group("code")
|
||||
|
||||
def _retclass(mo):
|
||||
return mo.group("class")
|
||||
|
||||
class GrammarLex(PyLR.Lexer):
|
||||
def __init__(self):
|
||||
PyLR.Lexer.__init__(self)
|
||||
self.addpat(r"_lex\s+(?P<lex>[^\n]*)", "LEX", _retlex)
|
||||
self.addpat(r"_code\s+(?P<code>[^\n]*)", "CODE", _retcode)
|
||||
self.addpat(r"_class\s+(?P<class>[a-zA-Z_][a-zA-Z_0-9]*)", "CLASS", _retclass)
|
||||
self.addpat(r"[a-zA-Z_][a-zA-Z_0-9]*", "ID")
|
||||
self.addpat(r":", "COLON")
|
||||
self.addpat(r";", "SCOLON")
|
||||
self.addpat(r"\|", "OR")
|
||||
self.addpat(r"\(", "LPAREN")
|
||||
self.addpat(r"\)", "RPAREN")
|
||||
self.addpat(r'"""', "GDEL")
|
||||
self.addpat(r"\s*#[^\n]*", "", None, 1)
|
||||
self.addpat(r"\s+", "", None, 1)
|
||||
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
import re, PyLR
|
||||
|
||||
def _intfunc(m):
|
||||
return int(m.group(0))
|
||||
|
||||
class MathLex(PyLR.Lexer):
|
||||
def __init__(self):
|
||||
PyLR.Lexer.__init__(self)
|
||||
self.addpat(r"([1-9]([0-9]+)?)|0", "INT", _intfunc)
|
||||
self.addpat(r"\+", "PLUS")
|
||||
self.addpat(r"\*","TIMES")
|
||||
self.addpat(r"\(", "LPAR")
|
||||
self.addpat(r"\)", "RPAR")
|
||||
self.addpat(r"\s+", "WS", None, 1)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
from GrammarLex import GrammarLex
|
||||
from MathLex import MathLex
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import PyLR
|
||||
|
||||
class MyMathParser(PyLR.Parsers.MathParser):
|
||||
def addfunc(self, left, plus, right):
|
||||
print "%d + %d" % (left, right)
|
||||
return left + right
|
||||
def parenfunc(self, lp, expr, rp):
|
||||
print "handling parens"
|
||||
return expr
|
||||
def timesfunc(self, left, times, right):
|
||||
print "%d * %d" % (left, right)
|
||||
return left * right
|
||||
|
||||
def _test():
|
||||
p = MyMathParser()
|
||||
p.parse("4 * (3 + 2 * 5)", 1)
|
||||
|
||||
if __name__=='__main__':
|
||||
_test()
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
"""
|
||||
./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)
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
"""
|
||||
Parsers/MathParser.py -- created Sun Feb 27 14:24:41 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 MathParser which will use this engine. It's usage
|
||||
is indicated in MathParser'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
|
||||
# (including Grammar.EPS, which is -1).
|
||||
# Lexer symbols are:
|
||||
# ['EOF', 'INT', 'PLUS', 'TIMES', 'LPAR', 'RPAR']
|
||||
#
|
||||
_actiontable = [
|
||||
[('', -1), ('s', 7), ('', -1), ('', -1), ('s', 8), ('', -1), ('', -1)],
|
||||
[('a', -1), ('', -1), ('s', 9), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('r', 2), ('', -1), ('r', 2), ('s', 11), ('', -1), ('r', 2), ('r', 2)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('r', 4), ('', -1), ('r', 4), ('r', 4), ('', -1), ('r', 4), ('r', 4)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('r', 6), ('', -1), ('r', 6), ('r', 6), ('', -1), ('r', 6), ('r', 6)],
|
||||
[('', -1), ('s', 7), ('', -1), ('', -1), ('s', 8), ('', -1), ('', -1)],
|
||||
[('', -1), ('s', 7), ('', -1), ('', -1), ('s', 8), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('s', 7), ('', -1), ('', -1), ('s', 8), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('s', 9), ('', -1), ('', -1), ('s', 23), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('r', 1), ('', -1), ('r', 1), ('s', 11), ('', -1), ('r', 1), ('r', 1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('r', 3), ('', -1), ('r', 3), ('r', 3), ('', -1), ('r', 3), ('r', 3)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('r', 5), ('', -1), ('r', 5), ('r', 5), ('', -1), ('r', 5), ('r', 5)],
|
||||
[('', -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 = [
|
||||
[1, 1, 3, 3, 5, 5],
|
||||
[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],
|
||||
[13, 13, 3, 3, 5, 5],
|
||||
[None, None, 15, 15, 5, 5],
|
||||
[None, None, 15, 15, 5, 5],
|
||||
[None, None, None, None, 19, 19],
|
||||
[None, None, None, None, 19, 19],
|
||||
[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]
|
||||
]
|
||||
|
||||
|
||||
|
||||
#
|
||||
# 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 MathParser class below that gets called
|
||||
# when that production occurs, and the index of the lhs in the
|
||||
# nonterminals (as in the gototable)
|
||||
#
|
||||
_prodinfo = [
|
||||
(3, 'addfunc', 0), # expression: expression 2 term (addfunc)
|
||||
(1, 'unspecified', 0), # expression: term (unspecified)
|
||||
(3, 'timesfunc', 2), # term: term 3 factor (timesfunc)
|
||||
(1, 'unspecified', 2), # term: factor (unspecified)
|
||||
(3, 'parenfunc', 4), # factor: 4 expression 5 (parenfunc)
|
||||
(1, 'unspecified', 4), # factor: 1 (unspecified)
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
class MathParser(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
|
||||
|
||||
expression: expression PLUS term (addfunc);
|
||||
expression: term (unspecified);
|
||||
term: term TIMES factor (timesfunc);
|
||||
term: factor (unspecified);
|
||||
factor: LPAR expression RPAR (parenfunc);
|
||||
factor: INT (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 MyMathParser(MathParser):
|
||||
# ...define the methods for the productions...
|
||||
|
||||
p = MyMathParser(); p.parse(text)
|
||||
"""
|
||||
def __init__(self):
|
||||
lexer = PyLR.Lexers.MathLex()
|
||||
PyLR.Parser.Parser.__init__(self, lexer, _actiontable, _gototable, _prodinfo)
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
"""if you want to make parsers available from this package directly,
|
||||
that is, if you want 'from PyLR.Parsers import RandomParser' to
|
||||
work, import the name here
|
||||
"""
|
||||
|
||||
from GrammarParser import GrammarParser
|
||||
from MathParser import MathParser
|
||||
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
"""
|
||||
out -- created Tue Dec 16 00:30:36 1997
|
||||
|
||||
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.Lexers
|
||||
import PyLR.Parser
|
||||
import PyLR
|
||||
|
||||
#
|
||||
# the action table ('s', 4) means shift to state 4,
|
||||
# ('r', 4) means reduce by production number 4
|
||||
# other entries are errors. each row represents a state
|
||||
# and each column a terminal lookahead symbol (plus EOF)
|
||||
# these symbols are ['LEX', 'CODE', 'CLASS', 'ID', 'COLON', 'SCOLON', 'OR', 'LPAREN', 'RPAREN', 'GDEL', 'EOF']
|
||||
#
|
||||
_actiontable = [
|
||||
[('s', 10), ('s', 11), ('s', 12), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 5), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('a', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 1)],
|
||||
[('s', 10), ('s', 11), ('s', 12), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 5), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 2)],
|
||||
[('', -1), ('', -1), ('', -1), ('s', 15), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('s', 15), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 7), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 3)],
|
||||
[('r', 4), ('r', 4), ('r', 4), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 4), ('', -1)],
|
||||
[('r', 5), ('r', 5), ('r', 5), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 5), ('', -1)],
|
||||
[('r', 6), ('r', 6), ('r', 6), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 6), ('', -1)],
|
||||
[('r', 7), ('r', 7), ('r', 7), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 7), ('', -1)],
|
||||
[('r', 8), ('r', 8), ('r', 8), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 8), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('r', 9), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 9), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('r', 10), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 10), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('s', 16), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('s', 28), ('', -1), ('r', 17), ('r', 17), ('r', 17), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 18), ('s', 20), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('r', 11), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 11), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 12), ('r', 12), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('s', 28), ('', -1), ('r', 17), ('r', 17), ('r', 17), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 13), ('r', 13), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 14), ('r', 14), ('s', 23), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('s', 24), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('s', 25), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('', -1), ('', -1), ('r', 15), ('r', 15), ('', -1), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('s', 27), ('', -1), ('r', 16), ('r', 16), ('r', 16), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('r', 18), ('', -1), ('r', 18), ('r', 18), ('r', 18), ('', -1), ('', -1), ('', -1)],
|
||||
[('', -1), ('', -1), ('', -1), ('r', 19), ('', -1), ('r', 19), ('r', 19), ('r', 19), ('', -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 = [
|
||||
[1, 2, 3, 9, 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, 4, None, 8, None, None, None, None, None, None],
|
||||
[None, None, None, None, None, None, None, None, None, None],
|
||||
[None, None, None, None, 6, 14, None, None, None, None],
|
||||
[None, None, None, None, 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, 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, 17, 19, 22, 26],
|
||||
[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, 21, 22, 26],
|
||||
[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]
|
||||
]
|
||||
|
||||
|
||||
|
||||
#
|
||||
# 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']
|
||||
(2, 'unspecified', 0), # pspec -> ['pydefs', 'gspec']
|
||||
(3, 'unspecified', 1), # gspec -> ['GDEL', 'lhsdeflist', 'GDEL']
|
||||
(2, 'unspecified', 2), # pydefs -> ['pydefs', 'pydef']
|
||||
(1, 'unspecified', 2), # pydefs -> ['pydef']
|
||||
(1, 'lexdef', 3), # pydef -> ['LEX']
|
||||
(1, 'addcode', 3), # pydef -> ['CODE']
|
||||
(1, 'classname', 3), # pydef -> ['CLASS']
|
||||
(2, 'unspecified', 4), # lhsdeflist -> ['lhsdeflist', 'lhsdef']
|
||||
(1, 'unspecified', 4), # lhsdeflist -> ['lhsdef']
|
||||
(4, 'lhsdef', 5), # lhsdef -> ['ID', 'COLON', 'rhslist', 'SCOLON']
|
||||
(1, 'singletolist', 6), # rhslist -> ['rhs']
|
||||
(3, 'rhslist_OR_rhs', 6), # rhslist -> ['rhslist', 'OR', 'rhs']
|
||||
(1, 'rhs_idlist', 7), # rhs -> ['rhsidlist']
|
||||
(4, 'rhs_idlist_func', 7), # rhs -> ['rhsidlist', 'LPAREN', 'ID', 'RPAREN']
|
||||
(1, 'unspecified', 8), # rhsidlist -> ['idlist']
|
||||
(0, 'rhseps', 8), # rhsidlist -> []
|
||||
(2, 'idl_idlistID', 9), # idlist -> ['idlist', 'ID']
|
||||
(1, 'idlistID', 9), # idlist -> ['ID']
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
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)
|
||||
| pydefs gspec; (unspecified)
|
||||
gspec -> GDEL lhsdeflist GDEL; (unspecified)
|
||||
pydefs -> pydefs pydef (unspecified)
|
||||
| pydef; (unspecified)
|
||||
pydef -> LEX (lexdef)
|
||||
| CODE (addcode)
|
||||
| CLASS; (classname)
|
||||
lhsdeflist -> lhsdeflist lhsdef (unspecified)
|
||||
| lhsdef; (unspecified)
|
||||
lhsdef -> ID COLON rhslist SCOLON; (lhsdef)
|
||||
rhslist -> rhs (singletolist)
|
||||
| rhslist OR rhs; (rhslist_OR_rhs)
|
||||
rhs -> rhsidlist (rhs_idlist)
|
||||
| rhsidlist LPAREN ID RPAREN; (rhs_idlist_func)
|
||||
rhsidlist -> idlist (unspecified)
|
||||
| ; (rhseps)
|
||||
idlist -> idlist ID (idl_idlistID)
|
||||
| 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)
|
||||
Loading…
Reference in a new issue