public Result <TextSpan, TextSpan> Parse(ParseText text, TextSpan span) { int longestStart = span.Start; Result <TextSpan, TextSpan> longestResult = new Unmatched <TextSpan, TextSpan>(span); for (int index = 0; index < _parsers.Length; index++) { var result = _parsers[index].Parse(text, span); if (result.HasValue && result.Next.Start > longestStart) { longestResult = result; } } return(longestResult); }
public Result <TInput, TResult> Parse(Cursor <TInput> input) { int longestOffset = input.Offset; Result <TInput, TResult> longestResult = new Unmatched <TInput, TResult>(input); for (int index = 0; index < _parsers.Length; index++) { Result <TInput, TResult> result = _parsers[index].Parse(input); if (result.HasValue && result.Next.Offset > longestOffset) { longestResult = result; } } return(longestResult); }
public Result <TextSpan, TextSpan> Parse(ParseText text, TextSpan span) { var input = _parser.Parse(text, span); Result <TextSpan, TextSpan> result = new Unmatched <TextSpan, TextSpan>(input.Next); if (input.HasResult) { var inputSpan = input.Result; int longest = inputSpan.Start; for (int index = 0; index < _parsers.Length; index++) { var parsed = _parsers[index].Parse(text, inputSpan); if (parsed.HasResult && parsed.Next.Start > longest) { result = parsed; } } } return(result); }