diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-02-04 00:28:21 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-02-04 00:28:21 (GMT) |
commit | 8b6323d3ef78042118c08703f26cb2adf741ea2e (patch) | |
tree | 5846996e14b70761c0fb019e1938ec74a0e467be /Lib/compiler/misc.py | |
parent | 106a02da942424b30b572f9bd962c1f5744f0ba2 (diff) | |
download | cpython-8b6323d3ef78042118c08703f26cb2adf741ea2e.zip cpython-8b6323d3ef78042118c08703f26cb2adf741ea2e.tar.gz cpython-8b6323d3ef78042118c08703f26cb2adf741ea2e.tar.bz2 |
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
Diffstat (limited to 'Lib/compiler/misc.py')
-rw-r--r-- | Lib/compiler/misc.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py new file mode 100644 index 0000000..5a3e261 --- /dev/null +++ b/Lib/compiler/misc.py @@ -0,0 +1,18 @@ +class Set: + def __init__(self): + self.elts = {} + def add(self, elt): + self.elts[elt] = elt + def items(self): + return self.elts.keys() + def has_elt(self, elt): + return self.elts.has_key(elt) + +class Stack: + def __init__(self): + self.stack = [] + self.pop = self.stack.pop + def push(self, elt): + self.stack.append(elt) + def top(self): + return self.stack[-1] |