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
90 inFileName
= args
and args
[0] or "Include/token.h"
91 outFileName
= "Lib/token.py"
97 sys
.stdout
.write("I/O error: %s\n" % str(err
))
99 lines
= fp
.read().split("\n")
102 "#define[ \t][ \t]*([A-Z0-9][A-Z0-9_]*)[ \t][ \t]*([0-9][0-9]*)",
106 match
= prog
.match(line
)
108 name
, val
= match
.group(1, 2)
110 tokens
[val
] = name
# reverse so we can sort them...
113 # load the output skeleton from the target:
115 fp
= open(outFileName
)
117 sys
.stderr
.write("I/O error: %s\n" % str(err
))
119 format
= fp
.read().split("\n")
122 start
= format
.index("#--start constants--") + 1
123 end
= format
.index("#--end constants--")
125 sys
.stderr
.write("target does not contain format markers")
129 lines
.append("%s = %d" % (tokens
[val
], val
))
130 format
[start
:end
] = lines
132 fp
= open(outFileName
, 'w')
134 sys
.stderr
.write("I/O error: %s\n" % str(err
))
136 fp
.write("\n".join(format
))
140 if __name__
== "__main__":