summaryrefslogtreecommitdiffstats
path: root/Doc/ref/ref2.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/ref/ref2.tex')
-rw-r--r--Doc/ref/ref2.tex68
1 files changed, 34 insertions, 34 deletions
diff --git a/Doc/ref/ref2.tex b/Doc/ref/ref2.tex
index b093998..8724c49 100644
--- a/Doc/ref/ref2.tex
+++ b/Doc/ref/ref2.tex
@@ -1,7 +1,7 @@
\chapter{Lexical analysis}
-A Python program is read by a {\em parser}. Input to the parser is a
-stream of {\em tokens}, generated by the {\em lexical analyzer}. This
+A Python program is read by a \emph{parser}. Input to the parser is a
+stream of \emph{tokens}, generated by the \emph{lexical analyzer}. This
chapter describes how the lexical analyzer breaks a file into tokens.
\index{lexical analysis}
\index{parser}
@@ -19,7 +19,7 @@ syntax (e.g. between statements in compound statements).
\subsection{Comments}
-A comment starts with a hash character (\verb@#@) that is not part of
+A comment starts with a hash character (\code{\#}) that is not part of
a string literal, and ends at the end of the physical line. A comment
always signifies the end of the logical line. Comments are ignored by
the syntax.
@@ -31,7 +31,7 @@ the syntax.
\subsection{Explicit line joining}
Two or more physical lines may be joined into logical lines using
-backslash characters (\verb/\/), as follows: when a physical line ends
+backslash characters (\code{\e}), as follows: when a physical line ends
in a backslash that is not part of a string literal or comment, it is
joined with the following forming a single logical line, deleting the
backslash and the following end-of-line character. For example:
@@ -91,7 +91,7 @@ turn is used to determine the grouping of statements.
First, tabs are replaced (from left to right) by one to eight spaces
such that the total number of characters up to there is a multiple of
-eight (this is intended to be the same rule as used by {\UNIX}). The
+eight (this is intended to be the same rule as used by \UNIX{}). The
total number of spaces preceding the first non-blank character then
determines the line's indentation. Indentation cannot be split over
multiple physical lines using backslashes.
@@ -107,7 +107,7 @@ the stack will always be strictly increasing from bottom to top. At
the beginning of each logical line, the line's indentation level is
compared to the top of the stack. If it is equal, nothing happens.
If it is larger, it is pushed on the stack, and one INDENT token is
-generated. If it is smaller, it {\em must} be one of the numbers
+generated. If it is smaller, it \emph{must} be one of the numbers
occurring on the stack; all numbers on the stack that are larger are
popped off, and for each number popped off a DEDENT token is
generated. At the end of the file, a DEDENT token is generated for
@@ -145,7 +145,7 @@ The following example shows various indentation errors:
(Actually, the first three errors are detected by the parser; only the
last error is found by the lexical analyzer --- the indentation of
-\verb@return r@ does not match a level popped off the stack.)
+\code{return r} does not match a level popped off the stack.)
\section{Other tokens}
@@ -174,10 +174,10 @@ Identifiers are unlimited in length. Case is significant.
\subsection{Keywords}
-The following identifiers are used as reserved words, or {\em
-keywords} of the language, and cannot be used as ordinary
-identifiers. They must be spelled exactly as written here:
-\index{keyword}
+The following identifiers are used as reserved words, or
+\emph{keywords} of the language, and cannot be used as ordinary
+identifiers. They must be spelled exactly as written here:%
+\index{keyword}%
\index{reserved word}
\begin{verbatim}
@@ -212,13 +212,13 @@ shortstringchar: <any ASCII character except "\" or newline or the quote>
longstringchar: <any ASCII character except "\">
escapeseq: "\" <any ASCII character>
\end{verbatim}
-\index{ASCII}
+\index{ASCII@\ASCII{}}
In ``long strings'' (strings surrounded by sets of three quotes),
unescaped newlines and quotes are allowed (and are retained), except
that three unescaped quotes in a row terminate the string. (A
``quote'' is the character used to open the string, i.e. either
-\verb/'/ or \verb/"/.)
+\code{'} or \code{"}.)
Escape sequences in strings are interpreted according to rules similar
to those used by Standard C. The recognized escape sequences are:
@@ -230,32 +230,32 @@ to those used by Standard C. The recognized escape sequences are:
\begin{center}
\begin{tabular}{|l|l|}
\hline
-\verb/\/{\em newline} & Ignored \\
-\verb/\\/ & Backslash (\verb/\/) \\
-\verb/\'/ & Single quote (\verb/'/) \\
-\verb/\"/ & Double quote (\verb/"/) \\
-\verb/\a/ & \ASCII{} Bell (BEL) \\
-\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...} \\
+\code{\e}\emph{newline} & Ignored \\
+\code{\e\e} & Backslash (\code{\e}) \\
+\code{\e'} & Single quote (\code{'}) \\
+\code{\e"} & Double quote (\code{"}) \\
+\code{\e a} & \ASCII{} Bell (BEL) \\
+\code{\e b} & \ASCII{} Backspace (BS) \\
+%\code{\e E} & \ASCII{} Escape (ESC) \\
+\code{\e f} & \ASCII{} Formfeed (FF) \\
+\code{\e n} & \ASCII{} Linefeed (LF) \\
+\code{\e r} & \ASCII{} Carriage Return (CR) \\
+\code{\e t} & \ASCII{} Horizontal Tab (TAB) \\
+\code{\e v} & \ASCII{} Vertical Tab (VT) \\
+\code{\e}\emph{ooo} & \ASCII{} character with octal value \emph{ooo} \\
+\code{\e x}\emph{xx...} & \ASCII{} character with hex value \emph{xx...} \\
\hline
\end{tabular}
\end{center}
-\index{ASCII}
+\index{ASCII@\ASCII{}}
-In strict compatibility with Standard C, up to three octal digits are
+In strict compatibility with 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 in all current implementations...).
All unrecognized escape sequences are left in the string unchanged,
-i.e., {\em the backslash is left in the string.} (This behavior is
+i.e., \emph{the backslash is left in the string.} (This behavior is
useful when debugging: if an escape sequence is mistyped, the
resulting output is more easily recognized as broken. It also helps a
great deal for string literals used as regular expressions or
@@ -331,8 +331,8 @@ Some examples of floating point literals:
\end{verbatim}
Note that numeric literals do not include a sign; a phrase like
-\verb@-1@ is actually an expression composed of the operator
-\verb@-@ and the literal \verb@1@.
+\code{-1} is actually an expression composed of the operator
+\code{-} and the literal \code{1}.
\section{Operators}
@@ -345,7 +345,7 @@ The following tokens are operators:
< == > <= <> != >=
\end{verbatim}
-The comparison operators \verb@<>@ and \verb@!=@ are alternate
+The comparison operators \code{<>} and \code{!=} are alternate
spellings of the same operator.
\section{Delimiters}
@@ -363,7 +363,7 @@ meaning:
The following printing \ASCII{} characters are not used in Python. Their
occurrence outside string literals and comments is an unconditional
error:
-\index{ASCII}
+\index{ASCII@\ASCII{}}
\begin{verbatim}
@ $ ?