package coq

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file g_ssrmatching.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327

# 13 "plugins/ssrmatching/g_ssrmatching.mlg"
 

open Ltac_plugin
open Pcoq.Constr
open Ssrmatching
open Ssrmatching.Internal

(* Defining grammar rules with "xx" in it automatically declares keywords too,
 * we thus save the lexer to restore it at the end of the file *)
let frozen_lexer = CLexer.get_keyword_state () ;;



let __coq_plugin_name = "ssrmatching_plugin"
let _ = Mltop.add_known_module __coq_plugin_name

# 28 "plugins/ssrmatching/g_ssrmatching.mlg"
 

let pr_rpattern _ _ _ = pr_rpattern



let (wit_rpattern, rpattern) = Tacentries.argument_extend ~name:"rpattern" 
                               {
                               Tacentries.arg_parsing = Vernacextend.Arg_rules (
                                                        [(Pcoq.Production.make
                                                          (Pcoq.Rule.next 
                                                          (Pcoq.Rule.next 
                                                          (Pcoq.Rule.next 
                                                          (Pcoq.Rule.next 
                                                          (Pcoq.Rule.next 
                                                          (Pcoq.Rule.stop)
                                                          ((Pcoq.Symbol.nterm lconstr)))
                                                          ((Pcoq.Symbol.token (CLexer.terminal "as"))))
                                                          ((Pcoq.Symbol.nterm lconstr)))
                                                          ((Pcoq.Symbol.token (CLexer.terminal "in"))))
                                                          ((Pcoq.Symbol.nterm lconstr)))
                                                          (fun c _ x _ e
                                                          loc -> 
# 49 "plugins/ssrmatching/g_ssrmatching.mlg"
      mk_rpattern (E_As_X_In_T (mk_lterm e None, mk_lterm x None, mk_lterm c None)) 
                                                                 ));
                                                        (Pcoq.Production.make
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.stop)
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         ((Pcoq.Symbol.token (CLexer.terminal "in"))))
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         ((Pcoq.Symbol.token (CLexer.terminal "in"))))
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         (fun c _ x _ e
                                                         loc -> 
# 47 "plugins/ssrmatching/g_ssrmatching.mlg"
      mk_rpattern (E_In_X_In_T (mk_lterm e None, mk_lterm x None, mk_lterm c None)) 
                                                                ));
                                                        (Pcoq.Production.make
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.stop)
                                                         ((Pcoq.Symbol.token (CLexer.terminal "in"))))
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         ((Pcoq.Symbol.token (CLexer.terminal "in"))))
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         (fun c _ x _ loc ->
                                                         
# 45 "plugins/ssrmatching/g_ssrmatching.mlg"
      mk_rpattern (In_X_In_T (mk_lterm x None, mk_lterm c None)) 
                                                         ));
                                                        (Pcoq.Production.make
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.stop)
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         ((Pcoq.Symbol.token (CLexer.terminal "in"))))
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         (fun c _ x loc -> 
# 43 "plugins/ssrmatching/g_ssrmatching.mlg"
      mk_rpattern (X_In_T (mk_lterm x None, mk_lterm c None)) 
                                                                    ));
                                                        (Pcoq.Production.make
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.stop)
                                                         ((Pcoq.Symbol.token (CLexer.terminal "in"))))
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         (fun c _ loc -> 
# 41 "plugins/ssrmatching/g_ssrmatching.mlg"
                             mk_rpattern (In_T (mk_lterm c None)) 
                                                                    ));
                                                        (Pcoq.Production.make
                                                         (Pcoq.Rule.next 
                                                         (Pcoq.Rule.stop)
                                                         ((Pcoq.Symbol.nterm lconstr)))
                                                         (fun c loc -> 
# 40 "plugins/ssrmatching/g_ssrmatching.mlg"
                        mk_rpattern (T (mk_lterm c None)) 
                                                                    ))]);
                               Tacentries.arg_tag = Some
                                                    (Geninterp.val_tag (Genarg.topwit wit_rpatternty));
                               Tacentries.arg_intern = Tacentries.ArgInternFun ((fun f ist v -> (ist, f ist v)) (
                                                       
# 38 "plugins/ssrmatching/g_ssrmatching.mlg"
                  glob_rpattern 
                                                       ));
                               Tacentries.arg_subst = Tacentries.ArgSubstFun (
                                                      
# 39 "plugins/ssrmatching/g_ssrmatching.mlg"
                   subst_rpattern 
                                                      );
                               Tacentries.arg_interp = Tacentries.ArgInterpLegacy (
                                                       
# 37 "plugins/ssrmatching/g_ssrmatching.mlg"
                   interp_rpattern 
                                                       );
                               Tacentries.arg_printer = ((fun env sigma -> 
                                                        
# 36 "plugins/ssrmatching/g_ssrmatching.mlg"
               pr_rpattern 
                                                        ), (fun env sigma -> 
                                                        
# 36 "plugins/ssrmatching/g_ssrmatching.mlg"
               pr_rpattern 
                                                        ), (fun env sigma -> 
                                                        
# 36 "plugins/ssrmatching/g_ssrmatching.mlg"
               pr_rpattern 
                                                        ));
                               }
