Skip to content

Commit 231e2ba

Browse files
encukoublaisepAA-Turner
committed
Note practical difference between syntactic & lexical definitions
Co-authored-by: Blaise Pabon <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent 160ff42 commit 231e2ba

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Doc/reference/introduction.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,19 @@ This does *not* mean that there is an empty first alternative.
183183

184184
.. index:: lexical definitions
185185

186-
.. note::
187-
188-
There is some difference between *lexical* and *syntactic* analysis:
189-
the :term:`lexical analyzer` operates on the individual characters of the
190-
input source, while the *parser* (syntactic analyzer) operates on the stream
191-
of :term:`tokens <token>` generated by the lexical analysis.
192-
However, in some cases the exact boundary between the two phases is a
193-
CPython implementation detail.
194-
195-
This documentation uses the same BNF grammar for both.
186+
There is some difference between *lexical* and *syntactic* analysis:
187+
the :term:`lexical analyzer` operates on the individual characters of the
188+
input source, while the *parser* (syntactic analyzer) operates on the stream
189+
of :term:`tokens <token>` generated by the lexical analysis.
190+
However, in some cases the exact boundary between the two phases is a
191+
CPython implementation detail.
192+
193+
The practical difference between the two is that in *lexical* definitions,
194+
all whitespace is significant.
195+
The lexical analyzer :ref:`discards <whitespace>` all whitespace that is not
196+
converted to tokens like :data:`token.INDENT` or :data:`~token.NEWLINE`.
197+
*Syntactic* definitions then use these tokens, rather than source characters.
198+
199+
This documentation uses the same BNF grammar for both styles of definitions.
200+
All uses of BNF in the next chapter (“Lexical Analysis”) are lexical definitions;
201+
uses in subsequent chapters are syntactic definitions.

0 commit comments

Comments
 (0)