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:
47 for keyword
in kwlist
:
50 iskeyword
= kwdict
.has_key
53 import sys
, re
, string
56 iptfile
= args
and args
[0] or "Python/graminit.c"
57 if len(args
) > 1: optfile
= args
[1]
58 else: optfile
= "Lib/keyword.py"
60 # scan the source file for keywords
62 strprog
= re
.compile('"([^"]+)"')
67 if string
.find(line
, '{1, "') > -1:
68 match
= strprog
.search(line
)
70 lines
.append(" '" + match
.group(1) + "',\n")
74 # load the output skeleton from the target
76 format
= fp
.readlines()
79 # insert the lines of keywords
81 start
= format
.index("#--start keywords--\n") + 1
82 end
= format
.index("#--end keywords--\n")
83 format
[start
:end
] = lines
85 sys
.stderr
.write("target does not contain format markers\n")
88 # write the output file
89 fp
= open(optfile
, 'w')
90 fp
.write(string
.join(format
, ''))
93 if __name__
== "__main__":