mike-lischke / antlr4ng

Next Generation TypeScript runtime for ANTLR4
Other
87 stars 16 forks source link

ParseRuleContext in empty input has undefined stop token #71

Closed lonely-lockley closed 2 months ago

lonely-lockley commented 6 months ago

In java ANTLR4 implementation the code like:

var parseTree = parser.parse();

returns a ParseRuleContext object with start and stop token pointing to EOF for zero-length input. This library returns start as expected, but stop property value is undefined. This breaks the logic of searching for the rule bounds (from parseTree.start!.start to parseTree.stop!.stop). I've added additional checks, but it would be nice not to have them at all.

antlr4ng version 3.0.4 antlr4ng-cli version 2.0.0

mike-lischke commented 6 months ago

Odd, the stop token is only omitted in case of errors. At least that's what I though until now.

mike-lischke commented 2 months ago

It turned out to be bug in the original JS runtime, which has been fixed now