@@ -1353,78 +1353,61 @@ Formally, imaginary literals are described by the following lexical definition:
13531353
13541354.. _delimiters :
13551355.. _operators :
1356+ .. _lexical-ellipsis :
13561357
13571358Operators and delimiters
13581359======================== 
13591360
1360- .. index :: single: operators 
1361- 
1362- The following tokens are :dfn: `operators ` -- they are used to combine
1363- :ref: `expressions  <expressions >`.
1364- 
1365- .. code-block :: none 
1366- 
1367- 
1368-    +       -       *       **      /       //      % 
1369-    <<      >>      &       |       ^       ~ 
1370-    <       >       <=      >=      ==      != 
1371-    .       @       := 
1372- 
1373- + ``) and minus (``- ``) signs can also occur in
1374- :ref: `floating-point  <floating >` and :ref: `imaginary ` literals.
1375- 
1376- .. index :: single: delimiters 
1377- 
1378- The following tokens are :dfn: `delimiters ` -- simple tokens that
1379- are not operators:
1380- 
1381- .. code-block :: none 
1382- 
1383-    (       )       [       ]       {       } 
1384-    ,       :       !       ;       =       -> 
1385-    .       @ 
1386- 
1387- . ``) and at-sign (``@ ``) can serve either as operators
1388- or delimiters.
1389- 
1390- The period can also occur in :ref: `floating-point  <floating >` and
1391- :ref: `imaginary ` literals.
1392- 
1393- The symbols ``{ ``, ``} ``, ``! `` and ``: `` have special meaning in
1394- :ref: `formatted string literals  <f-strings >` and
1395- :ref: `template string literals  <t-strings >`.
1396- 
1397- .. _lexical-ellipsis :
1398- 
1399- A sequence of three periods (without whitespace between them) has a special
1400- meaning as an :py:data: `Ellipsis ` literal:
1401- 
1402- .. code-block :: none 
1403- 
1404-    ... 
1361+ .. index ::
1362+    single: operators
1363+    single: delimiters
14051364
1406- tokens are  :ref: ` augmented assignment  < augassign >` operators: 
1407- they serve lexically as delimiters, but also perform an operation :
1365+ The following grammar defines  :dfn: ` operator ` and  :dfn: ` delimiter ` tokens, 
1366+ that is, the generic  :data: ` ~token.OP ` token type :
14081367
1409- .. code-block :: none 
1368+ .. grammar-snippet ::
1369+    :group:  python-grammar
14101370
1411-    +=      -=      *=      **=     /=      //=     %= 
1412-    <<=     >>=     &=      |=      ^=      @= 
1371+    OP:
1372+       |  arithmetic_operator 
1373+ |  bitwise_operator 
1374+ |  comparison_operator 
1375+ |  enclosing_delimiter 
1376+ |  other_delimiter 
1377+ |  assignment_operator 
1378+ |  other_op 
1379+ |  "..." 
1380+ 
1381+    arithmetic_operator:   "+"  | "-"  | "*"  | "**"  | "/"   | "//"  | "%"
1382+    bitwise_operator:      "&"  | "^"  | "~"  | "<<"  | ">>"
1383+    assignment_operator:   "+=" | "-=" | "*=" | "**=" | "/="  | "//=" | "%=" | 
1384+                           "&=" | "|=" | "^=" | "<<=" | ">>=" | "@="  | ":=" 
1385+    comparison_operator:   "<"  | ">"  | "<=" | ">="  | "=="  | "!=" 
1386+    enclosing_delimiter:   "("  | ")"  | "["  | "]"   | "{"   | "}" 
1387+    other_delimiter:       ","  | ":"  | "!"  | ";"   | "="   | "->" 
1388+    other_op:              "."  | "@" 
1389+ 
1390+ .. note ::
1391+ 
1392+    Generally, *operators * are used to combine :ref: `expressions  <expressions >`,
1393+    while *delimiters * serve other purposes.
1394+    However, there is no clear, formal distinction between the two categories.
1395+ 
1396+    Some tokens can serve as either operators or delimiters, depending on usage.
1397+    For example, ``* `` is both the multiplication operator and a delimiter used
1398+    for sequence unpacking, and ``@ `` is both the matrix multiplication and
1399+    a delimiter that introduces decorators.
1400+ 
1401+    For some tokens, the distinction is unclear.
1402+    For example, some people consider ``. ( ) `` to be delimiters, while others
1403+    see the :py:func: `getattr ` operator and the function call operator(s).
1404+ 
1405+    Some of Python's operators, like ``and ``, ``or ``, and ``not in ``, use
1406+    :ref: `keyword  <keywords >` tokens rather than "symbols" (operator tokens).
1407+ 
1408+ A sequence of three consecutive periods (``... ``) has a special
1409+ meaning as an :py:data: `Ellipsis ` literal.
14131410
14141411See :ref: `operator and delimiter tokens  <token_operators_delimiters >`
14151412in the :mod: `!token ` module documentation for names of the operator and
14161413delimiter tokens.
1417- 
1418- The following printing ASCII characters have special meaning as part of other
1419- tokens or are otherwise significant to the lexical analyzer:
1420- 
1421- .. code-block :: none 
1422- 
1423-    '       "       #       \ 
1424- 
1425- 
1426- occurrence outside string literals and comments is an unconditional error:
1427- 
1428- .. code-block :: none 
1429- 
1430-    $       ?       ` 
0 commit comments