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.
This commit is contained in:
parent
e03ea37a7b
commit
b788a385cd
|
@ -16,8 +16,9 @@ import traceback
|
||||||
|
|
||||||
import spark
|
import spark
|
||||||
|
|
||||||
def output(string):
|
def output(*strings):
|
||||||
sys.stdout.write(string + "\n")
|
for s in strings:
|
||||||
|
sys.stdout.write(str(s) + "\n")
|
||||||
|
|
||||||
|
|
||||||
class Token(object):
|
class Token(object):
|
||||||
|
@ -397,7 +398,8 @@ def parse(file):
|
||||||
scanner = ASDLScanner()
|
scanner = ASDLScanner()
|
||||||
parser = ASDLParser()
|
parser = ASDLParser()
|
||||||
|
|
||||||
buf = open(file).read()
|
with open(file) as f:
|
||||||
|
buf = f.read()
|
||||||
tokens = scanner.tokenize(buf)
|
tokens = scanner.tokenize(buf)
|
||||||
try:
|
try:
|
||||||
return parser.parse(tokens)
|
return parser.parse(tokens)
|
||||||
|
@ -428,4 +430,4 @@ if __name__ == "__main__":
|
||||||
output("Check failed")
|
output("Check failed")
|
||||||
else:
|
else:
|
||||||
for dfn in mod.dfns:
|
for dfn in mod.dfns:
|
||||||
output(dfn.type)
|
output(dfn.name, dfn.value)
|
||||||
|
|
Loading…
Reference in New Issue