var longerAltPattern = longerAltConfig.pattern;
^
TypeError: Cannot read properties of undefined (reading 'pattern')
at Lexer.tokenizeInternal (...\node_modules\chevrotain\src\scan\lexer_public.ts:576:56)
at Lexer.tokenize (...\node_modules\chevrotain\src\scan\lexer_public.ts:392:17)
...
This happens because Pop's longer_alt is Identifier (instead of Item), which isn't part of the body mode. So, instead failing internally, it should create a more descriptive error, eg.
Lexer Mode: ->body<- is missing the Token Type ->Identifier<- required by Token Type ->Pop<- as a longer alternative
Also, (not really important or related to this issue, but) it looks like many errors have a <- that doesn't have a space after it
Funnily enough, I just noticed this issue as well last week, although the original contribution is already relatively old. I'm working on a fix for this right now.
The example above throws the following error:
https://github.com/Chevrotain/chevrotain/blob/376d9fe6065fb1e0cf78d02a25f625bf03f3d7cb/packages/chevrotain/src/scan/lexer_public.ts#L576
This happens because
Pop
'slonger_alt
isIdentifier
(instead ofItem
), which isn't part of thebody
mode. So, instead failing internally, it should create a more descriptive error, eg.Also, (not really important or related to this issue, but) it looks like many errors have a
<-
that doesn't have a space after ithttps://github.com/Chevrotain/chevrotain/blob/376d9fe6065fb1e0cf78d02a25f625bf03f3d7cb/packages/chevrotain/src/scan/lexer.ts#L722-L723
And sometimes Token Type is just refered to as Token
https://github.com/Chevrotain/chevrotain/blob/376d9fe6065fb1e0cf78d02a25f625bf03f3d7cb/packages/chevrotain/src/scan/lexer.ts#L764