Merge pull request #2 from catseye/support-python-3
Support python 3
Chris Pressey authored 4 months ago
GitHub committed 4 months ago
16 | 16 |
|
17 | 17 |
|
18 | 18 |
def load(filename, options):
|
19 | |
f = open(filename, "r")
|
|
19 |
f = open(filename, "rb")
|
20 | 20 |
scanner = Scanner(f.read())
|
21 | 21 |
f.close()
|
22 | 22 |
parser = ClassBaseParser(scanner, stdlib)
|
23 | 23 |
parser.parse()
|
24 | 24 |
if options.dump_ast:
|
25 | |
print "---AST---"
|
26 | |
print str(stdlib)
|
|
25 |
print("---AST---")
|
|
26 |
print(str(stdlib))
|
27 | 27 |
|
28 | 28 |
|
29 | 29 |
def main(argv):
|
12 | 12 |
A lexical scanner.
|
13 | 13 |
"""
|
14 | 14 |
|
15 | |
def __init__(self, input):
|
|
15 |
def __init__(self, input_):
|
16 | 16 |
"""
|
17 | 17 |
Create a new Scanner object that will consume the given
|
18 | 18 |
UTF-8 encoded input string.
|
19 | 19 |
"""
|
20 | |
self._input = unicode(input, 'utf-8')
|
|
20 |
self._input = input_.decode('utf-8')
|
21 | 21 |
self._token = None
|
22 | 22 |
self.scan()
|
23 | 23 |
|
|
88 | 88 |
"""
|
89 | 89 |
Log the given scan error.
|
90 | 90 |
"""
|
91 | |
print "error: " + str
|
|
91 |
print("error: " + str)
|
92 | 92 |
self.scan()
|
6 | 6 |
Pre-built AST representing built-in Unlikely classes.
|
7 | 7 |
"""
|
8 | 8 |
|
9 | |
import ast
|
|
9 |
from .ast import ClassBase
|
10 | 10 |
|
11 | |
stdlib = ast.ClassBase()
|
|
11 |
stdlib = ClassBase()
|
12 | 12 |
|
13 | 13 |
continuation = stdlib.add_class_defn_by_name("Continuation", None,
|
14 | 14 |
["saturated", "abstract"])
|
0 | 0 |
#!/bin/sh
|
1 | 1 |
|
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
|
1 | 1 |
==================
|
2 | 2 |
|
3 | 3 |
-> 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)"
|
8 | 4 |
|
9 | 5 |
Here is a syntactically correct program.
|
10 | 6 |
|
|
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)"
|