Debian Codegraph @

test-suite/output-coqtop/LevelTolerance.v

raw
1 Set Warnings "+level-tolerance".
2 Set Warnings "-closed-notation-not-level-0".
3 Set Warnings "-level-0-notation-not-closed".
4 Set Warnings "-postfix-notation-not-level-1".
5
6 Inductive T := E : T | F : T -> T | G : T -> T -> T.
7 Inductive Parsing {A} := Accept (_ : nat) (_ : A) | Reject (_ : nat) (_ : A).
8
9 Declare Custom Entry expr.
10
11 Notation "x 'op22' y" := (G x y) (in custom expr at level 3, only parsing, no associativity).
12 Notation "x 'op12' y" := (G x y) (in custom expr at level 2, only parsing, right associativity).
13 Notation "x 'op10' y" := (G x y) (in custom expr at level 1, only parsing, left associativity).
14
15 Notation "[3 e ]" := e (e custom expr at level 3, only parsing).
16 Notation "[2 e ]" := e (e custom expr at level 2, only parsing).
17 Notation "[1 e ]" := e (e custom expr at level 1, only parsing).
18 Notation "[0 e ]" := e (e custom expr at level 0, only parsing).
19
20 Notation "'atom3'" := E (in custom expr at level 3, only parsing).
21 Notation "'atom2'" := E (in custom expr at level 2, only parsing).
22 Notation "'atom1'" := E (in custom expr at level 1, only parsing).
23 Notation "'atom0'" := E (in custom expr at level 0, only parsing).
24
25 Notation "'pre22' x" := (F x) (in custom expr at level 2, x at level 2, only parsing).
26 Notation "'pre21' x" := (F x) (in custom expr at level 2, x at next level, only parsing).
27 Notation "'pre11' x" := (F x) (in custom expr at level 1, x at level 1, only parsing).
28 Notation "'pre10' x" := (F x) (in custom expr at level 1, x at next level, only parsing).
29 Notation "'pre00' x" := (F x) (in custom expr at level 0, x at level 0, only parsing).
30 Notation "'pre0x' x" := (F x) (in custom expr at level 0, x at next level, only parsing).
31
32 Notation "x 'post12'" := (F x) (in custom expr at level 2, only parsing).
33 Notation "x 'post11'" := (F x) (in custom expr at level 1, only parsing).
34
35 Print Custom Grammar expr.
36
37 (* The following sed script prints the first line with a wrong result:
38
39 sed -En '/Accept/{/^(Rocq < )+Accept/!bf};/Reject/{/^> Check Reject/!bf};b;:f;p;q1' \
40 test-suite/output-coqtop/LevelTolerance.out
41
42 The script checks that:
43 - Each line containing "Reject" starts with "> Check Reject"
44 - Each line containing "Accept" starts with one or more "Rocq < " followed by "Accept"
45
46 In case of failure, it prints the line containing "Reject" or "Accept". *)
47
48 Check Reject 10 [2 atom3 ].
49 Check Accept 11 [2 atom2 ].
50 Check Reject 12 [1 atom2 ].
51 Check Accept 13 [1 atom1 ].
52
53 Check Reject 20 [2 pre22 atom3 ].
54 Check Accept 21 [2 pre22 atom2 ].
55 Check Reject 22 [1 pre22 atom2 ].
56
57 Check Reject 30 [2 pre21 atom2 ].
58 Check Accept 31 [2 pre21 atom1 ].
59 Check Reject 32 [1 pre21 atom1 ].
60
61 Check Reject 40 [2 pre11 atom2 ].
62 Check Reject 41 [1 pre11 atom2 ].
63 Check Accept 42 [1 pre11 atom1 ].
64 Check Reject 43 [0 pre11 atom1 ].
65
66 Check Reject 50 [1 pre10 atom1 ].
67 Check Accept 51 [1 pre10 atom0 ].
68 Check Reject 52 [0 pre10 atom0 ].
69
70 Check Reject 60 [1 pre00 atom1 ].
71 Check Reject 61 [0 pre00 atom1 ].
72 Check Accept 62 [0 pre00 atom0 ].
73
74 Check Reject 70 [0 pre0x atom0 ].
75
76 Check Reject 80 [2 atom3 post12 ].
77 Check Reject 81 [2 atom2 post12 ].
78 Check Accept 82 [2 atom1 post12 ].
79 Check Reject 83 [1 atom1 post12 ].
80
81 Check Reject 90 [2 atom2 post11 ].
82 Check Accept 91 [2 atom1 post11 ].
83 Check Accept 92 [1 atom1 post11 ].
84 Check Reject 93 [0 atom1 post11 ].
85
86 Check Reject 100 [3 atom3 op22 atom2 ].
87 Check Reject 101 [3 atom2 op22 atom3 ].
88 Check Accept 102 [3 atom2 op22 atom2 ].
89 Check Reject 103 [2 atom2 op22 atom2 ].
90
91 Check Reject 110 [2 atom2 op12 atom2 ].
92 Check Reject 111 [2 atom1 op12 atom3 ].
93 Check Accept 112 [2 atom1 op12 atom2 ].
94 Check Reject 113 [1 atom1 op12 atom2 ].
95
96 Check Reject 120 [1 atom2 op10 atom0].
97 Check Reject 121 [1 atom1 op10 atom1].
98 Check Accept 122 [1 atom1 op10 atom0].
99 Check Reject 123 [0 atom1 op10 atom0].
100
101 Check Reject 130 [2 pre22 atom2 op12 atom2 ].
102 Check Reject 131 [2 pre21 atom1 op12 atom2 ].
103 Check Accept 132 [2 pre22 atom1 op12 atom2 ].
104
105 Check Reject 140 [2 atom2 post12 op12 atom2 ].
106 Check Reject 141 [2 atom1 post12 op12 atom2 ].
107 Check Accept 142 [2 atom1 post11 op12 atom2 ].
108
109 Check Accept 150 [2 atom1 op12 pre22 atom2 ].
110 Check Reject 151 [2 atom1 op12 pre21 atom2 ].
111 Check Accept 152 [2 atom1 op12 pre21 atom1 ].
112
113 Check Reject 160 [2 atom1 op12 atom2 post12 ].
114 Check Accept 161 [2 atom1 op12 atom1 post12 ].
115 Check Reject 162 [2 atom1 op10 atom1 post12 ].
116 Check Accept 163 [2 atom1 op10 atom0 post12 ].
117
118 Check Accept 170 [1 pre11 atom1 op10 atom0 ].
119 Check Reject 171 [1 pre10 atom1 op10 atom0 ].
120 Check Accept 172 [1 pre10 atom0 op10 atom0 ].
121
122 Check Reject 180 [1 atom1 post12 op10 atom0 ].
123 Check Accept 181 [1 atom1 post11 op10 atom0 ].
124
125 Check Reject 190 [1 atom1 op10 pre11 atom0 ].
126 Check Reject 191 [1 atom1 op10 pre10 atom0 ].
127
128 Check Accept 200 [2 atom1 op10 atom0 post12 ].
129 Check Reject 201 [1 atom1 op10 atom0 post12 ].
130 Check Accept 202 [1 atom1 op10 atom0 post11 ].
131
132 Check Reject 210 [2 atom1 op12 atom2 op12 atom2 ].
133 Check Accept 211 [2 atom1 op12 atom1 op12 atom2 ].
134
135 Check Reject 220 [1 atom1 op10 atom1 op10 atom0 ].
136 Check Accept 221 [1 atom1 op10 atom0 op10 atom0 ].
137
138 From Corelib Require Import Notations.
139
140 Tactic Notation (at level 5) "atom5" := idtac.
141 Tactic Notation (at level 4) "atom4" := idtac.
142 Tactic Notation (at level 3) "atom3" := idtac.
143 Tactic Notation (at level 2) "atom2" := idtac.
144 Tactic Notation (at level 1) "atom1" := idtac.
145
146 Tactic Notation (at level 4) "pre44" tactic4(x) := x.
147 Tactic Notation (at level 4) "pre43" tactic3(x) := x.
148 Tactic Notation (at level 2) "pre22" tactic2(x) := x.
149 Tactic Notation (at level 2) "pre21" tactic1(x) := x.
150
151 Tactic Notation (at level 4) tactic4(x) "post44" := x.
152 Tactic Notation (at level 2) tactic2(x) "post12" := x.
153
154 Print Grammar tactic.
155
156 Check Reject 230 ltac:(atom5 ; atom3).
157 Check Reject 231 ltac:(atom4 ; atom4).
158 Check Accept 232 ltac:(atom4 ; atom3).
159 Check Accept 233 ltac:(atom4 ; atom3 ; atom3).
160
161 Check Reject 240 ltac:(pre43 atom4 ; atom3).
162 Check Accept 241 ltac:(pre43 atom3 ; atom3).
163 Check Reject 242 ltac:(pre44 atom4 ; atom3).
164 Check Accept 243 ltac:(pre44 atom3 ; atom3).
165
166 Check Accept 250 ltac:(atom4 post44 ; atom3).
167 Check Accept 251 ltac:(atom4 ; atom3 post44).
168
169 Check Reject 260 ltac:(atom2 + atom2).
170 Check Reject 261 ltac:(atom1 + atom3).
171 Check Accept 262 ltac:(atom1 + atom2).
172 Check Accept 263 ltac:(atom1 + atom1 + atom2).
173
174 Check Reject 270 ltac:(pre22 atom2 + atom2).
175 Check Reject 271 ltac:(pre21 atom1 + atom2).
176 Check Accept 272 ltac:(pre22 atom1 + atom2).
177 Check Accept 273 ltac:(atom1 + pre22 atom2).
178
179 Check Reject 280 ltac:(atom1 post12 + atom2).
180 Check Reject 281 ltac:(atom1 + atom2 post12).
181 Check Accept 282 ltac:(atom1 + atom1 post12).