public UserOrderProductGrammar() { this.db = new UserOrderProductDataSet(); this.pop = new DatabasePopulator(); this.pop.Populate(this.db); this.ProductionFinished += new EventHandler(UserOrderProductGrammar_ProductionFinished); // create rules this.addUser = Rules.Method(new MethodInvoker(this.AddUser)); this.addOrder = Rules.Method(new MethodInvoker(this.AddOrder)); this.addProduct = Rules.Method(new MethodInvoker(this.AddProduct)); this.addOrderProduct = Rules.Method(new MethodInvoker(this.AddOrderProduct)); // guarded rules this.guardAddOrder = Rules.Guard(this.addUser, typeof(InvalidOperationException)); this.guardAddOrderProduct = Rules.Guard(this.addOrderProduct, typeof(InvalidOperationException)); this.init = Rules.Seq(this.addUser, this.addProduct, this.addOrder); this.StartRule = Rules.Seq(this.init, Rules.Kleene( Rules.Alt( this.addUser, this.addOrder, this.addProduct, this.addOrderProduct ) ) ); }
public DataGeneratorCollectionGrammar() { // methods this.add = Rules.Method(new MethodInvoker(this.Add)); this.remove = Rules.Method(new MethodInvoker(this.Remove)); this.removeColumn = Rules.Method(new MethodInvoker(this.RemoveColumn)); this.removeColumnName = Rules.Method(new MethodInvoker(this.RemoveColumnName)); this.clear = Rules.Method(new MethodInvoker(this.Clear)); // guarded methods this.guardRemove = Rules.Guard(this.remove, typeof(InvalidOperationException)); this.guardRemoveColumn = Rules.Guard(this.removeColumn, typeof(InvalidOperationException)); this.guardRemoveColumnName = Rules.Guard(this.removeColumnName, typeof(InvalidOperationException)); // high order rules this.nonEmpty = Rules.Alt( this.add, this.clear, this.remove, this.removeColumn, this.removeColumnName ); this.empty = Rules.Alt( this.add, this.clear, this.guardRemove, this.guardRemoveColumn, this.guardRemoveColumnName ); this.modify = Rules.If(new ConditionDelegate(this.IsEmpty), empty, nonEmpty); this.StartRule = Rules.Kleene(this.modify); }