Skip to content

Commit b2c1d6a

Browse files
committed
Update the notation chapter for grammar updates
This updates some of the description for the new grammar renderer.
1 parent 2d5d801 commit b2c1d6a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/notation.md

+12
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ The following notations are used by the *Lexer* and *Syntax* grammar snippets:
1313
| x<sup>\*</sup> | _OuterAttribute_<sup>\*</sup> | 0 or more of x |
1414
| x<sup>+</sup> | _MacroMatch_<sup>+</sup> | 1 or more of x |
1515
| x<sup>a..b</sup> | HEX_DIGIT<sup>1..6</sup> | a to b repetitions of x |
16+
| Rule1 Rule2 | `fn` _Name_ _Parameters_ | Sequence of rules in order |
1617
| \| | `u8` \| `u16`, Block \| Item | Either one or another |
1718
| \[ ] | \[`b` `B`] | Any of the characters listed |
1819
| \[ - ] | \[`a`-`z`] | Any of the characters in the range |
1920
| ~\[ ] | ~\[`b` `B`] | Any characters, except those listed |
2021
| ~`string` | ~`\n`, ~`*/` | Any characters, except this sequence |
2122
| ( ) | (`,` _Parameter_)<sup>?</sup> | Groups items |
23+
| U+xxxx | U+0060 | A single unicode character |
24+
| \<text\> | \<any ASCII char except CR\> | An English description of what should be matched |
25+
| Rule <sub>suffix</sub> | IDENTIFIER_OR_KEYWORD <sub>_except `crate`_</sub> | A modification to the previous rule |
26+
27+
Sequences have a higher precedence than `|` alternation.
2228

2329
## String table productions
2430

@@ -34,6 +40,12 @@ When such a string in `monospace` font occurs inside the grammar,
3440
it is an implicit reference to a single member of such a string table
3541
production. See [tokens] for more information.
3642

43+
## Railroad visualizations
44+
45+
Below each grammar block is a button to toggle the display of a [railroad diagram]. A square element is a non-terminal rule, and a rounded rectangle is a terminal.
46+
47+
[railroad diagram]: https://en.wikipedia.org/wiki/Syntax_diagram
48+
3749
## Common productions
3850

3951
The following are common definitions used in the grammar.

0 commit comments

Comments
 (0)