Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Earley: Incorrect value for SymbolNode.end #1431

Closed
chanicpanic opened this issue Jun 25, 2024 · 0 comments · Fixed by #1432
Closed

Dynamic Earley: Incorrect value for SymbolNode.end #1431

chanicpanic opened this issue Jun 25, 2024 · 0 comments · Fixed by #1432

Comments

@chanicpanic
Copy link
Contributor

Consider the following:

grammar = r"""
start: "ABC"
"""

print(Lark(grammar, ambiguity="forest").parse("ABC"))

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:

grammar = r"""
start: abc 
abc: "ABC"
"""

print(Lark(grammar, ambiguity="forest").parse("ABC"))

Output: (start, 0, 3, -inf)

I will open a PR with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant