parsec-3.1.0: Monadic parser combinatorsSource codeContentsIndex
Text.Parsec.Error
Portabilityportable
Stabilityprovisional
Maintainerderek.a.elkins@gmail.com
Description
Parse errors
Synopsis
data Message
= SysUnExpect !String
| UnExpect !String
| Expect !String
| Message !String
messageString :: Message -> String
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 Source

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 Text.Parsec.Combinator.satisfy combinator. The argument is the unexpected input.
  • A UnExpect message is generated by the Text.Parsec.Prim.unexpected combinator. The argument describes the unexpected item.
  • A Expect message is generated by the Text.Parsec.Prim.<?> 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
messageString :: Message -> StringSource
Extract the message string from an error message
data ParseError Source
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 Text.Parsec.Prim.parse. ParseError is an instance of the Show class.
errorPos :: ParseError -> SourcePosSource
Extracts the source position from the parse error
errorMessages :: ParseError -> [Message]Source
Extracts the list of error messages from the parse error
errorIsUnknown :: ParseError -> BoolSource
showErrorMessages :: String -> String -> String -> String -> String -> [Message] -> StringSource
newErrorMessage :: Message -> SourcePos -> ParseErrorSource
newErrorUnknown :: SourcePos -> ParseErrorSource
addErrorMessage :: Message -> ParseError -> ParseErrorSource
setErrorPos :: SourcePos -> ParseError -> ParseErrorSource
setErrorMessage :: Message -> ParseError -> ParseErrorSource
mergeError :: ParseError -> ParseError -> ParseErrorSource
Produced by Haddock version 2.6.1