jvanzyl 00/10/26 22:14:51
Modified: src/java/org/apache/velocity/runtime/parser/node
ASTReference.java
Log:
Fix for the $foo! bug reported by Dave Bryson <[EMAIL PROTECTED]>. Fix modified
the grammar a little, resulting in change to the AST, hence the ASTReference.java fix.
Passes the current testbed cleanly.
Questions or problems to geir ([EMAIL PROTECTED]).
Revision Changes Path
1.5 +43 -8
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Index: ASTReference.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ASTReference.java 2000/10/21 22:58:41 1.4
+++ ASTReference.java 2000/10/27 05:14:48 1.5
@@ -180,28 +180,63 @@
{
Token t = getFirstToken();
- if (t.image.equals("$!"))
+ /*
+ * geirm : changed Parser.jjt to handle $foo!
+ * so the tree structure changed. Leaving this stuff here
+ * for a little while in case something bad happens. :)
+ * following line was -> if (t.image.equals("$!"))
+ */
+
+ if (t.image.startsWith("$!"))
{
referenceType = QUIET_REFERENCE;
nullString = "";
- if (t.next.image.equals("{"))
- // $!{provider.Title}
- return t.next.next.image;
- else
- // $!provider.Title
+ /*
+ * geirm : Parser.jjt change. was -> if (t.next.image.equals("{"))
+ */
+
+ if (t.image.startsWith("$!{"))
+ {
+ /*
+ * ex : $!{provider.Title}
+ */
+
+ /*
+ * geirm : Parser.jjt change. Was -> return t.next.next.image;
+ */
+
return t.next.image;
+ }
+ else
+ {
+ /*
+ * ex : $!provider.Title
+ */
+
+ /*
+ * geirm : Parser.jjt change. Was -> return t.next.image;
+ */
+
+ return t.image.substring(2);
+ }
}
else if (t.image.equals("${"))
{
- // ${provider.Title}
+ /*
+ * ex : ${provider.Title}
+ */
+
referenceType = FORMAL_REFERENCE;
nullString = literal();
return t.next.image;
}
else
{
- // $provider.Title
+ /*
+ * ex : $provider.Title
+ */
+
referenceType = NORMAL_REFERENCE;
nullString = literal();
return t.image.substring(1);