language-c-0.10.1: Analysis and generation of C code

Copyright | (c) 2008 Benedikt Huber Manuel M. T. Chakravarty
License | BSD-style
Maintainer | benedikt.huber@gmail.com
Stability | experimental
Portability | ghc
Safe Haskell | None
Language | Haskell2010

Language.C.Data.Error

Contents

- Severity Level
- Error class
- Error `supertype`
- Infos attached to errors
- Default error types
- Raising internal errors

Description

Base type for errors occurring in parsing, analysing and pretty-printing. With ideas from Simon Marlow's "An extensible dynamically-typed hierarchy of execeptions [2006]"

Synopsis

- data ErrorLevel
  - = LevelWarn
  - | LevelError
  - | LevelFatal
- isHardError :: Error ex => ex -> Bool
- class (Typeable e, Show e) => Error e where
  - errorInfo :: e -> ErrorInfo
  - toError :: e -> CError
  - fromError :: CError -> Maybe e
  - changeErrorLevel :: e -> ErrorLevel -> e
- errorPos :: Error e => e -> Position
- errorLevel :: Error e => e -> ErrorLevel
- errorMsgs :: Error e => e -> [String]
- data CError = Error err => CError err
- data ErrorInfo = ErrorInfo ErrorLevel Position [String]
- showError :: Error e => String -> e -> String
- showErrorInfo :: String -> ErrorInfo -> String
- mkErrorInfo :: ErrorLevel -> String -> NodeInfo -> ErrorInfo
- data UnsupportedFeature
- unsupportedFeature :: Pos a => String -> a -> UnsupportedFeature
- unsupportedFeature_ :: String -> UnsupportedFeature
- data UserError
- userErr :: String -> UserError
- internalErr :: String -> a

# Severity Level

data ErrorLevel Source #

Error levels (severity)

Constructors

LevelWarn |
LevelError |
LevelFatal |

#### Instances

Instances details

Show ErrorLevel Source # |
Instance details Defined in Language.C.Data.Error Methods showsPrec :: Int -> ErrorLevel -> ShowS Source # show :: ErrorLevel -> String Source # showList :: [ErrorLevel] -> ShowS Source #
Eq ErrorLevel Source # |
Instance details Defined in Language.C.Data.Error Methods (==) :: ErrorLevel -> ErrorLevel -> Bool Source # (/=) :: ErrorLevel -> ErrorLevel -> Bool Source #
Ord ErrorLevel Source # |

Instance details

Defined in Language.C.Data.Error

Methods

compare :: ErrorLevel -> ErrorLevel -> Ordering Source #

(<) :: ErrorLevel -> ErrorLevel -> Bool Source #

(<=) :: ErrorLevel -> ErrorLevel -> Bool Source #

(>) :: ErrorLevel -> ErrorLevel -> Bool Source #

(>=) :: ErrorLevel -> ErrorLevel -> Bool Source #

max :: ErrorLevel -> ErrorLevel -> ErrorLevel Source #

min :: ErrorLevel -> ErrorLevel -> ErrorLevel Source #

isHardError :: Error ex => ex -> Bool Source #

return `True` when the given error makes it impossible to continue analysis or compilation.

# Error class

class (Typeable e, Show e) => Error e where Source #

errors in Language.C are instance of `Error`

Minimal complete definition

errorInfo

Methods

errorInfo :: e -> ErrorInfo Source #

obtain source location etc. of an error

toError :: e -> CError Source #

wrap error in `CError`

fromError :: CError -> Maybe e Source #

try to cast a generic `CError` to the specific error type

changeErrorLevel :: e -> ErrorLevel -> e Source #

modify the error level

#### Instances

Instances details

Error BadSpecifierError Source # |
Instance details Defined in Language.C.Analysis.SemError Methods errorInfo :: BadSpecifierError -> ErrorInfo Source # toError :: BadSpecifierError -> CError Source # fromError :: CError -> Maybe BadSpecifierError Source # changeErrorLevel :: BadSpecifierError -> ErrorLevel -> BadSpecifierError Source #
Error InvalidASTError Source # |
Instance details Defined in Language.C.Analysis.SemError Methods errorInfo :: InvalidASTError -> ErrorInfo Source # toError :: InvalidASTError -> CError Source # fromError :: CError -> Maybe InvalidASTError Source # changeErrorLevel :: InvalidASTError -> ErrorLevel -> InvalidASTError Source #
Error RedefError Source # |
Instance details Defined in Language.C.Analysis.SemError Methods errorInfo :: RedefError -> ErrorInfo Source # toError :: RedefError -> CError Source # fromError :: CError -> Maybe RedefError Source # changeErrorLevel :: RedefError -> ErrorLevel -> RedefError Source #
Error TypeMismatch Source # |
Instance details Defined in Language.C.Analysis.SemError Methods errorInfo :: TypeMismatch -> ErrorInfo Source # toError :: TypeMismatch -> CError Source # fromError :: CError -> Maybe TypeMismatch Source # changeErrorLevel :: TypeMismatch -> ErrorLevel -> TypeMismatch Source #
Error CError Source # |
Instance details Defined in Language.C.Data.Error Methods errorInfo :: CError -> ErrorInfo Source # toError :: CError -> CError Source # fromError :: CError -> Maybe CError Source # changeErrorLevel :: CError -> ErrorLevel -> CError Source #
Error ErrorInfo Source # |
Instance details Defined in Language.C.Data.Error Methods errorInfo :: ErrorInfo -> ErrorInfo Source # toError :: ErrorInfo -> CError Source # fromError :: CError -> Maybe ErrorInfo Source # changeErrorLevel :: ErrorInfo -> ErrorLevel -> ErrorInfo Source #
Error UnsupportedFeature Source # |
Instance details Defined in Language.C.Data.Error Methods errorInfo :: UnsupportedFeature -> ErrorInfo Source # toError :: UnsupportedFeature -> CError Source # fromError :: CError -> Maybe UnsupportedFeature Source # changeErrorLevel :: UnsupportedFeature -> ErrorLevel -> UnsupportedFeature Source #
Error UserError Source # |
Instance details Defined in Language.C.Data.Error Methods errorInfo :: UserError -> ErrorInfo Source # toError :: UserError -> CError Source # fromError :: CError -> Maybe UserError Source # changeErrorLevel :: UserError -> ErrorLevel -> UserError Source #

