예제 #1
0
        private Item(Production production, int index, State parent, Item prevItem)
        {
            if (production == null || parent == null)
            {
                throw new ArgumentNullException();
            }

            if (index < 0 || index > production.Symbols.Count)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (index == 0 && prevItem != null)
            {
                throw new ArgumentException();
            }

            if (index > 0 && prevItem == null)
            {
                throw new ArgumentNullException();
            }

            this.production = production;
            this.index = index;
            this.parent = parent;
            this.prevItem = prevItem;
            this.derivations = index == 0 ? null : new List<object>();
        }
예제 #2
0
 public void Add()
 {
     Nonterminal nt = new Nonterminal();
     Production p = new Production();
     nt.Add(p);
     Assert.IsTrue(nt.Contains(p));
 }
예제 #3
0
        public void UpdateDisplay(ProductionShift shift, Production production, IEnumerable<ProductionStop> allStops)
        {
            productionStart = production.ProductionStart.ToString("g", System.Globalization.CultureInfo.CurrentUICulture);
            productionShiftStartDate = shift.ProductionStart.ToShortDateString();
            ClearDisplay();

            ClearChart(chartShift);
            ClearChart(chartProduction);
            if (production == null ||
                shift == null)
                return;

            team = shift.Team.Name;

            DisplayOrder(production.Order);
            DisplayProduct(production.Product);
            DisplayProductionStart(shift.ProductionStart, production.ProductionStart);
            DisplayProductionTime(shift.Duration, production.Duration);
            DisplayProducedItems(shift.ProducedItems, production.ProducedItems, production.ProducedItemsPerHour);
            DisplayDiscardedItems(shift.DiscardedItems, production.DiscardedItems);
            DisplayFactors(new FactorCalculator(shift), new FactorCalculator(production));

            DisplayStopRegistrationsOnChart(chartShift, shift.ProductionStopRegistrations, allStops, production.ValidatedStartTime);
            DisplayStopRegistrationsOnChart(chartProduction, production.ProductionStopRegistrations, allStops, production.ValidatedStartTime);
        }
예제 #4
0
		/// <summary>
		/// </summary>
		/// <param name="targetclasses"></param>
		/// <returns></returns>
		protected override IEnumerable<Production> InternalGenerate(IBSharpClass[] targetclasses){
			var genfactory = new Production{
				FileName = "Adapters/Model.cs",
				GetContent = () => new BaseModelWriter(Model).ToString()
			};
			yield return genfactory;
		}
 public PrecedenceBasedParserAction(BnfTerm shiftTerm, ParserState newShiftState, Production reduceProduction)
 {
     _reduceAction = new ReduceParserAction(reduceProduction);
     var reduceEntry = new ConditionalEntry(CheckMustReduce, _reduceAction, "(Precedence comparison)");
     ConditionalEntries.Add(reduceEntry);
     DefaultAction = _shiftAction = new ShiftParserAction(shiftTerm, newShiftState);
 }
예제 #6
0
		internal IntermediateNode(Item item, int startPosition, int endPosition) : base(startPosition, endPosition) {
			Item = item;

			// these two are used just for figuring out equality
			_production = item.Production;
			_currentPosition = item.CurrentPosition;
		}
예제 #7
0
 /**
  * <summary>Called when adding a child to a parse tree
  * node.</summary>
  *
  * <param name='node'>the parent node</param>
  * <param name='child'>the child node, or null</param>
  *
  * <exception cref='ParseException'>if the node analysis
  * discovered errors</exception>
  */
 public override void Child(Production node, Node child)
 {
     switch (node.Id) {
     case (int) LogicalConstants.FORMULE:
         ChildFormule(node, child);
         break;
     case (int) LogicalConstants.FORMULE_PRED:
         ChildFormulePred(node, child);
         break;
     case (int) LogicalConstants.FORMULE_BIN:
         ChildFormuleBin(node, child);
         break;
     case (int) LogicalConstants.ATOM:
         ChildAtom(node, child);
         break;
     case (int) LogicalConstants.PREDICAT:
         ChildPredicat(node, child);
         break;
     case (int) LogicalConstants.PRED1:
         ChildPred1(node, child);
         break;
     case (int) LogicalConstants.PRED2:
         ChildPred2(node, child);
         break;
     case (int) LogicalConstants.PRED3:
         ChildPred3(node, child);
         break;
     }
 }
