[great-users] Generating code with Great
Sandeep Neema
sandeep at isis.vanderbilt.edu
Fri Sep 24 19:09:04 CDT 2004
All,
The 'CreateNew' construct in GReAT typically constructs a 'model type'
(in the GME types/instances sense). Is it possible to create 'model
instances' with the 'CreateNew' construct.
Thanks
Sandeep
--
Sandeep Neema
Research Scientist,
Institute of Software Integrated Systems, Vanderbilt University
Phone: 615-343-9996
Email: sandeep.k.neema at vanderbilt.edu
-----Original Message-----
From: great-users-bounces at list.isis.vanderbilt.edu
[mailto:great-users-bounces at list.isis.vanderbilt.edu] On Behalf Of
Aditya Agrawal
Sent: Friday, September 24, 2004 2:26 PM
To: Zonghua Gu; great-users
Subject: Re: [great-users] Generating code with Great
Please see inserts.
Zonghua wrote:
> If I want to generate code in a programming language like Java with
> GReAT, I will need to construct a meta-model for Java in GME. But it's
> not clear to me how to do this. In the compiler area, Java code is
> parsed into an abstract syntax tree (AST), which is further processed
> into machine or byte code. I wondering if we can establish some kind
> of link between AST and meta-model, perhaps using GReaT to generate
> AST, then trivially map AST into Java code?
Yes you do have to create a metamodel for Java. Now there are many
choices.
1. One choice is, as you mentioned create a metamodel that shadows that
Java AST, have a code generator that can convert this shadow AST to Java
code.
2. The second choice, is to create a coarse grain AST structure for
Java. For example, you create a metamodel that models classes,
functions, variables, code blocks but the statements inside the code
block are represented as text variables. I have used this style in cases
where I have these small code fragments that I can use and I am doing
higher level composition.
3. The third choice, is to create a metamodel for the class of
applications rather than for Java. For example, if you want to have your
Java program implement state machines, you may want to create a
metamodel for representing state machines and then you could write
different code generators that would generate Java and potentially code
for other languages.
4. There was an effort by Abdul (I have cced him on the mail) who tried
to create a generic AST for OO languages and then specialize it for a
particular OO language.
Abdul, could you please tell us more about that.
> Another question: Suppose I want to generate output in XML to feed
> into another tool like UPAAL, which already has a dtd (data type
> definition) format defined. Is there a way to "reverse engineer" from
> a dtd file into a meta-model? We can use UDM to generate dtd from
> meta-model, can we go the other direction?
Currently with UDM you cannot create XML files that conform to a
predefined DTD. Some of the things we have done in the past is to create
a DTD using UDM which is very close to the target DTD. Then use GReAT
and other methods to create instances of these DTD and finally use a
simple (hopefully) XSLT script to convert the UDM XML file to the
required XML file.
Another choice is to use UDM Pat (UDM pattern processor) or a visitor on
the UDM objects to generate the required XML format.
Thanks,
Adi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/great-users/attachments/20040924/1b68f1f0/attachment.htm
More information about the great-users
mailing list