Skip to content

Commit caccca7

Browse files
andresdelfinoserhiy-storchaka
authored andcommitted
bpo-33702: Add some missing links in production lists and do a little polish (GH-7259)
1 parent b6bb77c commit caccca7

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`]
@@ -384,7 +384,7 @@ This allows common :keyword:`try`...\ :keyword:`except`...\ :keyword:`finally`
384384
usage patterns to be encapsulated for convenient reuse.
385385

386386
.. productionlist::
387-
with_stmt: "with" with_item ("," with_item)* ":" `suite`
387+
with_stmt: "with" `with_item` ("," `with_item`)* ":" `suite`
388388
with_item: `expression` ["as" `target`]
389389

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

470470
.. productionlist::
471-
funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")" ["->" `expression`] ":" `suite`
471+
funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")"
472+
: ["->" `expression`] ":" `suite`
472473
decorators: `decorator`+
473474
decorator: "@" `dotted_name` ["(" [`argument_list` [","]] ")"] NEWLINE
474475
dotted_name: `identifier` ("." `identifier`)*
475476
parameter_list: `defparameter` ("," `defparameter`)* ["," [`parameter_list_starargs`]]
476477
: | `parameter_list_starargs`
477478
parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* ["," ["**" `parameter` [","]]]
478-
: | "**" `parameter` [","]
479+
: | "**" `parameter` [","]
479480
parameter: `identifier` [":" `expression`]
480481
defparameter: `parameter` ["=" `expression`]
481482
funcname: `identifier`
@@ -698,7 +699,8 @@ Coroutine function definition
698699
-----------------------------
699700

700701
.. productionlist::
701-
async_funcdef: [`decorators`] "async" "def" `funcname` "(" [`parameter_list`] ")" ["->" `expression`] ":" `suite`
702+
async_funcdef: [`decorators`] "async" "def" `funcname` "(" [`parameter_list`] ")"
703+
: ["->" `expression`] ":" `suite`
702704

703705
.. index::
704706
keyword: async

Doc/reference/expressions.rst

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

10571057
.. productionlist::
1058-
power: ( `await_expr` | `primary` ) ["**" `u_expr`]
1058+
power: (`await_expr` | `primary`) ["**" `u_expr`]
10591059

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

11281128
.. productionlist::
11291129
m_expr: `u_expr` | `m_expr` "*" `u_expr` | `m_expr` "@" `m_expr` |
1130-
: `m_expr` "//" `u_expr`| `m_expr` "/" `u_expr` |
1130+
: `m_expr` "//" `u_expr` | `m_expr` "/" `u_expr` |
11311131
: `m_expr` "%" `u_expr`
11321132
a_expr: `m_expr` | `a_expr` "+" `m_expr` | `a_expr` "-" `m_expr`
11331133

@@ -1207,7 +1207,7 @@ Shifting operations
12071207
The shifting operations have lower priority than the arithmetic operations:
12081208

12091209
.. productionlist::
1210-
shift_expr: `a_expr` | `shift_expr` ( "<<" | ">>" ) `a_expr`
1210+
shift_expr: `a_expr` | `shift_expr` ("<<" | ">>") `a_expr`
12111211

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

12691269
.. productionlist::
1270-
comparison: `or_expr` ( `comp_operator` `or_expr` )*
1270+
comparison: `or_expr` (`comp_operator` `or_expr`)*
12711271
comp_operator: "<" | ">" | "==" | ">=" | "<=" | "!="
12721272
: | "is" ["not"] | ["not"] "in"
12731273

@@ -1631,9 +1631,9 @@ Expression lists
16311631
.. index:: pair: expression; list
16321632

16331633
.. productionlist::
1634-
expression_list: `expression` ( "," `expression` )* [","]
1635-
starred_list: `starred_item` ( "," `starred_item` )* [","]
1636-
starred_expression: `expression` | ( `starred_item` "," )* [`starred_item`]
1634+
expression_list: `expression` ("," `expression`)* [","]
1635+
starred_list: `starred_item` ("," `starred_item`)* [","]
1636+
starred_expression: `expression` | (`starred_item` ",")* [`starred_item`]
16371637
starred_item: `expression` | "*" `or_expr`
16381638

16391639
.. index:: object: tuple

Doc/reference/simple_stmts.rst

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

709709
.. productionlist::
710-
import_stmt: "import" `module` ["as" `name`] ( "," `module` ["as" `name`] )*
711-
: | "from" `relative_module` "import" `identifier` ["as" `name`]
712-
: ( "," `identifier` ["as" `name`] )*
713-
: | "from" `relative_module` "import" "(" `identifier` ["as" `name`]
714-
: ( "," `identifier` ["as" `name`] )* [","] ")"
710+
import_stmt: "import" `module` ["as" `identifier`] ("," `module` ["as" `identifier`])*
711+
: | "from" `relative_module` "import" `identifier` ["as" `identifier`]
712+
: ("," `identifier` ["as" `identifier`])*
713+
: | "from" `relative_module` "import" "(" `identifier` ["as" `identifier`]
714+
: ("," `identifier` ["as" `identifier`])* [","] ")"
715715
: | "from" `module` "import" "*"
716716
module: (`identifier` ".")* `identifier`
717717
relative_module: "."* `module` | "."+
718-
name: `identifier`
719718

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

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

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

0 commit comments

Comments
 (0)