Debian Codegraph @

doc/tools/rocqrst/notations/TacticNotations.g

raw
1 /************************************************************************/
2 /* * The Rocq Prover / The Rocq Development Team */
3 /* v * Copyright INRIA, CNRS and contributors */
4 /* <O___,, * (see version control and CREDITS file for authors & dates) */
5 /* \VV/ **************************************************************/
6 /* // * This file is distributed under the terms of the */
7 /* * GNU Lesser General Public License Version 2.1 */
8 /* * (see LICENSE file for the text of the license) */
9 /************************************************************************/
10 grammar TacticNotations;
11
12 // Terminals are not visited, so we add non-terminals for each terminal that
13 // needs rendering (in particular whitespace (kept in output) vs. WHITESPACE
14 // (discarded)).
15
16 // The distinction between nopipeblock and block is needed because we only want
17 // to require escaping within alternative blocks, so that e.g. `first [ x | y ]`
18 // can be written without escaping the `|`.
19
20 top: blocks EOF;
21 blocks: block ((whitespace)? block)*;
22
23 block: pipe | nopipeblock;
24 nopipeblock: atomic | escaped | hole | alternative | repeat | curlies;
25
26 alternative: LALT (WHITESPACE)? altblocks (WHITESPACE)? RBRACE;
27 altblocks: altblock ((WHITESPACE)? altsep (WHITESPACE)? altblock)+;
28 altblock: nopipeblock ((whitespace)? nopipeblock)*;
29
30 repeat: LGROUP (ATOM | PIPE)? WHITESPACE blocks (WHITESPACE)? RBRACE;
31 curlies: LBRACE (whitespace)? blocks (whitespace)? RBRACE;
32
33 pipe: PIPE;
34 altsep: PIPE;
35 whitespace: WHITESPACE;
36 escaped: ESCAPED;
37 atomic: ATOM (SUB)?;
38 hole: ID (SUB)?;
39
40
41 LALT: '{|';
42 LGROUP: '{+' | '{*' | '{?';
43 LBRACE: '{';
44 RBRACE: '}';
45 // todo: need a cleaner way to escape the 3-character strings here
46 ESCAPED: '%{' | '%}' | '%|' | '`%{' | '@%{' |
47 '%|-' | '%|->' | '%||' | '%|||' | '%||||'; // for SSR
48 PIPE: '|';
49 ATOM: '@' | '_' | ~[@_{}| ]+;
50 ID: '@' ('_'? [a-zA-Z0-9])+;
51 SUB: '_' '_' [a-zA-Z0-9]+;
52 WHITESPACE: ' '+;