Skip to content

Is there a way to not consider tokens for OR / maxLookahead? #1972

Answered by bd82
matthew-dean asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @matthew-dean

Chevrotain by default uses LL(K) lookahead, meaning it searches at most a fixed number of tokens ahead.
This would conflict with ignoring an arbitrarily number of whitespace tokens in the alternatives.

While you could implement a custom lookahead strategy that only takes into account the non-whitespace tokens.
There may be a more generic solution of using the existing LL(*) lookahead plugin for Chevrotain.

LL(*) should be able to "check" an arbitrarily number of tokens ahead to distinguish between alternatives, even when the lookahead paths include optional sequences of whitespace, e.g (AB vs AC):

  • _ _ _ A _ B
  • _ _ _ _ A _ _

Replies: 4 comments 10 replies

Comment options

You must be logged in to vote
7 replies
@bd82
Comment options

@matthew-dean
Comment options

@matthew-dean
Comment options

@msujew
Comment options

@matthew-dean
Comment options

Answer selected by matthew-dean
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@bd82
Comment options

@matthew-dean
Comment options

@matthew-dean
Comment options

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