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.
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):
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)
output("Check failed")
else:
for dfn in mod.dfns:
- output(dfn.type)
+ output(dfn.name, dfn.value)