-
Notifications
You must be signed in to change notification settings - Fork 4
feat: error recovery, handling and mapping #53
Copy link
Copy link
Open
Labels
A-combinatorsArea: Issues related to combinatorsArea: Issues related to combinatorsA-errorsArea: Issues related to error handlingArea: Issues related to error handlingA-typesArea: Issues related to types and type inferenceArea: Issues related to types and type inferenceC-feature-acceptedCategory: A feature request that has been accepted and awaiting implementationCategory: A feature request that has been accepted and awaiting implementationP-highPriority: HighPriority: High
Description
Activity
Metadata
Metadata
Assignees
Labels
A-combinatorsArea: Issues related to combinatorsArea: Issues related to combinatorsA-errorsArea: Issues related to error handlingArea: Issues related to error handlingA-typesArea: Issues related to types and type inferenceArea: Issues related to types and type inferenceC-feature-acceptedCategory: A feature request that has been accepted and awaiting implementationCategory: A feature request that has been accepted and awaiting implementationP-highPriority: HighPriority: High
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 parameterE, 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:
mapErr(parser, fn)- this combinator will map error fromEto some other type using givenfn.mapOrElse(parser, okFn, errFn)- this combinator will conditionally applyokFnorerrFndepending on the parser's result.It also makes sense to implement error recovery along with the stuff above. Hopefully, it will be enough to provide a single combinator:
recovery(parser, fn)- this combinator takes aparserand a recovery functionfnthat should produce another parser; similar towhencombinator, but it acts only on failures.Making parsers named (adding
nameproperty toParser<T>) wouldn't hurt as well.