Skip to content

Instantly share code, notes, and snippets.

@paurkedal
Last active August 29, 2016 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paurkedal/3526cdf7cf65baea271d40f42fd50392 to your computer and use it in GitHub Desktop.
Save paurkedal/3526cdf7cf65baea271d40f42fd50392 to your computer and use it in GitHub Desktop.
(* 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