private static Set<NonTerminal> getProductiveNonterminals(Set<Production> productions) {
		Set<NonTerminal> productive = new ShareableHashSet<NonTerminal>();
		
		int oldSize = 0;
		int newSize = 0;
		
		do {
			for (Production p : productions) {
				if (p.reject) {
					continue;
				}
				boolean all = true;
				for (int i = 0; i < p.getLength(); i++) {
					Symbol s = p.getSymbolAt(i);
					if (s instanceof NonTerminal) {
						NonTerminal n = (NonTerminal) s;
						if (!productive.contains(n)) {
							all = false;
							break;
						}
					}
				}
				if (all) {
					productive.add(p.lhs);
				}
			}
			
			oldSize = newSize;
			newSize = productive.size();
		} while (oldSize != newSize);		

		return productive;
	}