Module parser
[show private | hide private]
[frames | no frames]

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.6 2003/11/15 16:20:18 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.

Exceptions
GrammarError Class for input grammar errors
LexicalError Class for all Yappy Lexical analyser exceptions
LexicalRulesErrorRE An error occured parsing the RE part of a lexical rule
LRConflictError Conflicting actions in building LR parsing table.
LRConflicts Confliting actions in building LR parsing table.
LRParserError An error occured in LR parsing program
SemanticError An error occured in the application of a semantic action
SLRConflictError Confliting actions in building SLR parsing table.
TableError Mismatch table version
YappyError Class for all Yappy exceptions

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
tuple StringTypes = (<type 'str'>, <type 'unicode'>)

Function Details

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

Variable Details

StringTypes

Type:
tuple
Value:
(<type 'str'>, <type 'unicode'>)                                       

Generated by Epydoc 2.0 on Sun Nov 16 11:16:30 2003 http://epydoc.sf.net