let _ = (wit_rpattern, rpattern)


# 52 "plugins/ssrmatching/g_ssrmatching.mlg"
 

let pr_ssrterm _ _ _ = pr_ssrterm



let (wit_cpattern, cpattern) = Tacentries.argument_extend ~name:"cpattern" 
                               {
                               Tacentries.arg_parsing = Vernacextend.Arg_rules (
                                                        [(Pcoq.Production.make
                                                          (Pcoq.Rule.next 
                                                          (Pcoq.Rule.next 
                                                          (Pcoq.Rule.stop)
                                                          ((Pcoq.Symbol.token (CLexer.terminal "Qed"))))
                                                          ((Pcoq.Symbol.nterm constr)))
                                                          (fun c _ loc -> 
# 64 "plugins/ssrmatching/g_ssrmatching.mlg"
                           mk_lterm c None 
                                                                    ))]);
                               Tacentries.arg_tag = None;
                               Tacentries.arg_intern = Tacentries.ArgInternFun ((fun f ist v -> (ist, f ist v)) (
                                                       
# 61 "plugins/ssrmatching/g_ssrmatching.mlg"
                     glob_cpattern 
                                                       ));
                               Tacentries.arg_subst = Tacentries.ArgSubstFun (
                                                      
# 61 "plugins/ssrmatching/g_ssrmatching.mlg"
                                                      subst_ssrterm 
                                                      );
                               Tacentries.arg_interp = Tacentries.ArgInterpLegacy (
                                                       
# 60 "plugins/ssrmatching/g_ssrmatching.mlg"
                      interp_ssrterm 
                                                       );
                               Tacentries.arg_printer = ((fun env sigma -> 
                                                        
# 62 "plugins/ssrmatching/g_ssrmatching.mlg"
                      pr_ssrterm 
                                                        ), (fun env sigma -> 
                                                        
# 63 "plugins/ssrmatching/g_ssrmatching.mlg"
                       pr_ssrterm 
                                                        ), (fun env sigma -> 
                                                        
# 59 "plugins/ssrmatching/g_ssrmatching.mlg"
                  pr_ssrterm 
                                                        ));
                               }
let _ = (wit_cpattern, cpattern)


# 67 "plugins/ssrmatching/g_ssrmatching.mlg"
 

let input_ssrtermkind strm = match LStream.peek_nth 0 strm with
  | Tok.KEYWORD "(" -> InParens
  | Tok.KEYWORD "@" -> WithAt
  | _ -> NoFlag
let ssrtermkind = Pcoq.Entry.(of_parser "ssrtermkind" { parser_fun = input_ssrtermkind })



let _ = let () =
        Pcoq.grammar_extend cpattern
        (Pcoq.Reuse (None, [Pcoq.Production.make
                            (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.stop)
                                                            ((Pcoq.Symbol.nterm ssrtermkind)))
                                            ((Pcoq.Symbol.nterm constr)))
                            (fun c k loc -> 
# 79 "plugins/ssrmatching/g_ssrmatching.mlg"
                                                   
    let pattern = mk_term k c None in
    if loc_of_cpattern pattern <> Some loc && k = InParens
    then mk_term Cpattern c None
    else pattern 
                                            )]))
        in ()

