Update of /cvsroot/qooxdoo/qooxdoo/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/tools
Modified Files:
Tag: renderer
compileng.py compileng_compress.xsl
Log Message:
Added enhanced handling for if commands
Index: compileng_compress.xsl
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/tools/Attic/compileng_compress.xsl,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** compileng_compress.xsl 16 Jan 2006 18:58:10 -0000 1.1.2.4
--- compileng_compress.xsl 16 Jan 2006 21:06:05 -0000 1.1.2.5
***************
*** 32,35 ****
--- 32,46 ----
</xsl:template>
+ <xsl:template match="if">
+ <xsl:text>if</xsl:text>
+
+ <xsl:apply-templates/>
+
+ <!-- for ifs without brackets -->
+ <xsl:if test="block and not(following-sibling::*[position() = 1 and name() = 'protected' and @detail = 'else'])">
+ <xsl:value-of select="$blockdivider"/>
+ </xsl:if>
+ </xsl:template>
+
<xsl:template match="commandgroup">
<xsl:text>{</xsl:text>
***************
*** 53,57 ****
<xsl:choose>
! <xsl:when test="preceding-sibling::*[position()=1 and name() = 'protected' and (@detail = 'WHILE' or @detail = 'IF')]">
</xsl:when>
--- 64,68 ----
<xsl:choose>
! <xsl:when test="preceding-sibling::*[position()=1 and (name() = 'if' or (name() = 'protected' and @detail = 'WHILE'))]">
</xsl:when>
***************
*** 100,107 ****
<xsl:choose>
! <xsl:when test="@detail = 'ELSE' and following-sibling::*[position()=1 and name() = 'protected' and @detail = 'IF']">
<xsl:text> </xsl:text>
</xsl:when>
! <xsl:when test="@detail != 'ELSE' and following-sibling::*[position()=1 and name() = 'protected' and (@detail = 'IF' or @detail = 'RETURN')]">
<xsl:value-of select="$blockdivider"/>
</xsl:when>
--- 111,118 ----
<xsl:choose>
! <xsl:when test="@detail = 'ELSE' and following-sibling::*[position()=1 and name() = 'if']">
<xsl:text> </xsl:text>
</xsl:when>
! <xsl:when test="@detail != 'ELSE' and following-sibling::*[position()=1 and (name() = 'if' or (name() = 'protected' and @detail = 'RETURN'))]">
<xsl:value-of select="$blockdivider"/>
</xsl:when>
***************
*** 131,135 ****
</xsl:when>
! <xsl:when test="following-sibling::*[position()=1 and name() = 'protected' and (@detail = 'IF' or @detail = 'WHILE' or @detail = 'DO' or @detail = 'DELETE')]">
<xsl:value-of select="$blockdivider"/>
</xsl:when>
--- 142,146 ----
</xsl:when>
! <xsl:when test="following-sibling::*[position()=1 and (name() = 'if' or (name() = 'protected' and (@detail = 'WHILE' or @detail = 'DO' or @detail = 'DELETE')))]">
<xsl:value-of select="$blockdivider"/>
</xsl:when>
Index: compileng.py
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/tools/Attic/compileng.py,v
retrieving revision 1.1.2.68
retrieving revision 1.1.2.69
diff -C2 -d -r1.1.2.68 -r1.1.2.69
*** compileng.py 16 Jan 2006 18:58:10 -0000 1.1.2.68
--- compileng.py 16 Jan 2006 21:06:05 -0000 1.1.2.69
***************
*** 410,413 ****
--- 410,447 ----
+ def treecloser(need=False):
+ global xmlindent
+ global treecontext
+ global sourceline
+
+ if treecontext[-1] == "namegroup":
+ tagstop("namegroup")
+
+ if treecontext[-1] == "block":
+ tagstop("block")
+
+ elif need:
+ print " Warning: Used semicolon outside a block! (line: %s)" % sourceline
+
+
+ if treecontext[-1] == "if":
+ tagstop("if")
+
+
+
+
+ def treeblockstart():
+ global xmlindent
+ global treecontext
+ global sourceline
+
+ if treecontext[-1] == "if":
+ print " Warning: Missing brackets for if command! (line: %s)" % sourceline
+
+ tagstart("block")
+
+
+
+
def treebuilder_content(data, item):
global xmlindent
***************
*** 432,458 ****
pass
-
-
elif typ == "eof":
! if treecontext[-1] == "namegroup":
! tagstop("namegroup")
!
! if treecontext[-1] == "block":
! tagstop("block")
!
!
elif typ == "eol":
pass
-
elif typ == "token" and det == "SEMICOLON":
! if treecontext[-1] == "namegroup":
! tagstop("namegroup")
!
! if treecontext[-1] == "block":
! tagstop("block")
! else:
! print " Warning: Used semicolon outside a block! (line: %s)" % lin
--- 466,477 ----
pass
elif typ == "eof":
! treecloser()
elif typ == "eol":
pass
elif typ == "token" and det == "SEMICOLON":
! treecloser(True)
***************
*** 473,492 ****
tagstop("block")
- if treecontext[-1] != "commandgroup":
- print "Warning: Wrong context: %s. Requires commandgroup close here!" % treecontext[-1]
-
tagstop("commandgroup")
! if treecontext[-1] == "function":
tagstop("function")
elif det == "LB":
tagstart("accessgroup")
elif det == "RB":
! if treecontext[-1] == "block":
! tagstop("block")
!
tagstop("accessgroup")
--- 492,510 ----
tagstop("block")
tagstop("commandgroup")
! if treecontext[-1] == "if":
! tagstop("if")
!
! elif treecontext[-1] == "function":
tagstop("function")
+
elif det == "LB":
tagstart("accessgroup")
elif det == "RB":
! treecloser()
tagstop("accessgroup")
***************
*** 497,503 ****
elif det == "RP":
! if treecontext[-1] == "block":
! tagstop("block")
!
tagstop("argumentgroup")
--- 515,519 ----
elif det == "RP":
! treecloser()
tagstop("argumentgroup")
***************
*** 510,514 ****
else:
if treecontext[-1] != "namegroup" and treecontext[-1] != "block":
! tagstart("block")
tagsource(typ, det, src)
--- 526,530 ----
else:
if treecontext[-1] != "namegroup" and treecontext[-1] != "block":
! treeblockstart()
tagsource(typ, det, src)
***************
*** 519,523 ****
else:
if treecontext[-1] != "namegroup" and treecontext[-1] != "block" and treecontext[-1] != "function":
! tagstart("block")
--- 535,540 ----
else:
if treecontext[-1] != "namegroup" and treecontext[-1] != "block" and treecontext[-1] != "function":
! treeblockstart()
!
***************
*** 532,539 ****
tagstop("namegroup")
-
if det == "FUNCTION":
tagstart("function")
else:
tagsource(typ, det, src)
--- 549,558 ----
tagstop("namegroup")
if det == "FUNCTION":
tagstart("function")
+ elif det == "IF":
+ tagstart("if")
+
else:
tagsource(typ, det, src)
***************
*** 601,605 ****
while treecontext[-1] != tag:
! print "Want to close: %s, but in wrong tree context: %s" % (tag, treecontext[-1])
xmlindent -= 1;
--- 620,624 ----
while treecontext[-1] != tag:
! print "Line %s: Want to close: %s, but in wrong tree context: %s" % (sourceline, tag, treecontext[-1])
xmlindent -= 1;
|