Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b788a38

Browse files
committed
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.
1 parent e03ea37 commit b788a38

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Parser/asdl.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
import spark
1818

19-
def output(string):
20-
sys.stdout.write(string + "\n")
19+
def output(*strings):
20+
for s in strings:
21+
sys.stdout.write(str(s) + "\n")
2122

2223

2324
class Token(object):
@@ -397,7 +398,8 @@ def parse(file):
397398
scanner = ASDLScanner()
398399
parser = ASDLParser()
399400

400-
buf = open(file).read()
401+
with open(file) as f:
402+
buf = f.read()
401403
tokens = scanner.tokenize(buf)
402404
try:
403405
return parser.parse(tokens)
@@ -428,4 +430,4 @@ def parse(file):
428430
output("Check failed")
429431
else:
430432
for dfn in mod.dfns:
431-
output(dfn.type)
433+
output(dfn.name, dfn.value)

0 commit comments

Comments
 (0)