Beispiel #1
0
        private IEnumerable <OMatch <TValue> > GetAllMathes(TValue[] values, int startIndex = -1)
        {
            var handler = new SequenceHandler <TValue>(values)
            {
                Reverse = Options.HasFlag(ORegexOptions.ReverseSequence)
            };

            startIndex = GetStartIndex(handler, startIndex);

            var captureTable = new OCaptureTable <TValue>(_fa.CaptureNames);

            for (int i = startIndex; i <= handler.Count; i++)
            {
                Range range;
                if (_fa.TryRun(handler, i, captureTable, out range))
                {
                    bool beginMatched = range.Index == startIndex;
                    bool endMatched   = range.RightIndex == handler.Count;

                    if (!_fa.ExactBegin && !_fa.ExactEnd ||
                        !(beginMatched ^ _fa.ExactBegin) && !(endMatched ^ _fa.ExactEnd))
                    {
                        var match = new OMatch <TValue>(handler, captureTable, range);
                        captureTable.Add(0, match);
                        yield return(match);
                    }
                    captureTable = new OCaptureTable <TValue>(_fa.CaptureNames);
                    i           += range.Length == 0 ? 0 : range.Length - 1;
                }
                if (_fa.ExactBegin)
                {
                    break;
                }
            }
        }
Beispiel #2
0
 public bool TryRun(SequenceHandler <TValue> values, int startIndex, OCaptureTable <TValue> table, out Range range)
 {
     return(FastFsa.TryRun(values, startIndex, null, out range) && CmdFsa.TryRun(values, startIndex, table, out range));
 }