git @ Cat's Eye Technologies Unlikely / 6c96ef4
Adapt code to run under both Python 2 and Python 3. Chris Pressey 2 years ago
4 changed file(s) with 13 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
1616
1717
1818 def load(filename, options):
19 f = open(filename, "r")
19 f = open(filename, "rb")
2020 scanner = Scanner(f.read())
2121 f.close()
2222 parser = ClassBaseParser(scanner, stdlib)
2323 parser.parse()
2424 if options.dump_ast:
25 print "---AST---"
26 print str(stdlib)
25 print("---AST---")
26 print(str(stdlib))
2727
2828
2929 def main(argv):
1212 A lexical scanner.
1313 """
1414
15 def __init__(self, input):
15 def __init__(self, input_):
1616 """
1717 Create a new Scanner object that will consume the given
1818 UTF-8 encoded input string.
1919 """
20 self._input = unicode(input, 'utf-8')
20 self._input = input_.decode('utf-8')
2121 self._token = None
2222 self.scan()
2323
8888 """
8989 Log the given scan error.
9090 """
91 print "error: " + str
91 print("error: " + str)
9292 self.scan()
66 Pre-built AST representing built-in Unlikely classes.
77 """
88
9 import ast
9 from .ast import ClassBase
1010
11 stdlib = ast.ClassBase()
11 stdlib = ClassBase()
1212
1313 continuation = stdlib.add_class_defn_by_name("Continuation", None,
1414 ["saturated", "abstract"])
44
55 -> Functionality "Parse Unlikely Program" is implemented by
66 -> shell command
7 -> "python src/coldwater.py %(test-body-file)"
7 -> "python2 src/coldwater.py %(test-body-file)"
8
9 -> Functionality "Parse Unlikely Program" is implemented by
10 -> shell command
11 -> "python3 src/coldwater.py %(test-body-file)"
812
913 Here is a syntactically correct program.
1014