public ProductionDirectory(Grammar grammar) {
			Production[] p = grammar.getProductions();
			// Create the map of LHSes to RHSes.
			for (int i = 0; i < p.length; i++) {
				String lhs = p[i].getLHS(), rhs = p[i].getRHS();
				if (rhs.indexOf('(') != -1)
					throw new IllegalArgumentException(
							"Grammar has the ( character, which is reserved.");
				if (rhs.indexOf(')') != -1)
					throw new IllegalArgumentException(
							"Grammar has the ) character, which is reserved.");
				// Add it to the list of productions.
				productions.add(p[i]);
				// Check the right hand side map.
				Set rhses = (Set) lhsToRhs.get(lhs);
				if (rhses == null) {
					rhses = new HashSet();
					lhsToRhs.put(lhs, rhses);
				}
				rhses.add(rhs);
			}
			// Creates the map of RHSes to LHSes.
			Iterator it = lhsToRhs.entrySet().iterator();
			while (it.hasNext()) {
				Map.Entry entry = (Map.Entry) it.next();
				Set rhses = (Set) entry.getValue();
				Iterator it2 = rhses.iterator();
				String rhs = (String) it2.next();
				if (it2.hasNext())
					continue;
				rhsToLhs.put(rhs, entry.getKey());
			}
		}