예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Quantifier{TData, TOffset}"/> class.
        /// </summary>
        /// <param name="minOccur">The minimum number of occurrences.</param>
        /// <param name="maxOccur">The maximum number of occurrences.</param>

        /// <param name="node">The pattern node.</param>
        public Quantifier(int minOccur, int maxOccur, PatternNode <TData, TOffset> node)
            : base(node == null ? Enumerable.Empty <PatternNode <TData, TOffset> >() : node.ToEnumerable())
        {
            _greedy   = true;
            _minOccur = minOccur;
            _maxOccur = maxOccur;
        }
예제 #2
0
 protected override bool CanAdd(PatternNode <TData, TOffset> child)
 {
     if (!base.CanAdd(child) || child is Pattern <TData, TOffset> )
     {
         return(false);
     }
     return(true);
 }
예제 #3
0
        public virtual bool ValueEquals(PatternNode <TData, TOffset> other)
        {
            if (IsLeaf && other.IsLeaf)
            {
                return(true);
            }

            if (!IsLeaf && !other.IsLeaf && Children.Count == other.Children.Count)
            {
                return(Children.Zip(other.Children).All(tuple => tuple.Item1.ValueEquals(tuple.Item2)));
            }
            return(false);
        }
예제 #4
0
        public override bool ValueEquals(PatternNode <TData, TOffset> other)
        {
            var otherCons = other as Constraint <TData, TOffset>;

            return(otherCons != null && ValueEquals(otherCons));
        }
예제 #5
0
 protected override bool CanAdd(PatternNode <TData, TOffset> child)
 {
     return(false);
 }
예제 #6
0
 protected PatternNode(PatternNode <TData, TOffset> node)
     : this(node.Children.CloneItems())
 {
     Tag = node.Tag;
 }
예제 #7
0
 protected override bool CanRemove(PatternNode <TData, TOffset> child)
 {
     return(!IsFrozen);
 }
예제 #8
0
        public override bool ValueEquals(PatternNode <TData, TOffset> other)
        {
            var otherPattern = other as Pattern <TData, TOffset>;

            return(otherPattern != null && ValueEquals(otherPattern));
        }
예제 #9
0
        public override bool ValueEquals(PatternNode <TData, TOffset> other)
        {
            var otherQuant = other as Quantifier <TData, TOffset>;

            return(otherQuant != null && ValueEquals(otherQuant));
        }
예제 #10
0
 public Quantifier(PatternNode <TData, TOffset> node)
     : this(0, Infinite, node)
 {
 }
예제 #11
0
 protected PatternNode(PatternNode <TData, TOffset> node)
     : this(node.Children.DeepClone())
 {
 }
예제 #12
0
        public override bool ValueEquals(PatternNode <TData, TOffset> other)
        {
            var otherAlter = other as Alternation <TData, TOffset>;

            return(otherAlter != null && ValueEquals(otherAlter));
        }
예제 #13
0
        public override bool ValueEquals(PatternNode <TData, TOffset> other)
        {
            var otherGroup = other as Group <TData, TOffset>;

            return(otherGroup != null && ValueEquals(otherGroup));
        }
예제 #14
0
 public Group(string name, PatternNode <TData, TOffset> node)
     : base(node)
 {
     _name = name;
 }
예제 #15
0
 public Group(PatternNode <TData, TOffset> node)
     : this(null, node)
 {
 }