public void TestProtcolBuffersV3Grammar() { var testDirectory = Directory.GetCurrentDirectory(); var ebnfPath = Path.Combine(testDirectory, "Runtime", GrammarFile); var ebnf = File.ReadAllText(ebnfPath); var ebnfGenerator = new PdlGrammarGenerator(); var ebnfParser = new PdlParser(); var ebnfDefintion = ebnfParser.Parse(ebnf); var parseEngine = new ParseEngine(ebnfGenerator.Generate(ebnfDefintion)); var inputPath = Path.Combine(testDirectory, "Runtime", ProtoFile); var input = File.ReadAllText(inputPath); var parseRunner = new ParseRunner(parseEngine, input); while (!parseRunner.EndOfStream()) { Assert.IsTrue(parseRunner.Read()); } Assert.IsTrue(parseRunner.ParseEngine.IsAccepted()); }
private static IGrammar GenerateGrammar(PdlDefinition definition) { var generator = new PdlGrammarGenerator(); return(generator.Generate(definition)); }