module Data.ParserCombinators.KangarooReader
(
Kangaroo
, parse
, runKangaroo
, ask
, asks
, local
, ParseErr
, RegionCoda(..)
, RegionName
, liftIOAction
, reportError
, substError
, word8
, satisfy
, checkWord8
, opt
, skip
, position
, region
, atEnd
, lengthRemaining
, regionSize
, intraparse
, advance
, advanceRelative
, restrict
, restrictToPos
, printHexAll
, printHexRange
, printRegionStack
, module Data.ParserCombinators.Kangaroo.Combinators
, module Data.ParserCombinators.Kangaroo.Prim
) where
import Data.ParserCombinators.Kangaroo.Combinators
import Data.ParserCombinators.Kangaroo.ParseMonad
import Data.ParserCombinators.Kangaroo.Prim
import Control.Monad ( liftM )
type Kangaroo r a = GenKangaroo r a
parse :: Kangaroo r a
-> r
-> FilePath
-> IO (Either ParseErr a)
parse = runKangaroo
runKangaroo :: Kangaroo r a
-> r
-> FilePath
-> IO (Either ParseErr a)
runKangaroo p env filename = liftM fst (runGenKangaroo p env filename)
ask :: Kangaroo r r
ask = getUserSt
asks :: (r -> a) -> Kangaroo r a
asks f = liftM f getUserSt
local :: (r -> r) -> Kangaroo r a -> Kangaroo r a
local f ma = do
e <- getUserSt
putUserSt (f e)
ans <- ma
putUserSt e
return ans