15 (try Some
(Std.input_file filename
) with exn
-> None
)
17 | None
-> Error.log
"cannot open file : %s" filename
19 let lexbuf = Lexing.from_string s
in
21 match (try Sql_lexer.ruleStatement
Props.empty
lexbuf with exn
-> None
) with
22 | Some x
-> lines (x
::l
)
25 let all = lines [] >> List.rev
in
26 (* parse in direct order *)
27 let parse1 (stmt
,props
) =
30 let (s
,ps
) = Parser.parse_stmt stmt
in
32 print_endline
(Show.show
<Stmt.Raw.params
>(ps
))
36 print_endline
(Printexc.to_string exn
)
43 (fun (str,props) -> match P.parse_string str with
44 | Some ((k,n,placeholders) as stmt) ->
45 (*Error.logs (Show.show<Stmt.Raw.parsed> stmt); *)
46 Some
(k
,n
,placeholders
,props
,str
)
47 | None
-> Error.log
"Failed to parse : %s" str
; None
)
51 Gen.process
(Stmt.resolve
stmts)
54 (* match P.parse_file filename with
55 | None -> print_endline "none"
57 Error.logs (Show.show<Stmt.t list> stmts);
61 Error.log
"SQL to C++ Code Generator Version %s (%s)" Version.version
(Version.revision
>> S.explode
>> L.take
8 >> S.implode
);
63 Error.log
" Usage: %s file_with_statements.sql" (Filename.basename
Sys.executable_name
);
65 Error.log
" Parse given file (treating content as SQL statements) and emit corresponding code to stdout"
68 match Array.to_list
Sys.argv
with
69 | _
::"-test"::_
-> Test.run
()
70 | _
::[file
] -> work file
73 let _ = Printexc.print
main ()