Allow varargs for Ref to reference to defs with different names and return them in parsing order.
Closed this issue · 0 comments
mvanaken commented
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:
- this will select the tokens in the order specified, in this example thatt could be "a", "a", "a", "b", "b", "c"
- 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:
- this will select the tokens in the parsing order, in this example that could be "a", "b", "c", "b", "a", "a"
- to find these elements only one traversal of the ParseGraph is required.