DParser for Python

DParser is a simple but powerful tool for parsing, written by J. Plevyak. DParser for Python gives Python programmers a seamless interface to DParser.

The features that set this Python parser apart from other Python parsers are:

DParser for Python also has many easy-to-use features found in other Python parsers: A simple example-- a grammar to add numbers:
from dparser import Parser

def d_add(t):              # actions must start with 'd_'
    "exp : exp '+' exp"    # literals are put directly into grammar rules
    return t[0] + t[2]
    
def d_number(t):
    'exp : "[0-9]+" '  # regular expressions are enclosed in double quotes
    return int(t[0])
    
print Parser().parse("2+3+4")

==> 9

Also see the slightly longer requisite calculator example.

Documentation

DParser for Python Documentation

DParser for Python requires at least Python 2.2

Contact

Brian Sabbey (sabbey_at_u_dot_washington_dot_edu.)