mirror of https://github.com/python/cpython
Use file.write instead of print to make it easier to merge with 3k.
This commit is contained in:
parent
105f3d4fdc
commit
371d1747f9
|
@ -1106,7 +1106,7 @@ class ChainOfVisitors:
|
||||||
v.visit(object)
|
v.visit(object)
|
||||||
v.emit("", 0)
|
v.emit("", 0)
|
||||||
|
|
||||||
common_msg = "/* File automatically generated by %s. */\n"
|
common_msg = "/* File automatically generated by %s. */\n\n"
|
||||||
|
|
||||||
c_file_msg = """
|
c_file_msg = """
|
||||||
/*
|
/*
|
||||||
|
@ -1116,6 +1116,7 @@ c_file_msg = """
|
||||||
The __version__ number is set to the revision number of the commit
|
The __version__ number is set to the revision number of the commit
|
||||||
containing the grammar change.
|
containing the grammar change.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def main(srcfile):
|
def main(srcfile):
|
||||||
|
@ -1129,27 +1130,27 @@ def main(srcfile):
|
||||||
if INC_DIR:
|
if INC_DIR:
|
||||||
p = "%s/%s-ast.h" % (INC_DIR, mod.name)
|
p = "%s/%s-ast.h" % (INC_DIR, mod.name)
|
||||||
f = open(p, "wb")
|
f = open(p, "wb")
|
||||||
print >> f, auto_gen_msg
|
f.write(auto_gen_msg)
|
||||||
print >> f, '#include "asdl.h"\n'
|
f.write('#include "asdl.h"\n\n')
|
||||||
c = ChainOfVisitors(TypeDefVisitor(f),
|
c = ChainOfVisitors(TypeDefVisitor(f),
|
||||||
StructVisitor(f),
|
StructVisitor(f),
|
||||||
PrototypeVisitor(f),
|
PrototypeVisitor(f),
|
||||||
)
|
)
|
||||||
c.visit(mod)
|
c.visit(mod)
|
||||||
print >>f, "PyObject* PyAST_mod2obj(mod_ty t);"
|
f.write("PyObject* PyAST_mod2obj(mod_ty t);\n")
|
||||||
print >>f, "mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);"
|
f.write("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n")
|
||||||
print >>f, "int PyAST_Check(PyObject* obj);"
|
f.write("int PyAST_Check(PyObject* obj);\n")
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
if SRC_DIR:
|
if SRC_DIR:
|
||||||
p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")
|
p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")
|
||||||
f = open(p, "wb")
|
f = open(p, "wb")
|
||||||
print >> f, auto_gen_msg
|
f.write(auto_gen_msg)
|
||||||
print >> f, c_file_msg % parse_version(mod)
|
f.write(c_file_msg % parse_version(mod))
|
||||||
print >> f, '#include "Python.h"'
|
f.write('#include "Python.h"\n')
|
||||||
print >> f, '#include "%s-ast.h"' % mod.name
|
f.write('#include "%s-ast.h"\n' % mod.name)
|
||||||
print >> f
|
f.write('\n')
|
||||||
print >>f, "static PyTypeObject AST_type;"
|
f.write("static PyTypeObject AST_type;\n")
|
||||||
v = ChainOfVisitors(
|
v = ChainOfVisitors(
|
||||||
PyTypesDeclareVisitor(f),
|
PyTypesDeclareVisitor(f),
|
||||||
PyTypesVisitor(f),
|
PyTypesVisitor(f),
|
||||||
|
|
Loading…
Reference in New Issue