-1

嘿,我刚开始使用 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 -> ()
4

1 回答 1

0

你想做什么

let rec f (xpath: string list) : ( string list ) =
       (match  Str.split (Str.regexp "/") xpath  with 
                 | _ ::rest -> out (String.concat "/" rest)
                 | _ -> []
       )

此代码块与您的其余代码无关。

删除它,您的代码将在语法上正确。

于 2013-06-11T13:11:06.077 回答