Open LunaTheFoxgirl opened 3 years ago
I don't quite understand what you propose. Maybe you can start with a currently working example, and describe what you don't like about its behaviour. Note that {
...}
are reserved for semantic actions. Poor error messages are a known limitation of Pegged, error reporting is probably the hardest part of a parser generator.
I am unable to provide a "working example" at current time, but essentially what I want is a way to force pegged to stop parsing and output an error if a rule fails.
And yeah, I later realised that {
and }
are already taken.
But yeah, what I need is a way to tell pegged a way to halt parsing and display an error if a rule fails, without using semantic actions + throwing exceptions from that.
I think there is a way to get what you want using parser composition and semantic actions. So why wouldn't you want to use semantic actions?
I have some grammar that needs to be able to repeat, it would be nice to have a tag you could wrap some grammar in to to force an error to be output instead of discarded when * or + is used. Eg.
Would not throw an error if # was not encountered, but would if # was encountered followed by a malformed grammar inside the {}
That would make error handling a lot more useful for grammars that contain statements in a non recursive fashion.