summaryrefslogtreecommitdiffstats
path: root/Parser/asdl.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-09-26 13:31:32 (GMT)
committerEli Bendersky <eliben@gmail.com>2013-09-26 13:31:32 (GMT)
commitb788a385cd0fa71ba068a16c237e220a03862dc7 (patch)
tree100ab841350839f90706651afb196dea0b896e39 /Parser/asdl.py
parente03ea37a7bea48c46e6d96851f471db0f3c8e6e2 (diff)
downloadcpython-b788a385cd0fa71ba068a16c237e220a03862dc7.zip
cpython-b788a385cd0fa71ba068a16c237e220a03862dc7.tar.gz
cpython-b788a385cd0fa71ba068a16c237e220a03862dc7.tar.bz2
Small fixes in Parser/asdl.py - no change in functionality.
1. Make it work when invoked directly from the command-line. It was failing due to a couple of stale function/class usages in the __main__ section. 2. Close the parsed file in the parse() function after opening it.
Diffstat (limited to 'Parser/asdl.py')
-rw-r--r--Parser/asdl.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Parser/asdl.py b/Parser/asdl.py
index 7df76c0..25987b8 100644
--- a/Parser/asdl.py
+++ b/Parser/asdl.py
@@ -16,8 +16,9 @@ import traceback
import spark
-def output(string):
- sys.stdout.write(string + "\n")
+def output(*strings):
+ for s in strings:
+ sys.stdout.write(str(s) + "\n")
class Token(object):
@@ -397,7 +398,8 @@ def parse(file):
scanner = ASDLScanner()
parser = ASDLParser()
- buf = open(file).read()
+ with open(file) as f:
+ buf = f.read()
tokens = scanner.tokenize(buf)
try:
return parser.parse(tokens)
@@ -428,4 +430,4 @@ if __name__ == "__main__":
output("Check failed")
else:
for dfn in mod.dfns:
- output(dfn.type)
+ output(dfn.name, dfn.value)