geirm 00/11/04 19:16:41
Modified: src/java/org/apache/velocity/runtime/parser Parser.jjt
Log:
Simplified the handling of REF_TERM, fixing a few small bugs that really were 1
general class. The fog is starting to clear. :)
Revision Changes Path
1.19 +28 -24
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jjt
Index: Parser.jjt
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jjt,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Parser.jjt 2000/11/04 15:29:54 1.18
+++ Parser.jjt 2000/11/05 03:16:37 1.19
@@ -127,7 +127,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Parser.jjt,v 1.18 2000/11/04 15:29:54 geirm Exp $
+ * @version $Id: Parser.jjt,v 1.19 2000/11/05 03:16:37 geirm Exp $
*/
public class Parser
{
@@ -488,12 +488,13 @@
}
}
-/*
- * in REFMOD2, we don't want to bind the whitespace and \n like we do when closing
a directive.
- */
+
<REFMOD2>
TOKEN:
{
+ /*
+ * in REFMOD2, we don't want to bind the whitespace and \n like we do when
closing a directive.
+ */
<REFMOD2_RPAREN: ")">
{
/*
@@ -856,34 +857,17 @@
<REFERENCE_TERMINATOR: ~[] >
{
/*
- * These can terminate a reference, but are needed in subsequent states
+ * push every terminator character back into the stream
*/
- if (image.toString().equals("=") || image.toString().equals("\n") ||
image.toString().equals("\r") )
- {
- input_stream.backup(1);
- }
-
+ input_stream.backup(1);
+
inReference = false;
if ( bDebugPrint_ )
System.out.print("REF_TERM :");
stateStackPop();
-
- /*
- * I removed LPAREN & RPAREN from REFERENCE; as there is no LPAREN,RPAREN
in REF is there is REFMETHOD
- */
-
- if (curLexState != DEFAULT && ( image.toString().equals(")")
- || image.toString().equals(",")
- || image.toString().equals("[")
- || image.toString().equals("]")
- ) )
- {
- input_stream.backup(1);
- }
-
}
}
@@ -1305,6 +1289,26 @@
would output
$foo $bar \$woogie
+
+
+ What You Expect
+ ---------------
+ The recent versions of the parser are trying to support precise output to
support general template use.
+ So the #set statment no longer renders to a \n in the output, nor do the
control statements. So if you
+ had a template
+
+ ------
+ #set $foo="foo"
+ #if($foo)
+ \$foo = $foo
+ #end
+ ------
+
+ it will render precisely :
+
+ ------
+ $foo = foo
+ ------
*/