Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Conditional template(Is it possible ?)
Conditional template [message #641469] Thu, 25 November 2010 15:26
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
My problem is the following:

I have developed a DSL with XText, to specify agriculture development models and then run calculations on them. So far so good.

One possible element of a model is 'herd' , it includes a demographic model for herd populations projections over time.

In the initial version the herd population model is structured in six 'compartments' defined by the sex (M or F) and the age category (Juvenile, Sub-adult and Adult).

A number of parameters (e.g. mortality rates) require a value for each compartment for each year of the projection. I have a template that works fine and produces the following for each such parameter:

Intake numbers
Female - Juvenile = [ 0 0 ] ;
Female - Sub-adult = [ 0 0 ] ;
Female - Adult = [ 0 0 ] ;
Male - Juvenile = [ 0 0 ] ;
Male - Sub-adult = [ 0 0 ] ;
Male - Adult = [ 0 0 ] ;

Now I want to expand the model and make the number of age groups for each sex a variable. If for example it is 4 for females then the template should be:
Female - 1 = [ 0 0 ] ;
Female - 2 = [ 0 0 ] ;
Female - 3= [ 0 0 ] ;
Female - 4 = [ 0 0 ] ;

Is there a way for the editor to set the template programmatically by reading the number of age classes as they are entered and generating accoordingly, for example, a sub-template "list of classes" .

Or alternatively could the content of the sub-template be written in such a way that it can be passed the number of age classes and define itself accordingly ?

Thanks in advance
MS
Previous Topic:[Xtext] Does Xtext really support LL(*) parsing?
Next Topic:Why can't a user define a grammar that doesn't extend another grammar?
Goto Forum:
  


Current Time: Fri Apr 19 19:25:14 GMT 2024

Powered by FUDForum. Page generated in 0.04052 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top