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

Problems with juxt_function_call (help wanted) #5

Open
murtaza64 opened this issue Feb 1, 2024 · 1 comment
Open

Problems with juxt_function_call (help wanted) #5

murtaza64 opened this issue Feb 1, 2024 · 1 comment

Comments

@murtaza64
Copy link
Owner

murtaza64 commented Feb 1, 2024

Groovy's optional parentheses for function calls have created an absolute nightmare.

For example, String foo and print foo should be parsed differently.

I noticed my parser fails on def x = foo "bar". To fix this, I'm trying to allow juxt_function_calls as _expressions. But that leads to a whole host of other ambiguities:

x ? f y:b : z // not ambiguous but hard to parse once you see the first colon
f y:b ? ... // is it (f y:b) ? ... or f y:(b ? ...)
a b, c ? d : e // is it (a b, c) ? d : e or a b, (c ? d : e)

and if I solve them by adding conflicts or trying to tweak precedence for map_item and ternary, all the tests break.

I feel like i need to redo the whole juxt_function_call thing... but I'm not sure how

@murtaza64
Copy link
Owner Author

murtaza64 commented Feb 1, 2024

It seems like some of this can be alleviated by allowing closure as the sole child of function_call:

    function_call: $ =>
      prec.left(2, seq( //higher precedence than juxt_function_call
        field('function', $._prefix_expression),
        field('args', choice($.argument_list, $.closure)),
      )),

gonna run with this for a while and see if it's better

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