X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java index ae73d5f..20039eb 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java @@ -1107,6 +1107,10 @@ public class Scanner implements IScanner, ITerminalSymbols { return TokenName.LPAREN; } + /** + * + * + */ public void consumeStringInterpolated() throws InvalidInputException { try { // consume next character @@ -1323,54 +1327,60 @@ public class Scanner implements IScanner, ITerminalSymbols { } } + /** + * + * + */ 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; } @@ -1396,19 +1406,20 @@ public class Scanner implements IScanner, ITerminalSymbols { } 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); @@ -1439,7 +1450,7 @@ public class Scanner implements IScanner, ITerminalSymbols { while ((currentCharacter == ' ') || Character.isWhitespace(currentCharacter)) { if ((currentCharacter == '\r') || (currentCharacter == '\n')) { checkNonExternalizeString(); - + if (recordLineSeparator) { pushLineSeparator(); } else { @@ -1449,7 +1460,7 @@ public class Scanner implements IScanner, ITerminalSymbols { startPosition = currentPosition; currentCharacter = source[currentPosition++]; } - + if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) { // reposition scanner in case we are interested by // spaces as tokens @@ -1642,7 +1653,12 @@ public class Scanner implements IScanner, ITerminalSymbols { } return getInlinedHTMLToken(currentPosition - 2); } + else if (getNextChar(':')) { + return TokenName.TERNARY_SHORT; + } + return TokenName.QUESTION; + case ':': if (getNextChar(':')) return TokenName.PAAMAYIM_NEKUDOTAYIM; @@ -2788,6 +2804,7 @@ public class Scanner implements IScanner, ITerminalSymbols { } // ---------other side--------- i = -1; + int max = newEntry4; while (++i <= max) { char[] charArray = table[i]; @@ -4721,3 +4738,4 @@ public class Scanner implements IScanner, ITerminalSymbols { // } // } } +