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

Earley predict on complete input #109

Merged
merged 1 commit into from
Sep 13, 2022
Merged

Conversation

CrockAgile
Copy link
Collaborator

@CrockAgile CrockAgile commented Sep 13, 2022

An original (maybe overeager!) optimization was included with Earley parsing. If there was no remaining input text, then no more predictions from the grammar were attempted. In most cases, this saves Earley some work. But the BNF crate supports empty production rules. This invalidates this optimization, because an empty production may still be successful even with no remaining input text.

This commit only removes this optimization built on that false assumption. It would be possible to reintroduce this improvement, but only for grammars without any empty productions.

Closes #108

An original (maybe overeager!) optimization was included with Earley
parsing. If there was no remaining input text, then no more predictions
from the grammar were attempted. In most cases, this saves Earley a
some work. But the BNF crate supports empty production
rules. This invalidates this optimization, because an empty production
may still be successful even with no remaining input text.

This commit only removes this optimization built on that false
assumption. It would be possible to reintroduce this improvement, but
*only* for grammars without any empty productions.
@CrockAgile CrockAgile self-assigned this Sep 13, 2022
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 92.873% when pulling e31217e on fix-empty-production-parsing into e5a894b on main.

Copy link
Owner

@shnewto shnewto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome! nice that it was a relatively low impact change!

@shnewto shnewto merged commit d02f39a into main Sep 13, 2022
@shnewto shnewto deleted the fix-empty-production-parsing branch September 13, 2022 20:30
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.

Empty String Rules Fail to Match
3 participants