Skip to content

Support for original PEG syntax #140

Open
@pwuertz

Description

@pwuertz

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.

Activity

erikrose

erikrose commented on Oct 7, 2018

@erikrose
Owner

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

erikrose commented on Oct 7, 2018

@erikrose
Owner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @erikrose@pwuertz

        Issue actions

          Support for original PEG syntax · Issue #140 · erikrose/parsimonious