Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class (MonadFail p, MonadPlus p) => MonadParser p where
- type Parser a = forall p. MonadParser p => p a
- class Applicative f => Alternative (f :: * -> *) where
- class (Alternative m, Monad m) => MonadPlus (m :: * -> *)
- data Pos = Pos {
- _posLine :: !Int
- _posColumn :: !Int
- data Error
- data ByteString
- data Word8
- showError :: Error -> String
Documentation
class (MonadFail p, MonadPlus p) => MonadParser p 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, byte, char, satisfy, byteSatisfy, bytes, asBytes
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.
byte :: Word8 -> p Word8 Source #
Parse a single byte
char :: Char -> p Char Source #
Parse a single UTF-8 character
satisfy :: (Char -> Bool) -> p Char Source #
Parse a single character with the given predicate
byteSatisfy :: (Word8 -> Bool) -> p Word8 Source #
Parse a single byte with the given predicate
bytes :: ByteString -> p ByteString Source #
Parse a string of bytes
asBytes :: p () -> p ByteString Source #
Run the given parser and return the result as bytes
Instances
type Parser a = forall p. MonadParser p => p a Source #
Parser shortcut
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 Acceptor # | |
MonadPlus Tracer # | |
MonadPlus Reporter # | |
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 # | |
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.Class type Rep Pos = D1 (MetaData "Pos" "Text.PariPari.Class" "paripari-0.1.0.0-3bHffQaMVFHBdNIVKeDa1t" 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
EEmpty | |
EInvalidUtf8 | |
EExpectedEnd | |
EExpected [String] | |
EUnexpected String | |
EFail String | |
ECombinator String | |
EIndentNotAligned !Int !Int | |
EIndentOverLine !Int !Int | |
ENotEnoughIndent !Int !Int |
Instances
data ByteString #
A space-efficient representation of a Word8
vector, supporting many
efficient operations.
A ByteString
contains 8-bit bytes, or by using the operations from
Data.ByteString.Char8 it can be interpreted as containing 8-bit
characters.
Instances
8-bit unsigned integer type