-
Notifications
You must be signed in to change notification settings - Fork 34
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
Binary expressions with function calls on their RHS get incorrectly parsed #153
Comments
I think the problem is because |
I suspect you are right, and that we may need to do something similar to the ternary expr hack. There, the ambiguity is with |
I see. Thanks a lot. I ll take this up. |
Thank you for fixing this in #158 ! |
I reckon #158 is incomplete? I think it still needs to handle the |
Yeah, I think that's fair. We probably want to incorporate that workaround into some sort of helper function if we're going to keep applying it. Theoretically there's some precedence / associativity relationship between function calls and the various types of binary expressions that encodes the right behavior, removing the need for the workaround, but the precedence of function calls is very precariously balanced against all sorts of other things right now. I'm somewhat skeptical that there's a way to make it work other than just applying this workaround in all of those places. We can absolutely use this to track the other places! |
if_statement
's condition
expression
Thanks for pinging on this, @nighthawk. I think @ketkarameya is right and we should apply the hack elsewhere; I was just dragging my feet in the hopes that a more elegant solution would present itself. I've published #187 to apply the hack to all binary expressions except the additive and multiplicative ones. The issue exists there too, but for some reason, the hack causes those expressions to act right-associative despite being left-associative. Maybe that's the lesser evil here, but if so, we can apply it separately. Once that PR is merged, |
Hey thanks a lot for #187. I was wondering what is the impact of |
It means that in an expression like: I want to better understand why that happens when we apply the hack before applying it to those operations where it's that much more likely. The "it's not right" argument, of course, also applies to the current interpretation of |
I see, I see. I had observed something similar, when earlier I had tried to apply the hack everywhere. I agree, let's try to investigate why this is happening. |
Hello,
Thanks a lot for making this grammar available. I was tinkering with the parser and I found that for the below scenario, the
condition
of the firstif_statement
is parsed as aconjunction_expression
, while for the secondif_statement
it is parsed as acall_expression
.I was wondering how difficult a fix is this? I am very new to writing / updating tree-sitter grammar, and I am not sure where to start.
The text was updated successfully, but these errors were encountered: