import Symantic.Parser.Grammar
import Symantic.Parser.Machine.Input
import Symantic.Parser.Machine.Instructions
-import Symantic.Univariant.Trans
+import Symantic.Typed.Trans
-- * Data family 'Instr'
-- | 'Instr'uctions of the 'Machine'.
-- This is an extensible data-type.
data family Instr
(instr :: ReprInstr -> Constraint)
- (repr :: ReprInstr)
- :: ReprInstr
+ :: ReprInstr -> ReprInstr
-- | Convenient utility to pattern-match a 'SomeInstr'.
pattern Instr :: Typeable comb =>
-- InstrValuable
data instance Instr InstrValuable repr inp vs a where
PushValue ::
- TermInstr v ->
+ Splice v ->
SomeInstr repr inp (v ': vs) a ->
Instr InstrValuable repr inp vs a
PopValue ::
SomeInstr repr inp vs a ->
Instr InstrValuable repr inp (v ': vs) a
Lift2Value ::
- TermInstr (x -> y -> z) ->
+ Splice (x -> y -> z) ->
SomeInstr repr inp (z : vs) a ->
Instr InstrValuable repr inp (y : x : vs) a
SwapValue ::
Lift2Value f k -> lift2Value f (trans k)
SwapValue k -> swapValue (trans k)
instance InstrValuable repr => InstrValuable (SomeInstr repr) where
+ -- 'PopValue' after a 'PushValue' is a no-op.
pushValue _v (Instr (PopValue i)) = i
pushValue v i = SomeInstr (PushValue v i)
popValue = SomeInstr . PopValue
SomeInstr repr inp (y ': vs) a ->
Instr InstrBranchable repr inp (Either x y ': vs) a
ChoicesBranch ::
- [TermInstr (v -> Bool)] ->
+ [Splice (v -> Bool)] ->
[SomeInstr repr inp vs a] ->
SomeInstr repr inp vs a ->
Instr InstrBranchable repr inp (v ': vs) a
data instance Instr (InstrReadable tok) repr inp vs a where
Read ::
Set SomeFailure ->
- TermInstr (InputToken inp -> Bool) ->
+ Splice (InputToken inp -> Bool) ->
SomeInstr repr inp (InputToken inp ': vs) a ->
Instr (InstrReadable tok) repr inp vs a
instance