Misreported range in SyntaxTree for optional parser
Thomvis opened this issue · 1 comments
Thomvis commented
When an optional parser parses nothing, it's range becomes 0..0, because of the fallback here. This error will bubble up, e.g. when the optional is inside an "and" parser.
Example:
val integerExpression by (optional(MINUS) * INT)
If there is no -
to parse, the start of the range of the SyntaxTree
corresponding to a match of integerExpression
will always start at 0
, regardless of where the match happens. So if the input where Hello World! 5
(and imagine integerExpression
is part of a larger parser that can also parse words), the actual range would be 0..14
, while the expected range would be 13..14
.
Do you have any pointers how this could be best resolved?
h0tk3y commented
Thanks for the report and the PR! I've merged it, so closing the issue now.