Files
ocaml-sexpr/main.ml

25 lines
536 B
OCaml

let read_all_stdin () =
let buf = Buffer.create 4096 in
try
while true do
let line = input_line stdin in
Buffer.add_string buf line;
Buffer.add_char buf '\n';
done;
Buffer.contents buf
with End_of_file ->
Buffer.contents buf
let () =
let src = read_all_stdin () in
let v = Sexpr_macro.sparse src in
let v = Sexpr_macro.do_eval v in
Format.printf "; number of macro expansions: %d\n%!" !Sexpr_macro.num_expands;
Format.set_margin 40;
Format.printf "%a@.@?" Sexpr.pp_t v;
exit 0