Python Parsers Comparison

Randall Hopper aa8vb at
Thu Apr 20 19:39:52 CEST 2000

Warren Postma:
 |> For example, a comma-separated list of nested vectors would be a good
 |>     [ 1, 2 ], [ 3, 4 ]
 |>     [ [ 1,2 ],[ 3,4 ] ], [ 5.6 ]
 |>     etc.
 |Wherever I am able to do so, I use eval() and design my grammar to be
 |basically PYTHON.
 |If you are in control of the grammar, and you are inventing it, why not
 |stick with python, if on the other hand, the grammar is something you're
 |stuck with 'as-is', and it's not a proper subset of some Python construct,
 |then all bets are off.

You've hit it on the head.  The grammer is from a third-party tool which
I'm picking up and using as-is.  For simply expressions I already re.sub it
into Python and eval.  But more complex expressions don't play so nice with
this approach.

 |I certainly WOULD like to see some tutorial material on constructing such
 |parsers, because I don't know the first thing about them. We studied this
 |stuff in undergrad C.S., but it was trivial stuff (BNF grammars, some simple
 |parsing code techniques in C).  We never did learn the Nifty Hardcode Stuff.

Exactly.  We covered them as well and I have no doubt that with sufficient
time and effort I (or most folks certainly) could learn them all and pick
the best one.  Though, a "Python Parsers FAQ" written from the 30,000 foot
view (feature comparison, limitations, examples, still-maintained status,
etc.) would really be a timesaver for folks looking for the best parser for
their task.

Randall Hopper
aa8vb at

More information about the Python-list mailing list