| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 27201cd commit 8af239e
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -596,7 +596,7 @@ are always available. They are listed here in alphabetical order. | |||
| 596 | 596 | input must conform to the following grammar after leading and trailing | |
| 597 | 597 | whitespace characters are removed: | |
| 598 | 598 | ||
| 599 | - .. productionlist:: | ||
| 599 | + .. productionlist:: float | ||
| 600 | 600 | sign: "+" | "-" | |
| 601 | 601 | infinity: "Infinity" | "inf" | |
| 602 | 602 | nan: "nan" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,7 +205,7 @@ literal text, it can be escaped by doubling: ``{{`` and ``}}``. | |||
| 205 | 205 | ||
| 206 | 206 | The grammar for a replacement field is as follows: | |
| 207 | 207 | ||
| 208 | - .. productionlist:: sf | ||
| 208 | + .. productionlist:: format-string | ||
| 209 | 209 | replacement_field: "{" [`field_name`] ["!" `conversion`] [":" `format_spec`] "}" | |
| 210 | 210 | field_name: arg_name ("." `attribute_name` | "[" `element_index` "]")* | |
| 211 | 211 | arg_name: [`identifier` | `digit`+] | |
@@ -308,7 +308,7 @@ non-empty format specification typically modifies the result. | |||
| 308 | 308 | ||
| 309 | 309 | The general form of a *standard format specifier* is: | |
| 310 | 310 | ||
| 311 | - .. productionlist:: | ||
| 311 | + .. productionlist:: format-spec | ||
| 312 | 312 | format_spec: [[`fill`]`align`][`sign`][#][0][`width`][`grouping_option`][.`precision`][`type`] | |
| 313 | 313 | fill: <any character> | |
| 314 | 314 | align: "<" | ">" | "=" | "^" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,8 @@ executed:: | |||
| 44 | 44 | ||
| 45 | 45 | Summarizing: | |
| 46 | 46 | ||
| 47 | - .. productionlist:: | ||
| 47 | + | ||
| 48 | + .. productionlist:: python-grammar | ||
| 48 | 49 | compound_stmt: `if_stmt` | |
| 49 | 50 | : | `while_stmt` | |
| 50 | 51 | : | `for_stmt` | |
@@ -89,7 +90,7 @@ The :keyword:`!if` statement | |||
| 89 | 90 | ||
| 90 | 91 | The :keyword:`if` statement is used for conditional execution: | |
| 91 | 92 | ||
| 92 | - .. productionlist:: | ||
| 93 | + .. productionlist:: python-grammar | ||
| 93 | 94 | if_stmt: "if" `assignment_expression` ":" `suite` | |
| 94 | 95 | : ("elif" `assignment_expression` ":" `suite`)* | |
| 95 | 96 | : ["else" ":" `suite`] | |
@@ -115,7 +116,7 @@ The :keyword:`!while` statement | |||
| 115 | 116 | The :keyword:`while` statement is used for repeated execution as long as an | |
| 116 | 117 | expression is true: | |
| 117 | 118 | ||
| 118 | - .. productionlist:: | ||
| 119 | + .. productionlist:: python-grammar | ||
| 119 | 120 | while_stmt: "while" `assignment_expression` ":" `suite` | |
| 120 | 121 | : ["else" ":" `suite`] | |
| 121 | 122 | ||
@@ -151,7 +152,7 @@ The :keyword:`!for` statement | |||
| 151 | 152 | The :keyword:`for` statement is used to iterate over the elements of a sequence | |
| 152 | 153 | (such as a string, tuple or list) or other iterable object: | |
| 153 | 154 | ||
| 154 | - .. productionlist:: | ||
| 155 | + .. productionlist:: python-grammar | ||
| 155 | 156 | for_stmt: "for" `target_list` "in" `expression_list` ":" `suite` | |
| 156 | 157 | : ["else" ":" `suite`] | |
| 157 | 158 | ||
@@ -234,7 +235,7 @@ The :keyword:`!try` statement | |||
| 234 | 235 | The :keyword:`try` statement specifies exception handlers and/or cleanup code | |
| 235 | 236 | for a group of statements: | |
| 236 | 237 | ||
| 237 | - .. productionlist:: | ||
| 238 | + .. productionlist:: python-grammar | ||
| 238 | 239 | try_stmt: `try1_stmt` | `try2_stmt` | |
| 239 | 240 | try1_stmt: "try" ":" `suite` | |
| 240 | 241 | : ("except" [`expression` ["as" `identifier`]] ":" `suite`)+ | |
@@ -390,7 +391,7 @@ methods defined by a context manager (see section :ref:`context-managers`). | |||
| 390 | 391 | This allows common :keyword:`try`...\ :keyword:`except`...\ :keyword:`finally` | |
| 391 | 392 | usage patterns to be encapsulated for convenient reuse. | |
| 392 | 393 | ||
| 393 | - .. productionlist:: | ||
| 394 | + .. productionlist:: python-grammar | ||
| 394 | 395 | with_stmt: "with" `with_item` ("," `with_item`)* ":" `suite` | |
| 395 | 396 | with_item: `expression` ["as" `target`] | |
| 396 | 397 | ||
@@ -503,7 +504,7 @@ Function definitions | |||
| 503 | 504 | A function definition defines a user-defined function object (see section | |
| 504 | 505 | :ref:`types`): | |
| 505 | 506 | ||
| 506 | - .. productionlist:: | ||
| 507 | + .. productionlist:: python-grammar | ||
| 507 | 508 | funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")" | |
| 508 | 509 | : ["->" `expression`] ":" `suite` | |
| 509 | 510 | decorators: `decorator`+ | |
@@ -670,7 +671,7 @@ Class definitions | |||
| 670 | 671 | ||
| 671 | 672 | A class definition defines a class object (see section :ref:`types`): | |
| 672 | 673 | ||
| 673 | - .. productionlist:: | ||
| 674 | + .. productionlist:: python-grammar | ||
| 674 | 675 | classdef: [`decorators`] "class" `classname` [`inheritance`] ":" `suite` | |
| 675 | 676 | inheritance: "(" [`argument_list`] ")" | |
| 676 | 677 | classname: `identifier` | |
@@ -762,7 +763,7 @@ Coroutines | |||
| 762 | 763 | Coroutine function definition | |
| 763 | 764 | ----------------------------- | |
| 764 | 765 | ||
| 765 | - .. productionlist:: | ||
| 766 | + .. productionlist:: python-grammar | ||
| 766 | 767 | async_funcdef: [`decorators`] "async" "def" `funcname` "(" [`parameter_list`] ")" | |
| 767 | 768 | : ["->" `expression`] ":" `suite` | |
| 768 | 769 | ||
@@ -795,7 +796,7 @@ An example of a coroutine function:: | |||
| 795 | 796 | The :keyword:`!async for` statement | |
| 796 | 797 | ----------------------------------- | |
| 797 | 798 | ||
| 798 | - .. productionlist:: | ||
| 799 | + .. productionlist:: python-grammar | ||
| 799 | 800 | async_for_stmt: "async" `for_stmt` | |
| 800 | 801 | ||
| 801 | 802 | An :term:`asynchronous iterable` is able to call asynchronous code in its | |
@@ -840,7 +841,7 @@ body of a coroutine function. | |||
| 840 | 841 | The :keyword:`!async with` statement | |
| 841 | 842 | ------------------------------------ | |
| 842 | 843 | ||
| 843 | - .. productionlist:: | ||
| 844 | + .. productionlist:: python-grammar | ||
| 844 | 845 | async_with_stmt: "async" `with_stmt` | |
| 845 | 846 | ||
| 846 | 847 | An :term:`asynchronous context manager` is a :term:`context manager` that is | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ This chapter explains the meaning of the elements of expressions in Python. | |||
| 13 | 13 | be used to describe syntax, not lexical analysis. When (one alternative of) a | |
| 14 | 14 | syntax rule has the form | |
| 15 | 15 | ||
| 16 | - .. productionlist:: * | ||
| 16 | + .. productionlist:: python-grammar | ||
| 17 | 17 | name: `othername` | |
| 18 | 18 | ||
| 19 | 19 | and no semantics are given, the semantics of this form of ``name`` are the same | |
@@ -54,7 +54,7 @@ Atoms are the most basic elements of expressions. The simplest atoms are | |||
| 54 | 54 | identifiers or literals. Forms enclosed in parentheses, brackets or braces are | |
| 55 | 55 | also categorized syntactically as atoms. The syntax for atoms is: | |
| 56 | 56 | ||
| 57 | - .. productionlist:: | ||
| 57 | + .. productionlist:: python-grammar | ||
| 58 | 58 | atom: `identifier` | `literal` | `enclosure` | |
| 59 | 59 | enclosure: `parenth_form` | `list_display` | `dict_display` | `set_display` | |
| 60 | 60 | : | `generator_expression` | `yield_atom` | |
@@ -103,7 +103,7 @@ Literals | |||
| 103 | 103 | ||
| 104 | 104 | Python supports string and bytes literals and various numeric literals: | |
| 105 | 105 | ||
| 106 | - .. productionlist:: | ||
| 106 | + .. productionlist:: python-grammar | ||
| 107 | 107 | literal: `stringliteral` | `bytesliteral` | |
| 108 | 108 | : | `integer` | `floatnumber` | `imagnumber` | |
| 109 | 109 | ||
@@ -134,7 +134,7 @@ Parenthesized forms | |||
| 134 | 134 | ||
| 135 | 135 | A parenthesized form is an optional expression list enclosed in parentheses: | |
| 136 | 136 | ||
| 137 | - .. productionlist:: | ||
| 137 | + .. productionlist:: python-grammar | ||
| 138 | 138 | parenth_form: "(" [`starred_expression`] ")" | |
| 139 | 139 | ||
| 140 | 140 | A parenthesized expression list yields whatever that expression list yields: if | |
@@ -177,7 +177,7 @@ called "displays", each of them in two flavors: | |||
| 177 | 177 | ||
| 178 | 178 | Common syntax elements for comprehensions are: | |
| 179 | 179 | ||
| 180 | - .. productionlist:: | ||
| 180 | + .. productionlist:: python-grammar | ||
| 181 | 181 | comprehension: `assignment_expression` `comp_for` | |
| 182 | 182 | comp_for: ["async"] "for" `target_list` "in" `or_test` [`comp_iter`] | |
| 183 | 183 | comp_iter: `comp_for` | `comp_if` | |
@@ -243,7 +243,7 @@ List displays | |||
| 243 | 243 | A list display is a possibly empty series of expressions enclosed in square | |
| 244 | 244 | brackets: | |
| 245 | 245 | ||
| 246 | - .. productionlist:: | ||
| 246 | + .. productionlist:: python-grammar | ||
| 247 | 247 | list_display: "[" [`starred_list` | `comprehension`] "]" | |
| 248 | 248 | ||
| 249 | 249 | A list display yields a new list object, the contents being specified by either | |
@@ -267,7 +267,7 @@ Set displays | |||
| 267 | 267 | A set display is denoted by curly braces and distinguishable from dictionary | |
| 268 | 268 | displays by the lack of colons separating keys and values: | |
| 269 | 269 | ||
| 270 | - .. productionlist:: | ||
| 270 | + .. productionlist:: python-grammar | ||
| 271 | 271 | set_display: "{" (`starred_list` | `comprehension`) "}" | |
| 272 | 272 | ||
| 273 | 273 | A set display yields a new mutable set object, the contents being specified by | |
@@ -296,7 +296,7 @@ Dictionary displays | |||
| 296 | 296 | A dictionary display is a possibly empty series of key/datum pairs enclosed in | |
| 297 | 297 | curly braces: | |
| 298 | 298 | ||
| 299 | - .. productionlist:: | ||
| 299 | + .. productionlist:: python-grammar | ||
| 300 | 300 | dict_display: "{" [`key_datum_list` | `dict_comprehension`] "}" | |
| 301 | 301 | key_datum_list: `key_datum` ("," `key_datum`)* [","] | |
| 302 | 302 | key_datum: `expression` ":" `expression` | "**" `or_expr` | |
@@ -355,7 +355,7 @@ Generator expressions | |||
| 355 | 355 | ||
| 356 | 356 | A generator expression is a compact generator notation in parentheses: | |
| 357 | 357 | ||
| 358 | - .. productionlist:: | ||
| 358 | + .. productionlist:: python-grammar | ||
| 359 | 359 | generator_expression: "(" `expression` `comp_for` ")" | |
| 360 | 360 | ||
| 361 | 361 | A generator expression yields a new generator object. Its syntax is the same as | |
@@ -409,7 +409,7 @@ Yield expressions | |||
| 409 | 409 | pair: yield; expression | |
| 410 | 410 | pair: generator; function | |
| 411 | 411 | ||
| 412 | - .. productionlist:: | ||
| 412 | + .. productionlist:: python-grammar | ||
| 413 | 413 | yield_atom: "(" `yield_expression` ")" | |
| 414 | 414 | yield_expression: "yield" [`expression_list` | "from" `expression`] | |
| 415 | 415 | ||
@@ -746,7 +746,7 @@ Primaries | |||
| 746 | 746 | Primaries represent the most tightly bound operations of the language. Their | |
| 747 | 747 | syntax is: | |
| 748 | 748 | ||
| 749 | - .. productionlist:: | ||
| 749 | + .. productionlist:: python-grammar | ||
| 750 | 750 | primary: `atom` | `attributeref` | `subscription` | `slicing` | `call` | |
| 751 | 751 | ||
| 752 | 752 | ||
@@ -761,7 +761,7 @@ Attribute references | |||
| 761 | 761 | ||
| 762 | 762 | An attribute reference is a primary followed by a period and a name: | |
| 763 | 763 | ||
| 764 | - .. productionlist:: | ||
| 764 | + .. productionlist:: python-grammar | ||
| 765 | 765 | attributeref: `primary` "." `identifier` | |
| 766 | 766 | ||
| 767 | 767 | .. index:: | |
@@ -799,7 +799,7 @@ Subscriptions | |||
| 799 | 799 | A subscription selects an item of a sequence (string, tuple or list) or mapping | |
| 800 | 800 | (dictionary) object: | |
| 801 | 801 | ||
| 802 | - .. productionlist:: | ||
| 802 | + .. productionlist:: python-grammar | ||
| 803 | 803 | subscription: `primary` "[" `expression_list` "]" | |
| 804 | 804 | ||
| 805 | 805 | The primary must evaluate to an object that supports subscription (lists or | |
@@ -855,7 +855,7 @@ A slicing selects a range of items in a sequence object (e.g., a string, tuple | |||
| 855 | 855 | or list). Slicings may be used as expressions or as targets in assignment or | |
| 856 | 856 | :keyword:`del` statements. The syntax for a slicing: | |
| 857 | 857 | ||
| 858 | - .. productionlist:: | ||
| 858 | + .. productionlist:: python-grammar | ||
| 859 | 859 | slicing: `primary` "[" `slice_list` "]" | |
| 860 | 860 | slice_list: `slice_item` ("," `slice_item`)* [","] | |
| 861 | 861 | slice_item: `expression` | `proper_slice` | |
@@ -905,7 +905,7 @@ Calls | |||
| 905 | 905 | A call calls a callable object (e.g., a :term:`function`) with a possibly empty | |
| 906 | 906 | series of :term:`arguments <argument>`: | |
| 907 | 907 | ||
| 908 | - .. productionlist:: | ||
| 908 | + .. productionlist:: python-grammar | ||
| 909 | 909 | call: `primary` "(" [`argument_list` [","] | `comprehension`] ")" | |
| 910 | 910 | argument_list: `positional_arguments` ["," `starred_and_keywords`] | |
| 911 | 911 | : ["," `keywords_arguments`] | |
@@ -1088,7 +1088,7 @@ Await expression | |||
| 1088 | 1088 | Suspend the execution of :term:`coroutine` on an :term:`awaitable` object. | |
| 1089 | 1089 | Can only be used inside a :term:`coroutine function`. | |
| 1090 | 1090 | ||
| 1091 | - .. productionlist:: | ||
| 1091 | + .. productionlist:: python-grammar | ||
| 1092 | 1092 | await_expr: "await" `primary` | |
| 1093 | 1093 | ||
| 1094 | 1094 | .. versionadded:: 3.5 | |
@@ -1106,7 +1106,7 @@ The power operator | |||
| 1106 | 1106 | The power operator binds more tightly than unary operators on its left; it binds | |
| 1107 | 1107 | less tightly than unary operators on its right. The syntax is: | |
| 1108 | 1108 | ||
| 1109 | - .. productionlist:: | ||
| 1109 | + .. productionlist:: python-grammar | ||
| 1110 | 1110 | power: (`await_expr` | `primary`) ["**" `u_expr`] | |
| 1111 | 1111 | ||
| 1112 | 1112 | Thus, in an unparenthesized sequence of power and unary operators, the operators | |
@@ -1139,7 +1139,7 @@ Unary arithmetic and bitwise operations | |||
| 1139 | 1139 | ||
| 1140 | 1140 | All unary arithmetic and bitwise operations have the same priority: | |
| 1141 | 1141 | ||
| 1142 | - .. productionlist:: | ||
| 1142 | + .. productionlist:: python-grammar | ||
| 1143 | 1143 | u_expr: `power` | "-" `u_expr` | "+" `u_expr` | "~" `u_expr` | |
| 1144 | 1144 | ||
| 1145 | 1145 | .. index:: | |
@@ -1183,7 +1183,7 @@ that some of these operations also apply to certain non-numeric types. Apart | |||
| 1183 | 1183 | from the power operator, there are only two levels, one for multiplicative | |
| 1184 | 1184 | operators and one for additive operators: | |
| 1185 | 1185 | ||
| 1186 | - .. productionlist:: | ||
| 1186 | + .. productionlist:: python-grammar | ||
| 1187 | 1187 | m_expr: `u_expr` | `m_expr` "*" `u_expr` | `m_expr` "@" `m_expr` | | |
| 1188 | 1188 | : `m_expr` "//" `u_expr` | `m_expr` "/" `u_expr` | | |
| 1189 | 1189 | : `m_expr` "%" `u_expr` | |
@@ -1279,7 +1279,7 @@ Shifting operations | |||
| 1279 | 1279 | ||
| 1280 | 1280 | The shifting operations have lower priority than the arithmetic operations: | |
| 1281 | 1281 | ||
| 1282 | - .. productionlist:: | ||
| 1282 | + .. productionlist:: python-grammar | ||
| 1283 | 1283 | shift_expr: `a_expr` | `shift_expr` ("<<" | ">>") `a_expr` | |
| 1284 | 1284 | ||
| 1285 | 1285 | These operators accept integers as arguments. They shift the first argument to | |
@@ -1300,7 +1300,7 @@ Binary bitwise operations | |||
| 1300 | 1300 | ||
| 1301 | 1301 | Each of the three bitwise operations has a different priority level: | |
| 1302 | 1302 | ||
| 1303 | - .. productionlist:: | ||
| 1303 | + .. productionlist:: python-grammar | ||
| 1304 | 1304 | and_expr: `shift_expr` | `and_expr` "&" `shift_expr` | |
| 1305 | 1305 | xor_expr: `and_expr` | `xor_expr` "^" `and_expr` | |
| 1306 | 1306 | or_expr: `xor_expr` | `or_expr` "|" `xor_expr` | |
@@ -1349,7 +1349,7 @@ lower than that of any arithmetic, shifting or bitwise operation. Also unlike | |||
| 1349 | 1349 | C, expressions like ``a < b < c`` have the interpretation that is conventional | |
| 1350 | 1350 | in mathematics: | |
| 1351 | 1351 | ||
| 1352 | - .. productionlist:: | ||
| 1352 | + .. productionlist:: python-grammar | ||
| 1353 | 1353 | comparison: `or_expr` (`comp_operator` `or_expr`)* | |
| 1354 | 1354 | comp_operator: "<" | ">" | "==" | ">=" | "<=" | "!=" | |
| 1355 | 1355 | : | "is" ["not"] | ["not"] "in" | |
@@ -1608,7 +1608,7 @@ Boolean operations | |||
| 1608 | 1608 | pair: Conditional; expression | |
| 1609 | 1609 | pair: Boolean; operation | |
| 1610 | 1610 | ||
| 1611 | - .. productionlist:: | ||
| 1611 | + .. productionlist:: python-grammar | ||
| 1612 | 1612 | or_test: `and_test` | `or_test` "or" `and_test` | |
| 1613 | 1613 | and_test: `not_test` | `and_test` "and" `not_test` | |
| 1614 | 1614 | not_test: `comparison` | "not" `not_test` | |
@@ -1647,7 +1647,7 @@ returns a boolean value regardless of the type of its argument | |||
| 1647 | 1647 | Assignment expressions | |
| 1648 | 1648 | ====================== | |
| 1649 | 1649 | ||
| 1650 | - .. productionlist:: | ||
| 1650 | + .. productionlist:: python-grammar | ||
| 1651 | 1651 | assignment_expression: [`identifier` ":="] `expression` | |
| 1652 | 1652 | ||
| 1653 | 1653 | An assignment expression (sometimes also called a "named expression" or | |
@@ -1683,7 +1683,7 @@ Conditional expressions | |||
| 1683 | 1683 | single: if; conditional expression | |
| 1684 | 1684 | single: else; conditional expression | |
| 1685 | 1685 | ||
| 1686 | - .. productionlist:: | ||
| 1686 | + .. productionlist:: python-grammar | ||
| 1687 | 1687 | conditional_expression: `or_test` ["if" `or_test` "else" `expression`] | |
| 1688 | 1688 | expression: `conditional_expression` | `lambda_expr` | |
| 1689 | 1689 | expression_nocond: `or_test` | `lambda_expr_nocond` | |
@@ -1710,7 +1710,7 @@ Lambdas | |||
| 1710 | 1710 | pair: anonymous; function | |
| 1711 | 1711 | single: : (colon); lambda expression | |
| 1712 | 1712 | ||
| 1713 | - .. productionlist:: | ||
| 1713 | + .. productionlist:: python-grammar | ||
| 1714 | 1714 | lambda_expr: "lambda" [`parameter_list`] ":" `expression` | |
| 1715 | 1715 | lambda_expr_nocond: "lambda" [`parameter_list`] ":" `expression_nocond` | |
| 1716 | 1716 | ||
@@ -1737,7 +1737,7 @@ Expression lists | |||
| 1737 | 1737 | pair: expression; list | |
| 1738 | 1738 | single: , (comma); expression list | |
| 1739 | 1739 | ||
| 1740 | - .. productionlist:: | ||
| 1740 | + .. productionlist:: python-grammar | ||
| 1741 | 1741 | expression_list: `expression` ("," `expression`)* [","] | |
| 1742 | 1742 | starred_list: `starred_item` ("," `starred_item`)* [","] | |
| 1743 | 1743 | starred_expression: `expression` | (`starred_item` ",")* [`starred_item`] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,7 +93,7 @@ Notation | |||
| 93 | 93 | The descriptions of lexical analysis and syntax use a modified BNF grammar | |
| 94 | 94 | notation. This uses the following style of definition: | |
| 95 | 95 | ||
| 96 | - .. productionlist:: | ||
| 96 | + .. productionlist:: notation | ||
| 97 | 97 | name: `lc_letter` (`lc_letter` | "_")* | |
| 98 | 98 | lc_letter: "a"..."z" | |
| 99 | 99 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments