Skip to content

Why parsing failed #1808

Answered by msujew
PavelDymkov asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @PavelDymkov,

When entering the MANY call, Chevrotain will try to identify whether it should actually parse it using it's lookahead algorithm. So it basically compares the next tokens in the input with the possible next tokens in the MANY call. The issue is that the tokens in the MANY call match exactly with the tokens after that. The tokens { ,X, " " can be parsed using either:

this.MANY(() => {
  $.OPTION(() => $.CONSUME1(Space));
  $.CONSUME(Word);
  $.OPTION1(() => $.CONSUME2(Space));
  $.CONSUME(Comma);
});

or

$.OPTION2(() => {
  $.OPTION3(() => $.CONSUME3(Space));
  $.CONSUME1(Word);
});
$.OPTION4(() => $.CONSUME4(Space));

Because Chevrotain will always take the first match for p…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by PavelDymkov
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