module Hectoparsec
(
module Hectoparsec.Error
, module Hectoparsec.Pos
, module Hectoparsec.Stream
, module Hectoparsec.State
, ParserT
, evalParserT
, runParserT
, Parser
, evalParser
, runParser
, MonadParser(..)
, anyToken
, char
, string
, satisfy
, peek
, peekNext
, countTokens
, tokenWhile
, tokenWhile1
, matchRest
, atEnd
, label
, (<?>)
, hidden
, restore
, unexpected
, failure
, customError
, getsState
, modifyState
, getInput
, getsInput
, putInput
, modifyInput
, getPos
, getOffset
) where
import Data.Functor.Identity
import Hectoparsec.Class
import Hectoparsec.Error
import Hectoparsec.Pos
import Hectoparsec.Primitive
import Hectoparsec.State
import Hectoparsec.Stream
evalParserT
:: Monad m
=> ParserT s e l m a
-> FilePath
-> s
-> m (Either (ParseError s e l) a)
evalParserT :: forall (m :: * -> *) s e l a.
Monad m =>
ParserT s e l m a
-> FilePath -> s -> m (Either (ParseError s e l) a)
evalParserT ParserT s e l m a
p FilePath
fp s
s = ((State s, Either (ParseError s e l) a)
-> Either (ParseError s e l) a)
-> m (State s, Either (ParseError s e l) a)
-> m (Either (ParseError s e l) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (State s, Either (ParseError s e l) a)
-> Either (ParseError s e l) a
forall a b. (a, b) -> b
snd (m (State s, Either (ParseError s e l) a)
-> m (Either (ParseError s e l) a))
-> m (State s, Either (ParseError s e l) a)
-> m (Either (ParseError s e l) a)
forall a b. (a -> b) -> a -> b
$ ParserT s e l m a
-> State s -> m (State s, Either (ParseError s e l) a)
forall (m :: * -> *) s e l a.
Monad m =>
ParserT s e l m a
-> State s -> m (State s, Either (ParseError s e l) a)
runParserT ParserT s e l m a
p (FilePath -> s -> State s
forall s. FilePath -> s -> State s
initialState FilePath
fp s
s)
runParserT
:: Monad m
=> ParserT s e l m a
-> State s
-> m (State s, Either (ParseError s e l) a)
runParserT :: forall (m :: * -> *) s e l a.
Monad m =>
ParserT s e l m a
-> State s -> m (State s, Either (ParseError s e l) a)
runParserT ParserT s e l m a
p State s
st = do
Reply State s
st' Bool
_ Either (ParseError s e l) a
res <- ParserT s e l m a -> State s -> m (Reply s e l a)
forall (m :: * -> *) s e l a.
Monad m =>
ParserT s e l m a -> State s -> m (Reply s e l a)
contParserT ParserT s e l m a
p State s
st
(State s, Either (ParseError s e l) a)
-> m (State s, Either (ParseError s e l) a)
forall (m :: * -> *) a. Monad m => a -> m a
return ((State s, Either (ParseError s e l) a)
-> m (State s, Either (ParseError s e l) a))
-> (State s, Either (ParseError s e l) a)
-> m (State s, Either (ParseError s e l) a)
forall a b. (a -> b) -> a -> b
$ case Either (ParseError s e l) a
res of
Right a
a -> (State s
st', a -> Either (ParseError s e l) a
forall a b. b -> Either a b
Right a
a)
Left ParseError s e l
e -> (State s
st', ParseError s e l -> Either (ParseError s e l) a
forall a b. a -> Either a b
Left ParseError s e l
e)
evalParser
:: Parser s e l a
-> FilePath
-> s
-> Either (ParseError s e l) a
evalParser :: forall s e l a.
Parser s e l a -> FilePath -> s -> Either (ParseError s e l) a
evalParser Parser s e l a
p FilePath
fp s
s = Identity (Either (ParseError s e l) a)
-> Either (ParseError s e l) a
forall a. Identity a -> a
runIdentity (Identity (Either (ParseError s e l) a)
-> Either (ParseError s e l) a)
-> Identity (Either (ParseError s e l) a)
-> Either (ParseError s e l) a
forall a b. (a -> b) -> a -> b
$ Parser s e l a
-> FilePath -> s -> Identity (Either (ParseError s e l) a)
forall (m :: * -> *) s e l a.
Monad m =>
ParserT s e l m a
-> FilePath -> s -> m (Either (ParseError s e l) a)
evalParserT Parser s e l a
p FilePath
fp s
s
runParser
:: Parser s e l a
-> State s
-> (State s, Either (ParseError s e l) a)
runParser :: forall s e l a.
Parser s e l a -> State s -> (State s, Either (ParseError s e l) a)
runParser Parser s e l a
p State s
st = Identity (State s, Either (ParseError s e l) a)
-> (State s, Either (ParseError s e l) a)
forall a. Identity a -> a
runIdentity (Identity (State s, Either (ParseError s e l) a)
-> (State s, Either (ParseError s e l) a))
-> Identity (State s, Either (ParseError s e l) a)
-> (State s, Either (ParseError s e l) a)
forall a b. (a -> b) -> a -> b
$ Parser s e l a
-> State s -> Identity (State s, Either (ParseError s e l) a)
forall (m :: * -> *) s e l a.
Monad m =>
ParserT s e l m a
-> State s -> m (State s, Either (ParseError s e l) a)
runParserT Parser s e l a
p State s
st