Class costructor or ClassifierType generation

Hi,

  How to generate suitable template fragment in some cases? For example for concept "IntegerType" I have two template fragments: ClassifierType (IntType) and ClassCreator (IntType()), but I don't know how to generate concrete fragment in suitable case. What technology I must use to do this? Example, pls, if you may :-)

Regards,

Oleg

1 comment
Comment actions Permalink

Oleg,

If you need to explicitly choose a template fragment to generate code with, you can use $INCLUDE$ macro in your generator.

But mostly you don't do it explicitly. In the example you provided, you should use different concepts for the type itself and for creation of type.

Let's consider some example from MPS:

Screen shot 2010-03-29 at 2.17.12 PM.png

Here the leftmost "linkedlist" is a LinkedListType, while the rightmost is LinkedListCreator. Generated code depends on concepts of nodes.

If you don't want to create two concepts (in the example - for each collection type), you can create a MyCreator concept, and reference collection's type inside of it. Then you can write a guarding condition for reduction rule for your types - that this rule is not used for nodes inside MyCreator concept:

Screen shot 2010-03-29 at 2.25.18 PM.png

In that case, you generate a type, in another - creation expression.

Regards,

Mihail



Attachment(s):
Screen shot 2010-03-29 at 2.17.12 PM.png
Screen shot 2010-03-29 at 2.25.18 PM.png
0

Please sign in to leave a comment.