Safe Haskell | None |
---|---|
Language | Haskell2010 |
a collection of generic parsing combinators that can work with any token and error type.
Synopsis
- (<>) :: Semigroup a => a -> a -> a
- duck :: Boomerang e tok r1 r2 -> Boomerang e tok (h :- r1) (h :- r2)
- duck1 :: Boomerang e tok r1 (a :- r2) -> Boomerang e tok (h :- r1) (a :- (h :- r2))
- opt :: Boomerang e tok r r -> Boomerang e tok r r
- manyr :: Boomerang e tok r r -> Boomerang e tok r r
- somer :: Boomerang e tok r r -> Boomerang e tok r r
- chainr :: Boomerang e tok r r -> Boomerang e tok r r -> Boomerang e tok r r
- chainr1 :: Boomerang e tok r (a :- r) -> Boomerang e tok (a :- (a :- r)) (a :- r) -> Boomerang e tok r (a :- r)
- manyl :: Boomerang e tok r r -> Boomerang e tok r r
- somel :: Boomerang e tok r r -> Boomerang e tok r r
- chainl :: Boomerang e tok r r -> Boomerang e tok r r -> Boomerang e tok r r
- chainl1 :: Boomerang e tok r (a :- r) -> Boomerang e tok (a :- (a :- r)) (a :- r) -> Boomerang e tok r (a :- r)
- rFilter :: (a -> Bool) -> Boomerang e tok () (a :- ()) -> Boomerang e tok r (a :- r)
- printAs :: Boomerang e [tok] a b -> tok -> Boomerang e [tok] a b
- push :: Eq a => a -> Boomerang e tok r (a :- r)
- rNil :: Boomerang e tok r ([a] :- r)
- rCons :: Boomerang e tok (a :- ([a] :- r)) ([a] :- r)
- rList :: Boomerang e tok r (a :- r) -> Boomerang e tok r ([a] :- r)
- rList1 :: Boomerang e tok r (a :- r) -> Boomerang e tok r ([a] :- r)
- rListSep :: Boomerang e tok r (a :- r) -> Boomerang e tok ([a] :- r) ([a] :- r) -> Boomerang e tok r ([a] :- r)
- rPair :: Boomerang e tok (f :- (s :- r)) ((f, s) :- r)
- rLeft :: forall tok e r a b. Boomerang e tok ((:-) a r) ((:-) (Either a b) r)
- rRight :: forall tok e r a b. Boomerang e tok ((:-) b r) ((:-) (Either a b) r)
- rEither :: Boomerang e tok r (a :- r) -> Boomerang e tok r (b :- r) -> Boomerang e tok r (Either a b :- r)
- rNothing :: forall tok e r a. Boomerang e tok r ((:-) (Maybe a) r)
- rJust :: forall tok e r a. Boomerang e tok ((:-) a r) ((:-) (Maybe a) r)
- rMaybe :: Boomerang e tok r (a :- r) -> Boomerang e tok r (Maybe a :- r)
- rTrue :: forall tok e r. Boomerang e tok r ((:-) Bool r)
- rFalse :: forall tok e r. Boomerang e tok r ((:-) Bool r)
- rBool :: Boomerang e tok a r -> Boomerang e tok a r -> Boomerang e tok a (Bool :- r)
- rUnit :: Boomerang e tok r (() :- r)
Documentation
(<>) :: Semigroup a => a -> a -> a infixr 6 #
An associative operation.
>>>
[1,2,3] <> [4,5,6]
[1,2,3,4,5,6]
duck :: Boomerang e tok r1 r2 -> Boomerang e tok (h :- r1) (h :- r2) Source #
Convert a router to do what it does on the tail of the stack.
duck1 :: Boomerang e tok r1 (a :- r2) -> Boomerang e tok (h :- r1) (a :- (h :- r2)) Source #
Convert a router to do what it does on the tail of the stack.
manyr :: Boomerang e tok r r -> Boomerang e tok r r Source #
Repeat a router zero or more times, combining the results from left to right.
somer :: Boomerang e tok r r -> Boomerang e tok r r Source #
Repeat a router one or more times, combining the results from left to right.
chainr :: Boomerang e tok r r -> Boomerang e tok r r -> Boomerang e tok r r Source #
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 :: Boomerang e tok r (a :- r) -> Boomerang e tok (a :- (a :- r)) (a :- r) -> Boomerang 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 :: Boomerang e tok r r -> Boomerang e tok r r Source #
Repeat a router zero or more times, combining the results from right to left.
somel :: Boomerang e tok r r -> Boomerang e tok r r Source #
Repeat a router one or more times, combining the results from right to left.
chainl :: Boomerang e tok r r -> Boomerang e tok r r -> Boomerang e tok r r Source #
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 :: Boomerang e tok r (a :- r) -> Boomerang e tok (a :- (a :- r)) (a :- r) -> Boomerang 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) -> Boomerang e tok () (a :- ()) -> Boomerang 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 :: Boomerang e [tok] a b -> tok -> Boomerang e [tok] a b Source #
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 => a -> Boomerang e tok r (a :- r) Source #
Push a value on the stack (during parsing, pop it from the stack when serializing).
rList :: Boomerang e tok r (a :- r) -> Boomerang e tok r ([a] :- r) Source #
Converts a router for a value a
to a router for a list of a
.
rList1 :: Boomerang e tok r (a :- r) -> Boomerang e tok r ([a] :- r) Source #
Converts a router for a value a
to a router for a list of a
.
rListSep :: Boomerang e tok r (a :- r) -> Boomerang e tok ([a] :- r) ([a] :- r) -> Boomerang 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 :: Boomerang e tok r (a :- r) -> Boomerang e tok r (b :- r) -> Boomerang 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
.
rMaybe :: Boomerang e tok r (a :- r) -> Boomerang e tok r (Maybe a :- r) Source #
Converts a router for a value a
to a router for a Maybe a
.