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

Make sure operator precedence is right #43

Open
erikrose opened this issue Jun 12, 2014 · 13 comments
Open

Make sure operator precedence is right #43

erikrose opened this issue Jun 12, 2014 · 13 comments
Milestone

Comments

@erikrose
Copy link
Owner

IIRC, the original paper had / as extremely low precedence. Make sure we got it all right.

@keleshev
Copy link
Contributor

In my PEG implementation I just used Ford's grammar, and am very happy about it. I found it very easy to bootstrap the grammar too. Ford's grammar defines character ranges, which for me eliminated any need to have embedded regular expressions.

@erikrose
Copy link
Owner Author

Yes, I want to deprecate regexes and build them myself out of Ford-style syntax. Regexes were just a way to get to a working product faster.

@erikrose
Copy link
Owner Author

I'm probably going to keep the = signs, though; they're easier to type and, I think, easier to read for Python people. I did a survey of PEG libs before I designed Parsimonious's syntax, and none of them could agree on anything (Pijnu uses :=, for example), so there wasn't the interoperability gain I hoped for from following some consensus.

@keleshev
Copy link
Contributor

Well, there is a chance to interoperate with my halst/peg.rb library :-). Also, I usually follow this rule: if I don't know any better—just pick something existing. That's how docopt became.

@erikrose
Copy link
Owner Author

I'd consider supporting <- as an alternative syntax, though I like = as the recommended one: more like a Python assignment, easier to type, more compact, etc.

@erikrose erikrose added this to the 1.0 milestone Jul 14, 2014
@keleshev
Copy link
Contributor

If you can make Parsimonious' syntax a strict superset of Fords'—that would make me really happy.

@ramunas
Copy link

ramunas commented Apr 6, 2015

It would be great if you could lower the precedence of the '/' operator. This
would allow to avoid quite a few superfluous parenthesis. It is awkward to
group choices in longer grammars, as in the following trivial example

ex = ("x" "y" "z")
   / ("u" "w")

Note the grammar without parenthesis is not accepted by parsimonious.

@erikrose
Copy link
Owner Author

Working on this right now. :-)

@erikrose
Copy link
Owner Author

Ended up hitting a mysterious non-parsing grammar while writing the first test case and then spending the rest of the day working on a graphical grammer debugger. But I guess that's good, too. :-)

@Botwise-Operator
Copy link

I just ran into the whole "a = b c / d" thing. Anything that can be done about it?

@erikrose
Copy link
Owner Author

I keep coming back to it but haven't had any luck yet; it basically amounts to rewriting the grammar grammar. Someday I intend to get it right, but I can't give an estimate of when. Help is welcome, of course.

@erikrose
Copy link
Owner Author

In the meantime, you can certainly work around it with parentheses.

@erikrose
Copy link
Owner Author

Here, I've pushed the branch with my work so far: https://github.com/erikrose/parsimonious/tree/lower-precedence-ors. I don't promise it makes sense, but, if anyone wants to tinker with it, you're welcome. As the 2nd-last commit message says, see test_something in test_grammar.py for an explanation of my current problem.

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

4 participants