| 1 30 31 package jbet; 32 33 45 46 public class Token { 47 48 public int type; 50 public String text; 52 public long l; 53 public double d; 54 55 60 public static final int EOF = 0x101; 61 public static final int TAG = 0x102; 62 public static final int NAME = 0x103; 63 public static final int END_OF_OPTS = 0x104; 64 public static final int TYPE = 0x105; 65 public static final int DEFAULT = 0x106; public static final int DONOR = 0x107; public static final int DESCRIPTOR = 0x108; 69 public static final int STRING = 0x109; 70 public static final int INT = 0x10A; 71 public static final int LABEL = 0x10B; 72 public static final int FLOAT = 0x10C; 73 public static final int EOL = '\n'; 74 75 76 78 81 public Token (int t) { 82 type = t; 83 text = null; 84 } 85 86 87 91 public Token (int t, String s) { 92 type = t; 93 text = s; 94 } 95 96 99 public Token (int t, long s) { 100 type = t; 101 l = s; 102 } 103 104 107 public Token (int t, double s) { 108 type = t; 109 d = s; 110 } 111 112 115 public String toString() { 116 if (type < 256) 117 return "'" + ((char)type) + "'"; 118 switch (type) { 119 case DEFAULT: 120 return "<DEFAULT>"; 121 case DONOR: 122 return "<DONOR>"; 123 case EOF: 124 return "EOF"; 125 case END_OF_OPTS: 126 return "END_OF_OPTS"; 127 case STRING: 128 return '"' + text + '"'; 129 case DESCRIPTOR: 130 case TYPE: 131 case TAG: 132 return text; 133 case LABEL: 134 return text + ":"; 135 case INT: 136 return "" + l; 137 } 138 return null; 139 } 140 141 } 142 143 | Popular Tags |