home *** CD-ROM | disk | FTP | other *** search
- package com.netscape.javascript;
-
- import java.io.IOException;
- import java.io.Reader;
- import java.util.Hashtable;
-
- public class TokenStream {
- public static final int TSF_ERROR = 1;
- public static final int TSF_NEWLINES = 4;
- public static final int TSF_FUNCTION = 8;
- public static final int TSF_RETURN_EXPR = 16;
- public static final int TSF_RETURN_VOID = 32;
- public static final int TSF_REGEXP = 512;
- private static final int EOF_CHAR = -1;
- public static final int ERROR = -1;
- public static final int EOF = 0;
- public static final int EOL = 1;
- public static final int POPV = 2;
- public static final int ENTERWITH = 3;
- public static final int LEAVEWITH = 4;
- public static final int RETURN = 5;
- public static final int GOTO = 6;
- public static final int IFEQ = 7;
- public static final int IFNE = 8;
- public static final int DUP = 9;
- public static final int SETNAME = 10;
- public static final int BITOR = 11;
- public static final int BITXOR = 12;
- public static final int BITAND = 13;
- // $FF: renamed from: EQ int
- public static final int field_0 = 14;
- // $FF: renamed from: NE int
- public static final int field_1 = 15;
- // $FF: renamed from: LT int
- public static final int field_2 = 16;
- // $FF: renamed from: LE int
- public static final int field_3 = 17;
- // $FF: renamed from: GT int
- public static final int field_4 = 18;
- // $FF: renamed from: GE int
- public static final int field_5 = 19;
- public static final int LSH = 20;
- public static final int RSH = 21;
- public static final int URSH = 22;
- public static final int ADD = 23;
- public static final int SUB = 24;
- public static final int MUL = 25;
- public static final int DIV = 26;
- public static final int MOD = 27;
- public static final int BITNOT = 28;
- public static final int NEG = 29;
- public static final int NEW = 30;
- public static final int DELPROP = 31;
- public static final int TYPEOF = 32;
- public static final int NAMEINC = 33;
- public static final int PROPINC = 34;
- public static final int ELEMINC = 35;
- public static final int NAMEDEC = 36;
- public static final int PROPDEC = 37;
- public static final int ELEMDEC = 38;
- public static final int GETPROP = 39;
- public static final int SETPROP = 40;
- public static final int GETELEM = 41;
- public static final int SETELEM = 42;
- public static final int CALL = 43;
- public static final int NAME = 44;
- public static final int NUMBER = 45;
- public static final int STRING = 46;
- public static final int ZERO = 47;
- public static final int ONE = 48;
- public static final int NULL = 49;
- public static final int THIS = 50;
- public static final int FALSE = 51;
- public static final int TRUE = 52;
- public static final int SHEQ = 53;
- public static final int SHNE = 54;
- public static final int CLOSURE = 55;
- public static final int OBJECT = 56;
- public static final int POP = 57;
- public static final int POS = 58;
- public static final int VARINC = 59;
- public static final int VARDEC = 60;
- public static final int BINDNAME = 61;
- public static final int THROW = 62;
- // $FF: renamed from: IN int
- public static final int field_6 = 63;
- public static final int INSTANCEOF = 64;
- public static final int GOSUB = 65;
- public static final int RETSUB = 66;
- public static final int CALLSPECIAL = 67;
- public static final int GETTHIS = 68;
- public static final int NEWTEMP = 69;
- public static final int USETEMP = 70;
- public static final int GETBASE = 71;
- public static final int GETVAR = 72;
- public static final int SETVAR = 73;
- public static final int UNDEFINED = 74;
- public static final int TRY = 75;
- public static final int ENDTRY = 76;
- public static final int NEWSCOPE = 77;
- public static final int TYPEOFNAME = 78;
- public static final int ENUMINIT = 79;
- public static final int ENUMNEXT = 80;
- public static final int GETPROTO = 81;
- public static final int GETPARENT = 82;
- public static final int SETPROTO = 83;
- public static final int SETPARENT = 84;
- public static final int SCOPE = 85;
- public static final int GETSCOPEPARENT = 86;
- public static final int JTHROW = 87;
- public static final int SEMI = 88;
- // $FF: renamed from: LB int
- public static final int field_7 = 89;
- // $FF: renamed from: RB int
- public static final int field_8 = 90;
- // $FF: renamed from: LC int
- public static final int field_9 = 91;
- // $FF: renamed from: RC int
- public static final int field_10 = 92;
- // $FF: renamed from: LP int
- public static final int field_11 = 93;
- // $FF: renamed from: RP int
- public static final int field_12 = 94;
- public static final int COMMA = 95;
- public static final int ASSIGN = 96;
- public static final int HOOK = 97;
- public static final int COLON = 98;
- // $FF: renamed from: OR int
- public static final int field_13 = 99;
- public static final int AND = 100;
- public static final int EQOP = 101;
- public static final int RELOP = 102;
- public static final int SHOP = 103;
- public static final int UNARYOP = 104;
- public static final int INC = 105;
- public static final int DEC = 106;
- public static final int DOT = 107;
- public static final int PRIMARY = 108;
- public static final int FUNCTION = 109;
- public static final int EXPORT = 110;
- public static final int IMPORT = 111;
- // $FF: renamed from: IF int
- public static final int field_14 = 112;
- public static final int ELSE = 113;
- public static final int SWITCH = 114;
- public static final int CASE = 115;
- public static final int DEFAULT = 116;
- public static final int WHILE = 117;
- // $FF: renamed from: DO int
- public static final int field_15 = 118;
- public static final int FOR = 119;
- public static final int BREAK = 120;
- public static final int CONTINUE = 121;
- public static final int VAR = 122;
- public static final int WITH = 123;
- public static final int CATCH = 124;
- public static final int FINALLY = 125;
- public static final int RESERVED = 126;
- public static final int NOP = 127;
- public static final int NOT = 128;
- public static final int PRE = 129;
- public static final int POST = 130;
- public static final int VOID = 131;
- public static final int BLOCK = 132;
- public static final int ARRAYLIT = 133;
- public static final int OBJLIT = 134;
- public static final int LABEL = 135;
- public static final int TARGET = 136;
- public static final int LOOP = 137;
- public static final int ENUMDONE = 138;
- public static final int EXPRSTMT = 139;
- public static final int PARENT = 140;
- public static final int CONVERT = 141;
- public static final int JSR = 142;
- public static final int NEWLOCAL = 143;
- public static final int USELOCAL = 144;
- public static final int SCRIPT = 145;
- private static String[] names;
- private static Hashtable keywords;
- // $FF: renamed from: in com.netscape.javascript.LineBuffer
- private LineBuffer field_16;
- public int flags;
- public String regExpFlags;
- private String sourceName;
- private String line;
- private int pushbackToken;
- private int tokenno;
- // $FF: renamed from: op int
- private int field_17;
- private String string = "";
- private Number number;
-
- static boolean isJSSpace(int var0) {
- return var0 == 9 || var0 == 11 || var0 == 12 || var0 == 32;
- }
-
- public Number getNumber() {
- return this.number;
- }
-
- private static void checkNames() {
- }
-
- public boolean matchToken(int var1) throws IOException {
- int var2 = this.getToken();
- if (var2 == var1) {
- return true;
- } else {
- this.tokenno += -1;
- this.pushbackToken = var2;
- return false;
- }
- }
-
- public int getToken() throws IOException {
- ++this.tokenno;
- if ((this.flags & 1) != 0) {
- return -1;
- } else if (this.pushbackToken != 0) {
- int var26 = this.pushbackToken;
- this.pushbackToken = 0;
- return var26;
- } else {
- int var1;
- do {
- var1 = this.field_16.read();
- } while((var1 != 10 || (this.flags & 4) == 0) && (isJSSpace(var1) || var1 == 10));
-
- if (var1 == -1) {
- return 0;
- } else if (isJSIdentifierStart(var1)) {
- this.field_16.startString();
-
- do {
- var1 = this.field_16.read();
- } while(isJSIdentifierPart(var1));
-
- this.field_16.unread();
- String var30 = this.field_16.getString();
- int var25;
- if ((var25 = this.stringToKeyword(var30)) != 0) {
- return var25;
- } else {
- this.string = var30;
- return 44;
- }
- } else if (isDigit(var1) || var1 == 46 && isDigit(this.field_16.peek())) {
- byte var24 = 10;
- this.field_16.startString();
- double var28 = ScriptRuntime.NaN;
- long var39 = 0L;
- boolean var41 = true;
- if (var1 == 48) {
- var1 = this.field_16.read();
- if (var1 != 120 && var1 != 88) {
- if (isDigit(var1)) {
- if (var1 < 56) {
- var24 = 8;
- this.field_16.startString();
- } else {
- Object[] var42 = new Object[]{String.valueOf((char)var1)};
- Context.reportWarning(Context.getMessage("msg.bad.octal.literal", var42), this.getSourceName(), this.field_16.getLineno(), this.getLine(), this.getOffset());
- }
- }
- } else {
- var1 = this.field_16.read();
- var24 = 16;
- this.field_16.startString();
- }
- }
-
- while(isXDigit(var1) && (var24 >= 16 || !isAlpha(var1) && (var24 != 8 || var1 < 56))) {
- var1 = this.field_16.read();
- }
-
- if (var24 == 10 && (var1 == 46 || var1 == 101 || var1 == 69)) {
- var41 = false;
- if (var1 == 46) {
- do {
- var1 = this.field_16.read();
- } while(isDigit(var1));
- }
-
- if (var1 == 101 || var1 == 69) {
- var1 = this.field_16.read();
- if (var1 == 43 || var1 == 45) {
- var1 = this.field_16.read();
- }
-
- if (!isDigit(var1)) {
- this.field_16.getString();
- this.reportError("msg.missing.exponent", (Object[])null);
- return -1;
- }
-
- do {
- var1 = this.field_16.read();
- } while(isDigit(var1));
- }
- }
-
- this.field_16.unread();
- String var43 = this.field_16.getString();
- if (var24 == 10 && !var41) {
- try {
- var28 = Double.valueOf(var43);
- } catch (NumberFormatException var11) {
- Object[] var10 = new Object[]{((Throwable)var11).getMessage()};
- this.reportError("msg.caught.nfe", var10);
- return -1;
- }
- } else {
- var28 = ScriptRuntime.stringToNumber(var43, 0, var24);
- var39 = (long)var28;
- if ((double)var39 != var28) {
- var41 = false;
- }
- }
-
- if (!var41) {
- this.number = new Double(var28);
- } else if (-128L <= var39 && var39 <= 127L) {
- this.number = new Byte((byte)((int)var39));
- } else if (-32768L <= var39 && var39 <= 32767L) {
- this.number = new Short((short)((int)var39));
- } else if (-2147483648L <= var39 && var39 <= 2147483647L) {
- this.number = new Integer((int)var39);
- } else {
- this.number = new Double((double)var39);
- }
-
- return 45;
- } else if (var1 != 34 && var1 != 39) {
- switch (var1) {
- case 10:
- return 1;
- case 33:
- if (this.field_16.match('=')) {
- if (this.field_16.match('=')) {
- this.field_17 = 54;
- } else {
- this.field_17 = 15;
- }
-
- return 101;
- }
-
- this.field_17 = 128;
- return 104;
- case 37:
- this.field_17 = 27;
- if (this.field_16.match('=')) {
- return 96;
- }
-
- return 27;
- case 38:
- if (this.field_16.match('&')) {
- return 100;
- } else {
- if (this.field_16.match('=')) {
- this.field_17 = 13;
- return 96;
- }
-
- return 13;
- }
- case 40:
- return 93;
- case 41:
- return 94;
- case 42:
- if (this.field_16.match('=')) {
- this.field_17 = 25;
- return 96;
- }
-
- return 25;
- case 43:
- case 45:
- if (this.field_16.match('=')) {
- if (var1 == 43) {
- this.field_17 = 23;
- return 96;
- }
-
- this.field_17 = 24;
- return 96;
- } else if (this.field_16.match((char)var1)) {
- if (var1 == 43) {
- return 105;
- }
-
- return 106;
- } else {
- if (var1 == 45) {
- return 24;
- }
-
- return 23;
- }
- case 44:
- return 95;
- case 46:
- return 107;
- case 47:
- if (this.field_16.match('/')) {
- while((var1 = this.field_16.read()) != -1 && var1 != 10) {
- }
-
- this.field_16.unread();
- return this.getToken();
- } else if (this.field_16.match('*')) {
- while((var1 = this.field_16.read()) != -1 && (var1 != 42 || !this.field_16.match('/'))) {
- if (var1 != 10 && var1 == 47 && this.field_16.match('*')) {
- if (this.field_16.match('/')) {
- return this.getToken();
- }
-
- this.reportError("msg.nested.comment", (Object[])null);
- return -1;
- }
- }
-
- if (var1 == -1) {
- this.reportError("msg.unterminated.comment", (Object[])null);
- return -1;
- } else {
- return this.getToken();
- }
- } else if ((this.flags & 512) == 0) {
- if (this.field_16.match('=')) {
- this.field_17 = 26;
- return 96;
- } else {
- return 26;
- }
- } else {
- StringBuffer var23;
- for(var23 = new StringBuffer(); (var1 = this.field_16.read()) != 47; var23.append((char)var1)) {
- if (var1 == 10 || var1 == -1) {
- this.field_16.unread();
- this.reportError("msg.unterminated.re.lit", (Object[])null);
- return -1;
- }
-
- if (var1 == 92) {
- var23.append((char)var1);
- var1 = this.field_16.read();
- }
- }
-
- StringBuffer var27 = new StringBuffer();
-
- while(true) {
- while(!this.field_16.match('g')) {
- if (!this.field_16.match('i')) {
- if (isAlpha(this.field_16.peek())) {
- this.reportError("msg.invalid.re.flag", (Object[])null);
- return -1;
- }
-
- this.string = var23.toString();
- this.regExpFlags = var27.toString();
- return 56;
- }
-
- var27.append('i');
- }
-
- var27.append('g');
- }
- }
- case 58:
- return 98;
- case 59:
- return 88;
- case 60:
- if (this.field_16.match('!')) {
- if (this.field_16.match('-')) {
- if (this.field_16.match('-')) {
- while((var1 = this.field_16.read()) != -1 && var1 != 10) {
- }
-
- this.field_16.unread();
- return this.getToken();
- }
-
- this.field_16.unread();
- }
-
- this.field_16.unread();
- }
-
- if (this.field_16.match('<')) {
- if (this.field_16.match('=')) {
- this.field_17 = 20;
- return 96;
- }
-
- this.field_17 = 20;
- return 103;
- } else {
- if (this.field_16.match('=')) {
- this.field_17 = 17;
- return 102;
- }
-
- this.field_17 = 16;
- return 102;
- }
- case 61:
- if (this.field_16.match('=')) {
- if (this.field_16.match('=')) {
- this.field_17 = 53;
- } else {
- this.field_17 = 14;
- }
-
- return 101;
- }
-
- this.field_17 = 127;
- return 96;
- case 62:
- if (this.field_16.match('>')) {
- if (this.field_16.match('>')) {
- if (this.field_16.match('=')) {
- this.field_17 = 22;
- return 96;
- }
-
- this.field_17 = 22;
- return 103;
- } else {
- if (this.field_16.match('=')) {
- this.field_17 = 21;
- return 96;
- }
-
- this.field_17 = 21;
- return 103;
- }
- } else {
- if (this.field_16.match('=')) {
- this.field_17 = 19;
- return 102;
- }
-
- this.field_17 = 18;
- return 102;
- }
- case 63:
- return 97;
- case 91:
- return 89;
- case 93:
- return 90;
- case 94:
- if (this.field_16.match('=')) {
- this.field_17 = 12;
- return 96;
- }
-
- return 12;
- case 123:
- return 91;
- case 124:
- if (this.field_16.match('|')) {
- return 99;
- } else {
- if (this.field_16.match('=')) {
- this.field_17 = 11;
- return 96;
- }
-
- return 11;
- }
- case 125:
- return 92;
- case 126:
- this.field_17 = 28;
- return 104;
- default:
- this.reportError("msg.illegal.character", (Object[])null);
- return -1;
- }
- } else {
- StringBuffer var2 = null;
- int var3 = var1;
- int var4 = 0;
- var1 = this.field_16.read();
- this.field_16.startString();
-
- for(; var1 != var3; var1 = this.field_16.read()) {
- if (var1 == 10 || var1 == -1) {
- this.field_16.unread();
- this.field_16.getString();
- this.reportError("msg.unterminated.string.lit", (Object[])null);
- return -1;
- }
-
- if (var1 == 92) {
- if (var2 == null) {
- this.field_16.unread();
- var2 = new StringBuffer(this.field_16.getString());
- this.field_16.read();
- }
-
- switch (var1 = this.field_16.read()) {
- case 98:
- var1 = 8;
- break;
- case 102:
- var1 = 12;
- break;
- case 110:
- var1 = 10;
- break;
- case 114:
- var1 = 13;
- break;
- case 116:
- var1 = 9;
- break;
- case 118:
- var1 = 11;
- break;
- default:
- if (isDigit(var1) && var1 < 56) {
- var4 = var1 - 48;
- var1 = this.field_16.read();
- if (isDigit(var1) && var1 < 56) {
- var4 = 8 * var4 + var1 - 48;
- var1 = this.field_16.read();
- if (isDigit(var1) && var1 < 56) {
- var4 = 8 * var4 + var1 - 48;
- var1 = this.field_16.read();
- }
- }
-
- this.field_16.unread();
- if (var4 > 255) {
- this.reportError("msg.oct.esc.too.large", (Object[])null);
- return -1;
- }
-
- var1 = var4;
- } else if (var1 == 117) {
- int var5 = this.field_16.read();
- if (!isXDigit(var5)) {
- this.field_16.unread();
- var1 = 117;
- } else {
- var4 = Character.digit((char)var5, 16);
- int var6 = this.field_16.read();
- if (!isXDigit(var6)) {
- this.field_16.unread();
- var2.append('u');
- var1 = var5;
- } else {
- var4 = 16 * var4 + Character.digit((char)var6, 16);
- int var7 = this.field_16.read();
- if (!isXDigit(var7)) {
- this.field_16.unread();
- var2.append('u');
- var2.append((char)var5);
- var1 = var6;
- } else {
- var4 = 16 * var4 + Character.digit((char)var7, 16);
- int var8 = this.field_16.read();
- if (!isXDigit(var8)) {
- this.field_16.unread();
- var2.append('u');
- var2.append((char)var5);
- var2.append((char)var6);
- var1 = var7;
- } else {
- var4 = 16 * var4 + Character.digit((char)var8, 16);
- var1 = var4;
- }
- }
- }
- }
- } else if (var1 == 120) {
- int var38 = this.field_16.read();
- if (!isXDigit(var38)) {
- this.field_16.unread();
- var1 = 120;
- } else {
- var4 = Character.digit((char)var38, 16);
- int var40 = this.field_16.read();
- if (!isXDigit(var40)) {
- this.field_16.unread();
- var2.append('x');
- var1 = var38;
- } else {
- var4 = 16 * var4 + Character.digit((char)var40, 16);
- var1 = var4;
- }
- }
- }
- }
- }
-
- if (var2 != null) {
- var2.append((char)var1);
- }
- }
-
- if (var2 != null) {
- this.string = var2.toString();
- } else {
- this.field_16.unread();
- this.string = this.field_16.getString();
- this.field_16.read();
- }
-
- return 46;
- }
- }
- }
-
- public String getLine() {
- return this.field_16.getLine();
- }
-
- public String tokenToString(int var1) {
- return "";
- }
-
- public TokenStream(Reader var1, String var2, int var3) {
- this.field_16 = new LineBuffer(var1, var3);
- this.pushbackToken = 0;
- this.sourceName = var2;
- this.flags = 0;
- }
-
- public int peekToken() throws IOException {
- int var1 = this.getToken();
- this.pushbackToken = var1;
- this.tokenno += -1;
- return var1;
- }
-
- public int peekTokenSameLine() throws IOException {
- this.flags |= 4;
- int var1 = this.peekToken();
- this.flags &= -5;
- if (this.pushbackToken == 1) {
- this.pushbackToken = 0;
- }
-
- return var1;
- }
-
- static boolean isDigit(int var0) {
- return var0 >= 48 && var0 <= 57;
- }
-
- static boolean isXDigit(int var0) {
- return var0 >= 48 && var0 <= 57 || var0 >= 97 && var0 <= 102 || var0 >= 65 && var0 <= 70;
- }
-
- public String getString() {
- return this.string;
- }
-
- public String getSourceName() {
- return this.sourceName;
- }
-
- private int stringToKeyword(String var1) {
- Integer var2 = (Integer)keywords.get(var1);
- if (var2 == null) {
- return 0;
- } else {
- int var3 = var2;
- this.field_17 = var3 >> 8;
- return var3 & 255;
- }
- }
-
- public int getOp() {
- return this.field_17;
- }
-
- public boolean eof() {
- return this.field_16.eof();
- }
-
- public static String tokenToName(int var0) {
- checkNames();
- return names == null ? "" : names[var0 + 1];
- }
-
- public int getLineno() {
- return this.field_16.getLineno();
- }
-
- public int getTokenno() {
- return this.tokenno;
- }
-
- private void reportError(String var1, Object[] var2) {
- this.flags |= 1;
- String var3 = Context.getMessage(var1, var2);
- Context.reportError(var3, this.getSourceName(), this.getLineno(), this.getLine(), this.getOffset());
- }
-
- static {
- String[] var0 = new String[]{"break", "case", "continue", "default", "delete", "do", "else", "export", "false", "for", "function", "if", "in", "new", "null", "return", "switch", "this", "true", "typeof", "var", "void", "while", "with", "abstract", "boolean", "byte", "catch", "char", "class", "const", "debugger", "double", "enum", "extends", "final", "finally", "float", "goto", "implements", "import", "instanceof", "int", "interface", "long", "native", "package", "private", "protected", "public", "short", "static", "super", "synchronized", "throw", "throws", "transient", "try", "volatile"};
- int[] var1 = new int[]{120, 115, 121, 116, 31, 118, 113, 110, 13164, 119, 109, 112, 16230, 30, 12652, 5, 114, 12908, 13420, 8296, 122, 33640, 117, 123, 126, 126, 126, 124, 126, 126, 126, 126, 126, 126, 126, 126, 125, 126, 126, 126, 111, 16486, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 32620, 126, 62, 126, 126, 75, 126};
- keywords = new Hashtable(var0.length);
- Integer var2 = new Integer(126);
-
- for(int var3 = 0; var3 < var0.length; ++var3) {
- keywords.put(var0[var3], var1[var3] == 126 ? var2 : new Integer(var1[var3]));
- }
-
- }
-
- protected static boolean isJSIdentifierStart(int var0) {
- return var0 >= 97 && var0 <= 122 || var0 >= 65 && var0 <= 90 || var0 == 95 || var0 == 36;
- }
-
- protected static boolean isJSIdentifier(String var0) {
- int var1 = var0.length();
- if (var1 != 0 && isJSIdentifierStart(var0.charAt(0))) {
- for(int var2 = 1; var2 < var1; ++var2) {
- if (!isJSIdentifierPart(var0.charAt(var2))) {
- return false;
- }
- }
-
- return true;
- } else {
- return false;
- }
- }
-
- public void clearPushback() {
- this.pushbackToken = 0;
- }
-
- public void ungetToken(int var1) {
- if (this.pushbackToken != 0 && var1 != -1) {
- Object[] var2 = new Object[]{this.tokenToString(var1), this.tokenToString(this.pushbackToken)};
- String var3 = Context.getMessage("msg.token.replaces.pushback", var2);
- throw new RuntimeException(var3);
- } else {
- this.pushbackToken = var1;
- this.tokenno += -1;
- }
- }
-
- public int getOffset() {
- return this.field_16.getOffset();
- }
-
- protected static boolean isJSIdentifierPart(int var0) {
- return var0 >= 97 && var0 <= 122 || var0 >= 65 && var0 <= 90 || var0 >= 48 && var0 <= 57 || var0 == 95 || var0 == 36;
- }
-
- private static boolean isAlpha(int var0) {
- return var0 >= 97 && var0 <= 122 || var0 >= 65 && var0 <= 90;
- }
- }
-