dlang-community / Pegged

A Parsing Expression Grammar (PEG) module, using the D programming language.
533 stars 66 forks source link

Any way to simplify compile time grammar errors? #254

Open Aphexus opened 6 years ago

Aphexus commented 6 years ago

There seems to be a feature to reduce error display at runtime but I do not see that feature at compile time.

I get a lot of lines like:

+-Pegged.Arrow [32, 34]["<"] | | +-Pegged.SPACEARROW [32, 34]["<"] | +-Pegged.Expression [34, 59]["!", "'", "[", "'", ".", "", "X", ""]

Even related to parts of the grammar that do not have a mistake.

It does terminate at the offending line but there is a lot of junk above it.

I'm wondering if all that could be reduced(optionally, of course):

+- "< " | +-(!'[' .) X

Or, just show the grammar rules when they pass rather than the pegged. stuff, for lines near the error, show the full expressions.

Stuff like this would make the grammar error output "infinitely" easier to read.

veelo commented 6 years ago

For the record: if anybody would be going to look into an issue like this (it could be @Aphexus yourself, even) it would help a lot to have a practical minimal example to work with.