public void GenerateInitialRulesFromDerivedRules() { if (!LandingSites.Any() || !Moveables.Any()) { return; } var initialRules = ruleNumberDictionary.Values.ToList(); var derivedRules = initialRules.Where(x => !x.IsInitialRule()).ToList(); var toRemove = derivedRules.ToList(); foreach (var item in toRemove) { DeleteRule(item); } }
public bool Contains(IWadObject wadObject) { if (wadObject is WadMoveable) { return(Moveables.Any(obj => obj.Value == (WadMoveable)wadObject)); } else if (wadObject is WadStatic) { return(Statics.Any(obj => obj.Value == (WadStatic)wadObject)); } else if (wadObject is WadSpriteSequence) { return(SpriteSequences.Any(obj => obj.Value == (WadSpriteSequence)wadObject)); } else { throw new ArgumentException("Argument not of a valid type."); } }
public void GenerateDerivedRulesFromSchema() { if (!LandingSites.Any() || !Moveables.Any()) { return; } var toAdd = new List <Rule>(); foreach (var moveable in Moveables) { var pop1 = new Rule(1, moveable, new[] { Epsilon }, 0, 0); pop1.Name.Stack = new NonTerminalStack(moveable); toAdd.Add(pop1); foreach (var landingSiteNonTerminal in LandingSites) { var push = new Rule(1, landingSiteNonTerminal, new[] { moveable, landingSiteNonTerminal }, 1, 1); push.Name.Stack = new NonTerminalStack("."); push.Production[1].Stack = new NonTerminalStack("."); push.Production[1].Stack = push.Production[1].Stack.Push(moveable); toAdd.Add(push); } var pop2 = new Rule(1, "IP", new[] { moveable, "VP" }, 1, 1); pop2.Name.Stack = new NonTerminalStack("."); pop2.Name.Stack = pop2.Name.Stack.Push(moveable); pop2.Production[0].Stack = new NonTerminalStack(moveable); pop2.Production[1].Stack = new NonTerminalStack("."); toAdd.Add(pop2); } foreach (var item in toAdd) { AddRule(item); } }