let (wit_lcpattern, lcpattern) = Tacentries.argument_extend ~name:"lcpattern" 
                                 {
                                 Tacentries.arg_parsing = Vernacextend.Arg_rules (
                                                          [(Pcoq.Production.make
                                                            (Pcoq.Rule.next 
                                                            (Pcoq.Rule.next 
                                                            (Pcoq.Rule.stop)
                                                            ((Pcoq.Symbol.token (CLexer.terminal "Qed"))))
                                                            ((Pcoq.Symbol.nterm lconstr)))
                                                            (fun c _ loc -> 
# 93 "plugins/ssrmatching/g_ssrmatching.mlg"
                            mk_lterm c None 
                                                                    ))]);
                                 Tacentries.arg_tag = Some
                                                      (Geninterp.val_tag (Genarg.topwit wit_cpattern));
                                 Tacentries.arg_intern = Tacentries.ArgInternFun ((fun f ist v -> (ist, f ist v)) (
                                                         
# 90 "plugins/ssrmatching/g_ssrmatching.mlg"
                     glob_cpattern 
                                                         ));
                                 Tacentries.arg_subst = Tacentries.ArgSubstFun (
                                                        
# 90 "plugins/ssrmatching/g_ssrmatching.mlg"
                                                      subst_ssrterm 
                                                        );
                                 Tacentries.arg_interp = Tacentries.ArgInterpLegacy (
                                                         
# 89 "plugins/ssrmatching/g_ssrmatching.mlg"
                      interp_ssrterm 
                                                         );
                                 Tacentries.arg_printer = ((fun env sigma -> 
                                                          
# 91 "plugins/ssrmatching/g_ssrmatching.mlg"
                      pr_ssrterm 
                                                          ), (fun env sigma -> 
                                                          
# 92 "plugins/ssrmatching/g_ssrmatching.mlg"
                       pr_ssrterm 
                                                          ), (fun env sigma -> 
                                                          
# 88 "plugins/ssrmatching/g_ssrmatching.mlg"
                  pr_ssrterm 
                                                          ));
                                 }
let _ = (wit_lcpattern, lcpattern)

let _ = let () =
        Pcoq.grammar_extend lcpattern
        (Pcoq.Reuse (None, [Pcoq.Production.make
                            (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.stop)
                                                            ((Pcoq.Symbol.nterm ssrtermkind)))
                                            ((Pcoq.Symbol.nterm lconstr)))
                            (fun c k loc -> 
# 98 "plugins/ssrmatching/g_ssrmatching.mlg"
                                                     
    let pattern = mk_term k c None in
    if loc_of_cpattern pattern <> Some loc && k = InParens
    then mk_term Cpattern c None
    else pattern 
                                            )]))
        in ()

let (wit_ssrpatternarg, ssrpatternarg) = Tacentries.argument_extend ~name:"ssrpatternarg" 
                                         {
                                         Tacentries.arg_parsing = Vernacextend.Arg_alias (rpattern);
                                         Tacentries.arg_tag = Some
                                                              (Geninterp.val_tag (Genarg.topwit wit_rpattern));
                                         Tacentries.arg_intern = Tacentries.ArgInternWit (wit_rpattern);
                                         Tacentries.arg_subst = Tacentries.ArgSubstWit (wit_rpattern);
                                         Tacentries.arg_interp = Tacentries.ArgInterpWit (wit_rpattern);
                                         Tacentries.arg_printer = ((fun env sigma -> 
                                                                  
# 105 "plugins/ssrmatching/g_ssrmatching.mlg"
                                                             pr_rpattern 
                                                                  ), (fun env sigma -> 
                                                                  
# 105 "plugins/ssrmatching/g_ssrmatching.mlg"
                                                             pr_rpattern 
                                                                  ), (fun env sigma -> 
                                                                  
# 105 "plugins/ssrmatching/g_ssrmatching.mlg"
                                                             pr_rpattern 
                                                                  ));
                                         }
let _ = (wit_ssrpatternarg, ssrpatternarg)

let () = Tacentries.tactic_extend __coq_plugin_name "ssrinstoftpat" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("ssrinstancesoftpat", 
                            Tacentries.TyArg (Extend.TUentry (Genarg.get_arg_tag wit_cpattern), 
                            Tacentries.TyNil)), (fun arg ist -> 
# 110 "plugins/ssrmatching/g_ssrmatching.mlg"
                                              ssrinstancesof arg 
                                                )))]


# 113 "plugins/ssrmatching/g_ssrmatching.mlg"
 

(* We wipe out all the keywords generated by the grammar rules we defined. *)
(* The user is supposed to Require Import ssreflect or Require ssreflect   *)
(* and Import ssreflect.SsrSyntax to obtain these keywords and as a         *)
(* consequence the extended ssreflect grammar.                             *)
let () = CLexer.set_keyword_state frozen_lexer ;;



OCaml

Innovation. Community. Security.