private bool AfterAndCoreUnificationAtPosition(Disjunct other, int possiblePos, ref AASetSequence aAASetSequence) { int iHowMuchDoesThisStickIn = Math.Max(other.Core.Count - (possiblePos + Core.Count), 0); for (int iCommon = 0; iCommon < iHowMuchDoesThisStickIn; ++iCommon) { AASet chOther = other.Core[other.Core.Count - iHowMuchDoesThisStickIn + iCommon]; if (iCommon < After.Count) { AASet chThis = After[(int)iCommon]; AASet chUnifyOrEmpty = FlankingAndCoreUnifyOrEmpty(chThis, chOther); if (chUnifyOrEmpty == AASet.Empty) //!!!const { return(false); } aAASetSequence.Append(chUnifyOrEmpty); } else { aAASetSequence.Append(chOther); } } return(true); }
private bool AfterUnificationAtPosition(Disjunct other, int possiblePos, ref AASetSequence aAASetSequence) { //This creates the new after string. It will be the unification of other's after string //and any of This's after that sticks out beyond the core of other int iHowMuchDoesThisStickOut = Math.Max(0, possiblePos + Core.Count + After.Count - other.Core.Count); int iHowMuchInCommon = Math.Min(iHowMuchDoesThisStickOut, other.After.Count); for (int iCommon = 0; iCommon < iHowMuchInCommon; ++iCommon) { AASet chThis = After[After.Count - iHowMuchDoesThisStickOut + iCommon]; AASet chOther = other.After[iCommon]; AASet chUnifyOrOptionalEmpty = FlankingUnifyOrOptionalEmpty(chThis, chOther); if (chUnifyOrOptionalEmpty == AASet.OptionalEmpty) //!!!const { return(false); } aAASetSequence.Append(chUnifyOrOptionalEmpty); } int iHowMuchLongerDoesOtherStickOutComparedToThis = Math.Max(0, other.After.Count - iHowMuchDoesThisStickOut); aAASetSequence.AppendSubsequence(other.After, iHowMuchInCommon, iHowMuchLongerDoesOtherStickOutComparedToThis); int iHowMuchLongerDoesThisStickOutComparedToOther = Math.Max(0, iHowMuchDoesThisStickOut - other.After.Count); aAASetSequence.AppendSubsequence(After, After.Count - iHowMuchLongerDoesThisStickOutComparedToOther, iHowMuchLongerDoesThisStickOutComparedToOther); return(true); }
public AASetSequence Subsequence(int start) { AASetSequence aAASetSequence = AASetSequence.GetInstance(); for (int i = start; i < Count; ++i) { aAASetSequence.Append(this[i]); } return(aAASetSequence); }
public AASetSequence Subsequence(int start, int length) { AASetSequence aAASetSequence = AASetSequence.GetInstance(); for (int i = start; i < start + length; ++i) { aAASetSequence.Append(this[i]); } return(aAASetSequence); }
// private AASetSequence(int size) : base(size) // { // for(int i = 0; i < size; ++i) // { // Add(null); // } // } public static AASetSequence Concatenate(params AASetSequence[] aaSetSequenceParams) { AASetSequence result = AASetSequence.GetInstance(); foreach (AASetSequence aAASetSequence in aaSetSequenceParams) { result.Append(aAASetSequence); } return(result); }
private bool BeforeAndCoreUnificationAtPosition(Disjunct other, int possiblePos, ref AASetSequence aAASetSequence) { for (int iCommon = 0; iCommon < possiblePos; ++iCommon) { AASet chOther = other.Core[iCommon]; int iInBefore = Before.Count - possiblePos + iCommon; if (iInBefore >= 0) { AASet chThis = Before[iInBefore]; AASet chUnifyOrEmpty = FlankingAndCoreUnifyOrEmpty(chThis, chOther); if (chUnifyOrEmpty == AASet.Empty) //!!!const { return(false); } aAASetSequence.Append(chUnifyOrEmpty); } else { aAASetSequence.Append(chOther); } } return(true); }
private bool CoreUnificationAtPosition(Disjunct other, int possiblePos, ref AASetSequence aAASetSequence) { for (int iThisPos = 0; iThisPos < Core.Count; ++iThisPos) { AASet chThis = Core[iThisPos]; int iOtherPos = possiblePos + iThisPos; AASet chOther = other.Core[iOtherPos]; AASet chUnifyOrEmpty = AASetSequence.UnifyOrEmpty(chThis, chOther); if (chUnifyOrEmpty == AASet.Empty) //!!!const { return(false); } aAASetSequence.Append(chUnifyOrEmpty); } return(true); }
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); // } }
public void AppendDontCareOrEdge() { sbCurrentDisjunct.Append(AASet.OptionalAny); }