module Parsimony.IO
( parseFileASCII
, parseFileUTF8
, parseLargeFileASCII
, parseLargeFileUTF8
, uparseFileASCII
, uparseFileUTF8
, uparseLargeFileASCII
, uparseLargeFileUTF8
) where
import Parsimony.Prim
import Parsimony.Error
import Parsimony.Stream
import Parsimony.Combinator
import Parsimony.UserState
import qualified Data.ByteString as Strict
import qualified Data.ByteString.Lazy as Lazy
parseFileASCII :: FilePath
-> Parser (ASCII Strict.ByteString) a
-> IO (Either ParseError a)
parseFileASCII f p =
do bytes <- Strict.readFile f
return $ parseSource p f $ ascii bytes
parseFileUTF8 :: FilePath
-> Parser (UTF8 Strict.ByteString) a
-> IO (Either ParseError a)
parseFileUTF8 f p =
do bytes <- Strict.readFile f
return $ parseSource p f $ utf8 bytes
parseLargeFileASCII :: FilePath
-> Parser (ASCII Lazy.ByteString) a
-> IO (Either ParseError a)
parseLargeFileASCII f p =
do bytes <- Lazy.readFile f
return $ parseSource p f $ ascii bytes
parseLargeFileUTF8 :: FilePath
-> Parser (UTF8 Lazy.ByteString) a
-> IO (Either ParseError a)
parseLargeFileUTF8 f p =
do bytes <- Lazy.readFile f
return $ parseSource p f $ utf8 bytes
uparseFileASCII :: FilePath
-> ParserU u (ASCII Strict.ByteString) a
-> u -> IO (Either ParseError a)
uparseFileASCII f p u =
do bytes <- Strict.readFile f
return $ uparseSource p u f $ ascii bytes
uparseFileUTF8 :: FilePath
-> ParserU u (UTF8 Strict.ByteString) a
-> u -> IO (Either ParseError a)
uparseFileUTF8 f p u =
do bytes <- Strict.readFile f
return $ uparseSource p u f $ utf8 bytes
uparseLargeFileASCII :: FilePath
-> ParserU u (ASCII Lazy.ByteString) a
-> u -> IO (Either ParseError a)
uparseLargeFileASCII f p u =
do bytes <- Lazy.readFile f
return $ uparseSource p u f $ ascii bytes
uparseLargeFileUTF8 :: FilePath
-> ParserU u (UTF8 Lazy.ByteString) a
-> u -> IO (Either ParseError a)
uparseLargeFileUTF8 f p u =
do bytes <- Lazy.readFile f
return $ uparseSource p u f $ utf8 bytes