Update version number and release date.
[python/dscho.git] / Lib / keyword.py
blobc89708157f28f83d0bf4fff16c25ea2bb7066a03
1 #! /usr/bin/env python
3 """Keywords (from "graminit.c")
5 This file is automatically generated; please don't muck it up!
7 To update the symbols in this file, 'cd' to the top directory of
8 the python source tree after building the interpreter and run:
10 python Lib/keyword.py
11 """
13 __all__ = ["iskeyword", "kwlist"]
15 kwlist = [
16 #--start keywords--
17 'and',
18 'assert',
19 'break',
20 'class',
21 'continue',
22 'def',
23 'del',
24 'elif',
25 'else',
26 'except',
27 'exec',
28 'finally',
29 'for',
30 'from',
31 'global',
32 'if',
33 'import',
34 'in',
35 'is',
36 'lambda',
37 'not',
38 'or',
39 'pass',
40 'print',
41 'raise',
42 'return',
43 'try',
44 'while',
45 'yield',
46 #--end keywords--
49 kwdict = {}
50 for keyword in kwlist:
51 kwdict[keyword] = 1
53 iskeyword = kwdict.has_key
55 def main():
56 import sys, re
58 args = sys.argv[1:]
59 iptfile = args and args[0] or "Python/graminit.c"
60 if len(args) > 1: optfile = args[1]
61 else: optfile = "Lib/keyword.py"
63 # scan the source file for keywords
64 fp = open(iptfile)
65 strprog = re.compile('"([^"]+)"')
66 lines = []
67 while 1:
68 line = fp.readline()
69 if not line: break
70 if line.find('{1, "') > -1:
71 match = strprog.search(line)
72 if match:
73 lines.append(" '" + match.group(1) + "',\n")
74 fp.close()
75 lines.sort()
77 # load the output skeleton from the target
78 fp = open(optfile)
79 format = fp.readlines()
80 fp.close()
82 # insert the lines of keywords
83 try:
84 start = format.index("#--start keywords--\n") + 1
85 end = format.index("#--end keywords--\n")
86 format[start:end] = lines
87 except ValueError:
88 sys.stderr.write("target does not contain format markers\n")
89 sys.exit(1)
91 # write the output file
92 fp = open(optfile, 'w')
93 fp.write(''.join(format))
94 fp.close()
96 if __name__ == "__main__":
97 main()