Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class (MonadFail p, MonadPlus p, Chunk k) => ChunkParser k p | p -> k where
- class (ChunkParser k p, CharChunk k) => CharParser k p | p -> k where
- data Error
- showError :: Error -> String
- class (Ord (Element k), Ord k) => Chunk k where
- type Element k
- class Chunk k => CharChunk k
- data Pos = Pos {
- _posLine :: !Int
- _posColumn :: !Int
- runCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a
- runSeqCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a
- runCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a
- runSeqCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a
- runChunkParser :: CharChunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a
- runSeqChunkParser :: Chunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a
- runChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a
- runSeqChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a
- data Acceptor k a
- runAcceptor :: Chunk k => Acceptor k a -> FilePath -> k -> Either Error a
- data Reporter k a
- runReporter :: Chunk k => Reporter k a -> FilePath -> k -> Either Report a
- showReport :: Report -> String
- showErrors :: [ErrorContext] -> String
- runReporterWithOptions :: Chunk k => ReportOptions -> Reporter k a -> FilePath -> k -> Either Report a
- data Tracer k a
- runTracer :: Chunk k => Tracer k a -> FilePath -> k -> Either Report a
- 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, getPos, getRefPos, withRefPos, notFollowedBy, lookAhead, failWith, eof, label, hidden, commit, element, elementSatisfy, chunk, asChunk
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
Hide errors occurring within the given parser
from the error report. Based on the given
labels an Error
is constructed instead.
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).
Note: commit
only applies to the reported
errors, it has no effect on the backtracking behavior
of the parser.
element :: Element k -> p (Element k) Source #
Parse a single element
elementSatisfy :: (Element k -> Bool) -> p (Element k) Source #
Parse a single byte with the given predicate
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, 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.
satisfy :: (Char -> Bool) -> p Char Source #
Parse a single character with the given predicate
Note: The character '\0' cannot be parsed using this combinator
since it is used as decoding sentinel. Use elementSatisfy
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.
asciiSatisfy :: (Word8 -> Bool) -> p Word8 Source #
Parse a single character within the ASCII charset with the given predicate
Note: The character '\0' cannot be parsed using this combinator
since it is used as decoding sentinel. Use elementSatisfy
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 :: * Source # type Buffer ByteString :: * 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.2.0.0-QVoQxDaLiCdimzOS5pSG" 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 -> Either Report a Source #
runSeqCharParser :: CharChunk k => (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a Source #
runCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a Source #
Run parsers **in parallel** with additional ReportOptions
.
runSeqCharParserWithOptions :: CharChunk k => ReportOptions -> (forall p. CharParser k p => p a) -> FilePath -> k -> Either Report a Source #
Run parsers **sequentially** with additional ReportOptions
.
runChunkParser :: CharChunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a Source #
runSeqChunkParser :: Chunk k => (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a Source #
runChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a Source #
Run parsers **in parallel** with additional ReportOptions
.
runSeqChunkParserWithOptions :: Chunk k => ReportOptions -> (forall p. ChunkParser k p => p a) -> FilePath -> k -> Either Report a 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
showErrors :: [ErrorContext] -> String Source #
Pretty string representation of '[ErrorContext]'.
runReporterWithOptions :: Chunk k => ReportOptions -> Reporter k a -> FilePath -> k -> Either Report a Source #
Run Reporter
with additional ReportOptions
.
Parser which prints trace messages, when backtracking occurs.