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

Fix SymbolNode.end for completed tokens #1432

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

chanicpanic
Copy link
Contributor

Fixes #1431.

I realized that that bug helped #1427 work: multiple solutions had different end values and were considered distinct. After fixing the bug, the end values of solutions are the same, and the solutions get deduped being considered equal. However, we know that the solutions have different children and should be considered distinct. For simplicity, I updated SymbolNode to use the default identity-based equality. Let me know if you have any other ideas for its __eq__ and __hash__ implementations.

@erezsh
Copy link
Member

erezsh commented Jun 25, 2024

LGTM, but my understanding of this code is limited. What do you think are the chances that this will create duplicate solutions?

@chanicpanic
Copy link
Contributor Author

I think the chances are low. I would hope that if duplicate solutions could be created, it would have happened for some of the existing tests causing them to fail.

From my (imperfect) understanding of the code, I believe that there cannot be more than two different solution nodes at the end:

  1. One for completed start rule alternatives that ended in a non-terminal
  2. One for completed start rule alternatives that ended in a terminal

Within those two groups, ambiguities are handled as usual and SymbolNode creation is limited by the node_caches.

@erezsh erezsh merged commit 33136b3 into lark-parser:master Jun 26, 2024
9 checks passed
@erezsh
Copy link
Member

erezsh commented Jun 26, 2024

Thanks!

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 this pull request may close these issues.

Dynamic Earley: Incorrect value for SymbolNode.end
2 participants