public bool TryGet(IExpectPattern pattern, out string result) { return(TryWrapper(() => { Expect(pattern); }, out result)); }
private StringScannerEngine ExpectImpl(IExpectPattern pattern) { AssertNotFinished(); CachePos(); AutoSkipWhitespace(); int startPos = Index; pattern.Initialize(Index, Chars); // call the function one more time after the end of the string - this determines outcome if (pattern.Validate()) { Match = pattern.Result; NewPos(pattern.EndIndex); } else { Index = pattern.EndIndex; // for error report to be accurate - will be undone at end ThrowUnexpectedCharacterException(); } return(this); }
/// <summary> /// Continue seeking as long as the delegate returns true. /// </summary> /// /// <param name="pattern"> /// A class specifying the pattern to match. /// </param> /// /// <returns> /// The string scanner. /// </returns> public IStringScanner Expect(IExpectPattern pattern) { ExpectImpl(pattern); return(this); }
public string Get(IExpectPattern pattern) { ExpectImpl(pattern); return(Match); }