erikrose / parsimonious

The fastest pure-Python PEG parser I can muster
MIT License
1.83k stars 129 forks source link

Support for original PEG syntax #140

Open pwuertz opened 6 years ago

pwuertz commented 6 years ago

parsimonious differs from the original PEG syntax (as defined in http://www.brynosaurus.com/pub/lang/peg.pdf) in some aspects.

Differences I noticed so far:

Are those differences intentional? Would an optional "vanilla" parsing mode be of interest? The reason I'm asking is because I'd like to share PEG files (core syntax only) between two applications using different parsing libraries.

erikrose commented 6 years ago

Thanks for your good questions!

When I first made the decisions about Parsimonious’s grammar, there was no consensus among libraries, so I made it look as natural to Python programmers as possible. I wouldn’t at all mind if things that could work either way, like = and <-, both Just Worked. I’m less excited about introducing modes that people have to care about, but I could be persuaded if no other alternative could be found.

As for the character class issue, Parsimonious doesn’t yet support proper PEG char classes as might be embedded into the middle of a rule: just regexes. My intent was always to support the PEG char class syntax and have that compile down into regexes.

Patches for either would be welcomed.

erikrose commented 6 years ago

Btw, the other big difference from stock PEGs is that my sequences and alternations have their precedences switched. I have a ticket open about that, but it’s proven shockingly hard to get the tests passing after changing it. I can dig up my branch if you’re interested.