Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for original PEG syntax #140

Open
pwuertz opened this issue Oct 2, 2018 · 2 comments
Open

Support for original PEG syntax #140

pwuertz opened this issue Oct 2, 2018 · 2 comments

Comments

@pwuertz
Copy link

pwuertz commented Oct 2, 2018

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:

  • parsimonious uses = instead of <- for assignment
  • parsimonious uses whitespace separators within character classes. PEG doesn't allow separators within class definitions. E.g. parsimonious interprets [a b] as a or b, but PEG interprets it as a or space or b.

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
Copy link
Owner

erikrose commented Oct 7, 2018

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
Copy link
Owner

erikrose commented Oct 7, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants