RegexLexer was using a single static instance EOF_TOKEN whenever reaching the end of input. However the state of a Token comprises the next member, which RegexParser uses to set up a linked list of tokens. This could lead to EOF_TOKEN being linked to itself, creating an endless list, when RegexLexer.getNextToken was called again after the end had already been noticed.
Usually this does not happen, but the code in RegexParser.charRange does not consider EOF, which may lead to an extra token being acquired.
These changes remove RegexLexer.EOF_TOKEN, and add extra EOF-checking to RegexParser.charRange.
RegexLexer
was using a single static instanceEOF_TOKEN
whenever reaching the end of input. However the state of aToken
comprises thenext
member, whichRegexParser
uses to set up a linked list of tokens. This could lead toEOF_TOKEN
being linked to itself, creating an endless list, whenRegexLexer.getNextToken
was called again after the end had already been noticed.Usually this does not happen, but the code in
RegexParser.charRange
does not considerEOF
, which may lead to an extra token being acquired.These changes remove
RegexLexer.EOF_TOKEN
, and add extra EOF-checking toRegexParser.charRange
.