public override List<INode> MatchLetter(LetterNode l) { List<INode> results = new List<INode>(); if (!this.InnerMatchOpen()) return results; MatchMaker current = GetCurrentMatcher(); if (current.IsMatchComplete()) { this.Next(); results.AddRange(MatchLetter(l)); this.Prev(); } if (current.MatchLetter(l)) { foreach (MatchMaker aMatch in this.available) { if (aMatch.MatchLetter(l)) { MatchLetterWithCurrent(l, results, current); aMatch.UnmatchLetter(l); } } current.UnmatchLetter(l); } return results; }
public bool UnmatchLetter(LetterNode letter) { return this.matches.Remove(letter); }
public bool MatchLetter(LetterNode letter) { if (MatchOneLetter(letter)) { this.matches.Add(letter); return true; } return false; }
protected override bool MatchOneLetter(LetterNode letter) { return true; }
protected override bool MatchOneLetter(LetterNode letter) { //already seen letters. if (SeenAllLetters()) { return false; } else { return MatchOneCharacter(letter.Letter); } }
protected abstract bool MatchOneLetter(LetterNode letter);
private bool MatchAndMerge(LetterNode l, LetterNode resultLetter) { Constants.Debug("MatchSetBase.MatchAndMerge"); List<INode> temp = this.Match(l.ChildNodes); if (!temp.IsNullOrEmpty()) { TrieBase.MergeChildren(resultLetter, temp); return true; } return false; }
protected void MatchLetterWithCurrent(LetterNode l, List<INode> results, MatchMaker current) { Constants.Debug("MatchSetBase.MatchLetterWithCurrent.Enter"); DebugCounts.CallFunction("MatchSetBase.MatchLetterWithCurrent"); bool anyMatch = false; LetterNode resultLetter = LetterNode.GetInstance(l.Letter); if (current.IsMatchComplete()) { this.Next(); anyMatch = MatchAndMerge(l, resultLetter) || anyMatch; this.Prev(); } else { // we probably should not hit this case- // if the current matcher is not complete, but it is still open. // ie. it has not matched enough, but it cannot match any more. if (!current.IsMatchOpen()) { this.Next(); anyMatch = MatchAndMerge(l, resultLetter) || anyMatch; this.Prev(); } } if (current.IsMatchOpen()) { anyMatch = MatchAndMerge(l, resultLetter) || anyMatch; } if (anyMatch) { DebugCounts.CallFunction("MatchSetBase.MatchLetterWithCurrent.AnyMatchTrue"); results.Add(resultLetter); } Constants.Debug("MatchSetBase.MatchLetterWithCurrent.Exit"); }
public virtual List<INode> MatchLetter(LetterNode l) { Constants.Debug("MatchSetBase.MatchLetter.Enter"); DebugCounts.CallFunction("MatchSetBase.MatchLetter"); List<INode> results = new List<INode>(); if (!AnyMatchOpen()) return results; MatchMaker current = GetCurrentMatcher(); if (current.IsMatchComplete()) { this.Next(); results.AddRange(MatchLetter(l)); this.Prev(); } if (current.MatchLetter(l)) { MatchLetterWithCurrent(l, results, current); current.UnmatchLetter(l); } Constants.Debug("MatchSetBase.MatchLetter.Exit"); return results; }
public bool UnmatchLetter(LetterNode letter) { if (matchedLetters.Count > 0) { char last = matchedLetters[matchedLetters.Count - 1]; if (last == letter.Letter) { matchedLetters.RemoveAt(matchedLetters.Count - 1); return true; } return false; } else { return false; } }
public bool MatchLetter(LetterNode letter) { if (matchedLetters.Count > 0) { char last = matchedLetters[matchedLetters.Count - 1]; LetterClass current = LetterClass.Classes[last]; if (current.Allow(letter.Letter) && !matchedLetters.Contains(letter.Letter)) { matchedLetters.Add(letter.Letter); return true; } return false; } else if (LetterClass.Classes.ContainsKey(letter.Letter)) { matchedLetters.Add(letter.Letter); return true; } return false; }
public List<INode> MatchLetter(LetterNode l) { List<INode> result = new List<INode>(); foreach (BetaMatchSet ms in this.innerMatcher) { result.AddRange(ms.MatchLetter(l)); } return result; }