Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class (MonadFail p, MonadPlus p, Chunk k, IsString (p k)) => Parser 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
- try :: p a -> p a
- (<!>) :: p a -> p a -> p a
- recover :: p a -> p a -> p a
- chunk :: k -> p k
- asChunk :: p () -> p k
- char :: Char -> p Char
- scan :: (Char -> Maybe a) -> p a
- asciiByte :: Word8 -> p Word8
- asciiScan :: (Word8 -> Maybe a) -> p a
- class Applicative f => Alternative (f :: Type -> Type) where
- class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type)
- data Pos = Pos {}
- data Error
- = EInvalidUtf8
- | EExpected [String]
- | EUnexpected String
- | EFail String
- | EIndentNotAligned !Int !Int
- | EIndentOverLine !Int !Int
- | ENotEnoughIndent !Int !Int
- showError :: Error -> String
- expectedEnd :: Error
- unexpectedEnd :: Error
- string :: Parser k p => String -> p k
Documentation
class (MonadFail p, MonadPlus p, Chunk k, IsString (p k)) => Parser 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.
Reset position if parser fails
(<!>) :: p a -> p a -> p a infixl 3 Source #
Alternative which does not backtrack.
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.
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
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
class Applicative f => Alternative (f :: Type -> Type) 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 :: Type -> Type) #
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 ReadP | Since: base-2.1 |
MonadPlus Seq | |
MonadPlus P | Since: base-2.1 |
Defined in Text.ParserCombinators.ReadP | |
MonadPlus (U1 :: Type -> Type) | 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) Source # | |
Chunk k => MonadPlus (Reporter k) Source # | |
MonadPlus f => MonadPlus (Rec1 f) | Since: base-4.9.0.0 |
MonadPlus f => MonadPlus (Ap f) | Since: base-4.12.0.0 |
MonadPlus f => MonadPlus (Alt f) | Since: base-4.8.0.0 |
(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)
Instances
Eq Pos Source # | |
Show Pos Source # | |
Generic Pos Source # | |
type Rep Pos Source # | |
Defined in Text.PariPari.Internal.Class type Rep Pos = D1 (MetaData "Pos" "Text.PariPari.Internal.Class" "paripari-0.7.0.0-IvEurrnvmehFR9IQGtFHTg" False) (C1 (MetaCons "Pos" PrefixI True) (S1 (MetaSel (Just "_posLine") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Just "_posCol") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int))) |
Parsing errors
EInvalidUtf8 | |
EExpected [String] | |
EUnexpected String | |
EFail String | |
EIndentNotAligned !Int !Int | |
EIndentOverLine !Int !Int | |
ENotEnoughIndent !Int !Int |
Instances
expectedEnd :: Error Source #