velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r731779 [1/3] - in /velocity/engine/trunk: src/changes/ src/java/org/apache/velocity/runtime/directive/ src/java/org/apache/velocity/runtime/parser/ src/java/org/apache/velocity/runtime/parser/node/ src/parser/ src/test/org/apache/velocity/...
Date Tue, 06 Jan 2009 00:10:58 GMT
Author: nbubna
Date: Mon Jan  5 16:10:57 2009
New Revision: 731779

URL: http://svn.apache.org/viewvc?rev=731779&view=rev
Log:
VELOCITY-661 add #[[unparsed textblock]]# syntax to replace the limited #literal directive (thx to Jarkko Viinamaki)

Added:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTTextblock.java   (with props)
    velocity/engine/trunk/src/test/org/apache/velocity/test/TextblockTestCase.java   (with props)
Modified:
    velocity/engine/trunk/src/changes/changes.xml
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Literal.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.jj
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParserConstants.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParserTokenManager.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParserTreeConstants.java
    velocity/engine/trunk/src/parser/Parser.jjt
    velocity/engine/trunk/xdocs/docs/translations/user-guide_fr.xml
    velocity/engine/trunk/xdocs/docs/user-guide.xml
    velocity/engine/trunk/xdocs/docs/vtl-reference-guide.xml

Modified: velocity/engine/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/changes/changes.xml?rev=731779&r1=731778&r2=731779&view=diff
==============================================================================
--- velocity/engine/trunk/src/changes/changes.xml (original)
+++ velocity/engine/trunk/src/changes/changes.xml Mon Jan  5 16:10:57 2009
@@ -27,6 +27,12 @@
   <body>
     <release version="1.7" date="In Subversion">
 
+      <action type="fix" dev="nbubna" issue="VELOCITY-661" due-to="Jarkko Viinamaki">
+        Added #[[this is included in output but not parsed]]# syntax to replace
+        and deprecate the much more limited #literal directive
+        (which required parse-able content).
+      </action>
+
       <action type="fix" dev="byron" issue="VELOCITY-664">
 	Reduce memory usage of cached templates by preventing text from being stored
 	twice.

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Literal.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Literal.java?rev=731779&r1=731778&r2=731779&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Literal.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Literal.java Mon Jan  5 16:10:57 2009
@@ -31,10 +31,13 @@
  * A very simple directive that leverages the Node.literal()
  * to grab the literal rendition of a node. We basically
  * grab the literal value on init(), then repeatedly use
- * that during render().
+ * that during render().  <em>This is deprecated and will be
+ * removed in Velocity 2.0; please use #[[unparsed content]]#
+ * instead.</em>
  *
  * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
  * @version $Id$
+ * @deprecated Use the #[[unparsed content]]# syntax instead.
  */
 public class Literal extends Directive
 {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java?rev=731779&r1=731778&r2=731779&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java Mon Jan  5 16:10:57 2009
@@ -10,6 +10,7 @@
 import org.apache.velocity.runtime.directive.Macro;
 import org.apache.velocity.runtime.directive.MacroParseException;
 import org.apache.velocity.util.StringUtils;
+import org.apache.commons.lang.text.StrBuilder;
 
 /**
  * This class is responsible for parsing a Velocity
@@ -27,9 +28,9 @@
 */
 public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants, ParserConstants {/*@bgen(jjtree)*/
   protected JJTParserState jjtree = new JJTParserState();/**
-     *  This Hashtable contains a list of all of the dynamic directives.
+     *  This Map contains a list of all of the dynamic directives.
      */
-    private Hashtable directives = new Hashtable(0);
+    private Map directives = new HashMap();
 
     /**
      *  Name of current template we are parsing.  Passed to us in parse()
@@ -140,7 +141,7 @@
      */
     public void setDirectives(Hashtable directives)
     {
-        this.directives = directives;
+        this.directives = new HashMap(directives);
     }
 
     /**
@@ -291,6 +292,7 @@
         case TEXT:
         case FORMAL_COMMENT:
         case MULTI_LINE_COMMENT:
+        case TEXTBLOCK:
         case STRING_LITERAL:
         case IF_DIRECTIVE:
         case STOP_DIRECTIVE:
@@ -360,6 +362,9 @@
         case MULTI_LINE_COMMENT:
           Comment();
           break;
+        case TEXTBLOCK:
+          Textblock();
+          break;
         case SET_DIRECTIVE:
           SetDirective();
           break;
@@ -521,6 +526,20 @@
     }
   }
 
+  final public void Textblock() throws ParseException {
+                    /*@bgen(jjtree) Textblock */
+  ASTTextblock jjtn000 = new ASTTextblock(this, JJTTEXTBLOCK);
+  boolean jjtc000 = true;
+  jjtree.openNodeScope(jjtn000);
+    try {
+      jj_consume_token(TEXTBLOCK);
+    } finally {
+     if (jjtc000) {
+       jjtree.closeNodeScope(jjtn000, true);
+     }
+    }
+  }
+
   final public void FloatingPointLiteral() throws ParseException {
                                /*@bgen(jjtree) FloatingPointLiteral */
   ASTFloatingPointLiteral jjtn000 = new ASTFloatingPointLiteral(this, JJTFLOATINGPOINTLITERAL);
@@ -862,6 +881,7 @@
           case TEXT:
           case FORMAL_COMMENT:
           case MULTI_LINE_COMMENT:
+          case TEXTBLOCK:
           case STRING_LITERAL:
           case IF_DIRECTIVE:
           case STOP_DIRECTIVE:
@@ -1630,6 +1650,7 @@
           case TEXT:
           case FORMAL_COMMENT:
           case MULTI_LINE_COMMENT:
+          case TEXTBLOCK:
           case STRING_LITERAL:
           case IF_DIRECTIVE:
           case STOP_DIRECTIVE:
@@ -1742,6 +1763,7 @@
           case TEXT:
           case FORMAL_COMMENT:
           case MULTI_LINE_COMMENT:
+          case TEXTBLOCK:
           case STRING_LITERAL:
           case IF_DIRECTIVE:
           case STOP_DIRECTIVE:
@@ -1837,6 +1859,7 @@
           case TEXT:
           case FORMAL_COMMENT:
           case MULTI_LINE_COMMENT:
+          case TEXTBLOCK:
           case STRING_LITERAL:
           case IF_DIRECTIVE:
           case STOP_DIRECTIVE:
@@ -2636,336 +2659,168 @@
     }
   }
 
