public override void AddProduction(Production production) {
if (production.Lhs == this.Start && production.Rhs.Count == 0) {
if (_emptyProductions.Count > 0) {
_emptyProductions.First().Weight += production.Weight;
} else {
_emptyProductions.Add(production);
}
} else if (production.IsCnfNonterminal) {
var ntprod = production;
AddToListWithoutDuplicating(_nonterminalProductions, ntprod);
} else if (production.IsCnfTerminal) {
var tprod = production;
AddToListWithoutDuplicating(_terminalProductions, tprod);
} else {
// TODO: should look into the production and see if we can convert
throw new Exception("You can't add that kind of production to this grammar");
}
InvalidateCaches();
}