Ejemplo n.º 1
0
 public override void Initialize(ParserInitializeArgs args)
 {
     base.Initialize(args);
     if (Inner != null && args.Push(this))
     {
         Inner.Initialize(args);
         args.Pop();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Called to initialize the parser when used in a grammar
 /// </summary>
 /// <remarks>
 /// This is used to perform certain tasks like caching information for performance, or to deal with
 /// things like left recursion in the grammar.
 /// </remarks>
 /// <param name="args">Initialization arguments</param>
 public virtual void Initialize(ParserInitializeArgs args)
 {
     if (args.Push(this))
     {
         hasNamedChildren = Children().Any(r => r.Name != null);
         mode             = (hasNamedChildren && name != null) ? ParseMode.NamedChildren : name != null || AddError ? ParseMode.NameOrError : ParseMode.Simple;
         args.Pop();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Called to initialize the parser when used in a grammar
        /// </summary>
        /// <remarks>
        /// This is used to perform certain tasks like caching information for performance, or to deal with
        /// things like left recursion in the grammar.
        /// </remarks>
        /// <param name="args">Initialization arguments</param>
        public void Initialize(ParserInitializeArgs args)
        {
            if (!initialized && args.Push(this))
            {
                initialized = true;
                var parent = args.Parent;
                args.Parent = this;
                InnerInitialize(args);
                args.Parent      = parent;
                hasNamedChildren = (Children.Any(r => r.AddMatch || r.hasNamedChildren));
                var parentNamed = false;
                if (parent != null && hasNamedChildren)
                {
                    var parentHasMatches = parent.Scan(filter: p => p != this).Any(p => p.AddMatch);
                    //parentNamed = parent.Scan(filter: p => p != this).Any(p => p.AddMatch);
                    parentNamed = parent.AddMatch;
                }

                mode = (hasNamedChildren && (AddMatch /* || parentNamed*/)) ? ParseMode.NamedChildren : AddMatch || AddError ? ParseMode.NameOrError : ParseMode.Simple;

                args.Pop();
            }
        }