lib: edit comments to satisfy doctest
This commit is contained in:
parent
5f87e7cd5d
commit
132f8706d7
@ -35,13 +35,13 @@ import Text.Megaparsec
|
|||||||
data CustomErr
|
data CustomErr
|
||||||
-- | Fail with a message at a specific source position interval. The
|
-- | Fail with a message at a specific source position interval. The
|
||||||
-- interval must be contained within a single line.
|
-- interval must be contained within a single line.
|
||||||
= ErrorFailAt SourcePos -- ^ Starting position
|
= ErrorFailAt SourcePos -- Starting position
|
||||||
Pos -- ^ Ending position (column; same line as start)
|
Pos -- Ending position (column; same line as start)
|
||||||
String -- ^ Error message
|
String -- Error message
|
||||||
-- | Attach a source file to a parse error (for error reporting from
|
-- | Attach a source file to a parse error (for error reporting from
|
||||||
-- include files, e.g. with the 'region' parser combinator)
|
-- include files, e.g. with the 'region' parser combinator)
|
||||||
| ErrorWithSource Text -- ^ Source file contents
|
| ErrorWithSource Text -- Source file contents
|
||||||
(ParseError Char CustomErr) -- ^ The original
|
(ParseError Char CustomErr) -- The original
|
||||||
deriving (Show, Eq, Ord)
|
deriving (Show, Eq, Ord)
|
||||||
|
|
||||||
-- We require an 'Ord' instance for 'CustomError' so that they may be
|
-- We require an 'Ord' instance for 'CustomError' so that they may be
|
||||||
@ -131,7 +131,7 @@ customParseErrorPretty source err = case findCustomError err of
|
|||||||
--- * Modified Megaparsec source
|
--- * Modified Megaparsec source
|
||||||
|
|
||||||
-- The below code has been copied from the Megaparsec module and modified
|
-- The below code has been copied from the Megaparsec module and modified
|
||||||
-- to suit our needs. Changes are marked with '-- *'.
|
-- to suit our needs. These changes are indicated by square brackets.
|
||||||
--
|
--
|
||||||
-- NOTE: I am not sure what we are now obligated to do, having directly
|
-- NOTE: I am not sure what we are now obligated to do, having directly
|
||||||
-- copied source code from another project.
|
-- copied source code from another project.
|
||||||
@ -148,7 +148,7 @@ customParseErrorPretty'
|
|||||||
, Stream s )
|
, Stream s )
|
||||||
=> s -- ^ Original input stream
|
=> s -- ^ Original input stream
|
||||||
-> ParseError (Token s) e -- ^ Parse error to render
|
-> ParseError (Token s) e -- ^ Parse error to render
|
||||||
-> Pos -- ^ Length of error interval -- * added
|
-> Pos -- ^ Length of error interval [added]
|
||||||
-> String -- ^ Result of rendering
|
-> String -- ^ Result of rendering
|
||||||
customParseErrorPretty' = customParseErrorPretty_ defaultTabWidth
|
customParseErrorPretty' = customParseErrorPretty_ defaultTabWidth
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ customParseErrorPretty_
|
|||||||
=> Pos -- ^ Tab width
|
=> Pos -- ^ Tab width
|
||||||
-> s -- ^ Original input stream
|
-> s -- ^ Original input stream
|
||||||
-> ParseError (Token s) e -- ^ Parse error to render
|
-> ParseError (Token s) e -- ^ Parse error to render
|
||||||
-> Pos -- ^ Length of error interval -- * added
|
-> Pos -- ^ Length of error interval [added]
|
||||||
-> String -- ^ Result of rendering
|
-> String -- ^ Result of rendering
|
||||||
customParseErrorPretty_ w s e l =
|
customParseErrorPretty_ w s e l =
|
||||||
sourcePosStackPretty (errorPos e) <> ":\n" <>
|
sourcePosStackPretty (errorPos e) <> ":\n" <>
|
||||||
@ -171,7 +171,7 @@ customParseErrorPretty_ w s e l =
|
|||||||
padding <> "| " <> rpadding <> highlight <> "\n" <>
|
padding <> "| " <> rpadding <> highlight <> "\n" <>
|
||||||
parseErrorTextPretty e
|
parseErrorTextPretty e
|
||||||
where
|
where
|
||||||
epos = NE.head (errorPos e) -- * changed from NE.last to NE.head
|
epos = NE.head (errorPos e) -- [changed from NE.last to NE.head]
|
||||||
lineNumber = (show . unPos . sourceLine) epos
|
lineNumber = (show . unPos . sourceLine) epos
|
||||||
padding = replicate (length lineNumber + 1) ' '
|
padding = replicate (length lineNumber + 1) ' '
|
||||||
rpadding = replicate (unPos (sourceColumn epos) - 1) ' '
|
rpadding = replicate (unPos (sourceColumn epos) - 1) ' '
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user