3 ms·
I played around with the Earley parser that used to be used as part of the CPython build process (who’s name I can’t remember off the top of my head) a bunch an
by UncleEntity 4y ago
I played around with the Earley parser that used to be used as part of the CPython build process (who’s name I can’t remember off the top of my head) a bunch and with a lot of hacking I got it into a pretty usable state. It isn’t really that easy to hack on because they do a lot of optimization which is probably one of the major reasons they kicked it out of the python repo.
ANTLR does have python as one of the output languages IIRC.
There’s also a flex/bison clone written in python whose name I also can’t remember.
My current favorite parser generator library, Coco/R, has a python 2 implementation which I’ll maybe get around to porting to py3k one of these days, who knows?
But to answer your question I don’t think there’s a go to library on the python side, I’ve played around with a bunch of them and usually just go for re2c/lemon or Coco/R from C(++) since I mainly just poke at these things probably more than I should.
The next time I get a few days with nothing to do I plan to see if I can’t whip up a working lpeg (lua’s peg parser VM library thing) in python. Someone did a port a while ago but it is abandoned and, honestly, not all that good. No offense to the person who did it but you can do some pretty nifty things with the python C-api with some practice.
- mingodad 4y agoTo add to your list I just found this project https://github.com/ChrisHixon/chpeg https://github.com/ChrisHixon/chpeg it has good performance and it's relatively simple compared to others.
- eesmith 4y agoThe Earley parser was written by John Aycock. The flex/bison clone you're perhaps thinking of is PLY from David Beazley.
- mingodad 4y agoAlso to add to your list is https://github.com/KuramitsuLab/pegpy https://github.com/KuramitsuLab/pegpy it's an intriguing peg parser with origin from a Japanese group https://github.com/nez-peg/nez https://github.com/nez-peg/nez .