Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- unknownError :: State s u -> ParseError
- sysUnExpectError :: String -> SourcePos -> Reply s u a
- unexpected :: Stream s m t => String -> ParsecT s u m a
- type ParsecT = ParsecDSL
- runParsecT :: ParsecT s u m a -> ParsecDSL s u m a
- mkPT :: Monad m => (State s u -> m (Consumed (m (Reply s u a)))) -> ParsecT s u m a
- type Parsec s u = ParsecT s u Identity
- data Consumed a
- data Reply s u a
- = Ok a !(State s u) ParseError
- | Error ParseError
- data State s u = State {
- stateInput :: s
- statePos :: !SourcePos
- stateUser :: !u
- parsecMap :: (a -> b) -> ParsecT s u m a -> ParsecT s u m b
- parserReturn :: a -> ParsecT s u m a
- parserBind :: ParsecT s u m a -> (a -> ParsecT s u m b) -> ParsecT s u m b
- mergeErrorReply :: ParseError -> Reply s u a -> Reply s u a
- parserFail :: String -> ParsecT s u m a
- parserZero :: ParsecT s u m a
- parserPlus :: ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
- (<?>) :: ParsecT s u m a -> String -> ParsecT s u m a
- (<|>) :: ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
- label :: ParsecT s u m a -> String -> ParsecT s u m a
- labels :: ParsecT s u m a -> [String] -> ParsecT s u m a
- lookAhead :: Stream s m t => ParsecT s u m a -> ParsecT s u m a
- class Monad m => Stream s (m :: Type -> Type) t | s -> t where
- tokens :: (Monad m, Stream s m t, Eq t) => ([t] -> String) -> (SourcePos -> [t] -> SourcePos) -> [t] -> ParsecT s u m [t]
- try :: ParsecT s u m a -> ParsecT s u m a
- token :: Stream s Identity t => (t -> String) -> (t -> SourcePos) -> (t -> Maybe a) -> Parsec s u a
- tokenPrim :: Stream s m t => (t -> String) -> (SourcePos -> t -> s -> SourcePos) -> (t -> Maybe a) -> ParsecT s u m a
- tokenPrimEx :: Stream s m t => (t -> String) -> (SourcePos -> t -> s -> SourcePos) -> Maybe (SourcePos -> t -> s -> u -> u) -> (t -> Maybe a) -> ParsecT s u m a
- many :: ParsecT s u m a -> ParsecT s u m [a]
- skipMany :: ParsecT s u m a -> ParsecT s u m ()
- manyAccum :: (a -> [a] -> [a]) -> ParsecT s u m a -> ParsecT s u m [a]
- runPT :: (Monad m, Show t, Stream s m t) => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
- runPTLog :: (MonadIO m, MonadReader LogType m, Show t, Stream s m t) => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
- runP :: (Show t, Stream s Identity t) => Parsec s u a -> u -> SourceName -> s -> Either ParseError a
- runParserT :: (Show t, Stream s m t) => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
- runParserTLog :: (MonadIO m, MonadReader LogType m, Show t, Stream s m t) => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
- runParser :: (Show t, Stream s Identity t) => Parsec s u a -> u -> SourceName -> s -> Either ParseError a
- parse :: (Show t, Stream s Identity t) => Parsec s () a -> SourceName -> s -> Either ParseError a
- parseTest :: (Show t, Stream s Identity t, Show a) => Parsec s () a -> s -> IO ()
- parseTestLog :: (Show t, Stream s (ReaderT LogType IO) t, Show a) => Bool -> ParsecT s () (ReaderT LogType IO) a -> s -> IO ()
- getPosition :: forall (m :: Type -> Type) s u. Monad m => ParsecT s u m SourcePos
- getInput :: forall (m :: Type -> Type) s u. Monad m => ParsecT s u m s
- setPosition :: forall (m :: Type -> Type) s u. Monad m => SourcePos -> ParsecT s u m ()
- setInput :: forall (m :: Type -> Type) s u. Monad m => s -> ParsecT s u m ()
- getParserState :: Monad m => ParsecT s u m (State s u)
- setParserState :: Monad m => State s u -> ParsecT s u m (State s u)
- updateParserState :: Monad m => (State s u -> State s u) -> ParsecT s u m (State s u)
- getState :: Monad m => ParsecT s u m u
- putState :: Monad m => u -> ParsecT s u m ()
- modifyState :: Monad m => (u -> u) -> ParsecT s u m ()
- setState :: Monad m => u -> ParsecT s u m ()
- updateState :: Monad m => (u -> u) -> ParsecT s u m ()
Documentation
unknownError :: State s u -> ParseError #
sysUnExpectError :: String -> SourcePos -> Reply s u a #
runParsecT :: ParsecT s u m a -> ParsecDSL s u m a Source #
mkPT :: Monad m => (State s u -> m (Consumed (m (Reply s u a)))) -> ParsecT s u m a #
Low-level creation of the ParsecT type. You really shouldn't have to do this.
Ok a !(State s u) ParseError | |
Error ParseError |
parserReturn :: a -> ParsecT s u m a Source #
mergeErrorReply :: ParseError -> Reply s u a -> Reply s u a #
parserFail :: String -> ParsecT s u m a Source #
parserZero :: ParsecT s u m a Source #
label :: ParsecT s u m a -> String -> ParsecT s u m a Source #
A synonym for <?>
, but as a function instead of an operator.
class Monad m => Stream s (m :: Type -> Type) t | s -> t where #
An instance of Stream
has stream type s
, underlying monad m
and token type t
determined by the stream
Some rough guidelines for a "correct" instance of Stream:
- unfoldM uncons gives the [t] corresponding to the stream
- A
Stream
instance is responsible for maintaining the "position within the stream" in the stream states
. This is trivial unless you are using the monad in a non-trivial way.
Instances
Monad m => Stream ByteString m Char | |
Defined in Text.Parsec.Prim uncons :: ByteString -> m (Maybe (Char, ByteString)) # | |
Monad m => Stream ByteString m Char | |
Defined in Text.Parsec.Prim uncons :: ByteString -> m (Maybe (Char, ByteString)) # | |
Monad m => Stream Text m Char | |
Monad m => Stream Text m Char | |
Monad m => Stream [tok] m tok | |
Defined in Text.Parsec.Prim |
tokens :: (Monad m, Stream s m t, Eq t) => ([t] -> String) -> (SourcePos -> [t] -> SourcePos) -> [t] -> ParsecT s u m [t] Source #
tokenPrimEx :: Stream s m t => (t -> String) -> (SourcePos -> t -> s -> SourcePos) -> Maybe (SourcePos -> t -> s -> u -> u) -> (t -> Maybe a) -> ParsecT s u m a Source #
runPT :: (Monad m, Show t, Stream s m t) => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a) Source #
runPTLog :: (MonadIO m, MonadReader LogType m, Show t, Stream s m t) => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a) Source #
runP :: (Show t, Stream s Identity t) => Parsec s u a -> u -> SourceName -> s -> Either ParseError a Source #
runParserT :: (Show t, Stream s m t) => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a) Source #
runParserTLog :: (MonadIO m, MonadReader LogType m, Show t, Stream s m t) => ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a) Source #
runParser :: (Show t, Stream s Identity t) => Parsec s u a -> u -> SourceName -> s -> Either ParseError a Source #
parse :: (Show t, Stream s Identity t) => Parsec s () a -> SourceName -> s -> Either ParseError a Source #
getPosition :: forall (m :: Type -> Type) s u. Monad m => ParsecT s u m SourcePos #
Returns the current source position. See also SourcePos
.
setPosition :: forall (m :: Type -> Type) s u. Monad m => SourcePos -> ParsecT s u m () #
setPosition pos
sets the current source position to pos
.
setInput :: forall (m :: Type -> Type) s u. Monad m => s -> ParsecT s u m () #
setInput input
continues parsing with input
. The getInput
and
setInput
functions can for example be used to deal with #include
files.
getParserState :: Monad m => ParsecT s u m (State s u) Source #
Returns the full parser state as a State
record.
setParserState :: Monad m => State s u -> ParsecT s u m (State s u) Source #
setParserState st
set the full parser state to st
.
updateParserState :: Monad m => (State s u -> State s u) -> ParsecT s u m (State s u) Source #
updateParserState f
applies function f
to the parser state.
modifyState :: Monad m => (u -> u) -> ParsecT s u m () Source #
modifyState f
applies function f
to the user state. Suppose
that we want to count identifiers in a source, we could use the user
state as:
expr = do{ x <- identifier ; modifyState (+1) ; return (Id x) }
setState :: Monad m => u -> ParsecT s u m () Source #
An alias for putState for backwards compatibility.
updateState :: Monad m => (u -> u) -> ParsecT s u m () Source #
An alias for modifyState for backwards compatibility.