summaryrefslogtreecommitdiff
path: root/Parser
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-04-14 15:02:32 +0000
committerMartin v. Löwis <martin@v.loewis.de>2006-04-14 15:02:32 +0000
commit717bb53a5cf5eda3600a24d0c2664511184220fa (patch)
treed5b53bcef21cda7f52227793db32eda291a95de2 /Parser
parent32128ff9d62bef8959a6f75c76a59915eb979da1 (diff)
downloadcpython-717bb53a5cf5eda3600a24d0c2664511184220fa.tar.gz
Patch #1355883: Build Python-ast.c and Python-ast.h
independently. Fixes #1355883.
Diffstat (limited to 'Parser')
-rwxr-xr-xParser/asdl_c.py60
1 files changed, 30 insertions, 30 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 6a8d981cd1..b6d9830d37 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -726,39 +726,35 @@ def main(srcfile):
sys.exit(1)
if INC_DIR:
p = "%s/%s-ast.h" % (INC_DIR, mod.name)
- else:
- p = "%s-ast.h" % mod.name
- f = open(p, "wb")
- print >> f, auto_gen_msg
- print >> f, '#include "asdl.h"\n'
- c = ChainOfVisitors(TypeDefVisitor(f),
- StructVisitor(f),
- PrototypeVisitor(f),
- )
- c.visit(mod)
- print >>f, "PyObject* PyAST_mod2obj(mod_ty t);"
- f.close()
+ f = open(p, "wb")
+ print >> f, auto_gen_msg
+ print >> f, '#include "asdl.h"\n'
+ c = ChainOfVisitors(TypeDefVisitor(f),
+ StructVisitor(f),
+ PrototypeVisitor(f),
+ )
+ c.visit(mod)
+ print >>f, "PyObject* PyAST_mod2obj(mod_ty t);"
+ f.close()
if SRC_DIR:
p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")
- else:
- p = "%s-ast.c" % mod.name
- f = open(p, "wb")
- print >> f, auto_gen_msg
- print >> f, '#include "Python.h"'
- print >> f, '#include "%s-ast.h"' % mod.name
- print >> f
- print >>f, "static PyTypeObject* AST_type;"
- v = ChainOfVisitors(
- PyTypesDeclareVisitor(f),
- PyTypesVisitor(f),
- FunctionVisitor(f),
- ObjVisitor(f),
- ASTModuleVisitor(f),
- PartingShots(f),
- )
- v.visit(mod)
- f.close()
+ f = open(p, "wb")
+ print >> f, auto_gen_msg
+ print >> f, '#include "Python.h"'
+ print >> f, '#include "%s-ast.h"' % mod.name
+ print >> f
+ print >>f, "static PyTypeObject* AST_type;"
+ v = ChainOfVisitors(
+ PyTypesDeclareVisitor(f),
+ PyTypesVisitor(f),
+ FunctionVisitor(f),
+ ObjVisitor(f),
+ ASTModuleVisitor(f),
+ PartingShots(f),
+ )
+ v.visit(mod)
+ f.close()
if __name__ == "__main__":
import sys
@@ -767,6 +763,9 @@ if __name__ == "__main__":
INC_DIR = ''
SRC_DIR = ''
opts, args = getopt.getopt(sys.argv[1:], "h:c:")
+ if len(opts) != 1:
+ print "Must specify exactly one output file"
+ sys.exit(1)
for o, v in opts:
if o == '-h':
INC_DIR = v
@@ -774,4 +773,5 @@ if __name__ == "__main__":
SRC_DIR = v
if len(args) != 1:
print "Must specify single input file"
+ sys.exit(1)
main(args[0])