private static Category valueOfUncached(final String source){
  String newSource=source;
  if (newSource.startsWith("(")) {
    final int closeIndex=Util.findClosingBracket(newSource);
    if (Util.indexOfAny(newSource.substring(closeIndex),"/\\|") == -1) {
      newSource=newSource.substring(1,closeIndex);
      final Category result=valueOf(newSource);
      return result;
    }
  }
  final int endIndex=newSource.length();
  final int opIndex=Util.findNonNestedChar(newSource,"/\\|");
  if (opIndex == -1) {
    int featureIndex=newSource.indexOf("[");
    final List<String> features=new ArrayList<>();
    final String base=(featureIndex == -1 ? newSource : newSource.substring(0,featureIndex));
    while (featureIndex > -1) {
      features.add(newSource.substring(featureIndex + 1,newSource.indexOf("]",featureIndex)));
      featureIndex=newSource.indexOf("[",featureIndex + 1);
    }
    if (features.size() > 1) {
      throw new RuntimeException("Can only handle single features: " + source);
    }
    final String feature=features.size() == 0 ? null : features.get(0);
    final Category c=new AtomicCategory(base,feature);
    return c;
  }
 else {
    final Category left=valueOf(newSource.substring(0,opIndex));
    final Category right=valueOf(newSource.substring(opIndex + 1,endIndex));
    return new FunctorCategory(left,Slash.fromString(newSource.substring(opIndex,opIndex + 1)),right);
  }
}

private static Category valueOfUncached ( final String source ) { String newSource = source ; if ( newSource . startsWith ( "(" ) ) { final int closeIndex = Util . findClosingBracket ( newSource ) ; if ( Util . indexOfAny ( newSource . substring ( closeIndex ) , "/\\|" ) == - 1 ) { newSource = newSource . substring ( 1 , closeIndex ) ; final Category result = valueOf ( newSource ) ; return result ; } } final int endIndex = newSource . length ( ) ; final int opIndex = Util . findNonNestedChar ( newSource , "/\\|" ) ; if ( opIndex == - 1 ) { int featureIndex = newSource . indexOf ( "[" ) ; final List < String > features = new ArrayList < > ( ) ; final String base = ( featureIndex == - 1 ? newSource : newSource . substring ( 0 , featureIndex ) ) ; while ( featureIndex > - 1 ) { features . add ( newSource . substring ( featureIndex + 1 , newSource . indexOf ( "]" , featureIndex ) ) ) ; featureIndex = newSource . indexOf ( "[" , featureIndex + 1 ) ; } if ( features . size ( ) > 1 ) { throw new RuntimeException ( "Can only handle single features: " + source ) ; } final String feature = features . size ( ) == 0 ? null : features . get ( 0 ) ; final Category c = new AtomicCategory ( base , feature ) ; return c ; } else { final Category left = valueOf ( newSource . substring ( 0 , opIndex ) ) ; final Category right = valueOf ( newSource . substring ( opIndex + 1 , endIndex ) ) ; return new FunctorCategory ( left , Slash . fromString ( newSource . substring ( opIndex , opIndex + 1 ) ) , right ) ; } }
builds a category from a string representation .
