Standard format for concrete and abstract syntax trees

I have an idea for a hobby project that does some code analysis and manipulation. This project will require both concrete and abstract syntax trees for the given source file. In addition, bidirectional links between two trees are useful. I would like to avoid the work of decoding the grammar in order to build my own lexer and parser.

Is there a standard format for describing concrete or abstract syntax trees? Do any commonly used toolchains support output to these formats?

I do not have a specific target programming language. Any popular one will do for the prototype, but I would prefer that I know well: Python, C #, Javascript or C / C ++.

I need the ability to run the source file through a tool or library and return both trees. In an ideal world, it would be practical to run this tool by code, as it is edited by the user and makes mistakes. Again, I'm just trying to develop a prototype, so these requirements are pretty weak.

Thanks!

+5
source share
3 answers

In our project, we defined the AST metamodel in UML and use ANTLR (Java) to populate the model. We also save token information from ANTLR after parsing, but we have not yet tried to update the base text file with the changes made on the model.

( , Eclipse UML2/EMF), - /MDD, MDA, .

, OpenArchitectureWare Eclipse, ( UML ) , .

ANTLR .

+2

, , . . http://www.gupro.de/GXL

OMG . . http://www.omg.org/spec/ASTM/1.0/Beta1/

, , . " ", , . , ) [ , LISP,   XML,...], , ) , , AST; /, , , . , , .

, lisp -like , node :   (...) .

. AST, . , , - , a node . - (. :), , , ( ) . [ , - " ", ]

+4

- , . GXL RDF , , . .

ASTM, , ( ), / , ISO-IEC 24707 2007.

, : XML.

I do not know of a single efficiently used standard (in this area, where home cooking is always prepared), I am also interested in this topic.

+1
source

All Articles