Files
lci/bin/main.ml
elvis 52cd7e7e13 RISC code output
TODO: fix wrong order for conversion in cfgrisc
2024-12-01 12:55:20 +01:00

36 lines
1013 B
OCaml

open MiniImp
let () =
(* let program = "def main with input x output y as *)
(* x := 2; *)
(* if y < 0 then ( *)
(* y := x + 3; *)
(* x := y; *)
(* ) else *)
(* x := 1 - y;" in *)
let program = "def main with input x output y as
x := 2;
if y < 0 then (
y := x + 3;
if x > 0 then
x := y;
else
x := y + 1;
) else
x := 1 - y;" in
let get_result x = Lexing.from_string x |> Parser.prg Lexer.lex in
let p = get_result program in
let convertedcfg = CfgImp.convert_io p 3 in
Printf.printf "%a" CfgImp.SSCfg.pp convertedcfg;
let convertedrisccfg = CfgRISC.convert convertedcfg in
let risc = RISC.convert convertedrisccfg in
Printf.printf "%a" RISC.RISCAssembly.pp risc