public bool Equals(IUnicodeTarget other, bool relaxOriginatingState) { if (!relaxOriginatingState && other.TargetIsOrigin != this.TargetIsOrigin) { return(false); } if (other.Count != this.Count) { return(false); } if (other.Target != this.Target) { return(false); } return(other.All(p => this.ContainsKey(p.Key) && this[p.Key].Equals(p.Value))); }
public static RegularLanguageDFAUnicodeGraph BuildUnicodeGraph(this RegularLanguageDFAState state) { RegularLanguageDFAUnicodeGraph result = new RegularLanguageDFAUnicodeGraph() { UnicodeGraph = new UnicodeTargetGraph() }; if (state.OutTransitions.Count == 0) { return(result); } var fullSet = state.OutTransitions.FullCheck; foreach (var transition in state.OutTransitions) { /* * * Send in the current transition's requirement, along with the full set * to breakdown the unicode subsets contained within. * */ var breakdown = Breakdown(transition.Key, fullSet); /* * * If the remainder of the unicode breakdown does not overlap enough * of a category to include it, denote the remainder. * */ if (breakdown.Item1 != null && !breakdown.Item1.IsEmpty) { result.Add(breakdown.Item1, transition.Value); } /* * * If there are partial and full unicode sets, * push them into the unicode target logic result.UnicodeGraph. * */ if (breakdown.Item2.Length > 0 || breakdown.Item3.Count > 0) { IUnicodeTarget target = null; if (!result.UnicodeGraph.TryGetValue(transition.Value, out target)) { target = result.UnicodeGraph.Add(transition.Value, transition.Value == state); } //Full sets are simple. foreach (var category in breakdown.Item2) { target.Add(category); } var item3 = breakdown.Item3; /* * * Partial sets are a bit more interesting. * */ foreach (var partialCategory in item3.Keys) { /* * * If the partial set doesn't contain a remainder, * the original remainder was consumed by the overall * checks that occur before it. * * * As an example, if the category is Ll, assuming there * are other paths that utilize a-z, the original check used to * construct the unicode breakdown would note this, but * the full set sent into the breakdown method would negate * the negative set (if a-z are already checked, * there is no need to check that the character -isn't- * in that range). * */ if (item3[partialCategory] == null) { target.Add(partialCategory); } else { target.Add(partialCategory, item3[partialCategory]); } } } } return(result); }
public bool Equals(IUnicodeTarget other) { return(Equals(other, false)); }