Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class (MonadFail p, MonadPlus p, Chunk k) => ChunkParser k p | p -> k where
- class (ChunkParser k p, IsString (p k), CharChunk k) => CharParser k p | p -> k where
- class Applicative f => Alternative (f :: * -> *) where
- class (Alternative m, Monad m) => MonadPlus (m :: * -> *)
- data Pos = Pos {
- _posLine :: !Int
- _posColumn :: !Int
- data Error
- showError :: Error -> String
- expectedEnd :: Error
- unexpectedEnd :: Error
- string :: CharParser k p => String -> p k
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, elementScan, 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
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 # | |
class Applicative f => Alternative (f :: * -> *) where #
A monoid on applicative functors.
If defined, some
and many
should be the least solutions
of the equations:
Instances
class (Alternative m, Monad m) => MonadPlus (m :: * -> *) #
Monads that also support choice and failure.
Instances
MonadPlus [] | Since: base-2.1 |
MonadPlus Maybe | Since: base-2.1 |
MonadPlus IO | Since: base-4.9.0.0 |
MonadPlus Option | Since: base-4.9.0.0 |
MonadPlus STM | Since: base-4.3.0.0 |
MonadPlus ReadP | Since: base-2.1 |
MonadPlus Seq | |
MonadPlus P | Since: base-2.1 |
Defined in Text.ParserCombinators.ReadP | |
MonadPlus (U1 :: * -> *) | Since: base-4.9.0.0 |
(ArrowApply a, ArrowPlus a) => MonadPlus (ArrowMonad a) | Since: base-4.6.0.0 |
Defined in Control.Arrow mzero :: ArrowMonad a a0 # mplus :: ArrowMonad a a0 -> ArrowMonad a a0 -> ArrowMonad a a0 # | |
Chunk k => MonadPlus (Acceptor k) # | |
Chunk k => MonadPlus (Reporter k) # | |
Chunk k => MonadPlus (Tracer k) # | |
MonadPlus f => MonadPlus (Rec1 f) | Since: base-4.9.0.0 |
MonadPlus f => MonadPlus (Alt f) | |
(MonadPlus f, MonadPlus g) => MonadPlus (f :*: g) | Since: base-4.9.0.0 |
(MonadPlus f, MonadPlus g) => MonadPlus (Product f g) | Since: base-4.9.0.0 |
MonadPlus f => MonadPlus (M1 i c f) | Since: base-4.9.0.0 |
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.4.0.0-9zVj0AI90vR329B7YG7MGG" False) (C1 (MetaCons "Pos" PrefixI True) (S1 (MetaSel (Just "_posLine") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Just "_posColumn") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int))) |
Parsing errors
EInvalidUtf8 | |
EExpected [String] | |
EUnexpected String | |
EFail String | |
ECombinator String | |
EIndentNotAligned !Int !Int | |
EIndentOverLine !Int !Int | |
ENotEnoughIndent !Int !Int |
Instances
expectedEnd :: Error Source #
string :: CharParser k p => String -> p k Source #
Parse a string