You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
MyGrammar:
Body < Item+
Item <- :'#' {:'(' identifier :')'}
Would not throw an error if # was not encountered, but would if # was encountered followed by a malformed grammar inside the {}
#(MyItem)
^ Would not error
#MyItem2)
^ Expected '(' got 'M'
(MyItem2)
^ Body would be considered terminated as no # was found
That would make error handling a lot more useful for grammars that contain statements in a non recursive fashion.
The text was updated successfully, but these errors were encountered:
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 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.
The text was updated successfully, but these errors were encountered: