| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
open Pp |
| 12 |
open Names |
| 13 |
open Tactypes |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
let rec pr_intro_pattern prc {CAst.v=pat} = match pat with |
| 18 |
| IntroForthcoming true -> str "*" |
| 19 |
| IntroForthcoming false -> str "**" |
| 20 |
| IntroNaming p -> pr_intro_pattern_naming p |
| 21 |
| IntroAction p -> pr_intro_pattern_action prc p |
| 22 |
|
| 23 |
and pr_intro_pattern_naming = let open Namegen in function |
| 24 |
| IntroIdentifier id -> Id.print id |
| 25 |
| IntroFresh id -> str "?" ++ Id.print id |
| 26 |
| IntroAnonymous -> str "?" |
| 27 |
|
| 28 |
and pr_intro_pattern_action prc = function |
| 29 |
| IntroWildcard -> str "_" |
| 30 |
| IntroOrAndPattern pll -> pr_or_and_intro_pattern prc pll |
| 31 |
| IntroInjection pl -> |
| 32 |
str "[=" ++ hv 0 (prlist_with_sep spc (pr_intro_pattern prc) pl) ++ |
| 33 |
str "]" |
| 34 |
| IntroApplyOn ({CAst.v=c},pat) -> pr_intro_pattern prc pat ++ str "%" ++ prc c |
| 35 |
| IntroRewrite true -> str "->" |
| 36 |
| IntroRewrite false -> str "<-" |
| 37 |
|
| 38 |
and pr_or_and_intro_pattern prc = function |
| 39 |
| IntroAndPattern pl -> |
| 40 |
str "(" ++ hv 0 (prlist_with_sep pr_comma (pr_intro_pattern prc) pl) ++ str ")" |
| 41 |
| IntroOrPattern pll -> |
| 42 |
str "[" ++ |
| 43 |
hv 0 (prlist_with_sep pr_bar (prlist_with_sep spc (pr_intro_pattern prc)) pll) |
| 44 |
++ str "]" |
| 45 |
|
| 46 |
|
| 47 |
let pr_binding prc = let open CAst in function |
| 48 |
| {loc;v=(NamedHyp id, c)} -> hov 1 (Names.Id.print id.v ++ str " :=" ++ spc () ++ prc c) |
| 49 |
| {loc;v=(AnonHyp n, c)} -> hov 1 (int n ++ str " :=" ++ spc () ++ prc c) |
| 50 |
|
| 51 |
let pr_bindings prc prlc = function |
| 52 |
| ImplicitBindings l -> |
| 53 |
brk (1,1) ++ str "with" ++ brk (1,1) ++ |
| 54 |
pr_sequence prc l |
| 55 |
| ExplicitBindings l -> |
| 56 |
brk (1,1) ++ str "with" ++ brk (1,1) ++ |
| 57 |
pr_sequence (fun b -> str"(" ++ pr_binding prlc b ++ str")") l |
| 58 |
| NoBindings -> mt () |
| 59 |
|
| 60 |
let pr_bindings_no_with prc prlc = function |
| 61 |
| ImplicitBindings l -> |
| 62 |
brk (0,1) ++ prlist_with_sep spc prc l |
| 63 |
| ExplicitBindings l -> |
| 64 |
brk (0,1) ++ prlist_with_sep spc (fun b -> str"(" ++ pr_binding prlc b ++ str")") l |
| 65 |
| NoBindings -> mt () |
| 66 |
|
| 67 |
let pr_with_bindings prc prlc (c,bl) = |
| 68 |
hov 1 (prc c ++ pr_bindings prc prlc bl) |
| 69 |
|