Earley icon indicating copy to clipboard operation
Earley copied to clipboard

Report doesn't include enough information

Open chowells79 opened this issue 3 years ago • 2 comments
trafficstars

I was working on AoC problem (https://adventofcode.com/2021/day/10) recently and saw that recognizing whether an input matches a grammar was part of it. (I ended up going a different direction to solve it, but...)

Since I thought I only needed to identify whether something parsed or not, I wanted to use report to test acceptance without bothering with parse results. But.. that actually isn't sufficient. At least, not unless you add names to the productions, and in sufficient granularity. If you have skipped that portion for your grammar, the Report value doesn't give sufficient information to determine whether something parsed in its entirety - only whether it ran into an error or was able to consume the entire input without errors. The only way to determine if any parse ran to completion is checking whether fullParses returned any parses.

It would be really nice if report returned some way to determine whether there was a full parse without requiring sufficiently granular naming of productions.

chowells79 avatar Dec 11 '21 22:12 chowells79

You could check the position field of your Report, or check the unconsumed field for emptiness.

expipiplus1 avatar May 01 '23 03:05 expipiplus1

@expipiplus1 That covers the case when there was input that was unexpected. It does not cover the case of not enough input. I should know, it's exactly what I tried to do. It doesn't handle the situation.

chowells79 avatar May 01 '23 06:05 chowells79