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:
68 for _name
, _value
in globals().items():
69 if type(_value
) is type(0):
70 tok_name
[_value
] = _name
88 inFileName
= args
and args
[0] or "Include/token.h"
89 outFileName
= "Lib/token.py"
95 sys
.stdout
.write("I/O error: %s\n" % str(err
))
97 lines
= fp
.read().split("\n")
100 "#define[ \t][ \t]*([A-Z][A-Z_]*)[ \t][ \t]*([0-9][0-9]*)",
104 match
= prog
.match(line
)
106 name
, val
= match
.group(1, 2)
108 tokens
[val
] = name
# reverse so we can sort them...
111 # load the output skeleton from the target:
113 fp
= open(outFileName
)
115 sys
.stderr
.write("I/O error: %s\n" % str(err
))
117 format
= fp
.read().split("\n")
120 start
= format
.index("#--start constants--") + 1
121 end
= format
.index("#--end constants--")
123 sys
.stderr
.write("target does not contain format markers")
127 lines
.append("%s = %d" % (tokens
[val
], val
))
128 format
[start
:end
] = lines
130 fp
= open(outFileName
, 'w')
132 sys
.stderr
.write("I/O error: %s\n" % str(err
))
134 fp
.write("\n".join(format
))
138 if __name__
== "__main__":