In my previous post I described my initial work for Language Workbench Competition 2011, using AjGenesis. Now, it’s time to write about some new tasks I wrote. You can read the tasks of the competition at:
First, I skipped Phase 0.3 (constraint checks such as name-uniqueness). I plan to complete it, but not now. I wrote Phase 0.4:
0.4 Show how to break down a (large) model into several parts, while still cross-referencing between the parts. For example, put the Car and Person entities into different files, while still having the Person -> Car reference work.
The code was committed to AjGenesis repository:
This step was an easy one. The Project.txt is:
Project Lwc2011 Entities Entity Person Source="Entities\Person.txt" Entity Car Source="Entities\Car.txt" End Entities End Project
The Source attribute is special in AjGenesis model loading: it indicates a separate file to load in order to complete the object. I added this feature in the early times of AjGenesis: I want to have model files that are manageable, that don’t hurt the eyes ;-)
This is Person.txt:Entity Person Properties Property Name Type="Text" Property FirstName Type="Text" Property BirthDate Type="Date" Property OwnedCar Type="Car" End Properties End Entity
I began to write Phase 1.0 first step:
1.1 Show the integration of several languages. Define a second language to define instances of the entities, including assignment of values to the properties. This should ideally really be a second language that integrates with the first one, not just "more syntax" in the same
grammar. We want to showcase language modularity and composition here.
This is the new model:Project Lwc2011 Description = "Lwc" Entities Entity Person Source="Entities\Person.txt" Entity Car Source="Entities\Car.txt" End Entities Instances Instance p Type = "Person" Properties Property Name Value = "Voelter" Property FirstName Value = "Markus" Property BirthDay Value = "14/02/1927" Property OwnedCar Value = "c" End Properties End Instance Instance c Type = "Car" Properties Property Make Value = "VW" Property Model Value = "Touran" End Properties End Instance End Instances End Project
But it’s still work in progress. I could put the instances in another independent model file (Instances.txt) or I could put the each instance in a separate file, referenced by the above one using Source attribute. I should complete the tasks checking the existence of each property in the entity type that correspond to each instance. AjGenesis doesn’t support Domain-Specific Language definition: the above example is still a free model. You can add any property to any instance, and the current implementation doesn’t check the proper use of the model. So, this kind of check is pending work: I will add the checking logic in the tasks to execute.
Apparently, this task doesn’t involve code generation. In the next task, I should check the values of the properties, too.
Angel “Java” Lopez