Added 'description' class attribute to every command class (to help the
[python/dscho.git] / Lib / keyword.py
blob3cf8a2e7af9a38175c58f7c505ba94a95d7b29ff
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
12 kwlist = [
13 #--start keywords--
14 'and',
15 'assert',
16 'break',
17 'class',
18 'continue',
19 'def',
20 'del',
21 'elif',
22 'else',
23 'except',
24 'exec',
25 'finally',
26 'for',
27 'from',
28 'global',
29 'if',
30 'import',
31 'in',
32 'is',
33 'lambda',
34 'not',
35 'or',
36 'pass',
37 'print',
38 'raise',
39 'return',
40 'try',
41 'while',
42 #--end keywords--
45 kwdict = {}
46 for keyword in kwlist:
47 kwdict[keyword] = 1
49 iskeyword = kwdict.has_key
51 def main():
52 import sys, re, string
54 args = sys.argv[1:]
55 iptfile = args and args[0] or "Python/graminit.c"
56 if len(args) > 1: optfile = args[1]
57 else: optfile = "Lib/keyword.py"
59 # scan the source file for keywords
60 fp = open(iptfile)
61 strprog = re.compile('"([^"]+)"')
62 lines = []
63 while 1:
64 line = fp.readline()
65 if not line: break
66 if string.find(line, '{1, "') > -1:
67 match = strprog.search(line)
68 if match:
69 lines.append(" '" + match.group(1) + "',\n")
70 fp.close()
71 lines.sort()
73 # load the output skeleton from the target
74 fp = open(optfile)
75 format = fp.readlines()
76 fp.close()
78 # insert the lines of keywords
79 try:
80 start = format.index("#--start keywords--\n") + 1
81 end = format.index("#--end keywords--\n")
82 format[start:end] = lines
83 except ValueError:
84 sys.stderr.write("target does not contain format markers\n")
85 sys.exit(1)
87 # write the output file
88 fp = open(optfile, 'w')
89 fp.write(string.join(format, ''))
90 fp.close()
92 if __name__ == "__main__":
93 main()