mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
update examples/id_sexp so it can read on stdin
This commit is contained in:
parent
cf931aabb1
commit
b000355a74
1 changed files with 11 additions and 6 deletions
|
|
@ -1,13 +1,18 @@
|
|||
|
||||
|
||||
let () =
|
||||
if Array.length Sys.argv <> 2 then failwith "usage: id_sexp file";
|
||||
let f = Sys.argv.(1) in
|
||||
let s = CCSexpM.parse_file_list f in
|
||||
match s with
|
||||
let pp_sexp s = match s with
|
||||
| `Ok l ->
|
||||
List.iter
|
||||
(fun s -> Format.printf "@[%a@]@." CCSexpM.print s)
|
||||
l
|
||||
| `Error msg ->
|
||||
Format.printf "error: %s@." msg
|
||||
|
||||
let () =
|
||||
match Sys.argv with
|
||||
| [| _ |] ->
|
||||
let s = CCSexpM.parse_chan_list stdin in
|
||||
pp_sexp s
|
||||
| [| _; file |] ->
|
||||
let s = CCSexpM.parse_file_list file in
|
||||
pp_sexp s
|
||||
| _ -> failwith "usage: id_sexp [file]"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue