抽象语法树转换为XML表示

抽象语法树转换为XML表示

本文介绍了Java /抽象语法树转换为XML表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你知道从Java程序或类创建AST的任何工具,并从AST创建XML表示(集合或单个XML文档)吗?

do you know of any tool which creates an AST from a Java program or class and creates an XML representation (Collection or single XML document) from the AST?

亲切的问候,

Johannes

kind regards,
Johannes

推荐答案

我们的及其可以直接执行此操作。您要求DMS解析文件,并使用命令行开关++ XML生成XML转储。

Our DMS Software Reengineering Toolkit with its Java Front End can do this directly. You ask DMS to parse the file, and produce an XML dump using a command line switch ++XML.

请参阅。

作为一般规则,我们不建议这样做,原因如下:

As a general rule, we don't recommend this, for several reasons:


  • 真实文件的XML输出非常庞大,并且需要花费大量时间来编写和阅读

  • XML output for real files is really enormous, and takes a lot of time to write and read

大多数人这样做是因为他们相信XML表示只需要一点点XSLT就能得到他们想要的东西

Most people do this because they believe with an XML representation that just a little bit of XSLT will get them what they want

如果你打算修改代码,一旦你拥有了XML,你几乎无法重新生成它。

If you intend to modify the code, once you have the XML you pretty much can't regenerate it.

DMS提供的机制(属性语法,符号表,流分析,模式匹配)和源到源的转换,源再生来自AST的n,是你真正想要的,并且你可以在解析步骤之后使用DMS来访问它而不导出XML

The machinery that DMS provides (attribute grammars, symbol tables, flow analyses, pattern matching and source-to-source transformations, source regeneration from the AST, is what you really want, and you get access to it by using DMS after the parsing step without exporting the XML ever

这篇关于Java /抽象语法树转换为XML表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 18:00