@@ -90,9 +90,10 @@ Notation
90
90
91
91
..index ::BNF, grammar, syntax, notation
92
92
93
- The descriptions of lexical analysis and syntax use a modified
94
- `Backus–Naur form (BNF) <https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form >`_ grammar
95
- notation. This uses the following style of definition:
93
+ The descriptions of lexical analysis use a grammar notation that is a mixture
94
+ of `EBNF <https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form >`_
95
+ and `PEG <https://en.wikipedia.org/wiki/Parsing_expression_grammar >`_.
96
+ For example:
96
97
97
98
..grammar-snippet ::
98
99
:group: notation
@@ -136,7 +137,11 @@ The definition to the right of the colon uses the following syntax elements:
136
137
* ``e1 e2 ``: Items separated only by whitespace denote a sequence.
137
138
Here, ``e1 `` must be followed by ``e2 ``.
138
139
* ``e1 | e2 ``: A vertical bar is used to separate alternatives.
139
- It is the least tightly binding operator in this notation.
140
+ It denotes PEG's "ordered choice": if ``e1 `` matches, ``e2 `` is
141
+ not considered.
142
+ In traditional PEG grammars, this is written as a slash, ``/ ``, rather than
143
+ a vertical bar.
144
+ See:pep: `617 ` for more background and details.
140
145
* ``e* ``: A star means zero or more repetitions of the preceding item.
141
146
* ``e+ ``: Likewise, a plus means one or more repetitions.
142
147
* ``[e] ``: A phrase enclosed in square brackets means zero or
@@ -145,7 +150,8 @@ The definition to the right of the colon uses the following syntax elements:
145
150
the preceding item is optional.
146
151
* ``(e) ``: Parentheses are used for grouping.
147
152
148
- The unary operators (``* ``, ``+ ``, ``? ``) bind as tightly as possible.
153
+ The unary operators (``* ``, ``+ ``, ``? ``) bind as tightly as possible;
154
+ the vertical bar (``| ``) binds most loosely.
149
155
150
156
White space is only meaningful to separate tokens.
151
157