Several copySRC with different reduce-rules

Hi,

i need to copy a node in two different places in a model. (e.g. in the declaration part and the initializing part.)

I want both nodes to be reduced with different reduction rules.

Can I use a mapping-label to distinguish the nodes? How to do that?

Thank,
Michael
3 comments
There are several ways to attach some information to a node (to distinguish it later).

a) create an internal concept, wrapping the node and adding generator-specific properties
b) create an annotation (NodeAttribute)
c) use genContext.session/step/transient object maps

If you need two different set of rules, use TemplateSwitch and $SWITCH$ macro. Switch defines a named set of rules, which can be extended (specified) in sub-languages.

There can be a problem if you reduce an arbitrary input node (like Expression, Statement or Type) twice. Another generator may rely on mapping labels (which will contain several output nodes for the input node). General rule is to avoid such situations. Create a separate mapping configuration (executed strictly before the original one) or pre-processing script to clone the node and mark it as "a copy for goal X".
0

Not sure if we mean the same thing but I
also use a Concept from both declaration and implementation.
I use two different generator reduction rules by
having a check in the condition like this:
node.ancestor<concept = Declaration> != null

seems to work so far.
0
Solved my problem using c)

@ rzw. What I need to do is a bit different. I have one concept in the inputModel and need it for generation at several places in the outputModel.
0

Please sign in to leave a comment.