Angel \”Java\” Lopez on Blog

March 14, 2011

More Language Workbench Competition 2011 with AjGenesis

Filed under: AjGenesis, Code Generation, Lwc2011 — ajlopez @ 9:03 am

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:

under examples/Lcw2011

This step was an easy one. The Project.txt is:

Project Lwc2011
		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
		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"
		Entity Person Source="Entities\Person.txt"	
		Entity Car Source="Entities\Car.txt"
	End Entities
		Instance p 
			Type = "Person"
				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"
				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.

Keep tuned!

Angel “Java” Lopez

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: