Closed chanicpanic closed 1 week ago
Consider the following:
grammar = r""" start: "ABC" """ print(Lark(grammar, ambiguity="forest").parse("ABC"))
Output: (start, 0, 2, -inf)
(start, 0, 2, -inf)
The end index is 2 which suggests that the substring "AB" was parsed. However, we know that the full string was parsed, so the end index should be 3.
Note that the issue does not occur if we use a rule instead:
grammar = r""" start: abc abc: "ABC" """ print(Lark(grammar, ambiguity="forest").parse("ABC"))
Output: (start, 0, 3, -inf)
(start, 0, 3, -inf)
I will open a PR with a fix.
Consider the following:
Output:
(start, 0, 2, -inf)
The end index is 2 which suggests that the substring "AB" was parsed. However, we know that the full string was parsed, so the end index should be 3.
Note that the issue does not occur if we use a rule instead:
Output:
(start, 0, 3, -inf)
I will open a PR with a fix.