annotate Doc/lib/libtokenize.tex @ 15842:f6cd36498a50 legacy-trunk

Document extensions to .pth files.
author Martin v. Löwis <martin@v.loewis.de>
date Sat, 13 Jan 2001 09:54:41 +0000
parents eea1ab028f43
children bc89f116160b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10238
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 \section{\module{tokenize} ---
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 Tokenizer for Python source}
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 \declaremodule{standard}{tokenize}
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
5 \modulesynopsis{Lexical scanner for Python source code.}
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6 \moduleauthor{Ka Ping Yee}{}
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7 \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 The \module{tokenize} module provides a lexical scanner for Python
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
11 source code, implemented in Python. The scanner in this module
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
12 returns comments as tokens as well, making it useful for implementing
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13 ``pretty-printers,'' including colorizers for on-screen displays.
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14
10728
eea1ab028f43 Fix a couple of grammatical errors reported by Detlef Lannert
Fred Drake <fdrake@acm.org>
parents: 10238
diff changeset
15 The scanner is exposed by a single function:
10238
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18 \begin{funcdesc}{tokenize}{readline\optional{, tokeneater}}
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19 The \function{tokenize()} function accepts two parameters: one
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
20 representing the input stream, and one providing an output mechanism
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21 for \function{tokenize()}.
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
22
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23 The first parameter, \var{readline}, must be a callable object which
10728
eea1ab028f43 Fix a couple of grammatical errors reported by Detlef Lannert
Fred Drake <fdrake@acm.org>
parents: 10238
diff changeset
24 provides the same interface as the \method{readline()} method of
10238
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25 built-in file objects (see section~\ref{bltin-file-objects}). Each
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
26 call to the function should return one line of input as a string.
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
28 The second parameter, \var{tokeneater}, must also be a callable
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
29 object. It is called with five parameters: the token type, the
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
30 token string, a tuple \code{(\var{srow}, \var{scol})} specifying the
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
31 row and column where the token begins in the source, a tuple
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
32 \code{(\var{erow}, \var{ecol})} giving the ending position of the
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33 token, and the line on which the token was found. The line passed
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 is the \emph{logical} line; continuation lines are included.
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35 \end{funcdesc}
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38 All constants from the \refmodule{token} module are also exported from
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
39 \module{tokenize}, as is one additional token type value that might be
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40 passed to the \var{tokeneater} function by \function{tokenize()}:
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
41
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
42 \begin{datadesc}{COMMENT}
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
43 Token value used to indicate a comment.
86642b7a7a60 Documentation for pyclbr and tokenize modules.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
44 \end{datadesc}