public static PredicateList execute(PropositionSyntacticElement element, PredicateList predicateState) { // when a proposition element is executed the proposition // must be set to true. This can only be done when: // the proposition is found in the list // the proposition must not be false // the element can then be set to true PredicateSyntacticElement pse = predicateState.GetPredicate(element.PredicateName); if (pse == null) { element.Value = false; throw new ArgumentNullException(element.PredicateName + "could not bo found in state for " + element.Text); } else { if (pse.Value == false) { element.Value = false; } else { pse.Value = true; element.Value = true; } } return(predicateState); }
public override void Execute() { if (Command is PredicateSyntacticElement) { PredicateSyntacticElement pse = (PredicateSyntacticElement)(Command); Bertrand.program.Add(commandText); if (pse.State == State.Known) { Console.WriteLine("added predicate {0} > '{1}' with a value of {2}", pse.Name, pse.Predicate, pse.Value.ToString()); } else { Console.WriteLine("added predicate {0} > '{1}' with an unknown value", pse.Name, pse.Predicate); } return; } if (Command is PropositionExpression) { PropositionExpression pse = (PropositionExpression)(Command); Bertrand.program.Add(commandText); Console.WriteLine("added proposition {0}' ", pse.Text); return; } if (Command is PropositionSyntacticElement) { PropositionSyntacticElement pse = (PropositionSyntacticElement)(Command); Bertrand.program.Add(commandText); Console.WriteLine("added proposition setter {0}' ", pse.Text); return; } if (Command is PropositionNegationSyntacticElement) { PropositionExpression pse = (PropositionExpression)(Command); Bertrand.program.Add(commandText); Console.WriteLine("added proposition setter {0}' ", pse.Text); return; } if (Command is ThereforeSyntacticElement) { ThereforeSyntacticElement pse = (ThereforeSyntacticElement)(Command); Bertrand.program.Add(commandText); Console.WriteLine("added therefore command {0}' ", pse.Text); return; } if (Command is InvalidSyntacticElement) { InvalidSyntacticElement ise = (InvalidSyntacticElement)Command; Console.WriteLine("Error> {0}: {1}", ise.Title, ise.Message); Console.WriteLine(commandText); return; } throw new NotImplementedException(); }