Java / Abstract Syntax Tree into XML representation

后端 未结 2 2056
半阙折子戏
半阙折子戏 2021-01-14 20:28

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?

kind re

2条回答
  •  既然无缘
    2021-01-14 20:32

    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.

    See What would an AST (abstract syntax tree) for an object-oriented programming language look like?.

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

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

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

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

    • 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

提交回复
热议问题