예제 #8
0
 public void Create()
 {
     Production p1 = new Production();
     Production p2 = new Production();
     Nonterminal nt = new Nonterminal(p1, p2);
     Assert.AreEqual(2, nt.Count);
     Assert.IsTrue(nt.Contains(p1) && nt.Contains(p2));
 }
        public Production PostSave(Production production)
        {
            if (production.Id > 0)
                DatabaseContext.Database.Update(production);
            else
                DatabaseContext.Database.Save(production);

            return production;
        }
예제 #10
0
파일: Grammar.cs 프로젝트: adamedx/shango
 public Grammar(
     Production   startProduction,
     Production[] productionList,
     Token[]      tokenList)
 {
     _startProduction = startProduction;
     _productionList = productionList;
     _tokenList = tokenList;
 }
예제 #11
0
 public TransitionAction(ParserAction action, Production reduceByProduction)
     : this(action)
 {
     if (action != ParserAction.Reduce)
         throw new Exception("Can only define the production to reduce by for the reduce action.");
     if (reduceByProduction == null)
         throw new ArgumentNullException("reduceByProduction");
     ReduceByProduction = reduceByProduction;
 }
예제 #12
0
파일: Form1.cs 프로젝트: AtanasK/VP
 public Form1()
 {
     InitializeComponent();
     Production m = new Production("AMC", "01");
     cbProductions.Items.Add(m);
     m = new Production("Showtime", "02");
     cbProductions.Items.Add(m);
     m = new Production("HBO", "03");
     cbProductions.Items.Add(m);
 }
예제 #13
0
 /**
  * <summary>Called when adding a child to a parse tree
  * node.</summary>
  *
  * <param name='node'>the parent node</param>
  * <param name='child'>the child node, or null</param>
  *
  * <exception cref='ParseException'>if the node analysis
  * discovered errors</exception>
  */
 public override void Child(Production node, Node child)
 {
     switch (node.Id) {
     case (int) GrammarConstants.DOCUMENT:
         ChildDocument(node, child);
         break;
     case (int) GrammarConstants.TEXT:
         ChildText(node, child);
         break;
     }
 }
예제 #14
0
		internal void AddChild(int i, Production production) {
			if (i >= _families.Count) {
				throw new Exception();
			}
			if (_families[i].Production != null) {
				if (production != _families[i].Production) {
					throw new Exception();
				}
			}
			_families[i].Production = production;
		}
예제 #15
0
        public void AddTwoProductionsWithSameOrder()
        {
            Production production1 = new Production("Machine A", product1, order1, 1000, 100);
            Production production2 = new Production("Machine A", product1, order1, 1000, 100);

            using (IEntityRepository<Production> repository = factory.CreateEntityRepository<Production>())
            {
                repository.Save(production1);
                repository.Save(production2);
            }
        }
예제 #16
0
        public override void Add(Production item)
        {
            if (Productions.Count == 0)
            {
                var initialProduction = new Production(new NonTerminal(INITAL_SYMBOL_NAME), item.Symbol, null)
                                            {ID = INITAL_SYMBOL_ID};
                Productions.Add(initialProduction);
            }

            base.Add(item);
        }
예제 #17
0
        public void AddDuplicate()
        {
            State state = new State();
            Production p = new Production(new Terminal('x', 'y'));
            Item itemA = new Item(p, state);
            itemA.Add('x');
            state.Add(itemA);

            Item itemB = new Item(p, state);
            itemB.Add('y');
            state.Add(itemB);
        }
예제 #18
0
 protected string GetClassName(Production prod)
 {
     var sb = new StringBuilder();
     sb.Append('_');
     sb.Append(prod.Head.Name);
     foreach (var v in prod.Tail)
     {
         sb.Append('_');
         sb.Append(v.Name);
     }
     return sb.ToString();
 }
