private boolean phpMode;
final static int TokenNameEOF = 0;
- final static int TokenNameUNDEFINED = 1;
+ final static int TokenNameERROR = 1;
final static int TokenNameHTML = 2;
final static int TokenNameREMAINDER = 30;
final static int TokenNameXOR = 33;
final static int TokenNameDIVIDE = 34;
final static int TokenNameMULTIPLY = 35;
- final static int TokenNameSUBTRACT = 36;
- final static int TokenNameADD = 37;
- final static int TokenNameEQUAL = 38;
- final static int TokenNameUNEQUAL = 39;
+ final static int TokenNameMINUS = 36;
+ final static int TokenNamePLUS = 37;
+ final static int TokenNameEQUAL_EQUAL = 38;
+ final static int TokenNameNOT_EQUAL = 39;
final static int TokenNameGREATER = 40;
- final static int TokenNameGREATEREQUAL = 41;
+ final static int TokenNameGREATER_EQUAL = 41;
final static int TokenNameLESS = 42;
- final static int TokenNameLESSEQUAL = 43;
- final static int TokenNameAND = 44;
- final static int TokenNameOR = 45;
- final static int TokenNameHASH = 46;
- final static int TokenNameDDOT = 47;
- final static int TokenNameDOTASSIGN = 48;
-
- final static int TokenNameASSIGN = 49;
- final static int TokenNameREF = 50;
+ final static int TokenNameLESS_EQUAL = 43;
+ final static int TokenNameAND_AND = 44;
+ final static int TokenNameOR_OR = 45;
+ // final static int TokenNameHASH = 46;
+ final static int TokenNameCOLON = 47;
+ final static int TokenNameDOT_EQUAL = 48;
+
+ final static int TokenNameEQUAL = 49;
+ final static int TokenNameMINUS_GREATER = 50; // ->
final static int TokenNameFOREACH = 51;
- final static int TokenNameAMPERSAND = 52;
- final static int TokenNameDOLLARLISTOPEN = 53;
- final static int TokenNameTILDE = 54;
- final static int TokenNameTILDEASSIGN = 55;
+ final static int TokenNameAND = 52;
+ //final static int TokenNameDOLLARLISTOPEN = 53;
+ final static int TokenNameTWIDDLE = 54;
+ final static int TokenNameTWIDDLE_EQUAL = 55;
final static int TokenNameREMAINDER_EQUAL = 56;
final static int TokenNameXOR_EQUAL = 57;
final static int TokenNameRIGHT_SHIFT_EQUAL = 58;
final static int TokenNameLEFT_SHIFT_EQUAL = 59;
- final static int TokenNameANDASSIGN = 60;
- final static int TokenNameQUESTIONMARK = 61;
- final static int TokenNameDDOT2 = 62;
+ final static int TokenNameAND_EQUAL = 60;
+ final static int TokenNameQUESTION = 61;
+ final static int TokenNameCOLON_COLON = 62;
final static int TokenNameAT = 63;
// final static int TokenNameHEREDOC = 64;
final static int TokenNameDOLLAROPEN = 127;
- final static int TokenNameARGOPEN = 128;
- final static int TokenNameARGCLOSE = 129;
- final static int TokenNameLISTOPEN = 130;
- final static int TokenNameLISTCLOSE = 131;
- final static int TokenNamePARTOPEN = 132;
- final static int TokenNamePARTCLOSE = 133;
+ final static int TokenNameLPAREN = 128;
+ final static int TokenNameRPAREN = 129;
+ final static int TokenNameLBRACE = 130;
+ final static int TokenNameRBRACE = 131;
+ final static int TokenNameLBRACKET = 132;
+ final static int TokenNameRBRACKET = 133;
final static int TokenNameCOMMA = 134;
- final static int TokenNameSTRING = 136;
- final static int TokenNameIDENTIFIER = 138;
- final static int TokenNameDIGIT = 139;
+ final static int TokenNameStringLiteral = 136;
+ final static int TokenNameIdentifier = 138;
+ // final static int TokenNameDIGIT = 139;
final static int TokenNameSEMICOLON = 140;
- final static int TokenNameSLOT = 141;
- final static int TokenNameSLOTSEQUENCE = 142;
- final static int TokenNameDECREMENT = 144;
- final static int TokenNameINCREMENT = 145;
- final static int TokenNameADDTO = 146;
+ // final static int TokenNameSLOT = 141;
+ // final static int TokenNameSLOTSEQUENCE = 142;
+ final static int TokenNameMINUS_MINUS = 144;
+ final static int TokenNamePLUS_PLUS = 145;
+ final static int TokenNamePLUS_EQUAL = 146;
final static int TokenNameDIVIDE_EQUAL = 147;
- final static int TokenNameSUBTRACTFROM = 148;
- final static int TokenNameTIMESBY = 149;
- final static int TokenNameVARIABLE = 150;
- final static int TokenNameINT_NUMBER = 151;
- final static int TokenNameDOUBLE_NUMBER = 152;
- final static int TokenNameINTERPOLATED_STRING = 153;
- final static int TokenNameSTRING_CONSTANT = 154;
+ final static int TokenNameMINUS_EQUAL = 148;
+ final static int TokenNameMULTIPLY_EQUAL = 149;
+ final static int TokenNameVariable = 150;
+ final static int TokenNameIntegerLiteral = 151;
+ final static int TokenNameDoubleLiteral = 152;
+ final static int TokenNameStringInterpolated = 153;
+ final static int TokenNameStringConstant = 154;
final static int TokenNameLEFT_SHIFT = 155;
final static int TokenNameRIGHT_SHIFT = 156;
- final static int TokenNameEX_EQUAL = 157;
- final static int TokenNameEX_UNEQUAL = 158;
- final static int TokenNameLINE = 159;
+ final static int TokenNameEQUAL_EQUAL_EQUAL = 157;
+ final static int TokenNameNOT_EQUAL_EQUAL = 158;
+ final static int TokenNameOR = 159;
// final static int TokenNameAT = 153; // @
/**
* Class Constructor.
phpEnd = true;
}
- private void getNextToken_OldVersion() throws CoreException {
- phpEnd = false;
-
- while (str.length() > chIndx) {
- ch = str.charAt(chIndx++);
- token = TokenNameUNDEFINED;
- if (ch == '\n') {
- rowCount++;
- columnCount = chIndx;
- continue; // while loop
- }
- if (str.length() == chIndx) {
- phpEnd = true;
- }
- if (!Character.isWhitespace(ch)) {
- if (ch == '$') {
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '{') {
- chIndx++;
- token = TokenNameDOLLAROPEN;
- return;
- }
- }
- getIdentifier();
- return;
- }
- if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '_') || (ch == '$')) {
- getIdentifier();
- return;
- }
- if (ch >= '0' && ch <= '9') {
- getNumber();
- return;
- }
- if (ch == '/') {
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '/') {
- chIndx++;
- // read comment until end of line:
- while ((str.length() > chIndx) && (str.charAt(chIndx) != '\n')) {
- chIndx++;
- }
- continue;
- } else if (str.charAt(chIndx) == '*') {
- chIndx++;
- // multi line comment:
- while (str.length() > chIndx) {
- if (str.charAt(chIndx) == '*' && (str.length() > (chIndx + 1)) && str.charAt(chIndx + 1) == '/') {
- chIndx += 2;
- break;
- }
- ch = str.charAt(chIndx++);
- if (ch == '\n') {
- rowCount++;
- columnCount = chIndx;
- }
- }
- continue;
- }
- }
- } else if (ch == '#') {
- // read comment until end of line:
- while ((str.length() > chIndx) && (str.charAt(chIndx) != '\n')) {
- chIndx++;
- }
- continue;
- } else if (ch == '"') {
- // read string until end
- boolean openString = true;
- while (str.length() > chIndx) {
- ch = str.charAt(chIndx++);
- if (ch == '\\') {
- if (str.length() > chIndx) {
- ch = str.charAt(chIndx++);
- }
- } else if (ch == '"') {
- openString = false;
- break;
- } else if (ch == '\n') {
- rowCount++;
- columnCount = chIndx;
- }
- }
- if (openString) {
- throwSyntaxError("Open string character '\"' at end of file.");
- }
- token = TokenNameINTERPOLATED_STRING;
- return;
- } else if (ch == '\'') {
- // read string until end
- boolean openString = true;
- int startRow = rowCount;
- while (str.length() > chIndx) {
- ch = str.charAt(chIndx++);
- if (ch == '\\') {
- if (str.length() > chIndx) {
- ch = str.charAt(chIndx++);
- }
- } else if (ch == '\'') {
- openString = false;
- break;
- } else if (ch == '\n') {
- rowCount++;
- columnCount = chIndx;
- }
- }
- if (openString) {
- throwSyntaxError("Open string character \"'\" at end of file.", startRow);
- }
- token = TokenNameSTRING_CONSTANT;
- return;
- } else if (ch == '`') {
- // read string until end
- boolean openString = true;
- int startRow = rowCount;
- while (str.length() > chIndx) {
- ch = str.charAt(chIndx++);
- if (ch == '\\') {
- if (str.length() > chIndx) {
- ch = str.charAt(chIndx++);
- }
- } else if (ch == '`') {
- openString = false;
- break;
- } else if (ch == '\n') {
- rowCount++;
- columnCount = chIndx;
- }
- }
- if (openString) {
- throwSyntaxError("Open string character \"`\" at end of file.", startRow);
- }
- token = TokenNameSTRING_CONSTANT;
- return;
- }
-
- switch (ch) {
-
- case '(' :
- token = TokenNameARGOPEN;
-
- break;
- case ')' :
- token = TokenNameARGCLOSE;
-
- break;
- case '{' :
- token = TokenNameLISTOPEN;
-
- break;
- case '}' :
- token = TokenNameLISTCLOSE;
-
- break;
- case '[' :
- token = TokenNamePARTOPEN;
-
- break;
- case ']' :
- token = TokenNamePARTCLOSE;
-
- break;
- case ',' :
- token = TokenNameCOMMA;
-
- break;
- case '?' :
- token = TokenNameQUESTIONMARK;
- break;
- case '@' :
- token = TokenNameAT;
- break;
- case '~' :
- token = TokenNameTILDE;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameTILDEASSIGN;
-
- break;
- }
- }
- break;
- case '.' :
- token = TokenNameDOT;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameDOTASSIGN;
-
- break;
- }
- }
-
- break;
- case '"' :
- token = TokenNameSTRING;
-
- break;
- case '%' :
- token = TokenNameREMAINDER;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameREMAINDER_EQUAL;
-
- break;
- }
- }
- break;
- case ';' :
- token = TokenNameSEMICOLON;
-
- break;
- case '^' :
- token = TokenNameXOR;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameXOR_EQUAL;
-
- break;
- }
- }
- break;
- case '/' :
- token = TokenNameDIVIDE;
-
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameDIVIDE_EQUAL;
-
- break;
- }
- }
-
- break;
- case '*' :
- token = TokenNameMULTIPLY;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '*') {
- chIndx++;
- token = TokenNameXOR;
-
- break;
- }
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameTIMESBY;
-
- break;
- }
- }
-
- break;
- case '+' :
- token = TokenNameADD;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '+') {
- chIndx++;
- token = TokenNameINCREMENT;
-
- break;
- }
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameADDTO;
-
- break;
- }
- }
- break;
- case '-' :
- token = TokenNameSUBTRACT;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '-') {
- chIndx++;
- token = TokenNameDECREMENT;
-
- break;
- }
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameSUBTRACTFROM;
-
- break;
- }
- if (str.charAt(chIndx) == '>') {
- chIndx++;
- token = TokenNameREF;
-
- break;
- }
- }
-
- break;
- case '=' :
- token = TokenNameASSIGN;
-
- if (str.length() > chIndx) {
- ch = str.charAt(chIndx);
-
- if (ch == '=') {
- chIndx++;
- token = TokenNameEQUAL;
- if (str.length() > chIndx) {
- ch = str.charAt(chIndx);
-
- if (ch == '=') {
- chIndx++;
- token = TokenNameEX_EQUAL;
- }
- }
- break;
- }
- if (ch == '>') {
- chIndx++;
- token = TokenNameFOREACH;
-
- break;
- }
- }
-
- break;
- case '!' :
- token = TokenNameNOT;
-
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameUNEQUAL;
- if (str.length() > chIndx) {
- ch = str.charAt(chIndx);
-
- if (ch == '=') {
- chIndx++;
- token = TokenNameEX_UNEQUAL;
- }
- }
- break;
- }
- }
-
- break;
- case '>' :
- token = TokenNameGREATER;
-
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameGREATEREQUAL;
- break;
- }
- if (str.charAt(chIndx) == '>') {
- chIndx++;
- token = TokenNameRIGHT_SHIFT;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameRIGHT_SHIFT_EQUAL;
- break;
- }
- }
- break;
- }
- }
-
- break;
- case '<' :
- token = TokenNameLESS;
-
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameLESSEQUAL;
-
- break;
- }
- if (str.charAt(chIndx) == '<') {
- chIndx++;
- token = TokenNameLEFT_SHIFT;
- if (str.charAt(chIndx) == '<') {
- // heredoc
- int startRow = rowCount;
- if (str.length() > chIndx) {
-
- ch = str.charAt(++chIndx);
- if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '_')) {
- chIndx++;
- getIdentifier();
- token = TokenNameSTRING_CONSTANT;
- while (str.length() > chIndx) {
- ch = str.charAt(chIndx++);
- if (ch == '\n') {
- if (str.length() >= chIndx + identifier.length()) {
- if (str.substring(chIndx, chIndx + identifier.length()).equals(identifier)) {
- chIndx += identifier.length();
- return;
- }
- }
- }
- }
- }
- }
- throwSyntaxError("Open heredoc syntax after operator '<<<'.", startRow);
- } else if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameLEFT_SHIFT_EQUAL;
- break;
- }
- break;
- }
- }
-
- break;
-
- case '|' :
- token = TokenNameLINE;
-
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '|') {
- chIndx++;
- token = TokenNameOR;
-
- break;
- }
- }
-
- break;
- case '&' :
- token = TokenNameAMPERSAND;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == '&') {
- chIndx++;
- token = TokenNameAND;
- break;
- }
- if (str.charAt(chIndx) == '=') {
- chIndx++;
- token = TokenNameANDASSIGN;
- break;
- }
- break;
- }
-
- break;
- case ':' :
- token = TokenNameDDOT;
- if (str.length() > chIndx) {
- if (str.charAt(chIndx) == ':') {
- chIndx++;
- token = TokenNameDDOT2;
- }
- }
- break;
- case '#' :
- token = TokenNameHASH;
-
- break;
- // case '@' :
- // token = TokenNameAT;
- //
- // break;
- default :
- throwSyntaxError("unexpected character: '" + ch + "'");
- }
-
- if (token == TokenNameUNDEFINED) {
- throwSyntaxError("token not found");
- }
-
- return;
- }
- }
-
- chIndx = str.length() + 1;
- ch = ' ';
- token = TokenNameEOF;
- phpEnd = true;
- PHPString temp;
- if (phpList != null) {
- if (currentPHPString < phpList.size()) {
- token = TokenNameUNDEFINED;
- temp = (PHPString) phpList.get(currentPHPString++);
- this.str = temp.getPHPString();
- this.token = TokenNameEOF;
- this.chIndx = 0;
- this.rowCount = temp.getLineNumber();
- this.columnCount = 0;
- getNextToken();
- phpEnd = true;
- } else {
- token = TokenNameUNDEFINED;
- return;
- }
- }
- }
+// private void getNextToken_OldVersion() throws CoreException {
+// phpEnd = false;
+//
+// while (str.length() > chIndx) {
+// ch = str.charAt(chIndx++);
+// token = TokenNameERROR;
+// if (ch == '\n') {
+// rowCount++;
+// columnCount = chIndx;
+// continue; // while loop
+// }
+// if (str.length() == chIndx) {
+// phpEnd = true;
+// }
+// if (!Character.isWhitespace(ch)) {
+// if (ch == '$') {
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '{') {
+// chIndx++;
+// token = TokenNameDOLLAROPEN;
+// return;
+// }
+// }
+// getIdentifier();
+// return;
+// }
+// if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '_') || (ch == '$')) {
+// getIdentifier();
+// return;
+// }
+// if (ch >= '0' && ch <= '9') {
+// getNumber();
+// return;
+// }
+// if (ch == '/') {
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '/') {
+// chIndx++;
+// // read comment until end of line:
+// while ((str.length() > chIndx) && (str.charAt(chIndx) != '\n')) {
+// chIndx++;
+// }
+// continue;
+// } else if (str.charAt(chIndx) == '*') {
+// chIndx++;
+// // multi line comment:
+// while (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '*' && (str.length() > (chIndx + 1)) && str.charAt(chIndx + 1) == '/') {
+// chIndx += 2;
+// break;
+// }
+// ch = str.charAt(chIndx++);
+// if (ch == '\n') {
+// rowCount++;
+// columnCount = chIndx;
+// }
+// }
+// continue;
+// }
+// }
+// } else if (ch == '#') {
+// // read comment until end of line:
+// while ((str.length() > chIndx) && (str.charAt(chIndx) != '\n')) {
+// chIndx++;
+// }
+// continue;
+// } else if (ch == '"') {
+// // read string until end
+// boolean openString = true;
+// while (str.length() > chIndx) {
+// ch = str.charAt(chIndx++);
+// if (ch == '\\') {
+// if (str.length() > chIndx) {
+// ch = str.charAt(chIndx++);
+// }
+// } else if (ch == '"') {
+// openString = false;
+// break;
+// } else if (ch == '\n') {
+// rowCount++;
+// columnCount = chIndx;
+// }
+// }
+// if (openString) {
+// throwSyntaxError("Open string character '\"' at end of file.");
+// }
+// token = TokenNameINTERPOLATED_STRING;
+// return;
+// } else if (ch == '\'') {
+// // read string until end
+// boolean openString = true;
+// int startRow = rowCount;
+// while (str.length() > chIndx) {
+// ch = str.charAt(chIndx++);
+// if (ch == '\\') {
+// if (str.length() > chIndx) {
+// ch = str.charAt(chIndx++);
+// }
+// } else if (ch == '\'') {
+// openString = false;
+// break;
+// } else if (ch == '\n') {
+// rowCount++;
+// columnCount = chIndx;
+// }
+// }
+// if (openString) {
+// throwSyntaxError("Open string character \"'\" at end of file.", startRow);
+// }
+// token = TokenNameStringConstant;
+// return;
+// } else if (ch == '`') {
+// // read string until end
+// boolean openString = true;
+// int startRow = rowCount;
+// while (str.length() > chIndx) {
+// ch = str.charAt(chIndx++);
+// if (ch == '\\') {
+// if (str.length() > chIndx) {
+// ch = str.charAt(chIndx++);
+// }
+// } else if (ch == '`') {
+// openString = false;
+// break;
+// } else if (ch == '\n') {
+// rowCount++;
+// columnCount = chIndx;
+// }
+// }
+// if (openString) {
+// throwSyntaxError("Open string character \"`\" at end of file.", startRow);
+// }
+// token = TokenNameStringConstant;
+// return;
+// }
+//
+// switch (ch) {
+//
+// case '(' :
+// token = TokenNameLPAREN;
+//
+// break;
+// case ')' :
+// token = TokenNameRPAREN;
+//
+// break;
+// case '{' :
+// token = TokenNameLBRACE;
+//
+// break;
+// case '}' :
+// token = TokenNameRBRACE;
+//
+// break;
+// case '[' :
+// token = TokenNameLBRACKET;
+//
+// break;
+// case ']' :
+// token = TokenNameRBRACKET;
+//
+// break;
+// case ',' :
+// token = TokenNameCOMMA;
+//
+// break;
+// case '?' :
+// token = TokenNameQUESTION;
+// break;
+// case '@' :
+// token = TokenNameAT;
+// break;
+// case '~' :
+// token = TokenNameTWIDDLE;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameTWIDDLE_EQUAL;
+//
+// break;
+// }
+// }
+// break;
+// case '.' :
+// token = TokenNameDOT;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameDOT_EQUAL;
+//
+// break;
+// }
+// }
+//
+// break;
+// case '"' :
+// token = TokenNameStringLiteral;
+//
+// break;
+// case '%' :
+// token = TokenNameREMAINDER;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameREMAINDER_EQUAL;
+//
+// break;
+// }
+// }
+// break;
+// case ';' :
+// token = TokenNameSEMICOLON;
+//
+// break;
+// case '^' :
+// token = TokenNameXOR;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameXOR_EQUAL;
+//
+// break;
+// }
+// }
+// break;
+// case '/' :
+// token = TokenNameDIVIDE;
+//
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameDIVIDE_EQUAL;
+//
+// break;
+// }
+// }
+//
+// break;
+// case '*' :
+// token = TokenNameMULTIPLY;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '*') {
+// chIndx++;
+// token = TokenNameXOR;
+//
+// break;
+// }
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameMULTIPLY_EQUAL;
+//
+// break;
+// }
+// }
+//
+// break;
+// case '+' :
+// token = TokenNamePLUS;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '+') {
+// chIndx++;
+// token = TokenNamePLUS_PLUS;
+//
+// break;
+// }
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNamePLUS_EQUAL;
+//
+// break;
+// }
+// }
+// break;
+// case '-' :
+// token = TokenNameMINUS;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '-') {
+// chIndx++;
+// token = TokenNameMINUS_MINUS;
+//
+// break;
+// }
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameMINUS_EQUAL;
+//
+// break;
+// }
+// if (str.charAt(chIndx) == '>') {
+// chIndx++;
+// token = TokenNameMINUS_GREATER;
+//
+// break;
+// }
+// }
+//
+// break;
+// case '=' :
+// token = TokenNameEQUAL;
+//
+// if (str.length() > chIndx) {
+// ch = str.charAt(chIndx);
+//
+// if (ch == '=') {
+// chIndx++;
+// token = TokenNameEQUAL_EQUAL;
+// if (str.length() > chIndx) {
+// ch = str.charAt(chIndx);
+//
+// if (ch == '=') {
+// chIndx++;
+// token = TokenNameEQUAL_EQUAL_EQUAL;
+// }
+// }
+// break;
+// }
+// if (ch == '>') {
+// chIndx++;
+// token = TokenNameFOREACH;
+//
+// break;
+// }
+// }
+//
+// break;
+// case '!' :
+// token = TokenNameNOT;
+//
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameNOT_EQUAL;
+// if (str.length() > chIndx) {
+// ch = str.charAt(chIndx);
+//
+// if (ch == '=') {
+// chIndx++;
+// token = TokenNameNOT_EQUAL_EQUAL;
+// }
+// }
+// break;
+// }
+// }
+//
+// break;
+// case '>' :
+// token = TokenNameGREATER;
+//
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameGREATER_EQUAL;
+// break;
+// }
+// if (str.charAt(chIndx) == '>') {
+// chIndx++;
+// token = TokenNameRIGHT_SHIFT;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameRIGHT_SHIFT_EQUAL;
+// break;
+// }
+// }
+// break;
+// }
+// }
+//
+// break;
+// case '<' :
+// token = TokenNameLESS;
+//
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameLESS_EQUAL;
+//
+// break;
+// }
+// if (str.charAt(chIndx) == '<') {
+// chIndx++;
+// token = TokenNameLEFT_SHIFT;
+// if (str.charAt(chIndx) == '<') {
+// // heredoc
+// int startRow = rowCount;
+// if (str.length() > chIndx) {
+//
+// ch = str.charAt(++chIndx);
+// if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '_')) {
+// chIndx++;
+// getIdentifier();
+// token = TokenNameStringConstant;
+// while (str.length() > chIndx) {
+// ch = str.charAt(chIndx++);
+// if (ch == '\n') {
+// if (str.length() >= chIndx + identifier.length()) {
+// if (str.substring(chIndx, chIndx + identifier.length()).equals(identifier)) {
+// chIndx += identifier.length();
+// return;
+// }
+// }
+// }
+// }
+// }
+// }
+// throwSyntaxError("Open heredoc syntax after operator '<<<'.", startRow);
+// } else if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameLEFT_SHIFT_EQUAL;
+// break;
+// }
+// break;
+// }
+// }
+//
+// break;
+//
+// case '|' :
+// token = TokenNameOR;
+//
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '|') {
+// chIndx++;
+// token = TokenNameOR_OR;
+//
+// break;
+// }
+// }
+//
+// break;
+// case '&' :
+// token = TokenNameAND;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == '&') {
+// chIndx++;
+// token = TokenNameAND_AND;
+// break;
+// }
+// if (str.charAt(chIndx) == '=') {
+// chIndx++;
+// token = TokenNameAND_EQUAL;
+// break;
+// }
+// break;
+// }
+//
+// break;
+// case ':' :
+// token = TokenNameCOLON;
+// if (str.length() > chIndx) {
+// if (str.charAt(chIndx) == ':') {
+// chIndx++;
+// token = TokenNameCOLON_COLON;
+// }
+// }
+// break;
+// case '#' :
+// token = TokenNameHASH;
+//
+// break;
+// // case '@' :
+// // token = TokenNameAT;
+// //
+// // break;
+// default :
+// throwSyntaxError("unexpected character: '" + ch + "'");
+// }
+//
+// if (token == TokenNameERROR) {
+// throwSyntaxError("token not found");
+// }
+//
+// return;
+// }
+// }
+//
+// chIndx = str.length() + 1;
+// ch = ' ';
+// token = TokenNameEOF;
+// phpEnd = true;
+// PHPString temp;
+// if (phpList != null) {
+// if (currentPHPString < phpList.size()) {
+// token = TokenNameERROR;
+// temp = (PHPString) phpList.get(currentPHPString++);
+// this.str = temp.getPHPString();
+// this.token = TokenNameEOF;
+// this.chIndx = 0;
+// this.rowCount = temp.getLineNumber();
+// this.columnCount = 0;
+// getNextToken();
+// phpEnd = true;
+// } else {
+// token = TokenNameERROR;
+// return;
+// }
+// }
+// }
/**
* gets the next token from input
*/
if (!phpMode) {
while (str.length() > chIndx) {
- token = TokenNameUNDEFINED;
+ token = TokenNameERROR;
ch = str.charAt(chIndx++);
if (ch == '\n') {
if (phpMode) {
while (str.length() > chIndx) {
ch = str.charAt(chIndx++);
- token = TokenNameUNDEFINED;
+ token = TokenNameERROR;
if (ch == '\n') {
rowCount++;
columnCount = chIndx;
continue;
} else if (ch == '"') {
- getString('"',TokenNameINTERPOLATED_STRING,"Open string character '\"' at end of file.");
+ getString('"',TokenNameStringInterpolated,"Open string character '\"' at end of file.");
return;
} else if (ch == '\'') {
- getString('\'',TokenNameSTRING_CONSTANT,"Open string character \"'\" at end of file.");
+ getString('\'',TokenNameStringConstant,"Open string character \"'\" at end of file.");
return;
} else if (ch == '`') {
- getString('`',TokenNameSTRING_CONSTANT,"Open string character \"`\" at end of file.");
+ getString('`',TokenNameStringConstant,"Open string character \"`\" at end of file.");
setMarker("Other string delimiters prefered (found \"`\").", rowCount, PHPParser.INFO);
return;
}
switch (ch) {
case '(' :
- token = TokenNameARGOPEN;
+ token = TokenNameLPAREN;
break;
case ')' :
- token = TokenNameARGCLOSE;
+ token = TokenNameRPAREN;
break;
case '{' :
- token = TokenNameLISTOPEN;
+ token = TokenNameLBRACE;
break;
case '}' :
- token = TokenNameLISTCLOSE;
+ token = TokenNameRBRACE;
break;
case '[' :
- token = TokenNamePARTOPEN;
+ token = TokenNameLBRACKET;
break;
case ']' :
- token = TokenNamePARTCLOSE;
+ token = TokenNameRBRACKET;
break;
case ',' :
break;
case '?' :
- token = TokenNameQUESTIONMARK;
+ token = TokenNameQUESTION;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '>') {
chIndx++;
token = TokenNameAT;
break;
case '~' :
- token = TokenNameTILDE;
+ token = TokenNameTWIDDLE;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameTILDEASSIGN;
+ token = TokenNameTWIDDLE_EQUAL;
break;
}
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameDOTASSIGN;
+ token = TokenNameDOT_EQUAL;
break;
}
break;
case '"' :
- token = TokenNameSTRING;
+ token = TokenNameStringLiteral;
break;
case '%' :
}
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameTIMESBY;
+ token = TokenNameMULTIPLY_EQUAL;
break;
}
break;
case '+' :
- token = TokenNameADD;
+ token = TokenNamePLUS;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '+') {
chIndx++;
- token = TokenNameINCREMENT;
+ token = TokenNamePLUS_PLUS;
break;
}
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameADDTO;
+ token = TokenNamePLUS_EQUAL;
break;
}
}
break;
case '-' :
- token = TokenNameSUBTRACT;
+ token = TokenNameMINUS;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '-') {
chIndx++;
- token = TokenNameDECREMENT;
+ token = TokenNameMINUS_MINUS;
break;
}
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameSUBTRACTFROM;
+ token = TokenNameMINUS_EQUAL;
break;
}
if (str.charAt(chIndx) == '>') {
chIndx++;
- token = TokenNameREF;
+ token = TokenNameMINUS_GREATER;
break;
}
break;
case '=' :
- token = TokenNameASSIGN;
+ token = TokenNameEQUAL;
if (str.length() > chIndx) {
ch = str.charAt(chIndx);
if (ch == '=') {
chIndx++;
- token = TokenNameEQUAL;
+ token = TokenNameEQUAL_EQUAL;
if (str.length() > chIndx) {
ch = str.charAt(chIndx);
if (ch == '=') {
chIndx++;
- token = TokenNameEX_EQUAL;
+ token = TokenNameEQUAL_EQUAL_EQUAL;
}
}
break;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameUNEQUAL;
+ token = TokenNameNOT_EQUAL;
if (str.length() > chIndx) {
ch = str.charAt(chIndx);
if (ch == '=') {
chIndx++;
- token = TokenNameEX_UNEQUAL;
+ token = TokenNameNOT_EQUAL_EQUAL;
}
}
break;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameGREATEREQUAL;
+ token = TokenNameGREATER_EQUAL;
break;
}
if (str.charAt(chIndx) == '>') {
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameLESSEQUAL;
+ token = TokenNameLESS_EQUAL;
break;
}
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '_')) {
chIndx++;
getIdentifier();
- token = TokenNameSTRING_CONSTANT;
+ token = TokenNameStringConstant;
while (str.length() > chIndx) {
ch = str.charAt(chIndx++);
if (ch == '\n') {
break;
case '|' :
- token = TokenNameLINE;
+ token = TokenNameOR;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '|') {
chIndx++;
- token = TokenNameOR;
+ token = TokenNameOR_OR;
break;
}
break;
case '&' :
- token = TokenNameAMPERSAND;
+ token = TokenNameAND;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == '&') {
chIndx++;
- token = TokenNameAND;
+ token = TokenNameAND_AND;
break;
}
if (str.charAt(chIndx) == '=') {
chIndx++;
- token = TokenNameANDASSIGN;
+ token = TokenNameAND_EQUAL;
break;
}
break;
break;
case ':' :
- token = TokenNameDDOT;
+ token = TokenNameCOLON;
if (str.length() > chIndx) {
if (str.charAt(chIndx) == ':') {
chIndx++;
- token = TokenNameDDOT2;
+ token = TokenNameCOLON_COLON;
}
}
break;
- case '#' :
- token = TokenNameHASH;
-
- break;
+// case '#' :
+// token = TokenNameHASH;
+//
+// break;
// case '@' :
// token = TokenNameAT;
//
throwSyntaxError("unexpected character: '" + ch + "'");
}
- if (token == TokenNameUNDEFINED) {
+ if (token == TokenNameERROR) {
throwSyntaxError("token not found");
}
getChar();
// attention recursive call:
getIdentifier();
- token = TokenNameVARIABLE;
+ token = TokenNameVariable;
return;
} else {
- token = TokenNameIDENTIFIER;
+ token = TokenNameIdentifier;
}
getChar();
try {
if (dFlag != ' ') {
doubleNumber = new Double(inum.toString());
- token = TokenNameDOUBLE_NUMBER;
+ token = TokenNameDoubleLiteral;
return;
} else {
longNumber = Long.valueOf(inum.toString(), numFormat);
- token = TokenNameINT_NUMBER;
+ token = TokenNameIntegerLiteral;
return;
}
}
}
if (openString) {
- if (typeString == TokenNameSTRING_CONSTANT) {
+ if (typeString == TokenNameStringConstant) {
throwSyntaxError(errorMsg, startRow);
} else {
throwSyntaxError(errorMsg);
getNextToken();
do {
try {
- if (token != TokenNameEOF && token != TokenNameUNDEFINED) {
+ if (token != TokenNameEOF && token != TokenNameERROR) {
statementList();
}
- if (token != TokenNameEOF && token != TokenNameUNDEFINED) {
- if (token == TokenNameARGCLOSE) {
+ if (token != TokenNameEOF && token != TokenNameERROR) {
+ if (token == TokenNameRPAREN) {
throwSyntaxError("Too many closing ')'; end-of-file not reached.");
}
- if (token == TokenNameLISTCLOSE) {
+ if (token == TokenNameRBRACE) {
throwSyntaxError("Too many closing '}'; end-of-file not reached.");
}
- if (token == TokenNamePARTCLOSE) {
+ if (token == TokenNameRBRACKET) {
throwSyntaxError("Too many closing ']'; end-of-file not reached.");
}
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
throwSyntaxError("Read character '('; end-of-file not reached.");
}
- if (token == TokenNameLISTOPEN) {
+ if (token == TokenNameLBRACE) {
throwSyntaxError("Read character '{'; end-of-file not reached.");
}
- if (token == TokenNamePARTOPEN) {
+ if (token == TokenNameLBRACKET) {
throwSyntaxError("Read character '['; end-of-file not reached.");
}
// if an error occured,
// try to find keywords 'class' or 'function'
// to parse the rest of the string
- while (token != TokenNameEOF && token != TokenNameUNDEFINED) {
+ while (token != TokenNameEOF && token != TokenNameERROR) {
if (token == TokenNameclass || token == TokenNamefunction) {
break;
}
getNextToken();
}
- if (token == TokenNameEOF || token == TokenNameUNDEFINED) {
+ if (token == TokenNameEOF || token == TokenNameERROR) {
return;
}
}
getNextToken();
do {
try {
- if (token != TokenNameEOF && token != TokenNameUNDEFINED) {
+ if (token != TokenNameEOF && token != TokenNameERROR) {
statementList();
}
- if (token != TokenNameEOF && token != TokenNameUNDEFINED) {
- if (token == TokenNameARGCLOSE) {
+ if (token != TokenNameEOF && token != TokenNameERROR) {
+ if (token == TokenNameRPAREN) {
throwSyntaxError("Too many closing ')'; end-of-file not reached.");
}
- if (token == TokenNameLISTCLOSE) {
+ if (token == TokenNameRBRACE) {
throwSyntaxError("Too many closing '}'; end-of-file not reached.");
}
- if (token == TokenNamePARTCLOSE) {
+ if (token == TokenNameRBRACKET) {
throwSyntaxError("Too many closing ']'; end-of-file not reached.");
}
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
throwSyntaxError("Read character '('; end-of-file not reached.");
}
- if (token == TokenNameLISTOPEN) {
+ if (token == TokenNameLBRACE) {
throwSyntaxError("Read character '{'; end-of-file not reached.");
}
- if (token == TokenNamePARTOPEN) {
+ if (token == TokenNameLBRACKET) {
throwSyntaxError("Read character '['; end-of-file not reached.");
}
// if an error occured,
// try to find keywords 'class' or 'function'
// to parse the rest of the string
- while (token != TokenNameEOF && token != TokenNameUNDEFINED) {
+ while (token != TokenNameEOF && token != TokenNameERROR) {
if (token == TokenNameclass || token == TokenNamefunction) {
break;
}
getNextToken();
}
- if (token == TokenNameEOF || token == TokenNameUNDEFINED) {
+ if (token == TokenNameEOF || token == TokenNameERROR) {
return;
}
} catch (SyntaxError sytaxErr2) {
String oldIdentifier;
IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
try {
- while (token != TokenNameEOF && token != TokenNameUNDEFINED) {
- if (token == TokenNameVARIABLE) {
+ while (token != TokenNameEOF && token != TokenNameERROR) {
+ if (token == TokenNameVariable) {
outlineInfo.addVariable(identifier);
getNextToken();
} else if (token == TokenNamevar) {
getNextToken();
- if (token == TokenNameVARIABLE && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_VAR)) {
+ if (token == TokenNameVariable && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_VAR)) {
getNextToken();
outlineInfo.addVariable(identifier);
if (token != TokenNameSEMICOLON) {
oldIdentifier = identifier;
getNextToken();
switch (token) {
- case TokenNameVARIABLE : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),identifier));
+ case TokenNameVariable : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),identifier));
break;
- case TokenNameIDENTIFIER : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),identifier));
+ case TokenNameIdentifier : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),identifier));
break;
- case TokenNameDOUBLE_NUMBER : current.add(new PHPVarDeclaration(current, oldIdentifier + doubleNumber, chIndx - identifier.length(),doubleNumber.toString()));
+ case TokenNameDoubleLiteral : current.add(new PHPVarDeclaration(current, oldIdentifier + doubleNumber, chIndx - identifier.length(),doubleNumber.toString()));
break;
- case TokenNameINT_NUMBER : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),longNumber.toString()));
+ case TokenNameIntegerLiteral : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),longNumber.toString()));
break;
- case TokenNameINTERPOLATED_STRING : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),stringValue));
+ case TokenNameStringInterpolated : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),stringValue));
break;
- case TokenNameSTRING_CONSTANT : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),stringValue));
+ case TokenNameStringConstant : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length(),stringValue));
break;
default : current.add(new PHPVarDeclaration(current, oldIdentifier, chIndx - identifier.length()));
break;
}
} else if (token == TokenNamefunction) {
getNextToken();
- if (token == TokenNameAMPERSAND) {
+ if (token == TokenNameAND) {
getNextToken();
}
- if (token == TokenNameIDENTIFIER && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_FUNC)) {
+ if (token == TokenNameIdentifier && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_FUNC)) {
outlineInfo.addVariable(identifier);
temp = new PHPFunctionDeclaration(current, identifier, chIndx - identifier.length());
current.add(temp);
}
} else if (token == TokenNameclass) {
getNextToken();
- if (token == TokenNameIDENTIFIER && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_CLASS)) {
+ if (token == TokenNameIdentifier && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_CLASS)) {
outlineInfo.addVariable(identifier);
temp = new PHPClassDeclaration(current, identifier, chIndx - identifier.length());
current.add(temp);
getNextToken();
//skip tokens for classname, extends and others until we have the opening '{'
- while (token != TokenNameLISTOPEN && token != TokenNameEOF && token != TokenNameUNDEFINED) {
+ while (token != TokenNameLBRACE && token != TokenNameEOF && token != TokenNameERROR) {
getNextToken();
}
parseDeclarations(outlineInfo, temp, true);
// stack.pop();
}
- } else if (token == TokenNameLISTOPEN) {
+ } else if (token == TokenNameLBRACE) {
getNextToken();
counter++;
- } else if (token == TokenNameLISTCLOSE) {
+ } else if (token == TokenNameRBRACE) {
getNextToken();
--counter;
if (counter == 0 && goBack) {
private void statementList() throws CoreException {
do {
statement();
- if ((token == TokenNameLISTCLOSE)
+ if ((token == TokenNameRBRACE)
|| (token == TokenNamecase)
|| (token == TokenNamedefault)
|| (token == TokenNameelseif)
|| (token == TokenNameendwhile)
|| (token == TokenNameendswitch)
|| (token == TokenNameEOF)
- || (token == TokenNameUNDEFINED)) {
+ || (token == TokenNameERROR)) {
return;
}
} while (true);
private void compoundStatement() throws CoreException {
// '{' [statement-list] '}'
- if (token == TokenNameLISTOPEN) {
+ if (token == TokenNameLBRACE) {
getNextToken();
} else {
throwSyntaxError("'{' expected in compound-statement.");
}
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
statementList();
}
- if (token == TokenNameLISTCLOSE) {
+ if (token == TokenNameRBRACE) {
getNextToken();
} else {
throwSyntaxError("'}' expected in compound-statement.");
return;
} else if (token == TokenNameif) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected after 'if' keyword.");
}
expression();
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'if' condition.");
} else if (token == TokenNameswitch) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected after 'switch' keyword.");
}
expression();
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'switch' condition.");
return;
} else if (token == TokenNamefor) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected after 'for' keyword.");
throwSyntaxError("';' expected after 'for'.");
}
}
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
expressionList();
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'for'.");
return;
} else if (token == TokenNamewhile) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected after 'while' keyword.");
}
expression();
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'while' condition.");
return;
} else if (token == TokenNamedo) {
getNextToken();
- if (token == TokenNameLISTOPEN) {
+ if (token == TokenNameLBRACE) {
getNextToken();
} else {
throwSyntaxError("'{' expected after 'do' keyword.");
}
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
statementList();
}
- if (token == TokenNameLISTCLOSE) {
+ if (token == TokenNameRBRACE) {
getNextToken();
} else {
throwSyntaxError("'}' expected after 'do' keyword.");
}
if (token == TokenNamewhile) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected after 'while' keyword.");
}
expression();
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'while' condition.");
return;
} else if (token == TokenNameforeach) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected after 'foreach' keyword.");
getNextToken();
variable();
}
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'foreach' expression.");
} else if (token == TokenNamedefine) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected after 'define' keyword.");
getNextToken();
expression();
}
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'define' statement.");
return;
// } else {
// throwSyntaxError("Unexpected keyword '" + keyword + "'");
- } else if (token == TokenNameLISTOPEN) {
+ } else if (token == TokenNameLBRACE) {
// compoundStatement
getNextToken();
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
statementList();
}
- if (token == TokenNameLISTCLOSE) {
+ if (token == TokenNameRBRACE) {
getNextToken();
return;
} else {
private void classDeclarator() throws CoreException {
//identifier
//identifier 'extends' identifier
- if (token == TokenNameIDENTIFIER) {
+ if (token == TokenNameIdentifier) {
getNextToken();
if (token == TokenNameextends) {
getNextToken();
- if (token == TokenNameIDENTIFIER) {
+ if (token == TokenNameIdentifier) {
getNextToken();
} else {
throwSyntaxError("Class name expected after keyword 'extends'.");
private void classBody() throws CoreException {
//'{' [class-element-list] '}'
- if (token == TokenNameLISTOPEN) {
+ if (token == TokenNameLBRACE) {
getNextToken();
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
classElementList();
}
- if (token == TokenNameLISTCLOSE) {
+ if (token == TokenNameRBRACE) {
getNextToken();
} else {
throwSyntaxError("'}' expected at end of class body.");
//'var' variable ';'
//'var' variable '=' constant ';'
do {
- if (token == TokenNameVARIABLE) {
+ if (token == TokenNameVariable) {
getNextToken();
- if (token == TokenNameASSIGN) {
+ if (token == TokenNameEQUAL) {
getNextToken();
constant();
}
private void functionDeclarator() throws CoreException {
//identifier '(' [parameter-list] ')'
- if (token == TokenNameAMPERSAND) {
+ if (token == TokenNameAND) {
getNextToken();
}
- if (token == TokenNameIDENTIFIER) {
+ if (token == TokenNameIdentifier) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected in function declaration.");
}
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
parameterList();
}
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
throwSyntaxError("')' expected in function declaration.");
} else {
getNextToken();
private void parameterDeclaration() throws CoreException {
//variable
//variable-reference
- if (token == TokenNameAMPERSAND) {
+ if (token == TokenNameAND) {
getNextToken();
- if (token == TokenNameVARIABLE) {
+ if (token == TokenNameVariable) {
getNextToken();
} else {
throwSyntaxError("Variable expected after reference operator '&'.");
}
}
//variable '=' constant
- if (token == TokenNameVARIABLE) {
+ if (token == TokenNameVariable) {
getNextToken();
- if (token == TokenNameASSIGN) {
+ if (token == TokenNameEQUAL) {
getNextToken();
constant();
}
if (token == TokenNamecase) {
getNextToken();
constant();
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
if (token == TokenNamecase || token == TokenNamedefault) { // empty case statement ?
continue;
}
} else { // TokenNamedefault
getNextToken();
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
statementList();
} else {
private void ifStatement() throws CoreException {
// ':' statement-list [elseif-list] [else-colon-statement] 'endif' ';'
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
statementList();
switch (token) {
case TokenNameelse :
getNextToken();
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
statementList();
} else {
statement();
if (token == TokenNameelseif) {
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected after 'elseif' keyword.");
}
expression();
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'elseif' condition.");
switch (token) {
case TokenNameelse :
getNextToken();
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
statementList();
return;
}
private void elseifStatement() throws CoreException {
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
expression();
- if (token != TokenNameARGOPEN) {
+ if (token != TokenNameLPAREN) {
throwSyntaxError("')' expected in else-if-statement.");
}
getNextToken();
- if (token != TokenNameDDOT) {
+ if (token != TokenNameCOLON) {
throwSyntaxError("':' expected in else-if-statement.");
}
getNextToken();
}
private void switchStatement() throws CoreException {
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
// ':' [labeled-statement-list] 'endswitch' ';'
getNextToken();
labeledStatementList();
getNextToken();
} else {
// '{' [labeled-statement-list] '}'
- if (token != TokenNameLISTOPEN) {
+ if (token != TokenNameLBRACE) {
throwSyntaxError("'{' expected in switch statement.");
}
getNextToken();
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
labeledStatementList();
}
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
throwSyntaxError("'}' expected in switch statement.");
}
getNextToken();
}
private void forStatement() throws CoreException {
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
statementList();
if (token != TokenNameendfor) {
private void whileStatement() throws CoreException {
// ':' statement-list 'endwhile' ';'
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
statementList();
if (token != TokenNameendwhile) {
}
private void foreachStatement() throws CoreException {
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
statementList();
if (token != TokenNameendforeach) {
}
private void exitStatus() throws CoreException {
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
} else {
throwSyntaxError("'(' expected in 'exit-status'.");
}
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
expression();
}
- if (token == TokenNameARGCLOSE) {
+ if (token == TokenNameRPAREN) {
getNextToken();
} else {
throwSyntaxError("')' expected after 'exit-status'.");
case TokenNametrue :
getNextToken();
break;
- case TokenNameSTRING_CONSTANT :
+ case TokenNameStringConstant :
getNextToken();
break;
- case TokenNameINTERPOLATED_STRING :
+ case TokenNameStringInterpolated :
getNextToken();
break;
- case TokenNameARGOPEN :
+ case TokenNameLPAREN :
getNextToken();
- if (token == TokenNameIDENTIFIER) {
+ if (token == TokenNameIdentifier) {
// check if identifier is a type:
ident = identifier;
String str = identifier.toLowerCase();
}
if (castFlag) {
getNextToken();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
throwSyntaxError(") expected after cast-type '" + ident + "'.");
}
getNextToken();
if (!castFlag) {
expression();
}
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
throwSyntaxError(") expected in postfix-expression.");
}
getNextToken();
break;
- case TokenNameDOUBLE_NUMBER :
+ case TokenNameDoubleLiteral :
getNextToken();
break;
- case TokenNameINT_NUMBER :
+ case TokenNameIntegerLiteral :
getNextToken();
break;
case TokenNameDOLLAROPEN :
getNextToken();
expression();
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
throwSyntaxError("'}' expected after indirect variable token '${'.");
}
getNextToken();
break;
- case TokenNameVARIABLE :
+ case TokenNameVariable :
ident = identifier;
getNextToken();
- if (token == TokenNameLISTOPEN) {
+ if (token == TokenNameLBRACE) {
getNextToken();
expression();
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
throwSyntaxError("'}' expected after variable '" + ident + "' in variable-expression.");
}
getNextToken();
- } else if (token == TokenNameARGOPEN) {
+ } else if (token == TokenNameLPAREN) {
getNextToken();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
expressionList();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
throwSyntaxError("')' expected after variable '" + ident + "' in postfix-expression.");
}
}
getNextToken();
}
break;
- case TokenNameIDENTIFIER :
+ case TokenNameIdentifier :
ident = identifier;
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
expressionList();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
throwSyntaxError("')' expected after identifier '" + ident + "' in postfix-expression.");
}
}
break;
case TokenNamelist :
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
if (token == TokenNameCOMMA) {
getNextToken();
}
expressionList();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
throwSyntaxError("')' expected after 'list' keyword.");
}
getNextToken();
boolean while_flag = true;
do {
switch (token) {
- case TokenNamePARTOPEN :
+ case TokenNameLBRACKET :
getNextToken();
expression();
- if (token != TokenNamePARTCLOSE) {
+ if (token != TokenNameRBRACKET) {
throwSyntaxError("] expected in postfix-expression.");
}
getNextToken();
break;
- case TokenNameDDOT2 : // ::
- case TokenNameREF : // ->
+ case TokenNameCOLON_COLON : // ::
+ case TokenNameMINUS_GREATER : // ->
getNextToken();
if (token > TokenNameKEYWORD) {
ident = identifier;
setMarker("Avoid using keyword '" + ident + "' as variable name.", rowCount, PHPParser.INFO);
}
switch (token) {
- case TokenNameVARIABLE :
+ case TokenNameVariable :
ident = identifier;
getNextToken();
// if (token == TokenNameARGOPEN) {
// getNextToken();
// }
break;
- case TokenNameIDENTIFIER :
+ case TokenNameIdentifier :
ident = identifier;
getNextToken();
break;
- case TokenNameLISTOPEN :
+ case TokenNameLBRACE :
getNextToken();
expression();
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
throwSyntaxError("} expected in postfix-expression.");
}
getNextToken();
break;
default :
throwSyntaxError("Syntax error after '->' token.");
- } while (token == TokenNamePARTOPEN || token == TokenNameARGOPEN || token == TokenNameLISTOPEN) {
- if (token == TokenNamePARTOPEN) {
+ } while (token == TokenNameLBRACKET || token == TokenNameLPAREN || token == TokenNameLBRACE) {
+ if (token == TokenNameLBRACKET) {
getNextToken();
expressionList();
- if (token != TokenNamePARTCLOSE) {
+ if (token != TokenNameRBRACKET) {
throwSyntaxError("] expected after '->'.");
}
getNextToken();
}
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
expressionList();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
throwSyntaxError(") expected after '->'.");
}
getNextToken();
}
- if (token == TokenNameLISTOPEN) {
+ if (token == TokenNameLBRACE) {
getNextToken();
expression();
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
throwSyntaxError("} expected after '->'.");
}
getNextToken();
}
}
break;
- case TokenNameINCREMENT :
+ case TokenNamePLUS_PLUS :
getNextToken();
break;
- case TokenNameDECREMENT :
+ case TokenNameMINUS_MINUS :
getNextToken();
break;
default :
private void unaryExpression() throws CoreException {
switch (token) {
- case TokenNameINCREMENT :
+ case TokenNamePLUS_PLUS :
getNextToken();
unaryExpression();
break;
- case TokenNameDECREMENT :
+ case TokenNameMINUS_MINUS :
getNextToken();
unaryExpression();
break;
getNextToken();
castExpression();
break;
- case TokenNameAMPERSAND :
+ case TokenNameAND :
getNextToken();
castExpression();
break;
getNextToken();
castExpression();
break;
- case TokenNameADD :
+ case TokenNamePLUS :
getNextToken();
castExpression();
break;
- case TokenNameSUBTRACT :
+ case TokenNameMINUS :
getNextToken();
castExpression();
break;
- case TokenNameTILDE :
+ case TokenNameTWIDDLE :
getNextToken();
castExpression();
break;
//'real' 'double' 'float'
//'int' 'integer'
String ident = "";
- if (token == TokenNameIDENTIFIER) {
+ if (token == TokenNameIdentifier) {
ident = identifier;
String str = identifier.toLowerCase();
getNextToken();
private void assignExpression() throws CoreException {
castExpression();
- if (token == TokenNameASSIGN) { // =
+ if (token == TokenNameEQUAL) { // =
getNextToken();
logicalinclusiveorExpression();
- } else if (token == TokenNameDOTASSIGN) { // .=
+ } else if (token == TokenNameDOT_EQUAL) { // .=
getNextToken();
logicalinclusiveorExpression();
} else if (token == TokenNameFOREACH) { // =>
getNextToken();
logicalinclusiveorExpression();
- } else if (token == TokenNameADDTO) { // +=
+ } else if (token == TokenNamePLUS_EQUAL) { // +=
getNextToken();
logicalinclusiveorExpression();
- } else if (token == TokenNameSUBTRACTFROM) { // -=
+ } else if (token == TokenNameMINUS_EQUAL) { // -=
getNextToken();
logicalinclusiveorExpression();
- } else if (token == TokenNameTIMESBY) { // *=
+ } else if (token == TokenNameMULTIPLY_EQUAL) { // *=
getNextToken();
logicalinclusiveorExpression();
} else if (token == TokenNameDIVIDE_EQUAL) { // *=
} else if (token == TokenNameREMAINDER_EQUAL) { // %=
getNextToken();
logicalinclusiveorExpression();
- } else if (token == TokenNameANDASSIGN) { // &=
+ } else if (token == TokenNameAND_EQUAL) { // &=
getNextToken();
logicalinclusiveorExpression();
} else if (token == TokenNameXOR_EQUAL) { // ^=
} else if (token == TokenNameRIGHT_SHIFT_EQUAL) { // >>=
getNextToken();
logicalinclusiveorExpression();
- } else if (token == TokenNameTILDEASSIGN) { // ~=
+ } else if (token == TokenNameTWIDDLE_EQUAL) { // ~=
getNextToken();
logicalinclusiveorExpression();
}
private void additiveExpression() throws CoreException {
do {
concatenationExpression();
- if (token != TokenNameADD && token != TokenNameSUBTRACT) {
+ if (token != TokenNamePLUS && token != TokenNameMINUS) {
return;
}
getNextToken();
private void relationalExpression() throws CoreException {
do {
shiftExpression();
- if (token != TokenNameLESS && token != TokenNameGREATER && token != TokenNameLESSEQUAL && token != TokenNameGREATEREQUAL) {
+ if (token != TokenNameLESS && token != TokenNameGREATER && token != TokenNameLESS_EQUAL && token != TokenNameGREATER_EQUAL) {
return;
}
getNextToken();
private void identicalExpression() throws CoreException {
do {
relationalExpression();
- if (token != TokenNameEX_EQUAL && token != TokenNameEX_UNEQUAL) {
+ if (token != TokenNameEQUAL_EQUAL_EQUAL && token != TokenNameNOT_EQUAL_EQUAL) {
return;
}
getNextToken();
private void equalityExpression() throws CoreException {
do {
identicalExpression();
- if (token != TokenNameEQUAL && token != TokenNameUNEQUAL) {
+ if (token != TokenNameEQUAL_EQUAL && token != TokenNameNOT_EQUAL) {
return;
}
getNextToken();
private void ternaryExpression() throws CoreException {
equalityExpression();
- if (token == TokenNameQUESTIONMARK) {
+ if (token == TokenNameQUESTION) {
getNextToken();
expression();
- if (token == TokenNameDDOT) {
+ if (token == TokenNameCOLON) {
getNextToken();
expression();
} else {
private void andExpression() throws CoreException {
do {
ternaryExpression();
- if (token != TokenNameAMPERSAND) {
+ if (token != TokenNameAND) {
return;
}
getNextToken();
private void inclusiveorExpression() throws CoreException {
do {
exclusiveorExpression();
- if (token != TokenNameLINE) {
+ if (token != TokenNameOR) {
return;
}
getNextToken();
private void booleanandExpression() throws CoreException {
do {
inclusiveorExpression();
- if (token != TokenNameAND) {
+ if (token != TokenNameAND_AND) {
return;
}
getNextToken();
private void booleanorExpression() throws CoreException {
do {
booleanandExpression();
- if (token != TokenNameOR) {
+ if (token != TokenNameOR_OR) {
return;
}
getNextToken();
getNextToken();
expression();
;
- if (token != TokenNameLISTCLOSE) {
+ if (token != TokenNameRBRACE) {
throwSyntaxError("'}' expected after indirect variable token '${'.");
}
getNextToken();
} else {
- if (token == TokenNameVARIABLE) {
+ if (token == TokenNameVariable) {
getNextToken();
- if (token == TokenNamePARTOPEN) {
+ if (token == TokenNameLBRACKET) {
getNextToken();
expression();
- if (token != TokenNamePARTCLOSE) {
+ if (token != TokenNameRBRACKET) {
throwSyntaxError("']' expected in variable-list.");
}
getNextToken();
- } else if (token == TokenNameASSIGN) {
+ } else if (token == TokenNameEQUAL) {
getNextToken();
constant();
}
private void constant() throws CoreException {
String ident;
switch (token) {
- case TokenNameADD :
+ case TokenNamePLUS :
getNextToken();
switch (token) {
- case TokenNameDOUBLE_NUMBER :
+ case TokenNameDoubleLiteral :
getNextToken();
break;
- case TokenNameINT_NUMBER :
+ case TokenNameIntegerLiteral :
getNextToken();
break;
default :
throwSyntaxError("Constant expected after '+' presign.");
}
break;
- case TokenNameSUBTRACT :
+ case TokenNameMINUS :
getNextToken();
switch (token) {
- case TokenNameDOUBLE_NUMBER :
+ case TokenNameDoubleLiteral :
getNextToken();
break;
- case TokenNameINT_NUMBER :
+ case TokenNameIntegerLiteral :
getNextToken();
break;
default :
case TokenNametrue :
getNextToken();
break;
- case TokenNameIDENTIFIER :
+ case TokenNameIdentifier :
ident = identifier;
getNextToken();
- if (token == TokenNameARGOPEN) {
+ if (token == TokenNameLPAREN) {
getNextToken();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
expressionList();
- if (token != TokenNameARGCLOSE) {
+ if (token != TokenNameRPAREN) {
throwSyntaxError("')' expected after identifier '" + ident + "' in postfix-expression.");
}
}
getNextToken();
}
break;
- case TokenNameSTRING_CONSTANT :
+ case TokenNameStringConstant :
getNextToken();
break;
- case TokenNameINTERPOLATED_STRING :
+ case TokenNameStringInterpolated :
getNextToken();
break;
- case TokenNameDOUBLE_NUMBER :
+ case TokenNameDoubleLiteral :
getNextToken();
break;
- case TokenNameINT_NUMBER :
+ case TokenNameIntegerLiteral :
getNextToken();
break;
default :