Fixed common.ml/Syntax.ml

This commit is contained in:
Dmitry Boulytchev 2018-02-26 08:41:06 +03:00
parent 3c0884cfa5
commit 2f6169cdbd
2 changed files with 15 additions and 1 deletions

View file

@ -9,7 +9,7 @@ let state ps = List.fold_right (fun (x, v) (s, p) -> Expr.update x v s, (x =:= !
let eval (s, p) e =
let orig = Expr.eval s e in
let stmt = List.fold_right (fun p s -> p |> s) p (Stmt.Write e) in
let [s_orig] = Stmt.eval [] stmt in
let [s_orig] = eval [] stmt in
let [sm_orig] = SM.run [] (SM.compile stmt) in
if conj (orig = s_orig) (orig = sm_orig)
then Printf.printf "%d\n" orig

View file

@ -68,3 +68,17 @@ module Stmt =
let eval _ = failwith "Not implemented yet"
end
(* The top-level definitions *)
(* The top-level syntax category is statement *)
type t = Stmt.t
(* Top-level evaluator
eval : int list -> t -> int list
Takes a program and its input stream, and returns the output stream
*)
let eval i p =
let _, _, o = Stmt.eval (Expr.empty, i, []) p in o