git @ Cat's Eye Technologies Eightebed / ad39321
Nudge towards supporting Python 3. Chris Pressey 2 years ago
7 changed file(s) with 20 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
0 __pycache__
1 *.pyc
+0
-4
.hgignore less more
0 syntax: glob
1
2 *.pyc
3
+0
-3
.hgtags less more
0 4938a2222c2250779560047a61cfa7ad11dc03e8 rel_1_1_2011_0510
1 3bd7e4328239a60da67ae0382394c8c7da33a582 rel_1_1_2012_0623
2 9d2a2d1cf4b1ab59adf6a511c609e20c8d0a6ff0 rel_1_1_2014_0819
8787 infilename = args[0]
8888 outfilename = args[1]
8989 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.")
9292 sys.exit(1)
9393 parse_and_gen(options, infilename, outfilename, tests=tests.Tests)
9494 if options.compile:
1111 """
1212 >>> d = Context({ 'a': 2, 'b': 3 })
1313 >>> e = Context({ 'c': 4 }, parent=d)
14 >>> print e.lookup('c')
14 >>> e.lookup('c')
1515 4
16 >>> print e.lookup('b')
16 >>> e.lookup('b')
1717 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')
2121 Traceback (most recent call last):
2222 ...
2323 KeyError: 'e'
2424 >>> d.declare('d', 7)
25 >>> print e.lookup('d')
25 >>> e.lookup('d')
2626 7
2727 >>> d.declare('b', 4)
2828 Traceback (most recent call last):
3333 ...
3434 KeyError: 'b already declared'
3535 >>> 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
4040
4141 """
4242
8484
8585 def cmdline(options):
8686 cmd = ""
87 print "Eightebed interactive! Type 'quit' to quit."
87 print("Eightebed interactive! Type 'quit' to quit.")
8888 options.run = True
8989 options.clean = True
9090 while True:
9696 ast = parse_and_check(cmd, options=options)
9797 result = load_and_go(ast, options=options)
9898 sys.stdout.write(result)
99 except Exception, e:
100 print "Exception!", repr(e)
99 except Exception as e:
100 print("Exception!", repr(e))
5151 def peek(self):
5252 if not self.buffer:
5353 try:
54 self.buffer.append(self.generator.next())
54 self.buffer.append(next(self.generator))
5555 except StopIteration:
5656 return None
5757 return self.buffer[0]
5858
5959 def advance(self):
6060 if not self.buffer:
61 self.buffer.extend(self.generator.next())
61 self.buffer.extend(next(self.generator))
6262 self.buffer.pop()
6363
6464
464464
465465 def __getitem__(self, key):
466466 if self.trace:
467 print "Reading production ", key
467 print("Reading production ", key)
468468 if key in self.productions:
469469 return self.productions[key]
470470 elif self.parent: