Skip to content

Commit 445f9ed

Browse files
bpo-33702: Add some missing links in production lists and do a little polish (GH-7259)
(cherry picked from commit caccca7) Co-authored-by: Andrés Delfino <[email protected]>
1 parent 770937b commit 445f9ed

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

Doc/reference/compound_stmts.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The :keyword:`if` statement is used for conditional execution:
9191

9292
.. productionlist::
9393
if_stmt: "if" `expression` ":" `suite`
94-
: ( "elif" `expression` ":" `suite` )*
94+
: ("elif" `expression` ":" `suite`)*
9595
: ["else" ":" `suite`]
9696

9797
It selects exactly one of the suites by evaluating the expressions one by one
@@ -235,7 +235,7 @@ The :keyword:`try` statement specifies exception handlers and/or cleanup code
235235
for a group of statements:
236236

237237
.. productionlist::
238-
try_stmt: try1_stmt | try2_stmt
238+
try_stmt: `try1_stmt` | `try2_stmt`
239239
try1_stmt: "try" ":" `suite`
240240
: ("except" [`expression` ["as" `identifier`]] ":" `suite`)+
241241
: ["else" ":" `suite`]
@@ -383,7 +383,7 @@ This allows common :keyword:`try`...\ :keyword:`except`...\ :keyword:`finally`
383383
usage patterns to be encapsulated for convenient reuse.
384384

385385
.. productionlist::
386-
with_stmt: "with" with_item ("," with_item)* ":" `suite`
386+
with_stmt: "with" `with_item` ("," `with_item`)* ":" `suite`
387387
with_item: `expression` ["as" `target`]
388388

389389
The execution of the :keyword:`with` statement with one "item" proceeds as follows:
@@ -467,14 +467,15 @@ A function definition defines a user-defined function object (see section
467467
:ref:`types`):
468468

469469
.. productionlist::
470-
funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")" ["->" `expression`] ":" `suite`
470+
funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")"
471+
: ["->" `expression`] ":" `suite`
471472
decorators: `decorator`+
472473
decorator: "@" `dotted_name` ["(" [`argument_list` [","]] ")"] NEWLINE
473474
dotted_name: `identifier` ("." `identifier`)*
474475
parameter_list: `defparameter` ("," `defparameter`)* ["," [`parameter_list_starargs`]]
475476
: | `parameter_list_starargs`
476477
parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* ["," ["**" `parameter` [","]]]
477-
: | "**" `parameter` [","]
478+
: | "**" `parameter` [","]
478479
parameter: `identifier` [":" `expression`]
479480
defparameter: `parameter` ["=" `expression`]
480481
funcname: `identifier`
@@ -682,7 +683,8 @@ Coroutine function definition
682683
-----------------------------
683684

684685
.. productionlist::
685-
async_funcdef: [`decorators`] "async" "def" `funcname` "(" [`parameter_list`] ")" ["->" `expression`] ":" `suite`
686+
async_funcdef: [`decorators`] "async" "def" `funcname` "(" [`parameter_list`] ")"
687+
: ["->" `expression`] ":" `suite`
686688

687689
.. index::
688690
keyword: async

Doc/reference/expressions.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ The power operator binds more tightly than unary operators on its left; it binds
10131013
less tightly than unary operators on its right. The syntax is:
10141014

10151015
.. productionlist::
1016-
power: ( `await_expr` | `primary` ) ["**" `u_expr`]
1016+
power: (`await_expr` | `primary`) ["**" `u_expr`]
10171017

