Debian Codegraph @

test-suite/output/lexical_convention_in_doc.v

raw
1 Set Printing All. Set Warnings "-prefix-incompatible-level".
2
3 (* if ``~`` and ``~~`` are both defined as tokens,
4 the inputs ``~ ~`` and ``~~`` generate different tokens *)
5 Section TestLexer0.
6
7 #[warning="-closed-notation-not-level-0"]
8 Local Notation "~" := not.
9 Local Notation "~~" := not.
10
11 Check ~ ~ True.
12 Check ~~ True.
13
14 End TestLexer0.
15
16 (* whereas if ``~~`` is not defined,
17 then the two inputs are equivalent *)
18 Section TestLexer1.
19
20 #[warning="-closed-notation-not-level-0"]
21 Local Notation "~" := not.
22
23 Set Printing All.
24 Check ~ ~ True.
25 Check ~~ True.
26
27 End TestLexer1.
28
29 (* Also, if ``~`` and ``~_h`` are both defined as tokens, the input
30 ``~_ho`` is interpreted as ``~ _ho`` rather than ``~_h o`` so as
31 not to cut the identifier-like subsequence ``ho``. *)
32 Section TestLexer2.
33
34 #[warning="-closed-notation-not-level-0"]
35 Local Notation "~" := not.
36 Local Notation "~_h" := (fun x => not (not x)).
37 Local Notation "'_ho'" := False.
38 Let o := True.
39
40 Check ~_ho.
41 Check ~_h o.
42
43 End TestLexer2.
44
45
46 (* Contrastingly, if only ``~_h`` is defined as a token, then ``~_ho``
47 is an error because no token can be found that includes the whole
48 subsequence ``ho`` without cutting it in the middle. *)
49 Section TestLexer3.
50
51 Local Notation "~_h" := (fun x => not (not x)).
52
53 Fail Check ~_ho.
54
55 End TestLexer3.
56
57 (* Finally, if all of ``~``, ``~_h`` and ``~_ho`` are defined as
58 tokens, the input ``~_ho`` is interpreted using the longest match
59 rule, i.e. as the token ``~_ho``. *)
60 Section TestLexer4.
61
62 #[warning="-closed-notation-not-level-0"]
63 Local Notation "~" := not.
64 Local Notation "~_h" := (fun x => not (not x)).
65 Local Notation "'_ho'" := False.
66 Local Notation "~_ho" := True.
67
68 Check ~_ho.
69
70 End TestLexer4.