git @ Cat's Eye Technologies Unlikely / c725abd
Merge pull request #2 from catseye/support-python-3 Support python 3 Chris Pressey authored 4 months ago GitHub committed 4 months ago
7 changed file(s) with 35 addition(s) and 13 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"])
00 #!/bin/sh
11
2 falderal --substring-error tests/Unlikely.markdown
2 APPLIANCES=""
3 MISSING=""
4
5 if command -v python2 > /dev/null 2>&1; then
6 APPLIANCES="$APPLIANCES tests/appliances/coldwater.py2.md"
7 else
8 MISSING="${MISSING}2"
9 fi
10
11 if command -v python3 > /dev/null 2>&1; then
12 APPLIANCES="$APPLIANCES tests/appliances/coldwater.py3.md"
13 else
14 MISSING="${MISSING}3"
15 fi
16
17 if [ "x${MISSING}" = "x23" ]; then
18 echo "Neither python2 nor python3 found on executable search path. Aborting."
19 exit 1
20 fi
21
22 falderal $APPLIANCES tests/Unlikely.markdown || exit 1
11 ==================
22
33 -> Tests for functionality "Parse Unlikely Program"
4
5 -> Functionality "Parse Unlikely Program" is implemented by
6 -> shell command
7 -> "python src/coldwater.py %(test-body-file)"
84
95 Here is a syntactically correct program.
106
0 -> Functionality "Parse Unlikely Program" is implemented by
1 -> shell command
2 -> "python2 src/coldwater.py %(test-body-file)"
0 -> Functionality "Parse Unlikely Program" is implemented by
1 -> shell command
2 -> "python3 src/coldwater.py %(test-body-file)"