예제 #1
0
            public static IAutomaton Create(IAutomaton s1, IAutomaton s2)
            {
                // Attempt to simplify/canonicalise the resulting state as much as possible.
                if (s1 is RejectState)
                {
                    return(s2);
                }
                if (s2 is RejectState)
                {
                    return(s1);
                }
                if (s1.Equals(s2))
                {
                    return(s1);
                }

                if (s1 is OrState os)
                {
                    return(Create(os.State1, Create(os.State2, s2)));
                }

                if (s1.GetHashCode() < s2.GetHashCode())
                {
                    return(new OrState(s2, s1));
                }
                return(new OrState(s1, s2));
            }
예제 #2
0
 public override bool Equals(object obj)
 {
     return(obj is SeqState seq && State1.Equals(seq.State1) && State2.Equals(seq.State2));
 }
예제 #3
0
 public override bool Equals(object other)
 {
     return(other is StarState ss && Child.Equals(ss.Child));
 }
예제 #4
0
 public override bool Equals(object obj)
 {
     return(obj is NotState ns && State.Equals(ns.State));
 }