[318281] EL validation error for quote escaping
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JJTJSPELParserState.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JJTJSPELParserState.java
index aedb1a2..951a84b 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JJTJSPELParserState.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JJTJSPELParserState.java
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 BEA Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BEA Systems - initial implementation
+ * IBM Corporation - Bug 318281 - EL validation error for quote escaping
+ *
+ *******************************************************************************/
/* Generated By:JavaCC: Do not edit this line. JJTJSPELParserState.java Version 4.2 */
package org.eclipse.jst.jsp.core.internal.java.jspel;
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPEL.jj b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPEL.jj
index 57c3c74..499e8c6 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPEL.jj
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPEL.jj
@@ -1,6 +1,6 @@
/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. JSPEL.jj */
/*@egen*//*******************************************************************************
- * Copyright (c) 2005 BEA Systems and others.
+ * Copyright (c) 2005, 2010 BEA Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,8 @@
*
* Contributors:
* BEA Systems - initial implementation
- *
+ * IBM Corporation - Bug 318281 - EL validation error for quote escaping
+ *
*******************************************************************************/
/* I know that having some of these options on one line is rude but
* if we don't do that the line number reported from javacc are off
@@ -76,8 +77,8 @@
< #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
|
< STRING_LITERAL:
- ("\"" ((~["\"","\\"]) | ("\\" ( ["\\","\""] )))* "\"") |
- ("\'" ((~["\'","\\"]) | ("\\" ( ["\\","\'"] )))* "\'")
+ ("\"" ((~["\"","\\"]) | ("\\" ( ["\\","\"","\'"] )))* "\"") |
+ ("\'" ((~["\'","\\"]) | ("\\" ( ["\\","\'","\""] )))* "\'")
>
|
< BADLY_ESCAPED_STRING_LITERAL:
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPEL.jjt b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPEL.jjt
index 677fbb9..66d2c79 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPEL.jjt
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPEL.jjt
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 BEA Systems and others.
+ * Copyright (c) 2005, 2010 BEA Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,8 @@
*
* Contributors:
* BEA Systems - initial implementation
- *
+ * IBM Corporation - Bug 318281 - EL validation error for quote escaping
+ *
*******************************************************************************/
/* I know that having some of these options on one line is rude but
* if we don't do that the line number reported from javacc are off
@@ -72,8 +73,8 @@
< #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
|
< STRING_LITERAL:
- ("\"" ((~["\"","\\"]) | ("\\" ( ["\\","\""] )))* "\"") |
- ("\'" ((~["\'","\\"]) | ("\\" ( ["\\","\'"] )))* "\'")
+ ("\"" ((~["\"","\\"]) | ("\\" ( ["\\","\"","\'"] )))* "\"") |
+ ("\'" ((~["\'","\\"]) | ("\\" ( ["\\","\'","\""] )))* "\'")
>
|
< BADLY_ESCAPED_STRING_LITERAL:
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPELParser.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPELParser.java
index 56e6425..9e3c2e7 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPELParser.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPELParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 BEA Systems and others.
+ * Copyright (c) 2005, 2010 BEA Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,8 @@
*
* Contributors:
* BEA Systems - initial implementation
- *
+ * IBM Corporation - Bug 318281 - EL validation error for quote escaping
+ *
*******************************************************************************/
/* Generated By:JJTree&JavaCC: Do not edit this line. JSPELParser.java */
package org.eclipse.jst.jsp.core.internal.java.jspel;
@@ -65,10 +66,10 @@
throw new ParseException();
}
}
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtreeCloseNodeScope(jjtn000);
- {if (true) return jjtn000;}
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {if (true) return jjtn000;}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
@@ -1275,7 +1276,7 @@
}
/** Constructor with InputStream and supplied encoding */
public JSPELParser(java.io.InputStream stream, String encoding) {
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
+ try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source = new JSPELParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
@@ -1290,7 +1291,7 @@
}
/** Reinitialise. */
public void ReInit(java.io.InputStream stream, String encoding) {
- jj_input_stream.ReInit(stream, 1, 1);
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
@@ -1420,7 +1421,7 @@
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];
@@ -1435,18 +1436,16 @@
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 (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
@@ -1455,11 +1454,8 @@
/** Generate ParseException. */
public ParseException generateParseException() {
- jj_expentries.removeAllElements();
+ jj_expentries.clear();
boolean[] la1tokens = new boolean[51];
- for (int i = 0; i < 51; i++) {
- la1tokens[i] = false;
- }
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
@@ -1480,7 +1476,7 @@
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;
@@ -1488,7 +1484,7 @@
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);
}
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPELParserTokenManager.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPELParserTokenManager.java
index 50b04d0..4c727ea 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPELParserTokenManager.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/JSPELParserTokenManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 BEA Systems and others.
+ * Copyright (c) 2005, 2010 BEA Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,14 +7,19 @@
*
* Contributors:
* BEA Systems - initial implementation
- *
+ * IBM Corporation - Bug 318281 - EL validation error for quote escaping
+ *
*******************************************************************************/
/* Generated By:JJTree&JavaCC: Do not edit this line. JSPELParserTokenManager.java */
package org.eclipse.jst.jsp.core.internal.java.jspel;
+/** Token Manager. */
public class JSPELParserTokenManager implements JSPELParserConstants
{
+
+ /** Debug output. */
public java.io.PrintStream debugStream = System.out;
+ /** Set debug output. */
public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
private final int jjStopStringLiteralDfa_0(int pos, long active0)
{
@@ -67,21 +72,13 @@
{
return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
}
-private final int jjStopAtPos(int pos, int kind)
+private int jjStopAtPos(int pos, int kind)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
return pos + 1;
}
-private final int jjStartNfaWithStates_0(int pos, int kind, int state)
-{
- jjmatchedKind = kind;
- jjmatchedPos = pos;
- try { curChar = input_stream.readChar(); }
- catch(java.io.IOException e) { return pos + 1; }
- return jjMoveNfa_0(state, pos + 1);
-}
-private final int jjMoveStringLiteralDfa0_0()
+private int jjMoveStringLiteralDfa0_0()
{
switch(curChar)
{
@@ -150,7 +147,7 @@
return jjMoveNfa_0(0, 0);
}
}
-private final int jjMoveStringLiteralDfa1_0(long active0)
+private int jjMoveStringLiteralDfa1_0(long active0)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
@@ -216,10 +213,10 @@
}
return jjStartNfa_0(0, active0);
}
-private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
+private int jjMoveStringLiteralDfa2_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
- return jjStartNfa_0(0, old0);
+ return jjStartNfa_0(0, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(1, active0);
@@ -252,10 +249,10 @@
}
return jjStartNfa_0(1, active0);
}
-private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
+private int jjMoveStringLiteralDfa3_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
- return jjStartNfa_0(1, old0);
+ return jjStartNfa_0(1, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(2, active0);
@@ -280,10 +277,10 @@
}
return jjStartNfa_0(2, active0);
}
-private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
+private int jjMoveStringLiteralDfa4_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
- return jjStartNfa_0(2, old0);
+ return jjStartNfa_0(2, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(3, active0);
@@ -304,36 +301,14 @@
}
return jjStartNfa_0(3, active0);
}
-private final void jjCheckNAdd(int state)
+private int jjStartNfaWithStates_0(int pos, int kind, int state)
{
- if (jjrounds[state] != jjround)
- {
- jjstateSet[jjnewStateCnt++] = state;
- jjrounds[state] = jjround;
- }
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_0(state, pos + 1);
}
-private final void jjAddStates(int start, int end)
-{
- do {
- jjstateSet[jjnewStateCnt++] = jjnextStates[start];
- } while (start++ != end);
-}
-private final void jjCheckNAddTwoStates(int state1, int state2)
-{
- jjCheckNAdd(state1);
- jjCheckNAdd(state2);
-}
-private final void jjCheckNAddStates(int start, int end)
-{
- do {
- jjCheckNAdd(jjnextStates[start]);
- } while (start++ != end);
-}
-//private final void jjCheckNAddStates(int start)
-//{
-// jjCheckNAdd(jjnextStates[start]);
-// jjCheckNAdd(jjnextStates[start + 1]);
-//}
static final long[] jjbitVec0 = {
0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
};
@@ -358,7 +333,7 @@
static final long[] jjbitVec8 = {
0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
};
-private final int jjMoveNfa_0(int startState, int curPos)
+private int jjMoveNfa_0(int startState, int curPos)
{
int startsAt = 0;
jjnewStateCnt = 35;
@@ -372,8 +347,7 @@
if (curChar < 64)
{
long l = 1L << curChar;
- // MatchLoop:
- do
+ do
{
switch(jjstateSet[--i])
{
@@ -496,7 +470,7 @@
jjCheckNAddStates(15, 17);
break;
case 22:
- if (curChar == 34)
+ if ((0x8400000000L & l) != 0L)
jjCheckNAddStates(15, 17);
break;
case 23:
@@ -520,7 +494,7 @@
jjCheckNAddStates(18, 20);
break;
case 30:
- if (curChar == 39)
+ if ((0x8400000000L & l) != 0L)
jjCheckNAddStates(18, 20);
break;
case 31:
@@ -542,8 +516,7 @@
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
- //MatchLoop:
- do
+ do
{
switch(jjstateSet[--i])
{
@@ -623,8 +596,7 @@
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
- //MatchLoop:
- do
+ do
{
switch(jjstateSet[--i])
{
@@ -692,7 +664,7 @@
return ((jjbitVec5[i2] & l2) != 0L);
case 61:
return ((jjbitVec6[i2] & l2) != 0L);
- default :
+ default :
if ((jjbitVec0[i1] & l1) != 0L)
return true;
return false;
@@ -704,12 +676,14 @@
{
case 0:
return ((jjbitVec8[i2] & l2) != 0L);
- default :
+ default :
if ((jjbitVec7[i1] & l1) != 0L)
return true;
return false;
}
}
+
+/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, "\164\162\165\145",
"\146\141\154\163\145", "\156\165\154\154", "\56", "\76", "\147\164", "\74", "\154\164", "\75\75",
@@ -717,8 +691,10 @@
"\51", "\54", "\72", "\133", "\135", "\53", "\55", "\52", "\57", "\144\151\166",
"\45", "\155\157\144", "\156\157\164", "\41", "\141\156\144", "\46\46", "\157\162",
"\174\174", "\145\155\160\164\171", "\77", null, null, null, null, };
+
+/** Lexer state names. */
public static final String[] lexStateNames = {
- "DEFAULT",
+ "DEFAULT",
};
static final long[] jjtoToken = {
0xffffffffff61L,
@@ -730,17 +706,20 @@
private final int[] jjrounds = new int[35];
private final int[] jjstateSet = new int[70];
protected char curChar;
-public JSPELParserTokenManager(SimpleCharStream stream)
-{
+/** Constructor. */
+public JSPELParserTokenManager(SimpleCharStream stream){
if (SimpleCharStream.staticFlag)
throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
input_stream = stream;
}
-public JSPELParserTokenManager(SimpleCharStream stream, int lexState)
-{
+
+/** Constructor. */
+public JSPELParserTokenManager(SimpleCharStream stream, int lexState){
this(stream);
SwitchTo(lexState);
}
+
+/** Reinitialise parser. */
public void ReInit(SimpleCharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
@@ -748,18 +727,22 @@
input_stream = stream;
ReInitRounds();
}
-private final void ReInitRounds()
+private void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 35; i-- > 0;)
jjrounds[i] = 0x80000000;
}
+
+/** Reinitialise parser. */
public void ReInit(SimpleCharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
+
+/** Switch to specified lex state. */
public void SwitchTo(int lexState)
{
if (lexState >= 1 || lexState < 0)
@@ -770,14 +753,25 @@
protected Token jjFillToken()
{
- Token t = Token.newToken(jjmatchedKind);
- t.kind = jjmatchedKind;
+ final Token t;
+ final String curTokenImage;
+ final int beginLine;
+ final int endLine;
+ final int beginColumn;
+ final int endColumn;
String im = jjstrLiteralImages[jjmatchedKind];
- t.image = (im == null) ? input_stream.GetImage() : im;
- t.beginLine = input_stream.getBeginLine();
- t.beginColumn = input_stream.getBeginColumn();
- t.endLine = input_stream.getEndLine();
- t.endColumn = input_stream.getEndColumn();
+ curTokenImage = (im == null) ? input_stream.GetImage() : im;
+ beginLine = input_stream.getBeginLine();
+ beginColumn = input_stream.getBeginColumn();
+ endLine = input_stream.getEndLine();
+ endColumn = input_stream.getEndColumn();
+ t = Token.newToken(jjmatchedKind, curTokenImage);
+
+ t.beginLine = beginLine;
+ t.endLine = endLine;
+ t.beginColumn = beginColumn;
+ t.endColumn = endColumn;
+
return t;
}
@@ -788,6 +782,7 @@
int jjmatchedPos;
int jjmatchedKind;
+/** Get the next Token. */
public Token getNextToken()
{
Token matchedToken;
@@ -795,13 +790,13 @@
EOFLoop :
for (;;)
- {
- try
- {
+ {
+ try
+ {
curChar = input_stream.BeginToken();
- }
+ }
catch(java.io.IOException e)
- {
+ {
jjmatchedKind = 0;
matchedToken = jjFillToken();
return matchedToken;
@@ -852,4 +847,31 @@
}
}
+private void jjCheckNAdd(int state)
+{
+ if (jjrounds[state] != jjround)
+ {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+}
+private void jjAddStates(int start, int end)
+{
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+}
+private void jjCheckNAddTwoStates(int state1, int state2)
+{
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+}
+
+private void jjCheckNAddStates(int start, int end)
+{
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+}
+
}
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/ParseException.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/ParseException.java
index ecd5087..fbaa061 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/ParseException.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/ParseException.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 BEA Systems and others.
+ * Copyright (c) 2005, 2010 BEA Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,9 +7,11 @@
*
* Contributors:
* BEA Systems - initial implementation
- *
+ * IBM Corporation - Bug 318281 - EL validation error for quote escaping
+ *
*******************************************************************************/
-/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 4.1 */
+/* JavaCCOptions:KEEP_LINE_COL=null */
package org.eclipse.jst.jsp.core.internal.java.jspel;
/**
@@ -24,29 +26,24 @@
public class ParseException extends Exception {
/**
- * Default <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
+ * The version identifier for this Serializable class.
+ * Increment only if the <i>serialized</i> form of the
+ * class changes.
+ */
+ private static final long serialVersionUID = 1L;
-/**
+ /**
* 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>
+ * "expectedTokenSequences", and "tokenImage" set.
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
)
{
- super("");
- specialConstructor = true;
+ super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
@@ -64,20 +61,13 @@
public ParseException() {
super();
- specialConstructor = false;
}
+ /** Constructor with message. */
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
@@ -101,32 +91,29 @@
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
+ * 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
+ * from the parser) the correct error message
* gets displayed.
*/
- public String getMessage() {
- if (!specialConstructor) {
- return super.getMessage();
- }
- String expected = "";
+ private static String initialise(Token currentToken,
+ int[][] expectedTokenSequences,
+ String[] tokenImage) {
+ String eol = System.getProperty("line.separator", "\n");
+ StringBuffer expected = new StringBuffer();
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]] + " ";
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
- expected += "...";
+ expected.append("...");
}
- expected += eol + " ";
+ expected.append(eol).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
@@ -136,8 +123,11 @@
retval += tokenImage[0];
break;
}
+ retval += " " + tokenImage[tok.kind];
+ retval += " \"";
retval += add_escapes(tok.image);
- tok = tok.next;
+ retval += " \"";
+ tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
@@ -146,7 +136,7 @@
} else {
retval += "Was expecting one of:" + eol + " ";
}
- retval += expected;
+ retval += expected.toString();
return retval;
}
@@ -154,13 +144,13 @@
* 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) {
+ static String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
@@ -206,3 +196,4 @@
}
}
+/* JavaCC - OriginalChecksum=2450ea96e71c048c1be00d6aa17c7b52 (do not edit this line) */
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/SimpleCharStream.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/SimpleCharStream.java
index 8021b4b..657c505 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/SimpleCharStream.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/SimpleCharStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 BEA Systems and others.
+ * Copyright (c) 2005, 2010 BEA Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,9 +7,11 @@
*
* Contributors:
* BEA Systems - initial implementation
- *
+ * IBM Corporation - Bug 318281 - EL validation error for quote escaping
+ *
*******************************************************************************/
-/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */
+/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.1 */
+/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.eclipse.jst.jsp.core.internal.java.jspel;
/**
@@ -19,10 +21,12 @@
public class SimpleCharStream
{
+/** Whether parser is static. */
public static final boolean staticFlag = false;
int bufsize;
int available;
int tokenBegin;
+/** Position in buffer. */
public int bufpos = -1;
protected int bufline[];
protected int bufcolumn[];
@@ -38,213 +42,224 @@
protected char[] buffer;
protected int maxNextCharInd = 0;
protected int inBuf = 0;
+ protected int tabSize = 8;
+
+ protected void setTabSize(int i) { tabSize = i; }
+ protected int getTabSize(int i) { return tabSize; }
+
protected void ExpandBuff(boolean wrapAround)
{
- char[] newbuffer = new char[bufsize + 2048];
- int newbufline[] = new int[bufsize + 2048];
- int newbufcolumn[] = new int[bufsize + 2048];
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
- try
- {
- if (wrapAround)
- {
- System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- System.arraycopy(buffer, 0, newbuffer,
- bufsize - tokenBegin, bufpos);
- buffer = newbuffer;
+ try
+ {
+ if (wrapAround)
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
- System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
- System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
- bufline = newbufline;
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
- System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
- System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
- bufcolumn = newbufcolumn;
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
- maxNextCharInd = (bufpos += (bufsize - tokenBegin));
- }
- else
- {
- System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- buffer = newbuffer;
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));
+ }
+ else
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
- System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
- bufline = newbufline;
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
- System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
- bufcolumn = newbufcolumn;
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
- maxNextCharInd = (bufpos -= tokenBegin);
- }
- }
- catch (Throwable t)
- {
- throw new Error(t.getMessage());
- }
+ maxNextCharInd = (bufpos -= tokenBegin);
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new Error(t.getMessage());
+ }
- bufsize += 2048;
- available = bufsize;
- tokenBegin = 0;
+ bufsize += 2048;
+ available = bufsize;
+ tokenBegin = 0;
}
protected void FillBuff() throws java.io.IOException
{
- if (maxNextCharInd == available)
- {
- if (available == bufsize)
+ if (maxNextCharInd == available)
+ {
+ if (available == bufsize)
+ {
+ if (tokenBegin > 2048)
{
- if (tokenBegin > 2048)
- {
- bufpos = maxNextCharInd = 0;
- available = tokenBegin;
- }
- else if (tokenBegin < 0)
- bufpos = maxNextCharInd = 0;
- else
- ExpandBuff(false);
+ bufpos = maxNextCharInd = 0;
+ available = tokenBegin;
}
- else if (available > tokenBegin)
- available = bufsize;
- else if ((tokenBegin - available) < 2048)
- ExpandBuff(true);
+ else if (tokenBegin < 0)
+ bufpos = maxNextCharInd = 0;
else
- available = tokenBegin;
- }
+ ExpandBuff(false);
+ }
+ else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
- int i;
- try {
- if ((i = inputStream.read(buffer, maxNextCharInd,
- available - maxNextCharInd)) == -1)
- {
- inputStream.close();
- throw new java.io.IOException();
- }
- else
- maxNextCharInd += i;
- return;
- }
- catch(java.io.IOException e) {
- --bufpos;
- backup(0);
- if (tokenBegin == -1)
- tokenBegin = bufpos;
- throw e;
- }
+ int i;
+ try {
+ if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1)
+ {
+ inputStream.close();
+ throw new java.io.IOException();
+ }
+ else
+ maxNextCharInd += i;
+ return;
+ }
+ catch(java.io.IOException e) {
+ --bufpos;
+ backup(0);
+ if (tokenBegin == -1)
+ tokenBegin = bufpos;
+ throw e;
+ }
}
+/** Start. */
public char BeginToken() throws java.io.IOException
{
- tokenBegin = -1;
- char c = readChar();
- tokenBegin = bufpos;
+ tokenBegin = -1;
+ char c = readChar();
+ tokenBegin = bufpos;
- return c;
+ return c;
}
protected void UpdateLineColumn(char c)
{
- column++;
+ column++;
- if (prevCharIsLF)
- {
- prevCharIsLF = false;
+ if (prevCharIsLF)
+ {
+ prevCharIsLF = false;
+ line += (column = 1);
+ }
+ else if (prevCharIsCR)
+ {
+ prevCharIsCR = false;
+ if (c == '\n')
+ {
+ prevCharIsLF = true;
+ }
+ else
line += (column = 1);
- }
- else if (prevCharIsCR)
- {
- prevCharIsCR = false;
- if (c == '\n')
- {
- prevCharIsLF = true;
- }
- else
- line += (column = 1);
- }
+ }
- switch (c)
- {
- case '\r' :
- prevCharIsCR = true;
- break;
- case '\n' :
- prevCharIsLF = true;
- break;
- case '\t' :
- column--;
- column += (8 - (column & 07));
- break;
- default :
- break;
- }
+ switch (c)
+ {
+ case '\r' :
+ prevCharIsCR = true;
+ break;
+ case '\n' :
+ prevCharIsLF = true;
+ break;
+ case '\t' :
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default :
+ break;
+ }
- bufline[bufpos] = line;
- bufcolumn[bufpos] = column;
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
}
+/** Read a character. */
public char readChar() throws java.io.IOException
{
- if (inBuf > 0)
- {
- --inBuf;
+ if (inBuf > 0)
+ {
+ --inBuf;
- if (++bufpos == bufsize)
- bufpos = 0;
+ if (++bufpos == bufsize)
+ bufpos = 0;
- return buffer[bufpos];
- }
+ return buffer[bufpos];
+ }
- if (++bufpos >= maxNextCharInd)
- FillBuff();
+ if (++bufpos >= maxNextCharInd)
+ FillBuff();
- char c = buffer[bufpos];
+ char c = buffer[bufpos];
- UpdateLineColumn(c);
- return (c);
+ UpdateLineColumn(c);
+ return c;
}
/**
- * @deprecated
+ * @deprecated
* @see #getEndColumn
*/
public int getColumn() {
- return bufcolumn[bufpos];
+ return bufcolumn[bufpos];
}
/**
- * @deprecated
+ * @deprecated
* @see #getEndLine
*/
public int getLine() {
- return bufline[bufpos];
+ return bufline[bufpos];
}
+ /** Get token end column number. */
public int getEndColumn() {
- return bufcolumn[bufpos];
+ return bufcolumn[bufpos];
}
+ /** Get token end line number. */
public int getEndLine() {
return bufline[bufpos];
}
+ /** Get token beginning column number. */
public int getBeginColumn() {
- return bufcolumn[tokenBegin];
+ return bufcolumn[tokenBegin];
}
+ /** Get token beginning line number. */
public int getBeginLine() {
- return bufline[tokenBegin];
+ return bufline[tokenBegin];
}
+/** Backup a number of characters. */
public void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
- bufpos += bufsize;
+ bufpos += bufsize;
}
+ /** Constructor. */
public SimpleCharStream(java.io.Reader dstream, int startline,
int startcolumn, int buffersize)
{
@@ -258,16 +273,20 @@
bufcolumn = new int[buffersize];
}
+ /** Constructor. */
public SimpleCharStream(java.io.Reader dstream, int startline,
- int startcolumn)
+ int startcolumn)
{
- this(dstream, startline, startcolumn, 4096);
+ this(dstream, startline, startcolumn, 4096);
}
+ /** Constructor. */
public SimpleCharStream(java.io.Reader dstream)
{
- this(dstream, 1, 1, 4096);
+ this(dstream, 1, 1, 4096);
}
+
+ /** Reinitialise. */
public void ReInit(java.io.Reader dstream, int startline,
int startcolumn, int buffersize)
{
@@ -287,78 +306,128 @@
bufpos = -1;
}
+ /** Reinitialise. */
public void ReInit(java.io.Reader dstream, int startline,
- int startcolumn)
+ int startcolumn)
{
- ReInit(dstream, startline, startcolumn, 4096);
+ ReInit(dstream, startline, startcolumn, 4096);
}
+ /** Reinitialise. */
public void ReInit(java.io.Reader dstream)
{
- ReInit(dstream, 1, 1, 4096);
+ ReInit(dstream, 1, 1, 4096);
}
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ /** Constructor. */
public SimpleCharStream(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
- this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
}
- public SimpleCharStream(java.io.InputStream dstream, int startline,
- int startcolumn)
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
{
- this(dstream, startline, startcolumn, 4096);
+ this(dstream, encoding, startline, startcolumn, 4096);
}
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ /** Constructor. */
public SimpleCharStream(java.io.InputStream dstream)
{
- this(dstream, 1, 1, 4096);
+ this(dstream, 1, 1, 4096);
}
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ /** Reinitialise. */
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
- ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
}
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ /** Reinitialise. */
public void ReInit(java.io.InputStream dstream)
{
- ReInit(dstream, 1, 1, 4096);
+ ReInit(dstream, 1, 1, 4096);
}
- public void ReInit(java.io.InputStream dstream, int startline,
- int startcolumn)
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
{
- ReInit(dstream, startline, startcolumn, 4096);
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
}
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+ /** Get token literal value. */
public String GetImage()
{
- if (bufpos >= tokenBegin)
- return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
- else
- return new String(buffer, tokenBegin, bufsize - tokenBegin) +
- new String(buffer, 0, bufpos + 1);
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
}
+ /** Get the suffix. */
public char[] GetSuffix(int len)
{
- char[] ret = new char[len];
+ char[] ret = new char[len];
- if ((bufpos + 1) >= len)
- System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
- else
- {
- System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
- len - bufpos - 1);
- System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
- }
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else
+ {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
- return ret;
+ return ret;
}
+ /** Reset buffer when finished. */
public void Done()
{
- buffer = null;
- bufline = null;
- bufcolumn = null;
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
}
/**
@@ -366,47 +435,47 @@
*/
public void adjustBeginLineColumn(int newLine, int newCol)
{
- int start = tokenBegin;
- int len;
+ int start = tokenBegin;
+ int len;
- if (bufpos >= tokenBegin)
- {
- len = bufpos - tokenBegin + inBuf + 1;
- }
- else
- {
- len = bufsize - tokenBegin + bufpos + 1 + inBuf;
- }
+ if (bufpos >= tokenBegin)
+ {
+ len = bufpos - tokenBegin + inBuf + 1;
+ }
+ else
+ {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
- int i = 0, j = 0, k = 0;
- int nextColDiff = 0, columnDiff = 0;
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
- while (i < len &&
- bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
- {
- bufline[j] = newLine;
- nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
- bufcolumn[j] = newCol + columnDiff;
- columnDiff = nextColDiff;
- i++;
- }
+ while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
- if (i < len)
- {
- bufline[j] = newLine++;
- bufcolumn[j] = newCol + columnDiff;
+ if (i < len)
+ {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
- while (i++ < len)
- {
- if (bufline[j = start % bufsize] != bufline[++start % bufsize])
- bufline[j] = newLine++;
- else
- bufline[j] = newLine;
- }
- }
+ while (i++ < len)
+ {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
- line = bufline[j];
- column = bufcolumn[j];
+ line = bufline[j];
+ column = bufcolumn[j];
}
}
+/* JavaCC - OriginalChecksum=f319cd62855f4b29d5c4e9550c8852eb (do not edit this line) */
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/Token.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/Token.java
index 7159820..6bad947 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/Token.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/jspel/Token.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 BEA Systems and others.
+ * Copyright (c) 2005, 2010 BEA Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,16 +7,25 @@
*
* Contributors:
* BEA Systems - initial implementation
- *
+ * IBM Corporation - Bug 318281 - EL validation error for quote escaping
+ *
*******************************************************************************/
-/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */
+/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.eclipse.jst.jsp.core.internal.java.jspel;
/**
* Describes the input token stream.
*/
-public class Token {
+public class Token implements java.io.Serializable {
+
+ /**
+ * The version identifier for this Serializable class.
+ * Increment only if the <i>serialized</i> form of the
+ * class changes.
+ */
+ private static final long serialVersionUID = 1L;
/**
* An integer that describes the kind of this token. This numbering
@@ -25,12 +34,14 @@
*/
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 line number of the first character of this Token. */
+ public int beginLine;
+ /** The column number of the first character of this Token. */
+ public int beginColumn;
+ /** The line number of the last character of this Token. */
+ public int endLine;
+ /** The column number of the last character of this Token. */
+ public int endColumn;
/**
* The string image of the token.
@@ -62,11 +73,45 @@
public Token specialToken;
/**
+ * An optional attribute value of the Token.
+ * Tokens which are not used as syntactic sugar will often contain
+ * meaningful values that will be used later on by the compiler or
+ * interpreter. This attribute value is often different from the image.
+ * Any subclass of Token that actually wants to return a non-null value can
+ * override this method as appropriate.
+ */
+ public Object getValue() {
+ return null;
+ }
+
+ /**
+ * No-argument constructor
+ */
+ public Token() {}
+
+ /**
+ * Constructs a new token for the specified Image.
+ */
+ public Token(int kind)
+ {
+ this(kind, null);
+ }
+
+ /**
+ * Constructs a new token for the specified Image and Kind.
+ */
+ public Token(int kind, String image)
+ {
+ this.kind = kind;
+ this.image = image;
+ }
+
+ /**
* Returns the image.
*/
public String toString()
{
- return image;
+ return image;
}
/**
@@ -74,19 +119,25 @@
* 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 :
+ * you want to create if ofKind is ID, simply add something like :
*
- * case MyParserConstants.ID : return new IDToken();
+ * case MyParserConstants.ID : return new IDToken(ofKind, image);
*
* to the following switch statement. Then you can cast matchedToken
- * variable to the appropriate type and use it in your lexical actions.
+ * variable to the appropriate type and use sit in your lexical actions.
*/
- public static final Token newToken(int ofKind)
+ public static Token newToken(int ofKind, String image)
{
- switch(ofKind)
- {
- default : return new Token();
- }
+ switch(ofKind)
+ {
+ default : return new Token(ofKind, image);
+ }
+ }
+
+ public static Token newToken(int ofKind)
+ {
+ return newToken(ofKind, null);
}
}
+/* JavaCC - OriginalChecksum=688686a2181e010445ea99e501e9cd07 (do not edit this line) */