protected override bool FindFirstChar() => true; // The logic is all in Go.

            protected override void Go()
            {
                // Perform the match.
                SymbolicMatch pos = _matcher.FindMatch(quick, runtext !, runtextpos, runtextend);

                if (pos.Success)
                {
                    // If we successfully matched, capture the match, and then jump the current position to the end of the match.
                    int start = pos.Index;
                    int end   = start + pos.Length;
                    Capture(0, start, end);
                    runtextpos = end;
                }
                else
                {
                    // If we failed to find a match in the entire remainder of the input, skip the current position to the end.
                    // The calling scan loop will then exit.
                    runtextpos = runtextend;
                }
            }
            protected override bool FindFirstChar() => true; // The logic is all in Go.

            protected override void Go()
            {
                int beginning = runtextbeg;
                ReadOnlySpan <char> inputSpan = runtext.AsSpan(beginning, runtextend - beginning);

                // Perform the match.
                SymbolicMatch pos = _matcher.FindMatch(quick, inputSpan, runtextpos - beginning, _perThreadData);

                // Transfer the result back to the RegexRunner state.
                if (pos.Success)
                {
                    // If we successfully matched, capture the match, and then jump the current position to the end of the match.
                    int start = pos.Index + beginning;
                    int end   = start + pos.Length;
                    if (!quick && pos.CaptureStarts != null)
                    {
                        Debug.Assert(pos.CaptureEnds != null);
                        Debug.Assert(pos.CaptureStarts.Length == pos.CaptureEnds.Length);
                        for (int cap = 0; cap < pos.CaptureStarts.Length; ++cap)
                        {
                            if (pos.CaptureStarts[cap] >= 0)
                            {
                                Debug.Assert(pos.CaptureEnds[cap] >= pos.CaptureStarts[cap]);
                                Capture(cap, pos.CaptureStarts[cap] + beginning, pos.CaptureEnds[cap] + beginning);
                            }
                        }
                    }
                    else
                    {
                        Capture(0, start, end);
                    }
                    runtextpos = end;
                }
                else
                {
                    // If we failed to find a match in the entire remainder of the input, skip the current position to the end.
                    // The calling scan loop will then exit.
                    runtextpos = runtextend;
                }
            }
Example #3
0
            protected internal override void Scan(ReadOnlySpan <char> text)
            {
                // Perform the match.
                SymbolicMatch pos = _matcher.FindMatch(_mode, text, runtextpos, _perThreadData);

                // Transfer the result back to the RegexRunner state.
                if (pos.Success)
                {
                    // If we successfully matched, capture the match, and then jump the current position to the end of the match.
                    int start = pos.Index;
                    int end   = start + pos.Length;
                    if (_mode == RegexRunnerMode.FullMatchRequired && pos.CaptureStarts != null)
                    {
                        Debug.Assert(pos.CaptureEnds != null);
                        Debug.Assert(pos.CaptureStarts.Length == pos.CaptureEnds.Length);
                        for (int cap = 0; cap < pos.CaptureStarts.Length; ++cap)
                        {
                            if (pos.CaptureStarts[cap] >= 0)
                            {
                                Debug.Assert(pos.CaptureEnds[cap] >= pos.CaptureStarts[cap]);
                                Capture(cap, pos.CaptureStarts[cap], pos.CaptureEnds[cap]);
                            }
                        }
                    }
                    else
                    {
                        Capture(0, start, end);
                    }

                    runtextpos = end;
                }
                else
                {
                    // If we failed to find a match in the entire remainder of the input, skip the current position to the end.
                    // The calling scan loop will then exit.
                    runtextpos = text.Length;
                }
            }
Example #4
0
            protected override bool FindFirstChar() => true; // The logic is all in Go.

            protected override void Go()
            {
                int beginning = runtextbeg;
                ReadOnlySpan <char> inputSpan = runtext.AsSpan(beginning, runtextend - beginning);

                // Perform the match.
                SymbolicMatch pos = _matcher.FindMatch(quick, inputSpan, runtextpos - beginning);

                // Transfer the result back to the RegexRunner state.
                if (pos.Success)
                {
                    // If we successfully matched, capture the match, and then jump the current position to the end of the match.
                    int start = pos.Index + beginning;
                    int end   = start + pos.Length;
                    Capture(0, start, end);
                    runtextpos = end;
                }
                else
                {
                    // If we failed to find a match in the entire remainder of the input, skip the current position to the end.
                    // The calling scan loop will then exit.
                    runtextpos = runtextend;
                }
            }