From d59d9a125d521db466c5bb321a5c17157b67ce4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Wed, 30 May 2018 20:20:18 -0300 Subject: [PATCH 1/7] Initial commit --- Doc/reference/compound_stmts.rst | 18 ++++++++++-------- Doc/reference/simple_stmts.rst | 22 ++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 5076e5df00789a..0e65e788af3105 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -235,7 +235,7 @@ The :keyword:`try` statement specifies exception handlers and/or cleanup code for a group of statements: .. productionlist:: - try_stmt: try1_stmt | try2_stmt + try_stmt: `try1_stmt` | `try2_stmt` try1_stmt: "try" ":" `suite` : ("except" [`expression` ["as" `identifier`]] ":" `suite`)+ : ["else" ":" `suite`] @@ -384,7 +384,7 @@ This allows common :keyword:`try`...\ :keyword:`except`...\ :keyword:`finally` usage patterns to be encapsulated for convenient reuse. .. productionlist:: - with_stmt: "with" with_item ("," with_item)* ":" `suite` + with_stmt: "with" `with_item` ("," `with_item`)* ":" `suite` with_item: `expression` ["as" `target`] 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 :ref:`types`): .. productionlist:: - funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")" ["->" `expression`] ":" `suite` + funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")" + : ["->" `expression`] ":" `suite` decorators: `decorator`+ decorator: "@" `dotted_name` ["(" [`argument_list` [","]] ")"] NEWLINE dotted_name: `identifier` ("." `identifier`)* - parameter_list: `defparameter` ("," `defparameter`)* ["," [`parameter_list_starargs`]] - : | `parameter_list_starargs` - parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* ["," ["**" `parameter` [","]]] - : | "**" `parameter` [","] + parameter_list: `defparameter` ("," `defparameter`)* + : ["," [`parameter_list_starargs`]] | `parameter_list_starargs` + parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* + : ["," ["**" `parameter` [","]]] | "**" `parameter` [","] parameter: `identifier` [":" `expression`] defparameter: `parameter` ["=" `expression`] funcname: `identifier` @@ -698,7 +699,8 @@ Coroutine function definition ----------------------------- .. productionlist:: - async_funcdef: [`decorators`] "async" "def" `funcname` "(" [`parameter_list`] ")" ["->" `expression`] ":" `suite` + async_funcdef: [`decorators`] "async" "def" `funcname` "(" [`parameter_list`] ")" + : ["->" `expression`] ":" `suite` .. index:: keyword: async diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index 9186210d951f69..6ecb140c9e4c62 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -707,15 +707,14 @@ The :keyword:`import` statement keyword: from .. productionlist:: - import_stmt: "import" `module` ["as" `name`] ( "," `module` ["as" `name`] )* - : | "from" `relative_module` "import" `identifier` ["as" `name`] - : ( "," `identifier` ["as" `name`] )* - : | "from" `relative_module` "import" "(" `identifier` ["as" `name`] - : ( "," `identifier` ["as" `name`] )* [","] ")" + import_stmt: "import" `module` ["as" `identifier`] ( "," `module` ["as" `identifier`] )* + : | "from" `relative_module` "import" `identifier` ["as" `identifier`] + : ( "," `identifier` ["as" `identifier`] )* + : | "from" `relative_module` "import" "(" `identifier` ["as" `identifier`] + : ( "," `identifier` ["as" `identifier`] )* [","] ")" : | "from" `module` "import" "*" module: (`identifier` ".")* `identifier` relative_module: "."* `module` | "."+ - name: `identifier` The basic import statement (no :keyword:`from` clause) is executed in two steps: @@ -837,12 +836,11 @@ features on a per-module basis before the release in which the feature becomes standard. .. productionlist:: * - future_statement: "from" "__future__" "import" feature ["as" name] - : ("," feature ["as" name])* - : | "from" "__future__" "import" "(" feature ["as" name] - : ("," feature ["as" name])* [","] ")" - feature: identifier - name: identifier + future_stmt: "from" "__future__" "import" `feature` ["as" `identifier`] + : ("," `feature` ["as" `identifier`])* + : | "from" "__future__" "import" "(" `feature` ["as" `identifier`] + : ("," `feature` ["as" `identifier`])* [","] ")" + feature: `identifier` A future statement must appear near the top of the module. The only lines that can appear before a future statement are: From e69dfc4364954f3d609d55049abcd46ed3f6bea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Wed, 30 May 2018 20:27:32 -0300 Subject: [PATCH 2/7] Second commit --- Doc/reference/compound_stmts.rst | 2 +- Doc/reference/expressions.rst | 14 +++++++------- Doc/reference/simple_stmts.rst | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 0e65e788af3105..7127888e849b53 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -91,7 +91,7 @@ The :keyword:`if` statement is used for conditional execution: .. productionlist:: if_stmt: "if" `expression` ":" `suite` - : ( "elif" `expression` ":" `suite` )* + : ("elif" `expression` ":" `suite`)* : ["else" ":" `suite`] It selects exactly one of the suites by evaluating the expressions one by one diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 222b8978e3709a..832793c285f554 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -816,7 +816,7 @@ or list). Slicings may be used as expressions or as targets in assignment or slicing: `primary` "[" `slice_list` "]" slice_list: `slice_item` ("," `slice_item`)* [","] slice_item: `expression` | `proper_slice` - proper_slice: [`lower_bound`] ":" [`upper_bound`] [ ":" [`stride`] ] + proper_slice: [`lower_bound`] ":" [`upper_bound`] [":" [`stride`]] lower_bound: `expression` upper_bound: `expression` stride: `expression` @@ -1055,7 +1055,7 @@ The power operator binds more tightly than unary operators on its left; it binds less tightly than unary operators on its right. The syntax is: .. productionlist:: - power: ( `await_expr` | `primary` ) ["**" `u_expr`] + power: (`await_expr` | `primary`) ["**" `u_expr`] Thus, in an unparenthesized sequence of power and unary operators, the operators are evaluated from right to left (this does not constrain the evaluation order @@ -1205,7 +1205,7 @@ Shifting operations The shifting operations have lower priority than the arithmetic operations: .. productionlist:: - shift_expr: `a_expr` | `shift_expr` ( "<<" | ">>" ) `a_expr` + shift_expr: `a_expr` | `shift_expr` ("<<" | ">>") `a_expr` These operators accept integers as arguments. They shift the first argument to the left or right by the number of bits given by the second argument. @@ -1265,7 +1265,7 @@ C, expressions like ``a < b < c`` have the interpretation that is conventional in mathematics: .. productionlist:: - comparison: `or_expr` ( `comp_operator` `or_expr` )* + comparison: `or_expr` (`comp_operator` `or_expr`)* comp_operator: "<" | ">" | "==" | ">=" | "<=" | "!=" : | "is" ["not"] | ["not"] "in" @@ -1629,9 +1629,9 @@ Expression lists .. index:: pair: expression; list .. productionlist:: - expression_list: `expression` ( "," `expression` )* [","] - starred_list: `starred_item` ( "," `starred_item` )* [","] - starred_expression: `expression` | ( `starred_item` "," )* [`starred_item`] + expression_list: `expression` ("," `expression`)* [","] + starred_list: `starred_item` ("," `starred_item`)* [","] + starred_expression: `expression` | (`starred_item` ",")* [`starred_item`] starred_item: `expression` | "*" `or_expr` .. index:: object: tuple diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index 6ecb140c9e4c62..bb1eea66f98bbc 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -707,11 +707,11 @@ The :keyword:`import` statement keyword: from .. productionlist:: - import_stmt: "import" `module` ["as" `identifier`] ( "," `module` ["as" `identifier`] )* + import_stmt: "import" `module` ["as" `identifier`] ("," `module` ["as" `identifier`])* : | "from" `relative_module` "import" `identifier` ["as" `identifier`] - : ( "," `identifier` ["as" `identifier`] )* + : ("," `identifier` ["as" `identifier`])* : | "from" `relative_module` "import" "(" `identifier` ["as" `identifier`] - : ( "," `identifier` ["as" `identifier`] )* [","] ")" + : ("," `identifier` ["as" `identifier`])* [","] ")" : | "from" `module` "import" "*" module: (`identifier` ".")* `identifier` relative_module: "."* `module` | "."+ From 71148b38c3890ec20a8b1c87dc7257cfcd3039c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Wed, 30 May 2018 20:36:13 -0300 Subject: [PATCH 3/7] Third commit --- Doc/reference/expressions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 832793c285f554..f59f052d8b3db2 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1127,7 +1127,7 @@ operators and one for additive operators: .. productionlist:: m_expr: `u_expr` | `m_expr` "*" `u_expr` | `m_expr` "@" `m_expr` | - : `m_expr` "//" `u_expr`| `m_expr` "/" `u_expr` | + : `m_expr` "//" `u_expr` | `m_expr` "/" `u_expr` | : `m_expr` "%" `u_expr` a_expr: `m_expr` | `a_expr` "+" `m_expr` | `a_expr` "-" `m_expr` From 433fba9e68eb7e59b8cd09d4e98203ddce540957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Thu, 31 May 2018 10:52:11 -0300 Subject: [PATCH 4/7] Fix whitespace --- Doc/reference/expressions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index f59f052d8b3db2..e3e93b7f1b2028 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -862,7 +862,7 @@ series of :term:`arguments `: .. productionlist:: call: `primary` "(" [`argument_list` [","] | `comprehension`] ")" argument_list: `positional_arguments` ["," `starred_and_keywords`] - : ["," `keywords_arguments`] + : ["," `keywords_arguments`] : | `starred_and_keywords` ["," `keywords_arguments`] : | `keywords_arguments` positional_arguments: ["*"] `expression` ("," ["*"] `expression`)* From 96e5d9e09b63ac139e2013a0827e89b3b2d80a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Thu, 31 May 2018 11:04:07 -0300 Subject: [PATCH 5/7] Fix whitspace --- Doc/reference/lexical_analysis.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst index c6d96ca612b8c3..0b7242217896cd 100644 --- a/Doc/reference/lexical_analysis.rst +++ b/Doc/reference/lexical_analysis.rst @@ -621,7 +621,7 @@ for the contents of the string is: f_string: (`literal_char` | "{{" | "}}" | `replacement_field`)* replacement_field: "{" `f_expression` ["!" `conversion`] [":" `format_spec`] "}" f_expression: (`conditional_expression` | "*" `or_expr`) - : ("," `conditional_expression` | "," "*" `or_expr`)* [","] + : ("," `conditional_expression` | "," "*" `or_expr`)* [","] : | `yield_expression` conversion: "s" | "r" | "a" format_spec: (`literal_char` | NULL | `replacement_field`)* From 5b7a4131ecf9342ed49d8383b7bdb09f14740f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Sat, 7 Jul 2018 16:44:18 -0300 Subject: [PATCH 6/7] Address Serhiy comments --- Doc/reference/compound_stmts.rst | 4 ++-- Doc/reference/expressions.rst | 4 ++-- Doc/reference/lexical_analysis.rst | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 7127888e849b53..853c5c200c3069 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -473,8 +473,8 @@ A function definition defines a user-defined function object (see section decorators: `decorator`+ decorator: "@" `dotted_name` ["(" [`argument_list` [","]] ")"] NEWLINE dotted_name: `identifier` ("." `identifier`)* - parameter_list: `defparameter` ("," `defparameter`)* - : ["," [`parameter_list_starargs`]] | `parameter_list_starargs` + parameter_list: `defparameter` ("," `defparameter`)* ["," [`parameter_list_starargs`]] + : | `parameter_list_starargs` parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* : ["," ["**" `parameter` [","]]] | "**" `parameter` [","] parameter: `identifier` [":" `expression`] diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index e3e93b7f1b2028..3c1c140f9d4f64 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -816,7 +816,7 @@ or list). Slicings may be used as expressions or as targets in assignment or slicing: `primary` "[" `slice_list` "]" slice_list: `slice_item` ("," `slice_item`)* [","] slice_item: `expression` | `proper_slice` - proper_slice: [`lower_bound`] ":" [`upper_bound`] [":" [`stride`]] + proper_slice: [`lower_bound`] ":" [`upper_bound`] [ ":" [`stride`] ] lower_bound: `expression` upper_bound: `expression` stride: `expression` @@ -862,7 +862,7 @@ series of :term:`arguments `: .. productionlist:: call: `primary` "(" [`argument_list` [","] | `comprehension`] ")" argument_list: `positional_arguments` ["," `starred_and_keywords`] - : ["," `keywords_arguments`] + : ["," `keywords_arguments`] : | `starred_and_keywords` ["," `keywords_arguments`] : | `keywords_arguments` positional_arguments: ["*"] `expression` ("," ["*"] `expression`)* diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst index 0b7242217896cd..c6d96ca612b8c3 100644 --- a/Doc/reference/lexical_analysis.rst +++ b/Doc/reference/lexical_analysis.rst @@ -621,7 +621,7 @@ for the contents of the string is: f_string: (`literal_char` | "{{" | "}}" | `replacement_field`)* replacement_field: "{" `f_expression` ["!" `conversion`] [":" `format_spec`] "}" f_expression: (`conditional_expression` | "*" `or_expr`) - : ("," `conditional_expression` | "," "*" `or_expr`)* [","] + : ("," `conditional_expression` | "," "*" `or_expr`)* [","] : | `yield_expression` conversion: "s" | "r" | "a" format_spec: (`literal_char` | NULL | `replacement_field`)* From f762477c14d3629decbf37dbceeecb9b02ba4b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Sat, 7 Jul 2018 17:09:31 -0300 Subject: [PATCH 7/7] Address new comments --- Doc/reference/compound_stmts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 853c5c200c3069..3372d27aa13fb0 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -475,8 +475,8 @@ A function definition defines a user-defined function object (see section dotted_name: `identifier` ("." `identifier`)* parameter_list: `defparameter` ("," `defparameter`)* ["," [`parameter_list_starargs`]] : | `parameter_list_starargs` - parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* - : ["," ["**" `parameter` [","]]] | "**" `parameter` [","] + parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* ["," ["**" `parameter` [","]]] + : | "**" `parameter` [","] parameter: `identifier` [":" `expression`] defparameter: `parameter` ["=" `expression`] funcname: `identifier`