Ejemplo n.º 1
0
        /// <summary>
        /// Parses the given token source using the specified grammar, starting with
        /// expression with the given name.
        /// </summary>
        /// <param name="expressionType">The type of the expression to start parsing.</param>
        /// <param name="tokenSource">The source of tokens.</param>
        public MatchResult Parse(string expressionType, ITokenSource tokenSource)
        {
            if (tokenSource == null)
            {
                throw new ArgumentNullException("tokenSource");
            }

            Expression   expression = grammar.Expression(expressionType);
            ParseAttempt attempt    = new ParseAttempt(this, tokenSource);
            MatchResult  result     = expression.Match(attempt, String.Empty);

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the given token source using the specified grammar, starting with
        /// expression with the given name.
        /// </summary>
        /// <param name="expressionType">The type of the expression to start parsing.</param>
        /// <param name="tokenSource">The source of tokens.</param>
        public MatchResult Parse(string expressionType, ITokenSource tokenSource)
        {
            if (tokenSource == null)
            {
                throw new ArgumentNullException("tokenSource");
            }

            Expression   expression = grammar.Expression(expressionType);
            ParseAttempt attempt    = new ParseAttempt(this, tokenSource);
            MatchResult  result     = expression.Match(attempt, String.Empty);

            // check that there are no trailing tokens
            if (result.IsMatch && attempt.GetToken() != null)
            {
                result.IsMatch = false;
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses the given token source using the specified grammar, starting with
        /// expression with the given name.
        /// </summary>
        /// <param name="expressionType">The type of the expression to start parsing.</param>
        /// <param name="tokenSource">The source of tokens.</param>
        public MatchResult Parse(string expressionType, ITokenSource tokenSource)
        {
            if (tokenSource == null)
            {
                throw new ArgumentNullException("tokenSource");
            }

            Expression expression = grammar.Expression(expressionType);
            ParseAttempt attempt = new ParseAttempt(this, tokenSource);
            MatchResult result = expression.Match(attempt, String.Empty);

            // check that there are no trailing tokens
            if (result.IsMatch && attempt.GetToken() != null)
            {
                result.IsMatch = false;
            }

            return result;
        }