mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-24 23:58:47 +00:00
Functions as values (no closures yet, and no tests)
This commit is contained in:
parent
f5b802ebed
commit
d69cb3d49d
12 changed files with 194 additions and 160 deletions
|
|
@ -40,11 +40,10 @@ let main =
|
|||
let infile = Sys.argv.(if not to_compile then 2 else 1) in
|
||||
match (try parse infile with Language.Semantic_error msg -> `Fail msg) with
|
||||
| `Ok prog ->
|
||||
let prog : Language.t = prog in
|
||||
if to_compile
|
||||
then
|
||||
let basename = Filename.chop_suffix infile ".expr" in
|
||||
ignore @@ X86.build prog basename
|
||||
(* ignore @@ X86.build prog basename *) (* TODO! *) ()
|
||||
else
|
||||
let rec read acc =
|
||||
try
|
||||
|
|
@ -57,7 +56,7 @@ let main =
|
|||
let output =
|
||||
if interpret
|
||||
then Language.eval prog input
|
||||
else SM.run (SM.compile prog) input
|
||||
else [] (* SM.run (SM.compile prog) input *) (* TODO! *)
|
||||
in
|
||||
List.iter (fun i -> Printf.printf "%d\n" i) output
|
||||
| `Fail er -> Printf.eprintf "Error: %s\n" er
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue