Pyacc is a Python interface/extension to the Berkeley Yacc parser generator. Pyacc reads a grammar, specified with Python documentation strings (similar to SPARK and PLY), and uses Yacc to produce the LALR(1) parsing tables. Unlike Yacc, Pyacc does not generate C code for a parser. Instead, the parser is built into the Pyacc Python module, and no C compilation is required to create a parser for a new grammar.
I created Pyacc because I wanted a Python parser that:
* can efficiently parse LALR(1) grammars. * allows strings and regular expressions to be embedded directly into the grammar rules. * uses function documentation strings to specify grammar rules. * is (I imagine) very fast, since most of it is just yacc. * does not produce code that needs to be run or compiled.
A simple example:
from pyacc import Parser
def add(t): 'exp : exp "+" exp' # literals are put directly into grammar rules return t + t
def number(t): r'exp : re"\d+" ' # regular expressions are preceded by 're' return int(t)
Pyacc can be obtained from <a href="http://staff.washington.edu/sabbey/pyacc">http://staff.washington.edu/sabbey/pyacc</a>