blob: 66536703a6c2d1b9d85ace27573d52372aa841af (
plain)
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
|
(***********************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
(* <O___,, * INRIA-Rocquencourt & LRI-CNRS-Orsay *)
(* \VV/ *************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(***********************************************************************)
(*i camlp4deps: "parsing/grammar.cma" i*)
(* $Id$ *)
open Pcoq
open Constr
GEXTEND Gram
GLOBAL: constr1 pattern;
pattern:
[ [ qid = global -> qid
| "("; p = compound_pattern; ")" -> p ] ]
;
compound_pattern:
[ [ p = pattern ; lp = ne_pattern_list ->
<:ast< (PATTCONSTRUCT $p ($LIST $lp)) >>
| p = pattern; "as"; id = Prim.var ->
<:ast< (PATTAS $id $p)>>
| p1 = pattern; ","; p2 = pattern ->
<:ast< (PATTCONSTRUCT Coq.Init.Datatypes.pair $p1 $p2) >>
| p = pattern -> p ] ]
;
ne_pattern_list:
[ [ c1 = pattern; cl = ne_pattern_list -> c1 :: cl
| c1 = pattern -> [c1] ] ]
;
equation:
[ [ lhs = ne_pattern_list; "=>"; rhs = constr9 ->
<:ast< (EQN $rhs ($LIST $lhs)) >> ] ]
;
ne_eqn_list:
[ [ e = equation; "|"; leqn = ne_eqn_list -> e :: leqn
| e = equation -> [e] ] ]
;
constr1:
[ [ "<"; l1 = lconstr; ">"; "Cases"; lc = ne_constr_list; "of";
OPT "|"; eqs = ne_eqn_list; "end" ->
<:ast< (CASES $l1 (TOMATCH ($LIST $lc)) ($LIST $eqs)) >>
| "Cases"; lc = ne_constr_list; "of";
OPT "|"; eqs = ne_eqn_list; "end" ->
<:ast< (CASES "SYNTH" (TOMATCH ($LIST $lc)) ($LIST $eqs)) >>
| "<"; l1 = lconstr; ">"; "Cases"; lc = ne_constr_list; "of";
"end" ->
<:ast< (CASES $l1 (TOMATCH ($LIST $lc))) >>
| "Cases"; lc = ne_constr_list; "of"; "end" ->
<:ast< (CASES "SYNTH" (TOMATCH ($LIST $lc))) >> ] ]
;
END;
|