Example #1
0
 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;
 }
Example #2
0
  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;
  }
Example #3
0
 public int defineTokenAlias(String name, String lit) {
   int ttype = defineTokenName(name);
   stringLiteralToTypeMap.put(lit, ttype);
   setTokenForType(ttype, name);
   return ttype;
 }