Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b6323d

Browse files
committed
checking in initial weekend's work
compile.py: ASTVisitor framework plus bits of a code generator that should be bug-for-buf compatible with compile.c misc.py: Set and Stack helpers test.py: a bit of simple sample code that compile.py will work on
1 parent 106a02d commit 8b6323d

4 files changed

Lines changed: 848 additions & 0 deletions

File tree

Lib/compiler/misc.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Set:
2+
def __init__(self):
3+
self.elts = {}
4+
def add(self, elt):
5+
self.elts[elt] = elt
6+
def items(self):
7+
return self.elts.keys()
8+
def has_elt(self, elt):
9+
return self.elts.has_key(elt)
10+
11+
class Stack:
12+
def __init__(self):
13+
self.stack = []
14+
self.pop = self.stack.pop
15+
def push(self, elt):
16+
self.stack.append(elt)
17+
def top(self):
18+
return self.stack[-1]

0 commit comments

Comments
 (0)