예제 #19
0
파일: NewProduction.cs 프로젝트: AtanasK/VP
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (!ValidateChildren())
     {
         return;
     }
     Production = new Production();
     Production.Name = tbName.Text;
     Production.Code = mtbCode.Text;
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.Close();
 }
예제 #20
0
        public void AddShift()
        {
            Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124);

            ProductionTeam team = new ProductionTeam("Team 1");

            DateTime start = new DateTime(2008, 10, 12, 8, 30, 0);

            ProductionShift shift = production.AddProductionShift(team, start);

            CollectionAssert.AreEquivalent(new [] { shift }, new List<ProductionShift>(production.Shifts));
        }
예제 #21
0
        public void AddNewProductions()
        {
            Production production1 = new Production("Machine A", product1, order1, 1000, 100);
            Production production2 = new Production("Machine A", product1, order2, 500, 25);

            using (IEntityRepository<Production> repository = factory.CreateEntityRepository<Production>())
            {
                repository.Save(production1);
                repository.Save(production2);
            }

            Assert.AreNotEqual(production1.Id, production2.Id);
        }
예제 #22
0
 public StartShiftForm(Production p, DateTime date)
     : this()
 {
     if (p != null)
     {
         Machine = p.Machine;
         Product = p.Product;
         ExpectedItems = p.ExpectedItems;
         ProducedItemsPerHour = p.ProducedItemsPerHour;
         ValidatedSetupTime = p.ValidatedStartTime;
         production = p;
     }
     this.date = date;
 }
예제 #23
0
        public void CreateProductionLeg()
        {
            Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124);
            ProductionTeam team = new ProductionTeam("Team");
            DateTime start = new DateTime(2008, 10, 12, 8, 30, 0);
            ProductionShift shift = production.AddProductionShift(team, start.Date);

            long counterStart = 9956;

            ProductionLeg leg =  shift.AddProductionLeg(start, counterStart);

            Assert.AreEqual<DateTime>(start, leg.ProductionStart);
            Assert.AreEqual<long>(counterStart, leg.CounterStart);
        }
예제 #24
0
        public void AddShiftsOnDifferentDaysWithSameTeam()
        {
            Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124);

            ProductionTeam team = new ProductionTeam("Team 1");

            DateTime start1 = new DateTime(2008, 10, 12, 8, 30, 0);
            DateTime start2 = new DateTime(2008, 11, 12, 8, 30, 0);

            ProductionShift shift1 = production.AddProductionShift(team, start1);
            ProductionShift shift2 = production.AddProductionShift(team, start2);

            CollectionAssert.AreEquivalent(new [] { shift1, shift2 }, new List<ProductionShift>(production.Shifts));
        }
예제 #25
0
        public void AddNewProduction()
        {
            Production production = new Production("Machine A", product1, order1, 1000, 100);

            Assert.AreEqual(0, production.Id);
            Assert.AreEqual(0, production.Version);

            using (IEntityRepository<Production> repository = factory.CreateEntityRepository<Production>())
            {
                repository.Save(production);
            }

            Assert.AreNotEqual(0, production.Id);
            Assert.AreNotEqual(0, production.Version);
        }
 /// <summary>Factory method for creating a proper type of reduce parser action. </summary>
 /// <param name="production">A Production to reduce.</param>
 /// <returns>Reduce action.</returns>
 public static ReduceParserAction Create(Production production)
 {
     var nonTerm = production.LValue;
     //List builder (non-empty production for list non-terminal) is a special case 
     var isList = nonTerm.Flags.IsSet(TermFlags.IsList);
     var isListBuilderProduction = isList && production.RValues.Count > 0 &&
                                   production.RValues[0] == production.LValue;
     if (isListBuilderProduction)
         return new ReduceListBuilderParserAction(production);
     if (nonTerm.Flags.IsSet(TermFlags.IsListContainer))
         return new ReduceListContainerParserAction(production);
     if (nonTerm.Flags.IsSet(TermFlags.IsTransient))
         return new ReduceTransientParserAction(production);
     return new ReduceParserAction(production);
 }
