geirm 01/05/29 22:54:49
Modified: src/java/org/apache/velocity/runtime/parser Parser.jjt
Log:
changed to support using a VelocityCharStream rather than the default
ASCII_CharStream
Revision Changes Path
1.60 +47 -4
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.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- Parser.jjt 2001/04/22 18:03:48 1.59
+++ Parser.jjt 2001/05/30 05:54:48 1.60
@@ -91,9 +91,25 @@
* the nothing has to change in the node code.
*/
VISITOR=true;
-
+
+ /**
+ * Declare that we are accepting unicode input and
+ * that we are using a custom character stream class
+ * Note that the char stream class is really a slightly
+ * modified ASCII_CharStream, as it appears we are safe
+ * because we only deal with pre-encoding-converted
+ * Readers rather than raw input streams.
+ */
+ UNICODE_INPUT=true;
+ USER_CHAR_STREAM=true;
+
+ /**
+ * for debugging purposes. Keep false
+ */
DEBUG_PARSER=false;
DEBUG_TOKEN_MANAGER=false;
+
+
}
PARSER_BEGIN(Parser)
@@ -120,7 +136,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.59 2001/04/22 18:03:48 geirm Exp $
+ * @version $Id: Parser.jjt,v 1.60 2001/05/30 05:54:48 geirm Exp $
*/
public class Parser
{
@@ -134,6 +150,8 @@
*/
String currentTemplateName = "";
+ VelocityCharStream velcharstream = null;
+
/**
* This constructor was added to allow the re-use of parsers.
* The normal constructor takes a single argument which
@@ -143,7 +161,18 @@
*/
public Parser()
{
- this(new ByteArrayInputStream("\n".getBytes()));
+ /*
+ * need to call the CTOR first thing.
+ */
+
+ this( new VelocityCharStream(
+ new ByteArrayInputStream("\n".getBytes()), 1, 1 ));
+
+ /*
+ * now setup a VCS for later use
+ */
+ velcharstream = new VelocityCharStream(
+ new ByteArrayInputStream("\n".getBytes()), 1, 1 );
}
/**
@@ -174,7 +203,21 @@
try
{
token_source.clearStateVars();
- ReInit(reader);
+
+ /*
+ * reinitialize the VelocityCharStream
+ * with the new reader
+ */
+ velcharstream.ReInit( reader, 1, 1 );
+
+ /*
+ * now reinit the Parser with this CharStream
+ */
+ ReInit( velcharstream );
+
+ /*
+ * do that voodoo...
+ */
sn = process();
}
catch (ParseException pe)