我刚开始使用 Caml,我正在尝试解析一个 git 文件:所以我使用 match 过滤以 diff/@@ 开头的行,这就是我尝试做的:| [“差异”; _; 前; 之后] -> 之前;之后出去;
(match Str.split (Str.regexp "/") file with
| String.concat "/" [_; path ; dest;file_c ]-> out path;
out dest;
out file_c;
| _ -> ()
)
我在这里和这里有一个语法错误:| ["@@"; 行_已删除;行_添加;_] -> outlines_deleted;出线_添加;
let nb_lines_deleted = String.sub lines_deleted 2 ((String.length lines_deleted)-1) in
let nb_lines_added = String.sub lines_added 2 ((String.length lines_added)-1) in
( match ( Str.split (Str.regexp ",") lines_deleted ) with
| [_; nb_lines_deleted;_; nb_lines_added] -> out nb_lines_deleted;
out nb_lines_added;
| _ -> ()
)
| _ -> ()
我不明白为什么!我尝试了不同的东西,但没有任何效果!