Writing Model-to-Text Transformations with VM2T 
 

Find a partner and form a group of two.  As a group you will make one submission.  Download Avalon, unzip it and follow the installation instructions.  Doing so, you should be able to run the vm2t tool:

> java vm2t.Main

Usage: vm2t.Main prolog-file template-file [output-file] [-cg ContextGeneratorClass]
if output-file is unspecified, output is directed to file vm2toutput.txt

Next, you should read the vm2t manual, which you will find in the  mdelitedir/MDELite3_05/Docs directory of the Avalon download.  Read it and the  MDELite manual which is in the same directory.


Part 1

Given the following state machine and its vm2t prolog representation (click here) which was discussed in class:

Write a vm2t program that produces the Java code represented by the figure below, where each Java class definition has its own file.  An example is here (USE THIS AS A TEMPLATE).


You are to run your generated code using app.java.  Example output is shown here.

Hint: You will have to supply actions for state transitions.  The prolog database that I give you defines all legal transitions.  Any other transition is "illegal".  For legal transitions, print "going to <state>", where <state> is the next current state and transition to that state.  If illegal, print "ignoring transition to <state>" and stay in the same state.


Part 2

One of the important ideas about MDE is that the essence of a design can be captured in a very abstract way -- namely the tuples of a prolog database.  The next part of this assignment is to generate a completely different implementation of the FSM from the same prolog database.  The code for this implementation is sketched in this file.  Both implementations should compile and when run with app.java, producing the same result.


Part 3

Your .vm files (that is, model-to-text mappings) should be general -- not specific to the finite state machine given above.  Hand-create another FSM and its prolog database definition, and show that your .vm file produces the correct code for your example.


What to Submit via Canvas

Submit a single zip file to Canvas.
  1. The zip file should unzip into <yourName>/<yourFilesAndDirectories> (I will return submissions that do not satisfy this constraint)

2.    your .vm files

3.    your .pl file that contains your hand-written FSM prolog-database

4.    a .pdf document that explains your design, program, and anything I need to know to evaluate what you have done.  If no PDF document is submitted, I will return your assignment with no grade.

5.    a bash-script called run.script that will run your examples (so that it is easy for me to see what you have done).

A critical part of any design is clarity and understandability.   Hence, you will be graded on the clarity of your project and its ability to work correctly.  Sloppy code, documentation, or anything that makes grading or understanding your program difficult will cost you points.  Beware, some of these "beauty" points are subjective. 

Remember: No late assignments/submissions will be accepted.