code: public int getGrammarID(Grammar r) {
  		// get ID of "equal" grammar (may be also pointer equal)
  		int id1 = this.grsIdDispenser.getGrammarID(r);
  		Grammar g1 = this.grsIdDispenser.getGrammar(id1);
  
  		for (int i = 0; i < this.sortedGrammars.size(); i++) {
  			Grammar g = this.sortedGrammars.get(i);
  			if (g1 == g) {
  				return i;
  			}
  		}
  
  		throw new RuntimeException("No grammar id found for: " + r);
  	}
docs: note: returns "sorted" id