Module parser
This is part of Yappy
parser.py -- Yet another parser for python...
A LR parser generator, based on Aho and al. 1986,
Compilers
(aho86:_compil).
It currently builds SLR
, LR(1)
and
LALR(1)
parsing tables.
Copyright (C) 2000-2003 Rogério Reis & Nelma Moreira
{rvr,nam}@ncc.up.pt Version: $Id: parser.py,v 1.9 2004/12/02 10:17:50
nam Exp $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Author: Rogério Reis & Nelma Moreira {rvr,nam}@ncc.up.pt
Classes |
CFGrammar |
Class for context-free grammars |
LALRtable |
Class for construction of LALR tables |
LALRtable1 |
Class for construction of LALR(1) tables |
Lexer |
Class for lexical analyser to use with the parser |
LogLR |
Class for LR table construction report: |
LR1table |
Class for construction of a LR1 table |
LRBuildparser |
Class for LR parser: without shelve and semantic rules(obsolete) |
LRparser |
Class for LR parser |
LRtable |
Class for construction of a LR table |
SLRtable |
Class for construction of a SLR table |
Stack |
A simple class to implement stacks |
Yappy |
A basic class for parsing. |
Yappy_grammar |
A parser for grammar rules. |
Function Summary |
|
DefaultSemRule (list,
context)
Default semantic rule |
|
Dict (**entries)
Create a dict out of the argument=value arguments |
|
EmptySemRule(list,
context)
|
|
grules (rules_list,
rulesym,
rhssep)
Transforms a list of rules in a grammar description |
|
Reduction (fun,
list,
context)
Reduction function for semantic rules |
Variable Summary |
str |
NIL = ''
|
tuple |
StringTypes = (<type 'str'>, <type 'unicode'>)
|
integer |
_DEBUG : if nonzero, display information during parser generation or
parsing. |
float |
_Version = 1.2 |
DefaultSemRule(list,
context=None)
Default semantic rule
-
|
Dict(**entries)
Create a dict out of the argument=value arguments
-
|
grules(rules_list,
rulesym='->',
rhssep=None)
Transforms a list of rules in a grammar description
-
- Parameters:
rules_list -
is a list of pairs (rule,sem) where rule is a string of the
form:
-
Word rulesym Word1 ... Word2
-
Word rulesym []
rulesym -
LHS and RHS rule separator
rhssep -
RHS values separator (None for white chars)
- Returns:
-
a grammar description
|
Reduction(fun,
list,
context=None)
Reduction function for semantic rules
-
|
StringTypes
-
- Type:
-
tuple
- Value:
(<type 'str'>, <type 'unicode'>)
|
|
_DEBUG
if nonzero, display information during parser generation or
parsing.
-
- Type:
-
integer
- Value:
|
_Version
-
- Type:
-
float
- Value:
|