1 implementation module gen
9 from Data.Func import $
10 from Text import class Text(join), instance Text String
11 from Data.List import intersperse
15 //Instruction is an instruction, with possible arguments and a possible comment
17 :: Instr = Instr String [Arg] String
19 :: Arg = L String | Lit Int
20 :: SSMProgram :== [Instr]
23 gen _ = toString [Label "Test"
24 ,Instr "ldc" [Lit 1] "Eerste instructie"
25 ,Instr "ldc" [Lit 2] "Tweede instructie"]
28 class g a :: a -> SSMProgram
35 class print a :: a -> [String]
37 instance print Instr where
38 print (Label l) = [l, ":", "\n"]
39 print (Instr i args com) = ["\t", i] ++ print args ++ [" ;", com, "\n"]
41 instance print [Arg] where
42 print args = (map toString args)
44 instance toString Arg where
46 toString (Lit int) = toString int
48 instance toString SSMProgram where
49 toString p = join " " $ map (\i-> join " " $ print i) p