summaryrefslogtreecommitdiff
path: root/main.ml
diff options
context:
space:
mode:
Diffstat (limited to 'main.ml')
-rw-r--r--main.ml26
1 files changed, 25 insertions, 1 deletions
diff --git a/main.ml b/main.ml
index 4f70229..01cccbe 100644
--- a/main.ml
+++ b/main.ml
@@ -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