Commit bd241359 authored by Quentin Aristote's avatar Quentin Aristote
Browse files

output easy to read for python

parent daf4c0a0
......@@ -7,54 +7,13 @@ exception Wrong_type of ident * arg * ty
(* Index_out_of_bounds equ_id *)
exception Out_of_bounds of ident
(*Computation of current soviet date *)
let date_soviet () =
let date = Unix.gmtime (Unix.time ()) in
let year = 1900 + date.tm_year in
let bis = if (year - 2016) mod 4 = 0 then 1 else 0 in
let sec = date.tm_sec in
let min = date.tm_min in
let hour = date.tm_hour + 1 in
let month, day, ferie, travailleur =
(match date.tm_yday with
| i when -1 <i && i < 31 ->
1, i, 0, i mod 5 + 1
| i when i = 31->
1, 31, 1, 0
| i when 31 < i && i < 63 ->
2, i - 31, 0, (i - 31) mod 5 + 1
| i when i = 63 && bis = 1 ->
2, 31, 6, 0
| i when 62 < i - bis && i - bis < 93 ->
3, i - 62 - bis, 0, (i - 62 - bis) mod 5 + 1
| i when 92 < i - bis && i - bis < 123 ->
4, i - 92 - bis, 0, (i - 92 - bis) mod 5 + 1
| i when i - bis = 123 ->
4, i - 92 - bis, 2, 0
| i when i - bis = 124 ->
4, i - 92 - bis, 3, 0
| i when 124 < i - bis && i - bis < 155 ->
5, i - 124 - bis, 0, (i - 124 - bis) mod 5 + 1
| i when 154 < i - bis && i - bis < 185 ->
6, i - 154 - bis, 0, (i - 154 - bis) mod 5 + 1
| i when 184 < i - bis && i - bis < 215 ->
7, i - 184 - bis, 0, (i - 184 - bis) mod 5 + 1
| i when 214 < i - bis && i - bis < 245 ->
8, i - 214 - bis, 0, (i - 214 - bis) mod 5 + 1
| i when 244 < i - bis && i - bis < 275 ->
9, i - 244 - bis, 0, (i - 244 - bis) mod 5 + 1
| i when 274 < i - bis && i - bis < 305 ->
10, i - 274 - bis, 0, (i - 274 - bis) mod 5 + 1
| i when 304 < i - bis && i - bis < 335 ->
11, i - 304 - bis, 0, (i - 304 - bis) mod 5 + 1
| i when i - bis = 335 ->
11, i - 304 - bis, 4, 0
| i when i - bis = 336 ->
11, i - 304 - bis, 5, 0
| i when 336 < i - bis && i - bis < 357 ->
12, i - 336 - bis, 0, (i - 336 - bis) mod 5 + 1
| _ -> failwith "day out of range") in
(sec, min, hour, day, month, year, travailleur, ferie)
(* Variables set when the program is called through the command line *)
let print_only = ref false
let number_steps = ref (-1)
let memory_directory = ref "./"
let frequence = ref 0
let default = [|0; 0; 0; 1; 1; 0; 0; 0|]
let debug = ref false
(* Integer <-> boolean *)
let bool_of_bit = function
......@@ -190,10 +149,13 @@ let output env vars =
List.iter
(fun id -> try
let value = (eval_addr env (Aconst (Env.find id env))) in
Format.printf "=> %s = %d = 0x%x@\n"
id
value
value
if !debug then
Format.printf "=> %s = %d = 0x%x@\n"
id
value
value
else
Format.printf "%d " value
with
| Not_found -> Format.eprintf "Outbound output variable %s.@." id;
exit 2)
......@@ -233,14 +195,6 @@ let load_memory ?(ram_size = 0) in_channel word_size =
(abs (ram_size - amount_filled))
(fun i -> Array.make word_size false))
(* Variables set when the program is called through the command line *)
let print_only = ref false
let number_steps = ref (-1)
let memory_directory = ref "./"
let frequence = ref 0
let default = [|0; 0; 0; 1; 1; 0; 0; 0|]
let debug = ref false
(* The main part of the program *)
let compile filename =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment