Commit ab80f6d3 authored by 's avatar

Generate and implement setPosition opcode. No runtime error actually uses

the position info yet, though.
parent e035757c
......@@ -339,10 +339,14 @@ class TALGenerator:
if n > 1:
raise TALError("at most one of content, replace, repeat",
position)
repeatWhitespace = None
if repeat:
# Hack to include preceding whitespace in the loop program
repeatWhitespace = self.unEmitNewlineWhitespace()
if position != (None, None):
# XXX at some point we should insist on a non-trivial position
self.emit("setPosition", position)
if defineMacro:
self.pushProgram()
todo["defineMacro"] = defineMacro
......
......@@ -128,6 +128,7 @@ class TALInterpreter:
self.html = html
self.slots = {}
self.currentMacro = None
self.position = None, None # (lineno, offset)
def __call__(self):
if self.html:
......@@ -164,6 +165,9 @@ class TALInterpreter:
apply(method, args)
self.level = self.level - 1
def do_setPosition(self, position):
self.position = position
def do_startEndTag(self, name, attrList):
if self.html and string.lower(name) not in EMPTY_HTML_TAGS:
self.do_startTag(name, attrList)
......@@ -242,8 +246,8 @@ class TALInterpreter:
if structure is None:
return
if repldict:
raise TALError(
"replace structure with attribute replacements not yet implemented")
raise TALError("replace structure with attribute replacements "
"not yet implemented", self.position)
text = str(structure)
self.checkXMLSyntax(text)
self.stream_write(text) # No quoting -- this is intentional
......
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