Nudge towards supporting Python 3.
Chris Pressey
2 years ago
0 | |
syntax: glob
|
1 | |
|
2 | |
*.pyc
|
3 | |
|
0 | |
4938a2222c2250779560047a61cfa7ad11dc03e8 rel_1_1_2011_0510
|
1 | |
3bd7e4328239a60da67ae0382394c8c7da33a582 rel_1_1_2012_0623
|
2 | |
9d2a2d1cf4b1ab59adf6a511c609e20c8d0a6ff0 rel_1_1_2014_0819
|
87 | 87 |
infilename = args[0]
|
88 | 88 |
outfilename = args[1]
|
89 | 89 |
except IndexError:
|
90 | |
print "Usage:", __doc__, "\n"
|
91 | |
print "Run with the -h option to see a list of all options."
|
|
90 |
print("Usage:", __doc__, "\n")
|
|
91 |
print("Run with the -h option to see a list of all options.")
|
92 | 92 |
sys.exit(1)
|
93 | 93 |
parse_and_gen(options, infilename, outfilename, tests=tests.Tests)
|
94 | 94 |
if options.compile:
|
11 | 11 |
"""
|
12 | 12 |
>>> d = Context({ 'a': 2, 'b': 3 })
|
13 | 13 |
>>> e = Context({ 'c': 4 }, parent=d)
|
14 | |
>>> print e.lookup('c')
|
|
14 |
>>> e.lookup('c')
|
15 | 15 |
4
|
16 | |
>>> print e.lookup('b')
|
|
16 |
>>> e.lookup('b')
|
17 | 17 |
3
|
18 | |
>>> print e.lookup('e', None)
|
19 | |
None
|
20 | |
>>> print e.lookup('e')
|
|
18 |
>>> e.lookup('e', None) is None
|
|
19 |
True
|
|
20 |
>>> e.lookup('e')
|
21 | 21 |
Traceback (most recent call last):
|
22 | 22 |
...
|
23 | 23 |
KeyError: 'e'
|
24 | 24 |
>>> d.declare('d', 7)
|
25 | |
>>> print e.lookup('d')
|
|
25 |
>>> e.lookup('d')
|
26 | 26 |
7
|
27 | 27 |
>>> d.declare('b', 4)
|
28 | 28 |
Traceback (most recent call last):
|
|
33 | 33 |
...
|
34 | 34 |
KeyError: 'b already declared'
|
35 | 35 |
>>> e.empty()
|
36 | |
>>> print e.lookup('c', None)
|
37 | |
None
|
38 | |
>>> print d.lookup('a', None)
|
39 | |
None
|
|
36 |
>>> e.lookup('c', None) is None
|
|
37 |
True
|
|
38 |
>>> d.lookup('a', None) is None
|
|
39 |
True
|
40 | 40 |
|
41 | 41 |
"""
|
42 | 42 |
|
84 | 84 |
|
85 | 85 |
def cmdline(options):
|
86 | 86 |
cmd = ""
|
87 | |
print "Eightebed interactive! Type 'quit' to quit."
|
|
87 |
print("Eightebed interactive! Type 'quit' to quit.")
|
88 | 88 |
options.run = True
|
89 | 89 |
options.clean = True
|
90 | 90 |
while True:
|
|
96 | 96 |
ast = parse_and_check(cmd, options=options)
|
97 | 97 |
result = load_and_go(ast, options=options)
|
98 | 98 |
sys.stdout.write(result)
|
99 | |
except Exception, e:
|
100 | |
print "Exception!", repr(e)
|
|
99 |
except Exception as e:
|
|
100 |
print("Exception!", repr(e))
|
51 | 51 |
def peek(self):
|
52 | 52 |
if not self.buffer:
|
53 | 53 |
try:
|
54 | |
self.buffer.append(self.generator.next())
|
|
54 |
self.buffer.append(next(self.generator))
|
55 | 55 |
except StopIteration:
|
56 | 56 |
return None
|
57 | 57 |
return self.buffer[0]
|
58 | 58 |
|
59 | 59 |
def advance(self):
|
60 | 60 |
if not self.buffer:
|
61 | |
self.buffer.extend(self.generator.next())
|
|
61 |
self.buffer.extend(next(self.generator))
|
62 | 62 |
self.buffer.pop()
|
63 | 63 |
|
64 | 64 |
|
|
464 | 464 |
|
465 | 465 |
def __getitem__(self, key):
|
466 | 466 |
if self.trace:
|
467 | |
print "Reading production ", key
|
|
467 |
print("Reading production ", key)
|
468 | 468 |
if key in self.productions:
|
469 | 469 |
return self.productions[key]
|
470 | 470 |
elif self.parent:
|