mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-17 06:20:27 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@5 e7d03fd6-7b0d-0410-9947-9c21f3af8025
51 lines
1,004 B
Text
51 lines
1,004 B
Text
#
|
|
# this is a Grammar Spec for parsing PyLR style
|
|
# Grammars
|
|
#
|
|
|
|
#
|
|
# this is the pydefs section, where you name the output class
|
|
# , add code, state how to initialize the lexer
|
|
#
|
|
_class GrammarParser
|
|
_code import PyLR.Lexers
|
|
_code import PyLR.Parser
|
|
_lex PyLR.Lexers.GrammarLex()
|
|
|
|
#
|
|
# this is the Grammar spec part, where you specify
|
|
# the productions and optionally their corresponding
|
|
# method names in the generated Parser class (or subclasses
|
|
# of it)
|
|
#
|
|
"""
|
|
pspec: gspec |
|
|
pydefs gspec;
|
|
|
|
gspec: GDEL lhsdeflist GDEL;
|
|
|
|
pydefs: pydefs pydef |
|
|
pydef;
|
|
|
|
pydef: LEX (lexdef) |
|
|
CODE (addcode) |
|
|
CLASS (classname);
|
|
|
|
lhsdeflist: lhsdeflist lhsdef |
|
|
lhsdef;
|
|
|
|
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
|
|
| (rhseps);
|
|
|
|
|
|
idlist: idlist ID (idl_idlistID) |
|
|
ID (idlistID);
|
|
"""
|