Open stanislaw opened 1 year ago
I have hit another problem with this approach, though. If everything is written to the buffer, then during the report time, also the exceptions that were eventually matched on a higher level are printed.
I have solved this problem by introducing the so-called markers, which help me to exclude the failed nodes that should not be printed. I hope that my code, in spite of it being messy, is easy to understand.
What I also found is that it could even make sense to print everything of Match* that is found in the deque because it gives a very nice presentation of what the grammar is capable of within the context of a currently edited file.
@stanislaw Just a head up. I've been experimenting with this branch today. The experiment consisted of running examples (bibtex
and simple
) with verbose2
flag set and introducing syntax errors at various places.
The reports I got were quite unintuitive, at least for me. The master branch still provides a simple but more to the point report. What are your thoughts? Does this give any better messages in the context of StrictDoc?
I still find much easier to understand what is going on by running the parser with debug=True
.
The
verbose=False/True
option is added to the Parser class. This option is disabled by default, and the existing behavior is fully preserved.When the option is enabled, the final expected message is extended with extra information about the previously "weakly failed" rules. This way, not only the last failed NoMatch exception and its failing rules are displayed but also all the rules that were not matched during the whole parsing process.
Open points:
The markers could be removed, and all nodes could be printed whenImplemented byverbose=True
.verbose2
.verbose
may be not the best name for this option. I am happy to change it to any other name.Will be done after/if the approach is confirmed.
Code review checklist
CHANGELOG.md
, no need to update for typo fixes and such).