-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ml
33 lines (28 loc) · 884 Bytes
/
main.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
28
29
30
31
32
33
open Syntax
open Functions
open Html
open Filename
(* Main function that checks if arguments and file are ok, then parse and export the tree to the HTML page *)
let _ =
if (Array.length Sys.argv) != 2 then begin
print_endline "Usage: ./main samples/a.dot";
exit 1
end else begin
if check_suffix (Sys.argv.(1)) ".dot" then begin
let file = open_in Sys.argv.(1) in
try
let lexbuf = Lexing.from_channel file in
let graph = Parser.graph Lexer.token lexbuf in
let filename = chop_extension (basename (Sys.argv.(1))) in
let couple = call_create_nodes_edges graph in
export_graph_to_html couple filename;
print_endline ("\nDONE.\nExported in output/" ^ filename ^ ".html\n");
flush stdout
with Lexer.Eof ->
close_in file;
exit 0
end else begin
print_endline "Error: .dot file expected";
exit 2
end
end