public void TestEvalution2() { string docPath = @"E:\桌面工作目录\正在进行的\Projects\PonyText\README_PonyText.pony"; ErrorListener listener = new ErrorListener(); PonyLexer lexer = new PonyLexer(); PonyParser parser = new PonyParser(lexer); lexer.errorListener = listener; parser.errorListener = listener; PonyTextStructureBase structureBase = parser.Parse(File.ReadAllText(docPath)); AssemblyInjectionManager injectionManager = new AssemblyInjectionManager(); injectionManager.RegisterAssembly("PonyTextRenderer.Markdown", Assembly.GetAssembly(typeof(MarkdownRenderer))); injectionManager.RegisterAssembly("PonyText.Processor", Assembly.GetAssembly(typeof(PonyParser))); IProcessorFactory processor = new ProcessorFactory(new ProcessorExperience(), injectionManager); SimpleTextContext simpleTextContext = new SimpleTextContext(processor, new TextElementFactory()); processor.LoadProcessorFrom("PonyText.Processor"); Assert.DoesNotThrow(() => { structureBase.Evaluate(simpleTextContext); }); using (FileStream fs = new FileStream("dump.json", FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.Write(simpleTextContext.GetCurrentContext().ToString()); } } MarkdownRenderer stringRenderer = new MarkdownRenderer(); simpleTextContext.GetCurrentContext().Render(stringRenderer, simpleTextContext); using (FileStream fs = new FileStream("out.md", FileMode.Create)) { stringRenderer.RenderContentTo(fs); } }