[ contrib ] Implement Show ParsingError (#2407)

This commit is contained in:
CodingCellist 2022-04-09 13:37:45 +02:00 committed by GitHub
parent e0f5f541e2
commit 36e38860b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -134,6 +134,7 @@
to 32 bits but now that is codified. JavaScript backends are now supported.
* Removes `contrib`'s deprecated `Data.Num.Implementations` module. See
`Prelude.Interfaces` instead.
* Implements `Show tok => Show (ParsingError tok)` for `Text.Parser.Core`.
### Other changes

View File

@ -271,6 +271,14 @@ position = Position
public export
data ParsingError tok = Error String (Maybe Bounds)
export
Show tok => Show (ParsingError tok) where
show (Error s Nothing) = "PARSING ERROR: " ++ s
show (Error s (Just (MkBounds startLine startCol endLine endCol))) =
"PARSING ERROR: "
++ s
++ " @ L\{show startLine}:\{show startCol}-L\{show endLine}:\{show endCol}"
data ParseResult : Type -> Type -> Type -> Type where
Failure : (committed : Bool) -> (fatal : Bool) ->
List1 (ParsingError tok) -> ParseResult state tok ty