Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class (MonadFail p, MonadPlus p, Chunk k) => ChunkParser k p | p -> k where
- getFile :: p FilePath
- getPos :: p Pos
- getRefPos :: p Pos
- withRefPos :: p a -> p a
- notFollowedBy :: Show a => p a -> p ()
- lookAhead :: p a -> p a
- failWith :: Error -> p a
- eof :: p ()
- label :: String -> p a -> p a
- hidden :: p a -> p a
- commit :: p a -> p a
- recover :: p a -> p a -> p a
- element :: Element k -> p (Element k)
- elementScan :: (Element k -> Maybe a) -> p a
- chunk :: k -> p k
- asChunk :: p () -> p k
- class (ChunkParser k p, IsString (p k), CharChunk k) => CharParser k p | p -> k where
- data Error
- showError :: Error -> String
- class (Ord (Element k), Ord k) => Chunk k where
- class Chunk k => CharChunk k
- data Pos = Pos {
- _posLine :: !Int
- _posColumn :: !Int
- runCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
- runSeqCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
- runCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
- runSeqCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
- runChunkParser :: CharChunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
- runSeqChunkParser :: Chunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
- runChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
- runSeqChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report])
- data Acceptor k a
- runAcceptor :: Chunk k => Acceptor k a -> FilePath -> k -> Either Error a
- data Reporter k a
- data Report = Report {
- _reportFile :: !FilePath
- _reportLine :: !Int
- _reportColumn :: !Int
- _reportErrors :: [ErrorContext]
- data ErrorContext = ErrorContext {
- _ecErrors :: [Error]
- _ecContext :: [String]
- data ReportOptions = ReportOptions {}
- runReporter :: Chunk k => Reporter k a -> FilePath -> k -> (Maybe a, [Report])
- showReport :: Report -> String
- showErrors :: [ErrorContext] -> String
- runReporterWithOptions :: Chunk k => ReportOptions -> Reporter k a -> FilePath -> k -> (Maybe a, [Report])
- defaultReportOptions :: ReportOptions
- data Tracer k a
- runTracer :: Chunk k => Tracer k a -> FilePath -> k -> (Maybe a, [Report])
- module Text.PariPari.Internal.ElementCombinators
- module Text.PariPari.Internal.CharCombinators
Documentation
class (MonadFail p, MonadPlus p, Chunk k) => ChunkParser k p | p -> k where Source #
Parser class, which specifies the necessary primitives for parsing. All other parser combinators rely on these primitives.
getFile :: p FilePath Source #
Get file name associated with current parser
Get current position of the parser
Get reference position used for indentation-sensitive parsing
withRefPos :: p a -> p a Source #
Update reference position with current position
notFollowedBy :: Show a => p a -> p () Source #
Parser which succeeds when the given parser fails
lookAhead :: p a -> p a Source #
Look ahead and return result of the given parser The current position stays the same.
failWith :: Error -> p a Source #
Parser failure with detailled Error
Parser which succeeds at the end of file
label :: String -> p a -> p a Source #
Annotate the given parser with a label used for error reporting.
Note: This function has zero cost in the Acceptor
. You can
use it to improve the error reports without slowing
down the fast path of your parser.
Hide errors occurring within the given parser
from the error report. Based on the given
labels an Error
is constructed instead.
Note: This function has zero cost in the Acceptor
. You can
use it to improve the error reports without slowing
down the fast path of your parser.
Commit to the given branch, increasing the priority of the errors within this branch in contrast to other branches.
This is basically the opposite of the try
combinator provided by other parser combinator
libraries, which decreases the error priority
within the given branch (and usually also influences backtracking).
commit
only applies to the reported
errors, it has no effect on the backtracking behavior
of the parser.
Note: This function has zero cost in the Acceptor
. You can
use it to improve the error reports without slowing
down the fast path of your parser.
recover :: p a -> p a -> p a Source #
Parse with error recovery.
If the parser p fails in `recover p r`
the parser r continues at the position where p failed.
If the recovering parser r fails too, the whole
parser fails. The errors reported by the recovering
parser are ignored in any case.
Error recovery support is only available
in the Reporter
instance.
Note: This function has zero cost in the Acceptor
. You can
use it to improve the error reports without slowing
down the fast path of your parser.
element :: Element k -> p (Element k) Source #
Parse a single element
elementScan :: (Element k -> Maybe a) -> p a Source #
Scan a single element
Parse a chunk of elements. The chunk must not contain multiple lines, otherwise the position information will be invalid.
asChunk :: p () -> p k Source #
Run the given parser and return the result as buffer
Instances
class (ChunkParser k p, IsString (p k), CharChunk k) => CharParser k p | p -> k where Source #
char :: Char -> p Char Source #
Parse a single character
Note: The character '\0' cannot be parsed using this combinator
since it is used as decoding sentinel. Use element
instead.
scan :: (Char -> Maybe a) -> p a Source #
Scan a single character
Note: The character '\0' cannot be parsed using this combinator
since it is used as decoding sentinel. Use elementScan
instead.
asciiByte :: Word8 -> p Word8 Source #
Parse a single character within the ASCII charset
Note: The character '\0' cannot be parsed using this combinator
since it is used as decoding sentinel. Use element
instead.
asciiScan :: (Word8 -> Maybe a) -> p a Source #
Scan a single character within the ASCII charset
Note: The character '\0' cannot be parsed using this combinator
since it is used as decoding sentinel. Use elementScan
instead.
Instances
CharChunk k => CharParser k (Acceptor k) Source # | |
CharChunk k => CharParser k (Reporter k) Source # | |
CharChunk k => CharParser k (Tracer k) Source # | |
Parsing errors
EInvalidUtf8 | |
EExpected [String] | |
EUnexpected String | |
EFail String | |
ECombinator String | |
EIndentNotAligned !Int !Int | |
EIndentOverLine !Int !Int | |
ENotEnoughIndent !Int !Int |
Instances
class (Ord (Element k), Ord k) => Chunk k where Source #
Instances
Chunk ByteString Source # | |
Defined in Text.PariPari.Internal.Chunk type Element ByteString :: Type Source # type Buffer ByteString :: Type Source # elementAt :: Buffer ByteString -> Int -> (Element ByteString, Int) Source # elementPos :: Element ByteString -> Pos -> Pos Source # chunkWidth :: ByteString -> Int Source # chunkEqual :: Buffer ByteString -> Int -> ByteString -> Bool Source # packChunk :: Buffer ByteString -> Int -> Int -> ByteString Source # unpackChunk :: ByteString -> (Buffer ByteString, Int, Int) Source # showElement :: Element ByteString -> String Source # showChunk :: ByteString -> String Source # | |
Chunk Text Source # | |
Defined in Text.PariPari.Internal.Chunk elementAt :: Buffer Text -> Int -> (Element Text, Int) Source # elementPos :: Element Text -> Pos -> Pos Source # chunkWidth :: Text -> Int Source # chunkEqual :: Buffer Text -> Int -> Text -> Bool Source # packChunk :: Buffer Text -> Int -> Int -> Text Source # unpackChunk :: Text -> (Buffer Text, Int, Int) Source # |
class Chunk k => CharChunk k Source #
Instances
CharChunk ByteString Source # | |
Defined in Text.PariPari.Internal.Chunk | |
CharChunk Text Source # | |
Line and column position starting at (1,1)
Pos | |
|
Instances
Eq Pos Source # | |
Show Pos Source # | |
Generic Pos Source # | |
type Rep Pos Source # | |
Defined in Text.PariPari.Internal.Chunk type Rep Pos = D1 (MetaData "Pos" "Text.PariPari.Internal.Chunk" "paripari-0.6.0.1-JCqv7UKAs2N5N8Bslf6KXq" False) (C1 (MetaCons "Pos" PrefixI True) (S1 (MetaSel (Just "_posLine") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Just "_posColumn") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int))) |
runCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report]) Source #
runSeqCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report]) Source #
runCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report]) Source #
Run parsers **in parallel** with additional ReportOptions
.
runSeqCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> (Maybe a, [Report]) Source #
Run parsers **sequentially** with additional ReportOptions
.
runChunkParser :: CharChunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report]) Source #
runSeqChunkParser :: Chunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report]) Source #
runChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report]) Source #
Run parsers **in parallel** with additional ReportOptions
.
runSeqChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> (Maybe a, [Report]) Source #
Run parsers **sequentially** with additional ReportOptions
.
Parser which is optimised for fast parsing. Error reporting is minimal.
Instances
Parser which is optimised for good error reports.
Performance is secondary, since the Reporter
is used
as a fallback to the Acceptor
.
Instances
Report | |
|
Instances
Eq Report Source # | |
Show Report Source # | |
Generic Report Source # | |
type Rep Report Source # | |
Defined in Text.PariPari.Internal.Reporter type Rep Report = D1 (MetaData "Report" "Text.PariPari.Internal.Reporter" "paripari-0.6.0.1-JCqv7UKAs2N5N8Bslf6KXq" False) (C1 (MetaCons "Report" PrefixI True) ((S1 (MetaSel (Just "_reportFile") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 FilePath) :*: S1 (MetaSel (Just "_reportLine") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int)) :*: (S1 (MetaSel (Just "_reportColumn") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Just "_reportErrors") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ErrorContext])))) |
data ErrorContext Source #
ErrorContext | |
|
Instances
data ReportOptions Source #
Instances
showErrors :: [ErrorContext] -> String Source #
Pretty string representation of '[ErrorContext]'.
runReporterWithOptions :: Chunk k => ReportOptions -> Reporter k a -> FilePath -> k -> (Maybe a, [Report]) Source #
Run Reporter
with additional ReportOptions
.
Parser which prints trace messages, when backtracking occurs.