never executed always true always false
1 module HelVM.HelMA.Automata.BrainFuck.Impl.Flat.Instruction where
2
3 import HelVM.HelMA.Automata.BrainFuck.Common.SimpleInstruction
4
5 import Text.Read
6
7 import qualified Text.Show
8
9 data FlatInstruction =
10 Simple SimpleInstruction
11 | JmpPast
12 | JmpBack
13 deriving stock (Eq)
14
15 type FlatTreeInstructionList = [FlatInstruction]
16
17 instance Show FlatInstruction where
18 show (Simple i) = show i
19 show JmpPast = "["
20 show JmpBack = "]"
21
22 instance Read FlatInstruction where
23 readsPrec _ ">" = [( Simple MoveR , "")]
24 readsPrec _ "<" = [( Simple MoveL , "")]
25 readsPrec _ "+" = [( Simple Inc , "")]
26 readsPrec _ "-" = [( Simple Dec , "")]
27 readsPrec _ "." = [( Simple Output , "")]
28 readsPrec _ "," = [( Simple Input , "")]
29 readsPrec _ "[" = [( JmpPast , "")]
30 readsPrec _ "]" = [( JmpBack , "")]
31 readsPrec _ _ = []