[ZPT] CVS: Packages/TAL - DummyEngine.py:1.16
guido@digicool.com
guido@digicool.com
Mon, 26 Mar 2001 17:10:07 -0500 (EST)
Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv2887
Modified Files:
DummyEngine.py
Log Message:
Emit a new opcode, "mode", with an argument "html" or "xml", depending
on the value of the xml argument to the constructor. (This requires a
matching checkin of TALInterpreter.)
Move the compile() method into this class.
Make compile() enclose the expression in $dollars$, and add an
uncompile() method to strip them again. This keeps me honest, making
sure that compile() is always called.
--- Updated File DummyEngine.py in package Packages/TAL --
--- DummyEngine.py 2001/03/23 19:48:45 1.15
+++ DummyEngine.py 2001/03/26 22:10:06 1.16
@@ -102,6 +102,13 @@
self.locals = self.globals = dict
self.stack = [dict]
+ def compile(self, expr):
+ return "$%s$" % expr
+
+ def uncompile(self, expression):
+ assert expression[:1] == "$" == expression[-1:], expression
+ return expression[1:-1]
+
def beginScope(self):
self.stack.append(self.locals)
@@ -119,6 +126,7 @@
self.globals[name] = value
def evaluate(self, expression):
+ expression = self.uncompile(expression)
m = re.match(r"(?s)(%s):(.*)\Z" % NAME_RE, expression)
if m:
type, expr = m.group(1, 2)
@@ -170,6 +178,7 @@
return self.evaluate(expr)
def evaluateMacro(self, macroName):
+ macroName = self.uncompile(macroName)
file, localName = self.findMacroFile(macroName)
if not file:
# Local macro