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

precedence on productions #39

Closed
sn6uv opened this issue Dec 21, 2014 · 2 comments
Closed

precedence on productions #39

sn6uv opened this issue Dec 21, 2014 · 2 comments

Comments

@sn6uv
Copy link
Contributor

sn6uv commented Dec 21, 2014

Is it possible to add precedence directly on productions?

I'm writing a parser for a language that reuses the ! symbol for both factorial (postfix) and negation (prefix). I'd like to be able to resolve the conflict with precedence but it seems like it's only possible to add precedence to tokens.

Example

I want 2 ! 3 to parse as Times[Factorial[2], 3] not Times[2, Not[3]]

@refi64
Copy link

refi64 commented Dec 21, 2014

Try using the precedence argument to pg.production. PLY own docs have a good explanation: www.dabeaz.com/ply/ply.html#ply_nn27. Jump to the part about %prec part. It does the same thing as the precedence arg to pg.production.

@sn6uv
Copy link
Contributor Author

sn6uv commented Dec 25, 2014

Thanks @kirbyfan64. I've opened #40 to document this feature

@sn6uv sn6uv closed this as completed Dec 25, 2014
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