Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
 public SelectorSyntaxReader(string selector)
 {
     _selector         = selector;
     _productionScope  = new ProductionScope();
     Index             = 0;
     CurrentProduction = default;
 }