return TokenName.LPAREN;
}
+ /**
+ *
+ *
+ */
public void consumeStringInterpolated() throws InvalidInputException {
try {
// consume next character
}
}
+ /**
+ *
+ *
+ */
public void consumeStringLiteral() throws InvalidInputException {
try {
int openDollarBrace = 0;
- // consume next character
- unicodeAsBackSlash = false;
- currentCharacter = source[currentPosition++];
- while (currentCharacter != '"' || openDollarBrace > 0) {
- /** ** in PHP \r and \n are valid in string literals *** */
+
+ 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
+
+ // 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....
- withoutUnicodePtr = currentPosition - escapeSize - 1
- - startPosition;
- System.arraycopy(source, startPosition,
- withoutUnicodeBuffer, 1, withoutUnicodePtr);
+
+ 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
+ }
+ 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] == '{') {
+ }
+ else if (currentCharacter == '$' && source[currentPosition] == '{') { // If found '${'
openDollarBrace++;
- } else if (currentCharacter == '{'
- && source[currentPosition] == '$') {
+ 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 == '}') {
+ }
+ else if (currentCharacter == '}') { // If found '}'
openDollarBrace--;
- } else if ((currentCharacter == '\r')
- || (currentCharacter == '\n')) {
+ }
+ 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.
+
+ if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags
+ // $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 TokenName getNextToken() throws InvalidInputException {
if (!phpMode) {
return getInlinedHTMLToken(currentPosition);
while ((currentCharacter == ' ') || Character.isWhitespace(currentCharacter)) {
if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
checkNonExternalizeString();
-
+
if (recordLineSeparator) {
pushLineSeparator();
} else {
startPosition = currentPosition;
currentCharacter = source[currentPosition++];
}
-
+
if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
// reposition scanner in case we are interested by
// spaces as tokens
if (getNextChar('='))
return TokenName.REMAINDER_EQUAL;
return TokenName.REMAINDER;
+
case '<': {
int oldPosition = currentPosition;
+
try {
currentCharacter = source[currentPosition++];
} catch (IndexOutOfBoundsException e) {
currentPosition = oldPosition;
return TokenName.LESS;
}
+
switch (currentCharacter) {
- case '=':
- return TokenName.LESS_EQUAL;
- case '>':
- return TokenName.NOT_EQUAL;
- case '<':
- if (getNextChar('='))
- return TokenName.LEFT_SHIFT_EQUAL;
- if (getNextChar('<')) {
- currentCharacter = source[currentPosition++];
- while (Character.isWhitespace(currentCharacter)) {
- currentCharacter = source[currentPosition++];
+ case '=':
+ return TokenName.LESS_EQUAL;
+
+ case '>':
+ return TokenName.NOT_EQUAL;
+
+ case '<':
+ if (getNextChar ('=')) {
+ return TokenName.LEFT_SHIFT_EQUAL;
}
- int heredocStart = currentPosition - 1;
- int heredocLength = 0;
- if (isPHPIdentifierStart(currentCharacter)) {
+
+ if (getNextChar('<')) {
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;
+
+ 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 TokenName.HEREDOC;
+ } while (true);
+
+ return TokenName.HEREDOC;
+ }
+ return TokenName.LEFT_SHIFT;
}
- return TokenName.LEFT_SHIFT;
+ currentPosition = oldPosition;
+ return TokenName.LESS;
}
- currentPosition = oldPosition;
- return TokenName.LESS;
- }
+
case '>': {
int test;
if ((test = getNextChar('=', '>')) == 0)
}
return getInlinedHTMLToken(currentPosition - 2);
}
+ else if (getNextChar(':')) {
+ return TokenName.TERNARY_SHORT;
+ }
+
return TokenName.QUESTION;
+
case ':':
if (getNextChar(':'))
return TokenName.PAAMAYIM_NEKUDOTAYIM;
}
// ---------other side---------
i = -1;
+
int max = newEntry4;
while (++i <= max) {
char[] charArray = table[i];
// }
// }
}
+