[ZPT] CVS: Packages/TAL - TALGenerator.py:1.39
fred@digicool.com
fred@digicool.com
Thu, 7 Jun 2001 14:02:30 -0400 (EDT)
Update of /cvs-repository/Packages/TAL
In directory korak.digicool.com:/tmp/cvs-serv16079
Modified Files:
TALGenerator.py
Log Message:
TALGenerator.optimize():
Re-write generated instructions: (op, arg1, arg2, ...) becomes
(op, (arg1, arg2, ...)) to reflect the change in the dispatch
mechanism in TALInterpreter -- this avoids a tuple concatenation
at dispatch time.
--- Updated File TALGenerator.py in package Packages/TAL --
--- TALGenerator.py 2001/05/18 01:24:04 1.38
+++ TALGenerator.py 2001/06/07 18:02:30 1.39
@@ -127,23 +127,29 @@
item = program[cursor]
except IndexError:
item = (None, None)
- if item[0] == "rawtext":
+ opcode = item[0]
+ if opcode == "rawtext":
collect.append(item[1])
continue
- if item[0] == "endTag":
+ if opcode == "endTag":
collect.append("</%s>" % item[1])
continue
- if item[0] == "startTag":
+ if opcode == "startTag":
if self.optimizeStartTag(collect, item[1], item[2], ">"):
continue
- if item[0] == "startEndTag":
+ if opcode == "startEndTag":
if self.optimizeStartTag(collect, item[1], item[2], endsep):
continue
text = string.join(collect, "")
if text:
- output.append(("rawtext", text))
- if item[0] != None:
- output.append(item)
+ i = string.rfind(text, "\n")
+ if i >= 0:
+ i = len(text) - (i + 1)
+ output.append(("rawtextColumn", (text, i)))
+ else:
+ output.append(("rawtextOffset", (text, len(text))))
+ if opcode != None:
+ output.append((opcode, tuple(item[1:])))
rawseen = cursor+1
collect = []
return output