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

Allow varargs for Ref to reference to defs with different names and return them in parsing order. #392

Closed
mvanaken opened this issue Jul 27, 2023 · 0 comments · Fixed by #393
Assignees
Milestone

Comments

@mvanaken
Copy link
Contributor

You can only specify one argument to ref to reference tokens with a specific name.
If you want to select tokens with different names simultanuously, you can use Join, eg:
join(ref("a"), ref("b"), ref("c"))

This will have the following properties:

  1. this will select the tokens in the order specified, in this example thatt could be "a", "a", "a", "b", "b", "c"
  2. this will evaluate the separate expressions, and with multiple refs, this would mean traversing the ParseGraph multiple times, in this example 3 times.

If Ref accepts a varargs for the selected elements, e.g.:
ref("a", "b", "c")

This will impact to above properties:

  1. this will select the tokens in the parsing order, in this example that could be "a", "b", "c", "b", "a", "a"
  2. to find these elements only one traversal of the ParseGraph is required.
mvanaken added a commit that referenced this issue Jul 28, 2023
This constructor is used to avoid converting an ImmutableList to an
array and then back to an ImmutableList again.
It also keeps the code simple.
Decided to deprecate two shorthands, to avoid confusion which shorthand
to use.
Adjusted tests to use the non-deprecated methods and then added tests to
ReferenceValueExpressionSemanticsTest to keep 100% test coverage.
@mvanaken mvanaken self-assigned this Jul 31, 2023
mvanaken added a commit that referenced this issue Aug 2, 2023
#392 RefAny implementation by allowing varargs for the Ref class.
@mvanaken mvanaken added this to the 10.0.0 milestone Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant