[ZPT] CVS: Packages/TAL - TALGenerator.py:1.18 TALInterpreter.py:1.21

tim@digicool.com tim@digicool.com
Fri, 16 Mar 2001 16:50:44 -0500 (EST)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv16105

Modified Files:
	TALGenerator.py TALInterpreter.py 
Log Message:
Generate and implement setPosition opcode.  No runtime error actually uses
the position info yet, though.



--- Updated File TALGenerator.py in package Packages/TAL --
--- TALGenerator.py	2001/03/16 21:00:01	1.17
+++ TALGenerator.py	2001/03/16 21:50:43	1.18
@@ -339,10 +339,14 @@
         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

--- Updated File TALInterpreter.py in package Packages/TAL --
--- TALInterpreter.py	2001/03/16 17:53:09	1.20
+++ TALInterpreter.py	2001/03/16 21:50:43	1.21
@@ -128,6 +128,7 @@
         self.html = html
         self.slots = {}
         self.currentMacro = None
+        self.position = None, None  # (lineno, offset)
 
     def __call__(self):
         if self.html:
@@ -164,6 +165,9 @@
             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 @@
         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