Last active
August 29, 2016 19:59
-
-
Save paurkedal/3526cdf7cf65baea271d40f42fd50392 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Ad comment to https://github.com/ocaml/ocaml/pull/722 | |
* | |
* E.. Everything indented to even columns. | |
* O.. Patterns indented to odd columns, the rest to even columns. | |
* .L. Loose layout, delimiters above and below cases. | |
* .C. Compact layout, end delimiter attached to last case. | |
* ..P Delimited with parentheses, as allowed by the current syntax. | |
* ..B Delimited with brackets, as in the PR. | |
* .XX Pointed form. | |
*) | |
(* ELP *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
(match String.cuts ~sep:"%" dc with | |
| [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
(match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with | |
| None, _ | _, None -> Lwt.return_none | |
| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
(match cut_circumfix dc1' dc2' pc with | |
| None -> Lwt.return_none | |
| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc') | |
) | |
) | |
| _ -> Lwt.return_none | |
) | |
(* ELB *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
match String.cuts ~sep:"%" dc with [ | |
| [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with [ | |
| None, _ | _, None -> Lwt.return_none | |
| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
match cut_circumfix dc1' dc2' pc with [ | |
| None -> Lwt.return_none | |
| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc') | |
] | |
] | |
| _ -> Lwt.return_none | |
] | |
(* ECP *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
(match String.cuts ~sep:"%" dc with | |
| [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
(match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with | |
| None, _ | _, None -> Lwt.return_none | |
| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
(match cut_circumfix dc1' dc2' pc with | |
| None -> Lwt.return_none | |
| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc'))) | |
| _ -> Lwt.return_none) | |
(* ECB *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
match String.cuts ~sep:"%" dc with | |
[ [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with | |
[ None, _ | _, None -> Lwt.return_none | |
| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
match cut_circumfix dc1' dc2' pc with | |
[ None -> Lwt.return_none | |
| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc') ] ] | |
| _ -> Lwt.return_none ] | |
(* OLP *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
(match String.cuts ~sep:"%" dc with | |
| [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
(match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with | |
| None, _ | _, None -> Lwt.return_none | |
| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
(match cut_circumfix dc1' dc2' pc with | |
| None -> Lwt.return_none | |
| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc') | |
) | |
) | |
| _ -> Lwt.return_none | |
) | |
(* OLB *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
match String.cuts ~sep:"%" dc with [ | |
| [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with [ | |
| None, _ | _, None -> Lwt.return_none | |
| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
match cut_circumfix dc1' dc2' pc with [ | |
| None -> Lwt.return_none | |
| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc') | |
] | |
] | |
| _ -> Lwt.return_none | |
] | |
(* OCP *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
(match String.cuts ~sep:"%" dc with | |
| [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
(match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with | |
| None, _ | _, None -> Lwt.return_none | |
| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
(match cut_circumfix dc1' dc2' pc with | |
| None -> Lwt.return_none | |
| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc'))) | |
| _ -> Lwt.return_none) | |
(* OCB *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
match String.cuts ~sep:"%" dc with | |
[ [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with | |
[ None, _ | _, None -> Lwt.return_none | |
| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
match cut_circumfix dc1' dc2' pc with | |
[ None -> Lwt.return_none | |
| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc') ] ] | |
| _ -> Lwt.return_none ] | |
(* OXX *) | |
let consider_pattern tc1 tc2 pc fp' dc = | |
Log.debug_f "Considering directory entry %s" dc >> | |
match String.cuts ~sep:"%" dc with | |
| [] -> assert false | |
| [_] -> Lwt.return_none | |
| [dc1; dc2] -> | |
match cut_prefix tc1 dc1, cut_suffix tc2 dc2 with | |
| None, _ | _, None -> Lwt.return_none | |
.| Some dc1', Some dc2' -> | |
Log.debug_f "Matching %s against %s%%%s" pc dc1' dc2' >> | |
match cut_circumfix dc1' dc2' pc with | |
| None -> Lwt.return_none | |
.| Some pc' -> | |
consider_fixed (Filename.concat tp dc) fp' (Filename.concat rp pc') | |
.| _ -> Lwt.return_none |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment