Beispiel #1
0
        public Feature Parse(TextReader featureFileReader, string sourceFilePath)
        {
            var fileContent = featureFileReader.ReadToEnd();

            var language = languageServices.GetLanguage(fileContent);

            I18n languageService = languageServices.GetLanguageService(language);
            var gherkinListener = new GherkinListener(languageService);
            Feature feature = Parse(fileContent, sourceFilePath, gherkinListener, languageService);

            if (gherkinListener.Errors.Count > 0)
                throw new SpecFlowParserException(gherkinListener.Errors);

            Debug.Assert(feature != null, "If there were no errors, the feature cannot be null");
            feature.Language = language.LanguageForConversions.Name;

            return feature;
        }
Beispiel #2
0
 private Feature Parse(string fileContent, string sourceFilePath, GherkinListener gherkinListener, I18n languageService)
 {
     try
     {
         Lexer lexer = languageService.lexer(gherkinListener);
         lexer.scan(fileContent, sourceFilePath, 0);
         return gherkinListener.GetResult();
     }
     catch(SpecFlowParserException specFlowParserException)
     {
         foreach (var errorDetail in specFlowParserException.ErrorDetails)
             gherkinListener.RegisterError(errorDetail);
     }
     catch (Exception ex)
     {
         gherkinListener.RegisterError(new ErrorDetail(ex));
     }
     return null;
 }