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:
70 for _name
, _value
in globals().items():
71 if type(_value
) is type(0):
72 tok_name
[_value
] = _name
89 inFileName
= args
and args
[0] or "Include/token.h"
90 outFileName
= "Lib/token.py"
96 sys
.stdout
.write("I/O error: %s\n" % str(err
))
98 lines
= fp
.read().split("\n")
101 "#define[ \t][ \t]*([A-Z][A-Z_]*)[ \t][ \t]*([0-9][0-9]*)",
105 match
= prog
.match(line
)
107 name
, val
= match
.group(1, 2)
109 tokens
[val
] = name
# reverse so we can sort them...
112 # load the output skeleton from the target:
114 fp
= open(outFileName
)
116 sys
.stderr
.write("I/O error: %s\n" % str(err
))
118 format
= fp
.read().split("\n")
121 start
= format
.index("#--start constants--") + 1
122 end
= format
.index("#--end constants--")
124 sys
.stderr
.write("target does not contain format markers")
128 lines
.append("%s = %d" % (tokens
[val
], val
))
129 format
[start
:end
] = lines
131 fp
= open(outFileName
, 'w')
133 sys
.stderr
.write("I/O error: %s\n" % str(err
))
135 fp
.write("\n".join(format
))
139 if __name__
== "__main__":