3 """Token constants (from "token.h")."""
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:
71 for _name
, _value
in globals().items():
72 if type(_value
) is type(0):
73 tok_name
[_value
] = _name
91 inFileName
= args
and args
[0] or "Include/token.h"
92 outFileName
= "Lib/token.py"
98 sys
.stdout
.write("I/O error: %s\n" % str(err
))
100 lines
= fp
.read().split("\n")
103 "#define[ \t][ \t]*([A-Z0-9][A-Z0-9_]*)[ \t][ \t]*([0-9][0-9]*)",
107 match
= prog
.match(line
)
109 name
, val
= match
.group(1, 2)
111 tokens
[val
] = name
# reverse so we can sort them...
114 # load the output skeleton from the target:
116 fp
= open(outFileName
)
118 sys
.stderr
.write("I/O error: %s\n" % str(err
))
120 format
= fp
.read().split("\n")
123 start
= format
.index("#--start constants--") + 1
124 end
= format
.index("#--end constants--")
126 sys
.stderr
.write("target does not contain format markers")
130 lines
.append("%s = %d" % (tokens
[val
], val
))
131 format
[start
:end
] = lines
133 fp
= open(outFileName
, 'w')
135 sys
.stderr
.write("I/O error: %s\n" % str(err
))
137 fp
.write("\n".join(format
))
141 if __name__
== "__main__":