mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 04:22:41 +00:00
init commit
This commit is contained in:
commit
d33023f435
13 changed files with 325 additions and 0 deletions
4
bin/dune
Normal file
4
bin/dune
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(executable
|
||||
(public_name MlLox)
|
||||
(libraries Lox)
|
||||
(name main))
|
||||
16
bin/main.ml
Normal file
16
bin/main.ml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
let printUsage () =
|
||||
print_endline "Usage: jlox [script]";
|
||||
exit 64
|
||||
|
||||
let () =
|
||||
let argc = Array.length Sys.argv in
|
||||
match argc - 1 with
|
||||
| 0 -> Lox.runRepl ()
|
||||
| 1 ->
|
||||
let path = Sys.argv.(1) in
|
||||
Printf.printf "Running script %s\n" path;
|
||||
let ic = open_in path in
|
||||
let source = In_channel.input_all ic in
|
||||
let result = Lox.run source in
|
||||
Result.iter_error Lox.Error.print_error result
|
||||
| _ -> printUsage ()
|
||||
Loading…
Add table
Add a link
Reference in a new issue