public class Scanner implements IScanner, ITerminalSymbols {
/*
- * APIs ares - getNextToken() which return the current type of the token (this
- * value is not memorized by the scanner) - getCurrentTokenSource() which
- * provides with the token "REAL" source (aka all unicode have been
- * transformed into a correct char) - sourceStart gives the position into the
- * stream - currentPosition-1 gives the sourceEnd position into the stream
+ * APIs ares - getNextToken() which return the current type of the token
+ * (this value is not memorized by the scanner) - getCurrentTokenSource()
+ * which provides with the token "REAL" source (aka all unicode have been
+ * transformed into a correct char) - sourceStart gives the position into
+ * the stream - currentPosition-1 gives the sourceEnd position into the
+ * stream
*/
// 1.4 feature
-// private boolean assertMode;
-
+ // private boolean assertMode;
public boolean useAssertAsAnIndentifier = false;
- // flag indicating if processed source contains occurrences of keyword assert
+ // flag indicating if processed source contains occurrences of keyword
+ // assert
public boolean containsAssertKeyword = false;
public boolean recordLineSeparator;
public boolean phpMode = false;
- public boolean phpExpressionTag = false;
-
- // public Stack encapsedStringStack = null;
+ /**
+ * This token is set to TokenName.echo if a short tag block begins (i.e.
+ * >?= ... ) Directly after the "=" character the
+ * getNextToken() method returns TokenName.INLINE_HTML In the next call to
+ * the getNextToken() method the value of fFillerToken (==TokenName.echo) is
+ * returned
+ *
+ */
+ TokenName fFillerToken = TokenName.EOF;
public char currentCharacter;
public static final String INVALID_CHAR_IN_STRING = "Invalid_Char_In_String"; //$NON-NLS-1$
// ----------------optimized identifier managment------------------
- static final char[] charArray_a = new char[] { 'a' }, charArray_b = new char[] { 'b' }, charArray_c = new char[] { 'c' },
- charArray_d = new char[] { 'd' }, charArray_e = new char[] { 'e' }, charArray_f = new char[] { 'f' },
- charArray_g = new char[] { 'g' }, charArray_h = new char[] { 'h' }, charArray_i = new char[] { 'i' },
- charArray_j = new char[] { 'j' }, charArray_k = new char[] { 'k' }, charArray_l = new char[] { 'l' },
- charArray_m = new char[] { 'm' }, charArray_n = new char[] { 'n' }, charArray_o = new char[] { 'o' },
- charArray_p = new char[] { 'p' }, charArray_q = new char[] { 'q' }, charArray_r = new char[] { 'r' },
- charArray_s = new char[] { 's' }, charArray_t = new char[] { 't' }, charArray_u = new char[] { 'u' },
- charArray_v = new char[] { 'v' }, charArray_w = new char[] { 'w' }, charArray_x = new char[] { 'x' },
- charArray_y = new char[] { 'y' }, charArray_z = new char[] { 'z' };
-
- static final char[] charArray_va = new char[] { '$', 'a' }, charArray_vb = new char[] { '$', 'b' }, charArray_vc = new char[] {
- '$', 'c' }, charArray_vd = new char[] { '$', 'd' }, charArray_ve = new char[] { '$', 'e' }, charArray_vf = new char[] { '$',
- 'f' }, charArray_vg = new char[] { '$', 'g' }, charArray_vh = new char[] { '$', 'h' },
- charArray_vi = new char[] { '$', 'i' }, charArray_vj = new char[] { '$', 'j' }, charArray_vk = new char[] { '$', 'k' },
- charArray_vl = new char[] { '$', 'l' }, charArray_vm = new char[] { '$', 'm' }, charArray_vn = new char[] { '$', 'n' },
- charArray_vo = new char[] { '$', 'o' }, charArray_vp = new char[] { '$', 'p' }, charArray_vq = new char[] { '$', 'q' },
- charArray_vr = new char[] { '$', 'r' }, charArray_vs = new char[] { '$', 's' }, charArray_vt = new char[] { '$', 't' },
- charArray_vu = new char[] { '$', 'u' }, charArray_vv = new char[] { '$', 'v' }, charArray_vw = new char[] { '$', 'w' },
- charArray_vx = new char[] { '$', 'x' }, charArray_vy = new char[] { '$', 'y' }, charArray_vz = new char[] { '$', 'z' };
+ static final char[] charArray_a = new char[] { 'a' },
+ charArray_b = new char[] { 'b' }, charArray_c = new char[] { 'c' },
+ charArray_d = new char[] { 'd' }, charArray_e = new char[] { 'e' },
+ charArray_f = new char[] { 'f' }, charArray_g = new char[] { 'g' },
+ charArray_h = new char[] { 'h' }, charArray_i = new char[] { 'i' },
+ charArray_j = new char[] { 'j' }, charArray_k = new char[] { 'k' },
+ charArray_l = new char[] { 'l' }, charArray_m = new char[] { 'm' },
+ charArray_n = new char[] { 'n' }, charArray_o = new char[] { 'o' },
+ charArray_p = new char[] { 'p' }, charArray_q = new char[] { 'q' },
+ charArray_r = new char[] { 'r' }, charArray_s = new char[] { 's' },
+ charArray_t = new char[] { 't' }, charArray_u = new char[] { 'u' },
+ charArray_v = new char[] { 'v' }, charArray_w = new char[] { 'w' },
+ charArray_x = new char[] { 'x' }, charArray_y = new char[] { 'y' },
+ charArray_z = new char[] { 'z' };
+
+ static final char[] charArray_va = new char[] { '$', 'a' },
+ charArray_vb = new char[] { '$', 'b' }, charArray_vc = new char[] {
+ '$', 'c' }, charArray_vd = new char[] { '$', 'd' },
+ charArray_ve = new char[] { '$', 'e' }, charArray_vf = new char[] {
+ '$', 'f' }, charArray_vg = new char[] { '$', 'g' },
+ charArray_vh = new char[] { '$', 'h' }, charArray_vi = new char[] {
+ '$', 'i' }, charArray_vj = new char[] { '$', 'j' },
+ charArray_vk = new char[] { '$', 'k' }, charArray_vl = new char[] {
+ '$', 'l' }, charArray_vm = new char[] { '$', 'm' },
+ charArray_vn = new char[] { '$', 'n' }, charArray_vo = new char[] {
+ '$', 'o' }, charArray_vp = new char[] { '$', 'p' },
+ charArray_vq = new char[] { '$', 'q' }, charArray_vr = new char[] {
+ '$', 'r' }, charArray_vs = new char[] { '$', 's' },
+ charArray_vt = new char[] { '$', 't' }, charArray_vu = new char[] {
+ '$', 'u' }, charArray_vv = new char[] { '$', 'v' },
+ charArray_vw = new char[] { '$', 'w' }, charArray_vx = new char[] {
+ '$', 'x' }, charArray_vy = new char[] { '$', 'y' },
+ charArray_vz = new char[] { '$', 'z' };
public final static int MAX_OBVIOUS = 256;
ObviousIdentCharNatures[12] = C_SPACE; // \ u000c: FORM FEED
ObviousIdentCharNatures[13] = C_SPACE; // \ u000d: CARRIAGE RETURN
ObviousIdentCharNatures[32] = C_SPACE; // \ u0020: SPACE
- ObviousIdentCharNatures[9] = C_SPACE; // \ u0009: HORIZONTAL TABULATION
+ ObviousIdentCharNatures[9] = C_SPACE; // \ u0009: HORIZONTAL
+ // TABULATION
ObviousIdentCharNatures['.'] = C_SEPARATOR;
ObviousIdentCharNatures[':'] = C_SEPARATOR;
ObviousIdentCharNatures['"'] = C_SEPARATOR;
ObviousIdentCharNatures['\''] = C_SEPARATOR;
}
- static final char[] initCharArray = new char[] { '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' };
+
+ static final char[] initCharArray = new char[] { '\u0000', '\u0000',
+ '\u0000', '\u0000', '\u0000', '\u0000' };
static final int TableSize = 30, InternalTableSize = 6;
}
}
- static int newEntry2 = 0, newEntry3 = 0, newEntry4 = 0, newEntry5 = 0, newEntry6 = 0;
+ static int newEntry2 = 0, newEntry3 = 0, newEntry4 = 0, newEntry5 = 0,
+ newEntry6 = 0;
public static final int RoundBracket = 0;
public ICompilationUnit compilationUnit = null;
/**
- * Determines if the specified character is permissible as the first character
- * in a PHP identifier or variable
+ * Determines if the specified character is permissible as the first
+ * character in a PHP identifier or variable
*
* The '$' character for PHP variables is regarded as a correct first
* character !
*/
public static boolean isPHPIdentOrVarStart(char ch) {
if (ch < MAX_OBVIOUS) {
- return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DOLLAR;
+ return ObviousIdentCharNatures[ch] == C_LETTER
+ || ObviousIdentCharNatures[ch] == C_DOLLAR;
}
return false;
- //return Character.isLetter(ch) || (ch == '$') || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+ // return Character.isLetter(ch) || (ch == '$') || (ch == '_') || (0x7F
+ // <=
+ // ch && ch <= 0xFF);
}
/**
- * Determines if the specified character is permissible as the first character
- * in a PHP identifier.
+ * Determines if the specified character is permissible as the first
+ * character in a PHP identifier.
*
* The '$' character for PHP variables isn't regarded as the first character !
*/
public static boolean isPHPIdentifierStart(char ch) {
if (ch < MAX_OBVIOUS) {
- return ObviousIdentCharNatures[ch]==C_LETTER;
+ return ObviousIdentCharNatures[ch] == C_LETTER;
}
return false;
-// return Character.isLetter(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+ // return Character.isLetter(ch) || (ch == '_') || (0x7F <= ch && ch <=
+ // 0xFF);
}
/**
*/
public static boolean isPHPIdentifierPart(char ch) {
if (ch < MAX_OBVIOUS) {
- return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DIGIT;
+ return ObviousIdentCharNatures[ch] == C_LETTER
+ || ObviousIdentCharNatures[ch] == C_DIGIT;
}
return false;
-// return Character.isLetterOrDigit(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+ // return Character.isLetterOrDigit(ch) || (ch == '_') || (0x7F <= ch &&
+ // ch
+ // <= 0xFF);
}
- public static boolean isSQLIdentifierPart(char ch) {
- if (ch < MAX_OBVIOUS) {
- return ObviousIdentCharNatures[ch]==C_LETTER || ObviousIdentCharNatures[ch]==C_DIGIT;
- }
- return false;
- }
+// public static boolean isSQLIdentifierPart(char ch) {
+// if (ch < MAX_OBVIOUS) {
+// return ObviousIdentCharNatures[ch] == C_LETTER
+// || ObviousIdentCharNatures[ch] == C_DIGIT;
+// }
+// return false;
+// }
public final boolean atEnd() {
// This code is not relevant if source is
// return the token REAL source (aka unicodes are precomputed)
char[] result;
// if (withoutUnicodePtr != 0)
- // //0 is used as a fast test flag so the real first char is in position 1
+ // //0 is used as a fast test flag so the real first char is in position
+ // 1
// System.arraycopy(
// withoutUnicodeBuffer,
// 1,
return optimizedCurrentTokenSource6();
}
// no optimization
- System.arraycopy(source, startPosition, result = new char[length], 0, length);
+ System.arraycopy(source, startPosition, result = new char[length], 0,
+ length);
// }
return result;
}
// Return the token REAL source (aka unicodes are precomputed)
char[] result;
// if (withoutUnicodePtr != 0)
- // // 0 is used as a fast test flag so the real first char is in position 1
+ // // 0 is used as a fast test flag so the real first char is in
+ // position 1
// System.arraycopy(
// withoutUnicodeBuffer,
// 1,
// withoutUnicodePtr);
// else {
int length;
- System.arraycopy(source, startPosition, result = new char[length = currentPosition - startPosition], 0, length);
+ System.arraycopy(source, startPosition,
+ result = new char[length = currentPosition - startPosition], 0,
+ length);
// }
return result;
}
// Return the token REAL source (aka unicodes are precomputed)
char[] result;
// if (withoutUnicodePtr != 0)
- // // 0 is used as a fast test flag so the real first char is in position 1
+ // // 0 is used as a fast test flag so the real first char is in
+ // position 1
// System.arraycopy(
// withoutUnicodeBuffer,
// 1,
// withoutUnicodePtr);
// else {
int length;
- System.arraycopy(source, startPos, result = new char[length = currentPosition - startPos], 0, length);
+ System.arraycopy(source, startPos,
+ result = new char[length = currentPosition - startPos], 0,
+ length);
// }
return result;
}
// REMOVE the two " that are at the beginning and the end.
char[] result;
if (withoutUnicodePtr != 0)
- // 0 is used as a fast test flag so the real first char is in position 1
+ // 0 is used as a fast test flag so the real first char is in
+ // position 1
System.arraycopy(withoutUnicodeBuffer, 2,
- // 2 is 1 (real start) + 1 (to jump over the ")
- result = new char[withoutUnicodePtr - 2], 0, withoutUnicodePtr - 2);
+ // 2 is 1 (real start) + 1 (to jump over the ")
+ result = new char[withoutUnicodePtr - 2], 0,
+ withoutUnicodePtr - 2);
else {
int length;
- System.arraycopy(source, startPosition + 1, result = new char[length = currentPosition - startPosition - 2], 0, length);
+ System.arraycopy(source, startPosition + 1,
+ result = new char[length = currentPosition - startPosition
+ - 2], 0, length);
}
return result;
}
return false;
}
for (int i = 0; i < word.length; i++) {
- if (word[i]!=source[startPosition+i]){
+ if (word[i] != source[startPosition + i]) {
return false;
}
}
return true;
}
- public final char[] getRawTokenSourceEnd() {
- int length = this.eofPosition - this.currentPosition - 1;
- char[] sourceEnd = new char[length];
- System.arraycopy(this.source, this.currentPosition, sourceEnd, 0, length);
- return sourceEnd;
- }
+// public final char[] getRawTokenSourceEnd() {
+// int length = this.eofPosition - this.currentPosition - 1;
+// char[] sourceEnd = new char[length];
+// System.arraycopy(this.source, this.currentPosition, sourceEnd, 0,
+// length);
+// return sourceEnd;
+// }
public int getCurrentTokenStartPosition() {
return this.startPosition;
}
- public final String getCurrentStringLiteral() {
- char[] result = getCurrentStringLiteralSource();
- return new String(result);
- }
+// public final String getCurrentStringLiteral() {
+// char[] result = getCurrentStringLiteralSource();
+// return new String(result);
+// }
public final char[] getCurrentStringLiteralSource() {
// Return the token REAL source (aka unicodes are precomputed)
}
char[] result;
int length;
- System.arraycopy(source, startPosition + 1, result = new char[length = currentPosition - startPosition - 2], 0, length);
+ System
+ .arraycopy(source, startPosition + 1,
+ result = new char[length = currentPosition
+ - startPosition - 2], 0, length);
// }
return result;
}
- public final char[] getCurrentStringLiteralSource(int startPos) {
- // Return the token REAL source (aka unicodes are precomputed)
- char[] result;
- int length;
- System.arraycopy(source, startPos + 1, result = new char[length = currentPosition - startPos - 2], 0, length);
- // }
- return result;
- }
+// public final char[] getCurrentStringLiteralSource(int startPos) {
+// // Return the token REAL source (aka unicodes are precomputed)
+// char[] result;
+// int length;
+// System.arraycopy(source, startPos + 1,
+// result = new char[length = currentPosition - startPos - 2], 0,
+// length);
+// // }
+// return result;
+// }
/*
- * Search the source position corresponding to the end of a given line number
+ * Search the source position corresponding to the end of a given line
+ * number
*
* Line numbers are 1-based, and relative to the scanner initialPosition.
* Character positions are 0-based.
// unicodeSize++;
// }
//
- // if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ // if (((c1 = Character.getNumericValue(source[currentPosition++]))
+ // > 15
// || c1 < 0)
- // || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c2 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c2 < 0)
- // || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c3 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c3 < 0)
- // || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c4 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c4 < 0)) {
// currentPosition = temp;
// return false;
// //need the unicode buffer
// if (withoutUnicodePtr == 0) {
// //buffer all the entries that have been left aside....
- // withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ // withoutUnicodePtr = currentPosition - unicodeSize -
+ // startPosition;
// System.arraycopy(
// source,
// startPosition,
// unicodeSize++;
// }
//
- // if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ // if (((c1 = Character.getNumericValue(source[currentPosition++]))
+ // > 15
// || c1 < 0)
- // || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c2 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c2 < 0)
- // || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c3 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c3 < 0)
- // || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c4 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c4 < 0)) {
// currentPosition = temp;
// return 2;
// //need the unicode buffer
// if (withoutUnicodePtr == 0) {
// //buffer all the entries that have been left aside....
- // withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ // withoutUnicodePtr = currentPosition - unicodeSize -
+ // startPosition;
// System.arraycopy(
// source,
// startPosition,
// unicodeSize++;
// }
//
- // if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ // if (((c1 = Character.getNumericValue(source[currentPosition++]))
+ // > 15
// || c1 < 0)
- // || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c2 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c2 < 0)
- // || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c3 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c3 < 0)
- // || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c4 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c4 < 0)) {
// currentPosition = temp;
// return false;
// //need the unicode buffer
// if (withoutUnicodePtr == 0) {
// //buffer all the entries that have been left aside....
- // withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ // withoutUnicodePtr = currentPosition - unicodeSize -
+ // startPosition;
// System.arraycopy(
// source,
// startPosition,
// internal values
// At the end of this method currentCharacter holds the new visited char
// and currentPosition points right next after it
- // Both previous lines are true if the currentCharacter is a digit base on
+ // Both previous lines are true if the currentCharacter is a digit base
+ // on
// radix
// On false, no side effect has occured.
// ALL getNextChar.... ARE OPTIMIZED COPIES
// unicodeSize++;
// }
//
- // if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ // if (((c1 = Character.getNumericValue(source[currentPosition++]))
+ // > 15
// || c1 < 0)
- // || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c2 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c2 < 0)
- // || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c3 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c3 < 0)
- // || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c4 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c4 < 0)) {
// currentPosition = temp;
// return false;
// //need the unicode buffer
// if (withoutUnicodePtr == 0) {
// //buffer all the entries that have been left aside....
- // withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ // withoutUnicodePtr = currentPosition - unicodeSize -
+ // startPosition;
// System.arraycopy(
// source,
// startPosition,
// unicodeSize++;
// }
//
- // if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ // if (((c1 = Character.getNumericValue(source[currentPosition++]))
+ // > 15
// || c1 < 0)
- // || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c2 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c2 < 0)
- // || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c3 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c3 < 0)
- // || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ // || ((c4 = Character.getNumericValue(source[currentPosition++])) >
+ // 15
// || c4 < 0)) {
// currentPosition = temp;
// return false;
// //need the unicode buffer
// if (withoutUnicodePtr == 0) {
// //buffer all the entries that have been left aside....
- // withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ // withoutUnicodePtr = currentPosition - unicodeSize -
+ // startPosition;
// System.arraycopy(
// source,
// startPosition,
}
}
- public int getCastOrParen() {
+ public TokenName getCastOrParen() {
int tempPosition = currentPosition;
char tempCharacter = currentCharacter;
- int tempToken = TokenNameLPAREN;
+ TokenName tempToken = TokenName.LPAREN;
boolean found = false;
StringBuffer buf = new StringBuffer();
try {
do {
currentCharacter = source[currentPosition++];
} while (currentCharacter == ' ' || currentCharacter == '\t');
- while (ObviousIdentCharNatures[currentCharacter]==C_LETTER) {
- // while((currentCharacter >= 'a' && currentCharacter <= 'z') || (currentCharacter >= 'A' && currentCharacter <= 'Z')) {
+ while (ObviousIdentCharNatures[currentCharacter] == C_LETTER) {
+ // while((currentCharacter >= 'a' && currentCharacter <= 'z') ||
+ // (currentCharacter >= 'A' && currentCharacter <= 'Z')) {
buf.append(currentCharacter);
currentCharacter = source[currentPosition++];
}
switch (data.length) {
case 3:
// int
- if ((data[index] == 'i') && (data[++index] == 'n') && (data[++index] == 't')) {
+ if ((data[index] == 'i') && (data[++index] == 'n')
+ && (data[++index] == 't')) {
found = true;
- tempToken = TokenNameintCAST;
+ tempToken = TokenName.INTCAST;
}
break;
case 4:
// bool real
- if ((data[index] == 'b') && (data[++index] == 'o') && (data[++index] == 'o') && (data[++index] == 'l')) {
+ if ((data[index] == 'b') && (data[++index] == 'o')
+ && (data[++index] == 'o') && (data[++index] == 'l')) {
found = true;
- tempToken = TokenNameboolCAST;
+ tempToken = TokenName.BOOLCAST;
} else {
index = 0;
- if ((data[index] == 'r') && (data[++index] == 'e') && (data[++index] == 'a') && (data[++index] == 'l')) {
+ if ((data[index] == 'r') && (data[++index] == 'e')
+ && (data[++index] == 'a')
+ && (data[++index] == 'l')) {
found = true;
- tempToken = TokenNamedoubleCAST;
+ tempToken = TokenName.DOUBLECAST;
}
}
break;
case 5:
// array unset float
- if ((data[index] == 'a') && (data[++index] == 'r') && (data[++index] == 'r') && (data[++index] == 'a')
+ if ((data[index] == 'a') && (data[++index] == 'r')
+ && (data[++index] == 'r') && (data[++index] == 'a')
&& (data[++index] == 'y')) {
found = true;
- tempToken = TokenNamearrayCAST;
+ tempToken = TokenName.ARRAYCAST;
} else {
index = 0;
- if ((data[index] == 'u') && (data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 'e')
+ if ((data[index] == 'u') && (data[++index] == 'n')
+ && (data[++index] == 's')
+ && (data[++index] == 'e')
&& (data[++index] == 't')) {
found = true;
- tempToken = TokenNameunsetCAST;
+ tempToken = TokenName.UNSETCAST;
} else {
index = 0;
- if ((data[index] == 'f') && (data[++index] == 'l') && (data[++index] == 'o') && (data[++index] == 'a')
+ if ((data[index] == 'f') && (data[++index] == 'l')
+ && (data[++index] == 'o')
+ && (data[++index] == 'a')
&& (data[++index] == 't')) {
found = true;
- tempToken = TokenNamedoubleCAST;
+ tempToken = TokenName.DOUBLECAST;
}
}
}
break;
case 6:
// object string double
- if ((data[index] == 'o') && (data[++index] == 'b') && (data[++index] == 'j') && (data[++index] == 'e')
+ if ((data[index] == 'o') && (data[++index] == 'b')
+ && (data[++index] == 'j') && (data[++index] == 'e')
&& (data[++index] == 'c') && (data[++index] == 't')) {
found = true;
- tempToken = TokenNameobjectCAST;
+ tempToken = TokenName.OBJECTCAST;
} else {
index = 0;
- if ((data[index] == 's') && (data[++index] == 't') && (data[++index] == 'r') && (data[++index] == 'i')
- && (data[++index] == 'n') && (data[++index] == 'g')) {
+ if ((data[index] == 's') && (data[++index] == 't')
+ && (data[++index] == 'r')
+ && (data[++index] == 'i')
+ && (data[++index] == 'n')
+ && (data[++index] == 'g')) {
found = true;
- tempToken = TokenNamestringCAST;
+ tempToken = TokenName.STRINGCAST;
} else {
index = 0;
- if ((data[index] == 'd') && (data[++index] == 'o') && (data[++index] == 'u') && (data[++index] == 'b')
- && (data[++index] == 'l') && (data[++index] == 'e')) {
+ if ((data[index] == 'd') && (data[++index] == 'o')
+ && (data[++index] == 'u')
+ && (data[++index] == 'b')
+ && (data[++index] == 'l')
+ && (data[++index] == 'e')) {
found = true;
- tempToken = TokenNamedoubleCAST;
+ tempToken = TokenName.DOUBLECAST;
}
}
}
break;
case 7:
// boolean integer
- if ((data[index] == 'b') && (data[++index] == 'o') && (data[++index] == 'o') && (data[++index] == 'l')
- && (data[++index] == 'e') && (data[++index] == 'a') && (data[++index] == 'n')) {
+ if ((data[index] == 'b') && (data[++index] == 'o')
+ && (data[++index] == 'o') && (data[++index] == 'l')
+ && (data[++index] == 'e') && (data[++index] == 'a')
+ && (data[++index] == 'n')) {
found = true;
- tempToken = TokenNameboolCAST;
+ tempToken = TokenName.BOOLCAST;
} else {
index = 0;
- if ((data[index] == 'i') && (data[++index] == 'n') && (data[++index] == 't') && (data[++index] == 'e')
- && (data[++index] == 'g') && (data[++index] == 'e') && (data[++index] == 'r')) {
+ if ((data[index] == 'i') && (data[++index] == 'n')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')
+ && (data[++index] == 'g')
+ && (data[++index] == 'e')
+ && (data[++index] == 'r')) {
found = true;
- tempToken = TokenNameintCAST;
+ tempToken = TokenName.INTCAST;
}
}
break;
}
currentCharacter = tempCharacter;
currentPosition = tempPosition;
- return TokenNameLPAREN;
+ return TokenName.LPAREN;
}
+ /**
+ *
+ *
+ */
public void consumeStringInterpolated() throws InvalidInputException {
try {
// consume next character
/** ** in PHP \r and \n are valid in string literals *** */
// if ((currentCharacter == '\n')
// || (currentCharacter == '\r')) {
- // // relocate if finding another quote fairly close: thus unicode
+ // // relocate if finding another quote fairly close: thus
+ // unicode
// '/u000D' will be fully consumed
// for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
// if (currentPosition + lookAhead == source.length)
if (currentCharacter == '\\') {
int escapeSize = currentPosition;
boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
- // scanEscapeCharacter make a side effect on this value and we need
+ // scanEscapeCharacter make a side effect on this value and
+ // we need
// the previous value few lines down this one
scanDoubleQuotedEscapeCharacter();
escapeSize = currentPosition - escapeSize;
if (withoutUnicodePtr == 0) {
// buffer all the entries that have been left aside....
- withoutUnicodePtr = currentPosition - escapeSize - 1 - startPosition;
- System.arraycopy(source, startPosition, withoutUnicodeBuffer, 1, withoutUnicodePtr);
+ withoutUnicodePtr = currentPosition - escapeSize - 1
+ - startPosition;
+ System.arraycopy(source, startPosition,
+ withoutUnicodeBuffer, 1, withoutUnicodePtr);
withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
} else { // overwrite the / in the buffer
withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
- if (backSlashAsUnicodeInString) { // there are TWO \ in the stream
+ if (backSlashAsUnicodeInString) { // there are TWO \
+ // in the stream
// where only one is correct
withoutUnicodePtr--;
}
}
- } else if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ } else if ((currentCharacter == '\r')
+ || (currentCharacter == '\n')) {
if (recordLineSeparator) {
pushLineSeparator();
}
}
throw e; // rethrow
}
- if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags
+ if (checkNonExternalizedStringLiterals) { // check for presence of NLS
+ // tags
// //$NON-NLS-?$ where ? is an
// int.
if (currentLine == null) {
currentLine = new NLSLine();
lines.add(currentLine);
}
- currentLine.add(new StringLiteral(getCurrentTokenSourceString(), startPosition, currentPosition - 1));
+ currentLine.add(new StringLiteral(getCurrentTokenSourceString(),
+ startPosition, currentPosition - 1));
}
}
/** ** in PHP \r and \n are valid in string literals *** */
// if ((currentCharacter == '\n')
// || (currentCharacter == '\r')) {
- // // relocate if finding another quote fairly close: thus unicode
+ // // relocate if finding another quote fairly close: thus
+ // unicode
// '/u000D' will be fully consumed
// for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
// if (currentPosition + lookAhead == source.length)
if (currentCharacter == '\\') {
int escapeSize = currentPosition;
boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
- // scanEscapeCharacter make a side effect on this value and we need
+ // scanEscapeCharacter make a side effect on this value and
+ // we need
// the previous value few lines down this one
scanSingleQuotedEscapeCharacter();
escapeSize = currentPosition - escapeSize;
if (withoutUnicodePtr == 0) {
// buffer all the entries that have been left aside....
- withoutUnicodePtr = currentPosition - escapeSize - 1 - startPosition;
- System.arraycopy(source, startPosition, withoutUnicodeBuffer, 1, withoutUnicodePtr);
+ withoutUnicodePtr = currentPosition - escapeSize - 1
+ - startPosition;
+ System.arraycopy(source, startPosition,
+ withoutUnicodeBuffer, 1, withoutUnicodePtr);
withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
} else { // overwrite the / in the buffer
withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
- if (backSlashAsUnicodeInString) { // there are TWO \ in the stream
+ if (backSlashAsUnicodeInString) { // there are TWO \
+ // in the stream
// where only one is correct
withoutUnicodePtr--;
}
}
- } else if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ } else if ((currentCharacter == '\r')
+ || (currentCharacter == '\n')) {
if (recordLineSeparator) {
pushLineSeparator();
}
}
throw e; // rethrow
}
- if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags
+ if (checkNonExternalizedStringLiterals) { // check for presence of NLS
+ // tags
// //$NON-NLS-?$ where ? is an
// int.
if (currentLine == null) {
currentLine = new NLSLine();
lines.add(currentLine);
}
- currentLine.add(new StringLiteral(getCurrentTokenSourceString(), startPosition, currentPosition - 1));
+ currentLine.add(new StringLiteral(getCurrentTokenSourceString(),
+ startPosition, currentPosition - 1));
}
}
+ /**
+ *
+ *
+ */
public void consumeStringLiteral() throws InvalidInputException {
try {
- boolean openDollarBrace = false;
- // consume next character
- unicodeAsBackSlash = false;
- currentCharacter = source[currentPosition++];
- while (currentCharacter != '"' || openDollarBrace) {
- /** ** in PHP \r and \n are valid in string literals *** */
+ int openDollarBrace = 0;
+
+ unicodeAsBackSlash = false;
+ currentCharacter = source[currentPosition++]; // consume next character
+
+ while (currentCharacter != '"' || // As long as the ending '"' isn't found, or
+ openDollarBrace > 0) { // the last '}' isn't found
if (currentCharacter == '\\') {
- int escapeSize = currentPosition;
+ int escapeSize = currentPosition;
boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
+
// scanEscapeCharacter make a side effect on this value and we need
// the previous value few lines down this one
- scanDoubleQuotedEscapeCharacter();
+ scanDoubleQuotedEscapeCharacter ();
escapeSize = currentPosition - escapeSize;
- if (withoutUnicodePtr == 0) {
- // buffer all the entries that have been left aside....
+
+ if (withoutUnicodePtr == 0) { // buffer all the entries that have been left aside....
withoutUnicodePtr = currentPosition - escapeSize - 1 - startPosition;
- System.arraycopy(source, startPosition, withoutUnicodeBuffer, 1, withoutUnicodePtr);
+ System.arraycopy (source, startPosition, withoutUnicodeBuffer, 1, withoutUnicodePtr);
withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
- } else { // overwrite the / in the buffer
+ }
+ else { // overwrite the / in the buffer
withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
- if (backSlashAsUnicodeInString) { // there are TWO \ in the stream
- // where only one is correct
+
+ if (backSlashAsUnicodeInString) { // there are TWO \ in the stream where only one is correct
withoutUnicodePtr--;
}
}
- } else if (currentCharacter == '$' && source[currentPosition] == '{') {
- openDollarBrace = true;
- } else if (currentCharacter == '{' && source[currentPosition] == '$') {
- openDollarBrace = true;
- } else if (currentCharacter == '}') {
- openDollarBrace = false;
- } else if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ }
+ else if (currentCharacter == '$' && source[currentPosition] == '{') { // If found '${'
+ openDollarBrace++;
+ currentCharacter = source[currentPosition++]; // consume next character, or we count one open brace to much!
+ }
+ else if (currentCharacter == '{' && source[currentPosition] == '$') { // If found '{$'
+ openDollarBrace++;
+ }
+ else if (currentCharacter == '}') { // If found '}'
+ openDollarBrace--;
+ }
+ else if ((currentCharacter == '\r') || (currentCharacter == '\n')) { // In PHP \r and \n are valid in string literals
if (recordLineSeparator) {
- pushLineSeparator();
+ pushLineSeparator ();
}
}
- // consume next character
+
unicodeAsBackSlash = false;
- currentCharacter = source[currentPosition++];
+ currentCharacter = source[currentPosition++]; // consume next character
+
if (withoutUnicodePtr != 0) {
withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
}
}
throw e; // rethrow
}
+
if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags
- // //$NON-NLS-?$ where ? is an
- // int.
+ // $NON-NLS-?$ where ? is an int.
if (currentLine == null) {
- currentLine = new NLSLine();
- lines.add(currentLine);
+ currentLine = new NLSLine ();
+ lines.add (currentLine);
}
- currentLine.add(new StringLiteral(getCurrentTokenSourceString(), startPosition, currentPosition - 1));
+ currentLine.add (new StringLiteral (getCurrentTokenSourceString (), startPosition, currentPosition - 1));
}
}
- public int getNextToken() throws InvalidInputException {
- phpExpressionTag = false;
+ /**
+ *
+ */
+ public TokenName getNextToken() throws InvalidInputException {
if (!phpMode) {
return getInlinedHTMLToken(currentPosition);
- }
- if (phpMode) {
+ } else {
+ if (fFillerToken != TokenName.EOF) {
+ TokenName tempToken;
+ startPosition = currentPosition;
+ tempToken = fFillerToken;
+ fFillerToken = TokenName.EOF;
+ return tempToken;
+ }
this.wasAcr = false;
if (diet) {
jumpOverMethodBody();
diet = false;
- return currentPosition > source.length ? TokenNameEOF : TokenNameRBRACE;
+ return currentPosition > source.length ? TokenName.EOF
+ : TokenName.RBRACE;
}
try {
while (true) {
withoutUnicodePtr = 0;
- // start with a new token
- char encapsedChar = ' ';
- // if (!encapsedStringStack.isEmpty()) {
- // encapsedChar = ((Character)
- // encapsedStringStack.peek()).charValue();
- // }
- // if (encapsedChar != '$' && encapsedChar != ' ') {
- // currentCharacter = source[currentPosition++];
- // if (currentCharacter == encapsedChar) {
- // switch (currentCharacter) {
- // case '`':
- // return TokenNameEncapsedString0;
- // case '\'':
- // return TokenNameEncapsedString1;
- // case '"':
- // return TokenNameEncapsedString2;
- // }
- // }
- // while (currentCharacter != encapsedChar) {
- // /** ** in PHP \r and \n are valid in string literals *** */
- // switch (currentCharacter) {
- // case '\\':
- // int escapeSize = currentPosition;
- // boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
- // //scanEscapeCharacter make a side effect on this value and
- // // we need the previous value few lines down this one
- // scanDoubleQuotedEscapeCharacter();
- // escapeSize = currentPosition - escapeSize;
- // if (withoutUnicodePtr == 0) {
- // //buffer all the entries that have been left aside....
- // withoutUnicodePtr = currentPosition - escapeSize - 1 -
- // startPosition;
- // System.arraycopy(source, startPosition, withoutUnicodeBuffer, 1,
- // withoutUnicodePtr);
- // withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
- // } else { //overwrite the / in the buffer
- // withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
- // if (backSlashAsUnicodeInString) { //there are TWO \ in
- // withoutUnicodePtr--;
- // }
- // }
- // break;
- // case '\r':
- // case '\n':
- // if (recordLineSeparator) {
- // pushLineSeparator();
- // }
- // break;
- // case '$':
- // if (isPHPIdentifierStart(source[currentPosition]) ||
- // source[currentPosition] == '{') {
- // currentPosition--;
- // encapsedStringStack.push(new Character('$'));
- // return TokenNameSTRING;
- // }
- // break;
- // case '{':
- // if (source[currentPosition] == '$') { // CURLY_OPEN
- // currentPosition--;
- // encapsedStringStack.push(new Character('$'));
- // return TokenNameSTRING;
- // }
- // }
- // // consume next character
- // unicodeAsBackSlash = false;
- // currentCharacter = source[currentPosition++];
- // if (withoutUnicodePtr != 0) {
- // withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
- // }
- // // }
- // } // end while
- // currentPosition--;
- // return TokenNameSTRING;
- // }
- // ---------Consume white space and handles startPosition---------
+ // ---------Consume white space and handles
+ // startPosition---------
int whiteStart = currentPosition;
startPosition = currentPosition;
currentCharacter = source[currentPosition++];
- // if (encapsedChar == '$') {
- // switch (currentCharacter) {
- // case '\\':
- // currentCharacter = source[currentPosition++];
- // return TokenNameSTRING;
- // case '{':
- // if (encapsedChar == '$') {
- // if (getNextChar('$'))
- // return TokenNameLBRACE_DOLLAR;
- // }
- // return TokenNameLBRACE;
- // case '}':
- // return TokenNameRBRACE;
- // case '[':
- // return TokenNameLBRACKET;
- // case ']':
- // return TokenNameRBRACKET;
- // case '\'':
- // if (tokenizeStrings) {
- // consumeStringConstant();
- // return TokenNameStringSingleQuote;
- // }
- // return TokenNameEncapsedString1;
- // case '"':
- // return TokenNameEncapsedString2;
- // case '`':
- // if (tokenizeStrings) {
- // consumeStringInterpolated();
- // return TokenNameStringInterpolated;
- // }
- // return TokenNameEncapsedString0;
- // case '-':
- // if (getNextChar('>'))
- // return TokenNameMINUS_GREATER;
- // return TokenNameSTRING;
- // default:
- // if (currentCharacter == '$') {
- // int oldPosition = currentPosition;
- // try {
- // currentCharacter = source[currentPosition++];
- // if (currentCharacter == '{') {
- // return TokenNameDOLLAR_LBRACE;
- // }
- // if (isPHPIdentifierStart(currentCharacter)) {
- // return scanIdentifierOrKeyword(true);
- // } else {
- // currentPosition = oldPosition;
- // return TokenNameSTRING;
- // }
- // } catch (IndexOutOfBoundsException e) {
- // currentPosition = oldPosition;
- // return TokenNameSTRING;
- // }
- // }
- // if (isPHPIdentifierStart(currentCharacter))
- // return scanIdentifierOrKeyword(false);
- // if (Character.isDigit(currentCharacter))
- // return scanNumber(false);
- // return TokenNameERROR;
- // }
- // }
- // boolean isWhiteSpace;
while ((currentCharacter == ' ') || Character.isWhitespace(currentCharacter)) {
- startPosition = currentPosition;
- currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
- // && (source[currentPosition] == 'u')) {
- // isWhiteSpace = jumpOverUnicodeWhiteSpace();
- // } else {
if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
checkNonExternalizeString();
+
if (recordLineSeparator) {
pushLineSeparator();
} else {
currentLine = null;
}
}
- // isWhiteSpace = (currentCharacter == ' ')
- // || Character.isWhitespace(currentCharacter);
- // }
+ startPosition = currentPosition;
+ currentCharacter = source[currentPosition++];
}
+
if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
- // reposition scanner in case we are interested by spaces as tokens
+ // reposition scanner in case we are interested by
+ // spaces as tokens
currentPosition--;
startPosition = whiteStart;
- return TokenNameWHITESPACE;
+ return TokenName.WHITESPACE;
}
- // little trick to get out in the middle of a source compuation
+ // little trick to get out in the middle of a source
+ // compuation
if (currentPosition > eofPosition)
- return TokenNameEOF;
+ return TokenName.EOF;
// ---------Identify the next token-------------
switch (currentCharacter) {
case '(':
return getCastOrParen();
case ')':
- return TokenNameRPAREN;
+ return TokenName.RPAREN;
case '{':
- return TokenNameLBRACE;
+ return TokenName.LBRACE;
case '}':
- return TokenNameRBRACE;
+ return TokenName.RBRACE;
case '[':
- return TokenNameLBRACKET;
+ return TokenName.LBRACKET;
case ']':
- return TokenNameRBRACKET;
+ return TokenName.RBRACKET;
case ';':
- return TokenNameSEMICOLON;
+ return TokenName.SEMICOLON;
case ',':
- return TokenNameCOMMA;
+ return TokenName.COMMA;
case '.':
if (getNextChar('='))
- return TokenNameDOT_EQUAL;
+ return TokenName.DOT_EQUAL;
if (getNextCharAsDigit())
return scanNumber(true);
- return TokenNameDOT;
+ return TokenName.DOT;
+ case '\\':
+ return TokenName.BACKSLASH;
case '+': {
int test;
if ((test = getNextChar('+', '=')) == 0)
- return TokenNamePLUS_PLUS;
+ return TokenName.PLUS_PLUS;
if (test > 0)
- return TokenNamePLUS_EQUAL;
- return TokenNamePLUS;
+ return TokenName.PLUS_EQUAL;
+ return TokenName.PLUS;
}
case '-': {
int test;
if ((test = getNextChar('-', '=')) == 0)
- return TokenNameMINUS_MINUS;
+ return TokenName.MINUS_MINUS;
if (test > 0)
- return TokenNameMINUS_EQUAL;
+ return TokenName.MINUS_EQUAL;
if (getNextChar('>'))
- return TokenNameMINUS_GREATER;
- return TokenNameMINUS;
+ return TokenName.MINUS_GREATER;
+ return TokenName.MINUS;
}
case '~':
if (getNextChar('='))
- return TokenNameTWIDDLE_EQUAL;
- return TokenNameTWIDDLE;
+ return TokenName.TWIDDLE_EQUAL;
+ return TokenName.TWIDDLE;
case '!':
if (getNextChar('=')) {
if (getNextChar('=')) {
- return TokenNameNOT_EQUAL_EQUAL;
+ return TokenName.NOT_EQUAL_EQUAL;
}
- return TokenNameNOT_EQUAL;
+ return TokenName.NOT_EQUAL;
}
- return TokenNameNOT;
+ return TokenName.NOT;
case '*':
if (getNextChar('='))
- return TokenNameMULTIPLY_EQUAL;
- return TokenNameMULTIPLY;
+ return TokenName.MULTIPLY_EQUAL;
+ return TokenName.MULTIPLY;
case '%':
if (getNextChar('='))
- return TokenNameREMAINDER_EQUAL;
- return TokenNameREMAINDER;
+ return TokenName.REMAINDER_EQUAL;
+ return TokenName.REMAINDER;
+
case '<': {
int oldPosition = currentPosition;
+
try {
currentCharacter = source[currentPosition++];
} catch (IndexOutOfBoundsException e) {
currentPosition = oldPosition;
- return TokenNameLESS;
+ return TokenName.LESS;
}
+
switch (currentCharacter) {
- case '=':
- return TokenNameLESS_EQUAL;
- case '>':
- return TokenNameNOT_EQUAL;
- case '<':
- if (getNextChar('='))
- return TokenNameLEFT_SHIFT_EQUAL;
- if (getNextChar('<')) {
- currentCharacter = source[currentPosition++];
- while (Character.isWhitespace(currentCharacter)) {
- currentCharacter = source[currentPosition++];
- }
- int heredocStart = currentPosition - 1;
- int heredocLength = 0;
- if (isPHPIdentifierStart(currentCharacter)) {
- currentCharacter = source[currentPosition++];
- } else {
- return TokenNameERROR;
+ case '=':
+ return TokenName.LESS_EQUAL;
+
+ case '>':
+ return TokenName.NOT_EQUAL;
+
+ case '<':
+ if (getNextChar ('=')) {
+ return TokenName.LEFT_SHIFT_EQUAL;
}
- while (isPHPIdentifierPart(currentCharacter)) {
+
+ if (getNextChar('<')) {
currentCharacter = source[currentPosition++];
- }
- heredocLength = currentPosition - heredocStart - 1;
- // heredoc end-tag determination
- boolean endTag = true;
- char ch;
- do {
- ch = source[currentPosition++];
- if (ch == '\r' || ch == '\n') {
- if (recordLineSeparator) {
- pushLineSeparator();
- } else {
- currentLine = null;
- }
- for (int i = 0; i < heredocLength; i++) {
- if (source[currentPosition + i] != source[heredocStart + i]) {
- endTag = false;
- break;
+
+ while (Character.isWhitespace(currentCharacter)) {
+ currentCharacter = source[currentPosition++];
+ }
+
+ int heredocStart = currentPosition - 1;
+ int heredocLength = 0;
+
+ if (isPHPIdentifierStart (currentCharacter)) {
+ currentCharacter = source[currentPosition++];
+ }
+ else {
+ return TokenName.ERROR;
+ }
+
+ while (isPHPIdentifierPart(currentCharacter)) {
+ currentCharacter = source[currentPosition++];
+ }
+
+ heredocLength = currentPosition - heredocStart - 1;
+
+ // heredoc end-tag determination
+ boolean endTag = true;
+ char ch;
+ do {
+ ch = source[currentPosition++];
+
+ if (ch == '\r' || ch == '\n') {
+ if (recordLineSeparator) {
+ pushLineSeparator();
+ }
+ else {
+ currentLine = null;
+ }
+
+ for (int i = 0; i < heredocLength; i++) {
+ if (source[currentPosition + i] != source[heredocStart + i]) {
+ endTag = false;
+ break;
+ }
+ }
+
+ if (endTag) {
+ currentPosition += heredocLength - 1;
+ currentCharacter = source[currentPosition++];
+ break; // do...while loop
+ }
+ else {
+ endTag = true;
}
}
- if (endTag) {
- currentPosition += heredocLength - 1;
- currentCharacter = source[currentPosition++];
- break; // do...while loop
- } else {
- endTag = true;
- }
- }
- } while (true);
- return TokenNameHEREDOC;
+ } while (true);
+
+ return TokenName.HEREDOC;
+ }
+ return TokenName.LEFT_SHIFT;
}
- return TokenNameLEFT_SHIFT;
+ currentPosition = oldPosition;
+ return TokenName.LESS;
}
- currentPosition = oldPosition;
- return TokenNameLESS;
- }
+
case '>': {
int test;
if ((test = getNextChar('=', '>')) == 0)
- return TokenNameGREATER_EQUAL;
+ return TokenName.GREATER_EQUAL;
if (test > 0) {
if ((test = getNextChar('=', '>')) == 0)
- return TokenNameRIGHT_SHIFT_EQUAL;
- return TokenNameRIGHT_SHIFT;
+ return TokenName.RIGHT_SHIFT_EQUAL;
+ return TokenName.RIGHT_SHIFT;
}
- return TokenNameGREATER;
+ return TokenName.GREATER;
}
case '=':
if (getNextChar('=')) {
if (getNextChar('=')) {
- return TokenNameEQUAL_EQUAL_EQUAL;
+ return TokenName.EQUAL_EQUAL_EQUAL;
}
- return TokenNameEQUAL_EQUAL;
+ return TokenName.EQUAL_EQUAL;
}
if (getNextChar('>'))
- return TokenNameEQUAL_GREATER;
- return TokenNameEQUAL;
+ return TokenName.EQUAL_GREATER;
+ return TokenName.EQUAL;
case '&': {
int test;
if ((test = getNextChar('&', '=')) == 0)
- return TokenNameAND_AND;
+ return TokenName.AND_AND;
if (test > 0)
- return TokenNameAND_EQUAL;
- return TokenNameAND;
+ return TokenName.AND_EQUAL;
+ return TokenName.OP_AND;
}
case '|': {
int test;
if ((test = getNextChar('|', '=')) == 0)
- return TokenNameOR_OR;
+ return TokenName.OR_OR;
if (test > 0)
- return TokenNameOR_EQUAL;
- return TokenNameOR;
+ return TokenName.OR_EQUAL;
+ return TokenName.OP_OR;
}
case '^':
if (getNextChar('='))
- return TokenNameXOR_EQUAL;
- return TokenNameXOR;
+ return TokenName.XOR_EQUAL;
+ return TokenName.OP_XOR;
case '?':
if (getNextChar('>')) {
phpMode = false;
if (currentPosition == source.length) {
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
}
return getInlinedHTMLToken(currentPosition - 2);
}
- return TokenNameQUESTION;
+ else if (getNextChar(':')) {
+ return TokenName.TERNARY_SHORT;
+ }
+
+ return TokenName.QUESTION;
+
case ':':
if (getNextChar(':'))
- return TokenNamePAAMAYIM_NEKUDOTAYIM;
- return TokenNameCOLON;
+ return TokenName.PAAMAYIM_NEKUDOTAYIM;
+ return TokenName.COLON;
case '@':
- return TokenNameAT;
+ return TokenName.OP_AT;
case '\'':
consumeStringConstant();
- return TokenNameStringSingleQuote;
+ return TokenName.STRINGSINGLEQUOTE;
case '"':
// if (tokenizeStrings) {
consumeStringLiteral();
- return TokenNameStringDoubleQuote;
- // }
- // return TokenNameEncapsedString2;
+ return TokenName.STRINGDOUBLEQUOTE;
+ // }
+ // return TokenName.EncapsedString2;
case '`':
// if (tokenizeStrings) {
consumeStringInterpolated();
- return TokenNameStringInterpolated;
- // }
- // return TokenNameEncapsedString0;
+ return TokenName.STRINGINTERPOLATED;
+ // }
+ // return TokenName.EncapsedString0;
case '#':
case '/': {
char startChar = currentCharacter;
if (getNextChar('=') && startChar == '/') {
- return TokenNameDIVIDE_EQUAL;
+ return TokenName.DIVIDE_EQUAL;
}
int test;
- if ((startChar == '#') || (test = getNextChar('/', '*')) == 0) {
+ if ((startChar == '#')
+ || (test = getNextChar('/', '*')) == 0) {
// line comment
this.lastCommentLinePosition = this.currentPosition;
int endPositionForLineComment = 0;
try { // get the next char
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++])
+ // if (((currentCharacter =
+ // source[currentPosition++])
// == '\\')
// && (source[currentPosition] == 'u')) {
- // //-------------unicode traitement ------------
+ // //-------------unicode traitement
+ // ------------
// int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
// currentPosition++;
// while (source[currentPosition] == 'u') {
// InvalidInputException(INVALID_UNICODE_ESCAPE);
// } else {
// currentCharacter =
- // (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ // (char) (((c1 * 16 + c2) * 16 + c3) * 16 +
+ // c4);
// }
// }
// handle the \\u case manually into comment
// currentPosition++;
// } //jump over the \\
boolean isUnicode = false;
- while (currentCharacter != '\r' && currentCharacter != '\n') {
+ while (currentCharacter != '\r'
+ && currentCharacter != '\n') {
this.lastCommentLinePosition = this.currentPosition;
if (currentCharacter == '?') {
if (getNextChar('>')) {
// ?> breaks line comments
startPosition = currentPosition - 2;
phpMode = false;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
}
}
// get the next char
isUnicode = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++])
+ // if (((currentCharacter =
+ // source[currentPosition++])
// == '\\')
// && (source[currentPosition] == 'u')) {
// isUnicode = true;
- // //-------------unicode traitement ------------
+ // //-------------unicode traitement
+ // ------------
// int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
// currentPosition++;
// while (source[currentPosition] == 'u') {
// InvalidInputException(INVALID_UNICODE_ESCAPE);
// } else {
// currentCharacter =
- // (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ // (char) (((c1 * 16 + c2) * 16 + c3) * 16 +
+ // c4);
// }
// }
// handle the \\u case manually into comment
endPositionForLineComment = currentPosition - 1;
}
// recordComment(false);
- recordComment(TokenNameCOMMENT_LINE);
+ recordComment(TokenName.COMMENT_LINE);
if (this.taskTags != null)
- checkTaskTag(this.startPosition, this.currentPosition);
- if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ checkTaskTag(this.startPosition,
+ this.currentPosition);
+ if ((currentCharacter == '\r')
+ || (currentCharacter == '\n')) {
checkNonExternalizeString();
if (recordLineSeparator) {
if (isUnicode) {
currentPosition = endPositionForLineComment;
// reset one character behind
}
- return TokenNameCOMMENT_LINE;
+ return TokenName.COMMENT_LINE;
}
- } catch (IndexOutOfBoundsException e) { // an eof will them
+ } catch (IndexOutOfBoundsException e) { // an eof
+ // will them
// be generated
if (tokenizeComments) {
currentPosition--;
// reset one character behind
- return TokenNameCOMMENT_LINE;
+ return TokenName.COMMENT_LINE;
}
}
break;
// consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) ==
+ // if (((currentCharacter =
+ // source[currentPosition++]) ==
// '\\')
// && (source[currentPosition] == 'u')) {
// getNextUnicodeChar();
isJavadoc = true;
star = true;
}
- if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ if ((currentCharacter == '\r')
+ || (currentCharacter == '\n')) {
checkNonExternalizeString();
if (recordLineSeparator) {
pushLineSeparator();
}
try { // get the next char
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++])
+ // if (((currentCharacter =
+ // source[currentPosition++])
// == '\\')
// && (source[currentPosition] == 'u')) {
- // //-------------unicode traitement ------------
+ // //-------------unicode traitement
+ // ------------
// getNextUnicodeChar();
// }
// handle the \\u case manually into comment
}
// loop until end of comment */
while ((currentCharacter != '/') || (!star)) {
- if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ if ((currentCharacter == '\r')
+ || (currentCharacter == '\n')) {
checkNonExternalizeString();
if (recordLineSeparator) {
pushLineSeparator();
star = currentCharacter == '*';
// get next char
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++])
+ // if (((currentCharacter =
+ // source[currentPosition++])
// == '\\')
// && (source[currentPosition] == 'u')) {
- // //-------------unicode traitement ------------
+ // //-------------unicode traitement
+ // ------------
// getNextUnicodeChar();
// }
// handle the \\u case manually into comment
}
// recordComment(isJavadoc);
if (isJavadoc) {
- recordComment(TokenNameCOMMENT_PHPDOC);
+ recordComment(TokenName.COMMENT_PHPDOC);
} else {
- recordComment(TokenNameCOMMENT_BLOCK);
+ recordComment(TokenName.COMMENT_BLOCK);
}
if (tokenizeComments) {
if (isJavadoc)
- return TokenNameCOMMENT_PHPDOC;
- return TokenNameCOMMENT_BLOCK;
+ return TokenName.COMMENT_PHPDOC;
+ return TokenName.COMMENT_BLOCK;
}
if (this.taskTags != null) {
- checkTaskTag(this.startPosition, this.currentPosition);
+ checkTaskTag(this.startPosition,
+ this.currentPosition);
}
} catch (IndexOutOfBoundsException e) {
// reset end position for error reporting
currentPosition -= 2;
- throw new InvalidInputException(UNTERMINATED_COMMENT);
+ throw new InvalidInputException(
+ UNTERMINATED_COMMENT);
}
break;
}
- return TokenNameDIVIDE;
+ return TokenName.DIVIDE;
}
case '\u001a':
if (atEnd())
- return TokenNameEOF;
- // the atEnd may not be <currentPosition == source.length> if
+ return TokenName.EOF;
+ // the atEnd may not be <currentPosition ==
+ // source.length> if
// source is only some part of a real (external) stream
throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$
default:
return scanIdentifierOrKeyword(true);
} else {
currentPosition = oldPosition;
- return TokenNameDOLLAR;
+ return TokenName.DOLLAR;
}
} catch (IndexOutOfBoundsException e) {
currentPosition = oldPosition;
- return TokenNameDOLLAR;
+ return TokenName.DOLLAR;
}
}
- if (isPHPIdentifierStart(currentCharacter))
+
+ if (isPHPIdentifierStart(currentCharacter)) {
return scanIdentifierOrKeyword(false);
- if (Character.isDigit(currentCharacter))
+ }
+
+ if (Character.isDigit(currentCharacter)) {
return scanNumber(false);
- return TokenNameERROR;
+ }
+
+ return TokenName.ERROR;
}
}
} // -----------------end switch while try--------------------
catch (IndexOutOfBoundsException e) {
}
}
- return TokenNameEOF;
+ return TokenName.EOF;
}
/**
* @return
* @throws InvalidInputException
*/
- private int getInlinedHTMLToken(int start) throws InvalidInputException {
+ private TokenName getInlinedHTMLToken(int start) throws InvalidInputException {
+ boolean phpShortTag = false; // true, if <?= detected
if (currentPosition > source.length) {
currentPosition = source.length;
- return TokenNameEOF;
+ return TokenName.EOF;
}
startPosition = start;
try {
if (currentCharacter == '<') {
if (getNextChar('?')) {
currentCharacter = source[currentPosition++];
- if ((currentCharacter != 'P') && (currentCharacter != 'p')) {
+ if ((currentCharacter != 'P')
+ && (currentCharacter != 'p')) {
if (currentCharacter != '=') { // <?=
currentPosition--;
+ phpShortTag = false;
} else {
- phpExpressionTag = true;
+ phpShortTag = true;
}
// <?
if (ignorePHPOneLiner) { // for CodeFormatter
- if (lookAheadLinePHPTag() == TokenNameINLINE_HTML) {
+ if (lookAheadLinePHPTag() == TokenName.INLINE_HTML) {
phpMode = true;
- return TokenNameINLINE_HTML;
+ if (phpShortTag) {
+ fFillerToken = TokenName.ECHO_INVISIBLE;
+ }
+ return TokenName.INLINE_HTML;
}
} else {
- phpMode = true;
- return TokenNameINLINE_HTML;
+ boolean foundXML = false;
+ if (getNextChar('X', 'x') >= 0) {
+ if (getNextChar('M', 'm') >= 0) {
+ if (getNextChar('L', 'l') >= 0) {
+ foundXML = true;
+ }
+ }
+ }
+ if (!foundXML) {
+ phpMode = true;
+ }
+ if (phpShortTag) {
+ fFillerToken = TokenName.ECHO_INVISIBLE;
+ }
+ return TokenName.INLINE_HTML;
}
} else {
- // boolean phpStart = (currentCharacter == 'P') ||
- // (currentCharacter == 'p');
- // if (phpStart) {
- int test = getNextChar('H', 'h');
- if (test >= 0) {
- test = getNextChar('P', 'p');
- if (test >= 0) {
+ if (getNextChar('H', 'h') >= 0) {
+ if (getNextChar('P', 'p') >= 0) {
// <?PHP <?php
if (ignorePHPOneLiner) {
- if (lookAheadLinePHPTag() == TokenNameINLINE_HTML) {
+ if (lookAheadLinePHPTag() == TokenName.INLINE_HTML) {
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
}
} else {
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
}
}
}
}
} // -----------------while--------------------
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
} // -----------------try--------------------
catch (IndexOutOfBoundsException e) {
startPosition = start;
currentPosition--;
}
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
}
/**
+ * check if the PHP is only in this line (for CodeFormatter)
+ *
* @return
*/
- private int lookAheadLinePHPTag() {
- // check if the PHP is only in this line (for CodeFormatter)
+ private TokenName lookAheadLinePHPTag() {
int currentPositionInLine = currentPosition;
char previousCharInLine = ' ';
char currentCharInLine = ' ';
// update the scanner's current Position in the source
currentPosition = currentPositionInLine;
// use as "dummy" token
- return TokenNameEOF;
+ return TokenName.EOF;
}
break;
case '\\':
break;
case '\n':
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
case '#':
if (!singleQuotedStringActive && !doubleQuotedStringActive) {
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
}
break;
case '/':
- if (previousCharInLine == '/' && !singleQuotedStringActive && !doubleQuotedStringActive) {
+ if (previousCharInLine == '/' && !singleQuotedStringActive
+ && !doubleQuotedStringActive) {
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
}
break;
case '*':
- if (previousCharInLine == '/' && !singleQuotedStringActive && !doubleQuotedStringActive) {
+ if (previousCharInLine == '/' && !singleQuotedStringActive
+ && !doubleQuotedStringActive) {
phpMode = true;
- return TokenNameINLINE_HTML;
+ return TokenName.INLINE_HTML;
}
break;
}
}
} catch (IndexOutOfBoundsException e) {
phpMode = true;
- currentPosition = currentPositionInLine;
- return TokenNameINLINE_HTML;
+ currentPosition = currentPositionInLine - 1;
+ return TokenName.INLINE_HTML;
}
}
// unicodeAsBackSlash = currentCharacter == '\\';
// }
/*
- * Tokenize a method body, assuming that curly brackets are properly balanced.
+ * Tokenize a method body, assuming that curly brackets are properly
+ * balanced.
*/
public final void jumpOverMethodBody() {
this.wasAcr = false;
int found = 1;
try {
while (true) { // loop for jumping over comments
- // ---------Consume white space and handles startPosition---------
+ // ---------Consume white space and handles
+ // startPosition---------
boolean isWhiteSpace;
do {
startPosition = currentPosition;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
+ // if (((currentCharacter = source[currentPosition++]) ==
+ // '\\')
// && (source[currentPosition] == 'u')) {
// isWhiteSpace = jumpOverUnicodeWhiteSpace();
// } else {
- if (recordLineSeparator && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
pushLineSeparator();
isWhiteSpace = Character.isWhitespace(currentCharacter);
// }
// try { // consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
+ // if (((currentCharacter = source[currentPosition++])
+ // == '\\')
// && (source[currentPosition] == 'u')) {
// getNextUnicodeChar();
// } else {
// try { // consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
+ // if (((currentCharacter = source[currentPosition++])
+ // == '\\')
// && (source[currentPosition] == 'u')) {
// getNextUnicodeChar();
// } else {
// try { // consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
+ // if (((currentCharacter =
+ // source[currentPosition++]) == '\\')
// && (source[currentPosition] == 'u')) {
// getNextUnicodeChar();
// } else {
try {
// get the next char
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) ==
+ // if (((currentCharacter =
+ // source[currentPosition++]) ==
// '\\')
// && (source[currentPosition] == 'u')) {
// //-------------unicode traitement ------------
// (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
// }
// }
- while (currentCharacter != '\r' && currentCharacter != '\n') {
+ while (currentCharacter != '\r'
+ && currentCharacter != '\n') {
// get the next char
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++])
+ // if (((currentCharacter =
+ // source[currentPosition++])
// == '\\')
// && (source[currentPosition] == 'u')) {
- // //-------------unicode traitement ------------
+ // //-------------unicode traitement
+ // ------------
// int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
// currentPosition++;
// while (source[currentPosition] == 'u') {
// } //something different from \n and \r
// else {
// currentCharacter =
- // (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ // (char) (((c1 * 16 + c2) * 16 + c3) * 16 +
+ // c4);
// }
// }
}
- if (recordLineSeparator && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
pushLineSeparator();
} catch (IndexOutOfBoundsException e) {
} // an eof will them be generated
// try { // consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
+ // if (((currentCharacter = source[currentPosition++])
+ // == '\\')
// && (source[currentPosition] == 'u')) {
// getNextUnicodeChar();
// } else {
if (currentCharacter == '*') {
star = true;
}
- if (recordLineSeparator && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
pushLineSeparator();
try { // get the next char
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) ==
+ // if (((currentCharacter =
+ // source[currentPosition++]) ==
// '\\')
// && (source[currentPosition] == 'u')) {
// //-------------unicode traitement ------------
// }
// loop until end of comment */
while ((currentCharacter != '/') || (!star)) {
- if (recordLineSeparator && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
pushLineSeparator();
star = currentCharacter == '*';
// get next char
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++])
+ // if (((currentCharacter =
+ // source[currentPosition++])
// == '\\')
// && (source[currentPosition] == 'u')) {
- // //-------------unicode traitement ------------
+ // //-------------unicode traitement
+ // ------------
// int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
// currentPosition++;
// while (source[currentPosition] == 'u') {
// } //something different from * and /
// else {
// currentCharacter =
- // (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ // (char) (((c1 * 16 + c2) * 16 + c3) * 16 +
+ // c4);
// }
// }
}
break;
}
default:
- if (isPHPIdentOrVarStart(currentCharacter) ) {
+ if (isPHPIdentOrVarStart(currentCharacter)) {
try {
scanIdentifierOrKeyword((currentCharacter == '$'));
} catch (InvalidInputException ex) {
;
break;
}
- if ( ObviousIdentCharNatures[currentCharacter]==C_DIGIT) {
-// if (Character.isDigit(currentCharacter)) {
+ if (ObviousIdentCharNatures[currentCharacter] == C_DIGIT) {
+ // if (Character.isDigit(currentCharacter)) {
try {
scanNumber(false);
} catch (InvalidInputException ex) {
public final int[] getLineEnds() {
// return a bounded copy of this.lineEnds
int[] copy;
- System.arraycopy(lineEnds, 0, copy = new int[linePtr + 1], 0, linePtr + 1);
+ System.arraycopy(lineEnds, 0, copy = new int[linePtr + 1], 0,
+ linePtr + 1);
return copy;
}
return this.source;
}
- public static boolean isIdentifierOrKeyword(int token) {
- return (token == TokenNameIdentifier) || (token > TokenNameKEYWORD);
+ public static boolean isIdentifierOrKeyword (TokenName token) {
+ return (token == TokenName.IDENTIFIER) || (token.compareTo (TokenName.KEYWORD) > 0);
}
final char[] optimizedCurrentTokenSource1() {
c1 = source[startPosition + 1];
if (c0 == '$') {
// return always the same char[] build only once
- // optimization at no speed cost of 99.5 % of the singleCharIdentifier
+ // optimization at no speed cost of 99.5 % of the
+ // singleCharIdentifier
switch (c1) {
case 'a':
return charArray_va;
final char[] optimizedCurrentTokenSource3() {
// try to return the same char[] build only once
char c0, c1, c2;
- int hash = (((c0 = source[startPosition]) << 12) + ((c1 = source[startPosition + 1]) << 6) + (c2 = source[startPosition + 2]))
+ int hash = (((c0 = source[startPosition]) << 12)
+ + ((c1 = source[startPosition + 1]) << 6) + (c2 = source[startPosition + 2]))
% TableSize;
char[][] table = charArray_length[1][hash];
int i = newEntry3;
while (++i < InternalTableSize) {
char[] charArray = table[i];
- if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]))
+ if ((c0 == charArray[0]) && (c1 == charArray[1])
+ && (c2 == charArray[2]))
return charArray;
}
// ---------other side---------
int max = newEntry3;
while (++i <= max) {
char[] charArray = table[i];
- if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]))
+ if ((c0 == charArray[0]) && (c1 == charArray[1])
+ && (c2 == charArray[2]))
return charArray;
}
// --------add the entry-------
final char[] optimizedCurrentTokenSource4() {
// try to return the same char[] build only once
char c0, c1, c2, c3;
- long hash = ((((long) (c0 = source[startPosition])) << 18) + ((c1 = source[startPosition + 1]) << 12)
+ long hash = ((((long) (c0 = source[startPosition])) << 18)
+ + ((c1 = source[startPosition + 1]) << 12)
+ ((c2 = source[startPosition + 2]) << 6) + (c3 = source[startPosition + 3]))
% TableSize;
char[][] table = charArray_length[2][(int) hash];
int i = newEntry4;
while (++i < InternalTableSize) {
char[] charArray = table[i];
- if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]) && (c3 == charArray[3]))
+ if ((c0 == charArray[0]) && (c1 == charArray[1])
+ && (c2 == charArray[2]) && (c3 == charArray[3]))
return charArray;
}
// ---------other side---------
i = -1;
+
int max = newEntry4;
while (++i <= max) {
char[] charArray = table[i];
- if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]) && (c3 == charArray[3]))
+ if ((c0 == charArray[0]) && (c1 == charArray[1])
+ && (c2 == charArray[2]) && (c3 == charArray[3]))
return charArray;
}
// --------add the entry-------
final char[] optimizedCurrentTokenSource5() {
// try to return the same char[] build only once
char c0, c1, c2, c3, c4;
- long hash = ((((long) (c0 = source[startPosition])) << 24) + (((long) (c1 = source[startPosition + 1])) << 18)
- + ((c2 = source[startPosition + 2]) << 12) + ((c3 = source[startPosition + 3]) << 6) + (c4 = source[startPosition + 4]))
+ long hash = ((((long) (c0 = source[startPosition])) << 24)
+ + (((long) (c1 = source[startPosition + 1])) << 18)
+ + ((c2 = source[startPosition + 2]) << 12)
+ + ((c3 = source[startPosition + 3]) << 6) + (c4 = source[startPosition + 4]))
% TableSize;
char[][] table = charArray_length[3][(int) hash];
int i = newEntry5;
while (++i < InternalTableSize) {
char[] charArray = table[i];
- if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]) && (c3 == charArray[3]) && (c4 == charArray[4]))
+ if ((c0 == charArray[0]) && (c1 == charArray[1])
+ && (c2 == charArray[2]) && (c3 == charArray[3])
+ && (c4 == charArray[4]))
return charArray;
}
// ---------other side---------
int max = newEntry5;
while (++i <= max) {
char[] charArray = table[i];
- if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]) && (c3 == charArray[3]) && (c4 == charArray[4]))
+ if ((c0 == charArray[0]) && (c1 == charArray[1])
+ && (c2 == charArray[2]) && (c3 == charArray[3])
+ && (c4 == charArray[4]))
return charArray;
}
// --------add the entry-------
final char[] optimizedCurrentTokenSource6() {
// try to return the same char[] build only once
char c0, c1, c2, c3, c4, c5;
- long hash = ((((long) (c0 = source[startPosition])) << 32) + (((long) (c1 = source[startPosition + 1])) << 24)
- + (((long) (c2 = source[startPosition + 2])) << 18) + ((c3 = source[startPosition + 3]) << 12)
+ long hash = ((((long) (c0 = source[startPosition])) << 32)
+ + (((long) (c1 = source[startPosition + 1])) << 24)
+ + (((long) (c2 = source[startPosition + 2])) << 18)
+ + ((c3 = source[startPosition + 3]) << 12)
+ ((c4 = source[startPosition + 4]) << 6) + (c5 = source[startPosition + 5]))
% TableSize;
char[][] table = charArray_length[4][(int) hash];
int i = newEntry6;
while (++i < InternalTableSize) {
char[] charArray = table[i];
- if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]) && (c3 == charArray[3]) && (c4 == charArray[4])
- && (c5 == charArray[5]))
+ if ((c0 == charArray[0]) && (c1 == charArray[1])
+ && (c2 == charArray[2]) && (c3 == charArray[3])
+ && (c4 == charArray[4]) && (c5 == charArray[5]))
return charArray;
}
// ---------other side---------
int max = newEntry6;
while (++i <= max) {
char[] charArray = table[i];
- if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]) && (c3 == charArray[3]) && (c4 == charArray[4])
- && (c5 == charArray[5]))
+ if ((c0 == charArray[0]) && (c1 == charArray[1])
+ && (c2 == charArray[2]) && (c3 == charArray[3])
+ && (c4 == charArray[4]) && (c5 == charArray[5]))
return charArray;
}
// --------add the entry-------
}
public final void pushUnicodeLineSeparator() {
- // isUnicode means that the \r or \n has been read as a unicode character
+ // isUnicode means that the \r or \n has been read as a unicode
+ // character
// see comment on isLineDelimiter(char) for the use of '\n' and '\r'
final int INCREMENT = 250;
// currentCharacter is at position currentPosition-1
}
}
- public void recordComment(int token) {
+ public void recordComment(TokenName token) {
// compute position
int stopPosition = this.currentPosition;
switch (token) {
- case TokenNameCOMMENT_LINE:
+ case COMMENT_LINE:
stopPosition = -this.lastCommentLinePosition;
break;
- case TokenNameCOMMENT_BLOCK:
+ case COMMENT_BLOCK:
stopPosition = -this.currentPosition;
break;
}
// a new comment is recorded
int length = this.commentStops.length;
if (++this.commentPtr >= length) {
- System.arraycopy(this.commentStops, 0, this.commentStops = new int[length + 30], 0, length);
+ System.arraycopy(this.commentStops, 0,
+ this.commentStops = new int[length + 30], 0, length);
// grows the positions buffers too
- System.arraycopy(this.commentStarts, 0, this.commentStarts = new int[length + 30], 0, length);
+ System.arraycopy(this.commentStarts, 0,
+ this.commentStarts = new int[length + 30], 0, length);
}
this.commentStops[this.commentPtr] = stopPosition;
this.commentStarts[this.commentPtr] = this.startPosition;
// int[] oldStack = commentStops;
// commentStops = new int[oldStackLength + 30];
// System.arraycopy(oldStack, 0, commentStops, 0, oldStackLength);
- // commentStops[commentPtr] = isJavadoc ? currentPosition : -currentPosition;
+ // commentStops[commentPtr] = isJavadoc ? currentPosition :
+ // -currentPosition;
// //grows the positions buffers too
// int[] old = commentStarts;
// commentStarts = new int[oldStackLength + 30];
commentPtr = -1; // reset comment stack
}
- public final void scanSingleQuotedEscapeCharacter() throws InvalidInputException {
+ public final void scanSingleQuotedEscapeCharacter()
+ throws InvalidInputException {
// the string with "\\u" is a legal string of two chars \ and u
// thus we use a direct access to the source (for regular cases).
// if (unicodeAsBackSlash) {
}
}
- public final void scanDoubleQuotedEscapeCharacter() throws InvalidInputException {
+ public final void scanDoubleQuotedEscapeCharacter()
+ throws InvalidInputException {
currentCharacter = source[currentPosition++];
switch (currentCharacter) {
// case 'b' :
int number = Character.getNumericValue(currentCharacter);
if (number >= 0 && number <= 7) {
boolean zeroToThreeNot = number > 3;
- if (Character.isDigit(currentCharacter = source[currentPosition++])) {
+ if (Character
+ .isDigit(currentCharacter = source[currentPosition++])) {
int digit = Character.getNumericValue(currentCharacter);
if (digit >= 0 && digit <= 7) {
number = (number * 8) + digit;
- if (Character.isDigit(currentCharacter = source[currentPosition++])) {
- if (zeroToThreeNot) { // has read \NotZeroToThree OctalDigit
+ if (Character
+ .isDigit(currentCharacter = source[currentPosition++])) {
+ if (zeroToThreeNot) { // has read \NotZeroToThree
+ // OctalDigit
// Digit --> ignore last character
currentPosition--;
} else {
- digit = Character.getNumericValue(currentCharacter);
+ digit = Character
+ .getNumericValue(currentCharacter);
if (digit >= 0 && digit <= 7) {
- // has read \ZeroToThree OctalDigit OctalDigit
+ // has read \ZeroToThree OctalDigit
+ // OctalDigit
number = (number * 8) + digit;
- } else { // has read \ZeroToThree OctalDigit NonOctalDigit
+ } else { // has read \ZeroToThree OctalDigit
+ // NonOctalDigit
// --> ignore last character
currentPosition--;
}
}
- } else { // has read \OctalDigit NonDigit--> ignore last
+ } else { // has read \OctalDigit NonDigit--> ignore
+ // last
// character
currentPosition--;
}
- } else { // has read \OctalDigit NonOctalDigit--> ignore last
+ } else { // has read \OctalDigit NonOctalDigit--> ignore
+ // last
// character
currentPosition--;
}
throw new InvalidInputException(INVALID_ESCAPE);
currentCharacter = (char) number;
}
- // else
- // throw new InvalidInputException(INVALID_ESCAPE);
+ // else
+ // throw new InvalidInputException(INVALID_ESCAPE);
}
}
// public int scanIdentifierOrKeyword() throws InvalidInputException {
// return scanIdentifierOrKeyword( false );
// }
- public int scanIdentifierOrKeyword(boolean isVariable) throws InvalidInputException {
+ public TokenName scanIdentifierOrKeyword(boolean isVariable)
+ throws InvalidInputException {
// test keywords
// first dispatch on the first char.
// then the length. If there are several
- // keywors with the same length AND the same first char, then do another
+ // keywords with the same length AND the same first char, then do another
// disptach on the second char :-)...cool....but fast !
useAssertAsAnIndentifier = false;
while (getNextCharAsJavaIdentifierPart()) {
;
if (isVariable) {
// if (new String(getCurrentTokenSource()).equals("$this")) {
- // return TokenNamethis;
+ // return TokenName.this;
// }
- return TokenNameVariable;
+ return TokenName.VARIABLE;
}
int index, length;
char[] data;
char firstLetter;
// if (withoutUnicodePtr == 0)
- // quick test on length == 1 but not on length > 12 while most identifier
+ // quick test on length == 1 but not on length > 12 while most
+ // identifier
// have a length which is <= 12...but there are lots of identifier with
// only one char....
// {
if ((length = currentPosition - startPosition) == 1)
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
// data = source;
data = new char[length];
index = startPosition;
index = 0;
// } else {
// if ((length = withoutUnicodePtr) == 1)
- // return TokenNameIdentifier;
+ // return TokenName.Identifier;
// // data = withoutUnicodeBuffer;
// data = new char[withoutUnicodeBuffer.length];
// for (int i = 0; i < withoutUnicodeBuffer.length; i++) {
switch (length) {
case 8:
// __FILE__
- if ((data[++index] == '_') && (data[++index] == 'f') && (data[++index] == 'i') && (data[++index] == 'l')
- && (data[++index] == 'e') && (data[++index] == '_') && (data[++index] == '_'))
- return TokenNameFILE;
+ if ((data[++index] == '_') && (data[++index] == 'f')
+ && (data[++index] == 'i') && (data[++index] == 'l')
+ && (data[++index] == 'e') && (data[++index] == '_')
+ && (data[++index] == '_'))
+ return TokenName.FILE;
index = 0; // __LINE__
- if ((data[++index] == '_') && (data[++index] == 'l') && (data[++index] == 'i') && (data[++index] == 'n')
- && (data[++index] == 'e') && (data[++index] == '_') && (data[++index] == '_'))
- return TokenNameLINE;
+ if ((data[++index] == '_') && (data[++index] == 'l')
+ && (data[++index] == 'i') && (data[++index] == 'n')
+ && (data[++index] == 'e') && (data[++index] == '_')
+ && (data[++index] == '_'))
+ return TokenName.LINE;
break;
case 9:
// __CLASS__
- if ((data[++index] == '_') && (data[++index] == 'c') && (data[++index] == 'l') && (data[++index] == 'a')
- && (data[++index] == 's') && (data[++index] == 's') && (data[++index] == '_') && (data[++index] == '_'))
- return TokenNameCLASS_C;
+ if ((data[++index] == '_') && (data[++index] == 'c')
+ && (data[++index] == 'l') && (data[++index] == 'a')
+ && (data[++index] == 's') && (data[++index] == 's')
+ && (data[++index] == '_') && (data[++index] == '_'))
+ return TokenName.CLASS_C;
break;
case 11:
// __METHOD__
- if ((data[++index] == '_') && (data[++index] == 'm') && (data[++index] == 'e') && (data[++index] == 't')
- && (data[++index] == 'h') && (data[++index] == 'o') && (data[++index] == 'd') && (data[++index] == '_')
+ if ((data[++index] == '_') && (data[++index] == 'm')
+ && (data[++index] == 'e') && (data[++index] == 't')
+ && (data[++index] == 'h') && (data[++index] == 'o')
+ && (data[++index] == 'd') && (data[++index] == '_')
&& (data[++index] == '_'))
- return TokenNameMETHOD_C;
+ return TokenName.METHOD_C;
break;
case 12:
// __FUNCTION__
- if ((data[++index] == '_') && (data[++index] == 'f') && (data[++index] == 'u') && (data[++index] == 'n')
- && (data[++index] == 'c') && (data[++index] == 't') && (data[++index] == 'i') && (data[++index] == 'o')
- && (data[++index] == 'n') && (data[++index] == '_') && (data[++index] == '_'))
- return TokenNameFUNC_C;
+ if ((data[++index] == '_') && (data[++index] == 'f')
+ && (data[++index] == 'u') && (data[++index] == 'n')
+ && (data[++index] == 'c') && (data[++index] == 't')
+ && (data[++index] == 'i') && (data[++index] == 'o')
+ && (data[++index] == 'n') && (data[++index] == '_')
+ && (data[++index] == '_'))
+ return TokenName.FUNC_C;
break;
}
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
case 'a':
// as and array abstract
switch (length) {
case 2:
// as
if ((data[++index] == 's')) {
- return TokenNameas;
- } else {
- return TokenNameIdentifier;
+ return TokenName.AS;
}
+ return TokenName.IDENTIFIER;
case 3:
// and
if ((data[++index] == 'n') && (data[++index] == 'd')) {
- return TokenNameand;
- } else {
- return TokenNameIdentifier;
+ return TokenName.OP_AND_OLD;
}
+ return TokenName.IDENTIFIER;
case 5:
// array
- if ((data[++index] == 'r') && (data[++index] == 'r') && (data[++index] == 'a') && (data[++index] == 'y'))
- return TokenNamearray;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 'r') && (data[++index] == 'r')
+ && (data[++index] == 'a') && (data[++index] == 'y'))
+ return TokenName.ARRAY;
+ return TokenName.IDENTIFIER;
case 8:
- if ((data[++index] == 'b') && (data[++index] == 's') && (data[++index] == 't') && (data[++index] == 'r')
- && (data[++index] == 'a') && (data[++index] == 'c') && (data[++index] == 't'))
- return TokenNameabstract;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ if ((data[++index] == 'b') && (data[++index] == 's')
+ && (data[++index] == 't') && (data[++index] == 'r')
+ && (data[++index] == 'a') && (data[++index] == 'c')
+ && (data[++index] == 't'))
+ return TokenName.ABSTRACT;
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'b':
// break
switch (length) {
case 5:
- if ((data[++index] == 'r') && (data[++index] == 'e') && (data[++index] == 'a') && (data[++index] == 'k'))
- return TokenNamebreak;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ if ((data[++index] == 'r') && (data[++index] == 'e')
+ && (data[++index] == 'a') && (data[++index] == 'k'))
+ return TokenName.BREAK;
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'c':
// case catch class clone const continue
switch (length) {
case 4:
- if ((data[++index] == 'a') && (data[++index] == 's') && (data[++index] == 'e'))
- return TokenNamecase;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 'a') && (data[++index] == 's')
+ && (data[++index] == 'e'))
+ return TokenName.CASE;
+ return TokenName.IDENTIFIER;
case 5:
- if ((data[++index] == 'a') && (data[++index] == 't') && (data[++index] == 'c') && (data[++index] == 'h'))
- return TokenNamecatch;
+ if ((data[++index] == 'a') && (data[++index] == 't')
+ && (data[++index] == 'c') && (data[++index] == 'h'))
+ return TokenName.CATCH;
index = 0;
- if ((data[++index] == 'l') && (data[++index] == 'a') && (data[++index] == 's') && (data[++index] == 's'))
- return TokenNameclass;
+ if ((data[++index] == 'l') && (data[++index] == 'a')
+ && (data[++index] == 's') && (data[++index] == 's'))
+ return TokenName.CLASS;
index = 0;
- if ((data[++index] == 'l') && (data[++index] == 'o') && (data[++index] == 'n') && (data[++index] == 'e'))
- return TokenNameclone;
+ if ((data[++index] == 'l') && (data[++index] == 'o')
+ && (data[++index] == 'n') && (data[++index] == 'e'))
+ return TokenName.CLONE;
index = 0;
- if ((data[++index] == 'o') && (data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 't'))
- return TokenNameconst;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 'o') && (data[++index] == 'n')
+ && (data[++index] == 's') && (data[++index] == 't'))
+ return TokenName.CONST;
+ return TokenName.IDENTIFIER;
case 8:
- if ((data[++index] == 'o') && (data[++index] == 'n') && (data[++index] == 't') && (data[++index] == 'i')
- && (data[++index] == 'n') && (data[++index] == 'u') && (data[++index] == 'e'))
- return TokenNamecontinue;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ if ((data[++index] == 'o') && (data[++index] == 'n')
+ && (data[++index] == 't') && (data[++index] == 'i')
+ && (data[++index] == 'n') && (data[++index] == 'u')
+ && (data[++index] == 'e'))
+ return TokenName.CONTINUE;
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'd':
// declare default do die
// TODO delete define ==> no keyword !
switch (length) {
case 2:
if ((data[++index] == 'o'))
- return TokenNamedo;
- else
- return TokenNameIdentifier;
- // case 6 :
- // if ((data[++index] == 'e')
- // && (data[++index] == 'f')
- // && (data[++index] == 'i')
- // && (data[++index] == 'n')
- // && (data[++index] == 'e'))
- // return TokenNamedefine;
- // else
- // return TokenNameIdentifier;
+ return TokenName.DO;
+ return TokenName.IDENTIFIER;
+ // case 6 :
+ // if ((data[++index] == 'e')
+ // && (data[++index] == 'f')
+ // && (data[++index] == 'i')
+ // && (data[++index] == 'n')
+ // && (data[++index] == 'e'))
+ // return TokenName.define;
+ // else
+ // return TokenName.Identifier;
case 7:
- if ((data[++index] == 'e') && (data[++index] == 'c') && (data[++index] == 'l') && (data[++index] == 'a')
+ if ((data[++index] == 'e') && (data[++index] == 'c')
+ && (data[++index] == 'l') && (data[++index] == 'a')
&& (data[++index] == 'r') && (data[++index] == 'e'))
- return TokenNamedeclare;
+ return TokenName.DECLARE;
index = 0;
- if ((data[++index] == 'e') && (data[++index] == 'f') && (data[++index] == 'a') && (data[++index] == 'u')
+ if ((data[++index] == 'e') && (data[++index] == 'f')
+ && (data[++index] == 'a') && (data[++index] == 'u')
&& (data[++index] == 'l') && (data[++index] == 't'))
- return TokenNamedefault;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ return TokenName.DEFAULT;
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'e':
// echo else exit elseif extends eval
switch (length) {
case 4:
- if ((data[++index] == 'c') && (data[++index] == 'h') && (data[++index] == 'o'))
- return TokenNameecho;
- else if ((data[index] == 'l') && (data[++index] == 's') && (data[++index] == 'e'))
- return TokenNameelse;
- else if ((data[index] == 'x') && (data[++index] == 'i') && (data[++index] == 't'))
- return TokenNameexit;
- else if ((data[index] == 'v') && (data[++index] == 'a') && (data[++index] == 'l'))
- return TokenNameeval;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 'c') && (data[++index] == 'h')
+ && (data[++index] == 'o'))
+ return TokenName.ECHO;
+ else if ((data[index] == 'l') && (data[++index] == 's')
+ && (data[++index] == 'e'))
+ return TokenName.ELSE;
+ else if ((data[index] == 'x') && (data[++index] == 'i')
+ && (data[++index] == 't'))
+ return TokenName.EXIT;
+ else if ((data[index] == 'v') && (data[++index] == 'a')
+ && (data[++index] == 'l'))
+ return TokenName.EVAL;
+ return TokenName.IDENTIFIER;
case 5:
// endif empty
- if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'i') && (data[++index] == 'f'))
- return TokenNameendif;
- if ((data[index] == 'm') && (data[++index] == 'p') && (data[++index] == 't') && (data[++index] == 'y'))
- return TokenNameempty;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 'n') && (data[++index] == 'd')
+ && (data[++index] == 'i') && (data[++index] == 'f'))
+ return TokenName.ENDIF;
+ if ((data[index] == 'm') && (data[++index] == 'p')
+ && (data[++index] == 't') && (data[++index] == 'y'))
+ return TokenName.EMPTY;
+ return TokenName.IDENTIFIER;
case 6:
// endfor
- if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'f') && (data[++index] == 'o')
+ if ((data[++index] == 'n') && (data[++index] == 'd')
+ && (data[++index] == 'f') && (data[++index] == 'o')
&& (data[++index] == 'r'))
- return TokenNameendfor;
- else if ((data[index] == 'l') && (data[++index] == 's') && (data[++index] == 'e') && (data[++index] == 'i')
+ return TokenName.ENDFOR;
+ else if ((data[index] == 'l') && (data[++index] == 's')
+ && (data[++index] == 'e') && (data[++index] == 'i')
&& (data[++index] == 'f'))
- return TokenNameelseif;
- else
- return TokenNameIdentifier;
+ return TokenName.ELSEIF;
+ return TokenName.IDENTIFIER;
case 7:
- if ((data[++index] == 'x') && (data[++index] == 't') && (data[++index] == 'e') && (data[++index] == 'n')
+ if ((data[++index] == 'x') && (data[++index] == 't')
+ && (data[++index] == 'e') && (data[++index] == 'n')
&& (data[++index] == 'd') && (data[++index] == 's'))
- return TokenNameextends;
- else
- return TokenNameIdentifier;
+ return TokenName.EXTENDS;
+ return TokenName.IDENTIFIER;
case 8:
// endwhile
- if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'w') && (data[++index] == 'h')
- && (data[++index] == 'i') && (data[++index] == 'l') && (data[++index] == 'e'))
- return TokenNameendwhile;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 'n') && (data[++index] == 'd')
+ && (data[++index] == 'w') && (data[++index] == 'h')
+ && (data[++index] == 'i') && (data[++index] == 'l')
+ && (data[++index] == 'e'))
+ return TokenName.ENDWHILE;
+ return TokenName.IDENTIFIER;
case 9:
// endswitch
- if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 's') && (data[++index] == 'w')
- && (data[++index] == 'i') && (data[++index] == 't') && (data[++index] == 'c') && (data[++index] == 'h'))
- return TokenNameendswitch;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 'n') && (data[++index] == 'd')
+ && (data[++index] == 's') && (data[++index] == 'w')
+ && (data[++index] == 'i') && (data[++index] == 't')
+ && (data[++index] == 'c') && (data[++index] == 'h'))
+ return TokenName.ENDSWITCH;
+ return TokenName.IDENTIFIER;
case 10:
// enddeclare
- if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'd') && (data[++index] == 'e')
- && (data[++index] == 'c') && (data[++index] == 'l') && (data[++index] == 'a') && (data[++index] == 'r')
+ if ((data[++index] == 'n') && (data[++index] == 'd')
+ && (data[++index] == 'd') && (data[++index] == 'e')
+ && (data[++index] == 'c') && (data[++index] == 'l')
+ && (data[++index] == 'a') && (data[++index] == 'r')
&& (data[++index] == 'e'))
- return TokenNameenddeclare;
+ return TokenName.ENDDECLARE;
index = 0;
if ((data[++index] == 'n') // endforeach
- && (data[++index] == 'd') && (data[++index] == 'f') && (data[++index] == 'o') && (data[++index] == 'r')
- && (data[++index] == 'e') && (data[++index] == 'a') && (data[++index] == 'c') && (data[++index] == 'h'))
- return TokenNameendforeach;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ && (data[++index] == 'd')
+ && (data[++index] == 'f')
+ && (data[++index] == 'o')
+ && (data[++index] == 'r')
+ && (data[++index] == 'e')
+ && (data[++index] == 'a')
+ && (data[++index] == 'c') && (data[++index] == 'h'))
+ return TokenName.ENDFOREACH;
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'f':
// for false final function
switch (length) {
case 3:
if ((data[++index] == 'o') && (data[++index] == 'r'))
- return TokenNamefor;
- else
- return TokenNameIdentifier;
+ return TokenName.FOR;
+ return TokenName.IDENTIFIER;
case 5:
// if ((data[++index] == 'a') && (data[++index] == 'l')
// && (data[++index] == 's') && (data[++index] == 'e'))
- // return TokenNamefalse;
- if ((data[++index] == 'i') && (data[++index] == 'n') && (data[++index] == 'a') && (data[++index] == 'l'))
- return TokenNamefinal;
- else
- return TokenNameIdentifier;
+ // return TokenName.false;
+ if ((data[++index] == 'i') && (data[++index] == 'n')
+ && (data[++index] == 'a') && (data[++index] == 'l'))
+ return TokenName.FINAL;
+ return TokenName.IDENTIFIER;
case 7:
// foreach
- if ((data[++index] == 'o') && (data[++index] == 'r') && (data[++index] == 'e') && (data[++index] == 'a')
+ if ((data[++index] == 'o') && (data[++index] == 'r')
+ && (data[++index] == 'e') && (data[++index] == 'a')
&& (data[++index] == 'c') && (data[++index] == 'h'))
- return TokenNameforeach;
- else
- return TokenNameIdentifier;
+ return TokenName.FOREACH;
+ return TokenName.IDENTIFIER;
case 8:
// function
- if ((data[++index] == 'u') && (data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 't')
- && (data[++index] == 'i') && (data[++index] == 'o') && (data[++index] == 'n'))
- return TokenNamefunction;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ if ((data[++index] == 'u') && (data[++index] == 'n')
+ && (data[++index] == 'c') && (data[++index] == 't')
+ && (data[++index] == 'i') && (data[++index] == 'o')
+ && (data[++index] == 'n'))
+ return TokenName.FUNCTION;
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'g':
- // global
+ // global
if (length == 6) {
- if ((data[++index] == 'l') && (data[++index] == 'o') && (data[++index] == 'b') && (data[++index] == 'a')
+ if ((data[++index] == 'l') && (data[++index] == 'o')
+ && (data[++index] == 'b') && (data[++index] == 'a')
&& (data[++index] == 'l')) {
- return TokenNameglobal;
+ return TokenName.GLOBAL;
}
+ }
+ else if (length == 4) { // goto
+ if ((data[++index] == 'o') &&
+ (data[++index] == 't') &&
+ (data[++index] == 'o')) {
+ return TokenName.GOTO;
+ }
}
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
case 'i':
// if int isset include include_once instanceof interface implements
switch (length) {
case 2:
if (data[++index] == 'f')
- return TokenNameif;
- else
- return TokenNameIdentifier;
- // case 3 :
- // if ((data[++index] == 'n') && (data[++index] == 't'))
- // return TokenNameint;
- // else
- // return TokenNameIdentifier;
+ return TokenName.IF;
+ return TokenName.IDENTIFIER;
+ // case 3 :
+ // if ((data[++index] == 'n') && (data[++index] == 't'))
+ // return TokenName.int;
+ // else
+ // return TokenName.IDENTIFIER;
case 5:
- if ((data[++index] == 's') && (data[++index] == 's') && (data[++index] == 'e') && (data[++index] == 't'))
- return TokenNameisset;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 's') && (data[++index] == 's')
+ && (data[++index] == 'e') && (data[++index] == 't'))
+ return TokenName.ISSET;
+ return TokenName.IDENTIFIER;
case 7:
- if ((data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'l') && (data[++index] == 'u')
+ if ((data[++index] == 'n') && (data[++index] == 'c')
+ && (data[++index] == 'l') && (data[++index] == 'u')
&& (data[++index] == 'd') && (data[++index] == 'e'))
- return TokenNameinclude;
- else
- return TokenNameIdentifier;
+ return TokenName.INCLUDE;
+ return TokenName.IDENTIFIER;
case 9:
// interface
- if ((data[++index] == 'n') && (data[++index] == 't') && (data[++index] == 'e') && (data[++index] == 'r')
- && (data[++index] == 'f') && (data[++index] == 'a') && (data[++index] == 'c') && (data[++index] == 'e'))
- return TokenNameinterface;
- else
- return TokenNameIdentifier;
+ if ((data[++index] == 'n') && (data[++index] == 't')
+ && (data[++index] == 'e') && (data[++index] == 'r')
+ && (data[++index] == 'f') && (data[++index] == 'a')
+ && (data[++index] == 'c') && (data[++index] == 'e'))
+ return TokenName.INTERFACE;
+ return TokenName.IDENTIFIER;
case 10:
- // instanceof
- if ((data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 't') && (data[++index] == 'a')
- && (data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'e') && (data[++index] == 'o')
+ // instanceof implements
+ if ((data[++index] == 'n') && (data[++index] == 's')
+ && (data[++index] == 't') && (data[++index] == 'a')
+ && (data[++index] == 'n') && (data[++index] == 'c')
+ && (data[++index] == 'e') && (data[++index] == 'o')
&& (data[++index] == 'f'))
- return TokenNameinstanceof;
- if ((data[index] == 'm') && (data[++index] == 'p') && (data[++index] == 'l') && (data[++index] == 'e')
- && (data[++index] == 'm') && (data[++index] == 'e') && (data[++index] == 'n') && (data[++index] == 't')
+ return TokenName.INSTANCEOF;
+ if ((data[index] == 'm') && (data[++index] == 'p')
+ && (data[++index] == 'l') && (data[++index] == 'e')
+ && (data[++index] == 'm') && (data[++index] == 'e')
+ && (data[++index] == 'n') && (data[++index] == 't')
&& (data[++index] == 's'))
- return TokenNameimplements;
- else
- return TokenNameIdentifier;
- case 12:
- if ((data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'l') && (data[++index] == 'u')
- && (data[++index] == 'd') && (data[++index] == 'e') && (data[++index] == '_') && (data[++index] == 'o')
- && (data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'e'))
- return TokenNameinclude_once;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ return TokenName.IMPLEMENTS;
+ return TokenName.IDENTIFIER;
+ case 12: // include_once
+ if ((data[++index] == 'n') && (data[++index] == 'c')
+ && (data[++index] == 'l') && (data[++index] == 'u')
+ && (data[++index] == 'd') && (data[++index] == 'e')
+ && (data[++index] == '_') && (data[++index] == 'o')
+ && (data[++index] == 'n') && (data[++index] == 'c')
+ && (data[++index] == 'e'))
+ return TokenName.INCLUDE_ONCE;
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'l':
// list
if (length == 4) {
- if ((data[++index] == 'i') && (data[++index] == 's') && (data[++index] == 't')) {
- return TokenNamelist;
+ if ((data[++index] == 'i') && (data[++index] == 's')
+ && (data[++index] == 't')) {
+ return TokenName.LIST;
}
}
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
case 'n':
- // new null
+ // new null namespace
switch (length) {
case 3:
if ((data[++index] == 'e') && (data[++index] == 'w'))
- return TokenNamenew;
- else
- return TokenNameIdentifier;
- // case 4 :
- // if ((data[++index] == 'u') && (data[++index] == 'l')
- // && (data[++index] == 'l'))
- // return TokenNamenull;
- // else
- // return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ return TokenName.NEW;
+ return TokenName.IDENTIFIER;
+ // case 4 :
+ // if ((data[++index] == 'u') && (data[++index] == 'l')
+ // && (data[++index] == 'l'))
+ // return TokenName.null;
+ // else
+ // return TokenName.IDENTIFIER;
+ case 9:
+ if ((data[++index] == 'a') && (data[++index] == 'm')
+ && (data[++index] == 'e') && (data[++index] == 's')
+ && (data[++index] == 'p') && (data[++index] == 'a')
+ && (data[++index] == 'c') && (data[++index] == 'e')) {
+ return TokenName.NAMESPACE;
+ }
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'o':
// or old_function
if (length == 2) {
if (data[++index] == 'r') {
- return TokenNameor;
+ return TokenName.OP_OR_OLD;
}
}
// if (length == 12) {
// && (data[++index] == 'i')
// && (data[++index] == 'o')
// && (data[++index] == 'n')) {
- // return TokenNameold_function;
+ // return TokenName.old_function;
// }
// }
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
case 'p':
// print public private protected
switch (length) {
case 5:
- if ((data[++index] == 'r') && (data[++index] == 'i') && (data[++index] == 'n') && (data[++index] == 't')) {
- return TokenNameprint;
- } else
- return TokenNameIdentifier;
+ if ((data[++index] == 'r') && (data[++index] == 'i')
+ && (data[++index] == 'n') && (data[++index] == 't')) {
+ return TokenName.PRINT;
+ }
+ return TokenName.IDENTIFIER;
case 6:
- if ((data[++index] == 'u') && (data[++index] == 'b') && (data[++index] == 'l') && (data[++index] == 'i')
+ if ((data[++index] == 'u') && (data[++index] == 'b')
+ && (data[++index] == 'l') && (data[++index] == 'i')
&& (data[++index] == 'c')) {
- return TokenNamepublic;
- } else
- return TokenNameIdentifier;
+ return TokenName.PUBLIC;
+ }
+ return TokenName.IDENTIFIER;
case 7:
- if ((data[++index] == 'r') && (data[++index] == 'i') && (data[++index] == 'v') && (data[++index] == 'a')
+ if ((data[++index] == 'r') && (data[++index] == 'i')
+ && (data[++index] == 'v') && (data[++index] == 'a')
&& (data[++index] == 't') && (data[++index] == 'e')) {
- return TokenNameprivate;
- } else
- return TokenNameIdentifier;
+ return TokenName.PRIVATE;
+ }
+ return TokenName.IDENTIFIER;
case 9:
- if ((data[++index] == 'r') && (data[++index] == 'o') && (data[++index] == 't') && (data[++index] == 'e')
- && (data[++index] == 'c') && (data[++index] == 't') && (data[++index] == 'e') && (data[++index] == 'd')) {
- return TokenNameprotected;
- } else
- return TokenNameIdentifier;
+ if ((data[++index] == 'r') && (data[++index] == 'o')
+ && (data[++index] == 't') && (data[++index] == 'e')
+ && (data[++index] == 'c') && (data[++index] == 't')
+ && (data[++index] == 'e') && (data[++index] == 'd')) {
+ return TokenName.PROTECTED;
+ }
+ return TokenName.IDENTIFIER;
}
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
case 'r':
// return require require_once
if (length == 6) {
- if ((data[++index] == 'e') && (data[++index] == 't') && (data[++index] == 'u') && (data[++index] == 'r')
+ if ((data[++index] == 'e') && (data[++index] == 't')
+ && (data[++index] == 'u') && (data[++index] == 'r')
&& (data[++index] == 'n')) {
- return TokenNamereturn;
+ return TokenName.RETURN;
}
} else if (length == 7) {
- if ((data[++index] == 'e') && (data[++index] == 'q') && (data[++index] == 'u') && (data[++index] == 'i')
+ if ((data[++index] == 'e') && (data[++index] == 'q')
+ && (data[++index] == 'u') && (data[++index] == 'i')
&& (data[++index] == 'r') && (data[++index] == 'e')) {
- return TokenNamerequire;
+ return TokenName.REQUIRE;
}
} else if (length == 12) {
- if ((data[++index] == 'e') && (data[++index] == 'q') && (data[++index] == 'u') && (data[++index] == 'i')
- && (data[++index] == 'r') && (data[++index] == 'e') && (data[++index] == '_') && (data[++index] == 'o')
- && (data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'e')) {
- return TokenNamerequire_once;
+ if ((data[++index] == 'e') && (data[++index] == 'q')
+ && (data[++index] == 'u') && (data[++index] == 'i')
+ && (data[++index] == 'r') && (data[++index] == 'e')
+ && (data[++index] == '_') && (data[++index] == 'o')
+ && (data[++index] == 'n') && (data[++index] == 'c')
+ && (data[++index] == 'e')) {
+ return TokenName.REQUIRE_ONCE;
}
- } else
- return TokenNameIdentifier;
+ }
+ return TokenName.IDENTIFIER;
case 's':
- // static switch
+ // self static switch
switch (length) {
+ // case 4:
+ // if ((data[++index] == 'e') && (data[++index] == 'l') &&
+ // (data[++index]
+ // == 'f')) {
+ // return TokenName.self;
+ // }
+ // return TokenName.IDENTIFIER;
case 6:
if (data[++index] == 't')
- if ((data[++index] == 'a') && (data[++index] == 't') && (data[++index] == 'i') && (data[++index] == 'c')) {
- return TokenNamestatic;
+ if ((data[++index] == 'a') && (data[++index] == 't')
+ && (data[++index] == 'i') && (data[++index] == 'c')) {
+ return TokenName.STATIC;
} else
- return TokenNameIdentifier;
- else if ((data[index] == 'w') && (data[++index] == 'i') && (data[++index] == 't') && (data[++index] == 'c')
+ return TokenName.IDENTIFIER;
+ else if ((data[index] == 'w') && (data[++index] == 'i')
+ && (data[++index] == 't') && (data[++index] == 'c')
&& (data[++index] == 'h'))
- return TokenNameswitch;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ return TokenName.SWITCH;
}
+ return TokenName.IDENTIFIER;
case 't':
// try true throw
switch (length) {
case 3:
if ((data[++index] == 'r') && (data[++index] == 'y'))
- return TokenNametry;
- else
- return TokenNameIdentifier;
- // case 4 :
- // if ((data[++index] == 'r') && (data[++index] == 'u')
- // && (data[++index] == 'e'))
- // return TokenNametrue;
- // else
- // return TokenNameIdentifier;
+ return TokenName.TRY;
+ // case 4 :
+ // if ((data[++index] == 'r') && (data[++index] == 'u')
+ // && (data[++index] == 'e'))
+ // return TokenName.true;
+ else
+ return TokenName.IDENTIFIER;
case 5:
- if ((data[++index] == 'h') && (data[++index] == 'r') && (data[++index] == 'o') && (data[++index] == 'w'))
- return TokenNamethrow;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ if ((data[++index] == 'h') && (data[++index] == 'r')
+ && (data[++index] == 'o') && (data[++index] == 'w'))
+ return TokenName.THROW;
}
+ return TokenName.IDENTIFIER;
case 'u':
// use unset
switch (length) {
case 3:
if ((data[++index] == 's') && (data[++index] == 'e'))
- return TokenNameuse;
+ return TokenName.USE;
else
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
case 5:
- if ((data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 'e') && (data[++index] == 't'))
- return TokenNameunset;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ if ((data[++index] == 'n') && (data[++index] == 's')
+ && (data[++index] == 'e') && (data[++index] == 't'))
+ return TokenName.UNSET;
}
+ return TokenName.IDENTIFIER;
case 'v':
// var
switch (length) {
case 3:
if ((data[++index] == 'a') && (data[++index] == 'r'))
- return TokenNamevar;
- else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ return TokenName.VAR;
}
+ return TokenName.IDENTIFIER;
case 'w':
// while
switch (length) {
case 5:
- if ((data[++index] == 'h') && (data[++index] == 'i') && (data[++index] == 'l') && (data[++index] == 'e'))
- return TokenNamewhile;
- else
- return TokenNameIdentifier;
- // case 6:if ( (data[++index] =='i') && (data[++index]=='d') &&
- // (data[++index]=='e') && (data[++index]=='f')&&
- // (data[++index]=='p'))
- // return TokenNamewidefp ;
- // else
- // return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ if ((data[++index] == 'h') && (data[++index] == 'i')
+ && (data[++index] == 'l') && (data[++index] == 'e'))
+ return TokenName.WHILE;
+ // case 6:if ( (data[++index] =='i') && (data[++index]=='d') &&
+ // (data[++index]=='e') && (data[++index]=='f')&&
+ // (data[++index]=='p'))
+ // return TokenName.widefp ;
+ // else
+ // return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
case 'x':
// xor
switch (length) {
case 3:
if ((data[++index] == 'o') && (data[++index] == 'r'))
- return TokenNamexor;
+ return TokenName.OP_XOR_OLD;
else
- return TokenNameIdentifier;
- default:
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
}
- default:
- return TokenNameIdentifier;
+ return TokenName.IDENTIFIER;
}
+ return TokenName.IDENTIFIER;
}
- public int scanNumber(boolean dotPrefix) throws InvalidInputException {
+ public TokenName scanNumber(boolean dotPrefix) throws InvalidInputException {
// when entering this method the currentCharacter is the firt
// digit of the number , i.e. it may be preceeded by a . when
// dotPrefix is true
}
;
// if (getNextChar('l', 'L') >= 0)
- // return TokenNameLongLiteral;
+ // return TokenName.LongLiteral;
// else
- return TokenNameIntegerLiteral;
+ return TokenName.INTEGERLITERAL;
}
// there is x or X in the number
// potential octal ! ... some one may write 000099.0 ! thus 00100 <
}
;
// if (getNextChar('l', 'L') >= 0) {
- // return TokenNameLongLiteral;
+ // return TokenName.LongLiteral;
// }
//
// if (getNextChar('f', 'F') >= 0) {
- // return TokenNameFloatingPointLiteral;
+ // return TokenName.FloatingPointLiteral;
// }
if (getNextChar('d', 'D') >= 0) {
- return TokenNameDoubleLiteral;
+ return TokenName.DOUBLELITERAL;
} else { // make the distinction between octal and float ....
if (getNextChar('.')) { // bingo ! ....
while (getNextCharAsDigit()) {
// consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
+ // if (((currentCharacter =
+ // source[currentPosition++]) == '\\')
// && (source[currentPosition] == 'u')) {
// getNextUnicodeChar();
// } else {
// if (withoutUnicodePtr != 0) {
- // withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ // withoutUnicodeBuffer[++withoutUnicodePtr] =
+ // currentCharacter;
// }
// }
- if ((currentCharacter == '-') || (currentCharacter == '+')) {
+ if ((currentCharacter == '-')
+ || (currentCharacter == '+')) {
// consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
+ // if (((currentCharacter =
+ // source[currentPosition++]) == '\\')
// && (source[currentPosition] == 'u')) {
// getNextUnicodeChar();
// } else {
;
}
// if (getNextChar('f', 'F') >= 0)
- // return TokenNameFloatingPointLiteral;
+ // return TokenName.FloatingPointLiteral;
getNextChar('d', 'D'); // jump over potential d or D
- return TokenNameDoubleLiteral;
+ return TokenName.DOUBLELITERAL;
} else {
- return TokenNameIntegerLiteral;
+ return TokenName.INTEGERLITERAL;
}
}
} else {
}
;
// if ((!dotPrefix) && (getNextChar('l', 'L') >= 0))
- // return TokenNameLongLiteral;
- if ((!dotPrefix) && (getNextChar('.'))) { // decimal part that can be empty
+ // return TokenName.LongLiteral;
+ if ((!dotPrefix) && (getNextChar('.'))) { // decimal part that can be
+ // empty
while (getNextCharAsDigit()) {
}
;
;
}
if (getNextChar('d', 'D') >= 0)
- return TokenNameDoubleLiteral;
+ return TokenName.DOUBLELITERAL;
// if (getNextChar('f', 'F') >= 0)
- // return TokenNameFloatingPointLiteral;
+ // return TokenName.FloatingPointLiteral;
// the long flag has been tested before
- return floating ? TokenNameDoubleLiteral : TokenNameIntegerLiteral;
+ return floating ? TokenName.DOUBLELITERAL : TokenName.INTEGERLITERAL;
}
/**
initialPosition = currentPosition = 0;
containsAssertKeyword = false;
withoutUnicodeBuffer = new char[this.source.length];
+ fFillerToken = TokenName.EOF;
// encapsedStringStack = new Stack();
}
middle = new char[0];
}
char end[] = new char[source.length - (currentPosition - 1)];
- System.arraycopy(source, (currentPosition - 1) + 1, end, 0, source.length - (currentPosition - 1) - 1);
- return new String(front) + "\n===============================\nStarts here -->" //$NON-NLS-1$
- + new String(middle) + "<-- Ends here\n===============================\n" //$NON-NLS-1$
+ System.arraycopy(source, (currentPosition - 1) + 1, end, 0,
+ source.length - (currentPosition - 1) - 1);
+ return new String(front)
+ + "\n===============================\nStarts here -->" //$NON-NLS-1$
+ + new String(middle)
+ + "<-- Ends here\n===============================\n" //$NON-NLS-1$
+ new String(end);
}
- public final String toStringAction(int act) {
+ public final String toStringAction(TokenName act) {
switch (act) {
- case TokenNameERROR:
- return "ScannerError"; // + new String(getCurrentTokenSource()) + ")";
- // //$NON-NLS-1$
- case TokenNameINLINE_HTML:
+ case ERROR:
+ return "ScannerError"; // + new String(getCurrentTokenSource()) +
+ // ")";
+ // //$NON-NLS-1$
+ case INLINE_HTML:
return "Inline-HTML(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameIdentifier:
+ case ECHO_INVISIBLE:
+ // 0-length token
+ return "";
+ case IDENTIFIER:
return "Identifier(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameVariable:
+ case VARIABLE:
return "Variable(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameabstract:
+ case ABSTRACT:
return "abstract"; //$NON-NLS-1$
- case TokenNameand:
+ case OP_AND_OLD:
return "AND"; //$NON-NLS-1$
- case TokenNamearray:
+ case ARRAY:
return "array"; //$NON-NLS-1$
- case TokenNameas:
+ case AS:
return "as"; //$NON-NLS-1$
- case TokenNamebreak:
+ case BREAK:
return "break"; //$NON-NLS-1$
- case TokenNamecase:
+ case CASE:
return "case"; //$NON-NLS-1$
- case TokenNameclass:
+ case CLASS:
return "class"; //$NON-NLS-1$
- case TokenNamecatch:
+ case CATCH:
return "catch"; //$NON-NLS-1$
- case TokenNameclone:
+ case CLONE:
//$NON-NLS-1$
return "clone";
- case TokenNameconst:
+ case CONST:
//$NON-NLS-1$
return "const";
- case TokenNamecontinue:
+ case CONTINUE:
return "continue"; //$NON-NLS-1$
- case TokenNamedefault:
+ case DEFAULT:
return "default"; //$NON-NLS-1$
- // case TokenNamedefine :
- // return "define"; //$NON-NLS-1$
- case TokenNamedo:
+ // case define :
+ // return "define"; //$NON-NLS-1$
+ case DO:
return "do"; //$NON-NLS-1$
- case TokenNameecho:
+ case ECHO:
return "echo"; //$NON-NLS-1$
- case TokenNameelse:
+ case ELSE:
return "else"; //$NON-NLS-1$
- case TokenNameelseif:
+ case ELSEIF:
return "elseif"; //$NON-NLS-1$
- case TokenNameendfor:
+ case ENDFOR:
return "endfor"; //$NON-NLS-1$
- case TokenNameendforeach:
+ case ENDFOREACH:
return "endforeach"; //$NON-NLS-1$
- case TokenNameendif:
+ case ENDIF:
return "endif"; //$NON-NLS-1$
- case TokenNameendswitch:
+ case ENDSWITCH:
return "endswitch"; //$NON-NLS-1$
- case TokenNameendwhile:
+ case ENDWHILE:
return "endwhile"; //$NON-NLS-1$
- case TokenNameexit:
+ case EXIT:
return "exit";
- case TokenNameextends:
+ case EXTENDS:
return "extends"; //$NON-NLS-1$
- // case TokenNamefalse :
- // return "false"; //$NON-NLS-1$
- case TokenNamefinal:
+ // case false :
+ // return "false"; //$NON-NLS-1$
+ case FINAL:
return "final"; //$NON-NLS-1$
- case TokenNamefor:
+ case FOR:
return "for"; //$NON-NLS-1$
- case TokenNameforeach:
+ case FOREACH:
return "foreach"; //$NON-NLS-1$
- case TokenNamefunction:
+ case FUNCTION:
return "function"; //$NON-NLS-1$
- case TokenNameglobal:
+ case GLOBAL:
return "global"; //$NON-NLS-1$
- case TokenNameif:
+ case IF:
return "if"; //$NON-NLS-1$
- case TokenNameimplements:
+ case IMPLEMENTS:
return "implements"; //$NON-NLS-1$
- case TokenNameinclude:
+ case INCLUDE:
return "include"; //$NON-NLS-1$
- case TokenNameinclude_once:
+ case INCLUDE_ONCE:
return "include_once"; //$NON-NLS-1$
- case TokenNameinstanceof:
+ case INSTANCEOF:
return "instanceof"; //$NON-NLS-1$
- case TokenNameinterface:
+ case INTERFACE:
return "interface"; //$NON-NLS-1$
- case TokenNameisset:
+ case ISSET:
return "isset"; //$NON-NLS-1$
- case TokenNamelist:
+ case LIST:
return "list"; //$NON-NLS-1$
- case TokenNamenew:
+ case NEW:
return "new"; //$NON-NLS-1$
- // case TokenNamenull :
- // return "null"; //$NON-NLS-1$
- case TokenNameor:
+ // case null :
+ // return "null"; //$NON-NLS-1$
+ case OP_OR_OLD:
return "OR"; //$NON-NLS-1$
- case TokenNameprint:
+ case PRINT:
return "print"; //$NON-NLS-1$
- case TokenNameprivate:
+ case PRIVATE:
return "private"; //$NON-NLS-1$
- case TokenNameprotected:
+ case PROTECTED:
return "protected"; //$NON-NLS-1$
- case TokenNamepublic:
+ case PUBLIC:
return "public"; //$NON-NLS-1$
- case TokenNamerequire:
+ case REQUIRE:
return "require"; //$NON-NLS-1$
- case TokenNamerequire_once:
+ case REQUIRE_ONCE:
return "require_once"; //$NON-NLS-1$
- case TokenNamereturn:
+ case RETURN:
return "return"; //$NON-NLS-1$
- case TokenNamestatic:
+ // case self:
+ // return "self"; //$NON-NLS-1$
+ case STATIC:
return "static"; //$NON-NLS-1$
- case TokenNameswitch:
+ case SWITCH:
return "switch"; //$NON-NLS-1$
- // case TokenNametrue :
- // return "true"; //$NON-NLS-1$
- case TokenNameunset:
+ // case true :
+ // return "true"; //$NON-NLS-1$
+ case UNSET:
return "unset"; //$NON-NLS-1$
- case TokenNamevar:
+ case VAR:
return "var"; //$NON-NLS-1$
- case TokenNamewhile:
+ case WHILE:
return "while"; //$NON-NLS-1$
- case TokenNamexor:
+ case OP_XOR_OLD:
return "XOR"; //$NON-NLS-1$
- // case TokenNamethis :
- // return "$this"; //$NON-NLS-1$
- case TokenNameIntegerLiteral:
+ // case this :
+ // return "$this"; //$NON-NLS-1$
+ case INTEGERLITERAL:
return "Integer(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameDoubleLiteral:
+ case DOUBLELITERAL:
return "Double(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameStringDoubleQuote:
+ case STRINGDOUBLEQUOTE:
return "StringLiteral(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameStringSingleQuote:
+ case STRINGSINGLEQUOTE:
return "StringConstant(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameStringInterpolated:
+ case STRINGINTERPOLATED:
return "StringInterpolated(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameEncapsedString0:
+ case ENCAPSEDSTRING0:
return "`"; //$NON-NLS-1$
- // case TokenNameEncapsedString1:
+ // case EncapsedString1:
// return "\'"; //$NON-NLS-1$
- // case TokenNameEncapsedString2:
+ // case EncapsedString2:
// return "\""; //$NON-NLS-1$
- case TokenNameSTRING:
+ case STRING:
return "STRING_DQ(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case TokenNameHEREDOC:
+ case HEREDOC:
return "HEREDOC(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
- case TokenNamePLUS_PLUS:
+ case PLUS_PLUS:
return "++"; //$NON-NLS-1$
- case TokenNameMINUS_MINUS:
+ case MINUS_MINUS:
return "--"; //$NON-NLS-1$
- case TokenNameEQUAL_EQUAL:
+ case EQUAL_EQUAL:
return "=="; //$NON-NLS-1$
- case TokenNameEQUAL_EQUAL_EQUAL:
+ case EQUAL_EQUAL_EQUAL:
return "==="; //$NON-NLS-1$
- case TokenNameEQUAL_GREATER:
+ case EQUAL_GREATER:
return "=>"; //$NON-NLS-1$
- case TokenNameLESS_EQUAL:
+ case LESS_EQUAL:
return "<="; //$NON-NLS-1$
- case TokenNameGREATER_EQUAL:
+ case GREATER_EQUAL:
return ">="; //$NON-NLS-1$
- case TokenNameNOT_EQUAL:
+ case NOT_EQUAL:
return "!="; //$NON-NLS-1$
- case TokenNameNOT_EQUAL_EQUAL:
+ case NOT_EQUAL_EQUAL:
return "!=="; //$NON-NLS-1$
- case TokenNameLEFT_SHIFT:
+ case LEFT_SHIFT:
return "<<"; //$NON-NLS-1$
- case TokenNameRIGHT_SHIFT:
+ case RIGHT_SHIFT:
return ">>"; //$NON-NLS-1$
- case TokenNamePLUS_EQUAL:
+ case PLUS_EQUAL:
return "+="; //$NON-NLS-1$
- case TokenNameMINUS_EQUAL:
+ case MINUS_EQUAL:
return "-="; //$NON-NLS-1$
- case TokenNameMULTIPLY_EQUAL:
+ case MULTIPLY_EQUAL:
return "*="; //$NON-NLS-1$
- case TokenNameDIVIDE_EQUAL:
+ case DIVIDE_EQUAL:
return "/="; //$NON-NLS-1$
- case TokenNameAND_EQUAL:
+ case AND_EQUAL:
return "&="; //$NON-NLS-1$
- case TokenNameOR_EQUAL:
+ case OR_EQUAL:
return "|="; //$NON-NLS-1$
- case TokenNameXOR_EQUAL:
+ case XOR_EQUAL:
return "^="; //$NON-NLS-1$
- case TokenNameREMAINDER_EQUAL:
+ case REMAINDER_EQUAL:
return "%="; //$NON-NLS-1$
- case TokenNameDOT_EQUAL:
+ case DOT_EQUAL:
return ".="; //$NON-NLS-1$
- case TokenNameLEFT_SHIFT_EQUAL:
+ case LEFT_SHIFT_EQUAL:
return "<<="; //$NON-NLS-1$
- case TokenNameRIGHT_SHIFT_EQUAL:
+ case RIGHT_SHIFT_EQUAL:
return ">>="; //$NON-NLS-1$
- case TokenNameOR_OR:
+ case OR_OR:
return "||"; //$NON-NLS-1$
- case TokenNameAND_AND:
+ case AND_AND:
return "&&"; //$NON-NLS-1$
- case TokenNamePLUS:
+ case PLUS:
return "+"; //$NON-NLS-1$
- case TokenNameMINUS:
+ case MINUS:
return "-"; //$NON-NLS-1$
- case TokenNameMINUS_GREATER:
+ case MINUS_GREATER:
return "->";
- case TokenNameNOT:
+ case NOT:
return "!"; //$NON-NLS-1$
- case TokenNameREMAINDER:
+ case REMAINDER:
return "%"; //$NON-NLS-1$
- case TokenNameXOR:
+ case OP_XOR:
return "^"; //$NON-NLS-1$
- case TokenNameAND:
+ case OP_AND:
return "&"; //$NON-NLS-1$
- case TokenNameMULTIPLY:
+ case MULTIPLY:
return "*"; //$NON-NLS-1$
- case TokenNameOR:
+ case OP_OR:
return "|"; //$NON-NLS-1$
- case TokenNameTWIDDLE:
+ case TWIDDLE:
return "~"; //$NON-NLS-1$
- case TokenNameTWIDDLE_EQUAL:
+ case TWIDDLE_EQUAL:
return "~="; //$NON-NLS-1$
- case TokenNameDIVIDE:
+ case DIVIDE:
return "/"; //$NON-NLS-1$
- case TokenNameGREATER:
+ case GREATER:
return ">"; //$NON-NLS-1$
- case TokenNameLESS:
+ case LESS:
return "<"; //$NON-NLS-1$
- case TokenNameLPAREN:
+ case LPAREN:
return "("; //$NON-NLS-1$
- case TokenNameRPAREN:
+ case RPAREN:
return ")"; //$NON-NLS-1$
- case TokenNameLBRACE:
+ case LBRACE:
return "{"; //$NON-NLS-1$
- case TokenNameRBRACE:
+ case RBRACE:
return "}"; //$NON-NLS-1$
- case TokenNameLBRACKET:
+ case LBRACKET:
return "["; //$NON-NLS-1$
- case TokenNameRBRACKET:
+ case RBRACKET:
return "]"; //$NON-NLS-1$
- case TokenNameSEMICOLON:
+ case SEMICOLON:
return ";"; //$NON-NLS-1$
- case TokenNameQUESTION:
+ case QUESTION:
return "?"; //$NON-NLS-1$
- case TokenNameCOLON:
+ case COLON:
return ":"; //$NON-NLS-1$
- case TokenNameCOMMA:
+ case COMMA:
return ","; //$NON-NLS-1$
- case TokenNameDOT:
+ case DOT:
return "."; //$NON-NLS-1$
- case TokenNameEQUAL:
+ case EQUAL:
return "="; //$NON-NLS-1$
- case TokenNameAT:
+ case OP_AT:
return "@";
- case TokenNameDOLLAR:
+ case DOLLAR:
return "$";
- case TokenNameDOLLAR_LBRACE:
+ case DOLLAR_LBRACE:
return "${";
- case TokenNameLBRACE_DOLLAR:
+ case LBRACE_DOLLAR:
return "{$";
- case TokenNameEOF:
+ case EOF:
return "EOF"; //$NON-NLS-1$
- case TokenNameWHITESPACE:
+ case WHITESPACE:
return "WHITESPACE(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
- case TokenNameCOMMENT_LINE:
+ case COMMENT_LINE:
return "COMMENT_LINE(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
- case TokenNameCOMMENT_BLOCK:
+ case COMMENT_BLOCK:
return "COMMENT_BLOCK(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
- case TokenNameCOMMENT_PHPDOC:
+ case COMMENT_PHPDOC:
return "COMMENT_PHPDOC(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
- // case TokenNameHTML :
- // return "HTML(" + new String(getCurrentTokenSource()) + ")";
- // //$NON-NLS-1$
- case TokenNameFILE:
+ // case HTML :
+ // return "HTML(" + new String(getCurrentTokenSource()) + ")";
+ // //$NON-NLS-1$
+ case FILE:
return "__FILE__"; //$NON-NLS-1$
- case TokenNameLINE:
+ case LINE:
return "__LINE__"; //$NON-NLS-1$
- case TokenNameCLASS_C:
+ case CLASS_C:
return "__CLASS__"; //$NON-NLS-1$
- case TokenNameMETHOD_C:
+ case METHOD_C:
return "__METHOD__"; //$NON-NLS-1$
- case TokenNameFUNC_C:
+ case FUNC_C:
return "__FUNCTION__"; //$NON-NLS-1
- case TokenNameboolCAST:
+ case BOOLCAST:
return "( bool )"; //$NON-NLS-1$
- case TokenNameintCAST:
+ case INTCAST:
return "( int )"; //$NON-NLS-1$
- case TokenNamedoubleCAST:
+ case DOUBLECAST:
return "( double )"; //$NON-NLS-1$
- case TokenNameobjectCAST:
+ case OBJECTCAST:
return "( object )"; //$NON-NLS-1$
- case TokenNamestringCAST:
+ case STRINGCAST:
return "( string )"; //$NON-NLS-1$
+ case NAMESPACE:
+ return "( namespace )"; //$NON-NLS-1$
default:
- return "not-a-token(" + (new Integer(act)) + ") " + new String(getCurrentTokenSource()); //$NON-NLS-1$
+ return "token not handled (" + (act.toString ()) + ") " + new String(getCurrentTokenSource()); //$NON-NLS-1$
}
}
this(tokenizeComments, tokenizeWhiteSpace, false);
}
- public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals) {
- this(tokenizeComments, tokenizeWhiteSpace, checkNonExternalizedStringLiterals, false);
+ public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace,
+ boolean checkNonExternalizedStringLiterals) {
+ this(tokenizeComments, tokenizeWhiteSpace,
+ checkNonExternalizedStringLiterals, false);
}
- public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals,
- boolean assertMode) {
- this(tokenizeComments, tokenizeWhiteSpace, checkNonExternalizedStringLiterals, assertMode, false, null, null, true);
+ public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace,
+ boolean checkNonExternalizedStringLiterals, boolean assertMode) {
+ this(tokenizeComments, tokenizeWhiteSpace,
+ checkNonExternalizedStringLiterals, assertMode, false, null,
+ null, true);
}
- public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals,
- boolean assertMode, boolean tokenizeStrings, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive) {
+ public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace,
+ boolean checkNonExternalizedStringLiterals, boolean assertMode,
+ boolean tokenizeStrings, char[][] taskTags,
+ char[][] taskPriorities, boolean isTaskCaseSensitive) {
this.eofPosition = Integer.MAX_VALUE;
this.tokenizeComments = tokenizeComments;
this.tokenizeWhiteSpace = tokenizeWhiteSpace;
this.tokenizeStrings = tokenizeStrings;
this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
-// this.assertMode = assertMode;
+ // this.assertMode = assertMode;
// this.encapsedStringStack = null;
this.taskTags = taskTags;
this.taskPriorities = taskPriorities;
}
this.wasNonExternalizedStringLiteral = true;
if (nonNLSCounter != lineLength) {
- System.arraycopy(this.nonNLSStrings, 0, (this.nonNLSStrings = new StringLiteral[nonNLSCounter]), 0, nonNLSCounter);
+ System.arraycopy(this.nonNLSStrings, 0,
+ (this.nonNLSStrings = new StringLiteral[nonNLSCounter]), 0,
+ nonNLSCounter);
}
currentLine = null;
}
int number = Character.getNumericValue(currentCharacter);
if (number >= 0 && number <= 7) {
boolean zeroToThreeNot = number > 3;
- if (Character.isDigit(currentCharacter = source[currentPosition++])) {
+ if (Character
+ .isDigit(currentCharacter = source[currentPosition++])) {
int digit = Character.getNumericValue(currentCharacter);
if (digit >= 0 && digit <= 7) {
number = (number * 8) + digit;
- if (Character.isDigit(currentCharacter = source[currentPosition++])) {
- if (zeroToThreeNot) { // has read \NotZeroToThree OctalDigit
+ if (Character
+ .isDigit(currentCharacter = source[currentPosition++])) {
+ if (zeroToThreeNot) { // has read \NotZeroToThree
+ // OctalDigit
// Digit --> ignore last character
currentPosition--;
} else {
- digit = Character.getNumericValue(currentCharacter);
- if (digit >= 0 && digit <= 7) { // has read \ZeroToThree
+ digit = Character
+ .getNumericValue(currentCharacter);
+ if (digit >= 0 && digit <= 7) { // has read
+ // \ZeroToThree
// OctalDigit OctalDigit
number = (number * 8) + digit;
- } else { // has read \ZeroToThree OctalDigit NonOctalDigit
+ } else { // has read \ZeroToThree OctalDigit
+ // NonOctalDigit
// --> ignore last character
currentPosition--;
}
}
- } else { // has read \OctalDigit NonDigit--> ignore last
+ } else { // has read \OctalDigit NonDigit--> ignore
+ // last
// character
currentPosition--;
}
- } else { // has read \OctalDigit NonOctalDigit--> ignore last
+ } else { // has read \OctalDigit NonOctalDigit--> ignore
+ // last
// character
currentPosition--;
}
char[] src = this.source;
// only look for newer task: tags
- if (this.foundTaskCount > 0 && this.foundTaskPositions[this.foundTaskCount - 1][0] >= commentStart) {
+ if (this.foundTaskCount > 0
+ && this.foundTaskPositions[this.foundTaskCount - 1][0] >= commentStart) {
return;
}
int foundTaskIndex = this.foundTaskCount;
char previous = src[commentStart + 1]; // should be '*' or '/'
- nextChar: for (int i = commentStart + 2; i < commentEnd && i < this.eofPosition; i++) {
+ nextChar: for (int i = commentStart + 2; i < commentEnd
+ && i < this.eofPosition; i++) {
char[] tag = null;
char[] priority = null;
// check for tag occurrence only if not ambiguous with javadoc tag
if (tagLength == 0)
continue nextTag;
- // ensure tag is not leaded with letter if tag starts with a letter
+ // ensure tag is not leaded with letter if tag starts with a
+ // letter
if (Scanner.isPHPIdentifierStart(tag[0])) {
if (Scanner.isPHPIdentifierPart(previous)) {
continue nextTag;
int x = i + t;
if (x >= this.eofPosition || x >= commentEnd)
continue nextTag;
- if ((sc = src[i + t]) != (tc = tag[t])) { // case sensitive check
- if (this.isTaskCaseSensitive || (Character.toLowerCase(sc) != Character.toLowerCase(tc))) { // case
- // insensitive
- // check
+ if ((sc = src[i + t]) != (tc = tag[t])) { // case
+ // sensitive
+ // check
+ if (this.isTaskCaseSensitive
+ || (Character.toLowerCase(sc) != Character
+ .toLowerCase(tc))) { // case
+ // insensitive
+ // check
continue nextTag;
}
}
}
- // ensure tag is not followed with letter if tag finishes with a
+ // ensure tag is not followed with letter if tag finishes
+ // with a
// letter
- if (i + tagLength < commentEnd && Scanner.isPHPIdentifierPart(src[i + tagLength - 1])) {
+ if (i + tagLength < commentEnd
+ && Scanner.isPHPIdentifierPart(src[i + tagLength
+ - 1])) {
if (Scanner.isPHPIdentifierPart(src[i + tagLength]))
continue nextTag;
}
this.foundTaskPriorities = new char[5][];
this.foundTaskPositions = new int[5][];
} else if (this.foundTaskCount == this.foundTaskTags.length) {
- System.arraycopy(this.foundTaskTags, 0, this.foundTaskTags = new char[this.foundTaskCount * 2][], 0,
- this.foundTaskCount);
- System.arraycopy(this.foundTaskMessages, 0, this.foundTaskMessages = new char[this.foundTaskCount * 2][], 0,
- this.foundTaskCount);
- System.arraycopy(this.foundTaskPriorities, 0, this.foundTaskPriorities = new char[this.foundTaskCount * 2][], 0,
- this.foundTaskCount);
- System.arraycopy(this.foundTaskPositions, 0, this.foundTaskPositions = new int[this.foundTaskCount * 2][], 0,
- this.foundTaskCount);
+ System
+ .arraycopy(
+ this.foundTaskTags,
+ 0,
+ this.foundTaskTags = new char[this.foundTaskCount * 2][],
+ 0, this.foundTaskCount);
+ System
+ .arraycopy(
+ this.foundTaskMessages,
+ 0,
+ this.foundTaskMessages = new char[this.foundTaskCount * 2][],
+ 0, this.foundTaskCount);
+ System
+ .arraycopy(
+ this.foundTaskPriorities,
+ 0,
+ this.foundTaskPriorities = new char[this.foundTaskCount * 2][],
+ 0, this.foundTaskCount);
+ System
+ .arraycopy(
+ this.foundTaskPositions,
+ 0,
+ this.foundTaskPositions = new int[this.foundTaskCount * 2][],
+ 0, this.foundTaskCount);
}
- priority = this.taskPriorities != null && itag < this.taskPriorities.length ? this.taskPriorities[itag] : null;
+ priority = this.taskPriorities != null
+ && itag < this.taskPriorities.length ? this.taskPriorities[itag]
+ : null;
this.foundTaskTags[this.foundTaskCount] = tag;
this.foundTaskPriorities[this.foundTaskCount] = priority;
- this.foundTaskPositions[this.foundTaskCount] = new int[] { i, i + tagLength - 1 };
+ this.foundTaskPositions[this.foundTaskCount] = new int[] {
+ i, i + tagLength - 1 };
this.foundTaskMessages[this.foundTaskCount] = CharOperation.NO_CHAR;
this.foundTaskCount++;
i += tagLength - 1; // will be incremented when looping
}
for (int i = foundTaskIndex; i < this.foundTaskCount; i++) {
// retrieve message start and end positions
- int msgStart = this.foundTaskPositions[i][0] + this.foundTaskTags[i].length;
- int max_value = i + 1 < this.foundTaskCount ? this.foundTaskPositions[i + 1][0] - 1 : commentEnd - 1;
+ int msgStart = this.foundTaskPositions[i][0]
+ + this.foundTaskTags[i].length;
+ int max_value = i + 1 < this.foundTaskCount ? this.foundTaskPositions[i + 1][0] - 1
+ : commentEnd - 1;
// at most beginning of next task
if (max_value < msgStart) {
- max_value = msgStart; // would only occur if tag is before EOF.
+ max_value = msgStart; // would only occur if tag is before
+ // EOF.
}
int end = -1;
char c;
// chech presence of task: tags
// public void checkTaskTag(int commentStart, int commentEnd) {
// // only look for newer task: tags
- // if (this.foundTaskCount > 0 && this.foundTaskPositions[this.foundTaskCount
+ // if (this.foundTaskCount > 0 &&
+ // this.foundTaskPositions[this.foundTaskCount
// - 1][0] >= commentStart) {
// return;
// }
// // check for tag occurrence
// nextTag: for (int itag = 0; itag < this.taskTags.length; itag++) {
// tag = this.taskTags[itag];
- // priority = this.taskPriorities != null && itag < this.taskPriorities.length
+ // priority = this.taskPriorities != null && itag <
+ // this.taskPriorities.length
// ? this.taskPriorities[itag] : null;
// int tagLength = tag.length;
// for (int t = 0; t < tagLength; t++) {
// System.arraycopy(this.foundTaskPriorities, 0, this.foundTaskPriorities =
// new char[this.foundTaskCount * 2][], 0,
// this.foundTaskCount);
- // System.arraycopy(this.foundTaskPositions, 0, this.foundTaskPositions = new
+ // System.arraycopy(this.foundTaskPositions, 0, this.foundTaskPositions =
+ // new
// int[this.foundTaskCount * 2][], 0,
// this.foundTaskCount);
// }
// this.foundTaskTags[this.foundTaskCount] = tag;
// this.foundTaskPriorities[this.foundTaskCount] = priority;
- // this.foundTaskPositions[this.foundTaskCount] = new int[] { i, i + tagLength
+ // this.foundTaskPositions[this.foundTaskCount] = new int[] { i, i +
+ // tagLength
// - 1 };
// this.foundTaskMessages[this.foundTaskCount] = CharOperation.NO_CHAR;
// this.foundTaskCount++;
// this.foundTaskMessages[i] = message;
// }
// }
-}
\ No newline at end of file
+}
+