diff options
Diffstat (limited to 'main.ml')
-rw-r--r-- | main.ml | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -20,6 +20,30 @@ let () = let prog = File_parser.parse_file !ifile in if !dump then Ast_printer.print_prog Format.std_formatter prog; - () (* nothing to do yet ... *) + try + let s0 = Interpret.program_init_state prog "test" in + Format.printf "Init state:@."; + Data.print_state s0; + let rec it i st = + let st, outputs, next_st = + Interpret.program_step prog st + ["i", Data.VInt i] "test" + in + Format.printf "@.> Step %d:@." i; + Data.print_state st; + match List.assoc "exit" outputs with + | Data.VBool false -> it (i+1) next_st + | _ -> () + in + it 0 s0 + with + | Data.Combinatorial_cycle v -> + Format.eprintf "Combinatorial cycle (%s)@." v + | Data.Type_error e -> + Format.eprintf "Typing error: %s@." e + | Data.Not_implemented l -> + Format.eprintf "Not implemented: %s@." l + | Data.No_variable id -> + Format.eprintf "No such variable: %s@." id |