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