Example #1
0
        public void WhenTheInputSourceIsCompiledWithTheBerpGrammarParserForTestParser()
        {
            ParseWithErrorHandling(parser =>
            {
                ruleSet = parser.Parse(new TokenScanner(new StringReader(sourceContent)));
                testOutputHelper.WriteLine(ruleSet.ToString());

                var states = StateCalculator.CalculateStates(ruleSet);
                testOutputHelper.WriteLine("{0} states calculated for the parser.", states.Count);
                foreach (var state in states.Values)
                {
                    PrintStateTransitions(state);
                    PrintStateBranches(state.Branches, state.Id);
                }
            });
        }
        public void WhenTheParserGenerationIsPerformedUsing(string templateName)
        {
            var parser  = new BerpGrammar.Parser();
            var ruleSet = parser.Parse(new TokenScanner(new StringReader(grammarDefinition)));
            var states  = StateCalculator.CalculateStates(ruleSet);

            try
            {
                var generator = new Generator(ruleSet.Settings);
                outputFile = TestFolders.GetTempFilePath("output.txt");
                generator.Generate(Path.Combine("GeneratorTemplates", templateName), ruleSet, states, outputFile);
            }
            catch (Exception ex)
            {
                generationError = ex;
            }
        }