errorPos :: Error e => e -> Position Source #

position of an `Error`

errorLevel :: Error e => e -> ErrorLevel Source #

severity level of an `Error`

errorMsgs :: Error e => e -> [String] Source #

message lines of an `Error`

# Error `supertype`

data CError Source #

`supertype` of all errors

Constructors

Error err => CError err |

#### Instances

Instances details

Show CError Source # |
Instance details Defined in Language.C.Data.Error Methods showsPrec :: Int -> CError -> ShowS Source # show :: CError -> String Source # showList :: [CError] -> ShowS Source #
Error CError Source # |
Instance details Defined in Language.C.Data.Error Methods errorInfo :: CError -> ErrorInfo Source # toError :: CError -> CError Source # fromError :: CError -> Maybe CError Source # changeErrorLevel :: CError -> ErrorLevel -> CError Source #

# Infos attached to errors

data ErrorInfo Source #

information attached to every error in Language.C

Constructors

ErrorInfo ErrorLevel Position [String] |

#### Instances

Instances details

Show ErrorInfo Source # |
Instance details Defined in Language.C.Data.Error Methods showsPrec :: Int -> ErrorInfo -> ShowS Source # show :: ErrorInfo -> String Source # showList :: [ErrorInfo] -> ShowS Source #
Error ErrorInfo Source # |
Instance details Defined in Language.C.Data.Error Methods errorInfo :: ErrorInfo -> ErrorInfo Source # toError :: ErrorInfo -> CError Source # fromError :: CError -> Maybe ErrorInfo Source # changeErrorLevel :: ErrorInfo -> ErrorLevel -> ErrorInfo Source #

showError :: Error e => String -> e -> String Source #

showErrorInfo :: String -> ErrorInfo -> String Source #

converts an error into a string using a fixed format

- either the lines of the long error message or the short message has to be non-empty
- the format is

       <fname>:<row>: (column <col>) [<err lvl>]
         >>> <line_1>
         <line_2>
           ...
         <line_n>

mkErrorInfo :: ErrorLevel -> String -> NodeInfo -> ErrorInfo Source #

# Default error types

data UnsupportedFeature Source #

error raised if a operation requires an unsupported or not yet implemented feature.

#### Instances

Instances details

Show UnsupportedFeature Source # |
Instance details Defined in Language.C.Data.Error Methods showsPrec :: Int -> UnsupportedFeature -> ShowS Source # show :: UnsupportedFeature -> String Source # showList :: [UnsupportedFeature] -> ShowS Source #
Error UnsupportedFeature Source # |
Instance details Defined in Language.C.Data.Error Methods errorInfo :: UnsupportedFeature -> ErrorInfo Source # toError :: UnsupportedFeature -> CError Source # fromError :: CError -> Maybe UnsupportedFeature Source # changeErrorLevel :: UnsupportedFeature -> ErrorLevel -> UnsupportedFeature Source #

unsupportedFeature :: Pos a => String -> a -> UnsupportedFeature Source #

unsupportedFeature_ :: String -> UnsupportedFeature Source #

data UserError Source #

unspecified error raised by the user (in case the user does not want to define her own error types).

#### Instances

Instances details

Show UserError Source # |
Instance details Defined in Language.C.Data.Error Methods showsPrec :: Int -> UserError -> ShowS Source # show :: UserError -> String Source # showList :: [UserError] -> ShowS Source #
Error UserError Source # |
Instance details Defined in Language.C.Data.Error Methods errorInfo :: UserError -> ErrorInfo Source # toError :: UserError -> CError Source # fromError :: CError -> Maybe UserError Source # changeErrorLevel :: UserError -> ErrorLevel -> UserError Source #

userErr :: String -> UserError Source #

# Raising internal errors

internalErr :: String -> a Source #

raise a fatal internal error; message may have multiple lines