geirm 01/05/29 22:55:24
Modified: src/java/org/apache/velocity/runtime/parser
ParseException.java Parser.java Parser.jj
ParserTokenManager.java Token.java
TokenMgrError.java
Log:
All autogenerated changes to support new VelocityCharStream changes.
Revision Changes Path
1.2 +172 -194
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/ParseException.java
Index: ParseException.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/ParseException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParseException.java 2000/09/30 17:04:23 1.1
+++ ParseException.java 2001/05/30 05:55:22 1.2
@@ -10,204 +10,182 @@
* You can modify this class to customize your error reporting
* mechanisms so long as you retain the public fields.
*/
-public class ParseException extends Exception
-{
+public class ParseException extends Exception {
- /**
- * This constructor is used by the method "generateParseException"
- * in the generated parser. Calling this constructor generates
- * a new object of this type with the fields "currentToken",
- * "expectedTokenSequences", and "tokenImage" set. The boolean
- * flag "specialConstructor" is also set to true to indicate that
- * this constructor was used to create this object.
- * This constructor calls its super class with the empty string
- * to force the "toString" method of parent class "Throwable" to
- * print the error message in the form:
- * ParseException: <result of getMessage>
- */
- public ParseException(Token currentTokenVal,
- int[][] expectedTokenSequencesVal, String[] tokenImageVal)
- {
- super("");
- specialConstructor = true;
- currentToken = currentTokenVal;
- expectedTokenSequences = expectedTokenSequencesVal;
- tokenImage = tokenImageVal;
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
}
-
- /**
- * The following constructors are for use by you for whatever
- * purpose you can think of. Constructing the exception in this
- * manner makes the exception behave in the normal way - i.e., as
- * documented in the class "Throwable". The fields "errorToken",
- * "expectedTokenSequences", and "tokenImage" do not contain
- * relevant information. The JavaCC generated code does not use
- * these constructors.
- */
-
- public ParseException()
- {
- super();
- specialConstructor = false;
+ String expected = "";
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected += tokenImage[expectedTokenSequences[i][j]] + " ";
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected += "...";
+ }
+ expected += eol + " ";
}
-
- public ParseException(String message)
- {
- super(message);
- specialConstructor = false;
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
}
-
- /**
- * This variable determines which constructor was used to create
- * this object and thereby affects the semantics of the
- * "getMessage" method (see below).
- */
- protected boolean specialConstructor;
-
- /**
- * This is the last token that has been consumed successfully. If
- * this object has been created due to a parse error, the token
- * followng this token will (therefore) be the first error token.
- */
- public Token currentToken;
-
- /**
- * Each entry in this array is an array of integers. Each array
- * of integers represents a sequence of tokens (by their ordinal
- * values) that is expected at this point of the parse.
- */
- public int[][] expectedTokenSequences;
-
- /**
- * This is a reference to the "tokenImage" array of the generated
- * parser within which the parse error occurred. This array is
- * defined in the generated ...Constants interface.
- */
- public String[] tokenImage;
-
- /**
- * This method has the standard behavior when this object has been
- * created using the standard constructors. Otherwise, it uses
- * "currentToken" and "expectedTokenSequences" to generate a parse
- * error message and returns it. If this object has been created
- * due to a parse error, and you do not catch it (it gets thrown
- * from the parser), then this method is called during the printing
- * of the final stack trace, and hence the correct error message
- * gets displayed.
- */
- public String getMessage()
- {
- if (!specialConstructor)
- {
- return super.getMessage();
- }
- String expected = "";
- int maxSize = 0;
- for (int i = 0; i < expectedTokenSequences.length; i++)
- {
- if (maxSize < expectedTokenSequences[i].length)
- {
- maxSize = expectedTokenSequences[i].length;
- }
- for (int j = 0; j < expectedTokenSequences[i].length; j++)
- {
- expected += tokenImage[expectedTokenSequences[i][j]] + " ";
- }
- if (expectedTokenSequences[i]
- [expectedTokenSequences[i].length - 1] != 0)
- {
- expected += "...";
- }
- expected += eol + " ";
- }
- String retval = "Encountered \"";
- Token tok = currentToken.next;
- for (int i = 0; i < maxSize; i++)
- {
- if (i != 0)
- retval += " ";
- if (tok.kind == 0)
- {
- retval += tokenImage[0];
- break;
- }
- retval += add_escapes(tok.image);
- tok = tok.next;
- }
- retval +=
- "\" at line " + currentToken.next.beginLine + ", column " +
- currentToken.next.beginColumn + "." + eol;
- if (expectedTokenSequences.length == 1)
- {
- retval += "Was expecting:" + eol + " ";
- }
- else
- {
- retval += "Was expecting one of:" + eol + " ";
- }
- retval += expected;
- return retval;
- }
-
- /**
- * The end of line string for this machine.
- */
- protected String eol = System.getProperty("line.separator", "\n");
-
- /**
- * Used to convert raw characters to their escaped version
- * when these raw version cannot be used as part of an ASCII
- * string literal.
- */
- protected String add_escapes(String str)
- {
- StringBuffer retval = new StringBuffer();
- char ch;
- for (int i = 0; i < str.length(); i++)
- {
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e)
- {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" +
- s.substring(s.length() - 4, s.length()));
- }
- else
- {
- retval.append(ch);
- }
- continue;
- }
- }
- return retval.toString();
+ retval += "\" at line " + currentToken.next.beginLine + ", column " +
currentToken.next.beginColumn + "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
}
+ retval += expected;
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
}
1.60 +58 -55
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.java
Index: Parser.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- Parser.java 2001/04/22 18:03:59 1.59
+++ Parser.java 2001/05/30 05:55:22 1.60
@@ -21,7 +21,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Parser.java,v 1.59 2001/04/22 18:03:59 geirm Exp $
+ * @version $Id: Parser.java,v 1.60 2001/05/30 05:55:22 geirm Exp $
*/
public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants, ParserConstants
{/*@bgen(jjtree)*/
protected JJTParserState jjtree = new JJTParserState();/**
@@ -34,6 +34,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
@@ -43,7 +45,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 );
}
/**
@@ -74,7 +87,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)
@@ -2202,24 +2229,6 @@
return retval;
}
- final private boolean jj_3_5() {
- if (jj_scan_token(WHITESPACE)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_66() {
- if (jj_scan_token(RCURLY)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_19() {
- if (jj_3R_32()) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
final private boolean jj_3_2() {
if (jj_3R_18()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -2488,6 +2497,12 @@
return false;
}
+ final private boolean jj_3R_55() {
+ if (jj_scan_token(WHITESPACE)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
final private boolean jj_3R_21() {
Token xsp;
xsp = jj_scanpos;
@@ -2523,12 +2538,6 @@
return false;
}
- final private boolean jj_3R_55() {
- if (jj_scan_token(WHITESPACE)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
final private boolean jj_3R_90() {
if (jj_scan_token(DIVIDE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -2944,8 +2953,25 @@
return false;
}
+ final private boolean jj_3_5() {
+ if (jj_scan_token(WHITESPACE)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_66() {
+ if (jj_scan_token(RCURLY)) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
+ final private boolean jj_3R_19() {
+ if (jj_3R_32()) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+ return false;
+ }
+
public ParserTokenManager token_source;
- ASCII_CharStream jj_input_stream;
public Token token, jj_nt;
private int jj_ntk;
private Token jj_scanpos, jj_lastpos;
@@ -2959,31 +2985,9 @@
final private JJCalls[] jj_2_rtns = new JJCalls[8];
private boolean jj_rescan = false;
private int jj_gc = 0;
-
- public Parser(java.io.InputStream stream) {
- jj_input_stream = new ASCII_CharStream(stream, 1, 1);
- token_source = new ParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 52; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- public void ReInit(java.io.InputStream stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jjtree.reset();
- jj_gen = 0;
- for (int i = 0; i < 52; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
- public Parser(java.io.Reader stream) {
- jj_input_stream = new ASCII_CharStream(stream, 1, 1);
- token_source = new ParserTokenManager(jj_input_stream);
+ public Parser(CharStream stream) {
+ token_source = new ParserTokenManager(stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
@@ -2991,9 +2995,8 @@
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
- public void ReInit(java.io.Reader stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
+ public void ReInit(CharStream stream) {
+ token_source.ReInit(stream);
token = new Token();
jj_ntk = -1;
jjtree.reset();
1.58 +47 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jj
Index: Parser.jj
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jj,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- Parser.jj 2001/04/22 18:03:59 1.57
+++ Parser.jj 2001/05/30 05:55:22 1.58
@@ -67,9 +67,25 @@
* is passed in as null, which isn't all the useful ;)
*/
STATIC=false;
-
+
+ /**
+ * 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)
@@ -96,7 +112,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Parser.jj,v 1.57 2001/04/22 18:03:59 geirm Exp $
+ * @version $Id: Parser.jj,v 1.58 2001/05/30 05:55:22 geirm Exp $
*/
public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants/*@egen*/
{/*@bgen(jjtree)*/
@@ -113,6 +129,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
@@ -122,7 +140,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 );
}
/**
@@ -153,7 +182,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)
1.44 +86 -46
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/ParserTokenManager.java
Index: ParserTokenManager.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/ParserTokenManager.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- ParserTokenManager.java 2001/03/01 03:31:26 1.43
+++ ParserTokenManager.java 2001/05/30 05:55:22 1.44
@@ -415,6 +415,9 @@
jjCheckNAdd(jjnextStates[start + 1]);
}
static final long[] jjbitVec0 = {
+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL,
0xffffffffffffffffL
+};
+static final long[] jjbitVec2 = {
0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
};
private final int jjMoveNfa_0(int startState, int curPos)
@@ -699,6 +702,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -706,15 +712,15 @@
switch(jjstateSet[--i])
{
case 6:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
case 11:
- if ((jjbitVec0[i2] & l2) != 0L)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(3, 5);
break;
case 22:
- if ((jjbitVec0[i2] & l2) != 0L)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(0, 2);
break;
default : break;
@@ -892,6 +898,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -899,7 +908,7 @@
switch(jjstateSet[--i])
{
case 1:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
default : break;
@@ -1395,6 +1404,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -1402,7 +1414,7 @@
switch(jjstateSet[--i])
{
case 1:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
default : break;
@@ -1699,6 +1711,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -1707,14 +1722,14 @@
{
case 11:
case 5:
- if ((jjbitVec0[i2] & l2) == 0L)
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
if (kind > 18)
kind = 18;
jjCheckNAdd(5);
break;
case 13:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
default : break;
@@ -1892,6 +1907,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -1899,7 +1917,7 @@
switch(jjstateSet[--i])
{
case 1:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
default : break;
@@ -2092,6 +2110,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -2099,7 +2120,7 @@
switch(jjstateSet[--i])
{
case 1:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
default : break;
@@ -2415,6 +2436,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -2422,7 +2446,7 @@
switch(jjstateSet[--i])
{
case 1:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
default : break;
@@ -2861,6 +2885,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -2868,15 +2895,15 @@
switch(jjstateSet[--i])
{
case 1:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
case 6:
- if ((jjbitVec0[i2] & l2) != 0L)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(65, 67);
break;
case 17:
- if ((jjbitVec0[i2] & l2) != 0L)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(62, 64);
break;
default : break;
@@ -3194,6 +3221,9 @@
}
else
{
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
@@ -3201,7 +3231,7 @@
switch(jjstateSet[--i])
{
case 1:
- if ((jjbitVec0[i2] & l2) != 0L && kind > 13)
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)
kind = 13;
break;
default : break;
@@ -3229,6 +3259,18 @@
21, 6, 7, 8, 6, 11, 7, 8, 14, 15, 29, 30, 31, 32, 9, 10,
12, 14, 15, 33, 34,
};
+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long
l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec2[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec0[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
public static final String[] jjstrLiteralImages = {
null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
@@ -3263,25 +3305,23 @@
static final long[] jjtoMore = {
0x40fc00L,
};
-private ASCII_CharStream input_stream;
+private CharStream input_stream;
private final int[] jjrounds = new int[42];
private final int[] jjstateSet = new int[84];
StringBuffer image;
int jjimageLen;
int lengthOfMatch;
protected char curChar;
-public ParserTokenManager(ASCII_CharStream stream)
+public ParserTokenManager(CharStream stream)
{
- if (ASCII_CharStream.staticFlag)
- throw new Error("ERROR: Cannot use a static CharStream class with a
non-static lexical analyzer.");
input_stream = stream;
}
-public ParserTokenManager(ASCII_CharStream stream, int lexState)
+public ParserTokenManager(CharStream stream, int lexState)
{
this(stream);
SwitchTo(lexState);
}
-public void ReInit(ASCII_CharStream stream)
+public void ReInit(CharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
curLexState = defaultLexState;
@@ -3295,7 +3335,7 @@
for (i = 42; i-- > 0;)
jjrounds[i] = 0x80000000;
}
-public void ReInit(ASCII_CharStream stream, int lexState)
+public void ReInit(CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
@@ -3506,7 +3546,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
/*
* push every terminator character back into the stream
*/
@@ -3524,7 +3564,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
if ( debugPrint )
System.out.print("DIRECTIVE_TERM :");
@@ -3545,7 +3585,7 @@
if (image == null)
image = new StringBuffer(new
String(input_stream.GetSuffix(jjimageLen)));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen)));
+ image.append(input_stream.GetSuffix(jjimageLen));
jjimageLen = 0;
if (! inComment)
{
@@ -3573,7 +3613,7 @@
if (image == null)
image = new StringBuffer(new
String(input_stream.GetSuffix(jjimageLen)));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen)));
+ image.append(input_stream.GetSuffix(jjimageLen));
jjimageLen = 0;
if (! inComment)
{
@@ -3601,7 +3641,7 @@
if (image == null)
image = new StringBuffer(new
String(input_stream.GetSuffix(jjimageLen)));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen)));
+ image.append(input_stream.GetSuffix(jjimageLen));
jjimageLen = 0;
if (!inComment)
{
@@ -3614,7 +3654,7 @@
if (image == null)
image = new StringBuffer(new
String(input_stream.GetSuffix(jjimageLen)));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen)));
+ image.append(input_stream.GetSuffix(jjimageLen));
jjimageLen = 0;
input_stream.backup(1);
inComment = true;
@@ -3625,7 +3665,7 @@
if (image == null)
image = new StringBuffer(new
String(input_stream.GetSuffix(jjimageLen)));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen)));
+ image.append(input_stream.GetSuffix(jjimageLen));
jjimageLen = 0;
inComment=true;
stateStackPush();
@@ -3635,7 +3675,7 @@
if (image == null)
image = new StringBuffer(new
String(input_stream.GetSuffix(jjimageLen)));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen)));
+ image.append(input_stream.GetSuffix(jjimageLen));
jjimageLen = 0;
if (! inComment)
{
@@ -3673,7 +3713,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
if (!inComment)
lparen++;
@@ -3689,14 +3729,14 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
RPARENHandler();
break;
case 7 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
/*
* need to simply switch back to REFERENCE, not drop down the stack
* because we can (infinitely) chain, ala
@@ -3709,7 +3749,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
if (! inComment)
{
inDirective = true;
@@ -3726,7 +3766,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
inComment = false;
stateStackPop();
break;
@@ -3734,7 +3774,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
inComment = false;
stateStackPop();
break;
@@ -3742,7 +3782,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
inComment = false;
stateStackPop();
break;
@@ -3750,7 +3790,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
/*
* - if we are in DIRECTIVE and haven't seen ( yet, then also drop out.
* don't forget to account for the beloved yet wierd #set
@@ -3764,7 +3804,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
if ( debugPrint )
System.out.println(" NEWLINE :");
@@ -3780,7 +3820,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
inDirective = false;
stateStackPop();
break;
@@ -3788,21 +3828,21 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
SwitchTo(DIRECTIVE);
break;
case 45 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
SwitchTo(DIRECTIVE);
break;
case 46 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
inDirective = false;
stateStackPop();
break;
@@ -3810,7 +3850,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
matchedToken.kind = EOF;
fileDepth = 0;
break;
@@ -3818,7 +3858,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
/*
* check to see if we are in set
* ex. #set $foo = $foo + 3
@@ -3834,7 +3874,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
/*
* push the alpha char back into the stream so the following identifier
* is complete
@@ -3857,7 +3897,7 @@
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
else
- image.append(new String(input_stream.GetSuffix(jjimageLen +
(lengthOfMatch = jjmatchedPos + 1))));
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch =
jjmatchedPos + 1)));
stateStackPop();
break;
default :
1.3 +73 -75
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Token.java
Index: Token.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Token.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Token.java 2000/10/17 11:27:41 1.2
+++ Token.java 2001/05/30 05:55:23 1.3
@@ -5,79 +5,77 @@
* Describes the input token stream.
*/
-public class Token
-{
- public boolean last = false;
-
- /**
- * An integer that describes the kind of this token. This numbering
- * system is determined by JavaCCParser, and a table of these numbers is
- * stored in the file ...Constants.java.
- */
- public int kind;
-
- /**
- * beginLine and beginColumn describe the position of the first character
- * of this token; endLine and endColumn describe the position of the
- * last character of this token.
- */
- public int beginLine, beginColumn, endLine, endColumn;
-
- /**
- * The string image of the token.
- */
- public String image;
-
- /**
- * A reference to the next regular (non-special) token from the input
- * stream. If this is the last token from the input stream, or if the
- * token manager has not read tokens beyond this one, this field is
- * set to null. This is true only if this token is also a regular
- * token. Otherwise, see below for a description of the contents of
- * this field.
- */
- public Token next;
-
- /**
- * This field is used to access special tokens that occur prior to this
- * token, but after the immediately preceding regular (non-special) token.
- * If there are no such special tokens, this field is set to null.
- * When there are more than one such special token, this field refers
- * to the last of these special tokens, which in turn refers to the next
- * previous special token through its specialToken field, and so on
- * until the first special token (whose specialToken field is null).
- * The next fields of special tokens refer to other special tokens that
- * immediately follow it (without an intervening regular token). If there
- * is no such token, this field is null.
- */
- public Token specialToken;
-
- /**
- * Returns the image.
- */
- public final String toString()
- {
- return image;
- }
-
- /**
- * Returns a new Token object, by default. However, if you want, you
- * can create and return subclass objects based on the value of ofKind.
- * Simply add the cases to the switch for all those special cases.
- * For example, if you have a subclass of Token called IDToken that
- * you want to create if ofKind is ID, simlpy add something like :
- *
- * case MyParserConstants.ID : return new IDToken();
- *
- * to the following switch statement. Then you can cast matchedToken
- * variable to the appropriate type and use it in your lexical actions.
- */
- public static final Token newToken(int ofKind)
- {
- switch (ofKind)
- {
- default :
- return new Token();
- }
- }
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public final String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch(ofKind)
+ {
+ default : return new Token();
+ }
+ }
+
}
1.2 +125 -141
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/TokenMgrError.java
Index: TokenMgrError.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/TokenMgrError.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TokenMgrError.java 2000/09/30 17:04:24 1.1
+++ TokenMgrError.java 2001/05/30 05:55:23 1.2
@@ -3,147 +3,131 @@
public class TokenMgrError extends Error
{
- /*
- * Ordinals for various reasons why an Error of this type can be thrown.
- */
-
- /**
- * Lexical error occured.
- */
- public static final int LEXICAL_ERROR = 0;
-
- /**
- * An attempt wass made to create a second instance of a static token manager.
- */
- public static final int STATIC_LEXER_ERROR = 1;
-
- /**
- * Tried to change to an invalid lexical state.
- */
- public static final int INVALID_LEXICAL_STATE = 2;
-
- /**
- * Detected (and bailed out of) an infinite loop in the token manager.
- */
- public static final int LOOP_DETECTED = 3;
-
- /**
- * Indicates the reason why the exception is thrown. It will have
- * one of the above 4 values.
- */
- public int errorCode;
-
- /**
- * Replaces unprintable characters by their espaced (or unicode escaped)
- * equivalents in the given string
- */
- // jvz. protected static final String addEscapes(String str) {
- public static final String addEscapes(String str)
- {
- StringBuffer retval = new StringBuffer();
- char ch;
- for (int i = 0; i < str.length(); i++)
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occured.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt wass made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
{
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e)
- {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" +
- s.substring(s.length() - 4, s.length()));
- }
- else
- {
- retval.append(ch);
- }
- continue;
- }
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
}
- return retval.toString();
- }
-
- /**
- * Returns a detailed message for the Error when it is thrown by the
- * token manager to indicate a lexical error.
- * Parameters :
- * EOFSeen : indicates if EOF caused the lexicl error
- * curLexState : lexical state in which this error occured
- * errorLine : line number when the error occured
- * errorColumn : column number when the error occured
- * errorAfter : prefix that was seen before this error occured
- * curchar : the offending character
- * Note: You can customize the lexical error message by modifying this method.
- */
- private static final String LexicalError(boolean EOFSeen,
- int lexState, int errorLine, int errorColumn,
- String errorAfter, char curChar)
- {
- return("Lexical error at line " + errorLine + ", column " +
- errorColumn + ". Encountered: " + (EOFSeen ? "<EOF> " :
- ("\"" + addEscapes(String.valueOf(curChar)) + "\"") +
- " (" + (int) curChar + "), ") + "after : \"" +
- addEscapes(errorAfter) + "\"");
- }
-
- /**
- * You can also modify the body of this method to customize your error
messages.
- * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
- * of end-users concern, so you can return something like :
- *
- * "Internal Error : Please file a bug report .... "
- *
- * from this method for such cases in the release version of your parser.
- */
- public String getMessage()
- {
- return super.getMessage();
- }
-
- /*
- * Constructors of various flavors follow.
- */
-
- public TokenMgrError()
- {
- }
-
- public TokenMgrError(String message, int reason)
- {
- super(message);
- errorCode = reason;
- }
-
- public TokenMgrError(boolean EOFSeen, int lexState, int errorLine,
- int errorColumn, String errorAfter, char curChar, int reason)
- {
- this(LexicalError(EOFSeen, lexState, errorLine, errorColumn,
- errorAfter, curChar), reason);
- }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexicl error
+ * curLexState : lexical state in which this error occured
+ * errorLine : line number when the error occured
+ * errorColumn : column number when the error occured
+ * errorAfter : prefix that was seen before this error occured
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ private static final String LexicalError(boolean EOFSeen, int lexState, int
errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) +
"\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int
errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter,
curChar), reason);
+ }
}