Strict generation mode failure: bad context for weaving rule: CorkboardState_Protein is generated by 'create root' rule


I'm trying to use a weaving rule in a root class template and I'm getting this message.

Could anyone please help explain this?

I've also tried:

genContext.get copied output for (node.ancestor<concept = ClassConcept>);

Is this a way to go?

Anyway it gives me an error:

failed to generate output after 10 repeated mappings
to get more diagnostic generate model with the 'save transient models' option
Generation failed for model 'EventLang.sandbox': failed to generate output after 10 repeated mappings.
generation completed with errors in 79 ms
Error executing target jetbrains.mps.lang.core.Generate.generate

Any help appreciated.

Btw, I'm trying to create a little language to alleviate the drudgery of events/listeners in java; quite similar to Property in MPS's java extensions.

Maybe such things already exists?
Does using weaving rules require mapping label (on Template Fragment) to work?
I've re-done my attempts, starting from scratch (to avoid any potential interference with other things), and using a mapping label. Still getting "Generation failed for model 'EventLang.sandbox': failed to generate output after 10 repeated mappings. ", so I hope someone could help me solve this!
I've also looked at the decision tables example in MPS examples folder, and I cannot spot the difference (what I'm doing wrong).

Could it be forbidden to weave from a class member (the event declaration) to another class member (a class field) ?
What is the best step-by-step tutorial showing how to do a weaving rule correctly?
I mean a tutorial that would use this as the weaving context :
genContext.get copied output for (node.ancestor<concept = ClassConcept>);
Here - - Evgeny Gryaznov says:

Weaving rule is a kind of hack, it makes generator hard to understand, cannot be applied in parallel, etc. It's better to avoid using it if possible (replace with a copy_src macro in the appropriate places).

Is this [still] true?

Can I even implement something like Property without a weaving rule?
Ok, seems like the solution is to make a REDUCTION rule, which abandons its input for the Event, with "<abandon input>".

Could that be the real solution and a safe one?

Wouldn't it risk some sort of "race condition" (metaphorically), in the generator, threatening to kill the class member node before it gets its weaving?
Weaving rules are indeed (inevitable, for now) evil. I would suggest to avoid them unless there's no other way to proceed.

The initial error message ("bad context for weaving rule: XXX is generated by 'create root' rule") doesn't really prevent you from using weaving rule. In a strict generation mode, there's a check to ensure input nodes weaving rule is applicable to match output nodes it's applied to. With an output node coming from a 'create new root' rule, there's no input nodes to match, hence the message. IOW, weaving rule is applied to INPUT nodes, and the query with output nodes merely gives a context to insert nodes into, thus no input effectively means no weaving could be applied. If you turn strict mode off, weaving would proceed then.

Please sign in to leave a comment.