summaryrefslogtreecommitdiffstats
path: root/Parser/asdl_c.py
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/asdl_c.py')
-rwxr-xr-xParser/asdl_c.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 325a2b6..8c33e9d 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -718,7 +718,7 @@ class ChainOfVisitors:
v.visit(object)
v.emit("", 0)
-common_msg = "/* File automatically generated by %s. */\n"
+common_msg = "/* File automatically generated by %s. */\n\n"
c_file_msg = """
/*
@@ -728,6 +728,7 @@ c_file_msg = """
The __version__ number is set to the revision number of the commit
containing the grammar change.
*/
+
"""
def main(srcfile):
@@ -741,25 +742,25 @@ def main(srcfile):
if INC_DIR:
p = "%s/%s-ast.h" % (INC_DIR, mod.name)
f = open(p, "wb")
- print >> f, auto_gen_msg
- print >> f, '#include "asdl.h"\n'
+ f.write(auto_gen_msg)
+ f.write('#include "asdl.h"\n\n')
c = ChainOfVisitors(TypeDefVisitor(f),
StructVisitor(f),
PrototypeVisitor(f),
)
c.visit(mod)
- print >>f, "PyObject* PyAST_mod2obj(mod_ty t);"
+ f.write("PyObject* PyAST_mod2obj(mod_ty t);\n")
f.close()
if SRC_DIR:
p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")
f = open(p, "wb")
- print >> f, auto_gen_msg
- print >> f, c_file_msg % parse_version(mod)
- print >> f, '#include "Python.h"'
- print >> f, '#include "%s-ast.h"' % mod.name
- print >> f
- print >>f, "static PyTypeObject* AST_type;"
+ f.write(auto_gen_msg)
+ f.write(c_file_msg % parse_version(mod))
+ f.write('#include "Python.h"\n')
+ f.write('#include "%s-ast.h"\n' % mod.name)
+ f.write('\n')
+ f.write("static PyTypeObject* AST_type;\n")
v = ChainOfVisitors(
PyTypesDeclareVisitor(f),
PyTypesVisitor(f),
@@ -779,7 +780,7 @@ if __name__ == "__main__":
SRC_DIR = ''
opts, args = getopt.getopt(sys.argv[1:], "h:c:")
if len(opts) != 1:
- print "Must specify exactly one output file"
+ sys.stdout.write("Must specify exactly one output file\n")
sys.exit(1)
for o, v in opts:
if o == '-h':
@@ -787,6 +788,6 @@ if __name__ == "__main__":
if o == '-c':
SRC_DIR = v
if len(args) != 1:
- print "Must specify single input file"
+ sys.stdout.write("Must specify single input file\n")
sys.exit(1)
main(args[0])