You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prepare the docs for using the notation used in the `python.gram`
file. If we want to sync the two, the meta-syntax should be the same.
Link the Full Grammar docs here; keep only a few extras.
Also, remove the distinction between lexical and syntactic rules,
except for whitespace handling.
With f- and t-strings, the line between the two is blurry.
Co-authored-by: Blaise Pabon <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Lysandros Nikolaou <[email protected]>
Co-authored-by: Colin Marquardt <[email protected]>
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:
96
-
97
-
.. productionlist:: notation
98
-
name: `lc_letter` (`lc_letter` | "_")*
99
-
lc_letter: "a"..."z"
100
-
101
-
The first line says that a ``name`` is an ``lc_letter`` followed by a sequence
102
-
of zero or more ``lc_letter``\ s and underscores. An ``lc_letter`` in turn is
103
-
any of the single characters ``'a'`` through ``'z'``. (This rule is actually
104
-
adhered to for the names defined in lexical and grammar rules in this document.)
105
-
106
-
Each rule begins with a name (which is the name defined by the rule) and
107
-
``::=``. A vertical bar (``|``) is used to separate alternatives; it is the
108
-
least binding operator in this notation. A star (``*``) means zero or more
109
-
repetitions of the preceding item; likewise, a plus (``+``) means one or more
110
-
repetitions, and a phrase enclosed in square brackets (``[ ]``) means zero or
111
-
one occurrences (in other words, the enclosed phrase is optional). The ``*``
112
-
and ``+`` operators bind as tightly as possible; parentheses are used for
113
-
grouping. Literal strings are enclosed in quotes. White space is only
114
-
meaningful to separate tokens. Rules are normally contained on a single line;
115
-
rules with many alternatives may be formatted alternatively with each line after
116
-
the first beginning with a vertical bar.
117
-
118
-
.. index:: lexical definitions, ASCII
119
-
120
-
In lexical definitions (as the example above), two more conventions are used:
121
-
Two literal characters separated by three dots mean a choice of any single
122
-
character in the given (inclusive) range of ASCII characters. A phrase between
123
-
angular brackets (``<...>``) gives an informal description of the symbol
124
-
defined; e.g., this could be used to describe the notion of 'control character'
125
-
if needed.
126
-
127
-
Even though the notation used is almost the same, there is a big difference
128
-
between the meaning of lexical and syntactic definitions: a lexical definition
129
-
operates on the individual characters of the input source, while a syntax
130
-
definition operates on the stream of tokens generated by the lexical analysis.
131
-
All uses of BNF in the next chapter ("Lexical Analysis") are lexical
132
-
definitions; uses in subsequent chapters are syntactic definitions.
133
-
93
+
The descriptions of lexical analysis and syntax use a grammar notation that
0 commit comments