expr();
if (token == TokenNameSEMICOLON) {
getNextToken();
- }
+ }
if (token != TokenNameINLINE_HTML) {
throwSyntaxError("Missing '?>' for open PHP expression block ('<?=').");
}
// | '`' encaps_list '`'
// | common_scalar
// | '`' encaps_list '`'
- case TokenNameEncapsedString0:
- scanner.encapsedStringStack.push(new Character('`'));
- getNextToken();
- try {
- if (token == TokenNameEncapsedString0) {
- } else {
- encaps_list();
- if (token != TokenNameEncapsedString0) {
- throwSyntaxError("\'`\' expected at end of string" + "(Found token: " + scanner.toStringAction(token) + " )");
- }
- }
- } finally {
- scanner.encapsedStringStack.pop();
- getNextToken();
- }
- break;
- // | '\'' encaps_list '\''
- case TokenNameEncapsedString1:
- scanner.encapsedStringStack.push(new Character('\''));
- getNextToken();
- try {
- exprSourceStart = scanner.getCurrentTokenStartPosition();
- if (token == TokenNameEncapsedString1) {
- expression = new StringLiteralSQ(scanner.getCurrentStringLiteralSource(exprSourceStart), exprSourceStart, scanner
- .getCurrentTokenEndPosition());
- } else {
- encaps_list();
- if (token != TokenNameEncapsedString1) {
- throwSyntaxError("\'\'\' expected at end of string" + "(Found token: " + scanner.toStringAction(token) + " )");
- } else {
- expression = new StringLiteralSQ(scanner.getCurrentStringLiteralSource(exprSourceStart), exprSourceStart, scanner
- .getCurrentTokenEndPosition());
- }
- }
- } finally {
- scanner.encapsedStringStack.pop();
- getNextToken();
- }
- break;
- //| '"' encaps_list '"'
- case TokenNameEncapsedString2:
- scanner.encapsedStringStack.push(new Character('"'));
- getNextToken();
- try {
- exprSourceStart = scanner.getCurrentTokenStartPosition();
- if (token == TokenNameEncapsedString2) {
- expression = new StringLiteralDQ(scanner.getCurrentStringLiteralSource(exprSourceStart), exprSourceStart, scanner
- .getCurrentTokenEndPosition());
- } else {
- encaps_list();
- if (token != TokenNameEncapsedString2) {
- throwSyntaxError("'\"' expected at end of string" + "(Found token: " + scanner.toStringAction(token) + " )");
- } else {
- expression = new StringLiteralDQ(scanner.getCurrentStringLiteralSource(exprSourceStart), exprSourceStart, scanner
- .getCurrentTokenEndPosition());
- }
- }
- } finally {
- scanner.encapsedStringStack.pop();
- getNextToken();
- }
- break;
+ // case TokenNameEncapsedString0:
+ // scanner.encapsedStringStack.push(new Character('`'));
+ // getNextToken();
+ // try {
+ // if (token == TokenNameEncapsedString0) {
+ // } else {
+ // encaps_list();
+ // if (token != TokenNameEncapsedString0) {
+ // throwSyntaxError("\'`\' expected at end of string" + "(Found token: " + scanner.toStringAction(token) + " )");
+ // }
+ // }
+ // } finally {
+ // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // }
+ // break;
+ // // | '\'' encaps_list '\''
+ // case TokenNameEncapsedString1:
+ // scanner.encapsedStringStack.push(new Character('\''));
+ // getNextToken();
+ // try {
+ // exprSourceStart = scanner.getCurrentTokenStartPosition();
+ // if (token == TokenNameEncapsedString1) {
+ // expression = new StringLiteralSQ(scanner.getCurrentStringLiteralSource(exprSourceStart), exprSourceStart, scanner
+ // .getCurrentTokenEndPosition());
+ // } else {
+ // encaps_list();
+ // if (token != TokenNameEncapsedString1) {
+ // throwSyntaxError("\'\'\' expected at end of string" + "(Found token: " + scanner.toStringAction(token) + " )");
+ // } else {
+ // expression = new StringLiteralSQ(scanner.getCurrentStringLiteralSource(exprSourceStart), exprSourceStart, scanner
+ // .getCurrentTokenEndPosition());
+ // }
+ // }
+ // } finally {
+ // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // }
+ // break;
+ // //| '"' encaps_list '"'
+ // case TokenNameEncapsedString2:
+ // scanner.encapsedStringStack.push(new Character('"'));
+ // getNextToken();
+ // try {
+ // exprSourceStart = scanner.getCurrentTokenStartPosition();
+ // if (token == TokenNameEncapsedString2) {
+ // expression = new StringLiteralDQ(scanner.getCurrentStringLiteralSource(exprSourceStart), exprSourceStart, scanner
+ // .getCurrentTokenEndPosition());
+ // } else {
+ // encaps_list();
+ // if (token != TokenNameEncapsedString2) {
+ // throwSyntaxError("'\"' expected at end of string" + "(Found token: " + scanner.toStringAction(token) + " )");
+ // } else {
+ // expression = new StringLiteralDQ(scanner.getCurrentStringLiteralSource(exprSourceStart), exprSourceStart, scanner
+ // .getCurrentTokenEndPosition());
+ // }
+ // }
+ // } finally {
+ // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // }
+ // break;
case TokenNameStringDoubleQuote:
expression = new StringLiteralDQ(scanner.getCurrentStringLiteralSource(), scanner.getCurrentTokenStartPosition(), scanner
.getCurrentTokenEndPosition());
getNextToken();
}
- private void encaps_list() {
- // encaps_list encaps_var
- // | encaps_list T_STRING
- // | encaps_list T_NUM_STRING
- // | encaps_list T_ENCAPSED_AND_WHITESPACE
- // | encaps_list T_CHARACTER
- // | encaps_list T_BAD_CHARACTER
- // | encaps_list '['
- // | encaps_list ']'
- // | encaps_list '{'
- // | encaps_list '}'
- // | encaps_list T_OBJECT_OPERATOR
- // | /* empty */
- while (true) {
- switch (token) {
- case TokenNameSTRING:
- getNextToken();
- break;
- case TokenNameLBRACE:
- // scanner.encapsedStringStack.pop();
- getNextToken();
- break;
- case TokenNameRBRACE:
- // scanner.encapsedStringStack.pop();
- getNextToken();
- break;
- case TokenNameLBRACKET:
- // scanner.encapsedStringStack.pop();
- getNextToken();
- break;
- case TokenNameRBRACKET:
- // scanner.encapsedStringStack.pop();
- getNextToken();
- break;
- case TokenNameMINUS_GREATER:
- // scanner.encapsedStringStack.pop();
- getNextToken();
- break;
- case TokenNameVariable:
- case TokenNameDOLLAR_LBRACE:
- case TokenNameLBRACE_DOLLAR:
- encaps_var();
- break;
- default:
- char encapsedChar = ((Character) scanner.encapsedStringStack.peek()).charValue();
- if (encapsedChar == '$') {
- scanner.encapsedStringStack.pop();
- encapsedChar = ((Character) scanner.encapsedStringStack.peek()).charValue();
- switch (encapsedChar) {
- case '`':
- if (token == TokenNameEncapsedString0) {
- return;
- }
- token = TokenNameSTRING;
- continue;
- case '\'':
- if (token == TokenNameEncapsedString1) {
- return;
- }
- token = TokenNameSTRING;
- continue;
- case '"':
- if (token == TokenNameEncapsedString2) {
- return;
- }
- token = TokenNameSTRING;
- continue;
- }
- }
- return;
- }
- }
- }
+ // private void encaps_list() {
+ // // encaps_list encaps_var
+ // // | encaps_list T_STRING
+ // // | encaps_list T_NUM_STRING
+ // // | encaps_list T_ENCAPSED_AND_WHITESPACE
+ // // | encaps_list T_CHARACTER
+ // // | encaps_list T_BAD_CHARACTER
+ // // | encaps_list '['
+ // // | encaps_list ']'
+ // // | encaps_list '{'
+ // // | encaps_list '}'
+ // // | encaps_list T_OBJECT_OPERATOR
+ // // | /* empty */
+ // while (true) {
+ // switch (token) {
+ // case TokenNameSTRING:
+ // getNextToken();
+ // break;
+ // case TokenNameLBRACE:
+ // // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // break;
+ // case TokenNameRBRACE:
+ // // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // break;
+ // case TokenNameLBRACKET:
+ // // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // break;
+ // case TokenNameRBRACKET:
+ // // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // break;
+ // case TokenNameMINUS_GREATER:
+ // // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // break;
+ // case TokenNameVariable:
+ // case TokenNameDOLLAR_LBRACE:
+ // case TokenNameLBRACE_DOLLAR:
+ // encaps_var();
+ // break;
+ // default:
+ // char encapsedChar = ((Character) scanner.encapsedStringStack.peek()).charValue();
+ // if (encapsedChar == '$') {
+ // scanner.encapsedStringStack.pop();
+ // encapsedChar = ((Character) scanner.encapsedStringStack.peek()).charValue();
+ // switch (encapsedChar) {
+ // case '`':
+ // if (token == TokenNameEncapsedString0) {
+ // return;
+ // }
+ // token = TokenNameSTRING;
+ // continue;
+ // case '\'':
+ // if (token == TokenNameEncapsedString1) {
+ // return;
+ // }
+ // token = TokenNameSTRING;
+ // continue;
+ // case '"':
+ // if (token == TokenNameEncapsedString2) {
+ // return;
+ // }
+ // token = TokenNameSTRING;
+ // continue;
+ // }
+ // }
+ // return;
+ // }
+ // }
+ // }
- private void encaps_var() {
- // T_VARIABLE
- // | T_VARIABLE '[' encaps_var_offset ']'
- // | T_VARIABLE T_OBJECT_OPERATOR T_STRING
- // | T_DOLLAR_OPEN_CURLY_BRACES expr '}'
- // | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
- // | T_CURLY_OPEN variable '}'
- switch (token) {
- case TokenNameVariable:
- getNextToken();
- if (token == TokenNameLBRACKET) {
- getNextToken();
- expr(); //encaps_var_offset();
- if (token != TokenNameRBRACKET) {
- throwSyntaxError("']' expected after variable.");
- }
- // scanner.encapsedStringStack.pop();
- getNextToken();
- // }
- } else if (token == TokenNameMINUS_GREATER) {
- getNextToken();
- if (token != TokenNameIdentifier) {
- throwSyntaxError("Identifier expected after '->'.");
- }
- // scanner.encapsedStringStack.pop();
- getNextToken();
- }
- // else {
- // // scanner.encapsedStringStack.pop();
- // int tempToken = TokenNameSTRING;
- // if (!scanner.encapsedStringStack.isEmpty()
- // && (token == TokenNameEncapsedString0
- // || token == TokenNameEncapsedString1
- // || token == TokenNameEncapsedString2 || token ==
- // TokenNameERROR)) {
- // char encapsedChar = ((Character)
- // scanner.encapsedStringStack.peek())
- // .charValue();
- // switch (token) {
- // case TokenNameEncapsedString0 :
- // if (encapsedChar == '`') {
- // tempToken = TokenNameEncapsedString0;
- // }
- // break;
- // case TokenNameEncapsedString1 :
- // if (encapsedChar == '\'') {
- // tempToken = TokenNameEncapsedString1;
- // }
- // break;
- // case TokenNameEncapsedString2 :
- // if (encapsedChar == '"') {
- // tempToken = TokenNameEncapsedString2;
- // }
- // break;
- // case TokenNameERROR :
- // if (scanner.source[scanner.currentPosition - 1] == '\\') {
- // scanner.currentPosition--;
- // getNextToken();
- // }
- // break;
- // }
- // }
- // token = tempToken;
- // }
- break;
- case TokenNameDOLLAR_LBRACE:
- getNextToken();
- if (token == TokenNameDOLLAR_LBRACE) {
- encaps_var();
- } else if (token == TokenNameIdentifier) {
- getNextToken();
- if (token == TokenNameLBRACKET) {
- getNextToken();
- // if (token == TokenNameRBRACKET) {
- // getNextToken();
- // } else {
- expr();
- if (token != TokenNameRBRACKET) {
- throwSyntaxError("']' expected after '${'.");
- }
- getNextToken();
- // }
- }
- } else {
- expr();
- }
- if (token != TokenNameRBRACE) {
- throwSyntaxError("'}' expected.");
- }
- getNextToken();
- break;
- case TokenNameLBRACE_DOLLAR:
- getNextToken();
- if (token == TokenNameLBRACE_DOLLAR) {
- encaps_var();
- } else if (token == TokenNameIdentifier || token > TokenNameKEYWORD) {
- getNextToken();
- if (token == TokenNameLBRACKET) {
- getNextToken();
- // if (token == TokenNameRBRACKET) {
- // getNextToken();
- // } else {
- expr();
- if (token != TokenNameRBRACKET) {
- throwSyntaxError("']' expected.");
- }
- getNextToken();
- // }
- } else if (token == TokenNameMINUS_GREATER) {
- getNextToken();
- if (token != TokenNameIdentifier && token != TokenNameVariable) {
- throwSyntaxError("String or Variable token expected.");
- }
- getNextToken();
- if (token == TokenNameLBRACKET) {
- getNextToken();
- // if (token == TokenNameRBRACKET) {
- // getNextToken();
- // } else {
- expr();
- if (token != TokenNameRBRACKET) {
- throwSyntaxError("']' expected after '${'.");
- }
- getNextToken();
- // }
- }
- }
- // if (token != TokenNameRBRACE) {
- // throwSyntaxError("'}' expected after '{$'.");
- // }
- // // scanner.encapsedStringStack.pop();
- // getNextToken();
- } else {
- expr();
- if (token != TokenNameRBRACE) {
- throwSyntaxError("'}' expected.");
- }
- // scanner.encapsedStringStack.pop();
- getNextToken();
- }
- break;
- }
- }
+ // private void encaps_var() {
+ // // T_VARIABLE
+ // // | T_VARIABLE '[' encaps_var_offset ']'
+ // // | T_VARIABLE T_OBJECT_OPERATOR T_STRING
+ // // | T_DOLLAR_OPEN_CURLY_BRACES expr '}'
+ // // | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
+ // // | T_CURLY_OPEN variable '}'
+ // switch (token) {
+ // case TokenNameVariable:
+ // getNextToken();
+ // if (token == TokenNameLBRACKET) {
+ // getNextToken();
+ // expr(); //encaps_var_offset();
+ // if (token != TokenNameRBRACKET) {
+ // throwSyntaxError("']' expected after variable.");
+ // }
+ // // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // // }
+ // } else if (token == TokenNameMINUS_GREATER) {
+ // getNextToken();
+ // if (token != TokenNameIdentifier) {
+ // throwSyntaxError("Identifier expected after '->'.");
+ // }
+ // // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // }
+ // // else {
+ // // // scanner.encapsedStringStack.pop();
+ // // int tempToken = TokenNameSTRING;
+ // // if (!scanner.encapsedStringStack.isEmpty()
+ // // && (token == TokenNameEncapsedString0
+ // // || token == TokenNameEncapsedString1
+ // // || token == TokenNameEncapsedString2 || token ==
+ // // TokenNameERROR)) {
+ // // char encapsedChar = ((Character)
+ // // scanner.encapsedStringStack.peek())
+ // // .charValue();
+ // // switch (token) {
+ // // case TokenNameEncapsedString0 :
+ // // if (encapsedChar == '`') {
+ // // tempToken = TokenNameEncapsedString0;
+ // // }
+ // // break;
+ // // case TokenNameEncapsedString1 :
+ // // if (encapsedChar == '\'') {
+ // // tempToken = TokenNameEncapsedString1;
+ // // }
+ // // break;
+ // // case TokenNameEncapsedString2 :
+ // // if (encapsedChar == '"') {
+ // // tempToken = TokenNameEncapsedString2;
+ // // }
+ // // break;
+ // // case TokenNameERROR :
+ // // if (scanner.source[scanner.currentPosition - 1] == '\\') {
+ // // scanner.currentPosition--;
+ // // getNextToken();
+ // // }
+ // // break;
+ // // }
+ // // }
+ // // token = tempToken;
+ // // }
+ // break;
+ // case TokenNameDOLLAR_LBRACE:
+ // getNextToken();
+ // if (token == TokenNameDOLLAR_LBRACE) {
+ // encaps_var();
+ // } else if (token == TokenNameIdentifier) {
+ // getNextToken();
+ // if (token == TokenNameLBRACKET) {
+ // getNextToken();
+ // // if (token == TokenNameRBRACKET) {
+ // // getNextToken();
+ // // } else {
+ // expr();
+ // if (token != TokenNameRBRACKET) {
+ // throwSyntaxError("']' expected after '${'.");
+ // }
+ // getNextToken();
+ // // }
+ // }
+ // } else {
+ // expr();
+ // }
+ // if (token != TokenNameRBRACE) {
+ // throwSyntaxError("'}' expected.");
+ // }
+ // getNextToken();
+ // break;
+ // case TokenNameLBRACE_DOLLAR:
+ // getNextToken();
+ // if (token == TokenNameLBRACE_DOLLAR) {
+ // encaps_var();
+ // } else if (token == TokenNameIdentifier || token > TokenNameKEYWORD) {
+ // getNextToken();
+ // if (token == TokenNameLBRACKET) {
+ // getNextToken();
+ // // if (token == TokenNameRBRACKET) {
+ // // getNextToken();
+ // // } else {
+ // expr();
+ // if (token != TokenNameRBRACKET) {
+ // throwSyntaxError("']' expected.");
+ // }
+ // getNextToken();
+ // // }
+ // } else if (token == TokenNameMINUS_GREATER) {
+ // getNextToken();
+ // if (token != TokenNameIdentifier && token != TokenNameVariable) {
+ // throwSyntaxError("String or Variable token expected.");
+ // }
+ // getNextToken();
+ // if (token == TokenNameLBRACKET) {
+ // getNextToken();
+ // // if (token == TokenNameRBRACKET) {
+ // // getNextToken();
+ // // } else {
+ // expr();
+ // if (token != TokenNameRBRACKET) {
+ // throwSyntaxError("']' expected after '${'.");
+ // }
+ // getNextToken();
+ // // }
+ // }
+ // }
+ // // if (token != TokenNameRBRACE) {
+ // // throwSyntaxError("'}' expected after '{$'.");
+ // // }
+ // // // scanner.encapsedStringStack.pop();
+ // // getNextToken();
+ // } else {
+ // expr();
+ // if (token != TokenNameRBRACE) {
+ // throwSyntaxError("'}' expected.");
+ // }
+ // // scanner.encapsedStringStack.pop();
+ // getNextToken();
+ // }
+ // break;
+ // }
+ // }
private void encaps_var_offset() {
// T_STRING
throwSyntaxError("'`' expected at end of static string.");
}
break;
- case TokenNameEncapsedString1:
- try {
- scanner.currentCharacter = scanner.source[scanner.currentPosition++];
- while (scanner.currentCharacter != '\'') {
- if (scanner.currentCharacter == '\\') {
- scanner.currentPosition++;
- }
- scanner.currentCharacter = scanner.source[scanner.currentPosition++];
- }
- getNextToken();
- } catch (IndexOutOfBoundsException e) {
- throwSyntaxError("'\'' expected at end of static string.");
- }
+ // case TokenNameEncapsedString1:
+ // try {
+ // scanner.currentCharacter = scanner.source[scanner.currentPosition++];
+ // while (scanner.currentCharacter != '\'') {
+ // if (scanner.currentCharacter == '\\') {
+ // scanner.currentPosition++;
+ // }
+ // scanner.currentCharacter = scanner.source[scanner.currentPosition++];
+ // }
+ // getNextToken();
+ // } catch (IndexOutOfBoundsException e) {
+ // throwSyntaxError("'\'' expected at end of static string.");
+ // }
+ // break;
+ // case TokenNameEncapsedString2:
+ // try {
+ // scanner.currentCharacter = scanner.source[scanner.currentPosition++];
+ // while (scanner.currentCharacter != '"') {
+ // if (scanner.currentCharacter == '\\') {
+ // scanner.currentPosition++;
+ // }
+ // scanner.currentCharacter = scanner.source[scanner.currentPosition++];
+ // }
+ // getNextToken();
+ // } catch (IndexOutOfBoundsException e) {
+ // throwSyntaxError("'\"' expected at end of static string.");
+ // }
+ // break;
+ case TokenNameStringSingleQuote:
+ getNextToken();
break;
- case TokenNameEncapsedString2:
- try {
- scanner.currentCharacter = scanner.source[scanner.currentPosition++];
- while (scanner.currentCharacter != '"') {
- if (scanner.currentCharacter == '\\') {
- scanner.currentPosition++;
- }
- scanner.currentCharacter = scanner.source[scanner.currentPosition++];
- }
- getNextToken();
- } catch (IndexOutOfBoundsException e) {
- throwSyntaxError("'\"' expected at end of static string.");
- }
+ case TokenNameStringDoubleQuote:
+ getNextToken();
break;
case TokenNamePLUS:
getNextToken();
public boolean ignorePHPOneLiner = false;
public boolean phpMode = false;
-
+
public boolean phpExpressionTag = false;
-
- public Stack encapsedStringStack = null;
+
+// public Stack encapsedStringStack = null;
public char currentCharacter;
public void consumeStringLiteral() throws InvalidInputException {
try {
+ boolean openDollarBrace = false;
// consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
- // && (source[currentPosition] == 'u')) {
- // getNextUnicodeChar();
- // } else {
- // if (withoutUnicodePtr != 0) {
- // withoutUnicodeBuffer[++withoutUnicodePtr] =
- // currentCharacter;
- // }
- // }
- while (currentCharacter != '"') {
+ while (currentCharacter != '"' || openDollarBrace) {
/** ** in PHP \r and \n are valid in string literals *** */
- // if ((currentCharacter == '\n')
- // || (currentCharacter == '\r')) {
- // // 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)
- // break;
- // if (source[currentPosition + lookAhead] == '\n')
- // break;
- // if (source[currentPosition + lookAhead] == '\"') {
- // currentPosition += lookAhead + 1;
- // break;
- // }
- // }
- // throw new InvalidInputException(INVALID_CHAR_IN_STRING);
- // }
if (currentCharacter == '\\') {
int escapeSize = currentPosition;
boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
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')) {
if (recordLineSeparator) {
pushLineSeparator();
// consume next character
unicodeAsBackSlash = false;
currentCharacter = source[currentPosition++];
- // if (((currentCharacter = source[currentPosition++]) == '\\')
- // && (source[currentPosition] == 'u')) {
- // getNextUnicodeChar();
- // } else {
if (withoutUnicodePtr != 0) {
withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
}
- // }
}
} catch (IndexOutOfBoundsException e) {
// reset end position for error reporting
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;
- }
+ // 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---------
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;
- }
- }
+ // 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)) {
consumeStringConstant();
return TokenNameStringSingleQuote;
case '"':
- if (tokenizeStrings) {
+// if (tokenizeStrings) {
consumeStringLiteral();
return TokenNameStringDoubleQuote;
- }
- return TokenNameEncapsedString2;
+// }
+// return TokenNameEncapsedString2;
case '`':
- if (tokenizeStrings) {
+// if (tokenizeStrings) {
consumeStringInterpolated();
return TokenNameStringInterpolated;
- }
- return TokenNameEncapsedString0;
+// }
+// return TokenNameEncapsedString0;
case '#':
case '/': {
char startChar = currentCharacter;
if (currentCharacter != '=') { // <?=
currentPosition--;
} else {
- phpExpressionTag = true;
+ phpExpressionTag = true;
}
// <?
if (ignorePHPOneLiner) { // for CodeFormatter
}
public final void scanDoubleQuotedEscapeCharacter() 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) {
- // // consume next character
- // unicodeAsBackSlash = false;
- // if (((currentCharacter = source[currentPosition++]) == '\\')
- // && (source[currentPosition] == 'u')) {
- // getNextUnicodeChar();
- // } else {
- // if (withoutUnicodePtr != 0) {
- // withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
- // }
- // }
- // } else
currentCharacter = source[currentPosition++];
switch (currentCharacter) {
// case 'b' :
initialPosition = currentPosition = 0;
containsAssertKeyword = false;
withoutUnicodeBuffer = new char[this.source.length];
- encapsedStringStack = new Stack();
+// encapsedStringStack = new Stack();
}
public String toString() {
return "StringInterpolated(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case TokenNameEncapsedString0:
return "`"; //$NON-NLS-1$
- case TokenNameEncapsedString1:
- return "\'"; //$NON-NLS-1$
- case TokenNameEncapsedString2:
- return "\""; //$NON-NLS-1$
+// case TokenNameEncapsedString1:
+// return "\'"; //$NON-NLS-1$
+// case TokenNameEncapsedString2:
+// return "\""; //$NON-NLS-1$
case TokenNameSTRING:
- return "STRING(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "STRING_DQ(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case TokenNameHEREDOC:
return "HEREDOC(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
case TokenNamePLUS_PLUS:
this.tokenizeStrings = tokenizeStrings;
this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
this.assertMode = assertMode;
- this.encapsedStringStack = null;
+// this.encapsedStringStack = null;
this.taskTags = taskTags;
this.taskPriorities = taskPriorities;
}