Overloading text Generation or call explicit text generator function
Hi
I am trying to overload the default text generator for MPS BinaryOperation in base language. However when the text generation executes it triggers the default one not my new one.
Is it possible:
- to point the text generator to my newly created text generator OR
- call an explicit text generator function
Thanks,
Chris
Please sign in to leave a comment.
Text generation relies on node's concept to find out appropriate generator. You can supply own text generator for a subclass of BinaryOperation, but not for the original class. The only feasible way to alter generation of a foreign concept is to annotate a node, and have text generator for the annotation (which may, but doesn't have to, delegate to original text generator).
The tricky part about overriding existing generators would be to tell MPS which overrides to use, provided there's more than one. Imagine there's a mechanism to override a textgen for BinaryOperation. What if there are two languages (from independent vendors) that would like to override BO textgen, which one MPS is to pick? MPS now approaches this with node attributes, that get consulted in specific order and thus give language designer control over override mechanism, with the price of modifications in a user's source model.