- private int getKeyword(String s) throws IOException {
- char c;
- switch (s.length()) {
- case 2: c=s.charAt(1);
- if (c=='f') { if (s.charAt(0)=='i') return IF; }
- else if (c=='n') { if (s.charAt(0)=='i') return IN; }
- else if (c=='o') { if (s.charAt(0)=='d') return DO; }
- break;
- case 3: switch (s.charAt(0)) {
- case 'a': if (s.charAt(2)=='d' && s.charAt(1)=='n') return AND; break;
- case 'f': if (s.charAt(2)=='r' && s.charAt(1)=='o') return FOR; break;
- case 'i': if (s.charAt(2)=='t' && s.charAt(1)=='n') return RESERVED;
- case 'n': if (s.charAt(2)=='w' && s.charAt(1)=='e') return RESERVED;
- case 't': if (s.charAt(2)=='y' && s.charAt(1)=='r') return TRY; break;
- case 'v': if (s.charAt(2)=='r' && s.charAt(1)=='a') return VAR; break;
- } break;
- case 4: switch (s.charAt(0)) {
- case 'b': return s.equals("byte") ? RESERVED : -1;
- case 'c': c=s.charAt(3);
- if (c=='e') { if (s.charAt(2)=='s' && s.charAt(1)=='a') return CASE; }
- else if (c=='r') { if (s.charAt(2)=='a' && s.charAt(1)=='h') return RESERVED; }
- return -1;
- case 'e': c=s.charAt(3);
- if (c=='e') { if (s.charAt(2)=='s' && s.charAt(1)=='l') return ELSE; }
- else if (c=='m') { if (s.charAt(2)=='u' && s.charAt(1)=='n') return RESERVED; }
- return -1;
- case 'g': return s.equals("goto") ? RESERVED : -1;
- case 'l': return s.equals("long") ? RESERVED : -1;
- case 'n': return s.equals("null") ? NULL : -1;
- case 't': c=s.charAt(3);
- if (c=='e') { if (s.charAt(2)=='u' && s.charAt(1)=='r') return TRUE; }
- else if (c=='s') { if (s.charAt(2)=='i' && s.charAt(1)=='h') return THIS; }
- return -1;
- case 'w': if (s.equals("with")) return RESERVED; else return -1;
- case 'v': if (s.equals("void")) return RESERVED; else return -1;
- } break;
- case 5: switch (s.charAt(2)) {
- case 'a': return s.equals("class") ? RESERVED : -1;
- case 'e': return s.equals("break") ? BREAK : -1;
- case 'i': return s.equals("while") ? WHILE : -1;
- case 'l': return s.equals("false") ? FALSE : -1;
- case 'n': c=s.charAt(0);
- if (s.equals("const")) return RESERVED;
- else if (s.equals("final")) return RESERVED;
- return -1;
- case 'o': c=s.charAt(0);
- if (c == 'c') return s.equals("float") ? RESERVED : -1;
- else if (c=='s') return s.equals("final") ? RESERVED : -1;
- break;
- case 'p': return s.equals("super") ? RESERVED : -1;
- case 'r': return s.equals("throw") ? THROW : -1;
- case 't': return s.equals("catch") ? CATCH : -1;
- } break;
- case 6: switch (s.charAt(1)) {
- case 'a': return s.equals("class") ? RESERVED : -1;
- case 'e': c=s.charAt(0);
- if (s.equals("delete")) return RESERVED;
- else if (c=='r') return s.equals("return") ? RETURN : -1;
- break;
- case 'h': return s.equals("throws") ? RESERVED : -1;
- case 'o': return s.equals("double") ? RESERVED : -1;
- case 's': return s.equals("assert") ? ASSERT : -1;
- case 'u': return s.equals("public") ? RESERVED : -1;
- case 'w': return s.equals("switch") ? SWITCH : -1;
- case 'y': return s.equals("typeof") ? TYPEOF : -1;
- } break;
- case 7: switch (s.charAt(1)) {
- case 'a': return s.equals("package") ? RESERVED : -1;
- case 'e': return s.equals("default") ? DEFAULT : -1;
- case 'i': return s.equals("finally") ? FINALLY : -1;
- case 'o': return s.equals("boolean") ? RESERVED : -1;
- case 'r': return s.equals("private") ? RESERVED : -1;
- case 'x': return s.equals("extends") ? RESERVED : -1;
- } break;
- case 8: switch (s.charAt(0)) {
- case 'a': return s.equals("abstract") ? RESERVED : -1;
- case 'c': return s.equals("continue") ? CONTINUE : -1;
- case 'd': return s.equals("debugger") ? RESERVED : -1;
- case 'f': return s.equals("function") ? FUNCTION : -1;
- case 'v': return s.equals("volatile") ? RESERVED : -1;
- } break;
- case 9: c=s.charAt(0);
- if (c=='i') return s.equals("interface") ? RESERVED : -1;
- else if (c=='p') return s.equals("protected") ? RESERVED : -1;
- else if (c=='t') return s.equals("transient") ? RESERVED : -1;
- break;
- case 10: c=s.charAt(1);
- if (c=='m') return s.equals("implements") ? RESERVED : -1;
- else if (c=='n' && s.equals("instanceof")) return RESERVED;
- break;
- case 12: return s.equals("synchronized") ? RESERVED : -1;
- }
- return -1;
+ private int getKeyword(String name) throws IOException {
+ //#switch(name)
+ case "if": return IF;
+ case "lt": return LT;
+ case "gt": return GT;
+ case "in": return IN;
+ case "do": return DO;
+ case "and": return AND;
+ case "for": return FOR;
+ case "int": return RESERVED;
+ case "new": return RESERVED;
+ case "try": return TRY;
+ case "var": return VAR;
+ case "byte": return RESERVED;
+ case "case": return CASE;
+ case "char": return RESERVED;
+ case "else": return ELSE;
+ case "enum": return RESERVED;
+ case "goto": return RESERVED;
+ case "long": return RESERVED;
+ case "null": return NULL;
+ case "true": return TRUE;
+ case "with": return RESERVED;
+ case "void": return RESERVED;
+ case "class": return RESERVED;
+ case "break": return BREAK;
+ case "while": return WHILE;
+ case "false": return FALSE;
+ case "const": return RESERVED;
+ case "final": return RESERVED;
+ case "super": return RESERVED;
+ case "throw": return THROW;
+ case "catch": return CATCH;
+ case "class": return RESERVED;
+ case "delete": return RESERVED;
+ case "return": return RETURN;
+ case "throws": return RESERVED;
+ case "double": return RESERVED;
+ case "assert": return ASSERT;
+ case "public": return RESERVED;
+ case "switch": return SWITCH;
+ case "typeof": return TYPEOF;
+ case "package": return RESERVED;
+ case "default": return DEFAULT;
+ case "finally": return FINALLY;
+ case "boolean": return RESERVED;
+ case "private": return RESERVED;
+ case "extends": return RESERVED;
+ case "abstract": return RESERVED;
+ case "continue": return CONTINUE;
+ case "debugger": return RESERVED;
+ case "function": return FUNCTION;
+ case "volatile": return RESERVED;
+ case "interface": return RESERVED;
+ case "protected": return RESERVED;
+ case "transient": return RESERVED;
+ case "implements": return RESERVED;
+ case "instanceof": return RESERVED;
+ case "synchronized": return RESERVED;
+ //#end
+ return -1;