Safe Haskell | None |
---|

Generalized fusion system for grammars.

NOTE Symbols typically do not check bound data for consistency. If you, say, bind a terminal symbol to an input of length 0 and then run your grammar, you probably get errors, garbled data or random crashes. Such checks are done via asserts in non-production code.

TODO each combinator should come with a special outer check. Given some index (say (i,j), this can then check if i-const >= 0, or j+const<=n, or i+const<=j. That should speed up everything that uses GChr combinators. Separating out this check means that certain inner loops can run without any conditions and just jump.

- (<<<) :: (ValidIndex (Stack x) i, Build x, MkStream m (Stack x) i, Elms (Stack x) i, Apply (Arg (Stack x) -> a)) => Fun (Arg (Stack x) -> a) -> x -> i -> Stream m a
- (<<#) :: (ValidIndex (Stack x) i, Build x, MkStream m (Stack x) i, Elms (Stack x) i, Apply (Arg (Stack x) -> m a)) => Fun (Arg (Stack x) -> m a) -> x -> i -> Stream m a
- (|||) :: Monad m => (t -> Stream m a) -> (t -> Stream m a) -> t -> Stream m a
- (...) :: (a -> b) -> (b -> c) -> a -> c
- (~~) :: a -> b -> Pair a b
- (%) :: a -> b -> Pair a b
- check :: Monad m => (t -> Stream m a) -> (t -> Bool) -> t -> Stream m a
- chr :: Vector v r => v r -> GChr r r
- chrLeft :: Vector v x => v x -> GChr (Maybe x, x) x
- chrRight :: Vector v x => v x -> GChr (x, Maybe x) x
- peekL :: Vector x -> PeekL x
- peekR :: Vector x -> PeekR x
- empty :: Empty
- region :: Vector x -> Region x
- sregion :: Int -> Int -> Vector x -> SRegion x
- data MTbl i xs = MTbl !(ENZ i) !xs
- data ENE
- data None = None

# Documentation

(<<<) :: (ValidIndex (Stack x) i, Build x, MkStream m (Stack x) i, Elms (Stack x) i, Apply (Arg (Stack x) -> a)) => Fun (Arg (Stack x) -> a) -> x -> i -> Stream m aSource

Apply a function to symbols on the RHS of a production rule. Builds the
stack of symbols from `xs`

using `build`

, then hands this stack to
`mkStream`

together with the initial `iniT`

telling `mkStream`

that we are
in the outer position. Once the stream has been created, we `map`

`getArg`

to get just the arguments in the stack, and finally `apply`

the
function `f`

.

(<<#) :: (ValidIndex (Stack x) i, Build x, MkStream m (Stack x) i, Elms (Stack x) i, Apply (Arg (Stack x) -> m a)) => Fun (Arg (Stack x) -> m a) -> x -> i -> Stream m aSource

(|||) :: Monad m => (t -> Stream m a) -> (t -> Stream m a) -> t -> Stream m aSource

Combine two RHSs to give a choice between parses.

(...) :: (a -> b) -> (b -> c) -> a -> cSource

Applies the objective function `h`

to a stream `s`

. The objective function
reduces the stream to a single optimal value (or some vector of co-optimal
things).

(%) :: a -> b -> Pair a bSource

This separator looks much paper on paper and is not widely used otherwise.

check :: Monad m => (t -> Stream m a) -> (t -> Bool) -> t -> Stream m aSource

Additional outer check with user-given check function

chrLeft :: Vector v x => v x -> GChr (Maybe x, x) xSource

Parses a single character and returns the character to the left in a strict Maybe.

chrRight :: Vector v x => v x -> GChr (x, Maybe x) xSource

Parses a single character and returns the character to the right in a strict Maybe.

(Monad m, PrimMonad m, Elms ls Subword, MkStream m ls Subword, MPrimArrayOps arr (:. Z Subword) x) => MkStream m (:!: ls (MTbl Subword (MutArr m (arr (:. Z Subword) x)))) Subword | |

(Monad m, PrimMonad m, MPrimArrayOps arr (:. is i) x, Elms ls (:. is i), NonTermValidIndex (:. is i), TableIndices (:. is i), MkStream m ls (:. is i)) => MkStream m (:!: ls (MTbl (:. is i) (MutArr m (arr (:. is i) x)))) (:. is i) | |

Build (MTbl i x) | |

EmptyENZ (ENZ i) => EmptyTable (MTbl i xs) | |

(ValidIndex ls Subword, Monad m, MPrimArrayOps arr (:. Z Subword) x) => ValidIndex (:!: ls (MTbl Subword (MutArr m (arr (:. Z Subword) x)))) Subword | |

Elms ls Subword => Elms (:!: ls (MTbl Subword (MutArr m (arr (:. Z Subword) x)))) Subword | |

(ValidIndex ls (:. is i), MPrimArrayOps arr (:. is i) x, NonTermValidIndex (:. is i)) => ValidIndex (:!: ls (MTbl (:. is i) (MutArr m (arr (:. is i) x)))) (:. is i) | |

Elms ls (:. is i) => Elms (:!: ls (MTbl (:. is i) (MutArr m (arr (:. is i) x)))) (:. is i) |

Build None | |

(Monad m, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls None) Subword | |

(Monad m, TermElm m ts is) => TermElm m (Term ts None) (:. is PointL) | |

ValidIndex ls Subword => ValidIndex (:!: ls None) Subword | |

Elms ls Subword => Elms (:!: ls None) Subword | |

TermValidIndex ts is => TermValidIndex (Term ts None) (:. is PointL) |