Ocaml を使い始めたばかりなのですが、理解できない奇妙な構文エラーが発生しました。ここに私のプログラムがあります:
let out x = Printf.printf " %s \n" x
let _ = try
while true do
let line = input_line stdin in
begin
match (Str.split (Str.regexp " ") line) with
["commit";code] -> out code;
| ["diff"; _; before; after] -> out before;
out after;
let rec f (xpath: string list) : ( string list ) =
(match Str.split (Str.regexp "/") xpath with
| _ ::rest -> out (String.concat "/" rest)
| _ -> []
)
| _ -> ()
end
done
with
End_of_file -> ()