Skip to content

Commit

Permalink
🐛 Fix stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yhs0602 committed Jun 1, 2024
1 parent 7139df0 commit 45b0764
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ let () =
let pgm = Parser.program Lexer.start lexbuf in
let _ = print_endline "=== Printing Input Program ===" in
pp pgm;
let _ = print_endline "=== Printing Output Program ===" in
let _ = print_endline "=== Gathering Functions ===" in
let open Compiler in
let env = gather_functions pgm in
let graph, _de = compile env Pred.Empty pgm.exp in
let _ = print_endline "=== Compiling Output Program ===" in
let graph, _de = compile''' env Pred.Empty pgm.exp in
let _ = print_endline "=== Printing Output Program ===" in
Printf.printf "%s" (Graph.pp graph)
with Parsing.Parse_error ->
print_endline ("Parsing Error: " ^ lexbuf_contents lexbuf)
Expand Down
5 changes: 3 additions & 2 deletions lib/compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ let gather_functions (prog : program) : Env.t =

exception Not_closed_observation

let compile (env : Env.t) (pred : Pred.t) (exp : Exp.t) : Graph.t * Det_exp.t =
let compile''' (env : Env.t) (pred : Pred.t) (exp : Exp.t) : Graph.t * Det_exp.t
=
let rec compile pred =
let compile' = compile pred in
let compile' e = compile pred e in
let open Graph in
function
| Exp.Int n -> (Graph.empty, Det_exp.Int n)
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ val gather_functions : Program.program -> Env.t

exception Not_closed_observation

val compile : Env.t -> Pred.t -> Program.Exp.t -> Graph.t * Program.Det_exp.t
val compile''' : Env.t -> Pred.t -> Program.Exp.t -> Graph.t * Program.Det_exp.t

0 comments on commit 45b0764

Please sign in to comment.