1
2
3
4
5
6
7
8
9
10
11
12
13
14
open Utils
let lexbuf_from_function = fun name f ->
let lexbuf = Lexing.from_function f in
Lexing.set_filename lexbuf name;
lexbuf
let parse_program ?(name = "") (inc : IO.input) =
let lexbuf = lexbuf_from_function name @@ fun buf n ->
try IO.input inc buf 0 n with IO.No_more_input -> 0 in
Parser.module_ Lexer.main lexbuf