public string Expect(QueryTokens expectedQueryToken)
            {
                if (AtEnd)
                {
                    throw new ApplicationException("Unexpected end of tokens!");
                }
                var curToken = mockTokensEnumerator.Current.Token;

                if (curToken != expectedQueryToken)
                {
                    throw new ApplicationException("Unexpected token: " + curToken + ", expected: " + expectedQueryToken);
                }

                var curTokenString = mockTokensEnumerator.Current.TokenString;

                Advance();

                return(curTokenString);
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Validate that the currrent token is the same as what is expected.
        /// Throws an exception if it is not.
        /// Advances to the next token automatically.
        /// Returns the token string for further processing.
        /// </summary>
        public string Expect(QueryTokens expectedQueryToken)
        {
            var tokenString = TokenString;

            if (Token == expectedQueryToken)
            {
                // Everything ok, move along.
                Advance();

                return(tokenString);
            }

            var curToken = Token;

            //
            // Expectation was not meet, throw exception.
            //
            TokenizerEnded();

            throw new ApplicationException("Expected token: " + expectedQueryToken + ", but encountered token " + curToken + " (" + tokenString + ")");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns true if the token is a separator for stack filters.
 /// </summary>
 private bool IsDescendentsSeparator(QueryTokens queryToken)
 {
     return(queryToken == QueryTokens.GreaterThan ||
            queryToken == QueryTokens.Slash);
 }