From: bananeweizen Date: Sun, 23 Apr 2006 13:54:28 +0000 (+0000) Subject: bug 1434118, scanner had a faulty behavior scanning variable names like 'retur*' X-Git-Url: http://secure.phpeclipse.com?hp=56846a218cda4f2fedb6d51bc208d456918c88c3 bug 1434118, scanner had a faulty behavior scanning variable names like 'retur*' made scanner structure more fault resistant against similar bugs --- 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 9782a3e..b2ae4c6 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 @@ -3054,50 +3054,42 @@ public class Scanner implements IScanner, ITerminalSymbols { // as if ((data[++index] == 's')) { return TokenNameas; - } else { - return TokenNameIdentifier; } + return TokenNameIdentifier; case 3: // and if ((data[++index] == 'n') && (data[++index] == 'd')) { return TokenNameand; - } else { - return TokenNameIdentifier; } + return TokenNameIdentifier; case 5: // array if ((data[++index] == 'r') && (data[++index] == 'r') && (data[++index] == 'a') && (data[++index] == 'y')) return TokenNamearray; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 8: if ((data[++index] == 'b') && (data[++index] == 's') && (data[++index] == 't') && (data[++index] == 'r') && (data[++index] == 'a') && (data[++index] == 'c') && (data[++index] == 't')) return TokenNameabstract; - else - return TokenNameIdentifier; - default: return TokenNameIdentifier; } + return TokenNameIdentifier; case 'b': // break switch (length) { case 5: if ((data[++index] == 'r') && (data[++index] == 'e') && (data[++index] == 'a') && (data[++index] == 'k')) return TokenNamebreak; - else - return TokenNameIdentifier; - default: return TokenNameIdentifier; } + return TokenNameIdentifier; case 'c': // case catch class clone const continue switch (length) { case 4: if ((data[++index] == 'a') && (data[++index] == 's') && (data[++index] == 'e')) return TokenNamecase; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 5: if ((data[++index] == 'a') && (data[++index] == 't') && (data[++index] == 'c') && (data[++index] == 'h')) return TokenNamecatch; @@ -3110,17 +3102,14 @@ public class Scanner implements IScanner, ITerminalSymbols { index = 0; if ((data[++index] == 'o') && (data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 't')) return TokenNameconst; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 8: if ((data[++index] == 'o') && (data[++index] == 'n') && (data[++index] == 't') && (data[++index] == 'i') && (data[++index] == 'n') && (data[++index] == 'u') && (data[++index] == 'e')) return TokenNamecontinue; - else - return TokenNameIdentifier; - default: return TokenNameIdentifier; } + return TokenNameIdentifier; case 'd': // declare default do die // TODO delete define ==> no keyword ! @@ -3128,8 +3117,7 @@ public class Scanner implements IScanner, ITerminalSymbols { case 2: if ((data[++index] == 'o')) return TokenNamedo; - else - return TokenNameIdentifier; + return TokenNameIdentifier; // case 6 : // if ((data[++index] == 'e') // && (data[++index] == 'f') @@ -3147,11 +3135,9 @@ public class Scanner implements IScanner, ITerminalSymbols { if ((data[++index] == 'e') && (data[++index] == 'f') && (data[++index] == 'a') && (data[++index] == 'u') && (data[++index] == 'l') && (data[++index] == 't')) return TokenNamedefault; - else - return TokenNameIdentifier; - default: return TokenNameIdentifier; } + return TokenNameIdentifier; case 'e': // echo else exit elseif extends eval switch (length) { @@ -3164,16 +3150,14 @@ public class Scanner implements IScanner, ITerminalSymbols { return TokenNameexit; else if ((data[index] == 'v') && (data[++index] == 'a') && (data[++index] == 'l')) return TokenNameeval; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 5: // endif empty if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'i') && (data[++index] == 'f')) return TokenNameendif; if ((data[index] == 'm') && (data[++index] == 'p') && (data[++index] == 't') && (data[++index] == 'y')) return TokenNameempty; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 6: // endfor if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'f') && (data[++index] == 'o') @@ -3182,28 +3166,24 @@ public class Scanner implements IScanner, ITerminalSymbols { else if ((data[index] == 'l') && (data[++index] == 's') && (data[++index] == 'e') && (data[++index] == 'i') && (data[++index] == 'f')) return TokenNameelseif; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 7: if ((data[++index] == 'x') && (data[++index] == 't') && (data[++index] == 'e') && (data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 's')) return TokenNameextends; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 8: // endwhile if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'w') && (data[++index] == 'h') && (data[++index] == 'i') && (data[++index] == 'l') && (data[++index] == 'e')) return TokenNameendwhile; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 9: // endswitch if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 's') && (data[++index] == 'w') && (data[++index] == 'i') && (data[++index] == 't') && (data[++index] == 'c') && (data[++index] == 'h')) return TokenNameendswitch; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 10: // enddeclare if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'd') && (data[++index] == 'e') @@ -3215,44 +3195,37 @@ public class Scanner implements IScanner, ITerminalSymbols { && (data[++index] == 'd') && (data[++index] == 'f') && (data[++index] == 'o') && (data[++index] == 'r') && (data[++index] == 'e') && (data[++index] == 'a') && (data[++index] == 'c') && (data[++index] == 'h')) return TokenNameendforeach; - else - return TokenNameIdentifier; - default: return TokenNameIdentifier; } + return TokenNameIdentifier; case 'f': // for false final function switch (length) { case 3: if ((data[++index] == 'o') && (data[++index] == 'r')) return TokenNamefor; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 5: // if ((data[++index] == 'a') && (data[++index] == 'l') // && (data[++index] == 's') && (data[++index] == 'e')) // return TokenNamefalse; if ((data[++index] == 'i') && (data[++index] == 'n') && (data[++index] == 'a') && (data[++index] == 'l')) return TokenNamefinal; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 7: // foreach if ((data[++index] == 'o') && (data[++index] == 'r') && (data[++index] == 'e') && (data[++index] == 'a') && (data[++index] == 'c') && (data[++index] == 'h')) return TokenNameforeach; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 8: // function if ((data[++index] == 'u') && (data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 't') && (data[++index] == 'i') && (data[++index] == 'o') && (data[++index] == 'n')) return TokenNamefunction; - else - return TokenNameIdentifier; - default: return TokenNameIdentifier; } + return TokenNameIdentifier; case 'g': // global if (length == 6) { @@ -3268,8 +3241,7 @@ public class Scanner implements IScanner, ITerminalSymbols { case 2: if (data[++index] == 'f') return TokenNameif; - else - return TokenNameIdentifier; + return TokenNameIdentifier; // case 3 : // if ((data[++index] == 'n') && (data[++index] == 't')) // return TokenNameint; @@ -3278,21 +3250,18 @@ public class Scanner implements IScanner, ITerminalSymbols { case 5: if ((data[++index] == 's') && (data[++index] == 's') && (data[++index] == 'e') && (data[++index] == 't')) return TokenNameisset; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 7: if ((data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'l') && (data[++index] == 'u') && (data[++index] == 'd') && (data[++index] == 'e')) return TokenNameinclude; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 9: // interface if ((data[++index] == 'n') && (data[++index] == 't') && (data[++index] == 'e') && (data[++index] == 'r') && (data[++index] == 'f') && (data[++index] == 'a') && (data[++index] == 'c') && (data[++index] == 'e')) return TokenNameinterface; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 10: // instanceof if ((data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 't') && (data[++index] == 'a') @@ -3303,18 +3272,15 @@ public class Scanner implements IScanner, ITerminalSymbols { && (data[++index] == 'm') && (data[++index] == 'e') && (data[++index] == 'n') && (data[++index] == 't') && (data[++index] == 's')) return TokenNameimplements; - else - return TokenNameIdentifier; + return TokenNameIdentifier; case 12: if ((data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'l') && (data[++index] == 'u') && (data[++index] == 'd') && (data[++index] == 'e') && (data[++index] == '_') && (data[++index] == 'o') && (data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'e')) return TokenNameinclude_once; - else - return TokenNameIdentifier; - default: return TokenNameIdentifier; } + return TokenNameIdentifier; case 'l': // list if (length == 4) { @@ -3329,17 +3295,15 @@ public class Scanner implements IScanner, ITerminalSymbols { case 3: if ((data[++index] == 'e') && (data[++index] == 'w')) return TokenNamenew; - else - return TokenNameIdentifier; + return TokenNameIdentifier; // case 4 : // if ((data[++index] == 'u') && (data[++index] == 'l') // && (data[++index] == 'l')) // return TokenNamenull; // else // return TokenNameIdentifier; - default: - return TokenNameIdentifier; } + return TokenNameIdentifier; case 'o': // or old_function if (length == 2) { @@ -3369,26 +3333,26 @@ public class Scanner implements IScanner, ITerminalSymbols { case 5: if ((data[++index] == 'r') && (data[++index] == 'i') && (data[++index] == 'n') && (data[++index] == 't')) { return TokenNameprint; - } else - return TokenNameIdentifier; + } + return TokenNameIdentifier; case 6: if ((data[++index] == 'u') && (data[++index] == 'b') && (data[++index] == 'l') && (data[++index] == 'i') && (data[++index] == 'c')) { return TokenNamepublic; - } else - return TokenNameIdentifier; + } + return TokenNameIdentifier; case 7: if ((data[++index] == 'r') && (data[++index] == 'i') && (data[++index] == 'v') && (data[++index] == 'a') && (data[++index] == 't') && (data[++index] == 'e')) { return TokenNameprivate; - } else - return TokenNameIdentifier; + } + return TokenNameIdentifier; case 9: if ((data[++index] == 'r') && (data[++index] == 'o') && (data[++index] == 't') && (data[++index] == 'e') && (data[++index] == 'c') && (data[++index] == 't') && (data[++index] == 'e') && (data[++index] == 'd')) { return TokenNameprotected; - } else - return TokenNameIdentifier; + } + return TokenNameIdentifier; } return TokenNameIdentifier; case 'r': @@ -3409,8 +3373,8 @@ public class Scanner implements IScanner, ITerminalSymbols { && (data[++index] == 'n') && (data[++index] == 'c') && (data[++index] == 'e')) { return TokenNamerequire_once; } - } else - return TokenNameIdentifier; + } + return TokenNameIdentifier; case 's': // self static switch switch (length) { @@ -3429,19 +3393,14 @@ public class Scanner implements IScanner, ITerminalSymbols { else if ((data[index] == 'w') && (data[++index] == 'i') && (data[++index] == 't') && (data[++index] == 'c') && (data[++index] == 'h')) return TokenNameswitch; - else - return TokenNameIdentifier; - default: - return TokenNameIdentifier; } + return TokenNameIdentifier; case 't': // try true throw switch (length) { case 3: if ((data[++index] == 'r') && (data[++index] == 'y')) return TokenNametry; - else - return TokenNameIdentifier; // case 4 : // if ((data[++index] == 'r') && (data[++index] == 'u') // && (data[++index] == 'e')) @@ -3451,55 +3410,41 @@ public class Scanner implements IScanner, ITerminalSymbols { case 5: if ((data[++index] == 'h') && (data[++index] == 'r') && (data[++index] == 'o') && (data[++index] == 'w')) return TokenNamethrow; - else - return TokenNameIdentifier; - default: - return TokenNameIdentifier; } + return TokenNameIdentifier; case 'u': // use unset switch (length) { case 3: if ((data[++index] == 's') && (data[++index] == 'e')) return TokenNameuse; - else - return TokenNameIdentifier; case 5: if ((data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 'e') && (data[++index] == 't')) return TokenNameunset; - else - return TokenNameIdentifier; - default: - return TokenNameIdentifier; } + return TokenNameIdentifier; case 'v': // var switch (length) { case 3: if ((data[++index] == 'a') && (data[++index] == 'r')) return TokenNamevar; - else - return TokenNameIdentifier; - default: - return TokenNameIdentifier; } + return TokenNameIdentifier; case 'w': // while switch (length) { case 5: if ((data[++index] == 'h') && (data[++index] == 'i') && (data[++index] == 'l') && (data[++index] == 'e')) return TokenNamewhile; - else - return TokenNameIdentifier; // case 6:if ( (data[++index] =='i') && (data[++index]=='d') && // (data[++index]=='e') && (data[++index]=='f')&& // (data[++index]=='p')) // return TokenNamewidefp ; // else // return TokenNameIdentifier; - default: - return TokenNameIdentifier; } + return TokenNameIdentifier; case 'x': // xor switch (length) { @@ -3508,12 +3453,10 @@ public class Scanner implements IScanner, ITerminalSymbols { return TokenNamexor; else return TokenNameIdentifier; - default: - return TokenNameIdentifier; } - default: return TokenNameIdentifier; } + return TokenNameIdentifier; } public int scanNumber(boolean dotPrefix) throws InvalidInputException {