norskeld / sigma

TypeScript parser combinator library for building fast and convenient parsers.
https://sigma.nrsk.dev
MIT License
26 stars 4 forks source link

feat: error recovery, handling and mapping #53

Open norskeld opened 1 year ago

norskeld commented 1 year ago

Right now there're no "errors" per se, i.e. all sigma provides users with is text messages and ability to re-map those messages to something custom. This is a shame and should be improved.

Implementation of spans in #34 should help a bit, but we will also need to extend Parser<T> signature with a second generic parameter E, so parsers could bear error type information. All parsers and combinators will be changed accordingly, although I'm pretty sure there'll be hurdles here and there.

Additionally, there should be added two combinators:

It also makes sense to implement error recovery along with the stuff above. Hopefully, it will be enough to provide a single combinator:


Making parsers named (adding name property to Parser<T>) wouldn't hurt as well.