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

Implement associativity attributes #6

Open
osa1 opened this issue Jul 26, 2022 · 1 comment
Open

Implement associativity attributes #6

osa1 opened this issue Jul 26, 2022 · 1 comment

Comments

@osa1
Copy link
Owner

osa1 commented Jul 26, 2022

It's tedious to parse expressions without associativity attributes.

Left associative = reduce in a shift/reduce conflict
Right associative = shift in a shift/reduce conflict

I don't like ocamlyacc/menhir/happy style associativity lines before non-terminals/productions. I think we should probably use Rust attribute syntax and annotate productions with the associativity attributes. Examples:

#[assoc(left)]
<e1:Expr> "+" <e2:Expr> => ...

#[assoc(right)]
<e1:Expr> "?" <e2:Expr> ":" <e3:Expr> => ...
@osa1
Copy link
Owner Author

osa1 commented Sep 13, 2022

LALRPOP PRs that added precedence and associativity annotations:

We should probably just copy the syntax (and maybe implementation too), but I would prefer avoiding lvl and side argument names. Just #[precedence(2)] #[assoc(left)] should be OK. (Do we need string quotes around 2 and left? I hope not)

See also:

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

1 participant