[Python-checkins] CVS: python/dist/src/Doc/ref ref2.tex,1.25,1.26 ref5.tex,1.48,1.49 ref6.tex,1.40,1.41 ref7.tex,1.27,1.28 ref8.tex,1.13,1.14
Fred L. Drake
fdrake@users.sourceforge.net
2001年7月06日 15:49:55 -0700
Update of /cvsroot/python/python/dist/src/Doc/ref
In directory usw-pr-cvs1:/tmp/cvs-serv31222/ref
Modified Files:
ref2.tex ref5.tex ref6.tex ref7.tex ref8.tex
Log Message:
Change the grammar productions to use the new productionlist environment;
this supports a hyperlinked version of the grammar that can make tracking
down details and definitions a little easier.
Index: ref2.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** ref2.tex 2001年06月23日 16:26:44 1.25
--- ref2.tex 2001年07月06日 22:49:52 1.26
***************
*** 238,248 ****
\index{name}
! \begin{verbatim}
! identifier: (letter|"_") (letter|digit|"_")*
! letter: lowercase | uppercase
! lowercase: "a"..."z"
! uppercase: "A"..."Z"
! digit: "0"..."9"
! \end{verbatim}
Identifiers are unlimited in length. Case is significant.
--- 238,253 ----
\index{name}
! \begin{productionlist}
! \production{identifier}
! {(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*}
! \production{letter}
! {\token{lowercase} | \token{uppercase}}
! \production{lowercase}
! {"a"..."z"}
! \production{uppercase}
! {"A"..."Z"}
! \production{digit}
! {"0"..."9"}
! \end{productionlist}
Identifiers are unlimited in length. Case is significant.
***************
*** 304,318 ****
\index{string literal}
- \begin{verbatim}
- stringliteral: shortstring | longstring
- shortstring: "'" shortstringitem* "'" | '"' shortstringitem* '"'
- longstring: "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
- shortstringitem: shortstringchar | escapeseq
- longstringitem: longstringchar | escapeseq
- shortstringchar: <any ASCII character except "\" or newline or the quote>
- longstringchar: <any ASCII character except "\">
- escapeseq: "\" <any ASCII character>
- \end{verbatim}
\index{ASCII@\ASCII{}}
\index{triple-quoted string}
--- 309,333 ----
\index{string literal}
\index{ASCII@\ASCII{}}
+ \begin{productionlist}
+ \production{stringliteral}
+ {\token{shortstring} | \token{longstring}}
+ \production{shortstring}
+ {"'" \token{shortstringitem}* "'"
+ | '"' \token{shortstringitem}* '"'}
+ \production{longstring}
+ {"'''" \token{longstringitem}* "'''"
+ | '"""' \token{longstringitem}* '"""'}
+ \production{shortstringitem}
+ {\token{shortstringchar} | \token{escapeseq}}
+ \production{longstringitem}
+ {\token{longstringchar} | \token{escapeseq}}
+ \production{shortstringchar}
+ {<any ASCII character except "\e" or newline or the quote>}
+ \production{longstringchar}
+ {<any ASCII character except "\e">}
+ \production{escapeseq}
+ {"\e" <any ASCII character>}
+ \end{productionlist}
\index{triple-quoted string}
***************
*** 453,466 ****
lexical definitions:
! \begin{verbatim}
! longinteger: integer ("l"|"L")
! integer: decimalinteger | octinteger | hexinteger
! decimalinteger: nonzerodigit digit* | "0"
! octinteger: "0" octdigit+
! hexinteger: "0" ("x"|"X") hexdigit+
! nonzerodigit: "1"..."9"
! octdigit: "0"..."7"
! hexdigit: digit|"a"..."f"|"A"..."F"
! \end{verbatim}
Although both lower case `l' and upper case `L' are allowed as suffix
--- 468,489 ----
lexical definitions:
! \begin{productionlist}
! \production{longinteger}
! {\token{integer} ("l" | "L")}
! \production{integer}
! {\token{decimalinteger} | \token{octinteger} | \token{hexinteger}}
! \production{decimalinteger}
! {\token{nonzerodigit} \token{digit}* | "0"}
! \production{octinteger}
! {"0" \token{octdigit}+}
! \production{hexinteger}
! {"0" ("x" | "X") \token{hexdigit}+}
! \production{nonzerodigit}
! {"1"..."9"}
! \production{octdigit}
! {"0"..."7"}
! \production{hexdigit}
! {\token{digit} | "a"..."f" | "A"..."F"}
! \end{productionlist}
Although both lower case `l' and upper case `L' are allowed as suffix
***************
*** 488,499 ****
definitions:
! \begin{verbatim}
! floatnumber: pointfloat | exponentfloat
! pointfloat: [intpart] fraction | intpart "."
! exponentfloat: (nonzerodigit digit* | pointfloat) exponent
! intpart: nonzerodigit digit* | "0"
! fraction: "." digit+
! exponent: ("e"|"E") ["+"|"-"] digit+
! \end{verbatim}
Note that the integer part of a floating point number cannot look like
--- 511,529 ----
definitions:
! \begin{productionlist}
! \production{floatnumber}
! {\token{pointfloat} | \token{exponentfloat}}
! \production{pointfloat}
! {[\token{intpart}] \token{fraction} | \token{intpart} "."}
! \production{exponentfloat}
! {(\token{nonzerodigit} \token{digit}* | \token{pointfloat})
! \token{exponent}}
! \production{intpart}
! {\token{nonzerodigit} \token{digit}* | "0"}
! \production{fraction}
! {"." \token{digit}+}
! \production{exponent}
! {("e" | "E") ["+" | "-"] \token{digit}+}
! \end{productionlist}
Note that the integer part of a floating point number cannot look like
***************
*** 518,524 ****
Imaginary literals are described by the following lexical definitions:
! \begin{verbatim}
! imagnumber: (floatnumber | intpart) ("j"|"J")
! \end{verbatim}
An imaginary literal yields a complex number with a real part of
--- 548,554 ----
Imaginary literals are described by the following lexical definitions:
! \begin{productionlist}
! \production{imagnumber}{(\token{floatnumber} | \token{intpart}) ("j" | "J")}
! \end{productionlist}
An imaginary literal yields a complex number with a real part of
Index: ref5.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -r1.48 -r1.49
*** ref5.tex 2001年06月23日 06:06:21 1.48
--- ref5.tex 2001年07月06日 22:49:53 1.49
***************
*** 9,15 ****
analysis. When (one alternative of) a syntax rule has the form
! \begin{verbatim}
! name: othername
! \end{verbatim}
and no semantics are given, the semantics of this form of \code{name}
--- 9,15 ----
analysis. When (one alternative of) a syntax rule has the form
! \begin{productionlist}[*]
! \production{name}{\token{othername}}
! \end{productionlist}
and no semantics are given, the semantics of this form of \code{name}
***************
*** 51,58 ****
categorized syntactically as atoms. The syntax for atoms is:
! \begin{verbatim}
! atom: identifier | literal | enclosure
! enclosure: parenth_form|list_display|dict_display|string_conversion
! \end{verbatim}
--- 51,61 ----
categorized syntactically as atoms. The syntax for atoms is:
! \begin{productionlist}
! \production{atom}
! {\token{identifier} | \token{literal} | \token{enclosure}}
! \production{enclosure}
! {\token{parenth_form} | \token{list_display}
! | \token{dict_display} | \token{string_conversion}}
! \end{productionlist}
***************
*** 108,114 ****
Python supports string literals and various numeric literals:
! \begin{verbatim}
! literal: stringliteral | integer | longinteger | floatnumber | imagnumber
! \end{verbatim}
Evaluation of a literal yields an object of the given type (string,
--- 111,120 ----
Python supports string literals and various numeric literals:
! \begin{productionlist}
! \production{literal}
! {\token{stringliteral} | \token{integer}
! | \token{longinteger} | \token{floatnumber}
! | \token{imagnumber}}
! \end{productionlist}
Evaluation of a literal yields an object of the given type (string,
***************
*** 133,139 ****
parentheses:
! \begin{verbatim}
! parenth_form: "(" [expression_list] ")"
! \end{verbatim}
A parenthesized expression list yields whatever that expression list
--- 139,146 ----
parentheses:
! \begin{productionlist}
! \production{parenth_form}
! {"(" [\token{expression_list}] ")"}
! \end{productionlist}
A parenthesized expression list yields whatever that expression list
***************
*** 163,173 ****
square brackets:
! \begin{verbatim}
! list_display: "[" [listmaker] "]"
! listmaker: expression ( list_for | ( "," expression)* [","] )
! list_iter: list_for | list_if
! list_for: "for" expression_list "in" testlist [list_iter]
! list_if: "if" test [list_iter]
! \end{verbatim}
A list display yields a new list object. Its contents are specified
--- 170,187 ----
square brackets:
! \begin{productionlist}
! \production{list_display}
! {"[" [\token{listmaker}] "]"}
! \production{listmaker}
! {\token{expression} ( \token{list_for}
! | ( "," \token{expression})* [","] )}
! \production{list_iter}
! {\token{list_for} | \token{list_if}}
! \production{list_for}
! {"for" \token{expression_list} "in" \token{testlist}
! [\token{list_iter}]}
! \production{list_if}
! {"if" \token{test} [\token{list_iter}]}
! \end{productionlist}
A list display yields a new list object. Its contents are specified
***************
*** 197,205 ****
\index{key/datum pair}
! \begin{verbatim}
! dict_display: "{" [key_datum_list] "}"
! key_datum_list: key_datum ("," key_datum)* [","]
! key_datum: expression ":" expression
! \end{verbatim}
A dictionary display yields a new dictionary object.
--- 211,222 ----
\index{key/datum pair}
! \begin{productionlist}
! \production{dict_display}
! {"{" [\token{key_datum_list}] "}"}
! \production{key_datum_list}
! {\token{key_datum} ("," \token{key_datum})* [","]}
! \production{key_datum}
! {\token{expression} ":" \token{expression}}
! \end{productionlist}
A dictionary display yields a new dictionary object.
***************
*** 227,233 ****
backward) quotes:
! \begin{verbatim}
! string_conversion: "`" expression_list "`"
! \end{verbatim}
A string conversion evaluates the contained expression list and
--- 244,251 ----
backward) quotes:
! \begin{productionlist}
! \production{string_conversion}
! {"`" \token{expression_list} "`"}
! \end{productionlist}
A string conversion evaluates the contained expression list and
***************
*** 264,270 ****
Their syntax is:
! \begin{verbatim}
! primary: atom | attributeref | subscription | slicing | call
! \end{verbatim}
--- 282,290 ----
Their syntax is:
! \begin{productionlist}
! \production{primary}
! {\token{atom} | \token{attributeref}
! | \token{subscription} | \token{slicing} | \token{call}}
! \end{productionlist}
***************
*** 274,280 ****
An attribute reference is a primary followed by a period and a name:
! \begin{verbatim}
! attributeref: primary "." identifier
! \end{verbatim}
The primary must evaluate to an object of a type that supports
--- 294,301 ----
An attribute reference is a primary followed by a period and a name:
! \begin{productionlist}
! \production{attributeref}
! {\token{primary} "." \token{identifier}}
! \end{productionlist}
The primary must evaluate to an object of a type that supports
***************
*** 303,309 ****
\indexii{sequence}{item}
! \begin{verbatim}
! subscription: primary "[" expression_list "]"
! \end{verbatim}
The primary must evaluate to an object of a sequence or mapping type.
--- 324,331 ----
\indexii{sequence}{item}
! \begin{productionlist}
! \production{subscription}
! {\token{primary} "[" \token{expression_list} "]"}
! \end{productionlist}
The primary must evaluate to an object of a sequence or mapping type.
***************
*** 340,357 ****
\obindex{list}
! \begin{verbatim}
! slicing: simple_slicing | extended_slicing
! simple_slicing: primary "[" short_slice "]"
! extended_slicing: primary "[" slice_list "]"
! slice_list: slice_item ("," slice_item)* [","]
! slice_item: expression | proper_slice | ellipsis
! proper_slice: short_slice | long_slice
! short_slice: [lower_bound] ":" [upper_bound]
! long_slice: short_slice ":" [stride]
! lower_bound: expression
! upper_bound: expression
! stride: expression
! ellipsis: "..."
! \end{verbatim}
There is ambiguity in the formal syntax here: anything that looks like
--- 362,391 ----
\obindex{list}
! \begin{productionlist}
! \production{slicing}
! {\token{simple_slicing} | \token{extended_slicing}}
! \production{simple_slicing}
! {\token{primary} "[" \token{short_slice} "]"}
! \production{extended_slicing}
! {\token{primary} "[" \token{slice_list} "]" }
! \production{slice_list}
! {\token{slice_item} ("," \token{slice_item})* [","]}
! \production{slice_item}
! {\token{expression} | \token{proper_slice} | \token{ellipsis}}
! \production{proper_slice}
! {\token{short_slice} | \token{long_slice}}
! \production{short_slice}
! {[\token{lower_bound}] ":" [\token{upper_bound}]}
! \production{long_slice}
! {\token{short_slice} ":" [\token{stride}]}
! \production{lower_bound}
! {\token{expression}}
! \production{upper_bound}
! {\token{expression}}
! \production{stride}
! {\token{expression}}
! \production{ellipsis}
! {"..."}
! \end{productionlist}
There is ambiguity in the formal syntax here: anything that looks like
***************
*** 402,413 ****
\obindex{callable}
! \begin{verbatim}
! call: primary "(" [argument_list [","]] ")"
! argument_list: positional_arguments ["," keyword_arguments]
! | keyword_arguments
! positional_arguments: expression ("," expression)*
! keyword_arguments: keyword_item ("," keyword_item)*
! keyword_item: identifier "=" expression
! \end{verbatim}
A trailing comma may be present after an argument list but does not
--- 436,452 ----
\obindex{callable}
! \begin{productionlist}
! \production{call}
! {\token{primary} "(" [\token{argument_list} [","]] ")"}
! \production{argument_list}
! {\token{positional_arguments} ["," \token{keyword_arguments}]
! | \token{keyword_arguments}}
! \production{positional_arguments}
! {\token{expression} ("," \token{expression})*}
! \production{keyword_arguments}
! {\token{keyword_item} ("," \token{keyword_item})*}
! \production{keyword_item}
! {\token{identifier} "=" \token{expression}}
! \end{productionlist}
A trailing comma may be present after an argument list but does not
***************
*** 522,528 ****
syntax is:
! \begin{verbatim}
! power: primary ["**" u_expr]
! \end{verbatim}
Thus, in an unparenthesized sequence of power and unary operators, the
--- 561,568 ----
syntax is:
! \begin{productionlist}
! \production{power}
! {\token{primary} ["**" \token{u_expr}]}
! \end{productionlist}
Thus, in an unparenthesized sequence of power and unary operators, the
***************
*** 546,552 ****
All unary arithmetic (and bit-wise) operations have the same priority:
! \begin{verbatim}
! u_expr: power | "-" u_expr | "+" u_expr | "~" u_expr
! \end{verbatim}
The unary \code{-} (minus) operator yields the negation of its
--- 586,594 ----
All unary arithmetic (and bit-wise) operations have the same priority:
! \begin{productionlist}
! \production{u_expr}
! {\token{power} | "-" \token{u_expr}
! | "+" \token{u_expr} | "~" \token{u_expr}}
! \end{productionlist}
The unary \code{-} (minus) operator yields the negation of its
***************
*** 579,587 ****
operators:
! \begin{verbatim}
! m_expr: u_expr | m_expr "*" u_expr
! | m_expr "/" u_expr | m_expr "%" u_expr
! a_expr: m_expr | aexpr "+" m_expr | aexpr "-" m_expr
! \end{verbatim}
The \code{*} (multiplication) operator yields the product of its
--- 621,633 ----
operators:
! \begin{productionlist}
! \production{m_expr}
! {\token{u_expr} | \token{m_expr} "*" \token{u_expr}
! | \token{m_expr} "/" \token{u_expr}
! | \token{m_expr} "\%" \token{u_expr}}
! \production{a_expr}
! {\token{m_expr} | \token{aexpr} "+" \token{m_expr}
! \token{aexpr} "-" \token{m_expr}}
! \end{productionlist}
The \code{*} (multiplication) operator yields the product of its
***************
*** 647,653 ****
operations:
! \begin{verbatim}
! shift_expr: a_expr | shift_expr ( "<<" | ">>" ) a_expr
! \end{verbatim}
These operators accept plain or long integers as arguments. The
--- 693,701 ----
operations:
! \begin{productionlist}
! \production{shift_expr}
! {\token{a_expr}
! | \token{shift_expr} ( "<<" | ">>" ) \token{a_expr}}
! \end{productionlist}
These operators accept plain or long integers as arguments. The
***************
*** 671,679 ****
Each of the three bitwise operations has a different priority level:
! \begin{verbatim}
! and_expr: shift_expr | and_expr "&" shift_expr
! xor_expr: and_expr | xor_expr "^" and_expr
! or_expr: xor_expr | or_expr "|" xor_expr
! \end{verbatim}
The \code{\&} operator yields the bitwise AND of its arguments, which
--- 719,730 ----
Each of the three bitwise operations has a different priority level:
! \begin{productionlist}
! \production{and_expr}
! {\token{shift_expr} | \token{and_expr} "\&" \token{shift_expr}}
! \production{xor_expr}
! {\token{and_expr} | \token{xor_expr} "\textasciicircum" \token{and_expr}}
! \production{or_expr}
! {\token{xor_expr} | \token{or_expr} "|" \token{xor_expr}}
! \end{productionlist}
The \code{\&} operator yields the bitwise AND of its arguments, which
***************
*** 704,711 ****
\indexii{C}{language}
! \begin{verbatim}
! comparison: or_expr (comp_operator or_expr)*
! comp_operator: "<"|">"|"=="|">="|"<="|"<>"|"!="|"is" ["not"]|["not"] "in"
! \end{verbatim}
Comparisons yield integer values: \code{1} for true, \code{0} for false.
--- 755,765 ----
\indexii{C}{language}
! \begin{productionlist}
! \production{comparison}
! {\token{or_expr} ( \token{comp_operator} \token{or_expr} )*}
! \production{comp_operator}
! {"<" | ">" | "==" | ">=" | "<=" | "<>" | "!="
! | "is" ["not"] | ["not"] "in"}
! \end{productionlist}
Comparisons yield integer values: \code{1} for true, \code{0} for false.
***************
*** 831,841 ****
Boolean operations have the lowest priority of all Python operations:
! \begin{verbatim}
! expression: or_test | lambda_form
! or_test: and_test | or_test "or" and_test
! and_test: not_test | and_test "and" not_test
! not_test: comparison | "not" not_test
! lambda_form: "lambda" [parameter_list]: expression
! \end{verbatim}
In the context of Boolean operations, and also when expressions are
--- 885,900 ----
Boolean operations have the lowest priority of all Python operations:
! \begin{productionlist}
! \production{expression}
! {\token{or_test} | \token{lambda_form}}
! \production{or_test}
! {\token{and_test} | \token{or_test} "or" \token{and_test}}
! \production{and_test}
! {\token{not_test} | \token{and_test} "and" \token{not_test}}
! \production{not_test}
! {\token{comparison} | "not" \token{not_test}}
! \production{lambda_form}
! {"lambda" [\token{parameter_list}]: \token{expression}}
! \end{productionlist}
In the context of Boolean operations, and also when expressions are
***************
*** 915,921 ****
\indexii{expression}{list}
! \begin{verbatim}
! expression_list: expression ("," expression)* [","]
! \end{verbatim}
An expression list containing at least one comma yields a
--- 974,981 ----
\indexii{expression}{list}
! \begin{productionlist}
! \production{expression_list}
! {\token{expression} ( "," \token{expression} )* [","]}
! \end{productionlist}
An expression list containing at least one comma yields a
Index: ref6.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -r1.40 -r1.41
*** ref6.tex 2001年06月23日 06:16:52 1.40
--- ref6.tex 2001年07月06日 22:49:53 1.41
***************
*** 6,25 ****
by semicolons. The syntax for simple statements is:
! \begin{verbatim}
! simple_stmt: expression_stmt
! | assert_stmt
! | assignment_stmt
! | augmented_assignment_stmt
! | pass_stmt
! | del_stmt
! | print_stmt
! | return_stmt
! | raise_stmt
! | break_stmt
! | continue_stmt
! | import_stmt
! | global_stmt
! | exec_stmt
! \end{verbatim}
--- 6,26 ----
by semicolons. The syntax for simple statements is:
! \begin{productionlist}
! \production{simple_stmt}
! {\token{expression_stmt}
! | \token{assert_stmt}
! | \token{assignment_stmt}
! | \token{augmented_assignment_stmt}
! | \token{pass_stmt}
! | \token{del_stmt}
! | \token{print_stmt}
! | \token{return_stmt}
! | \token{raise_stmt}
! | \token{break_stmt}
! | \token{continue_stmt}
! | \token{import_stmt}
! | \token{global_stmt}
! | \token{exec_stmt}}
! \end{productionlist}
***************
*** 33,39 ****
occasionally useful. The syntax for an expression statement is:
! \begin{verbatim}
! expression_stmt: expression_list
! \end{verbatim}
An expression statement evaluates the expression list (which may be a
--- 34,41 ----
occasionally useful. The syntax for an expression statement is:
! \begin{productionlist}
! \production{expression_stmt}
! {\token{expression_list}}
! \end{productionlist}
An expression statement evaluates the expression list (which may be a
***************
*** 60,66 ****
debugging assertions\indexii{debugging}{assertions} into a program:
! \begin{verbatim}
! assert_statement: "assert" expression ["," expression]
! \end{verbatim}
The simple form, \samp{assert expression}, is equivalent to
--- 62,69 ----
debugging assertions\indexii{debugging}{assertions} into a program:
! \begin{productionlist}
! \production{assert_statement}
! {"assert" \token{expression} ["," \token{expression}]}
! \end{productionlist}
The simple form, \samp{assert expression}, is equivalent to
***************
*** 103,112 ****
\indexii{attribute}{assignment}
! \begin{verbatim}
! assignment_stmt: (target_list "=")+ expression_list
! target_list: target ("," target)* [","]
! target: identifier | "(" target_list ")" | "[" target_list "]"
! | attributeref | subscription | slicing
! \end{verbatim}
(See section \ref{primaries} for the syntax definitions for the last
--- 106,122 ----
\indexii{attribute}{assignment}
! \begin{productionlist}
! \production{assignment_stmt}
! {(\token{target_list} "=")+ \token{expression_list}}
! \production{target_list}
! {\token{target} ("," \token{target})* [","]}
! \production{target}
! {\token{identifier}
! | "(" \token{target_list} ")"
! | "[" \token{target_list} "]"
! | \token{attributeref}
! | \token{subscription}
! | \token{slicing}}
! \end{productionlist}
(See section \ref{primaries} for the syntax definitions for the last
***************
*** 261,271 ****
\index{statement!assignment, augmented}
! \begin{verbatim}
! augmented_assignment_stmt: target augop expression_list
! augop: "+=" | "-=" | "*=" | "/=" | "%=" | "**="
! | ">>=" | "<<=" | "&=" | "^=" | "|="
! target: identifier | "(" target_list ")" | "[" target_list "]"
! | attributeref | subscription | slicing
! \end{verbatim}
(See section \ref{primaries} for the syntax definitions for the last
--- 271,288 ----
\index{statement!assignment, augmented}
! \begin{productionlist}
! \production{augmented_assignment_stmt}
! {\token{target} \token{augop} \token{expression_list}}
! \production{augop}
! {"+=" | "-=" | "*=" | "/=" | "\%=" | "**="
! | ">>=" | "<<=" | "\&=" | "\textasciicircum=" | "|="}
! \production{target}
! {\token{identifier}
! | "(" \token{target_list} ")"
! | "[" \token{target_list} "]"
! | \token{attributeref}
! | \token{subscription}
! | \token{slicing}}
! \end{productionlist}
(See section \ref{primaries} for the syntax definitions for the last
***************
*** 295,301 ****
\stindex{pass}
! \begin{verbatim}
! pass_stmt: "pass"
! \end{verbatim}
\keyword{pass} is a null operation --- when it is executed, nothing
--- 312,319 ----
\stindex{pass}
! \begin{productionlist}
! \production{pass_stmt}
! {"pass"}
! \end{productionlist}
\keyword{pass} is a null operation --- when it is executed, nothing
***************
*** 314,320 ****
\stindex{del}
! \begin{verbatim}
! del_stmt: "del" target_list
! \end{verbatim}
Deletion is recursively defined very similar to the way assignment is
--- 332,339 ----
\stindex{del}
! \begin{productionlist}
! \production{del_stmt}
! {"del" \token{target_list}}
! \end{productionlist}
Deletion is recursively defined very similar to the way assignment is
***************
*** 343,349 ****
\stindex{print}
! \begin{verbatim}
! print_stmt: "print" [ expression ("," expression)* [","] ]
! \end{verbatim}
\keyword{print} evaluates each expression in turn and writes the
--- 362,371 ----
\stindex{print}
! \begin{productionlist}
! \production{print_stmt}
! {"print" ( \optional{\token{expression} ("," \token{expression})* \optional{","}}
! | ">\code{>}" \token{expression}
! \optional{("," \token{expression})+ \optional{","}})}
! \end{productionlist}
\keyword{print} evaluates each expression in turn and writes the
***************
*** 376,387 ****
\withsubitem{(in module sys)}{\ttindex{stdout}}
\exindex{RuntimeError}
-
- \keyword{print} also has an extended form, defined as
- \index{extended print statement}
! \begin{verbatim}
! print_stmt: "print" ">>" expression [ ("," expression)+ [","] ]
! \end{verbatim}
!
In this form, the first expression after the \code{>}\code{>} must
evaluate to a ``file-like'' object, specifically an object that has a
--- 398,405 ----
\withsubitem{(in module sys)}{\ttindex{stdout}}
\exindex{RuntimeError}
! \keyword{print} also has an extended\index{extended print statement}
! form, defined by the second portion of the syntax described above.
! This form is sometimes referred to as ``\keyword{print} chevron.''
In this form, the first expression after the \code{>}\code{>} must
evaluate to a ``file-like'' object, specifically an object that has a
***************
*** 395,401 ****
\stindex{return}
! \begin{verbatim}
! return_stmt: "return" [expression_list]
! \end{verbatim}
\keyword{return} may only occur syntactically nested in a function
--- 413,420 ----
\stindex{return}
! \begin{productionlist}
! \production{return_stmt}
! {"return" [\token{expression_list}]}
! \end{productionlist}
\keyword{return} may only occur syntactically nested in a function
***************
*** 419,425 ****
\stindex{raise}
! \begin{verbatim}
! raise_stmt: "raise" [expression ["," expression ["," expression]]]
! \end{verbatim}
If no expressions are present, \keyword{raise} re-raises the last
--- 438,446 ----
\stindex{raise}
! \begin{productionlist}
! \production{raise_stmt}
! {"raise" [\token{expression} ["," \token{expression}
! ["," \token{expression}]]]}
! \end{productionlist}
If no expressions are present, \keyword{raise} re-raises the last
***************
*** 460,466 ****
\stindex{break}
! \begin{verbatim}
! break_stmt: "break"
! \end{verbatim}
\keyword{break} may only occur syntactically nested in a \keyword{for}
--- 481,488 ----
\stindex{break}
! \begin{productionlist}
! \production{break_stmt}
! {"break"}
! \end{productionlist}
\keyword{break} may only occur syntactically nested in a \keyword{for}
***************
*** 488,494 ****
\stindex{continue}
! \begin{verbatim}
! continue_stmt: "continue"
! \end{verbatim}
\keyword{continue} may only occur syntactically nested in a \keyword{for} or
--- 510,517 ----
\stindex{continue}
! \begin{productionlist}
! \production{continue_stmt}
! {"continue"}
! \end{productionlist}
\keyword{continue} may only occur syntactically nested in a \keyword{for} or
***************
*** 508,518 ****
\stindex{import}
! \begin{verbatim}
! import_stmt: "import" module ["as" name] ("," module ["as" name] )*
! | "from" module "import" identifier ["as" name]
! ("," identifier ["as" name] )*
! | "from" module "import" "*"
! module: (identifier ".")* identifier
! \end{verbatim}
Import statements are executed in two steps: (1) find a module, and
--- 531,545 ----
\stindex{import}
! \begin{productionlist}
! \production{import_stmt}
! {"import" \token{module} ["as" \token{name}]
! ( "," \token{module} ["as" \token{name}] )*
! | "from" \token{module} "import" \token{identifier}
! ["as" \token{name}]
! ( "," \token{identifier} ["as" \token{name}] )*
! | "from" \token{module} "import" "*"}
! \production{module}
! {(\token{identifier} ".")* \token{identifier}}
! \end{productionlist}
Import statements are executed in two steps: (1) find a module, and
***************
*** 609,615 ****
\stindex{global}
! \begin{verbatim}
! global_stmt: "global" identifier ("," identifier)*
! \end{verbatim}
The \keyword{global} statement is a declaration which holds for the
--- 636,643 ----
\stindex{global}
! \begin{productionlist}
! \production{global_stmt}
! {"global" \token{identifier} ("," \token{identifier})*}
! \end{productionlist}
The \keyword{global} statement is a declaration which holds for the
***************
*** 650,656 ****
\stindex{exec}
! \begin{verbatim}
! exec_stmt: "exec" expression ["in" expression ["," expression]]
! \end{verbatim}
This statement supports dynamic execution of Python code. The first
--- 678,686 ----
\stindex{exec}
! \begin{productionlist}
! \production{exec_stmt}
! {"exec" \token{expression}
! ["in" \token{expression} ["," \token{expression}]]}
! \end{productionlist}
This statement supports dynamic execution of Python code. The first
Index: ref7.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** ref7.tex 2001年06月23日 06:06:52 1.27
--- ref7.tex 2001年07月06日 22:49:53 1.28
***************
*** 41,51 ****
Summarizing:
! \begin{verbatim}
! compound_stmt: if_stmt | while_stmt | for_stmt
! | try_stmt | funcdef | classdef
! suite: stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT
! statement: stmt_list NEWLINE | compound_stmt
! stmt_list: simple_stmt (";" simple_stmt)* [";"]
! \end{verbatim}
Note that statements always end in a
--- 41,56 ----
Summarizing:
! \begin{productionlist}
! \production{compound_stmt}
! {\token{if_stmt} | \token{while_stmt} | \token{for_stmt}
! | \token{try_stmt} | \token{funcdef} | \token{classdef}}
! \production{suite}
! {\token{stmt_list} NEWLINE
! | NEWLINE INDENT \token{statement}+ DEDENT}
! \production{statement}
! {\token{stmt_list} NEWLINE | \token{compound_stmt}}
! \production{stmt_list}
! {\token{simple_stmt} (";" \token{simple_stmt})* [";"]}
! \end{productionlist}
Note that statements always end in a
***************
*** 67,75 ****
The \keyword{if} statement is used for conditional execution:
! \begin{verbatim}
! if_stmt: "if" expression ":" suite
! ("elif" expression ":" suite)*
! ["else" ":" suite]
! \end{verbatim}
It selects exactly one of the suites by evaluating the expressions one
--- 72,81 ----
The \keyword{if} statement is used for conditional execution:
! \begin{productionlist}
! \production{if_stmt}
! {"if" \token{expression} ":" \token{suite}
! ( "elif" \token{expression} ":" \token{suite} )*
! ["else" ":" \token{suite}]}
! \end{productionlist}
It selects exactly one of the suites by evaluating the expressions one
***************
*** 90,97 ****
as an expression is true:
! \begin{verbatim}
! while_stmt: "while" expression ":" suite
! ["else" ":" suite]
! \end{verbatim}
This repeatedly tests the expression and, if it is true, executes the
--- 96,104 ----
as an expression is true:
! \begin{productionlist}
! \production{while_stmt}
! {"while" \token{expression} ":" \token{suite}
! ["else" ":" \token{suite}]}
! \end{productionlist}
This repeatedly tests the expression and, if it is true, executes the
***************
*** 117,124 ****
\obindex{sequence}
! \begin{verbatim}
! for_stmt: "for" target_list "in" expression_list ":" suite
! ["else" ":" suite]
! \end{verbatim}
The expression list is evaluated once; it should yield a sequence. The
--- 124,133 ----
\obindex{sequence}
! \begin{productionlist}
! \production{for_stmt}
! {"for" \token{target_list} "in" \token{expression_list}
! ":" \token{suite}
! ["else" ":" \token{suite}]}
! \end{productionlist}
The expression list is evaluated once; it should yield a sequence. The
***************
*** 180,191 ****
code for a group of statements:
! \begin{verbatim}
! try_stmt: try_exc_stmt | try_fin_stmt
! try_exc_stmt: "try" ":" suite
! ("except" [expression ["," target]] ":" suite)+
! ["else" ":" suite]
! try_fin_stmt: "try" ":" suite
! "finally" ":" suite
! \end{verbatim}
There are two forms of \keyword{try} statement:
--- 189,204 ----
code for a group of statements:
! \begin{productionlist}
! \production{try_stmt}
! {\token{try_exc_stmt} | \token{try_fin_stmt}}
! \production{try_exc_stmt}
! {"try" ":" \token{suite}
! ("except" [\token{expression} ["," \token{target}]] ":"
! \token{suite})+
! ["else" ":" \token{suite}]}
! \production{try_fin_stmt}
! {"try" ":" \token{suite}
! "finally" ":" \token{suite}}
! \end{productionlist}
There are two forms of \keyword{try} statement:
***************
*** 292,305 ****
\obindex{function}
! \begin{verbatim}
! funcdef: "def" funcname "(" [parameter_list] ")" ":" suite
! parameter_list: (defparameter ",")* ("*" identifier [, "**" identifier]
! | "**" identifier
! | defparameter [","])
! defparameter: parameter ["=" expression]
! sublist: parameter ("," parameter)* [","]
! parameter: identifier | "(" sublist ")"
! funcname: identifier
! \end{verbatim}
A function definition is an executable statement. Its execution binds
--- 305,326 ----
\obindex{function}
! \begin{productionlist}
! \production{funcdef}
! {"def" \token{funcname} "(" [\token{parameter_list}] ")"
! ":" \token{suite}}
! \production{parameter_list}
! {(\token{defparameter} ",")*
! ("*" \token{identifier} [, "**" \token{identifier}]
! | "**" \token{identifier}
! | \token{defparameter} [","])}
! \production{defparameter}
! {\token{parameter} ["=" \token{expression}]}
! \production{sublist}
! {\token{parameter} ("," \token{parameter})* [","]}
! \production{parameter}
! {\token{identifier} | "(" \token{sublist} ")"}
! \production{funcname}
! {\token{identifier}}
! \end{productionlist}
A function definition is an executable statement. Its execution binds
***************
*** 377,385 ****
\obindex{class}
! \begin{verbatim}
! classdef: "class" classname [inheritance] ":" suite
! inheritance: "(" [expression_list] ")"
! classname: identifier
! \end{verbatim}
A class definition is an executable statement. It first evaluates the
--- 398,410 ----
\obindex{class}
! \begin{productionlist}
! \production{classdef}
! {"class" \token{classname} [\token{inheritance}] ":"
! \token{suite}}
! \production{inheritance}
! {"(" [\token{expression_list}] ")"}
! \production{classname}
! {\token{identifier}}
! \end{productionlist}
A class definition is an executable statement. It first evaluates the
Index: ref8.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref8.tex,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** ref8.tex 2001年06月23日 05:27:20 1.13
--- ref8.tex 2001年07月06日 22:49:53 1.14
***************
*** 50,56 ****
All input read from non-interactive files has the same form:
! \begin{verbatim}
! file_input: (NEWLINE | statement)*
! \end{verbatim}
This syntax is used in the following situations:
--- 50,57 ----
All input read from non-interactive files has the same form:
! \begin{productionlist}
! \production{file_input}
! {(NEWLINE | \token{statement})*}
! \end{productionlist}
This syntax is used in the following situations:
***************
*** 71,77 ****
Input in interactive mode is parsed using the following grammar:
! \begin{verbatim}
! interactive_input: [stmt_list] NEWLINE | compound_stmt NEWLINE
! \end{verbatim}
Note that a (top-level) compound statement must be followed by a blank
--- 72,79 ----
Input in interactive mode is parsed using the following grammar:
! \begin{productionlist}
! \production{interactive_input}
! {[\token{stmt_list}] NEWLINE | \token{compound_stmt} NEWLINE}
! \end{productionlist}
Note that a (top-level) compound statement must be followed by a blank
***************
*** 88,101 ****
\bifuncindex{eval}
! \begin{verbatim}
! eval_input: expression_list NEWLINE*
! \end{verbatim}
The input line read by \function{input()} must have the following form:
\bifuncindex{input}
! \begin{verbatim}
! input_input: expression_list NEWLINE
! \end{verbatim}
Note: to read `raw' input line without interpretation, you can use the
--- 90,105 ----
\bifuncindex{eval}
! \begin{productionlist}
! \production{eval_input}
! {\token{expression_list} NEWLINE*}
! \end{productionlist}
The input line read by \function{input()} must have the following form:
\bifuncindex{input}
! \begin{productionlist}
! \production{input_input}
! {\token{expression_list} NEWLINE}
! \end{productionlist}
Note: to read `raw' input line without interpretation, you can use the