Commit b9f0ea81 authored by Guido van Rossum's avatar Guido van Rossum

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.
parent 9004feda
......@@ -102,6 +102,13 @@ class DummyEngine:
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 @@ class DummyEngine:
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 @@ class DummyEngine:
return self.evaluate(expr)
def evaluateMacro(self, macroName):
macroName = self.uncompile(macroName)
file, localName = self.findMacroFile(macroName)
if not file:
# Local macro
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment