Safe Haskell | None |
---|
a collection of generic parsing combinators that can work with any token and error type.
- (<>) :: Monoid m => m -> m -> m
- duck :: PrinterParser e tok r1 r2 -> PrinterParser e tok (h :- r1) (h :- r2)
- duck1 :: PrinterParser e tok r1 (a :- r2) -> PrinterParser e tok (h :- r1) (a :- (h :- r2))
- opt :: PrinterParser e tok r r -> PrinterParser e tok r r
- manyr :: PrinterParser e tok r r -> PrinterParser e tok r r
- somer :: PrinterParser e tok r r -> PrinterParser e tok r r
- chainr :: PrinterParser e tok r r -> PrinterParser e tok r r -> PrinterParser e tok r r
- chainr1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok (a :- (a :- r)) (a :- r) -> PrinterParser e tok r (a :- r)
- manyl :: PrinterParser e tok r r -> PrinterParser e tok r r
- somel :: PrinterParser e tok r r -> PrinterParser e tok r r
- chainl :: PrinterParser e tok r r -> PrinterParser e tok r r -> PrinterParser e tok r r
- chainl1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok (a :- (a :- r)) (a :- r) -> PrinterParser e tok r (a :- r)
- rFilter :: (a -> Bool) -> PrinterParser e tok () (a :- ()) -> PrinterParser e tok r (a :- r)
- printAs :: PrinterParser e [tok] a b -> tok -> PrinterParser e [tok] a b
- push :: (Eq a, Error e) => a -> PrinterParser e tok r (a :- r)
- rNil :: PrinterParser e tok r ([a] :- r)
- rCons :: PrinterParser e tok (a :- ([a] :- r)) ([a] :- r)
- rList :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r ([a] :- r)
- rList1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r ([a] :- r)
- rListSep :: PrinterParser e tok r (a :- r) -> PrinterParser e tok ([a] :- r) ([a] :- r) -> PrinterParser e tok r ([a] :- r)
- rPair :: PrinterParser e tok (f :- (s :- r)) ((f, s) :- r)
- rLeft :: forall tok e r a b. PrinterParser e tok (:- a r) (:- (Either a b) r)
- rRight :: forall tok e r a b. PrinterParser e tok (:- b r) (:- (Either a b) r)
- rEither :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r (b :- r) -> PrinterParser e tok r (Either a b :- r)
- rNothing :: forall tok e r a. PrinterParser e tok r (:- (Maybe a) r)
- rJust :: forall tok e r a. PrinterParser e tok (:- a r) (:- (Maybe a) r)
- rMaybe :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r (Maybe a :- r)
- rTrue :: forall tok e r. PrinterParser e tok r (:- Bool r)
- rFalse :: forall tok e r. PrinterParser e tok r (:- Bool r)
- rBool :: PrinterParser e tok a r -> PrinterParser e tok a r -> PrinterParser e tok a (Bool :- r)
- rUnit :: PrinterParser e tok r (() :- r)
Documentation
duck :: PrinterParser e tok r1 r2 -> PrinterParser e tok (h :- r1) (h :- r2)Source
Convert a router to do what it does on the tail of the stack.
duck1 :: PrinterParser e tok r1 (a :- r2) -> PrinterParser e tok (h :- r1) (a :- (h :- r2))Source
Convert a router to do what it does on the tail of the stack.
opt :: PrinterParser e tok r r -> PrinterParser e tok r rSource
Make a router optional.
manyr :: PrinterParser e tok r r -> PrinterParser e tok r rSource
Repeat a router zero or more times, combining the results from left to right.
somer :: PrinterParser e tok r r -> PrinterParser e tok r rSource
Repeat a router one or more times, combining the results from left to right.
chainr :: PrinterParser e tok r r -> PrinterParser e tok r r -> PrinterParser e tok r rSource
chainr p op
repeats p
zero or more times, separated by op
.
The result is a right associative fold of the results of p
with the results of op
.
chainr1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok (a :- (a :- r)) (a :- r) -> PrinterParser e tok r (a :- r)Source
chainr1 p op
repeats p
one or more times, separated by op
.
The result is a right associative fold of the results of p
with the results of op
.
manyl :: PrinterParser e tok r r -> PrinterParser e tok r rSource
Repeat a router zero or more times, combining the results from right to left.
somel :: PrinterParser e tok r r -> PrinterParser e tok r rSource
Repeat a router one or more times, combining the results from right to left.
chainl :: PrinterParser e tok r r -> PrinterParser e tok r r -> PrinterParser e tok r rSource
chainl1 p op
repeats p
zero or more times, separated by op
.
The result is a left associative fold of the results of p
with the results of op
.
chainl1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok (a :- (a :- r)) (a :- r) -> PrinterParser e tok r (a :- r)Source
chainl1 p op
repeats p
one or more times, separated by op
.
The result is a left associative fold of the results of p
with the results of op
.
rFilter :: (a -> Bool) -> PrinterParser e tok () (a :- ()) -> PrinterParser e tok r (a :- r)Source
Filtering on routers.
TODO: We remove any parse errors, not sure if the should be preserved. Also, if the predicate fails we silently remove the element, but perhaps we should replace the value with an error message?
printAs :: PrinterParser e [tok] a b -> tok -> PrinterParser e [tok] a bSource
r `printAs` s
uses ther serializer of r
to test if serializing succeeds,
and if it does, instead serializes as s
.
TODO: can this be more general so that it can work on tok
instead of [tok]
push :: (Eq a, Error e) => a -> PrinterParser e tok r (a :- r)Source
Push a value on the stack (during parsing, pop it from the stack when serializing).
rNil :: PrinterParser e tok r ([a] :- r)Source
rList :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r ([a] :- r)Source
Converts a router for a value a
to a router for a list of a
.
rList1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r ([a] :- r)Source
Converts a router for a value a
to a router for a list of a
.
rListSep :: PrinterParser e tok r (a :- r) -> PrinterParser e tok ([a] :- r) ([a] :- r) -> PrinterParser e tok r ([a] :- r)Source
Converts a router for a value a
to a router for a list of a
, with a separator.
rEither :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r (b :- r) -> PrinterParser e tok r (Either a b :- r)Source
Combines a router for a value a
and a router for a value b
into a router for Either a b
.
rNothing :: forall tok e r a. PrinterParser e tok r (:- (Maybe a) r)Source
rMaybe :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r (Maybe a :- r)Source
Converts a router for a value a
to a router for a Maybe a
.
rTrue :: forall tok e r. PrinterParser e tok r (:- Bool r)Source
rFalse :: forall tok e r. PrinterParser e tok r (:- Bool r)Source
:: PrinterParser e tok a r |
|
-> PrinterParser e tok a r |
|
-> PrinterParser e tok a (Bool :- r) |
rUnit :: PrinterParser e tok r (() :- r)Source