home *** CD-ROM | disk | FTP | other *** search
- package sun.tools.java;
-
- import java.io.IOException;
- import java.io.InputStream;
-
- public class Scanner implements Constants {
- public static final int OFFSETINC = 1;
- public static final int LINEINC = 262144;
- public static final int EOF = -1;
- public Environment env;
- // $FF: renamed from: in sun.tools.java.ScannerInputStream
- protected ScannerInputStream field_0;
- public boolean scanComments = false;
- public int token;
- public int pos;
- public int prevPos;
- // $FF: renamed from: ch int
- protected int field_1;
- public char charValue;
- public int intValue;
- public long longValue;
- public float floatValue;
- public double doubleValue;
- public String stringValue;
- public Identifier idValue;
- public int radix;
- public String docComment;
- private int count;
- private char[] buffer = new char[32];
-
- private void putc(int var1) {
- if (this.count == this.buffer.length) {
- char[] var2 = new char[this.buffer.length * 2];
- System.arraycopy(this.buffer, 0, var2, 0, this.buffer.length);
- this.buffer = var2;
- }
-
- this.buffer[this.count++] = (char)var1;
- }
-
- private String bufferString() {
- char[] var1 = new char[this.count];
- System.arraycopy(this.buffer, 0, var1, 0, this.count);
- return new String(var1);
- }
-
- public Scanner(Environment var1, InputStream var2) throws IOException {
- this.env = var1;
- this.useInputStream(var2);
- }
-
- protected void useInputStream(InputStream var1) throws IOException {
- try {
- this.field_0 = new ScannerInputStream(this.env, var1);
- } catch (Exception var2) {
- this.env.setCharacterEncoding((String)null);
- this.field_0 = new ScannerInputStream(this.env, var1);
- }
-
- this.field_1 = this.field_0.read();
- this.prevPos = this.field_0.pos;
- this.scan();
- }
-
- protected Scanner(Environment var1) {
- this.env = var1;
- }
-
- private static void defineKeyword(int var0) {
- Identifier.lookup(Constants.opNames[var0]).setType(var0);
- }
-
- private void skipComment() throws IOException {
- while(true) {
- switch (this.field_1) {
- case -1:
- this.env.error(this.pos, "eof.in.comment");
- return;
- case 42:
- if ((this.field_1 = this.field_0.read()) != 47) {
- break;
- }
-
- this.field_1 = this.field_0.read();
- return;
- default:
- this.field_1 = this.field_0.read();
- }
- }
- }
-
- private String scanDocComment() throws IOException {
- this.count = 0;
- if (this.field_1 == 42) {
- do {
- this.field_1 = this.field_0.read();
- } while(this.field_1 == 42);
-
- if (this.field_1 == 47) {
- this.field_1 = this.field_0.read();
- return "";
- }
- }
-
- switch (this.field_1) {
- case 10:
- case 32:
- this.field_1 = this.field_0.read();
- default:
- boolean var1 = false;
- int var2 = this.count;
-
- while(true) {
- switch (this.field_1) {
- case -1:
- this.env.error(this.pos, "eof.in.comment");
- return this.bufferString();
- case 9:
- case 32:
- if (var1) {
- this.putc(this.field_1);
- }
-
- this.field_1 = this.field_0.read();
- break;
- case 10:
- this.putc(10);
- this.field_1 = this.field_0.read();
- var1 = false;
- var2 = this.count;
- break;
- case 42:
- if (var1) {
- if ((this.field_1 = this.field_0.read()) == 47) {
- this.field_1 = this.field_0.read();
- this.count = var2;
- return this.bufferString();
- }
-
- this.putc(42);
- break;
- } else {
- var1 = true;
- this.count = var2;
-
- while((this.field_1 = this.field_0.read()) == 42) {
- }
-
- switch (this.field_1) {
- case 47:
- this.field_1 = this.field_0.read();
- this.count = var2;
- return this.bufferString();
- }
- }
- default:
- if (!var1) {
- var1 = true;
- }
-
- this.putc(this.field_1);
- this.field_1 = this.field_0.read();
- var2 = this.count;
- }
- }
- }
- }
-
- private void scanNumber() throws IOException {
- boolean var1 = false;
- boolean var2 = false;
- this.radix = this.field_1 == 48 ? 8 : 10;
- long var3 = (long)(this.field_1 - 48);
- this.count = 0;
- this.putc(this.field_1);
-
- label136:
- while(true) {
- switch (this.field_1 = this.field_0.read()) {
- case 46:
- if (this.radix != 16) {
- this.scanReal();
- return;
- }
- break label136;
- case 48:
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- break;
- case 56:
- case 57:
- var1 = true;
- break;
- case 68:
- case 69:
- case 70:
- case 100:
- case 101:
- case 102:
- if (this.radix != 16) {
- this.scanReal();
- return;
- }
- case 65:
- case 66:
- case 67:
- case 97:
- case 98:
- case 99:
- this.putc(this.field_1);
- if (this.radix != 16) {
- break label136;
- }
-
- var2 = var2 || var3 >>> 60 != 0L;
- var3 = (var3 << 4) + 10L + (long)Character.toLowerCase((char)this.field_1) - 97L;
- continue;
- case 76:
- case 108:
- this.field_1 = this.field_0.read();
- this.longValue = var3;
- this.token = 66;
- break label136;
- case 88:
- case 120:
- if (this.count != 1 || this.radix != 8) {
- break label136;
- }
-
- this.radix = 16;
- continue;
- default:
- this.intValue = (int)var3;
- this.token = 65;
- break label136;
- }
-
- this.putc(this.field_1);
- if (this.radix == 10) {
- var2 = var2 || var3 * 10L / 10L != var3;
- var3 = var3 * 10L + (long)(this.field_1 - 48);
- var2 = var2 || var3 - 1L < -1L;
- } else if (this.radix == 8) {
- var2 = var2 || var3 >>> 61 != 0L;
- var3 = (var3 << 3) + (long)(this.field_1 - 48);
- } else {
- var2 = var2 || var3 >>> 60 != 0L;
- var3 = (var3 << 4) + (long)(this.field_1 - 48);
- }
- }
-
- if (!Character.isJavaLetterOrDigit((char)this.field_1) && this.field_1 != 46) {
- if (this.radix == 8 && var1) {
- this.intValue = 0;
- this.token = 65;
- this.env.error(this.field_0.pos, "invalid.octal.number");
- } else {
- if (!var2) {
- label145: {
- if (this.token != 65) {
- return;
- }
-
- boolean var10000;
- if (this.radix == 10) {
- if (this.intValue - 1 < -1) {
- break label145;
- }
-
- var10000 = false;
- } else {
- if ((var3 & -4294967296L) != 0L) {
- break label145;
- }
-
- var10000 = false;
- }
-
- if (!var10000) {
- return;
- }
- }
- }
-
- this.intValue = 0;
- this.longValue = 0L;
- this.env.error(this.pos, "overflow");
- }
- } else {
- this.env.error(this.field_0.pos, "invalid.number");
-
- do {
- this.field_1 = this.field_0.read();
- } while(Character.isJavaLetterOrDigit((char)this.field_1) || this.field_1 == 46);
-
- this.intValue = 0;
- this.token = 65;
- }
- }
-
- private void scanReal() throws IOException {
- boolean var1 = false;
- boolean var2 = false;
- if (this.field_1 == 46) {
- this.putc(this.field_1);
- this.field_1 = this.field_0.read();
- }
-
- label91:
- while(true) {
- switch (this.field_1) {
- case 43:
- case 45:
- char var3 = this.buffer[this.count - 1];
- if (var3 != 'e' && var3 != 'E') {
- break label91;
- }
-
- this.putc(this.field_1);
- break;
- case 48:
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- case 56:
- case 57:
- this.putc(this.field_1);
- break;
- case 68:
- case 100:
- this.field_1 = this.field_0.read();
- break label91;
- case 69:
- case 101:
- if (var1) {
- break label91;
- }
-
- this.putc(this.field_1);
- var1 = true;
- break;
- case 70:
- case 102:
- this.field_1 = this.field_0.read();
- var2 = true;
- default:
- break label91;
- }
-
- this.field_1 = this.field_0.read();
- }
-
- if (!Character.isJavaLetterOrDigit((char)this.field_1) && this.field_1 != 46) {
- this.token = var2 ? 67 : 68;
-
- try {
- char var6 = this.buffer[this.count - 1];
- if (var6 != 'e' && var6 != 'E' && var6 != '+' && var6 != '-') {
- if (var2) {
- String var7 = this.bufferString();
- this.floatValue = Float.valueOf(var7);
- if (Float.isInfinite(this.floatValue)) {
- this.env.error(this.pos, "overflow");
- return;
- }
-
- if (this.floatValue == 0.0F && !looksLikeZero(var7)) {
- this.env.error(this.pos, "underflow");
- return;
- }
- } else {
- String var4 = this.bufferString();
- this.doubleValue = Double.valueOf(var4);
- if (Double.isInfinite(this.doubleValue)) {
- this.env.error(this.pos, "overflow");
- return;
- }
-
- if (this.doubleValue != (double)0.0F || looksLikeZero(var4)) {
- return;
- }
-
- this.env.error(this.pos, "underflow");
- }
-
- } else {
- this.env.error(this.field_0.pos - 1, "float.format");
- }
- } catch (NumberFormatException var5) {
- this.env.error(this.pos, "float.format");
- this.doubleValue = (double)0.0F;
- this.floatValue = 0.0F;
- }
- } else {
- this.env.error(this.field_0.pos, "invalid.number");
-
- do {
- this.field_1 = this.field_0.read();
- } while(Character.isJavaLetterOrDigit((char)this.field_1) || this.field_1 == 46);
-
- this.doubleValue = (double)0.0F;
- this.token = 68;
- }
- }
-
- private static boolean looksLikeZero(String var0) {
- int var1 = var0.length();
-
- for(int var2 = 0; var2 < var1; ++var2) {
- switch (var0.charAt(var2)) {
- case '\u0000':
- case '.':
- default:
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- return false;
- case 'E':
- case 'F':
- case 'e':
- case 'f':
- return true;
- }
- }
-
- return true;
- }
-
- private int scanEscapeChar() throws IOException {
- int var1 = this.field_0.pos;
- switch (this.field_1 = this.field_0.read()) {
- case 34:
- this.field_1 = this.field_0.read();
- return 34;
- case 39:
- this.field_1 = this.field_0.read();
- return 39;
- case 48:
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- int var2 = this.field_1 - 48;
- int var3 = 2;
-
- while(var3 > 0) {
- switch (this.field_1 = this.field_0.read()) {
- case 48:
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- var2 = (var2 << 3) + this.field_1 - 48;
- --var3;
- break;
- default:
- if (var2 > 255) {
- this.env.error(var1, "invalid.escape.char");
- }
-
- return var2;
- }
- }
-
- this.field_1 = this.field_0.read();
- if (var2 > 255) {
- this.env.error(var1, "invalid.escape.char");
- }
-
- return var2;
- case 92:
- this.field_1 = this.field_0.read();
- return 92;
- case 98:
- this.field_1 = this.field_0.read();
- return 8;
- case 102:
- this.field_1 = this.field_0.read();
- return 12;
- case 110:
- this.field_1 = this.field_0.read();
- return 10;
- case 114:
- this.field_1 = this.field_0.read();
- return 13;
- case 116:
- this.field_1 = this.field_0.read();
- return 9;
- default:
- this.env.error(var1, "invalid.escape.char");
- this.field_1 = this.field_0.read();
- return -1;
- }
- }
-
- private void scanString() throws IOException {
- this.token = 69;
- this.count = 0;
- this.field_1 = this.field_0.read();
-
- while(true) {
- switch (this.field_1) {
- case -1:
- this.env.error(this.pos, "eof.in.string");
- this.stringValue = this.bufferString();
- return;
- case 10:
- this.field_1 = this.field_0.read();
- this.env.error(this.pos, "newline.in.string");
- this.stringValue = this.bufferString();
- return;
- case 34:
- this.field_1 = this.field_0.read();
- this.stringValue = this.bufferString();
- return;
- case 92:
- int var1 = this.scanEscapeChar();
- if (var1 >= 0) {
- this.putc((char)var1);
- }
- break;
- default:
- this.putc(this.field_1);
- this.field_1 = this.field_0.read();
- }
- }
- }
-
- private void scanCharacter() throws IOException {
- this.token = 63;
- switch (this.field_1 = this.field_0.read()) {
- case 10:
- this.charValue = 0;
- this.env.error(this.pos, "invalid.char.constant");
- return;
- case 92:
- int var1 = this.scanEscapeChar();
- this.charValue = (char)(var1 >= 0 ? var1 : 0);
- break;
- default:
- this.charValue = (char)this.field_1;
- this.field_1 = this.field_0.read();
- }
-
- if (this.field_1 == 39) {
- this.field_1 = this.field_0.read();
- } else {
- this.env.error(this.pos, "invalid.char.constant");
-
- while(true) {
- switch (this.field_1) {
- case -1:
- case 10:
- case 59:
- return;
- case 39:
- this.field_1 = this.field_0.read();
- return;
- default:
- this.field_1 = this.field_0.read();
- }
- }
- }
- }
-
- private void scanIdentifier() throws IOException {
- this.count = 0;
-
- while(true) {
- this.putc(this.field_1);
- switch (this.field_1 = this.field_0.read()) {
- case 36:
- case 48:
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- case 56:
- case 57:
- case 65:
- case 66:
- case 67:
- case 68:
- case 69:
- case 70:
- case 71:
- case 72:
- case 73:
- case 74:
- case 75:
- case 76:
- case 77:
- case 78:
- case 79:
- case 80:
- case 81:
- case 82:
- case 83:
- case 84:
- case 85:
- case 86:
- case 87:
- case 88:
- case 89:
- case 90:
- case 95:
- case 97:
- case 98:
- case 99:
- case 100:
- case 101:
- case 102:
- case 103:
- case 104:
- case 105:
- case 106:
- case 107:
- case 108:
- case 109:
- case 110:
- case 111:
- case 112:
- case 113:
- case 114:
- case 115:
- case 116:
- case 117:
- case 118:
- case 119:
- case 120:
- case 121:
- case 122:
- continue;
- }
-
- if (!Character.isJavaLetterOrDigit((char)this.field_1)) {
- this.idValue = Identifier.lookup(this.bufferString());
- this.token = this.idValue.getType();
- return;
- }
- }
- }
-
- public int getEndPos() {
- return this.field_0.pos;
- }
-
- public IdentifierToken getIdToken() {
- return this.token != 60 ? null : new IdentifierToken(this.pos, this.idValue);
- }
-
- public int scan() throws IOException {
- int var1 = this.xscan();
- return var1;
- }
-
- protected int xscan() throws IOException {
- int var1 = this.pos;
- this.prevPos = this.field_0.pos;
- this.docComment = null;
-
- while(true) {
- this.pos = this.field_0.pos;
- switch (this.field_1) {
- case -1:
- this.token = -1;
- return var1;
- case 10:
- if (this.scanComments) {
- this.field_1 = 32;
- this.token = 146;
- return var1;
- }
- case 9:
- case 12:
- case 32:
- this.field_1 = this.field_0.read();
- break;
- case 26:
- if ((this.field_1 = this.field_0.read()) == -1) {
- this.token = -1;
- return var1;
- }
-
- this.env.error(this.pos, "funny.char");
- this.field_1 = this.field_0.read();
- break;
- case 33:
- if ((this.field_1 = this.field_0.read()) == 61) {
- this.field_1 = this.field_0.read();
- this.token = 19;
- return var1;
- }
-
- this.token = 37;
- return var1;
- case 34:
- this.scanString();
- return var1;
- case 36:
- case 65:
- case 66:
- case 67:
- case 68:
- case 69:
- case 70:
- case 71:
- case 72:
- case 73:
- case 74:
- case 75:
- case 76:
- case 77:
- case 78:
- case 79:
- case 80:
- case 81:
- case 82:
- case 83:
- case 84:
- case 85:
- case 86:
- case 87:
- case 88:
- case 89:
- case 90:
- case 95:
- case 97:
- case 98:
- case 99:
- case 100:
- case 101:
- case 102:
- case 103:
- case 104:
- case 105:
- case 106:
- case 107:
- case 108:
- case 109:
- case 110:
- case 111:
- case 112:
- case 113:
- case 114:
- case 115:
- case 116:
- case 117:
- case 118:
- case 119:
- case 120:
- case 121:
- case 122:
- this.scanIdentifier();
- return var1;
- case 37:
- if ((this.field_1 = this.field_0.read()) == 61) {
- this.field_1 = this.field_0.read();
- this.token = 4;
- return var1;
- }
-
- this.token = 32;
- return var1;
- case 38:
- switch (this.field_1 = this.field_0.read()) {
- case 38:
- this.field_1 = this.field_0.read();
- this.token = 15;
- return var1;
- case 61:
- this.field_1 = this.field_0.read();
- this.token = 10;
- return var1;
- default:
- this.token = 18;
- return var1;
- }
- case 39:
- this.scanCharacter();
- return var1;
- case 40:
- this.field_1 = this.field_0.read();
- this.token = 140;
- return var1;
- case 41:
- this.field_1 = this.field_0.read();
- this.token = 141;
- return var1;
- case 42:
- if ((this.field_1 = this.field_0.read()) == 61) {
- this.field_1 = this.field_0.read();
- this.token = 2;
- return var1;
- }
-
- this.token = 33;
- return var1;
- case 43:
- switch (this.field_1 = this.field_0.read()) {
- case 43:
- this.field_1 = this.field_0.read();
- this.token = 50;
- return var1;
- case 61:
- this.field_1 = this.field_0.read();
- this.token = 5;
- return var1;
- default:
- this.token = 29;
- return var1;
- }
- case 44:
- this.field_1 = this.field_0.read();
- this.token = 0;
- return var1;
- case 45:
- switch (this.field_1 = this.field_0.read()) {
- case 45:
- this.field_1 = this.field_0.read();
- this.token = 51;
- return var1;
- case 61:
- this.field_1 = this.field_0.read();
- this.token = 6;
- return var1;
- default:
- this.token = 30;
- return var1;
- }
- case 46:
- switch (this.field_1 = this.field_0.read()) {
- case 48:
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- case 56:
- case 57:
- this.count = 0;
- this.putc(46);
- this.scanReal();
- break;
- default:
- this.token = 46;
- }
-
- return var1;
- case 47:
- switch (this.field_1 = this.field_0.read()) {
- case 42:
- this.field_1 = this.field_0.read();
- if (this.field_1 == 42) {
- this.docComment = this.scanDocComment();
- } else {
- this.skipComment();
- }
-
- if (this.scanComments) {
- return var1;
- }
- continue;
- case 47:
- while((this.field_1 = this.field_0.read()) != -1 && this.field_1 != 10) {
- }
-
- if (this.scanComments) {
- this.token = 146;
- return var1;
- }
- continue;
- case 61:
- this.field_1 = this.field_0.read();
- this.token = 3;
- return var1;
- default:
- this.token = 31;
- return var1;
- }
- case 48:
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- case 56:
- case 57:
- this.scanNumber();
- return var1;
- case 58:
- this.field_1 = this.field_0.read();
- this.token = 136;
- return var1;
- case 59:
- this.field_1 = this.field_0.read();
- this.token = 135;
- return var1;
- case 60:
- switch (this.field_1 = this.field_0.read()) {
- case 60:
- if ((this.field_1 = this.field_0.read()) == 61) {
- this.field_1 = this.field_0.read();
- this.token = 7;
- return var1;
- }
-
- this.token = 26;
- return var1;
- case 61:
- this.field_1 = this.field_0.read();
- this.token = 23;
- return var1;
- default:
- this.token = 24;
- return var1;
- }
- case 61:
- if ((this.field_1 = this.field_0.read()) == 61) {
- this.field_1 = this.field_0.read();
- this.token = 20;
- return var1;
- }
-
- this.token = 1;
- return var1;
- case 62:
- switch (this.field_1 = this.field_0.read()) {
- case 61:
- this.field_1 = this.field_0.read();
- this.token = 21;
- return var1;
- case 62:
- switch (this.field_1 = this.field_0.read()) {
- case 61:
- this.field_1 = this.field_0.read();
- this.token = 8;
- return var1;
- case 62:
- if ((this.field_1 = this.field_0.read()) == 61) {
- this.field_1 = this.field_0.read();
- this.token = 9;
- return var1;
- }
-
- this.token = 28;
- return var1;
- default:
- this.token = 27;
- return var1;
- }
- default:
- this.token = 22;
- return var1;
- }
- case 63:
- this.field_1 = this.field_0.read();
- this.token = 137;
- return var1;
- case 91:
- this.field_1 = this.field_0.read();
- this.token = 142;
- return var1;
- case 93:
- this.field_1 = this.field_0.read();
- this.token = 143;
- return var1;
- case 94:
- if ((this.field_1 = this.field_0.read()) == 61) {
- this.field_1 = this.field_0.read();
- this.token = 12;
- return var1;
- }
-
- this.token = 17;
- return var1;
- case 123:
- this.field_1 = this.field_0.read();
- this.token = 138;
- return var1;
- case 124:
- switch (this.field_1 = this.field_0.read()) {
- case 61:
- this.field_1 = this.field_0.read();
- this.token = 11;
- return var1;
- case 124:
- this.field_1 = this.field_0.read();
- this.token = 14;
- return var1;
- default:
- this.token = 16;
- return var1;
- }
- case 125:
- this.field_1 = this.field_0.read();
- this.token = 139;
- return var1;
- case 126:
- this.field_1 = this.field_0.read();
- this.token = 38;
- return var1;
- default:
- if (Character.isJavaLetter((char)this.field_1)) {
- this.scanIdentifier();
- return var1;
- }
-
- this.env.error(this.pos, "funny.char");
- this.field_1 = this.field_0.read();
- }
- }
- }
-
- public void match(int var1, int var2) throws IOException {
- int var3 = 1;
-
- while(true) {
- this.scan();
- if (this.token == var1) {
- ++var3;
- } else if (this.token == var2) {
- --var3;
- if (var3 == 0) {
- return;
- }
- } else if (this.token == -1) {
- this.env.error(this.pos, "unbalanced.paren");
- return;
- }
- }
- }
-
- static {
- defineKeyword(92);
- defineKeyword(90);
- defineKeyword(91);
- defineKeyword(93);
- defineKeyword(94);
- defineKeyword(95);
- defineKeyword(96);
- defineKeyword(97);
- defineKeyword(98);
- defineKeyword(99);
- defineKeyword(100);
- defineKeyword(101);
- defineKeyword(102);
- defineKeyword(103);
- defineKeyword(104);
- defineKeyword(70);
- defineKeyword(71);
- defineKeyword(72);
- defineKeyword(73);
- defineKeyword(74);
- defineKeyword(75);
- defineKeyword(76);
- defineKeyword(77);
- defineKeyword(78);
- defineKeyword(25);
- defineKeyword(80);
- defineKeyword(81);
- defineKeyword(49);
- defineKeyword(82);
- defineKeyword(83);
- defineKeyword(84);
- defineKeyword(110);
- defineKeyword(111);
- defineKeyword(112);
- defineKeyword(113);
- defineKeyword(114);
- defineKeyword(115);
- defineKeyword(144);
- defineKeyword(120);
- defineKeyword(121);
- defineKeyword(122);
- defineKeyword(124);
- defineKeyword(125);
- defineKeyword(126);
- defineKeyword(127);
- defineKeyword(130);
- defineKeyword(129);
- defineKeyword(128);
- defineKeyword(123);
- defineKeyword(58);
- }
- }
-