bool TryParseUntil(int index, out MatchCursor <TInput> match) { if (index >= _count) { match = default(MatchCursor <TInput>); return(false); } lock (_matches) { for (int i = _matches.Count; i <= index; i++) { Result <TInput, Match> result = _parser.Parse(_input); if (result.HasValue) { _input = result.Next; _matches.Add(new MatchCursor <TInput>(this, index, result.Value)); continue; } _count = i; break; } } if (index < _matches.Count) { match = _matches[index]; return(true); } match = default(MatchCursor <TInput>); return(false); }
public bool TryGet(int index, out MatchCursor <TInput> match) { if (index < 0) { throw new ArgumentOutOfRangeException("index"); } if (index < _matches.Count) { lock (_matches) match = _matches[index]; return(true); } return(TryParseUntil(index, out match)); }
public bool MoveNext() { if (_cursor == null) { return(_input.TryGet(0, out _cursor)); } MatchCursor <TInput> nextCursor; if (_cursor.TryGetNext(out nextCursor)) { _cursor = nextCursor; return(true); } return(false); }
public void Reset() { _cursor = null; }
public bool TryGetNext(out MatchCursor <TInput> cursor) { return(_input.TryGet(_index + 1, out cursor)); }