private Match <TData, TOffset> CreatePatternMatch(TData input, FstResult <TData, TOffset> match) { TOffset matchStart, matchEnd; _fsa.GetOffsets(EntireMatch, match.Registers, out matchStart, out matchEnd); Range <TOffset> matchRange = Range <TOffset> .Create(matchStart, matchEnd); var groupCaptures = new List <GroupCapture <TOffset> >(); foreach (string groupName in _fsa.GroupNames) { if (groupName == EntireMatch) { continue; } GroupCapture <TOffset> groupCapture = null; TOffset start, end; if (_fsa.GetOffsets(groupName, match.Registers, out start, out end)) { if (Range <TOffset> .IsValidRange(start, end) && !Range <TOffset> .IsEmptyRange(start, end)) { Range <TOffset> range = Range <TOffset> .Create(start, end); if (matchRange.Contains(range)) { groupCapture = new GroupCapture <TOffset>(groupName, range); } } } if (groupCapture == null) { groupCapture = new GroupCapture <TOffset>(groupName, Range <TOffset> .Null); } groupCaptures.Add(groupCapture); } return(new Match <TData, TOffset>(this, matchRange, input, groupCaptures, string.IsNullOrEmpty(match.ID) ? new string[0] : match.ID.Split('*'), match.VariableBindings, match.NextAnnotation)); }
private Match <TData, TOffset> CreatePatternMatch(TData input, FstResult <TData, TOffset> match) { TOffset matchStart, matchEnd; _fsa.GetOffsets(EntireMatch, match.Registers, out matchStart, out matchEnd); Span <TOffset> matchSpan = _spanFactory.Create(matchStart, matchEnd); var groupCaptures = new List <GroupCapture <TOffset> >(); foreach (string groupName in _fsa.GroupNames) { if (groupName == EntireMatch) { continue; } GroupCapture <TOffset> groupCapture = null; TOffset start, end; if (_fsa.GetOffsets(groupName, match.Registers, out start, out end)) { if (_spanFactory.IsValidSpan(start, end) && _spanFactory.IsRange(start, end)) { Span <TOffset> span = _spanFactory.Create(start, end); if (matchSpan.Contains(span)) { groupCapture = new GroupCapture <TOffset>(groupName, span); } } } if (groupCapture == null) { groupCapture = new GroupCapture <TOffset>(groupName, _spanFactory.Empty); } groupCaptures.Add(groupCapture); } return(new Match <TData, TOffset>(this, matchSpan, input, groupCaptures, string.IsNullOrEmpty(match.ID) ? new string[0] : match.ID.Split('*'), match.VariableBindings, match.NextAnnotation)); }