mirror of
https://github.com/python/cpython.git
synced 2025-11-13 15:40:05 +00:00
First round of corrections (lexer only).
This commit is contained in:
parent
01ebbb80ab
commit
4fc43bc377
2 changed files with 272 additions and 254 deletions
263
Doc/ref.tex
263
Doc/ref.tex
|
|
@ -42,9 +42,8 @@ and MS-DOS.
|
||||||
This reference manual describes the syntax and ``core semantics'' of
|
This reference manual describes the syntax and ``core semantics'' of
|
||||||
the language. It is terse, but exact and complete. The semantics of
|
the language. It is terse, but exact and complete. The semantics of
|
||||||
non-essential built-in object types and of the built-in functions and
|
non-essential built-in object types and of the built-in functions and
|
||||||
modules are described in the {\em Library Reference} document. For an
|
modules are described in the {\em Python Library Reference}. For an
|
||||||
informal introduction to the language, see the {\em Tutorial}
|
informal introduction to the language, see the {\em Python Tutorial}.
|
||||||
document.
|
|
||||||
|
|
||||||
\end{abstract}
|
\end{abstract}
|
||||||
|
|
||||||
|
|
@ -63,132 +62,119 @@ It is not intended as a tutorial.
|
||||||
|
|
||||||
\chapter{Lexical analysis}
|
\chapter{Lexical analysis}
|
||||||
|
|
||||||
A Python program is read by a {\em parser}.
|
A Python program is read by a {\em parser}. Input to the parser is a
|
||||||
Input to the parser is a stream of {\em tokens}, generated
|
stream of {\em tokens}, generated by the {\em lexical analyzer}. This
|
||||||
by the {\em lexical analyzer}.
|
chapter describes how the lexical analyzer breaks a file into tokens.
|
||||||
|
|
||||||
\section{Line structure}
|
\section{Line structure}
|
||||||
|
|
||||||
A Python program is divided in a number of logical lines.
|
A Python program is divided in a number of logical lines. Statements
|
||||||
Statements may not straddle logical line boundaries except where
|
do not straddle logical line boundaries except where explicitly
|
||||||
explicitly allowed by the syntax.
|
indicated by the syntax (i.e., for compound statements). To this
|
||||||
To this purpose, the end of a logical line
|
purpose, the end of a logical line is represented by the token
|
||||||
is represented by the token NEWLINE.
|
NEWLINE.
|
||||||
|
|
||||||
\subsection{Comments}
|
\subsection{Comments}
|
||||||
|
|
||||||
A comment starts with a hash character (\verb/#/) and ends at the end
|
A comment starts with a hash character (\verb\#\) that is not part of
|
||||||
of the physical line. Comments are ignored by the syntax.
|
a string literal, and ends at the end of the physical line. Comments
|
||||||
A hash character in a string literal does not start a comment.
|
are ignored by the syntax.
|
||||||
|
|
||||||
\subsection{Line joining}
|
\subsection{Line joining}
|
||||||
|
|
||||||
Physical lines may be joined into logical lines using backslash
|
Two or more physical lines may be joined into logical lines using
|
||||||
characters (\verb/\/), as follows.
|
backslash characters (\verb/\/), as follows: When physical line ends
|
||||||
If a physical line ends in a backslash that is not part of a string
|
in a backslash that is not part of a string literal or comment, it is
|
||||||
literal or comment, it is joined with
|
joined with the following forming a single logical line, deleting the
|
||||||
the following forming a single logical line, deleting the backslash
|
backslash and the following end-of-line character.
|
||||||
and the following end-of-line character. More than two physical
|
|
||||||
lines may be joined together in this way.
|
|
||||||
|
|
||||||
\subsection{Blank lines}
|
\subsection{Blank lines}
|
||||||
|
|
||||||
A physical line that is not the continuation of the previous line
|
A logical line that contains only spaces, tabs, and possibly a
|
||||||
and contains only spaces, tabs and possibly a comment, is ignored
|
comment, is ignored (i.e., no NEWLINE token is generated), except that
|
||||||
(i.e., no NEWLINE token is generated),
|
during interactive input of statements, an entirely blank logical line
|
||||||
except that during interactive input of statements, an empty
|
terminates a multi-line statement.
|
||||||
physical line terminates a multi-line statement.
|
|
||||||
|
|
||||||
\subsection{Indentation}
|
\subsection{Indentation}
|
||||||
|
|
||||||
Spaces and tabs at the beginning of a line are used to compute
|
Spaces and tabs at the beginning of a logical line are used to compute
|
||||||
the indentation level of the line, which in turn is used to determine
|
the indentation level of the line, which in turn is used to determine
|
||||||
the grouping of statements.
|
the grouping of statements.
|
||||||
|
|
||||||
First, each tab is replaced by one to eight spaces such that the column number
|
First, each tab is replaced by one to eight spaces such that the total
|
||||||
of the next character is a multiple of eight (counting from zero).
|
number of spaces up to that point is a multiple of eight. The total
|
||||||
The column number of the first non-space character then defines the
|
number of spaces preceding the first non-blank character then
|
||||||
line's indentation.
|
determines the line's indentation. Indentation cannot be split over
|
||||||
Indentation cannot be split over multiple physical lines using
|
multiple physical lines using backslashes.
|
||||||
backslashes.
|
|
||||||
|
|
||||||
The indentation levels of consecutive lines are used to generate
|
The indentation levels of consecutive lines are used to generate
|
||||||
INDENT and DEDENT tokens, using a stack, as follows.
|
INDENT and DEDENT tokens, using a stack, as follows.
|
||||||
|
|
||||||
Before the first line of the file is read, a single zero is pushed on
|
Before the first line of the file is read, a single zero is pushed on
|
||||||
the stack; this will never be popped off again. The numbers pushed
|
the stack; this will never be popped off again. The numbers pushed on
|
||||||
on the stack will always be strictly increasing from bottom to top.
|
the stack will always be strictly increasing from bottom to top. At
|
||||||
At the beginning of each logical line, the line's indentation level
|
the beginning of each logical line, the line's indentation level is
|
||||||
is compared to the top of the stack.
|
compared to the top of the stack. If it is equal, nothing happens.
|
||||||
If it is equal, nothing happens.
|
If it larger, it is pushed on the stack, and one INDENT token is
|
||||||
If it larger, it is pushed on the stack, and one INDENT token is generated.
|
generated. If it is smaller, it {\em must} be one of the numbers
|
||||||
If it is smaller, it {\em must} be one of the numbers occurring on the
|
occurring on the stack; all numbers on the stack that are larger are
|
||||||
stack; all numbers on the stack that are larger are popped off,
|
popped off, and for each number popped off a DEDENT token is
|
||||||
and for each number popped off a DEDENT token is generated.
|
generated. At the end of the file, a DEDENT token is generated for
|
||||||
At the end of the file, a DEDENT token is generated for each number
|
each number remaining on the stack that is larger than zero.
|
||||||
remaining on the stack that is larger than zero.
|
|
||||||
|
|
||||||
\section{Other tokens}
|
\section{Other tokens}
|
||||||
|
|
||||||
Besides NEWLINE, INDENT and DEDENT, the following categories of tokens
|
Besides NEWLINE, INDENT and DEDENT, the following categories of tokens
|
||||||
exist: identifiers, keywords, literals, operators, and delimiters.
|
exist: identifiers, keywords, literals, operators, and delimiters.
|
||||||
Spaces and tabs are not tokens, but serve to delimit tokens.
|
Spaces and tabs are not tokens, but serve to delimit tokens. Where
|
||||||
Where ambiguity exists, a token comprises the longest possible
|
ambiguity exists, a token comprises the longest possible string that
|
||||||
string that forms a legal token, when reading from left to right.
|
forms a legal token, when read from left to right.
|
||||||
|
|
||||||
Tokens are described using an extended regular expression notation.
|
Tokens are described using an extended regular expression notation.
|
||||||
This is similar to the extended BNF notation used later, except that
|
This is similar to the extended BNF notation used later, except that
|
||||||
the notation <...> is used to give an informal description of a character,
|
the notation \verb\<...>\ is used to give an informal description of a
|
||||||
and that spaces and tabs are not to be ignored.
|
character, and that spaces and tabs are not to be ignored.
|
||||||
|
|
||||||
\section{Identifiers}
|
\section{Identifiers}
|
||||||
|
|
||||||
Identifiers are described by the following regular expressions:
|
Identifiers are described by the following regular expressions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
identifier: (letter|'_') (letter|digit|'_')*
|
identifier: (letter|"_") (letter|digit|"_")*
|
||||||
letter: lowercase | uppercase
|
letter: lowercase | uppercase
|
||||||
lowercase: 'a'|'b'|...|'z'
|
lowercase: "a"|"b"|...|"z"
|
||||||
uppercase: 'A'|'B'|...|'Z'
|
uppercase: "A"|"B"|...|"Z"
|
||||||
digit: '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
|
digit: "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
Identifiers are unlimited in length.
|
Identifiers are unlimited in length. Case is significant.
|
||||||
Upper and lower case letters are different.
|
|
||||||
|
|
||||||
\section{Keywords}
|
\section{Keywords}
|
||||||
|
|
||||||
The following tokens are used as reserved words,
|
The following identifiers are used as reserved words, or {\em
|
||||||
or keywords of the language,
|
keywords} of the language, and may not be used as ordinary
|
||||||
and may not be used as ordinary identifiers.
|
identifiers. They must be spelled exactly as written here:
|
||||||
They must be spelled exactly as written here:
|
|
||||||
|
|
||||||
{\tt
|
\begin{verbatim}
|
||||||
and
|
and del for is raise
|
||||||
break
|
break elif from not return
|
||||||
class
|
class else if or try
|
||||||
continue
|
continue except import pass while
|
||||||
def
|
def finally in print
|
||||||
del
|
\end{verbatim}
|
||||||
elif
|
|
||||||
else
|
% import string
|
||||||
except
|
% l = []
|
||||||
finally
|
% try:
|
||||||
for
|
% while 1:
|
||||||
from
|
% l = l + string.split(raw_input())
|
||||||
if
|
% except EOFError:
|
||||||
import
|
% pass
|
||||||
in
|
% l.sort()
|
||||||
is
|
% for i in range((len(l)+4)/5):
|
||||||
not
|
% for j in range(i, len(l), 5):
|
||||||
or
|
% print string.ljust(l[j], 10),
|
||||||
pass
|
% print
|
||||||
print
|
|
||||||
raise
|
|
||||||
return
|
|
||||||
try
|
|
||||||
while
|
|
||||||
}
|
|
||||||
|
|
||||||
\section{Literals}
|
\section{Literals}
|
||||||
|
|
||||||
|
|
@ -197,24 +183,47 @@ They must be spelled exactly as written here:
|
||||||
String literals are described by the following regular expressions:
|
String literals are described by the following regular expressions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
stringliteral: '\'' stringitem* '\''
|
stringliteral: "'" stringitem* "'"
|
||||||
stringitem: stringchar | escapeseq
|
stringitem: stringchar | escapeseq
|
||||||
stringchar: <any character except newline or '\\' or '\''>
|
stringchar: <any character except newline or "\" or "'">
|
||||||
escapeseq: '\\' <any character except newline>
|
escapeseq: "'" <any character except newline>
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
String literals cannot span physical line boundaries.
|
String literals cannot span physical line boundaries. Escape
|
||||||
Escape sequences in strings are actually interpreted according to almost the
|
sequences in strings are actually interpreted according to rules
|
||||||
same rules as used by Standard C
|
simular to those used by Standard C. The recognized escape sequences
|
||||||
(XXX which should be made explicit here),
|
are:
|
||||||
except that \verb/\E/ is equivalent to \verb/\033/,
|
|
||||||
\verb/\"/ is not recognized,
|
\begin{center}
|
||||||
newline characters cannot be escaped, and
|
\begin{tabular}{|l|l|}
|
||||||
{\em all unrecognized escape sequences are left in the string unchanged}.
|
\hline
|
||||||
(The latter rule is useful when debugging: if an escape sequence is
|
\verb/\\/ & Backslash (\verb/\/) \\
|
||||||
mistyped, the resulting output is more easily recognized as broken.
|
\verb/\'/ & Single quote (\verb/'/) \\
|
||||||
It also helps somewhat for string literals used as regular expressions
|
\verb/\a/ & ASCII Bell (BEL) \\
|
||||||
or otherwise passed to other modules that do their own escape handling.)
|
\verb/\b/ & ASCII Backspace (BS) \\
|
||||||
|
\verb/\E/ & ASCII Escape (ESC) \\
|
||||||
|
\verb/\f/ & ASCII Formfeed (FF) \\
|
||||||
|
\verb/\n/ & ASCII Linefeed (LF) \\
|
||||||
|
\verb/\r/ & ASCII Carriage Return (CR) \\
|
||||||
|
\verb/\t/ & ASCII Horizontal Tab (TAB) \\
|
||||||
|
\verb/\v/ & ASCII Vertical Tab (VT) \\
|
||||||
|
\verb/\/{\em ooo} & ASCII character with octal value {\em ooo} \\
|
||||||
|
\verb/\x/{em xx...} & ASCII character with hex value {\em xx} \\
|
||||||
|
\hline
|
||||||
|
\end{tabular}
|
||||||
|
\end{center}
|
||||||
|
|
||||||
|
For compatibility with in Standard C, up to three octal digits are
|
||||||
|
accepted, but an unlimited number of hex digits is taken to be part of
|
||||||
|
the hex escape (and then the lower 8 bits of the resulting hex number
|
||||||
|
are used...).
|
||||||
|
|
||||||
|
All unrecognized escape sequences are left in the string {\em
|
||||||
|
unchanged}, i.e., the backslash is left in the string. (This rule is
|
||||||
|
useful when debugging: if an escape sequence is mistyped, the
|
||||||
|
resulting output is more easily recognized as broken. It also helps
|
||||||
|
somewhat for string literals used as regular expressions or otherwise
|
||||||
|
passed to other modules that do their own escape handling.)
|
||||||
|
|
||||||
\subsection{Numeric literals}
|
\subsection{Numeric literals}
|
||||||
|
|
||||||
|
|
@ -224,24 +233,24 @@ and floating point numbers.
|
||||||
Integers and long integers are described by the following regular expressions:
|
Integers and long integers are described by the following regular expressions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
longinteger: integer ('l'|'L')
|
longinteger: integer ("l"|"L")
|
||||||
integer: decimalinteger | octinteger | hexinteger
|
integer: decimalinteger | octinteger | hexinteger
|
||||||
decimalinteger: nonzerodigit digit* | '0'
|
decimalinteger: nonzerodigit digit* | "0"
|
||||||
octinteger: '0' octdigit+
|
octinteger: "0" octdigit+
|
||||||
hexinteger: '0' ('x'|'X') hexdigit+
|
hexinteger: "0" ("x"|"X") hexdigit+
|
||||||
|
|
||||||
nonzerodigit: '1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
|
nonzerodigit: "1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
|
||||||
octdigit: '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'
|
octdigit: "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"
|
||||||
hexdigit: digit|'a'|'b'|'c'|'d'|'e'|'f'|'A'|'B'|'C'|'D'|'E'|'F'
|
hexdigit: digit|"a"|"b"|"c"|"d"|"e"|"f"|"A"|"B"|"C"|"D"|"E"|"F"
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
Floating point numbers are described by the following regular expressions:
|
Floating point numbers are described by the following regular expressions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
floatnumber: [intpart] fraction [exponent] | intpart ['.'] exponent
|
floatnumber: [intpart] fraction [exponent] | intpart ["."] exponent
|
||||||
intpart: digit+
|
intpart: digit+
|
||||||
fraction: '.' digit+
|
fraction: "." digit+
|
||||||
exponent: ('e'|'E') ['+'|'-'] digit+
|
exponent: ("e"|"E") ["+"|"-"] digit+
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\section{Operators}
|
\section{Operators}
|
||||||
|
|
@ -292,15 +301,15 @@ conditions. Conditions are a superset of expressions, and a condition
|
||||||
may be used where an expression is required by enclosing it in
|
may be used where an expression is required by enclosing it in
|
||||||
parentheses. The only place where an unparenthesized condition
|
parentheses. The only place where an unparenthesized condition
|
||||||
is not allowed is on the right-hand side of the assignment operator,
|
is not allowed is on the right-hand side of the assignment operator,
|
||||||
because this operator is the same token (\verb/'='/) as used for
|
because this operator is the same token (\verb\=\) as used for
|
||||||
compasisons.
|
compasisons.
|
||||||
|
|
||||||
The comma plays a somewhat special role in Python's syntax.
|
The comma plays a somewhat special role in Python's syntax.
|
||||||
It is an operator with a lower precedence than all others, but
|
It is an operator with a lower precedence than all others, but
|
||||||
occasionally serves other purposes as well (e.g., it has special
|
occasionally serves other purposes as well (e.g., it has special
|
||||||
semantics in print statements). When a comma is accepted by the
|
semantics in print statements). When a comma is accepted by the
|
||||||
syntax, one of the syntactic categories \verb/expression_list/
|
syntax, one of the syntactic categories \verb\expression_list\
|
||||||
or \verb/condition_list/ is always used.
|
or \verb\condition_list\ is always used.
|
||||||
|
|
||||||
When (one alternative of) a syntax rule has the form
|
When (one alternative of) a syntax rule has the form
|
||||||
|
|
||||||
|
|
@ -308,8 +317,8 @@ When (one alternative of) a syntax rule has the form
|
||||||
name: othername
|
name: othername
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
and no semantics are given, the semantics of this form of \verb/name/
|
and no semantics are given, the semantics of this form of \verb\name\
|
||||||
are the same as for \verb/othername/.
|
are the same as for \verb\othername\.
|
||||||
|
|
||||||
\section{Arithmetic conversions}
|
\section{Arithmetic conversions}
|
||||||
|
|
||||||
|
|
@ -414,11 +423,11 @@ key value prevails.
|
||||||
A string conversion evaluates the contained condition list and converts the
|
A string conversion evaluates the contained condition list and converts the
|
||||||
resulting object into a string according to rules specific to its type.
|
resulting object into a string according to rules specific to its type.
|
||||||
|
|
||||||
If the object is a string, a number, \verb/None/, or a tuple, list or
|
If the object is a string, a number, \verb\None\, or a tuple, list or
|
||||||
dictionary containing only objects whose type is in this list,
|
dictionary containing only objects whose type is in this list,
|
||||||
the resulting
|
the resulting
|
||||||
string is a valid Python expression which can be passed to the
|
string is a valid Python expression which can be passed to the
|
||||||
built-in function \verb/eval()/ to yield an expression with the
|
built-in function \verb\eval()\ to yield an expression with the
|
||||||
same value (or an approximation, if floating point numbers are
|
same value (or an approximation, if floating point numbers are
|
||||||
involved).
|
involved).
|
||||||
|
|
||||||
|
|
@ -459,11 +468,11 @@ Their syntax is:
|
||||||
factor: primary | '-' factor | '+' factor | '~' factor
|
factor: primary | '-' factor | '+' factor | '~' factor
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
The unary \verb/'-'/ operator yields the negative of its numeric argument.
|
The unary \verb\-\ operator yields the negative of its numeric argument.
|
||||||
|
|
||||||
The unary \verb/'+'/ operator yields its numeric argument unchanged.
|
The unary \verb\+\ operator yields its numeric argument unchanged.
|
||||||
|
|
||||||
The unary \verb/'~'/ operator yields the bit-wise negation of its
|
The unary \verb\~\ operator yields the bit-wise negation of its
|
||||||
integral numerical argument.
|
integral numerical argument.
|
||||||
|
|
||||||
In all three cases, if the argument does not have the proper type,
|
In all three cases, if the argument does not have the proper type,
|
||||||
|
|
@ -477,7 +486,7 @@ Terms represent the most tightly binding binary operators:
|
||||||
term: factor | term '*' factor | term '/' factor | term '%' factor
|
term: factor | term '*' factor | term '/' factor | term '%' factor
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
The \verb/'*'/ operator yields the product of its arguments.
|
The \verb\*\ operator yields the product of its arguments.
|
||||||
The arguments must either both be numbers, or one argument must be
|
The arguments must either both be numbers, or one argument must be
|
||||||
a (short) integer and the other must be a string.
|
a (short) integer and the other must be a string.
|
||||||
In the former case, the numbers are converted to a common type
|
In the former case, the numbers are converted to a common type
|
||||||
|
|
@ -572,7 +581,7 @@ it is optional in all other cases (a single expression without
|
||||||
a trailing comma doesn't create a tuple, but rather yields the
|
a trailing comma doesn't create a tuple, but rather yields the
|
||||||
value of that expression).
|
value of that expression).
|
||||||
|
|
||||||
To create an empty tuple, use an empty pair of parentheses: \verb/()/.
|
To create an empty tuple, use an empty pair of parentheses: \verb\()\.
|
||||||
|
|
||||||
\section{Comparisons}
|
\section{Comparisons}
|
||||||
|
|
||||||
|
|
@ -597,8 +606,8 @@ Note that $e_0 op_1 e_1 op_2 e_2$ does not imply any kind of comparison
|
||||||
between $e_0$ and $e_2$, e.g., $x < y > z$ is perfectly legal.
|
between $e_0$ and $e_2$, e.g., $x < y > z$ is perfectly legal.
|
||||||
|
|
||||||
For the benefit of C programmers,
|
For the benefit of C programmers,
|
||||||
the comparison operators \verb/=/ and \verb/==/ are equivalent,
|
the comparison operators \verb\=\ and \verb\==\ are equivalent,
|
||||||
and so are \verb/<>/ and \verb/!=/.
|
and so are \verb\<>\ and \verb\!=\.
|
||||||
Use of the C variants is discouraged.
|
Use of the C variants is discouraged.
|
||||||
|
|
||||||
The operators {\tt '<', '>', '=', '>=', '<='}, and {\tt '<>'} compare
|
The operators {\tt '<', '>', '=', '>=', '<='}, and {\tt '<>'} compare
|
||||||
|
|
@ -610,7 +619,7 @@ the value \verb\None\ compares smaller than the values of any other type.
|
||||||
|
|
||||||
(This unusual
|
(This unusual
|
||||||
definition of comparison is done to simplify the definition of
|
definition of comparison is done to simplify the definition of
|
||||||
operations like sorting and the \verb/in/ and \verb/not in/ operators.)
|
operations like sorting and the \verb\in\ and \verb\not in\ operators.)
|
||||||
|
|
||||||
Comparison of objects of the same type depends on the type:
|
Comparison of objects of the same type depends on the type:
|
||||||
|
|
||||||
|
|
@ -869,12 +878,12 @@ A space is written before each object is (converted and) written,
|
||||||
unless the output system believes it is positioned at the beginning
|
unless the output system believes it is positioned at the beginning
|
||||||
of a line. This is the case: (1) when no characters have been written
|
of a line. This is the case: (1) when no characters have been written
|
||||||
to standard output; or (2) when the last character written to
|
to standard output; or (2) when the last character written to
|
||||||
standard output is \verb/'\n'/;
|
standard output is \verb/\n/;
|
||||||
or (3) when the last I/O operation
|
or (3) when the last I/O operation
|
||||||
on standard output was not a \verb\print\ statement.
|
on standard output was not a \verb\print\ statement.
|
||||||
|
|
||||||
Finally,
|
Finally,
|
||||||
a \verb/'\n'/ character is written at the end,
|
a \verb/\n/ character is written at the end,
|
||||||
unless the \verb\print\ statement ends with a comma.
|
unless the \verb\print\ statement ends with a comma.
|
||||||
This is the only action if the statement contains just the keyword
|
This is the only action if the statement contains just the keyword
|
||||||
\verb\print\.
|
\verb\print\.
|
||||||
|
|
|
||||||
263
Doc/ref/ref.tex
263
Doc/ref/ref.tex
|
|
@ -42,9 +42,8 @@ and MS-DOS.
|
||||||
This reference manual describes the syntax and ``core semantics'' of
|
This reference manual describes the syntax and ``core semantics'' of
|
||||||
the language. It is terse, but exact and complete. The semantics of
|
the language. It is terse, but exact and complete. The semantics of
|
||||||
non-essential built-in object types and of the built-in functions and
|
non-essential built-in object types and of the built-in functions and
|
||||||
modules are described in the {\em Library Reference} document. For an
|
modules are described in the {\em Python Library Reference}. For an
|
||||||
informal introduction to the language, see the {\em Tutorial}
|
informal introduction to the language, see the {\em Python Tutorial}.
|
||||||
document.
|
|
||||||
|
|
||||||
\end{abstract}
|
\end{abstract}
|
||||||
|
|
||||||
|
|
@ -63,132 +62,119 @@ It is not intended as a tutorial.
|
||||||
|
|
||||||
\chapter{Lexical analysis}
|
\chapter{Lexical analysis}
|
||||||
|
|
||||||
A Python program is read by a {\em parser}.
|
A Python program is read by a {\em parser}. Input to the parser is a
|
||||||
Input to the parser is a stream of {\em tokens}, generated
|
stream of {\em tokens}, generated by the {\em lexical analyzer}. This
|
||||||
by the {\em lexical analyzer}.
|
chapter describes how the lexical analyzer breaks a file into tokens.
|
||||||
|
|
||||||
\section{Line structure}
|
\section{Line structure}
|
||||||
|
|
||||||
A Python program is divided in a number of logical lines.
|
A Python program is divided in a number of logical lines. Statements
|
||||||
Statements may not straddle logical line boundaries except where
|
do not straddle logical line boundaries except where explicitly
|
||||||
explicitly allowed by the syntax.
|
indicated by the syntax (i.e., for compound statements). To this
|
||||||
To this purpose, the end of a logical line
|
purpose, the end of a logical line is represented by the token
|
||||||
is represented by the token NEWLINE.
|
NEWLINE.
|
||||||
|
|
||||||
\subsection{Comments}
|
\subsection{Comments}
|
||||||
|
|
||||||
A comment starts with a hash character (\verb/#/) and ends at the end
|
A comment starts with a hash character (\verb\#\) that is not part of
|
||||||
of the physical line. Comments are ignored by the syntax.
|
a string literal, and ends at the end of the physical line. Comments
|
||||||
A hash character in a string literal does not start a comment.
|
are ignored by the syntax.
|
||||||
|
|
||||||
\subsection{Line joining}
|
\subsection{Line joining}
|
||||||
|
|
||||||
Physical lines may be joined into logical lines using backslash
|
Two or more physical lines may be joined into logical lines using
|
||||||
characters (\verb/\/), as follows.
|
backslash characters (\verb/\/), as follows: When physical line ends
|
||||||
If a physical line ends in a backslash that is not part of a string
|
in a backslash that is not part of a string literal or comment, it is
|
||||||
literal or comment, it is joined with
|
joined with the following forming a single logical line, deleting the
|
||||||
the following forming a single logical line, deleting the backslash
|
backslash and the following end-of-line character.
|
||||||
and the following end-of-line character. More than two physical
|
|
||||||
lines may be joined together in this way.
|
|
||||||
|
|
||||||
\subsection{Blank lines}
|
\subsection{Blank lines}
|
||||||
|
|
||||||
A physical line that is not the continuation of the previous line
|
A logical line that contains only spaces, tabs, and possibly a
|
||||||
and contains only spaces, tabs and possibly a comment, is ignored
|
comment, is ignored (i.e., no NEWLINE token is generated), except that
|
||||||
(i.e., no NEWLINE token is generated),
|
during interactive input of statements, an entirely blank logical line
|
||||||
except that during interactive input of statements, an empty
|
terminates a multi-line statement.
|
||||||
physical line terminates a multi-line statement.
|
|
||||||
|
|
||||||
\subsection{Indentation}
|
\subsection{Indentation}
|
||||||
|
|
||||||
Spaces and tabs at the beginning of a line are used to compute
|
Spaces and tabs at the beginning of a logical line are used to compute
|
||||||
the indentation level of the line, which in turn is used to determine
|
the indentation level of the line, which in turn is used to determine
|
||||||
the grouping of statements.
|
the grouping of statements.
|
||||||
|
|
||||||
First, each tab is replaced by one to eight spaces such that the column number
|
First, each tab is replaced by one to eight spaces such that the total
|
||||||
of the next character is a multiple of eight (counting from zero).
|
number of spaces up to that point is a multiple of eight. The total
|
||||||
The column number of the first non-space character then defines the
|
number of spaces preceding the first non-blank character then
|
||||||
line's indentation.
|
determines the line's indentation. Indentation cannot be split over
|
||||||
Indentation cannot be split over multiple physical lines using
|
multiple physical lines using backslashes.
|
||||||
backslashes.
|
|
||||||
|
|
||||||
The indentation levels of consecutive lines are used to generate
|
The indentation levels of consecutive lines are used to generate
|
||||||
INDENT and DEDENT tokens, using a stack, as follows.
|
INDENT and DEDENT tokens, using a stack, as follows.
|
||||||
|
|
||||||
Before the first line of the file is read, a single zero is pushed on
|
Before the first line of the file is read, a single zero is pushed on
|
||||||
the stack; this will never be popped off again. The numbers pushed
|
the stack; this will never be popped off again. The numbers pushed on
|
||||||
on the stack will always be strictly increasing from bottom to top.
|
the stack will always be strictly increasing from bottom to top. At
|
||||||
At the beginning of each logical line, the line's indentation level
|
the beginning of each logical line, the line's indentation level is
|
||||||
is compared to the top of the stack.
|
compared to the top of the stack. If it is equal, nothing happens.
|
||||||
If it is equal, nothing happens.
|
If it larger, it is pushed on the stack, and one INDENT token is
|
||||||
If it larger, it is pushed on the stack, and one INDENT token is generated.
|
generated. If it is smaller, it {\em must} be one of the numbers
|
||||||
If it is smaller, it {\em must} be one of the numbers occurring on the
|
occurring on the stack; all numbers on the stack that are larger are
|
||||||
stack; all numbers on the stack that are larger are popped off,
|
popped off, and for each number popped off a DEDENT token is
|
||||||
and for each number popped off a DEDENT token is generated.
|
generated. At the end of the file, a DEDENT token is generated for
|
||||||
At the end of the file, a DEDENT token is generated for each number
|
each number remaining on the stack that is larger than zero.
|
||||||
remaining on the stack that is larger than zero.
|
|
||||||
|
|
||||||
\section{Other tokens}
|
\section{Other tokens}
|
||||||
|
|
||||||
Besides NEWLINE, INDENT and DEDENT, the following categories of tokens
|
Besides NEWLINE, INDENT and DEDENT, the following categories of tokens
|
||||||
exist: identifiers, keywords, literals, operators, and delimiters.
|
exist: identifiers, keywords, literals, operators, and delimiters.
|
||||||
Spaces and tabs are not tokens, but serve to delimit tokens.
|
Spaces and tabs are not tokens, but serve to delimit tokens. Where
|
||||||
Where ambiguity exists, a token comprises the longest possible
|
ambiguity exists, a token comprises the longest possible string that
|
||||||
string that forms a legal token, when reading from left to right.
|
forms a legal token, when read from left to right.
|
||||||
|
|
||||||
Tokens are described using an extended regular expression notation.
|
Tokens are described using an extended regular expression notation.
|
||||||
This is similar to the extended BNF notation used later, except that
|
This is similar to the extended BNF notation used later, except that
|
||||||
the notation <...> is used to give an informal description of a character,
|
the notation \verb\<...>\ is used to give an informal description of a
|
||||||
and that spaces and tabs are not to be ignored.
|
character, and that spaces and tabs are not to be ignored.
|
||||||
|
|
||||||
\section{Identifiers}
|
\section{Identifiers}
|
||||||
|
|
||||||
Identifiers are described by the following regular expressions:
|
Identifiers are described by the following regular expressions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
identifier: (letter|'_') (letter|digit|'_')*
|
identifier: (letter|"_") (letter|digit|"_")*
|
||||||
letter: lowercase | uppercase
|
letter: lowercase | uppercase
|
||||||
lowercase: 'a'|'b'|...|'z'
|
lowercase: "a"|"b"|...|"z"
|
||||||
uppercase: 'A'|'B'|...|'Z'
|
uppercase: "A"|"B"|...|"Z"
|
||||||
digit: '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
|
digit: "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
Identifiers are unlimited in length.
|
Identifiers are unlimited in length. Case is significant.
|
||||||
Upper and lower case letters are different.
|
|
||||||
|
|
||||||
\section{Keywords}
|
\section{Keywords}
|
||||||
|
|
||||||
The following tokens are used as reserved words,
|
The following identifiers are used as reserved words, or {\em
|
||||||
or keywords of the language,
|
keywords} of the language, and may not be used as ordinary
|
||||||
and may not be used as ordinary identifiers.
|
identifiers. They must be spelled exactly as written here:
|
||||||
They must be spelled exactly as written here:
|
|
||||||
|
|
||||||
{\tt
|
\begin{verbatim}
|
||||||
and
|
and del for is raise
|
||||||
break
|
break elif from not return
|
||||||
class
|
class else if or try
|
||||||
continue
|
continue except import pass while
|
||||||
def
|
def finally in print
|
||||||
del
|
\end{verbatim}
|
||||||
elif
|
|
||||||
else
|
% import string
|
||||||
except
|
% l = []
|
||||||
finally
|
% try:
|
||||||
for
|
% while 1:
|
||||||
from
|
% l = l + string.split(raw_input())
|
||||||
if
|
% except EOFError:
|
||||||
import
|
% pass
|
||||||
in
|
% l.sort()
|
||||||
is
|
% for i in range((len(l)+4)/5):
|
||||||
not
|
% for j in range(i, len(l), 5):
|
||||||
or
|
% print string.ljust(l[j], 10),
|
||||||
pass
|
% print
|
||||||
print
|
|
||||||
raise
|
|
||||||
return
|
|
||||||
try
|
|
||||||
while
|
|
||||||
}
|
|
||||||
|
|
||||||
\section{Literals}
|
\section{Literals}
|
||||||
|
|
||||||
|
|
@ -197,24 +183,47 @@ They must be spelled exactly as written here:
|
||||||
String literals are described by the following regular expressions:
|
String literals are described by the following regular expressions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
stringliteral: '\'' stringitem* '\''
|
stringliteral: "'" stringitem* "'"
|
||||||
stringitem: stringchar | escapeseq
|
stringitem: stringchar | escapeseq
|
||||||
stringchar: <any character except newline or '\\' or '\''>
|
stringchar: <any character except newline or "\" or "'">
|
||||||
escapeseq: '\\' <any character except newline>
|
escapeseq: "'" <any character except newline>
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
String literals cannot span physical line boundaries.
|
String literals cannot span physical line boundaries. Escape
|
||||||
Escape sequences in strings are actually interpreted according to almost the
|
sequences in strings are actually interpreted according to rules
|
||||||
same rules as used by Standard C
|
simular to those used by Standard C. The recognized escape sequences
|
||||||
(XXX which should be made explicit here),
|
are:
|
||||||
except that \verb/\E/ is equivalent to \verb/\033/,
|
|
||||||
\verb/\"/ is not recognized,
|
\begin{center}
|
||||||
newline characters cannot be escaped, and
|
\begin{tabular}{|l|l|}
|
||||||
{\em all unrecognized escape sequences are left in the string unchanged}.
|
\hline
|
||||||
(The latter rule is useful when debugging: if an escape sequence is
|
\verb/\\/ & Backslash (\verb/\/) \\
|
||||||
mistyped, the resulting output is more easily recognized as broken.
|
\verb/\'/ & Single quote (\verb/'/) \\
|
||||||
It also helps somewhat for string literals used as regular expressions
|
\verb/\a/ & ASCII Bell (BEL) \\
|
||||||
or otherwise passed to other modules that do their own escape handling.)
|
\verb/\b/ & ASCII Backspace (BS) \\
|
||||||
|
\verb/\E/ & ASCII Escape (ESC) \\
|
||||||
|
\verb/\f/ & ASCII Formfeed (FF) \\
|
||||||
|
\verb/\n/ & ASCII Linefeed (LF) \\
|
||||||
|
\verb/\r/ & ASCII Carriage Return (CR) \\
|
||||||
|
\verb/\t/ & ASCII Horizontal Tab (TAB) \\
|
||||||
|
\verb/\v/ & ASCII Vertical Tab (VT) \\
|
||||||
|
\verb/\/{\em ooo} & ASCII character with octal value {\em ooo} \\
|
||||||
|
\verb/\x/{em xx...} & ASCII character with hex value {\em xx} \\
|
||||||
|
\hline
|
||||||
|
\end{tabular}
|
||||||
|
\end{center}
|
||||||
|
|
||||||
|
For compatibility with in Standard C, up to three octal digits are
|
||||||
|
accepted, but an unlimited number of hex digits is taken to be part of
|
||||||
|
the hex escape (and then the lower 8 bits of the resulting hex number
|
||||||
|
are used...).
|
||||||
|
|
||||||
|
All unrecognized escape sequences are left in the string {\em
|
||||||
|
unchanged}, i.e., the backslash is left in the string. (This rule is
|
||||||
|
useful when debugging: if an escape sequence is mistyped, the
|
||||||
|
resulting output is more easily recognized as broken. It also helps
|
||||||
|
somewhat for string literals used as regular expressions or otherwise
|
||||||
|
passed to other modules that do their own escape handling.)
|
||||||
|
|
||||||
\subsection{Numeric literals}
|
\subsection{Numeric literals}
|
||||||
|
|
||||||
|
|
@ -224,24 +233,24 @@ and floating point numbers.
|
||||||
Integers and long integers are described by the following regular expressions:
|
Integers and long integers are described by the following regular expressions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
longinteger: integer ('l'|'L')
|
longinteger: integer ("l"|"L")
|
||||||
integer: decimalinteger | octinteger | hexinteger
|
integer: decimalinteger | octinteger | hexinteger
|
||||||
decimalinteger: nonzerodigit digit* | '0'
|
decimalinteger: nonzerodigit digit* | "0"
|
||||||
octinteger: '0' octdigit+
|
octinteger: "0" octdigit+
|
||||||
hexinteger: '0' ('x'|'X') hexdigit+
|
hexinteger: "0" ("x"|"X") hexdigit+
|
||||||
|
|
||||||
nonzerodigit: '1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
|
nonzerodigit: "1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
|
||||||
octdigit: '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'
|
octdigit: "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"
|
||||||
hexdigit: digit|'a'|'b'|'c'|'d'|'e'|'f'|'A'|'B'|'C'|'D'|'E'|'F'
|
hexdigit: digit|"a"|"b"|"c"|"d"|"e"|"f"|"A"|"B"|"C"|"D"|"E"|"F"
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
Floating point numbers are described by the following regular expressions:
|
Floating point numbers are described by the following regular expressions:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
floatnumber: [intpart] fraction [exponent] | intpart ['.'] exponent
|
floatnumber: [intpart] fraction [exponent] | intpart ["."] exponent
|
||||||
intpart: digit+
|
intpart: digit+
|
||||||
fraction: '.' digit+
|
fraction: "." digit+
|
||||||
exponent: ('e'|'E') ['+'|'-'] digit+
|
exponent: ("e"|"E") ["+"|"-"] digit+
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\section{Operators}
|
\section{Operators}
|
||||||
|
|
@ -292,15 +301,15 @@ conditions. Conditions are a superset of expressions, and a condition
|
||||||
may be used where an expression is required by enclosing it in
|
may be used where an expression is required by enclosing it in
|
||||||
parentheses. The only place where an unparenthesized condition
|
parentheses. The only place where an unparenthesized condition
|
||||||
is not allowed is on the right-hand side of the assignment operator,
|
is not allowed is on the right-hand side of the assignment operator,
|
||||||
because this operator is the same token (\verb/'='/) as used for
|
because this operator is the same token (\verb\=\) as used for
|
||||||
compasisons.
|
compasisons.
|
||||||
|
|
||||||
The comma plays a somewhat special role in Python's syntax.
|
The comma plays a somewhat special role in Python's syntax.
|
||||||
It is an operator with a lower precedence than all others, but
|
It is an operator with a lower precedence than all others, but
|
||||||
occasionally serves other purposes as well (e.g., it has special
|
occasionally serves other purposes as well (e.g., it has special
|
||||||
semantics in print statements). When a comma is accepted by the
|
semantics in print statements). When a comma is accepted by the
|
||||||
syntax, one of the syntactic categories \verb/expression_list/
|
syntax, one of the syntactic categories \verb\expression_list\
|
||||||
or \verb/condition_list/ is always used.
|
or \verb\condition_list\ is always used.
|
||||||
|
|
||||||
When (one alternative of) a syntax rule has the form
|
When (one alternative of) a syntax rule has the form
|
||||||
|
|
||||||
|
|
@ -308,8 +317,8 @@ When (one alternative of) a syntax rule has the form
|
||||||
name: othername
|
name: othername
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
and no semantics are given, the semantics of this form of \verb/name/
|
and no semantics are given, the semantics of this form of \verb\name\
|
||||||
are the same as for \verb/othername/.
|
are the same as for \verb\othername\.
|
||||||
|
|
||||||
\section{Arithmetic conversions}
|
\section{Arithmetic conversions}
|
||||||
|
|
||||||
|
|
@ -414,11 +423,11 @@ key value prevails.
|
||||||
A string conversion evaluates the contained condition list and converts the
|
A string conversion evaluates the contained condition list and converts the
|
||||||
resulting object into a string according to rules specific to its type.
|
resulting object into a string according to rules specific to its type.
|
||||||
|
|
||||||
If the object is a string, a number, \verb/None/, or a tuple, list or
|
If the object is a string, a number, \verb\None\, or a tuple, list or
|
||||||
dictionary containing only objects whose type is in this list,
|
dictionary containing only objects whose type is in this list,
|
||||||
the resulting
|
the resulting
|
||||||
string is a valid Python expression which can be passed to the
|
string is a valid Python expression which can be passed to the
|
||||||
built-in function \verb/eval()/ to yield an expression with the
|
built-in function \verb\eval()\ to yield an expression with the
|
||||||
same value (or an approximation, if floating point numbers are
|
same value (or an approximation, if floating point numbers are
|
||||||
involved).
|
involved).
|
||||||
|
|
||||||
|
|
@ -459,11 +468,11 @@ Their syntax is:
|
||||||
factor: primary | '-' factor | '+' factor | '~' factor
|
factor: primary | '-' factor | '+' factor | '~' factor
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
The unary \verb/'-'/ operator yields the negative of its numeric argument.
|
The unary \verb\-\ operator yields the negative of its numeric argument.
|
||||||
|
|
||||||
The unary \verb/'+'/ operator yields its numeric argument unchanged.
|
The unary \verb\+\ operator yields its numeric argument unchanged.
|
||||||
|
|
||||||
The unary \verb/'~'/ operator yields the bit-wise negation of its
|
The unary \verb\~\ operator yields the bit-wise negation of its
|
||||||
integral numerical argument.
|
integral numerical argument.
|
||||||
|
|
||||||
In all three cases, if the argument does not have the proper type,
|
In all three cases, if the argument does not have the proper type,
|
||||||
|
|
@ -477,7 +486,7 @@ Terms represent the most tightly binding binary operators:
|
||||||
term: factor | term '*' factor | term '/' factor | term '%' factor
|
term: factor | term '*' factor | term '/' factor | term '%' factor
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
The \verb/'*'/ operator yields the product of its arguments.
|
The \verb\*\ operator yields the product of its arguments.
|
||||||
The arguments must either both be numbers, or one argument must be
|
The arguments must either both be numbers, or one argument must be
|
||||||
a (short) integer and the other must be a string.
|
a (short) integer and the other must be a string.
|
||||||
In the former case, the numbers are converted to a common type
|
In the former case, the numbers are converted to a common type
|
||||||
|
|
@ -572,7 +581,7 @@ it is optional in all other cases (a single expression without
|
||||||
a trailing comma doesn't create a tuple, but rather yields the
|
a trailing comma doesn't create a tuple, but rather yields the
|
||||||
value of that expression).
|
value of that expression).
|
||||||
|
|
||||||
To create an empty tuple, use an empty pair of parentheses: \verb/()/.
|
To create an empty tuple, use an empty pair of parentheses: \verb\()\.
|
||||||
|
|
||||||
\section{Comparisons}
|
\section{Comparisons}
|
||||||
|
|
||||||
|
|
@ -597,8 +606,8 @@ Note that $e_0 op_1 e_1 op_2 e_2$ does not imply any kind of comparison
|
||||||
between $e_0$ and $e_2$, e.g., $x < y > z$ is perfectly legal.
|
between $e_0$ and $e_2$, e.g., $x < y > z$ is perfectly legal.
|
||||||
|
|
||||||
For the benefit of C programmers,
|
For the benefit of C programmers,
|
||||||
the comparison operators \verb/=/ and \verb/==/ are equivalent,
|
the comparison operators \verb\=\ and \verb\==\ are equivalent,
|
||||||
and so are \verb/<>/ and \verb/!=/.
|
and so are \verb\<>\ and \verb\!=\.
|
||||||
Use of the C variants is discouraged.
|
Use of the C variants is discouraged.
|
||||||
|
|
||||||
The operators {\tt '<', '>', '=', '>=', '<='}, and {\tt '<>'} compare
|
The operators {\tt '<', '>', '=', '>=', '<='}, and {\tt '<>'} compare
|
||||||
|
|
@ -610,7 +619,7 @@ the value \verb\None\ compares smaller than the values of any other type.
|
||||||
|
|
||||||
(This unusual
|
(This unusual
|
||||||
definition of comparison is done to simplify the definition of
|
definition of comparison is done to simplify the definition of
|
||||||
operations like sorting and the \verb/in/ and \verb/not in/ operators.)
|
operations like sorting and the \verb\in\ and \verb\not in\ operators.)
|
||||||
|
|
||||||
Comparison of objects of the same type depends on the type:
|
Comparison of objects of the same type depends on the type:
|
||||||
|
|
||||||
|
|
@ -869,12 +878,12 @@ A space is written before each object is (converted and) written,
|
||||||
unless the output system believes it is positioned at the beginning
|
unless the output system believes it is positioned at the beginning
|
||||||
of a line. This is the case: (1) when no characters have been written
|
of a line. This is the case: (1) when no characters have been written
|
||||||
to standard output; or (2) when the last character written to
|
to standard output; or (2) when the last character written to
|
||||||
standard output is \verb/'\n'/;
|
standard output is \verb/\n/;
|
||||||
or (3) when the last I/O operation
|
or (3) when the last I/O operation
|
||||||
on standard output was not a \verb\print\ statement.
|
on standard output was not a \verb\print\ statement.
|
||||||
|
|
||||||
Finally,
|
Finally,
|
||||||
a \verb/'\n'/ character is written at the end,
|
a \verb/\n/ character is written at the end,
|
||||||
unless the \verb\print\ statement ends with a comma.
|
unless the \verb\print\ statement ends with a comma.
|
||||||
This is the only action if the statement contains just the keyword
|
This is the only action if the statement contains just the keyword
|
||||||
\verb\print\.
|
\verb\print\.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue