Skip to content

Non-greedy subrules #1976

Answered by bd82
peterbud asked this question in Q&A
Aug 20, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Would it be possible to have something like a NGSUBRULE() or similar to have a parity functionality to ANTLR4?

Probably not, I am not convinced this feature is needed beyond syntactic sugar nor am I planning any significant new features at this time.

Back to your example:

I suspect you need multiple categories of "anyText"

$.RULE("statement", () => {
      $.SUBRULE($.anyTextNotAccount)
      $.CONSUME(header)
      $.SUBRULE2($.anyTextNotDate)
      $.MANY(() => $.SUBRULE($.transaction))
      $.SUBRULE3($.anyText) // if you don't care to "parse" anything after the list of transactions you can delete this line....
    })

Note that Chevrotain is a JavaScript DSL.
So you can likely creat…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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

Answer selected by peterbud
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