Ejemplo n.º 1
0
 public bool TryGet(IExpectPattern pattern, out string result)
 {
     return(TryWrapper(() =>
     {
         Expect(pattern);
     }, out result));
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
 public string Get(IExpectPattern pattern)
 {
     ExpectImpl(pattern);
     return(Match);
 }