public void EndDisjunct() { SetAndCheckCoreLength(); DisjunctAASetSequenceCollection[sbCurrentDisjunct.ToString()] = null; sbCurrentDisjunct = AASetSequence.GetInstance(); CoreLengthSoFar = 0; }
public Disjunct Right(int length) { SpecialFunctions.CheckCondition(length > 0); //!!!raise error AASetSequence expression = FullAsAASetSequence.Subsequence(Before.Count + Core.Count - (int)length); Disjunct disjunct = Disjunct.GetInstance(expression.ToString(), PatchRegexFactory); return(disjunct); }
/// Example: Suppose "1" is "[TNMSQC]" and the patchPattern is "11T11" and the other pattern is "T1111Z" /// then UnifyOrNull returns "T1T11Z" because that is the most general pattern /// such that "11T11".IsMatch("T1T11Z") is true and "T1111Z".IsMatch("T1T11Z") is true. /// Example: Suppose "1" is "[TNMSQC]" and the patchPattern is "11T11" and the other pattern is "A1111" /// then UnifyOrNull returns null because there is no pattern X such that /// such that "11T11".IsMatch(X) is true and "A1111".IsMatch(X) is true. /// </summary> public void AppendUnifications(Disjunct other, ref ArrayList unifiedDisjunctStringList) { SpecialFunctions.CheckCondition(Core.Count <= other.Core.Count); //!!!raise error for (int iPossiblePos = 0; iPossiblePos <= other.Core.Count - Core.Count; ++iPossiblePos) { AASetSequence unifiedDisjunctOrNull = UnificationAtPositionOrNull(other, iPossiblePos); if (unifiedDisjunctOrNull != null) { unifiedDisjunctStringList.Add(unifiedDisjunctOrNull.ToString()); } } }
static private PatchRegex Concatenate(params PatchRegex[] patchRegexParams) { SpecialFunctions.CheckCondition(patchRegexParams.Length > 0); //!!!raise error PatchRegexFactory patchRegexFactory = null; //ArrayList rgSegment = new ArrayList(); double combinations = 1; AASetSequence sbLuckyOne = AASetSequence.GetInstance(); foreach (PatchRegex patchRegex in patchRegexParams) { //rgSegment.AddRange(patchRegex.SegmentCollection); combinations *= patchRegex.DisjunctCollection.Length; if (combinations == 1) { sbLuckyOne.Append(patchRegex.DisjunctCollection[0].FullAsAASetSequence); } if (patchRegexFactory == null) { patchRegexFactory = patchRegex.PatchRegexFactory; } else { Debug.Assert(patchRegexFactory == patchRegex.PatchRegexFactory); //this says that all PatchRegex's must come from the same Hashtable } } if (combinations == 1) { Debug.Assert(sbLuckyOne[0] != AASet.OptionalAny && sbLuckyOne[sbLuckyOne.Count - 1] != AASet.OptionalAny); // real assert - disjuncts can't start or end with AASet.OptionalAny string[] rgDisjuncts = new string[] { sbLuckyOne.ToString() }; PatchRegex patchRegex = PatchRegex.GetInstance(rgDisjuncts, patchRegexFactory); return(patchRegex); } else { Debug.Fail("how may combinations?"); Debug.WriteLine("place of interest"); return(null); } // else if (rgSegment.Count > 1 && combinations == 2) // { // Segment segment = TurnToOneSegment(rgSegment, patchRegexFactory); // rgSegment.Clear(); // rgSegment.Add(segment); // } }