Ejemplo n.º 1
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);
        }