shnewto / bnf

Parse BNF grammar definitions
MIT License
256 stars 22 forks source link

Earley predict on complete input #109

Closed CrockAgile closed 1 year ago

CrockAgile commented 1 year ago

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

coveralls commented 1 year ago

Coverage Status

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