summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ansys.com>2014-06-12 16:48:43 +0200
committerAlex Auvolat <alex.auvolat@ansys.com>2014-06-12 16:48:43 +0200
commit9d280918051a77683fa7b9d15842eead22f7944a (patch)
tree7ea7eb63614acde889c643c48b32134d7c0dc558
parent68fef7a9612cf42ba42d9ca1cc2423556f66b461 (diff)
downloadscade-analyzer-9d280918051a77683fa7b9d15842eead22f7944a.tar.gz
scade-analyzer-9d280918051a77683fa7b9d15842eead22f7944a.zip
Adopt same output format as test.c
-rw-r--r--interpret/data.ml4
-rw-r--r--main.ml51
2 files changed, 39 insertions, 16 deletions
diff --git a/interpret/data.ml b/interpret/data.ml
index 2721528..51afcc3 100644
--- a/interpret/data.ml
+++ b/interpret/data.ml
@@ -34,9 +34,9 @@ let get_var (st: state) (c: calc_map) (id: id) : (state * svalue) =
if VarMap.mem id st then st
else try match VarMap.find id c with
| F f ->
- Format.printf "%s[ " id;
+ (* Format.printf "%s[ " id; *)
let r = f (VarMap.add id VBusy st) c in
- Format.printf "]%s " id;
+ (* Format.printf "]%s " id; *)
r
with Not_found -> raise (No_variable id)
in
diff --git a/main.ml b/main.ml
index 01cccbe..20e3dd3 100644
--- a/main.ml
+++ b/main.ml
@@ -2,12 +2,16 @@ open Ast
(* command line options *)
let dump = ref false
+let test = ref false
+let vtest = ref false
let ifile = ref ""
let usage = "usage: analyzer [options] file.scade"
let options = [
"--dump", Arg.Set dump, "Dump program source.";
+ "--vest", Arg.Set vtest, "Verbose testing.";
+ "--test", Arg.Set test, "Simple testing.";
]
let () =
@@ -21,21 +25,40 @@ let () =
let prog = File_parser.parse_file !ifile in
if !dump then Ast_printer.print_prog Format.std_formatter prog;
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"
+ if !vtest then begin
+ 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
- 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
+ it 0 s0
+ end;
+ if !test then begin
+ let s0 = Interpret.program_init_state prog "test" in
+ let rec it i st =
+ let st, outputs, next_st =
+ Interpret.program_step prog st
+ ["i", Data.VInt i] "test"
+ in
+ Format.printf "%d. %s %s %s@." i
+ (Data.str_of_value (List.assoc "a" outputs))
+ (Data.str_of_value (List.assoc "b" outputs))
+ (Data.str_of_value (List.assoc "c" outputs));
+ match List.assoc "exit" outputs with
+ | Data.VBool false -> it (i+1) next_st
+ | _ -> ()
+ in
+ it 0 s0
+ end
with
| Data.Combinatorial_cycle v ->
Format.eprintf "Combinatorial cycle (%s)@." v