Beispiel #1
0
 public Production(ProductionKind kind, int position)
 {
     Kind     = kind;
     Position = position;
     Captures = new List <string>();
     Children = new List <Production>();
 }
Beispiel #2
0
        public bool Production(ProductionKind kind, Func <bool> next)
        {
            var node        = new Production(kind, Index);
            var parent      = CurrentProduction;
            var parentScope = _productionScope;

            _productionScope  = new ProductionScope();
            CurrentProduction = node;
            try
            {
                var accepted = next();
                if (accepted)
                {
                    parentScope.AddProduction(node);
                }

                return(accepted);
            }
            finally
            {
                node.Children.AddRange(_productionScope.GetProductions());
                node.Captures.AddRange(_productionScope.GetCaptures());
                CurrentProduction = parent;
                _productionScope  = parentScope;
            }
        }