From 8b6323d3ef78042118c08703f26cb2adf741ea2e Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Fri, 4 Feb 2000 00:28:21 +0000 Subject: 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 --- Lib/compiler/misc.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Lib/compiler/misc.py (limited to 'Lib/compiler/misc.py') diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py new file mode 100644 index 00000000000..5a3e261d646 --- /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] -- cgit v1.2.3