Skip to content

Commit 01bed13

Browse files
encukoublaisepAA-Turner
committed
Initial rewording; add table of ASCII source characters
Co-authored-by: Blaise Pabon <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent 089a324 commit 01bed13

File tree

1 file changed

+163
-16
lines changed

1 file changed

+163
-16
lines changed

Doc/reference/lexical_analysis.rst

Lines changed: 163 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,27 +1351,25 @@ Formally, imaginary literals are described by the following lexical definition:
13511351
imagnumber: (`floatnumber` | `digitpart`) ("j" | "J")
13521352

13531353

1354+
.. _delimiters:
13541355
.. _operators:
13551356

1356-
Operators
1357-
=========
1357+
Operators and delimiters
1358+
========================
13581359

13591360
.. index:: single: operators
13601361

1361-
The following tokens are operators:
1362+
The following tokens are operators -- they can be put between two
1363+
:ref:`expressions <expressions>` (or in front of an expression)
1364+
to make a larger expression.
13621365

13631366
.. code-block:: none
13641367
13651368
1366-
+ - * ** / // % @
1367-
<< >> & | ^ ~ :=
1369+
+ - * ** / // %
1370+
<< >> & | ^ ~
13681371
< > <= >= == !=
1369-
1370-
1371-
.. _delimiters:
1372-
1373-
Delimiters
1374-
==========
1372+
@ := .
13751373
13761374
.. index:: single: delimiters
13771375

@@ -1380,9 +1378,11 @@ The following tokens serve as delimiters in the grammar:
13801378
.. code-block:: none
13811379
13821380
( ) [ ] { }
1383-
, : ! . ; @ =
1381+
, : ! ; = ->
1382+
. @
13841383
1385-
The period can also occur in floating-point and imaginary literals.
1384+
The period can also occur in floating-point and imaginary literals;
1385+
the period and the ``@`` can also serve as operators.
13861386

13871387
.. _lexical-ellipsis:
13881388

@@ -1393,13 +1393,13 @@ A sequence of three periods has a special meaning as an
13931393
13941394
...
13951395
1396-
The following *augmented assignment operators* serve
1396+
The following :ref:`augmented assignment <augassign>` operators serve
13971397
lexically as delimiters, but also perform an operation:
13981398

13991399
.. code-block:: none
14001400
1401-
-> += -= *= /= //= %=
1402-
@= &= |= ^= >>= <<= **=
1401+
+= -= *= **= /= //= %=
1402+
<<= >>= &= |= ^= @=
14031403
14041404
The following printing ASCII characters have special meaning as part of other
14051405
tokens or are otherwise significant to the lexical analyzer:
@@ -1415,3 +1415,150 @@ occurrence outside string literals and comments is an unconditional error:
14151415
14161416
$ ? `
14171417
1418+
1419+
Summary of source characters
1420+
============================
1421+
1422+
.. list-table::
1423+
:widths: auto
1424+
:header-rows: 1
1425+
1426+
* * No.
1427+
* Symbol
1428+
* Meaning in Python
1429+
* * 0
1430+
* ``'\x00'``
1431+
* not a source character
1432+
* * 1-8
1433+
*
1434+
* control characters
1435+
* * 9
1436+
* ``'\t'``
1437+
* whitespace
1438+
* * 10
1439+
* ``'\n'``
1440+
* newline
1441+
* * 11
1442+
*
1443+
* control character
1444+
* * 12
1445+
* ``'\f'``
1446+
* whitespace
1447+
* * 13
1448+
* ``'\r'``
1449+
* newline
1450+
* * 14-31
1451+
*
1452+
* control characters
1453+
* * 32
1454+
* space
1455+
* whitespace
1456+
* * 33
1457+
* ``!``
1458+
* part of ``!=``
1459+
* * 34
1460+
* ``"``
1461+
* string quote
1462+
* * 35
1463+
* ``#``
1464+
* comment
1465+
* * 36
1466+
* ``$``
1467+
* unused symbol
1468+
* * 37
1469+
* ``%``
1470+
* operator
1471+
* * 38
1472+
* ``&``
1473+
* operator
1474+
* * 39
1475+
* ``'``
1476+
* string quote
1477+
* * 40
1478+
* ``(``
1479+
* delimiter
1480+
* * 41
1481+
* ``)``
1482+
* delimiter
1483+
* * 42
1484+
* ``*``
1485+
* operator
1486+
* * 43
1487+
* ``+``
1488+
* operator
1489+
* * 44
1490+
* ``,``
1491+
* delimiter
1492+
* * 45
1493+
* ``-``
1494+
* operator
1495+
* * 46
1496+
* ``.``
1497+
* operator, delimiter, part of number syntax
1498+
* * 47
1499+
* ``/``
1500+
* operator
1501+
* * 48-57
1502+
* ``0`` to ``9``
1503+
* part of number syntax, part of name syntax
1504+
* * 58
1505+
* ``:``
1506+
* delimiter
1507+
* * 59
1508+
* ``;``
1509+
* delimiter
1510+
* * 60
1511+
* ``<``
1512+
* operator
1513+
* * 61
1514+
* ``=``
1515+
* operator
1516+
* * 62
1517+
* ``>``
1518+
* operator
1519+
* * 63
1520+
* ``?``
1521+
* unused symbol
1522+
* * 64
1523+
* ``@``
1524+
* operator, delimiter
1525+
* * 65-90
1526+
* ``A`` to ``Z``
1527+
* part of name syntax
1528+
* * 91
1529+
* ``[``
1530+
* delimiter
1531+
* * 92
1532+
* ``\``
1533+
* operator
1534+
* * 93
1535+
* ``]``
1536+
* delimiter
1537+
* * 94
1538+
* ``^``
1539+
* operator
1540+
* * 95
1541+
* ``_``
1542+
* part of name syntax
1543+
* * 96
1544+
* .. this uses zero-width joiner characters to get a
1545+
literal backtick:
1546+
1547+
``‍`‍``
1548+
1549+
* unused symbol
1550+
* * 97-122
1551+
* ``a`` to ``z``
1552+
* part of name syntax
1553+
* * 123
1554+
* ``{``
1555+
* delimiter
1556+
* * 124
1557+
* ``|``
1558+
* operator
1559+
* * 125
1560+
* ``}``
1561+
* delimiter
1562+
* * 126
1563+
* ``~``
1564+
* operator

0 commit comments

Comments
 (0)