/// <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); }
/// <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); }