10181018
Thus, in an unparenthesized sequence of power and unary operators, the operators
10191019
are evaluated from right to left (this does not constrain the evaluation order
@@ -1085,7 +1085,7 @@ operators and one for additive operators:
10851085

10861086
.. productionlist::
10871087
m_expr: `u_expr` | `m_expr` "*" `u_expr` | `m_expr` "@" `m_expr` |
1088-
: `m_expr` "//" `u_expr`| `m_expr` "/" `u_expr` |
1088+
: `m_expr` "//" `u_expr` | `m_expr` "/" `u_expr` |
10891089
: `m_expr` "%" `u_expr`
10901090
a_expr: `m_expr` | `a_expr` "+" `m_expr` | `a_expr` "-" `m_expr`
10911091

@@ -1165,7 +1165,7 @@ Shifting operations
11651165
The shifting operations have lower priority than the arithmetic operations:
11661166

11671167
.. productionlist::
1168-
shift_expr: `a_expr` | `shift_expr` ( "<<" | ">>" ) `a_expr`
1168+
shift_expr: `a_expr` | `shift_expr` ("<<" | ">>") `a_expr`
11691169

11701170
These operators accept integers as arguments. They shift the first argument to
11711171
the left or right by the number of bits given by the second argument.
@@ -1230,7 +1230,7 @@ C, expressions like ``a < b < c`` have the interpretation that is conventional
12301230
in mathematics:
12311231

12321232
.. productionlist::
1233-
comparison: `or_expr` ( `comp_operator` `or_expr` )*
1233+
comparison: `or_expr` (`comp_operator` `or_expr`)*
12341234
comp_operator: "<" | ">" | "==" | ">=" | "<=" | "!="
12351235
: | "is" ["not"] | ["not"] "in"
12361236

@@ -1594,9 +1594,9 @@ Expression lists
15941594
.. index:: pair: expression; list
15951595

15961596
.. productionlist::
1597-
expression_list: `expression` ( "," `expression` )* [","]
1598-
starred_list: `starred_item` ( "," `starred_item` )* [","]
1599-
starred_expression: `expression` | ( `starred_item` "," )* [`starred_item`]
1597+
expression_list: `expression` ("," `expression`)* [","]
1598+
starred_list: `starred_item` ("," `starred_item`)* [","]
1599+
starred_expression: `expression` | (`starred_item` ",")* [`starred_item`]
16001600
starred_item: `expression` | "*" `or_expr`
16011601

16021602
.. index:: object: tuple

Doc/reference/simple_stmts.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -708,15 +708,14 @@ The :keyword:`import` statement
708708
keyword: from
709709

710710
.. productionlist::
711-
import_stmt: "import" `module` ["as" `name`] ( "," `module` ["as" `name`] )*
712-
: | "from" `relative_module` "import" `identifier` ["as" `name`]
713-
: ( "," `identifier` ["as" `name`] )*
714-
: | "from" `relative_module` "import" "(" `identifier` ["as" `name`]
715-
: ( "," `identifier` ["as" `name`] )* [","] ")"
711+
import_stmt: "import" `module` ["as" `identifier`] ("," `module` ["as" `identifier`])*
712+
: | "from" `relative_module` "import" `identifier` ["as" `identifier`]
713+
: ("," `identifier` ["as" `identifier`])*
714+
: | "from" `relative_module` "import" "(" `identifier` ["as" `identifier`]
715+
: ("," `identifier` ["as" `identifier`])* [","] ")"
716716
: | "from" `module` "import" "*"
717717
module: (`identifier` ".")* `identifier`
718718
relative_module: "."* `module` | "."+
719-
name: `identifier`
720719

721720
The basic import statement (no :keyword:`from` clause) is executed in two
722721
steps:
@@ -838,12 +837,11 @@ features on a per-module basis before the release in which the feature becomes
838837
standard.
839838

840839
.. productionlist:: *
841-
future_statement: "from" "__future__" "import" feature ["as" name]
842-
: ("," feature ["as" name])*
843-
: | "from" "__future__" "import" "(" feature ["as" name]
844-
: ("," feature ["as" name])* [","] ")"
845-
feature: identifier
846-
name: identifier
840+
future_stmt: "from" "__future__" "import" `feature` ["as" `identifier`]
841+
: ("," `feature` ["as" `identifier`])*
842+
: | "from" "__future__" "import" "(" `feature` ["as" `identifier`]
843+
: ("," `feature` ["as" `identifier`])* [","] ")"
844+
feature: `identifier`
847845

848846
A future statement must appear near the top of the module. The only lines that
849847
can appear before a future statement are:

0 commit comments

Comments
 (0)