Skip to content

Order of elements in visitor for AT_LEAST_ONE rule #1856

Answered by bd82
dhowe asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @dhowe

If you wrap the alternation:

        $.OR([
          { ALT: () => $.SUBRULE($.choice) },
          { ALT: () => $.SUBRULE($.symbol) },
        ])

in its own rule (lets name it "expElement") and invoke that rule from the "loop":

    $.RULE("expr", () => {
      $.AT_LEAST_ONE(() => {
          $.SUBRULE($.expElement)
      })
    })

You will get an orderedList back, at the cost of another level of nesting...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dhowe
Comment options

Answer selected by dhowe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants