public static RegExNode Of(RegExNode first, RegExNode second)
 {
     if (first.RegExType == RegExType.Ranges && second.RegExType == RegExType.Ranges)
     {
         var r1 = ((RegExNodeRanges)first).Ranges;
         var r2 = ((RegExNodeRanges)second).Ranges;
         return(new RegExNodeRanges(new[] { r1, r2 }.SelectMany(r => r).ToArray()));
     }
     return(new RegExNodeUnion(first, second));
 }
 private void Add(RegExNode node)
 {
     if (node.RegExType == RegExType.Concat)
     {
         Expressions.AddRange(((RegExNodeConcat)node).Expressions);
     }
     else
     {
         Expressions.Add(node);
     }
 }
示例#3
0
        public static RegExNodeRanges Except(RegExNode n1, RegExNode n2)
        {
            var r1 = n1 as RegExNodeRanges;
            var r2 = n2 as RegExNodeRanges;

            if ((r1 == null) || (r2 == null))
            {
                throw new Exception("Invalid expression used in 'except' construct.");
            }
            var positives = r1.Ranges.SelectMany(range => FindExcepts(range, r2.Ranges)).ToList();

            return(new RegExNodeRanges(positives));
        }
示例#4
0
 public RegExNodeExcept(RegExNode e1, RegExNode e2) : base(RegExType.Except)
 {
     Expression1 = e1;
     Expression2 = e2;
 }
示例#5
0
 public RegExNodeRepeat(RegExNode intern, RegExRepeatType regExRepeatType) : base(RegExType.Repeat)
 {
     Expression      = intern;
     RegExRepeatType = regExRepeatType;
 }
 public RegExNodeConcat(RegExNode left, RegExNode right) : base(RegExType.Concat)
 {
     Add(left);
     Add(right);
 }
 public RegExNodeAccept(RegExNode expression, ushort acceptState) : base(RegExType.Accept)
 {
     Expression  = expression;
     AcceptState = acceptState;
 }
 private RegExNodeUnion(RegExNode first, RegExNode second) : base(RegExType.Union)
 {
     Add(first);
     Add(second);
 }