First draft report, removing exercises

This commit is contained in:
elvis
2025-01-15 00:09:58 +01:00
parent 9b48cc005f
commit 11adaa5103
11 changed files with 624 additions and 294 deletions

View File

@ -1,15 +1,3 @@
(executable
(name main)
(public_name main)
(libraries exercises
miniImp
miniFun
analysis
utility)
(package miniImp)
(modes byte exe)
)
(executable
(name miniFunInterpreter)
(public_name miniFunInterpreter)

View File

@ -1,79 +0,0 @@
open MiniImp
let colorred s =
"\027[31m" ^ s ^ "\027[0m"
let () =
let program = "
def main with input in output out as
out := in;
a := 1;
b := 2;
c := a + a;
"
in
(* Printf.printf "%s\n%s\n" (colorred "Program is") program; *)
let get_result x = Lexing.from_string x |> Parser.prg Lexer.lex in
let p = get_result program in
(* Format.printf "%s\n%a\n@?" (colorred "AST is") Types.pp_p_exp p; *)
let convertedcfg = CfgImp.convert_io 10 p in
(* Printf.printf "%s\n%a" (colorred "Converted CFG is") CfgImp.SSCfg.pp convertedcfg; *)
let convertedrisccfg = CfgRISC.convert convertedcfg in
Printf.printf "%s\n%a" (colorred "Converted RISC CFG is") CfgRISC.RISCCfg.pp convertedrisccfg;
(* ---------------------------------- *)
let analysiscfg = DefinedVariables.compute_defined_variables convertedrisccfg in
(* Printf.printf "%s\n%a" (colorred "Analysis CFG is") DefinedVariables.DVCfg.pp analysiscfg; *)
(* Printf.printf "%s" (colorred "Undefined Variables are:"); *)
(* ( *)
(* match DefinedVariables.check_undefined_variables analysiscfg with *)
(* | None -> Printf.printf " none"; *)
(* | Some l -> Printf.printf " %a" DefinedVariables.Variable.pplist l; *)
(* ); *)
(* Printf.printf "\n"; *)
let convertedrisccfg = DefinedVariables.compute_cfg analysiscfg in
(* Printf.printf "%s\n%a" (colorred "Converted RISC after analysis CFG is") CfgRISC.RISCCfg.pp convertedrisccfg; *)
(* let analysiscfg = LiveVariables.compute_live_variables convertedrisccfg in *)
(* Printf.printf "%s\n%a" (colorred "Live Analysis CFG is") LiveVariables.DVCfg.pp analysiscfg; *)
(* let convertedrisccfg = LiveVariables.compute_cfg analysiscfg in *)
(* Printf.printf "%s\n%a" (colorred "Converted RISC with no analysis CFG is") CfgRISC.RISCCfg.pp convertedrisccfg; *)
(* let convertedrisccfg = LiveVariables.compute_cfg (LiveVariables.optimize_cfg analysiscfg) in *)
(* Printf.printf "%s\n%a" (colorred "Converted RISC after analysis CFG is") CfgRISC.RISCCfg.pp convertedrisccfg; *)
let convertedrisccfg = ReduceRegisters.reduceregisters 4 convertedrisccfg in
Printf.printf "%s\n%a" (colorred "Converted RISC after reducing registers CFG is") CfgRISC.RISCCfg.pp convertedrisccfg;
(* ---------------------------------- *)
let risc = RISC.convert convertedrisccfg in
Printf.printf "%s\n%a" (colorred "RISC code is") RISC.RISCAssembly.pp risc;
let computerisc = RISCSemantics.reduce risc in
Printf.printf "%s\n%d\n" (colorred "Output of RISC code is") computerisc;
()

View File

@ -1,25 +0,0 @@
def main with input n output result as
if (n % 2) == 0 then result := 1
else (
result := 0;
s := 0;
while (0 == ((n - 1) / (2 ^ s)) % 2) do (
s := s + 1
);
d := ((n - 1) / 2 ^ s);
for (i := 20, i > 0, i := i - 1) do (
a := rand(n - 4) + 2;
x := powmod(a, d, n);
y := 0;
for (j := 0, j < s, j := j+1) do (
y := powmod(x, 2, n);
if (y == 1 && (not x == 1) && (not x == n - 1)) then
result := 1;
else
skip;
x := y;
);
if not y == 1 then result := 1;
else skip;
)
)