private void initReplacements(Grammar replacements) {
		Map reps = new HashMap();
		Production[] p = replacements.getProductions();
		for (int i = 0; i < p.length; i++) {
			String replace = p[i].getLHS();
			ArrayList currentReplacements = null;
			if (!reps.containsKey(replace))
				reps.put(replace, currentReplacements = new ArrayList());
			else
				currentReplacements = (ArrayList) reps.get(replace);
			List currentSubstitution = tokenify(p[i].getRHS());
			try {
				List lastSubstitution = (List) currentReplacements
						.get(currentReplacements.size() - 1);
				if (!currentSubstitution.equals(lastSubstitution))
					nondeterministic = true;
			} catch (IndexOutOfBoundsException e) {

			}
			currentReplacements.add(currentSubstitution);
		}
		Iterator it = reps.entrySet().iterator();
		symbolToReplacements = new TreeMap();
		List[] emptyListArray = new List[0];
		while (it.hasNext()) {
			Map.Entry entry = (Map.Entry) it.next();
			List l = (List) entry.getValue();
			List[] replacementArray = (List[]) l.toArray(emptyListArray);
			symbolToReplacements.put(entry.getKey(), replacementArray);
		}
	}