public int defineTokenName(String name, int ttype) { Integer prev = tokenNameToTypeMap.get(name); if (prev != null) return prev; tokenNameToTypeMap.put(name, ttype); setTokenForType(ttype, name); maxTokenType = Math.max(maxTokenType, ttype); return ttype; }
public int defineStringLiteral(String lit, int ttype) { if (!stringLiteralToTypeMap.containsKey(lit)) { stringLiteralToTypeMap.put(lit, ttype); // track in reverse index too if (ttype >= typeToStringLiteralList.size()) { Utils.setSize(typeToStringLiteralList, ttype + 1); } typeToStringLiteralList.set(ttype, lit); setTokenForType(ttype, lit); return ttype; } return Token.INVALID_TYPE; }
public int defineTokenAlias(String name, String lit) { int ttype = defineTokenName(name); stringLiteralToTypeMap.put(lit, ttype); setTokenForType(ttype, name); return ttype; }