Ejemplo n.º 1
0
 internal RefMatchEnumerator(InternalRegex regex, ReadOnlySpan <char> subject, PcreMatchSettings settings)
 {
     _regex    = regex;
     _subject  = subject;
     _settings = settings;
     _match    = default;
 }
Ejemplo n.º 2
0
            public bool MoveNext()
            {
                if (_regex == null)
                {
                    return(false);
                }

                if (!_match.IsInitialized)
                {
                    _match = _regex.CreateRefMatch();
                    _match.FirstMatch(_subject, _settings, _settings.StartIndex);
                }
                else
                {
                    _match.NextMatch(_settings);
                }

                if (_match.Success)
                {
                    return(true);
                }

                _regex = null;
                return(false);
            }
Ejemplo n.º 3
0
        private IEnumerable <PcreMatch> MatchesIterator(string subject, PcreMatchSettings settings)
        {
            var match = InternalRegex.Match(subject, settings, settings.StartIndex, settings.AdditionalOptions.ToPatternOptions());

            if (!match.Success)
            {
                yield break;
            }

            yield return(match);

            var baseOptions = settings.AdditionalOptions.ToPatternOptions() | PcreConstants.NO_UTF_CHECK;

            while (true)
            {
                var startIndex = match.GetStartOfNextMatchIndex();
                var options    = baseOptions | (match.Length == 0 ? PcreConstants.NOTEMPTY_ATSTART : 0);

                match = InternalRegex.Match(subject, settings, startIndex, options);
                if (!match.Success)
                {
                    yield break;
                }

                yield return(match);
            }
        }
Ejemplo n.º 4
0
        internal PcreRefCallout(ReadOnlySpan <char> subject, InternalRegex regex, Native.pcre2_callout_block *callout)
        {
            _subject = subject;
            _regex   = regex;
            _callout = callout;

            _oVector = null;
        }
Ejemplo n.º 5
0
 private MatchData ExecuteMatch(MatchContext context)
 {
     try
     {
         return(InternalRegex.Match(context));
     }
     catch (MatchException ex)
     {
         throw PcreMatchException.FromException(ex);
     }
 }
Ejemplo n.º 6
0
        internal PcreRefMatch(ReadOnlySpan <char> subject, InternalRegex regex, ReadOnlySpan <uint> oVector, char *mark)
        {
            // Callout

            Subject  = subject;
            _regex   = regex;
            _oVector = oVector;
            _markPtr = mark;

            _resultCode = oVector.Length / 2;
        }
Ejemplo n.º 7
0
        internal PcreRefMatch(InternalRegex regex, ReadOnlySpan <uint> oVector)
        {
            // Empty match

            _regex   = regex;
            _oVector = oVector;

            Subject     = default;
            _markPtr    = null;
            _resultCode = 0;
        }
Ejemplo n.º 8
0
        internal PcreMatch(string subject, InternalRegex regex, uint[] oVector, char *mark)
        {
            // Callout

            Subject  = subject;
            _regex   = regex;
            _oVector = oVector;
            _markPtr = mark;

            _resultCode = oVector.Length / 2;
        }
Ejemplo n.º 9
0
        internal PcreMatch(string subject, InternalRegex regex, ref Native.match_result result, uint[] oVector)
        {
            // Real match

            Subject  = subject;
            _regex   = regex;
            _oVector = oVector;
            _markPtr = result.mark;

            _resultCode = result.result_code;
        }
Ejemplo n.º 10
0
        public bool IsMatch(ReadOnlySpan <char> subject, int startIndex)
        {
            if (startIndex < 0 || startIndex > subject.Length)
            {
                throw new IndexOutOfRangeException("Invalid StartIndex value");
            }

            var outputVector = InternalRegex.CanStackAllocOutputVector
                ? stackalloc uint[InternalRegex.OutputVectorSize]
                : new uint[InternalRegex.OutputVectorSize];

            var match = InternalRegex.CreateRefMatch(outputVector);

            match.FirstMatch(subject, PcreMatchSettings.Default, startIndex);

            return(match.Success);
        }
Ejemplo n.º 11
0
        public PcreRefMatch Match(ReadOnlySpan <char> subject, PcreMatchSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (settings.StartIndex < 0 || settings.StartIndex > subject.Length)
            {
                throw new IndexOutOfRangeException("Invalid StartIndex value");
            }

            var match = InternalRegex.CreateRefMatch();

            match.FirstMatch(subject, settings, settings.StartIndex);

            return(match);
        }
Ejemplo n.º 12
0
        public PcreMatch Match(string subject, PcreMatchSettings settings)
        {
            if (subject == null)
            {
                throw new ArgumentNullException(nameof(subject));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (settings.StartIndex < 0 || settings.StartIndex > subject.Length)
            {
                throw new IndexOutOfRangeException("Invalid StartIndex value");
            }

            return(InternalRegex.Match(subject, settings, settings.StartIndex, settings.AdditionalOptions.ToPatternOptions()));
        }
Ejemplo n.º 13
0
        internal PcreCallout(string subject, InternalRegex regex, Native.pcre2_callout_block *callout)
        {
            _subject = subject;
            _regex   = regex;
            _flags   = callout->callout_flags;

            Number                = (int)callout->callout_number;
            StartOffset           = (int)callout->start_match;
            CurrentOffset         = (int)callout->current_position;
            MaxCapture            = (int)callout->capture_top;
            LastCapture           = (int)callout->capture_last;
            PatternPosition       = (int)callout->pattern_position;
            NextPatternItemLength = (int)callout->next_item_length;
            _markPtr              = callout->mark;

            _oVector    = new uint[callout->capture_top * 2];
            _oVector[0] = (uint)callout->start_match;
            _oVector[1] = (uint)callout->current_position;

            for (var i = 2; i < _oVector.Length; ++i)
            {
                _oVector[i] = callout->offset_vector[i].ToUInt32();
            }
        }
 internal PcreDfaRegex(InternalRegex regex)
 {
     _regex = regex;
 }
Ejemplo n.º 15
0
 internal PcrePatternInfo(InternalRegex re)
 {
     _re = re;
 }
Ejemplo n.º 16
0
 internal RefMatchEnumerable(InternalRegex regex, ReadOnlySpan <char> subject, PcreMatchSettings settings)
 {
     _regex    = regex;
     _subject  = subject;
     _settings = settings;
 }