diff options
| author | Jon French | 2018-06-11 16:38:53 +0100 |
|---|---|---|
| committer | Jon French | 2018-06-11 16:38:53 +0100 |
| commit | 6b70f78c3c9477d4c5f417ed0a5d96abc19c9fb0 (patch) | |
| tree | 5d8bdfd982c5c0efde9c7eac021f6341af124e7f /src/pattern_completeness.ml | |
| parent | 0cc7d50e08b36d036771493920bb2e20251def64 (diff) | |
| parent | 22aff19aeea53719004cca2b5c6b25d0a7ed0835 (diff) | |
Merge branch 'mappings' into sail2
Diffstat (limited to 'src/pattern_completeness.ml')
| -rw-r--r-- | src/pattern_completeness.ml | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pattern_completeness.ml b/src/pattern_completeness.ml index c13452ff..2372ea82 100644 --- a/src/pattern_completeness.ml +++ b/src/pattern_completeness.ml @@ -68,6 +68,7 @@ type gpat = | GP_cons of gpat * gpat | GP_app of (gpat Bindings.t) | GP_record of (gpat Bindings.t) + | GP_string_append of gpat list let rec string_of_gpat = function | GP_lit lit -> string_of_lit lit @@ -80,12 +81,14 @@ let rec string_of_gpat = function | GP_app app -> Util.string_of_list "|" (fun (id, gpat) -> string_of_id id ^ string_of_gpat gpat) (Bindings.bindings app) | GP_record _ -> "GP RECORD" + | GP_string_append gpats -> Util.string_of_list " ^^ " string_of_gpat gpats let is_wild = function | GP_wild -> true | _ -> false let rec generalize ctx (P_aux (p_aux, _) as pat) = + match p_aux with | P_lit lit -> GP_lit lit | P_wild -> GP_wild @@ -116,6 +119,9 @@ let rec generalize ctx (P_aux (p_aux, _) as pat) = let ghd_pat = generalize ctx hd_pat in let gtl_pat = generalize ctx tl_pat in if is_wild ghd_pat && is_wild gtl_pat then GP_wild else GP_cons (ghd_pat, gtl_pat) + | P_string_append pats -> + let gpats = List.map (generalize ctx) pats in + if List.for_all is_wild gpats then GP_wild else GP_string_append gpats | P_app (f, pats) -> let gpats = List.map (generalize ctx) pats in if List.for_all is_wild gpats then |
