| Copyright | (C) 2026 - Eitan Chatav |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Eitan Chatav <eitan.chatav@gmail.com> |
| Stability | provisional |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Profunctor.Grammar.Parsector
Contents
Description
Synopsis
- newtype Parsector s a b = Parsector {
- runParsector :: forall x. (ParsecState s b -> x) -> ParsecState s a -> x
- parsecP :: Categorized (Item s) => Parsector s a b -> s -> ParsecState s b
- unparsecP :: Categorized (Item s) => Parsector s a b -> a -> s -> ParsecState s b
- data ParsecState s a = ParsecState {
- parsecLooked :: !Bool
- parsecOffset :: !Word
- parsecStream :: s
- parsecFailure :: ParsecFailure s
- parsecResult :: Maybe a
- data ParsecFailure s = ParsecFailure {
- parsecExpect :: TokenClass (Item s)
- parsecLabels :: [Tree String]
Parsector
newtype Parsector s a b Source #
Parsector is an invertible LL(1) parser which is intended
to provide detailed failure information, based on Parsec.
Constructors
| Parsector | |
Fields
| |
Instances
Arguments
| :: Categorized (Item s) | |
| => Parsector s a b | |
| -> s | input stream |
| -> ParsecState s b |
Run Parsector as a parser: consume tokens from s,
left to right, returning a ParsecState whose parsecResult
is Nothing on failure and Just the output syntax value on success.
Arguments
| :: Categorized (Item s) | |
| => Parsector s a b | |
| -> a | input syntax |
| -> s | input stream |
| -> ParsecState s b |
Run Parsector as a printer: given a syntax value a and
an input stream, append tokens to s left to right,
returning a ParsecState whose parsecResult is
Nothing on failure or Just a successful output syntax value,
in which case, parsecStream is the output stream.
data ParsecState s a Source #
ParsecState is both the input and output type of the
underlying function inside Parsector.
Parsector s a b is equivalent to
ParsecState s a -> ParsecState s b
So ParsecState has a dual interpretation as input and output.
Constructors
| ParsecState | |
Fields
| |
Instances
data ParsecFailure s Source #
ParsecFailure is the failure payload produced by Parsector,
stored in parsecFailure.
ParsecFailure is a Monoid and Parsector merges failures/hints
when control flow reaches the same offset without commitment.
Constructors
| ParsecFailure | |
Fields
| |