-  final private boolean jj_2_1(int xla) {
+  private boolean jj_2_1(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_1(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(0, xla); }
   }
 
-  final private boolean jj_2_2(int xla) {
+  private boolean jj_2_2(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_2(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(1, xla); }
   }
 
-  final private boolean jj_2_3(int xla) {
+  private boolean jj_2_3(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_3(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(2, xla); }
   }
 
-  final private boolean jj_2_4(int xla) {
+  private boolean jj_2_4(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_4(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(3, xla); }
   }
 
-  final private boolean jj_2_5(int xla) {
+  private boolean jj_2_5(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_5(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(4, xla); }
   }
 
-  final private boolean jj_2_6(int xla) {
+  private boolean jj_2_6(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_6(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(5, xla); }
   }
 
-  final private boolean jj_2_7(int xla) {
+  private boolean jj_2_7(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_7(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(6, xla); }
   }
 
-  final private boolean jj_2_8(int xla) {
+  private boolean jj_2_8(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_8(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(7, xla); }
   }
 
-  final private boolean jj_2_9(int xla) {
+  private boolean jj_2_9(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_9(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(8, xla); }
   }
 
-  final private boolean jj_2_10(int xla) {
+  private boolean jj_2_10(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_10(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(9, xla); }
   }
 
-  final private boolean jj_2_11(int xla) {
+  private boolean jj_2_11(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_11(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(10, xla); }
   }
 
-  final private boolean jj_2_12(int xla) {
+  private boolean jj_2_12(int xla) {
     jj_la = xla; jj_lastpos = jj_scanpos = token;
     try { return !jj_3_12(); }
     catch(LookaheadSuccess ls) { return true; }
     finally { jj_save(11, xla); }
   }
 
-  final private boolean jj_3R_49() {
-    if (jj_3R_70()) return true;
-    return false;
-  }
-
-  final private boolean jj_3_3() {
-    if (jj_scan_token(LBRACKET)) return true;
-    Token xsp;
-    xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
-    xsp = jj_scanpos;
-    if (jj_3R_25()) {
-    jj_scanpos = xsp;
-    if (jj_3R_26()) return true;
-    }
-    xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
-    if (jj_scan_token(DOUBLEDOT)) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_48() {
-    if (jj_3R_69()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_47() {
-    if (jj_3R_68()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_46() {
-    if (jj_3R_67()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_45() {
-    if (jj_3R_66()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_90() {
-    if (jj_3R_73()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_44() {
-    if (jj_3R_40()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_89() {
-    if (jj_3R_73()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_43() {
-    if (jj_3R_65()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_37() {
-    if (jj_3R_40()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_42() {
-    if (jj_3R_64()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_27() {
-    if (jj_scan_token(COMMA)) return true;
-    Token xsp;
-    xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
-    return false;
-  }
-
-  final private boolean jj_3R_41() {
-    if (jj_3R_24()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_28() {
-    Token xsp;
-    xsp = jj_scanpos;
-    if (jj_3R_41()) {
-    jj_scanpos = xsp;
-    if (jj_3R_42()) {
-    jj_scanpos = xsp;
-    if (jj_3R_43()) {
-    jj_scanpos = xsp;
-    if (jj_3R_44()) {
-    jj_scanpos = xsp;
-    if (jj_3R_45()) {
-    jj_scanpos = xsp;
-    if (jj_3R_46()) {
-    jj_scanpos = xsp;
-    if (jj_3R_47()) {
-    jj_scanpos = xsp;
-    if (jj_3R_48()) {
-    jj_scanpos = xsp;
-    if (jj_3R_49()) {
-    jj_scanpos = xsp;
-    if (jj_3R_50()) return true;
-    }
-    }
-    }
-    }
-    }
-    }
-    }
-    }
-    }
-    return false;
-  }
-
-  final private boolean jj_3R_34() {
-    if (jj_3R_60()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_36() {
-    if (jj_3R_24()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_32() {
-    if (jj_3R_60()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_64() {
-    if (jj_scan_token(WORD)) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_60() {
-    if (jj_scan_token(IDENTIFIER)) return true;
-    return false;
-  }
-
-  final private boolean jj_3_10() {
-    if (jj_3R_33()) return true;
-    return false;
-  }
-
-  final private boolean jj_3_4() {
-    Token xsp;
-    xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
-    xsp = jj_scanpos;
-    if (jj_3R_27()) jj_scanpos = xsp;
-    if (jj_3R_28()) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_65() {
-    if (jj_scan_token(STRING_LITERAL)) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_31() {
-    if (jj_3R_40()) return true;
-    return false;
-  }
-
-  final private boolean jj_3_8() {
+  private boolean jj_3_8() {
     if (jj_3R_33()) return true;
     return false;
   }
 
-  final private boolean jj_3R_40() {
+  private boolean jj_3R_40() {
     if (jj_scan_token(INTEGER_LITERAL)) return true;
     return false;
   }
 
-  final private boolean jj_3R_74() {
+  private boolean jj_3R_74() {
     if (jj_3R_73()) return true;
     return false;
   }
 
-  final private boolean jj_3R_97() {
+  private boolean jj_3R_97() {
     if (jj_scan_token(COMMA)) return true;
     if (jj_3R_29()) return true;
     return false;
   }
 
-  final private boolean jj_3_12() {
+  private boolean jj_3_12() {
     if (jj_scan_token(LBRACKET)) return true;
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     xsp = jj_scanpos;
     if (jj_3R_36()) {
     jj_scanpos = xsp;
     if (jj_3R_37()) return true;
     }
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     if (jj_scan_token(DOUBLEDOT)) return true;
     return false;
   }
 
-  final private boolean jj_3R_67() {
+  private boolean jj_3R_67() {
     if (jj_scan_token(FLOATING_POINT_LITERAL)) return true;
     return false;
   }
 
-  final private boolean jj_3R_71() {
+  private boolean jj_3R_71() {
     if (jj_scan_token(FALSE)) return true;
     return false;
   }
 
-  final private boolean jj_3R_63() {
+  private boolean jj_3R_63() {
     if (jj_3R_73()) return true;
     return false;
   }
 
-  final private boolean jj_3R_88() {
+  private boolean jj_3R_88() {
     if (jj_scan_token(LPAREN)) return true;
     return false;
   }
 
-  final private boolean jj_3R_30() {
+  private boolean jj_3R_30() {
     if (jj_3R_24()) return true;
     return false;
   }
 
-  final private boolean jj_3R_87() {
+  private boolean jj_3R_87() {
     if (jj_3R_71()) return true;
     return false;
   }
 
-  final private boolean jj_3R_70() {
+  private boolean jj_3R_70() {
     if (jj_scan_token(TRUE)) return true;
     return false;
   }
 
-  final private boolean jj_3R_86() {
+  private boolean jj_3R_86() {
     if (jj_3R_70()) return true;
     return false;
   }
 
-  final private boolean jj_3_9() {
+  private boolean jj_3_9() {
     if (jj_scan_token(DOT)) return true;
     Token xsp;
     xsp = jj_scanpos;
@@ -2980,32 +2835,32 @@
     return false;
   }
 
-  final private boolean jj_3R_85() {
+  private boolean jj_3R_85() {
     if (jj_3R_69()) return true;
     return false;
   }
 
-  final private boolean jj_3R_84() {
+  private boolean jj_3R_84() {
     if (jj_3R_68()) return true;
     return false;
   }
 
-  final private boolean jj_3R_83() {
+  private boolean jj_3R_83() {
     if (jj_3R_67()) return true;
     return false;
   }
 
-  final private boolean jj_3R_82() {
+  private boolean jj_3R_82() {
     if (jj_3R_66()) return true;
     return false;
   }
 
-  final private boolean jj_3R_81() {
+  private boolean jj_3R_81() {
     if (jj_3R_40()) return true;
     return false;
   }
 
-  final private boolean jj_3_7() {
+  private boolean jj_3_7() {
     if (jj_scan_token(DOT)) return true;
     Token xsp;
     xsp = jj_scanpos;
@@ -3020,7 +2875,7 @@
     return false;
   }
 
-  final private boolean jj_3R_61() {
+  private boolean jj_3R_61() {
     if (jj_3R_29()) return true;
     Token xsp;
     while (true) {
@@ -3030,12 +2885,12 @@
     return false;
   }
 
-  final private boolean jj_3R_80() {
+  private boolean jj_3R_80() {
     if (jj_3R_24()) return true;
     return false;
   }
 
-  final private boolean jj_3R_39() {
+  private boolean jj_3R_39() {
     if (jj_scan_token(LCURLY)) return true;
     if (jj_scan_token(IDENTIFIER)) return true;
     Token xsp;
@@ -3051,15 +2906,15 @@
     return false;
   }
 
-  final private boolean jj_3R_79() {
+  private boolean jj_3R_79() {
     if (jj_3R_65()) return true;
     return false;
   }
 
-  final private boolean jj_3R_72() {
+  private boolean jj_3R_72() {
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     xsp = jj_scanpos;
     if (jj_3R_79()) {
     jj_scanpos = xsp;
@@ -3092,7 +2947,7 @@
     return false;
   }
 
-  final private boolean jj_3R_38() {
+  private boolean jj_3R_38() {
     if (jj_scan_token(IDENTIFIER)) return true;
     Token xsp;
     while (true) {
@@ -3106,7 +2961,7 @@
     return false;
   }
 
-  final private boolean jj_3R_24() {
+  private boolean jj_3R_24() {
     Token xsp;
     xsp = jj_scanpos;
     if (jj_3R_38()) {
@@ -3116,7 +2971,7 @@
     return false;
   }
 
-  final private boolean jj_3R_35() {
+  private boolean jj_3R_35() {
     Token xsp;
     xsp = jj_scanpos;
     if (jj_3_11()) {
@@ -3126,44 +2981,44 @@
     return false;
   }
 
-  final private boolean jj_3_11() {
+  private boolean jj_3_11() {
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     if (jj_scan_token(LOGICAL_NOT)) return true;
     if (jj_3R_35()) return true;
     return false;
   }
 
-  final private boolean jj_3R_62() {
+  private boolean jj_3R_62() {
     if (jj_3R_72()) return true;
     return false;
   }
 
-  final private boolean jj_3R_73() {
+  private boolean jj_3R_73() {
     if (jj_scan_token(INDEX_LBRACKET)) return true;
     if (jj_3R_91()) return true;
     if (jj_scan_token(INDEX_RBRACKET)) return true;
     return false;
   }
 
-  final private boolean jj_3_6() {
+  private boolean jj_3_6() {
     if (jj_scan_token(LBRACKET)) return true;
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     xsp = jj_scanpos;
     if (jj_3R_30()) {
     jj_scanpos = xsp;
     if (jj_3R_31()) return true;
     }
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     if (jj_scan_token(DOUBLEDOT)) return true;
     return false;
   }
 
-  final private boolean jj_3R_33() {
+  private boolean jj_3R_33() {
     if (jj_3R_60()) return true;
     if (jj_scan_token(LPAREN)) return true;
     Token xsp;
@@ -3173,60 +3028,60 @@
     return false;
   }
 
-  final private boolean jj_3R_59() {
+  private boolean jj_3R_59() {
     if (jj_3R_67()) return true;
     return false;
   }
 
-  final private boolean jj_3R_58() {
+  private boolean jj_3R_58() {
     if (jj_3R_24()) return true;
     return false;
   }
 
-  final private boolean jj_3R_57() {
+  private boolean jj_3R_57() {
     if (jj_3R_71()) return true;
     return false;
   }
 
-  final private boolean jj_3R_56() {
+  private boolean jj_3R_56() {
     if (jj_3R_70()) return true;
     return false;
   }
 
-  final private boolean jj_3_2() {
-    if (jj_scan_token(DOUBLE_ESCAPE)) return true;
-    return false;
-  }
-
-  final private boolean jj_3R_55() {
+  private boolean jj_3R_55() {
     if (jj_3R_69()) return true;
     return false;
   }
 
-  final private boolean jj_3R_54() {
+  private boolean jj_3R_54() {
     if (jj_3R_68()) return true;
     return false;
   }
 
-  final private boolean jj_3R_53() {
+  private boolean jj_3R_53() {
     if (jj_3R_66()) return true;
     return false;
   }
 
-  final private boolean jj_3R_52() {
+  private boolean jj_3R_52() {
     if (jj_3R_40()) return true;
     return false;
   }
 
-  final private boolean jj_3R_51() {
+  private boolean jj_3_2() {
+    if (jj_scan_token(DOUBLE_ESCAPE)) return true;
+    return false;
+  }
+
+  private boolean jj_3R_51() {
     if (jj_3R_65()) return true;
     return false;
   }
 
-  final private boolean jj_3R_29() {
+  private boolean jj_3R_29() {
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     xsp = jj_scanpos;
     if (jj_3R_51()) {
     jj_scanpos = xsp;
@@ -3254,11 +3109,11 @@
     }
     }
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     return false;
   }
 
-  final private boolean jj_3R_100() {
+  private boolean jj_3R_100() {
     if (jj_scan_token(COMMA)) return true;
     if (jj_3R_29()) return true;
     if (jj_scan_token(COLON)) return true;
@@ -3266,51 +3121,51 @@
     return false;
   }
 
-  final private boolean jj_3R_96() {
+  private boolean jj_3R_96() {
     if (jj_3R_24()) return true;
     return false;
   }
 
-  final private boolean jj_3R_95() {
+  private boolean jj_3R_95() {
     if (jj_3R_71()) return true;
     return false;
   }
 
-  final private boolean jj_3R_94() {
+  private boolean jj_3R_94() {
     if (jj_3R_70()) return true;
     return false;
   }
 
-  final private boolean jj_3R_93() {
+  private boolean jj_3R_93() {
     if (jj_3R_40()) return true;
     return false;
   }
 
-  final private boolean jj_3R_92() {
+  private boolean jj_3R_92() {
     if (jj_3R_65()) return true;
     return false;
   }
 
-  final private boolean jj_3R_99() {
+  private boolean jj_3R_99() {
     if (jj_3R_40()) return true;
     return false;
   }
 
-  final private boolean jj_3R_76() {
+  private boolean jj_3R_76() {
     if (jj_3R_40()) return true;
     return false;
   }
 
-  final private boolean jj_3R_101() {
+  private boolean jj_3R_101() {
     if (jj_scan_token(COMMA)) return true;
     if (jj_3R_29()) return true;
     return false;
   }
 
-  final private boolean jj_3R_91() {
+  private boolean jj_3R_91() {
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     xsp = jj_scanpos;
     if (jj_3R_92()) {
     jj_scanpos = xsp;
@@ -3326,26 +3181,26 @@
     }
     }
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     return false;
   }
 
-  final private boolean jj_3R_26() {
+  private boolean jj_3R_26() {
     if (jj_3R_40()) return true;
     return false;
   }
 
-  final private boolean jj_3R_98() {
+  private boolean jj_3R_98() {
     if (jj_3R_24()) return true;
     return false;
   }
 
-  final private boolean jj_3R_75() {
+  private boolean jj_3R_75() {
     if (jj_3R_24()) return true;
     return false;
   }
 
-  final private boolean jj_3R_78() {
+  private boolean jj_3R_78() {
     if (jj_3R_29()) return true;
     Token xsp;
     while (true) {
@@ -3355,43 +3210,43 @@
     return false;
   }
 
-  final private boolean jj_3R_66() {
+  private boolean jj_3R_66() {
     if (jj_scan_token(LBRACKET)) return true;
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     xsp = jj_scanpos;
     if (jj_3R_75()) {
     jj_scanpos = xsp;
     if (jj_3R_76()) return true;
     }
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     if (jj_scan_token(DOUBLEDOT)) return true;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     xsp = jj_scanpos;
     if (jj_3R_98()) {
     jj_scanpos = xsp;
     if (jj_3R_99()) return true;
     }
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     if (jj_scan_token(RBRACKET)) return true;
     return false;
   }
 
-  final private boolean jj_3_1() {
+  private boolean jj_3R_25() {
     if (jj_3R_24()) return true;
     return false;
   }
 
-  final private boolean jj_3R_25() {
+  private boolean jj_3_1() {
     if (jj_3R_24()) return true;
     return false;
   }
 
-  final private boolean jj_3R_69() {
+  private boolean jj_3R_69() {
     if (jj_scan_token(LBRACKET)) return true;
     Token xsp;
     xsp = jj_scanpos;
@@ -3400,14 +3255,14 @@
     return false;
   }
 
-  final private boolean jj_3R_77() {
+  private boolean jj_3R_77() {
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_scan_token(28)) jj_scanpos = xsp;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
     return false;
   }
 
-  final private boolean jj_3_5() {
+  private boolean jj_3_5() {
     if (jj_3R_29()) return true;
     if (jj_scan_token(COLON)) return true;
     if (jj_3R_29()) return true;
@@ -3419,12 +3274,12 @@
     return false;
   }
 
-  final private boolean jj_3R_50() {
+  private boolean jj_3R_50() {
     if (jj_3R_71()) return true;
     return false;
   }
 
-  final private boolean jj_3R_68() {
+  private boolean jj_3R_68() {
     if (jj_scan_token(LEFT_CURLEY)) return true;
     Token xsp;
     xsp = jj_scanpos;
@@ -3435,41 +3290,212 @@
     xsp = jj_scanpos;
     if (jj_scan_token(9)) {
     jj_scanpos = xsp;
-    if (jj_scan_token(67)) return true;
+    if (jj_scan_token(70)) return true;
+    }
+    return false;
+  }
+
+  private boolean jj_3R_49() {
+    if (jj_3R_70()) return true;
+    return false;
+  }
+
+  private boolean jj_3_3() {
+    if (jj_scan_token(LBRACKET)) return true;
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
+    xsp = jj_scanpos;
+    if (jj_3R_25()) {
+    jj_scanpos = xsp;
+    if (jj_3R_26()) return true;
     }
+    xsp = jj_scanpos;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
+    if (jj_scan_token(DOUBLEDOT)) return true;
+    return false;
+  }
+
+  private boolean jj_3R_48() {
+    if (jj_3R_69()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_47() {
+    if (jj_3R_68()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_46() {
+    if (jj_3R_67()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_45() {
+    if (jj_3R_66()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_90() {
+    if (jj_3R_73()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_44() {
+    if (jj_3R_40()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_89() {
+    if (jj_3R_73()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_43() {
+    if (jj_3R_65()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_37() {
+    if (jj_3R_40()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_42() {
+    if (jj_3R_64()) return true;
     return false;
   }
 
+  private boolean jj_3R_27() {
+    if (jj_scan_token(COMMA)) return true;
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
+    return false;
+  }
+
+  private boolean jj_3R_41() {
+    if (jj_3R_24()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_28() {
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_3R_41()) {
+    jj_scanpos = xsp;
+    if (jj_3R_42()) {
+    jj_scanpos = xsp;
+    if (jj_3R_43()) {
+    jj_scanpos = xsp;
+    if (jj_3R_44()) {
+    jj_scanpos = xsp;
+    if (jj_3R_45()) {
+    jj_scanpos = xsp;
+    if (jj_3R_46()) {
+    jj_scanpos = xsp;
+    if (jj_3R_47()) {
+    jj_scanpos = xsp;
+    if (jj_3R_48()) {
+    jj_scanpos = xsp;
+    if (jj_3R_49()) {
+    jj_scanpos = xsp;
+    if (jj_3R_50()) return true;
+    }
+    }
+    }
+    }
+    }
+    }
+    }
+    }
+    }
+    return false;
+  }
+
+  private boolean jj_3R_34() {
+    if (jj_3R_60()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_36() {
+    if (jj_3R_24()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_32() {
+    if (jj_3R_60()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_64() {
+    if (jj_scan_token(WORD)) return true;
+    return false;
+  }
+
+  private boolean jj_3R_60() {
+    if (jj_scan_token(IDENTIFIER)) return true;
+    return false;
+  }
+
+  private boolean jj_3_10() {
+    if (jj_3R_33()) return true;
+    return false;
+  }
+
+  private boolean jj_3_4() {
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_scan_token(31)) jj_scanpos = xsp;
+    xsp = jj_scanpos;
+    if (jj_3R_27()) jj_scanpos = xsp;
+    if (jj_3R_28()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_65() {
+    if (jj_scan_token(STRING_LITERAL)) return true;
+    return false;
+  }
+
+  private boolean jj_3R_31() {
+    if (jj_3R_40()) return true;
+    return false;
+  }
+
+  /** Generated Token Manager. */
   public ParserTokenManager token_source;
-  public Token token, jj_nt;
+  /** Current token. */
+  public Token token;
+  /** Next token. */
+  public Token jj_nt;
   private int jj_ntk;
   private Token jj_scanpos, jj_lastpos;
   private int jj_la;
-  public boolean lookingAhead = false;
-  private boolean jj_semLA;
   private int jj_gen;
   final private int[] jj_la1 = new int[69];
   static private int[] jj_la1_0;
   static private int[] jj_la1_1;
   static private int[] jj_la1_2;
   static {
-      jj_la1_0();
-      jj_la1_1();
-      jj_la1_2();
+      jj_la1_init_0();
+      jj_la1_init_1();
+      jj_la1_init_2();
    }
-   private static void jj_la1_0() {
-      jj_la1_0 = new int[] {0x26f06c00,0x0,0x26f06c00,0x1000000,0x6100000,0x20000000,0xc0000108,0x0,0x10000000,0x10000000,0x10000000,0x20,0x10000000,0x26f06c00,0x20,0x10000000,0x200,0x20,0xf0000108,0x10000000,0x0,0x10000000,0x10000000,0x0,0x10000000,0x10000000,0xe0000000,0x10000000,0x10000000,0x20000000,0xc0000108,0x10000000,0x20,0xf0000108,0x2,0x0,0x2,0x2,0x0,0x2,0x0,0x20c00c00,0x10000000,0x26f06c00,0x0,0x0,0x0,0x26f06c00,0x10000000,0x26f06c00,0x10000000,0x10000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10000000,0xf0000508,0x10000000,0x20000000,0xc0000508,0x10000000,};
+   private static void jj_la1_init_0() {
+      jj_la1_0 = new int[] {0x1de06c00,0x0,0x1de06c00,0x2000000,0xc200000,0x0,0x108,0x0,0x80000000,0x80000000,0x80000000,0x20,0x80000000,0x1de06c00,0x20,0x80000000,0x200,0x20,0x80000108,0x80000000,0x0,0x80000000,0x80000000,0x0,0x80000000,0x80000000,0x0,0x80000000,0x80000000,0x0,0x108,0x80000000,0x20,0x80000108,0x2,0x0,0x2,0x2,0x0,0x2,0x0,0x1800c00,0x80000000,0x1de06c00,0x0,0x0,0x0,0x1de06c00,0x80000000,0x1de06c00,0x80000000,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,0x80000508,0x80000000,0x0,0x508,0x80000000,};
    }
-   private static void jj_la1_1() {
-      jj_la1_1 = new int[] {0x18d20000,0x120000,0x18c00000,0x0,0x0,0x8400000,0x800000,0x18000000,0x0,0x0,0x0,0x0,0x0,0x18d20000,0x0,0x0,0x0,0x0,0xc00000,0x0,0x400000,0x0,0x0,0x400000,0x0,0x0,0x400000,0x0,0x0,0x400000,0x800000,0x0,0x0,0xc00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc00000,0x0,0x18d20000,0x40000,0x40000,0x80000,0x18d20000,0x0,0x18d20000,0x0,0x0,0x1,0x80,0x40,0x3000,0x3000,0xf00,0xf00,0x6,0x6,0x38,0x38,0x0,0xc00000,0x0,0x400000,0x800000,0x0,};
+   private static void jj_la1_init_1() {
+      jj_la1_1 = new int[] {0xc6900001,0x900000,0xc6000001,0x0,0x0,0x42000001,0x4000006,0xc0000000,0x0,0x0,0x0,0x0,0x0,0xc6900001,0x0,0x0,0x0,0x0,0x6000007,0x0,0x2000000,0x0,0x0,0x2000000,0x0,0x0,0x2000007,0x0,0x0,0x2000001,0x4000006,0x0,0x0,0x6000007,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000001,0x0,0xc6900001,0x200000,0x200000,0x400000,0xc6900001,0x0,0xc6900001,0x0,0x0,0x8,0x400,0x200,0x18000,0x18000,0x7800,0x7800,0x30,0x30,0x1c0,0x1c0,0x0,0x6000007,0x0,0x2000001,0x4000006,0x0,};
    }
-   private static void jj_la1_2() {
-      jj_la1_2 = new int[] {0x4f,0x0,0x4e,0x0,0x0,0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4f,0x0,0x0,0x8,0x0,0x5,0x0,0x5,0x0,0x0,0x5,0x0,0x0,0x5,0x0,0x0,0x0,0x5,0x0,0x0,0x5,0x0,0x1,0x0,0x0,0x1,0x0,0x5,0x4e,0x0,0x4f,0x0,0x0,0x0,0x4f,0x0,0x4f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x5,0x0,0x5,0x0,0x0,};
+   private static void jj_la1_init_2() {
+      jj_la1_2 = new int[] {0x278,0x0,0x270,0x0,0x0,0x28,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x278,0x0,0x0,0x40,0x0,0x28,0x0,0x28,0x0,0x0,0x28,0x0,0x0,0x28,0x0,0x0,0x0,0x28,0x0,0x0,0x28,0x0,0x8,0x0,0x0,0x8,0x0,0x28,0x270,0x0,0x278,0x0,0x0,0x0,0x278,0x0,0x278,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x28,0x0,0x28,0x0,0x0,};
    }
   final private JJCalls[] jj_2_rtns = new JJCalls[12];
   private boolean jj_rescan = false;
   private int jj_gc = 0;
 
+  /** Constructor with user supplied CharStream. */
   public Parser(CharStream stream) {
     token_source = new ParserTokenManager(stream);
     token = new Token();
@@ -3479,6 +3505,7 @@
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
+  /** Reinitialise. */
   public void ReInit(CharStream stream) {
     token_source.ReInit(stream);
     token = new Token();
@@ -3489,6 +3516,7 @@
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
+  /** Constructor with generated Token Manager. */
   public Parser(ParserTokenManager tm) {
     token_source = tm;
     token = new Token();
@@ -3498,6 +3526,7 @@
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
+  /** Reinitialise. */
   public void ReInit(ParserTokenManager tm) {
     token_source = tm;
     token = new Token();
@@ -3508,7 +3537,7 @@
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
-  final private Token jj_consume_token(int kind) throws ParseException {
+  private Token jj_consume_token(int kind) throws ParseException {
     Token oldToken;
     if ((oldToken = token).next != null) token = token.next;
     else token = token.next = token_source.getNextToken();
@@ -3534,7 +3563,7 @@
 
   static private final class LookaheadSuccess extends java.lang.Error { }
   final private LookaheadSuccess jj_ls = new LookaheadSuccess();
-  final private boolean jj_scan_token(int kind) {
+  private boolean jj_scan_token(int kind) {
     if (jj_scanpos == jj_lastpos) {
       jj_la--;
       if (jj_scanpos.next == null) {
@@ -3555,6 +3584,8 @@
     return false;
   }
 
+
+/** Get the next Token. */
   final public Token getNextToken() {
     if (token.next != null) token = token.next;
     else token = token.next = token_source.getNextToken();
@@ -3563,8 +3594,9 @@
     return token;
   }
 
+/** Get the specific Token. */
   final public Token getToken(int index) {
-    Token t = lookingAhead ? jj_scanpos : token;
+    Token t = token;
     for (int i = 0; i < index; i++) {
       if (t.next != null) t = t.next;
       else t = t.next = token_source.getNextToken();
@@ -3572,14 +3604,14 @@
     return t;
   }
 
-  final private int jj_ntk() {
+  private int jj_ntk() {
     if ((jj_nt=token.next) == null)
       return (jj_ntk = (token.next=token_source.getNextToken()).kind);
     else
       return (jj_ntk = jj_nt.kind);
   }
 
-  private java.util.Vector jj_expentries = new java.util.Vector();
+  private java.util.List jj_expentries = new java.util.ArrayList();
   private int[] jj_expentry;
   private int jj_kind = -1;
   private int[] jj_lasttokens = new int[100];
@@ -3594,31 +3626,26 @@
       for (int i = 0; i < jj_endpos; i++) {
         jj_expentry[i] = jj_lasttokens[i];
       }
-      boolean exists = false;
-      for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
-        int[] oldentry = (int[])(e.nextElement());
+      jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
+        int[] oldentry = (int[])(it.next());
         if (oldentry.length == jj_expentry.length) {
-          exists = true;
           for (int i = 0; i < jj_expentry.length; i++) {
             if (oldentry[i] != jj_expentry[i]) {
-              exists = false;
-              break;
+              continue jj_entries_loop;
             }
           }
-          if (exists) break;
+          jj_expentries.add(jj_expentry);
+          break jj_entries_loop;
         }
       }
-      if (!exists) jj_expentries.addElement(jj_expentry);
       if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
     }
   }
 
+  /** Generate ParseException. */
   public ParseException generateParseException() {
-    jj_expentries.removeAllElements();
-    boolean[] la1tokens = new boolean[71];
-    for (int i = 0; i < 71; i++) {
-      la1tokens[i] = false;
-    }
+    jj_expentries.clear();
+    boolean[] la1tokens = new boolean[74];
     if (jj_kind >= 0) {
       la1tokens[jj_kind] = true;
       jj_kind = -1;
@@ -3638,11 +3665,11 @@
         }
       }
     }
-    for (int i = 0; i < 71; i++) {
+    for (int i = 0; i < 74; i++) {
       if (la1tokens[i]) {
         jj_expentry = new int[1];
         jj_expentry[0] = i;
-        jj_expentries.addElement(jj_expentry);
+        jj_expentries.add(jj_expentry);
       }
     }
     jj_endpos = 0;
@@ -3650,20 +3677,23 @@
     jj_add_error_token(0, 0);
     int[][] exptokseq = new int[jj_expentries.size()][];
     for (int i = 0; i < jj_expentries.size(); i++) {
-      exptokseq[i] = (int[])jj_expentries.elementAt(i);
+      exptokseq[i] = (int[])jj_expentries.get(i);
     }
     return new ParseException(token, exptokseq, tokenImage);
   }
 
+  /** Enable tracing. */
   final public void enable_tracing() {
   }
 
+  /** Disable tracing. */
   final public void disable_tracing() {
   }
 
-  final private void jj_rescan_token() {
+  private void jj_rescan_token() {
     jj_rescan = true;
     for (int i = 0; i < 12; i++) {
+    try {
       JJCalls p = jj_2_rtns[i];
       do {
         if (p.gen > jj_gen) {
@@ -3685,11 +3715,12 @@
         }
         p = p.next;
       } while (p != null);
+      } catch(LookaheadSuccess ls) { }
     }
     jj_rescan = false;
   }
 
-  final private void jj_save(int index, int xla) {
+  private void jj_save(int index, int xla) {
     JJCalls p = jj_2_rtns[index];
     while (p.gen > jj_gen) {
       if (p.next == null) { p = p.next = new JJCalls(); break; }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.jj
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.jj?rev=731779&r1=731778&r2=731779&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.jj (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.jj Mon Jan  5 16:10:57 2009
@@ -1,4 +1,4 @@
-/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. Parser.jj */
+/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. C:\java\apache\velocity\head\src\java\org\apache\velocity\runtime\parser\Parser.jj */
 /*@egen*//*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -15,7 +15,7 @@
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 
 /*
@@ -23,14 +23,39 @@
  *    to always have to page past it... :)
  */
 options
-{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
+{
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
     /**
      * The parser must be non-static in order for the
      * above option to work, otherwise the parser value
      * is passed in as null, which isn't all the useful ;)
      */
-    STATIC=false;                                                                                                                                                                                                                                                                                                              
+    STATIC=false;
+
+
+
+
+
+
+
+
+
 
     /**
      * Declare that we are accepting unicode input and
@@ -62,6 +87,7 @@
 import org.apache.velocity.runtime.directive.Macro;
 import org.apache.velocity.runtime.directive.MacroParseException;
 import org.apache.velocity.util.StringUtils;
+import org.apache.commons.lang.text.StrBuilder;
 
 /**
  * This class is responsible for parsing a Velocity
@@ -83,9 +109,9 @@
 
 /*@egen*/
     /**
-     *  This Hashtable contains a list of all of the dynamic directives.
+     *  This Map contains a list of all of the dynamic directives.
      */
-    private Hashtable directives = new Hashtable(0);
+    private Map directives = new HashMap();
 
     /**
      *  Name of current template we are parsing.  Passed to us in parse()
@@ -196,7 +222,7 @@
      */
     public void setDirectives(Hashtable directives)
     {
-        this.directives = directives;
+        this.directives = new HashMap(directives);
     }
 
     /**
@@ -228,7 +254,7 @@
         String strDirective = strImage.substring(iLast + 1);
 
         boolean bRecognizedDirective = false;
-        
+
         // we don't have to call substring method all the time in this method
         String dirTag = strDirective.substring(1);
         if (dirTag.charAt(0) == '{')
@@ -329,7 +355,8 @@
     private int lparen = 0;
     private int rparen = 0;
 
-    Stack stateStack = new Stack();
+    List stateStack = new ArrayList(50);
+
     public boolean debugPrint = false;
 
     private boolean inReference;
@@ -347,14 +374,14 @@
      */
     public boolean stateStackPop()
     {
-        Hashtable h;
-
+        ParserState s;
         try
         {
-            h = (Hashtable) stateStack.pop();
+            s = (ParserState) stateStack.remove(stateStack.size() - 1); // stack.pop
         }
-        catch( EmptyStackException e)
+        catch(IndexOutOfBoundsException e)
         {
+            // empty stack
             lparen=0;
             SwitchTo(DEFAULT);
             return false;
@@ -363,13 +390,13 @@
         if( debugPrint )
             System.out.println(
                 " stack pop (" + stateStack.size() + ") : lparen=" +
-                    ( (Integer) h.get("lparen")).intValue() +
-                        " newstate=" + ( (Integer) h.get("lexstate")).intValue() );
+                    s.lparen +
+                        " newstate=" + s.lexstate );
 
-        lparen = ( (Integer) h.get("lparen")).intValue();
-        rparen = ( (Integer) h.get("rparen")).intValue();
+        lparen = s.lparen;
+        rparen = s.rparen;
 
-        SwitchTo( ( (Integer) h.get("lexstate")).intValue() );
+        SwitchTo(s.lexstate);
 
         return true;
     }
@@ -385,15 +412,13 @@
             System.out.println(" (" + stateStack.size() + ") pushing cur state : " +
                 curLexState );
 
-        Hashtable h = new Hashtable();
-
-        h.put("lexstate", new Integer( curLexState ) );
-        h.put("lparen", new Integer( lparen ));
-        h.put("rparen", new Integer( rparen ));
+        ParserState s = new ParserState();
+        s.lparen = lparen;
+        s.rparen = rparen;
+        s.lexstate = curLexState;
 
         lparen = 0;
-
-        stateStack.push( h );
+        stateStack.add(s); // stack.push
 
         return true;
     }
@@ -402,7 +427,6 @@
      *  Clears all state variables, resets to
      *  start values, clears stateStack.  Call
      *  before parsing.
-     *  @return void
      */
     public void clearStateVars()
     {
@@ -419,6 +443,16 @@
     }
 
     /**
+     * Holds the state of the parsing process.
+     */
+    private class ParserState
+    {
+        int lparen;
+        int rparen;
+        int lexstate;
+    }
+
+    /**
      *  handles the dropdown logic when encountering a RPAREN
      */
     private void RPARENHandler()
@@ -491,7 +525,7 @@
      stateStackPush();
      SwitchTo(REFINDEX);
    }
-  
+
 }
 
 <REFINDEX>
@@ -500,7 +534,7 @@
    <INDEX_RBRACKET: "]">
    {
      stateStackPop();
-   }  
+   }
 }
 
 
@@ -718,6 +752,16 @@
         }
     }
 
+|   "#[["
+    {
+       if (!inComment)
+       {
+           inComment = true;
+           stateStackPush();
+           SwitchTo( IN_TEXTBLOCK );
+       }
+    }
+
 |   <"#**" ~["#"]>
     {
     	if (!inComment)
@@ -834,12 +878,28 @@
   }
 }
 
+<IN_TEXTBLOCK>
+TOKEN :
+{
+  <TEXTBLOCK: "]]#" >
+  {
+    inComment = false;
+    stateStackPop();
+  }
+}
+
 <IN_SINGLE_LINE_COMMENT,IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
 SKIP :
 {
   < ~[] >
 }
 
+<IN_TEXTBLOCK>
+MORE :
+{
+  < ~[] >
+}
+
 /* -----------------------------------------------------------------------
  *
  *  DIRECTIVE Lexical State (some of it, anyway)
@@ -1061,7 +1121,7 @@
  *          |       re stateStack.
  *          |-- >  REFMOD2 : state switch to when the LPAREN is encountered.
  *                  again, this is a switch, not a push.
- * 
+ *
  *  During the REFERENCE or REFMODIFIER lex states we will switch to
  *  REFINDEX if a bracket is encountered '['.  for example:  $foo[1]
  *  or $foo.bar[1], $foo.bar( "arg" )[1]
@@ -1198,6 +1258,7 @@
 |   StopStatement()
 |   LOOKAHEAD(2) Reference()
 |   Comment()
+|   Textblock()
 |   SetDirective()
 |   EscapedDirective()
 |   Escape()
@@ -1332,6 +1393,23 @@
 /*@egen*/
 }
 
+void Textblock() : {/*@bgen(jjtree) Textblock */
+  ASTTextblock jjtn000 = new ASTTextblock(this, JJTTEXTBLOCK);
+  boolean jjtc000 = true;
+  jjtree.openNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Textblock */
+   try {
+/*@egen*/
+   <TEXTBLOCK>/*@bgen(jjtree)*/
+   } finally {
+     if (jjtc000) {
+       jjtree.closeNodeScope(jjtn000, true);
+     }
+   }
+/*@egen*/
+}
+
 void FloatingPointLiteral() : {/*@bgen(jjtree) FloatingPointLiteral */
   ASTFloatingPointLiteral jjtn000 = new ASTFloatingPointLiteral(this, JJTFLOATINGPOINTLITERAL);
   boolean jjtc000 = true;
@@ -1733,7 +1811,7 @@
       |
       [ <WHITESPACE> ]
      )
-     
+
      /** note: need both tokens as they are generated in different states **/
      ( <RIGHT_CURLEY> | <RCURLY> )/*@bgen(jjtree)*/
     } catch (Throwable jjte000) {
@@ -2061,7 +2139,7 @@
         jjtree.closeNodeScope(jjtn000, true);
       }
     }
-/*@egen*/    
+/*@egen*/
 }
 
 /* -----------------------------------------------------------------------
@@ -2168,7 +2246,7 @@
         jjtree.closeNodeScope(jjtn001, true);
       }
     }
-/*@egen*//*@bgen(jjtree)*/
+/*@egen*/       /*@bgen(jjtree)*/
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
@@ -2228,7 +2306,7 @@
         jjtree.closeNodeScope(jjtn001, true);
       }
     }
-/*@egen*//*@bgen(jjtree)*/
+/*@egen*/       /*@bgen(jjtree)*/
     } catch (Throwable jjte000) {
       if (jjtc000) {
         jjtree.clearNodeScope(jjtn000);
@@ -2419,7 +2497,7 @@
                        jjtree.closeNodeScope(jjtn001,  2);
                      }
                    }
-/*@egen*/ )*
+/*@egen*/            )*
 }
 
 
@@ -2453,7 +2531,7 @@
                       jjtree.closeNodeScope(jjtn001,  2);
                     }
                   }
-/*@egen*/ )*
+/*@egen*/             )*
 }
 
 void EqualityExpression()       : {}

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParserConstants.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParserConstants.java?rev=731779&r1=731778&r2=731779&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParserConstants.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParserConstants.java Mon Jan  5 16:10:57 2009
@@ -1,89 +1,178 @@
 /* Generated By:JJTree&JavaCC: Do not edit this line. ParserConstants.java */
 package org.apache.velocity.runtime.parser;
 
+
+/**
+ * Token literal values and constants.
+ * Generated by org.javacc.parser.OtherFilesGen#start()
+ */
 public interface ParserConstants {
 
+  /** End of File. */
   int EOF = 0;
+  /** RegularExpression Id. */
   int INDEX_LBRACKET = 1;
+  /** RegularExpression Id. */
   int INDEX_RBRACKET = 2;
+  /** RegularExpression Id. */
   int LBRACKET = 3;
+  /** RegularExpression Id. */
   int RBRACKET = 4;
+  /** RegularExpression Id. */
   int COMMA = 5;
+  /** RegularExpression Id. */
   int DOUBLEDOT = 6;
+  /** RegularExpression Id. */
   int COLON = 7;
+  /** RegularExpression Id. */
   int LEFT_CURLEY = 8;
+  /** RegularExpression Id. */
   int RIGHT_CURLEY = 9;
+  /** RegularExpression Id. */
   int LPAREN = 10;
+  /** RegularExpression Id. */
   int RPAREN = 11;
+  /** RegularExpression Id. */
   int REFMOD2_RPAREN = 12;
+  /** RegularExpression Id. */
   int ESCAPE_DIRECTIVE = 13;
+  /** RegularExpression Id. */
   int SET_DIRECTIVE = 14;
+  /** RegularExpression Id. */
   int DOLLAR = 15;
+  /** RegularExpression Id. */
   int DOLLARBANG = 16;
-  int HASH = 19;
-  int SINGLE_LINE_COMMENT_START = 20;
-  int DOUBLE_ESCAPE = 21;
-  int ESCAPE = 22;
-  int TEXT = 23;
-  int SINGLE_LINE_COMMENT = 24;
-  int FORMAL_COMMENT = 25;
-  int MULTI_LINE_COMMENT = 26;
-  int WHITESPACE = 28;
-  int STRING_LITERAL = 29;
-  int TRUE = 30;
-  int FALSE = 31;
-  int NEWLINE = 32;
-  int MINUS = 33;
-  int PLUS = 34;
-  int MULTIPLY = 35;
-  int DIVIDE = 36;
-  int MODULUS = 37;
-  int LOGICAL_AND = 38;
-  int LOGICAL_OR = 39;
-  int LOGICAL_LT = 40;
-  int LOGICAL_LE = 41;
-  int LOGICAL_GT = 42;
-  int LOGICAL_GE = 43;
-  int LOGICAL_EQUALS = 44;
-  int LOGICAL_NOT_EQUALS = 45;
-  int LOGICAL_NOT = 46;
-  int EQUALS = 47;
-  int END = 48;
-  int IF_DIRECTIVE = 49;
-  int ELSEIF_DIRECTIVE = 50;
-  int ELSE_DIRECTIVE = 51;
-  int STOP_DIRECTIVE = 52;
-  int DIGIT = 53;
-  int INTEGER_LITERAL = 54;
-  int FLOATING_POINT_LITERAL = 55;
-  int EXPONENT = 56;
-  int LETTER = 57;
-  int DIRECTIVE_CHAR = 58;
-  int WORD = 59;
-  int BRACKETED_WORD = 60;
-  int ALPHA_CHAR = 61;
-  int ALPHANUM_CHAR = 62;
-  int IDENTIFIER_CHAR = 63;
-  int IDENTIFIER = 64;
-  int DOT = 65;
-  int LCURLY = 66;
-  int RCURLY = 67;
-  int REFERENCE_TERMINATOR = 68;
-  int DIRECTIVE_TERMINATOR = 69;
-  int EMPTY_INDEX = 70;
+  /** RegularExpression Id. */
+  int HASH = 20;
+  /** RegularExpression Id. */
+  int SINGLE_LINE_COMMENT_START = 21;
+  /** RegularExpression Id. */
+  int DOUBLE_ESCAPE = 22;
+  /** RegularExpression Id. */
+  int ESCAPE = 23;
+  /** RegularExpression Id. */
+  int TEXT = 24;
+  /** RegularExpression Id. */
+  int SINGLE_LINE_COMMENT = 25;
+  /** RegularExpression Id. */
+  int FORMAL_COMMENT = 26;
+  /** RegularExpression Id. */
+  int MULTI_LINE_COMMENT = 27;
+  /** RegularExpression Id. */
+  int TEXTBLOCK = 28;
+  /** RegularExpression Id. */
+  int WHITESPACE = 31;
+  /** RegularExpression Id. */
+  int STRING_LITERAL = 32;
+  /** RegularExpression Id. */
+  int TRUE = 33;
+  /** RegularExpression Id. */
+  int FALSE = 34;
+  /** RegularExpression Id. */
+  int NEWLINE = 35;
+  /** RegularExpression Id. */
+  int MINUS = 36;
+  /** RegularExpression Id. */
+  int PLUS = 37;
+  /** RegularExpression Id. */
+  int MULTIPLY = 38;
+  /** RegularExpression Id. */
+  int DIVIDE = 39;
+  /** RegularExpression Id. */
+  int MODULUS = 40;
+  /** RegularExpression Id. */
+  int LOGICAL_AND = 41;
+  /** RegularExpression Id. */
+  int LOGICAL_OR = 42;
+  /** RegularExpression Id. */
+  int LOGICAL_LT = 43;
+  /** RegularExpression Id. */
+  int LOGICAL_LE = 44;
+  /** RegularExpression Id. */
+  int LOGICAL_GT = 45;
+  /** RegularExpression Id. */
+  int LOGICAL_GE = 46;
+  /** RegularExpression Id. */
+  int LOGICAL_EQUALS = 47;
+  /** RegularExpression Id. */
+  int LOGICAL_NOT_EQUALS = 48;
+  /** RegularExpression Id. */
+  int LOGICAL_NOT = 49;
+  /** RegularExpression Id. */
+  int EQUALS = 50;
+  /** RegularExpression Id. */
+  int END = 51;
+  /** RegularExpression Id. */
+  int IF_DIRECTIVE = 52;
+  /** RegularExpression Id. */
+  int ELSEIF_DIRECTIVE = 53;
+  /** RegularExpression Id. */
+  int ELSE_DIRECTIVE = 54;
+  /** RegularExpression Id. */
+  int STOP_DIRECTIVE = 55;
+  /** RegularExpression Id. */
+  int DIGIT = 56;
+  /** RegularExpression Id. */
+  int INTEGER_LITERAL = 57;
+  /** RegularExpression Id. */
+  int FLOATING_POINT_LITERAL = 58;
+  /** RegularExpression Id. */
+  int EXPONENT = 59;
+  /** RegularExpression Id. */
+  int LETTER = 60;
+  /** RegularExpression Id. */
+  int DIRECTIVE_CHAR = 61;
+  /** RegularExpression Id. */
+  int WORD = 62;
+  /** RegularExpression Id. */
+  int BRACKETED_WORD = 63;
+  /** RegularExpression Id. */
+  int ALPHA_CHAR = 64;
+  /** RegularExpression Id. */
+  int ALPHANUM_CHAR = 65;
+  /** RegularExpression Id. */
+  int IDENTIFIER_CHAR = 66;
+  /** RegularExpression Id. */
+  int IDENTIFIER = 67;
+  /** RegularExpression Id. */
+  int DOT = 68;
+  /** RegularExpression Id. */
+  int LCURLY = 69;
+  /** RegularExpression Id. */
+  int RCURLY = 70;
+  /** RegularExpression Id. */
+  int REFERENCE_TERMINATOR = 71;
+  /** RegularExpression Id. */
+  int DIRECTIVE_TERMINATOR = 72;
+  /** RegularExpression Id. */
+  int EMPTY_INDEX = 73;
 
+  /** Lexical state. */
   int REFERENCE = 0;
+  /** Lexical state. */
   int REFMODIFIER = 1;
+  /** Lexical state. */
   int REFINDEX = 2;
+  /** Lexical state. */
   int DIRECTIVE = 3;
+  /** Lexical state. */
   int REFMOD2 = 4;
+  /** Lexical state. */
   int DEFAULT = 5;
+  /** Lexical state. */
   int REFMOD = 6;
+  /** Lexical state. */
   int PRE_DIRECTIVE = 7;
-  int IN_MULTI_LINE_COMMENT = 8;
-  int IN_FORMAL_COMMENT = 9;
-  int IN_SINGLE_LINE_COMMENT = 10;
+  /** Lexical state. */
+  int IN_TEXTBLOCK = 8;
+  /** Lexical state. */
+  int IN_MULTI_LINE_COMMENT = 9;
+  /** Lexical state. */
+  int IN_FORMAL_COMMENT = 10;
+  /** Lexical state. */
+  int IN_SINGLE_LINE_COMMENT = 11;
 
+  /** Literal token values. */
   String[] tokenImage = {
     "<EOF>",
     "\"[\"",
@@ -102,7 +191,8 @@
     "<SET_DIRECTIVE>",
     "<DOLLAR>",
     "<DOLLARBANG>",
-    "<token of kind 17>",
+    "\"#[[\"",
+    "<token of kind 18>",
     "\"#*\"",
     "\"#\"",
     "\"##\"",
@@ -112,7 +202,9 @@
     "<SINGLE_LINE_COMMENT>",
     "\"*#\"",
     "\"*#\"",
-    "<token of kind 27>",
+    "\"]]#\"",
+    "<token of kind 29>",
+    "<token of kind 30>",
     "<WHITESPACE>",
     "<STRING_LITERAL>",
     "\"true\"",



Mime
View raw message