Пример #1
0
        /// <summary>
        /// Finds the first match for the pattern.
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public PatternMatch Match(string s)
        {
            // Note: need to implement captures here.
            PatternMatch match = new PatternMatch();

            computeThread.Join();

            try
            {
                int j = i;
                for (int f = 0; f < funcs.Count;)
                {
                    PatternFunc func    = funcs[f];
                    bool        applies = func(s, ref i, funcs.ElementAtOrDefault(f - 1), funcs.ElementAtOrDefault(f + 1));

                    if (applies)
                    {
                        f++;
                    }
                    else
                    {
                        f = 0; j++; i = j;
                    }
                }
            }
            catch (IndexOutOfRangeException) { return(null); }

            return(match);
        }
Пример #2
0
 public PatternFuncRange(PatternFunc func, Range range, PatternFunc prev = null, PatternFunc next = null)
 {
     Func = func; Range = range; Prev = prev; Next = next;
 }