annotate Lib/token.py @ 58765:2ba7677bfa95 legacy-trunk

testCopysign was defined twice in test_math; combine the definitions
author Mark Dickinson <dickinsm@gmail.com>
date Sat, 06 Feb 2010 23:11:25 +0000
parents 144e84672ef9
children 05a808bc6867
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
1 #! /usr/bin/env python
11707
6f4146846337 The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents: 7755
diff changeset
2
6f4146846337 The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents: 7755
diff changeset
3 """Token constants (from "token.h")."""
6f4146846337 The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents: 7755
diff changeset
4
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
5 # This file is automatically generated; please don't muck it up!
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
6 #
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
7 # To update the symbols in this file, 'cd' to the top directory of
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
8 # the python source tree after building the interpreter and run:
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
9 #
6519
24da035ceb6e Convert all remaining *simple* cases of regex usage to re usage.
Guido van Rossum <guido@python.org>
parents: 6406
diff changeset
10 # python Lib/token.py
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
12 #--start constants--
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 ENDMARKER = 0
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 NAME = 1
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 NUMBER = 2
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 STRING = 3
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 NEWLINE = 4
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 INDENT = 5
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 DEDENT = 6
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 LPAR = 7
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 RPAR = 8
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 LSQB = 9
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 RSQB = 10
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 COLON = 11
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 COMMA = 12
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 SEMI = 13
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 PLUS = 14
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 MINUS = 15
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 STAR = 16
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 SLASH = 17
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 VBAR = 18
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 AMPER = 19
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 LESS = 20
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 GREATER = 21
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 EQUAL = 22
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 DOT = 23
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 PERCENT = 24
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 BACKQUOTE = 25
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 LBRACE = 26
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 RBRACE = 27
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 EQEQUAL = 28
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 NOTEQUAL = 29
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 LESSEQUAL = 30
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 GREATEREQUAL = 31
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 TILDE = 32
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 CIRCUMFLEX = 33
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 LEFTSHIFT = 34
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 RIGHTSHIFT = 35
3754
d23fea248a1e Changes for new parser module (Fred Drake)
Guido van Rossum <guido@python.org>
parents: 1407
diff changeset
49 DOUBLESTAR = 36
14165
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
50 PLUSEQUAL = 37
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
51 MINEQUAL = 38
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
52 STAREQUAL = 39
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
53 SLASHEQUAL = 40
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
54 PERCENTEQUAL = 41
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
55 AMPEREQUAL = 42
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
56 VBAREQUAL = 43
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
57 CIRCUMFLEXEQUAL = 44
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
58 LEFTSHIFTEQUAL = 45
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
59 RIGHTSHIFTEQUAL = 46
01846568d147 Update for augmented assignment.
Thomas Wouters <thomas@python.org>
parents: 11707
diff changeset
60 DOUBLESTAREQUAL = 47
19059
c979625feb49 Regenerated token.py to account for new DOUBLESLASH and DOUBLESLASHEQUAL.
Tim Peters <tim.peters@gmail.com>
parents: 16548
diff changeset
61 DOUBLESLASH = 48
c979625feb49 Regenerated token.py to account for new DOUBLESLASH and DOUBLESLASHEQUAL.
Tim Peters <tim.peters@gmail.com>
parents: 16548
diff changeset
62 DOUBLESLASHEQUAL = 49
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 25537
diff changeset
63 AT = 50
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 25537
diff changeset
64 OP = 51
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 25537
diff changeset
65 ERRORTOKEN = 52
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 25537
diff changeset
66 N_TOKENS = 53
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
67 NT_OFFSET = 256
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
68 #--end constants--
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
69
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 tok_name = {}
6406
81154a51c16e Reduced number of temporary names used at module scope. Use underscores in
Fred Drake <fdrake@acm.org>
parents: 4084
diff changeset
71 for _name, _value in globals().items():
81154a51c16e Reduced number of temporary names used at module scope. Use underscores in
Fred Drake <fdrake@acm.org>
parents: 4084
diff changeset
72 if type(_value) is type(0):
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
73 tok_name[_value] = _name
45520
144e84672ef9 Issue 2117. Update compiler module to handle class decorators.
Facundo Batista <facundobatista@gmail.com>
parents: 32888
diff changeset
74 del _name, _value
6406
81154a51c16e Reduced number of temporary names used at module scope. Use underscores in
Fred Drake <fdrake@acm.org>
parents: 4084
diff changeset
75
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
76
3754
d23fea248a1e Changes for new parser module (Fred Drake)
Guido van Rossum <guido@python.org>
parents: 1407
diff changeset
77 def ISTERMINAL(x):
d23fea248a1e Changes for new parser module (Fred Drake)
Guido van Rossum <guido@python.org>
parents: 1407
diff changeset
78 return x < NT_OFFSET
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
79
3754
d23fea248a1e Changes for new parser module (Fred Drake)
Guido van Rossum <guido@python.org>
parents: 1407
diff changeset
80 def ISNONTERMINAL(x):
d23fea248a1e Changes for new parser module (Fred Drake)
Guido van Rossum <guido@python.org>
parents: 1407
diff changeset
81 return x >= NT_OFFSET
d23fea248a1e Changes for new parser module (Fred Drake)
Guido van Rossum <guido@python.org>
parents: 1407
diff changeset
82
d23fea248a1e Changes for new parser module (Fred Drake)
Guido van Rossum <guido@python.org>
parents: 1407
diff changeset
83 def ISEOF(x):
d23fea248a1e Changes for new parser module (Fred Drake)
Guido van Rossum <guido@python.org>
parents: 1407
diff changeset
84 return x == ENDMARKER
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
85
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
86
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
87 def main():
6519
24da035ceb6e Convert all remaining *simple* cases of regex usage to re usage.
Guido van Rossum <guido@python.org>
parents: 6406
diff changeset
88 import re
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
89 import sys
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
90 args = sys.argv[1:]
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
91 inFileName = args and args[0] or "Include/token.h"
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
92 outFileName = "Lib/token.py"
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
93 if len(args) > 1:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
94 outFileName = args[1]
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
95 try:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
96 fp = open(inFileName)
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
97 except IOError, err:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
98 sys.stdout.write("I/O error: %s\n" % str(err))
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
99 sys.exit(1)
16514
90c600a819e9 String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 14165
diff changeset
100 lines = fp.read().split("\n")
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
101 fp.close()
6519
24da035ceb6e Convert all remaining *simple* cases of regex usage to re usage.
Guido van Rossum <guido@python.org>
parents: 6406
diff changeset
102 prog = re.compile(
25537
61d624f5c107 Updates to track Grammar changes. The patch to token.py loosens the regexp to
Michael W. Hudson <mwh@python.net>
parents: 19229
diff changeset
103 "#define[ \t][ \t]*([A-Z0-9][A-Z0-9_]*)[ \t][ \t]*([0-9][0-9]*)",
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
104 re.IGNORECASE)
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
105 tokens = {}
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
106 for line in lines:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
107 match = prog.match(line)
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
108 if match:
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
109 name, val = match.group(1, 2)
16548
da8681f17b50 String method cleanup.
Eric S. Raymond <esr@thyrsus.com>
parents: 16514
diff changeset
110 val = int(val)
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
111 tokens[val] = name # reverse so we can sort them...
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
112 keys = tokens.keys()
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
113 keys.sort()
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
114 # load the output skeleton from the target:
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
115 try:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
116 fp = open(outFileName)
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
117 except IOError, err:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
118 sys.stderr.write("I/O error: %s\n" % str(err))
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
119 sys.exit(2)
16514
90c600a819e9 String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 14165
diff changeset
120 format = fp.read().split("\n")
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
121 fp.close()
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
122 try:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
123 start = format.index("#--start constants--") + 1
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
124 end = format.index("#--end constants--")
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
125 except ValueError:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
126 sys.stderr.write("target does not contain format markers")
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
127 sys.exit(3)
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
128 lines = []
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
129 for val in keys:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
130 lines.append("%s = %d" % (tokens[val], val))
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
131 format[start:end] = lines
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
132 try:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
133 fp = open(outFileName, 'w')
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
134 except IOError, err:
7755
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
135 sys.stderr.write("I/O error: %s\n" % str(err))
fb4b4d069cc7 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6519
diff changeset
136 sys.exit(4)
16514
90c600a819e9 String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 14165
diff changeset
137 fp.write("\n".join(format))
4084
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
138 fp.close()
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
139
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
140
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
141 if __name__ == "__main__":
7f83e24d1d86 New batch from Fred
Guido van Rossum <guido@python.org>
parents: 3754
diff changeset
142 main()