3 | module Text.ILex.DStack
6 | import Text.ILex.Interfaces
7 | import Text.ILex.Parser
19 | data Stack : Bool -> (s : SnocList Type -> Type) -> SnocList Type -> Type where
20 | Lin : Stack False s [<]
21 | (:>) : Stack b s ts -> (st : s ts) -> Stack True s [<]
22 | (:<) : Stack b s ts -> (v : t) -> Stack False s (ts:<t)
24 | public export %inline
25 | push : {0 s : _} -> Stack b s [<] -> (v : t) -> s [<t] -> Stack True s [<]
26 | push stck v st = stck :< v :> st
33 | record DStack (s : SnocList Type -> Type) (e : Type) (q : Type) where
37 | prev_ : Ref q ByteString
38 | cur_ : Ref q ByteString
40 | relpos_ : Ref q Integer
42 | positions_ : Ref q (SnocList BytePos)
44 | strings_ : Ref q (SnocList String)
45 | stack_ : Ref q (Stack True s [<])
46 | error_ : Ref q (Maybe $
BBErr e)
50 | init : Stack True s [<] -> F1 q (DStack s e q)
61 | pure (S pr fl ro rr ll ps ss sk er)
64 | HasBytes (DStack s e) where
70 | positions = positions_
73 | HasStack (DStack s e) (Stack True s [<]) where
77 | HasBBErr (DStack s e) e where
81 | HasStringLits (DStack s e) where
85 | 0 StateAct : Type -> (s : SnocList Type -> Type) -> Bits32 -> Type
93 | parameters {auto sk : DStack s e q}
96 | dact : StateAct q s r -> F1 q (Index r)
98 | let (x:>st) # t := read1 sk.stack_ t
102 | dput : s ts -> Cast (s ts) a => Stack b s ts -> F1 q a
103 | dput st x = writeAs sk.stack_ (x:>st) (cast st)
106 | dpush0 : s [<] -> Cast (s [<]) a => F1 q a
108 | let stck # t := read1 sk.stack_ t
109 | in writeAs sk.stack_ (stck:>st) (cast st) t
112 | dpush : s [<t] -> Cast (s [<t]) a => t -> F1 q a
114 | let stck # t := read1 sk.stack_ t
115 | in writeAs sk.stack_ (stck:<v:>st) (cast st) t
118 | derr : s [<] -> Cast (s [<]) a => Stack b s ts -> s ts -> F1 q a
119 | derr err st x = writeAs sk.stack_ (st:>x:>err) (cast err)