예제 #27
0
        public void Equals()
        {
            Production p = new Production(Terminal.Eof);
            State s = new State();
            Item item = new Item(p, s);
            Assert.IsFalse(item.Equals(null));
            Assert.IsFalse(item.Equals(new object()));
            Assert.IsTrue(item.Equals(item), "Identity");
            Assert.IsTrue(item.Equals(new Item(p, s)), "Value equality");
            Assert.IsFalse(item.Equals(new Item(p, new State())), "Vary by state");
            Assert.IsFalse(item.Equals(new Item(new Production(), s)), "Vary by production");
            Assert.IsFalse(item.Equals(item.NextItem), "Vary by index");

            Item another = new Item(p, s);
            Assert.IsFalse(item.NextItem.Equals(another.NextItem), "Vary by previous item");
        }
예제 #28
0
        public void AddStopsToProductionLeg()
        {
            Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124);
            ProductionShift shift = production.AddProductionShift(new ProductionTeam("T"), DateTime.Now.Date);
            ProductionLeg leg = shift.AddProductionLeg(DateTime.Now, 0);

            CollectionAssert.AreEquivalent(new ProductionStopRegistration[] { }, new List<ProductionStopRegistration>(leg.ProductionStopRegistrations));

            leg.AddProductionStopRegistration(new ProductionStopRegistration(stop1, new TimeSpan(0, 10, 0)));
            CollectionAssert.AreEquivalent(new [] { new ProductionStopRegistration(stop1, new TimeSpan(0, 10, 0)) }, new List<ProductionStopRegistration>(leg.ProductionStopRegistrations));

            leg.AddProductionStopRegistration(new ProductionStopRegistration(stop3, new TimeSpan(0, 35, 0)));
            CollectionAssert.AreEquivalent(new [] { new ProductionStopRegistration(stop1, new TimeSpan(0, 10, 0)), new ProductionStopRegistration(stop3, new TimeSpan(0, 35, 0)) }, new List<ProductionStopRegistration>(leg.ProductionStopRegistrations));

            leg.AddProductionStopRegistration(new ProductionStopRegistration(stop1, new TimeSpan(0, 12, 0)));
            CollectionAssert.AreEquivalent(new [] { new ProductionStopRegistration(stop1, new TimeSpan(0, 10, 0)), new ProductionStopRegistration(stop1, new TimeSpan(0, 12, 0)), new ProductionStopRegistration(stop3, new TimeSpan(0, 35, 0)) }, new List<ProductionStopRegistration>(leg.ProductionStopRegistrations));
        }
예제 #29
0
        public void CollectionTest()
        {
            CustomerFactory factory = new CustomerFactory(new ObjectContext(CreateDataStore()));
            Customer customer = factory.FindFirst("Name = {0}", "Joe Blow");

            IList<WME> factlist = customer.GenerateFactsForRootObject();
            Assert.IsTrue(factlist.Count == 11, "Wrong count.");

            Agenda agenda = new Agenda();
            agenda.LoadRulesFromAssemblies = false;

            Variable customer_var = new Variable("Customer");
            Variable orders = new Variable("Orders");
            Variable order = new Variable("Order");
            Variable orderItems = new Variable("OrderItems");
            Variable orderItem = new Variable("OrderItem");
            Variable product = new Variable("Product");
            //Variable comment = new Variable("Comment");
            Variable description = new Variable("Description");

            Production mostSimple = new Production("CollectionTest");
            mostSimple.AddConditionToLHS(new PositiveCondition(customer_var, "$Customer.Orders", orders));
            mostSimple.AddConditionToLHS(new PositiveCondition(orders, "$Customer.Orders.Order", order));
            mostSimple.AddConditionToLHS(new PositiveCondition(order, "$Customer.Orders.Order.OrderItems", orderItems));
            mostSimple.AddConditionToLHS(new PositiveCondition(orderItems, "$Customer.Orders.Order.OrderItems.OrderItem", orderItem));
            mostSimple.AddConditionToLHS(new PositiveCondition(orderItem, "$Customer.Orders.Order.OrderItems.OrderItem.Product", product));
            mostSimple.AddConditionToLHS(new PositiveCondition(product, "$Customer.Orders.Order.OrderItems.OrderItem.Product.Description", description));
            mostSimple.AddConditionToLHS(new FunctionCondition(description, new FuncTerm("funcEquals", new funcEquals()), "Troll Food"));
            mostSimple.AddConditionToRHS(new InvokeCondition("shout", customer_var, "Shout", "Yipee"));
            mostSimple.AddConditionToRHS(new AssertCondition("Wow", customer_var, "eats", description));
            agenda.AddProduction(mostSimple);

            agenda.AddFacts(factlist);

            agenda.Run();

            agenda.VisualizeNetworkToFile(@"C:\Temp\CollectionTest.log", false);

            Assert.IsTrue(agenda.TotalFacts == 11, "Bad");
            Assert.IsTrue(agenda.ActionsTaken.Count == 1, "Bad");
            Assert.IsTrue(agenda.ActionsSkipped.Count == 0, "Bad");
            Assert.IsTrue(agenda.ActivatedRuleCount == 1, "Bad");
            Assert.IsTrue(customer.Result != null && customer.Result.StartsWith("Shout"), "Did not invoke method.");
        }
