public T Parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher) { tokenMatcher.Reset(); astBuilder.Reset(); var context = new ParserContext { TokenScanner = tokenScanner, TokenMatcher = tokenMatcher, TokenQueue = new Queue <Token>(), Errors = new List <ParserException>() }; StartRule(context, RuleType.CucumberExpression); int state = 0; Token token; do { token = ReadToken(context); state = MatchToken(state, token, context); } while(!token.IsEOF); EndRule(context, RuleType.CucumberExpression); if (context.Errors.Count > 0) { throw new CompositeParserException(context.Errors.ToArray()); } return(GetResult(context)); }