{-# 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 -> (Maybe a, [Report])
runCharParser = runCharParserWithOptions defaultReportOptions
{-# INLINE runCharParser #-}
runSeqCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
runSeqCharParser = runSeqCharParserWithOptions defaultReportOptions
{-# INLINE runSeqCharParser #-}
runCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
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 -> (Just x, [])
{-# INLINE runCharParserWithOptions #-}
runSeqCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
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 -> (Just x, [])
{-# INLINE runSeqCharParserWithOptions #-}
runChunkParser :: CharChunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
runChunkParser = runCharParserWithOptions defaultReportOptions
{-# INLINE runChunkParser #-}
runSeqChunkParser :: Chunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
runSeqChunkParser = runSeqChunkParserWithOptions defaultReportOptions
{-# INLINE runSeqChunkParser #-}
runChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
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 -> (Just x, [])
{-# INLINE runChunkParserWithOptions #-}
runSeqChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
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 -> (Just x, [])
{-# INLINE runSeqChunkParserWithOptions #-}