예제 #30
0
 /**
  * <summary>Called when adding a child to a parse tree
  * node.</summary>
  *
  * <param name='node'>the parent node</param>
  * <param name='child'>the child node, or null</param>
  *
  * <exception cref='ParseException'>if the node analysis
  * discovered errors</exception>
  */
 public override void Child(Production node, Node child)
 {
     switch (node.Id) {
     case (int) DokiScriptConstants.DOKI:
         ChildDoki(node, child);
         break;
     case (int) DokiScriptConstants.PART:
         ChildPart(node, child);
         break;
     case (int) DokiScriptConstants.BLOCK:
         ChildBlock(node, child);
         break;
     case (int) DokiScriptConstants.ACTION:
         ChildAction(node, child);
         break;
     case (int) DokiScriptConstants.VOICE_ACTION:
         ChildVoiceAction(node, child);
         break;
     case (int) DokiScriptConstants.OTHER_ACTION:
         ChildOtherAction(node, child);
         break;
     case (int) DokiScriptConstants.TAG:
         ChildTag(node, child);
         break;
     case (int) DokiScriptConstants.KEY:
         ChildKey(node, child);
         break;
     case (int) DokiScriptConstants.VALUE:
         ChildValue(node, child);
         break;
     case (int) DokiScriptConstants.FLAG:
         ChildFlag(node, child);
         break;
     case (int) DokiScriptConstants.OPTION:
         ChildOption(node, child);
         break;
     case (int) DokiScriptConstants.JUMP:
         ChildJump(node, child);
         break;
     }
 }
예제 #31
0
 public override Node ExitProdStatements(Production node)
 {
     return(node);
 }
예제 #32
0
 public override Node ExitProdOutputStatement(Production node)
 {
     return(node);
 }
예제 #33
0
 public override void EnterProdFunctions(Production node)
 {
 }
예제 #34
0
 public override Node ExitProdSizeTail(Production node)
 {
     return(node);
 }
예제 #35
0
 public override Node ExitProdObjectVarTail(Production node)
 {
     return(node);
 }
예제 #36
0
 public override void ChildProdObjectVarTail(Production node, Node child)
 {
     node.AddChild(child);
 }
예제 #37
0
 public override Node ExitProdTask(Production node)
 {
     return(node);
 }
