2

Abstract Syntax Tree Metamodel (ASTM) is an OMG standard to represent ASTs.

In my very partial and limited understanding (I only spend an hour or two glancing into that spec), it is notably defining some XML representation for some kind of ASTs, and claims to be some kind of universal representation.

However, after having glanced into the ASTM spec (which I feel is implicitly focused for Java and perhaps C and maybe C++), I don't understand how it can be used for other languages like Scheme, Ocaml, Haskell, Scala, Clojure ...?

Could anyone give me several examples of ASTM in XML?

  • what is a possible XML representation of the ASTM for a very minimal hello-world program in Java or in C? I would be delighted with a concrete example.... (both the tiny C or Java source file, and the corresponding ASTM XML file)

  • what would be a possible XML representation of the ASTM for some small program in Scheme or Ocaml? My feeling is that it often would be impossible (e.g. because some syntactic constructs like let-bindings or pattern clauses are not even mentioned in ASTM standard)

  • it seems that C++11 lambda-s and probably Java8 lambda-s cannot be represented in ASTM.... If that is possible, how?

I am very probably misunderstanding the whole point of ASTM.

addenda:

Javier Luis Cánovas Izquierdo mentioned me some XML examples of ASTM:

https://github.com/jlcanovas/gra2mol/tree/master/examples/Grammar2Model.examples.Java2ASTMModel
https://github.com/jlcanovas/gra2mol/tree/master/examples/Grammar2Model.examples.PLSQL2ASTMModel

  • 2
    I don't use it and can't provide an answer, but I concur that this looks like an universal representation of ASTs for a very narrow subset of languages. – coredump Feb 05 '16 at 13:34
  • It's vaguely reminiscent of Expression Trees in C#. I would imagine that you'd have something reasonably representative of the standard if you serialized such a tree to XML. – Robert Harvey Feb 05 '16 at 15:01

1 Answers1

2

The standard is intended to be extended, as necessary, to support other language concepts (see pages 18-19 of the PDF). It is basically a general purpose abstract syntax tree with provision to add new node types to model concepts not already included.