-
Notifications
You must be signed in to change notification settings - Fork 9
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
Parser problem with chained method calls #29
Comments
And yeah, maybe things should be more nested, but maybe not. I'm not decided yet either way. FWIW, here's what that other parser (
(not very readable at least imo) |
@Leeft let me work on this, this weekend. Even in my org, we have several expressions as such. Let me refactor it. |
Okay @ganezdragon, thank you and please keep us posted :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've come up with a bit of code we use a lot at work, and the parser doesn't handle it very well. I'm not sure where to go with the solution, so here are some thoughts and hoping for feedback.
The current parser fails rather spectacularly at this:
I was fairly easily able to make it stop do that, though the result isn't that much better overall. Note how there is a single
method_invocation
while there are 4 method calls:Part of the problem would seem to be that
method_invocation
includes that what it is invoked on. I think that makes sense if the methods were executed right to left and thus somewhat recursively, but they're not, they're executed sequentially. Aside from that, I think the scope/single_var_declaration should've been wrapped in an lvalue node, and the rest after the assignment in an rvalue node (adding more structure). In these fictional results I've added this rvalue.More
method_invocation
calls would start to look something like this:But now the 1st one has the variable, the rest has nothing. I'm not keen on that. And a method call is just that, it is called on whatever is fed into it. Which led me to something like this:
I've not yet investigated how hard it might be to get to this result (doesn't seem to be an inconsequential change to the parse tree), but I'd love to know what others think.
The text was updated successfully, but these errors were encountered: