-
Notifications
You must be signed in to change notification settings - Fork 3
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
Problem about associativity #2
Comments
I think you mean left vs. right associativity (where the implied parens go) rather than precedence (which operator binds more tightly). Ouch, that is a good point; when I was writing this I wasn't as consciously aware of R/L associativity in parsing. I'll have to take a look later and think about how this interacts with the overall technique to factor out left recursion, and whether I want to change my example and/or address how to enforce left vs right bias. |
What I learned is to turn recursion into repetition:
The result now becomes a list, and we can This is just |
Ah that's helpful, thanks. Busy at the moment but will look at updating this repo in the future. |
I think the following grammar will produce a right-leaning syntax tree.
e.g., in your example in
Main
,1-1-1-1
is parsed intoSuccess (Sub (Lit 1) (Sub (Lit 1) (Sub (Lit 1) (Lit 1))))
, but it should beSuccess (Sub (Sub (Sub (Lit 1) (Lit 1)) (Lit 1)) (Lit 1))
The text was updated successfully, but these errors were encountered: