-
Notifications
You must be signed in to change notification settings - Fork 0
/
ezreq.ml
27 lines (25 loc) · 823 Bytes
/
ezreq.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(* compiling *)
let compile f =
let out = (Filename.remove_extension f) in
let out_chan = open_out (out ^ ".py")
and lexbuf = Lexing.from_channel (open_in f) in
try
let rec parse () =
Parser.program Lexer.ezreq lexbuf; parse () in
Codegen.set_chan out_chan;
ignore(parse ());
with
End_of_file ->
begin
close_out out_chan;
end
| Lexer.Syntax_error s ->
print_string s;
exit 1
let help () = print_string "./ezreq <file>\n"
let () = if Array.length Sys.argv != 2 then help ()
else
let file = Array.get Sys.argv 1 in
Format.printf "compiling %s\n" file;
Format.print_flush ();
compile file