Safe Haskell | None |
---|
- data CheckNoCheck
- data InnerOuter
- = Inner !CheckNoCheck !(Maybe Int)
- | Outer
- data ENE
- class Elms x i where
- class Index i where
- type InOut i :: *
- type ENZ i :: *
- type PartialIndex i :: *
- type ParserRange i :: *
- outer :: i -> InOut i
- leftPartialIndex :: i -> PartialIndex i
- rightPartialIndex :: i -> PartialIndex i
- fromPartialIndices :: PartialIndex i -> PartialIndex i -> i
- class EmptyENZ enz where
- toEmptyENZ :: enz -> enz
- toNonEmptyENZ :: enz -> enz
- class Monad m => MkStream m x i where
- class Build x where
- class Index i => ValidIndex x i where
- validIndex :: x -> ParserRange i -> i -> Bool
- getParserRange :: x -> i -> ParserRange i
- checkValidIndex :: ValidIndex x i => x -> i -> Bool
- outerCheck :: Monad m => Bool -> Stream m a -> Stream m a
Data and type constructors
data CheckNoCheck Source
The Inner/Outer handler. We encode three states. We are in Outer
or
right-most position, or Inner
position. The Inner
position encodes if
loop conditional CheckNoCheck
need to be performed.
In f <<< Z % table % table, the two tables already perform a conditional branch, so that Z/table does not have to check boundary conditions.
In f <<< Z % table % char, no check is performed in tablechar, so Ztable needs to perform a boundary check.
Classes
Elms Z ix | |
Elms ls Subword => Elms (:!: ls Empty) Subword | |
Elms ls Subword => Elms (:!: ls (SRegion x)) Subword | |
Elms ls Subword => Elms (:!: ls (Region x)) Subword | |
Elms ls Subword => Elms (:!: ls (SwBtTbl m x b)) Subword | |
Elms ls Subword => Elms (:!: ls (MTbl Subword (MutArr m (arr (:. Z Subword) x)))) Subword | |
Elms ls Subword => Elms (:!: ls None) Subword | |
Elms ls ix => Elms (:!: ls (Term a b)) ix | |
Elms ls Subword => Elms (:!: ls (PeekR x)) Subword | |
Elms ls Subword => Elms (:!: ls (PeekL x)) Subword | |
Elms ls Subword => Elms (:!: ls (GPeek r x)) Subword | |
Elms ls Subword => Elms (:!: ls (GChr r x)) Subword | |
Elms ls (:. is i) => Elms (:!: ls (DefBtTbl m (:. is i) x b)) (:. is i) | |
Elms ls (:. is i) => Elms (:!: ls (MTbl (:. is i) (MutArr m (arr (:. is i) x)))) (:. is i) |
type PartialIndex i :: *Source
type ParserRange i :: *Source
leftPartialIndex :: i -> PartialIndex iSource
rightPartialIndex :: i -> PartialIndex iSource
fromPartialIndices :: PartialIndex i -> PartialIndex i -> iSource
class EmptyENZ enz whereSource
toEmptyENZ :: enz -> enzSource
toNonEmptyENZ :: enz -> enzSource
class Monad m => MkStream m x i whereSource
Monad m => MkStream m Z Z | |
Monad m => MkStream m Z Outside | The bottom of every stack of RHS arguments in a grammar. |
Monad m => MkStream m Z Subword | The bottom of every stack of RHS arguments in a grammar. |
(Monad m, MkStream m Z is) => MkStream m Z (:. is PointL) | |
(Monad m, MkStream m Z is) => MkStream m Z (:. is Subword) | |
(Monad m, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls Empty) Subword | |
(Monad m, Unbox x, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls (SRegion x)) Subword | TODO Check that all inner / outer sized calculations are correct NOTE mkStream/Inner gives a size hint of Nothing, as in purely inner cases, min/max boundaries are determined solely from the running rightmost index from the next inner component. NOTE the filter in mkStream/Outer is still necessary to check for lowerbound>0 conditions. We could send the lower bound down with another size hint, but this only makes sense if you have use cases, where the lower bound is a lot higher than 0. Otherwise the current code is simpler. TODO use drop instead of filter: still condition, but large lower bounds are captured TODO remove mkStream/Outer : filter and test if one condition less gives much better runtimes. |
(Monad m, Unbox x, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls (Region x)) Subword | |
(Monad m, Elms ls Subword, Unbox x, MkStream m ls Subword) => MkStream m (:!: ls (SwBtTbl m x b)) Subword | |
(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, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls None) Subword | |
(Monad m, Elms ls ix, MkStream m ls ix, TermElm m (Term a b) ix, TermValidIndex (Term a b) ix) => MkStream m (:!: ls (Term a b)) ix | |
(Monad m, Unbox x, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls (PeekR x)) Subword | |
(Monad m, Unbox x, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls (PeekL x)) Subword | |
(Monad m, Unbox x, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls (GPeek r x)) Subword | |
(Monad m, Elms ls Subword, MkStream m ls Subword) => MkStream m (:!: ls (GChr r x)) Subword | |
(Monad m, Elms ls (:. is i), ExtShape (:. is i), Shape (:. is i), Unbox x, NonTermValidIndex (:. is i), TableIndices (:. is i), MkStream m ls (:. is i)) => MkStream m (:!: ls (DefBtTbl m (:. is i) x b)) (:. is i) | |
(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 the stack using (%)
class Index i => ValidIndex x i whereSource
ValidIndex
, via validIndex
statically checks if an index i
is valid
for a stack of terminals and non-terminals x
. validIndex
is used to
short-circuit streams via outerCheck
.
validIndex :: x -> ParserRange i -> i -> BoolSource
getParserRange :: x -> i -> ParserRange iSource
Helper functions
checkValidIndex :: ValidIndex x i => x -> i -> BoolSource
Correct wrapping of validIndex
and getParserRange
.
outerCheck :: Monad m => Bool -> Stream m a -> Stream m aSource
outerCheck
acts as a static filter. If b
is true, we keep all stream
elements. If b
is false, we discard all stream elements.