public void addProduction(Production production) {
        checkProduction(production);
		GrammarChecker gc = new GrammarChecker();
		/** if production already in grammar. */
		if (GrammarChecker.isProductionInGrammar(production, this))
			return;
		myProductions.add(production);

		/**
		 * add all new variables introduced by production to set of variables.
		 */
		String[] variablesInProduction = production.getVariables();
		for (int k = 0; k < variablesInProduction.length; k++) {
			if (!myVariables.contains(variablesInProduction[k])) {
				addVariable(variablesInProduction[k]);
			}
		}

		/**
		 * add all new terminals introduced by production to set of terminals.
		 */
		String[] terminalsInProduction = production.getTerminals();
		for (int i = 0; i < terminalsInProduction.length; i++) {
			if (!myTerminals.contains(terminalsInProduction[i])) {
				addTerminal(terminalsInProduction[i]);
			}
		}
	}