I am trying to do automated programming research: business software generation from the knowledge base that is implemented as Scheme (Lisp dialect) code (in the framework of http://opencog.org/ Atomspace). My question is - how to generate Java source code in academically acceptable way?
I know or I can imagine several ways:
- Raw code generation: I can predict what classes and what members can be and create one large literal constant that is the source code.
- Find or implement templating engine like Visual Studio's T4 templates
- Find something about code generation from the UML models. I don't know yet how MDD tools implement such generation
- I can genereate Java Abstract Syntax Tree in my Scheme code and then find tools generate Java source code from Java AST. Actually this could be - in my opinion - the most academically correct way that is also the best integrated in my workflow and that is the most extendable. My OpenCog Scheme Atomspace in effect is large hypergraph and Java AST is (hyper)graph to, so - AST generation reduces to the graph transformation. This seems the path to follow, isn't it?
There are some technical questions as well - are there tools that accept Java AST (in some form) and that generate Java source code? Can such AST-2-code tools be generated from the formal grammar of the programming language (https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html is example of the specification in the free, readable form)?
So - the question is - what is the best practice of code generation in the computer science academic project?