/// <summary> /// Add a new search target to the Tri. /// </summary> /// <param name="markerSpec">MarkerSpec containing the marker string to match</param> public void Add(MarkerSpec markerSpec) { m_tnRoot.Add(markerSpec.Marker, 0, markerSpec); }
/// <summary> /// Add the specified key to the tri. /// Assumes this is the node reached by traversing key[0]..key[ich-1]. /// Add nodes as necessary so that key can be matched and will return value. /// </summary> /// <param name="key"></param> /// <param name="ich"></param> /// <param name="markerSpec"></param> public void Add(string key, int ich, MarkerSpec markerSpec) { if (ich >= key.Length) TargetMarkerSpec = markerSpec; else { TriNode tn = Match(key[ich]); if (tn == null) { tn = new TriNode(); Add(key[ich], tn); } tn.Add(key, ich + 1, markerSpec); } }
/// <summary> /// Look for one of your keys at the specified position or any subsequenct position. /// /// Note that this returns an index, while Match returns the object. The rationale is that /// Match doesn't return a position at all, so the most useful return result seems to be the /// object. On the other hand, it is a widely used convention that search functions return /// the position where the match was found. /// </summary> /// <param name="line">One line of input (begin of line and end of line are /// assumed to occur before and after this string</param> /// <param name="startIndex">Position to look for keyword</param> /// <param name="nextIndex">Next char position after match (or line.Length if no match)</param> /// <param name="target">null if no match, or the object that matches.</param> /// <returns>-1 if not found, or char index of first character of match</returns> public int Search(string line, int startIndex, out int nextIndex, out MarkerSpec target) { target = null; nextIndex = line.Length; for (int ich = startIndex; ich < line.Length; ich++) { int nextIch; target = Match(line, ich, out nextIch); if (target != null) { nextIndex = nextIch; return ich; } } return -1; }
public EndInlineToken(int lineNo, int column, MarkerSpec markerSpec) : base(lineNo, column, markerSpec) { }
public MarkerToken(int lineNo, int column, MarkerSpec markerSpec) : base(lineNo, column) { m_markerSpec = markerSpec; }
public FieldToken(int lineNo, int column, MarkerSpec markerSpec) : base(lineNo, column, markerSpec) { }