{-# LANGUAGE Rank2Types #-}
module Text.PariPari.Internal.Run (
runCharParser
, runSeqCharParser
, runCharParserWithOptions
, runSeqCharParserWithOptions
, runChunkParser
, runSeqChunkParser
, runChunkParserWithOptions
, runSeqChunkParserWithOptions
) where
import Text.PariPari.Internal.Acceptor
import Text.PariPari.Internal.Class
import Text.PariPari.Internal.Chunk
import Text.PariPari.Internal.Reporter
import GHC.Conc (par)
runCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a
runCharParser = runCharParserWithOptions defaultReportOptions
{-# INLINE runCharParser #-}
runSeqCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a
runSeqCharParser = runSeqCharParserWithOptions defaultReportOptions
{-# INLINE runSeqCharParser #-}
runCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a
runCharParserWithOptions o p f b =
let a = runAcceptor p f b
r = runReporterWithOptions o p f b
in case r `par` a of
Left _ -> r
Right x -> Right x
{-# INLINE runCharParserWithOptions #-}
runSeqCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a
runSeqCharParserWithOptions o p f b =
let a = runAcceptor p f b
r = runReporterWithOptions o p f b
in case a of
Left _ -> r
Right x -> Right x
{-# INLINE runSeqCharParserWithOptions #-}
runChunkParser :: CharChunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a
runChunkParser = runCharParserWithOptions defaultReportOptions
{-# INLINE runChunkParser #-}
runSeqChunkParser :: Chunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a
runSeqChunkParser = runSeqChunkParserWithOptions defaultReportOptions
{-# INLINE runSeqChunkParser #-}
runChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a
runChunkParserWithOptions o p f b =
let a = runAcceptor p f b
r = runReporterWithOptions o p f b
in case r `par` a of
Left _ -> r
Right x -> Right x
{-# INLINE runChunkParserWithOptions #-}
runSeqChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a
runSeqChunkParserWithOptions o p f b =
let a = runAcceptor p f b
r = runReporterWithOptions o p f b
in case a of
Left _ -> r
Right x -> Right x
{-# INLINE runSeqChunkParserWithOptions #-}