parsingdata/metal

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

Closed this issue · 0 comments

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.