public Token(String lexeme, int lineNum, int charPos) { boolean foundPredefined = false; this.lineNum = lineNum; this.charPos = charPos; this.lexeme = lexeme; for (Kind k : Kind.values()) { if (lexeme.equals(k.default_lexeme)) { this.kind = k; foundPredefined = true; } } // not found in reserved words or character sequences if (!foundPredefined) { if (isInteger(lexeme)) this.kind = Kind.INTEGER; else if (isFloatingPoint(lexeme)) this.kind = Kind.FLOAT; else if (isIdentifier(lexeme)) this.kind = Kind.IDENTIFIER; else this.kind = Kind.ERROR; // TODO: IF ALL ELSE FAILS IT IS IDENTIFIER???? } // maybe need to check if identifier or etc. // if we don't match anything, signal error // this.kind = Kind.ERROR; I COMMENTED THIS OUT NOT SURE WHAT TO DO WITH IT // this.lexeme = "Unrecognized lexeme: " + lexeme; }
public void initialize(NBTTagCompound nbttagcompound) { kind = Kind.values()[nbttagcompound.getShort("kind")]; initialize( nbttagcompound.getInteger("xMin"), nbttagcompound.getInteger("yMin"), nbttagcompound.getInteger("zMin"), nbttagcompound.getInteger("xMax"), nbttagcompound.getInteger("yMax"), nbttagcompound.getInteger("zMax")); }
static { // Create maps to speed up lookup from raw value to enum kindMap = new HashMap<Integer, Kind>(); for (Kind next : Kind.values()) { kindMap.put(next.getId(), next); } audioProfileMap = new HashMap<Integer, AudioProfile>(); for (AudioProfile next : AudioProfile.values()) { audioProfileMap.put(next.getId(), next); } }
public void read(NBTTagCompound nbt) { uniqueId = nbt.getByteArray("uniqueBptId"); name = nbt.getString("name"); kind = Kind.values()[nbt.getByte("kind")]; }