Text.ParserCombinators.Parsec.Error

parsec-3.1.13.0: Monadic parser combinators

Copyright | (c) Paolo Martini 2007
License | BSD-style (see the LICENSE file)
Maintainer | derek.a.elkins@gmail.com
Stability | provisional
Portability | portable
Safe Haskell | Safe
Language | Haskell2010

Text.ParserCombinators.Parsec.Error

Description

Parsec compatibility module

Synopsis

- data Message
  - = SysUnExpect !String
  - | UnExpect !String
  - | Expect !String
  - | Message !String
- messageString :: Message -> String
- messageCompare :: Message -> Message -> Ordering
- messageEq :: Message -> Message -> Bool
- data ParseError
- errorPos :: ParseError -> SourcePos
- errorMessages :: ParseError -> [Message]
- errorIsUnknown :: ParseError -> Bool
- showErrorMessages :: String -> String -> String -> String -> String -> [Message] -> String
- newErrorMessage :: Message -> SourcePos -> ParseError
- newErrorUnknown :: SourcePos -> ParseError
- addErrorMessage :: Message -> ParseError -> ParseError
- setErrorPos :: SourcePos -> ParseError -> ParseError
- setErrorMessage :: Message -> ParseError -> ParseError
- mergeError :: ParseError -> ParseError -> ParseError

# Documentation

data Message #

This abstract data type represents parse error messages. There are four kinds of messages:

     data Message = SysUnExpect String
                  | UnExpect String
                  | Expect String
                  | Message String

The fine distinction between different kinds of parse errors allows the system to generate quite good error messages for the user. It also allows error messages that are formatted in different languages. Each kind of message is generated by different combinators:

- A `SysUnExpect` message is automatically generated by the `satisfy` combinator. The argument is the unexpected input.
- A `UnExpect` message is generated by the `unexpected` combinator. The argument describes the unexpected item.
- A `Expect` message is generated by the `<?>` combinator. The argument describes the expected item.
- A `Message` message is generated by the `fail` combinator. The argument is some general parser message.

Constructors

SysUnExpect !String |
UnExpect !String |
Expect !String |
Message !String |

Instances

Enum Message # |
Instance details Defined in Text.Parsec.Error Methods succ :: Message -> Message Source # pred :: Message -> Message Source # toEnum :: Int -> Message Source # fromEnum :: Message -> Int Source # enumFrom :: Message -> [Message] Source # enumFromThen :: Message -> Message -> [Message] Source # enumFromTo :: Message -> Message -> [Message] Source # enumFromThenTo :: Message -> Message -> Message -> [Message] Source #
Eq Message # |
Instance details Defined in Text.Parsec.Error Methods (==) :: Message -> Message -> Bool # (/=) :: Message -> Message -> Bool #
Ord Message # |
Instance details Defined in Text.Parsec.Error Methods compare :: Message -> Message -> Ordering # (<) :: Message -> Message -> Bool # (<=) :: Message -> Message -> Bool # (>) :: Message -> Message -> Bool # (>=) :: Message -> Message -> Bool # max :: Message -> Message -> Message # min :: Message -> Message -> Message #

messageString :: Message -> String #

Extract the message string from an error message

messageCompare :: Message -> Message -> Ordering #

messageEq :: Message -> Message -> Bool #

data ParseError #

The abstract data type `ParseError` represents parse errors. It provides the source position (`SourcePos`) of the error and a list of error messages (`Message`). A `ParseError` can be returned by the function `parse`. `ParseError` is an instance of the `Show` and `Eq` classes.

Instances

Eq ParseError # |
Instance details Defined in Text.Parsec.Error Methods (==) :: ParseError -> ParseError -> Bool # (/=) :: ParseError -> ParseError -> Bool #
Show ParseError # |
Instance details Defined in Text.Parsec.Error Methods showsPrec :: Int -> ParseError -> ShowS Source # show :: ParseError -> String Source # showList :: [ParseError] -> ShowS Source #

errorPos :: ParseError -> SourcePos #

Extracts the source position from the parse error

errorMessages :: ParseError -> [Message] #

Extracts the list of error messages from the parse error

errorIsUnknown :: ParseError -> Bool #

showErrorMessages :: String -> String -> String -> String -> String -> [Message] -> String #

newErrorMessage :: Message -> SourcePos -> ParseError #

newErrorUnknown :: SourcePos -> ParseError #

addErrorMessage :: Message -> ParseError -> ParseError #

setErrorPos :: SourcePos -> ParseError -> ParseError #

setErrorMessage :: Message -> ParseError -> ParseError #

mergeError :: ParseError -> ParseError -> ParseError #