예제 #38
0
        public override Node ExitProdIoStatement(Production node)
        {
            if (!runtime_error)
            {
                Node isRead = node.GetChildAt(0);
                if (isRead.GetName() == "READ")
                {
                    Node   id     = node.GetChildAt(1);
                    int    idcol  = id.GetStartColumn();
                    int    idline = id.GetStartLine();
                    Tokens token  = GetTokens(idline, idcol);
                    foreach (var item in identifiers)
                    {
                        if (item.getId() == token.getLexemes())
                        {
                            var    input = Console.ReadLine();
                            string dtype = item.getDtype();
                            bool   isneg = false;
                            switch (dtype)
                            {
                            case "Int":
                                int input_int = 0;
                                if (input.Contains("~"))
                                {
                                    isneg = true;
                                    input = input.Remove(0, 1);
                                }
                                if (Int32.TryParse(input, out input_int))
                                {
                                    if (isneg)
                                    {
                                        input_int *= -1;
                                    }
                                    item.setValue(input_int.ToString());
                                }
                                else
                                {
                                    runtime_error = true;
                                    Console.WriteLine("");
                                    Console.WriteLine("Runtime error: Type mismatch!");
                                }
                                break;

                            case "Double":
                                double input_double = 0;
                                if (input.Contains("~"))
                                {
                                    isneg = true;
                                    input = input.Remove(0, 1);
                                }
                                if (Double.TryParse(input, out input_double))
                                {
                                    if (isneg)
                                    {
                                        input_double *= -1;
                                    }
                                    item.setValue(input_double.ToString());
                                }
                                else
                                {
                                    runtime_error = true;
                                    Console.WriteLine("");
                                    Console.WriteLine("Runtime error: Type mismatch!");
                                }

                                break;

                            case "Char":
                                if (input.Count() < 2)
                                {
                                    item.setValue(input);
                                }
                                else
                                {
                                    runtime_error = true;
                                    Console.WriteLine("");
                                    Console.WriteLine("Runtime error: invalid character input.");
                                }
                                break;

                            case "String":
                                item.setValue(input);
                                break;

                            case "Boolean":
                                if (input == "Yes" || input == "No")
                                {
                                    item.setValue(input);
                                }
                                else
                                {
                                    runtime_error = true;
                                    Console.WriteLine("");
                                    Console.WriteLine("Runtime error: invalid boolean input.");
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            return(node);
        }
예제 #39
0
 public override void EnterProdObjectVarTail(Production node)
 {
 }
예제 #40
0
 public override void EnterProdPreIncdec(Production node)
 {
 }
예제 #41
0
 public override void ChildProdIoStatement(Production node, Node child)
 {
     node.AddChild(child);
 }
예제 #42
0
 public override void ChildProdConcat(Production node, Node child)
 {
     node.AddChild(child);
 }
예제 #43
0
 public override Node ExitProdConcat(Production node)
 {
     return(node);
 }
예제 #44
0
 public override void EnterProdConcat(Production node)
 {
 }
예제 #45
0
 public override void EnterProdStatements(Production node)
 {
 }
예제 #46
0
 public override void EnterProdParamTail(Production node)
 {
 }
예제 #47
0
 public override Node ExitProdReturnType(Production node)
 {
     return(node);
 }
예제 #48
0
 public override void EnterProdParameters(Production node)
 {
 }
예제 #49
0
 public override void EnterProdReturnType(Production node)
 {
 }
예제 #50
0
 public override void ChildProdReturnType(Production node, Node child)
 {
     node.AddChild(child);
 }
예제 #51
0
 public override void EnterProdTask(Production node)
 {
 }
예제 #52
0
 public override void ChildProdFunctions(Production node, Node child)
 {
     node.AddChild(child);
 }
예제 #53
0
 public override void EnterProdSizeTail(Production node)
 {
 }
예제 #54
0
 public override Node ExitProdFunctions(Production node)
 {
     return(node);
 }
예제 #55
0
 public override void ChildProdArray(Production node, Node child)
 {
     node.AddChild(child);
 }
예제 #56
0
 public override Node ExitProdParamTail(Production node)
 {
     return(node);
 }
예제 #57
0
 public override void EnterProdObjectElem(Production node)
 {
 }
예제 #58
0
 public override Node ExitProdObjectElem(Production node)
 {
     return(node);
 }
예제 #59
0
 public override void EnterProdOutputStatement(Production node)
 {
 }
예제 #60
0
 public override void ChildProdParamTail(Production node, Node child)
 {
     node.AddChild(child);
 }