Distribution.Parsec.LexerMonad

Cabal-2.1.0.0: A framework for packaging Haskell software

License | BSD3
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | None
Language | Haskell2010

Distribution.Parsec.LexerMonad

Description

Synopsis

- type InputStream = ByteString
- data LexState = LexState {
  - curPos :: !Position
  - curInput :: !InputStream
  - curCode :: !StartCode
  - warnings :: [LexWarning]
  }
- data LexResult a = LexResult !LexState a
- newtype Lex a = Lex {
  - unLex :: LexState -> LexResult a
  }
- execLexer :: Lex a -> InputStream -> ([LexWarning], a)
- getPos :: Lex Position
- setPos :: Position -> Lex ()
- adjustPos :: (Position -> Position) -> Lex ()
- getInput :: Lex InputStream
- setInput :: InputStream -> Lex ()
- getStartCode :: Lex Int
- setStartCode :: Int -> Lex ()
- data LexWarning = LexWarning !LexWarningType !Position !String
- data LexWarningType
  - = LexWarningNBSP
  - | LexWarningBOM
- addWarning :: LexWarningType -> String -> Lex ()
- toPWarning :: LexWarning -> PWarning

# Documentation

type InputStream = ByteString Source #

data LexState Source #

Constructors

LexState |
Fields curPos :: !Position position at current input location curInput :: !InputStream the current input curCode :: !StartCode lexer code warnings :: [LexWarning]

data LexResult a Source #

Constructors

LexResult !LexState a |

newtype Lex a Source #

Constructors

Lex |
Fields unLex :: LexState -> LexResult a

Instances

Monad Lex # |
Instance details Methods (>>=) :: Lex a -> (a -> Lex b) -> Lex b Source # (>>) :: Lex a -> Lex b -> Lex b Source # return :: a -> Lex a Source # fail :: String -> Lex a Source #
Functor Lex # |
Instance details Methods fmap :: (a -> b) -> Lex a -> Lex b Source # (<$) :: a -> Lex b -> Lex a Source #
Applicative Lex # |
Instance details Methods pure :: a -> Lex a Source # (<*>) :: Lex (a -> b) -> Lex a -> Lex b Source # liftA2 :: (a -> b -> c) -> Lex a -> Lex b -> Lex c Source # (*>) :: Lex a -> Lex b -> Lex b Source # (<*) :: Lex a -> Lex b -> Lex a Source #

execLexer :: Lex a -> InputStream -> ([LexWarning], a) Source #

Execute the given lexer on the supplied input stream.

getPos :: Lex Position Source #

setPos :: Position -> Lex () Source #

adjustPos :: (Position -> Position) -> Lex () Source #

getInput :: Lex InputStream Source #

setInput :: InputStream -> Lex () Source #

getStartCode :: Lex Int Source #

setStartCode :: Int -> Lex () Source #

data LexWarning Source #

Constructors

LexWarning !LexWarningType !Position !String |

Instances

Show LexWarning # |
Instance details Methods showsPrec :: Int -> LexWarning -> ShowS Source # show :: LexWarning -> String Source # showList :: [LexWarning] -> ShowS Source #

data LexWarningType Source #

Constructors

LexWarningNBSP | Encountered non breaking space
LexWarningBOM | BOM at the start of the cabal file

Instances

Show LexWarningType # |
Instance details Methods showsPrec :: Int -> LexWarningType -> ShowS Source # show :: LexWarningType -> String Source # showList :: [LexWarningType] -> ShowS Source #

addWarning :: LexWarningType -> String -> Lex () Source #

Add warning at the current position

toPWarning :: LexWarning -> PWarning Source #