MPS
 
Get MPS

Behavior

Last modified: 11 February 2024

During syntax tree manipulation, common operations are often extracted to utility methods in order to simplify the task and reuse functionality. It is possible to extract such utilities into static methods or create node wrappers holding the utility code in virtual methods. However, in MPS a better solution is available: the behavior language aspect. It makes it possible to create virtual and non-virtual instance methods, static methods, and concept instance constructors on nodes.

Behavior example

The methods in the Behavior aspect are implemented using BaseLanguage, typically enhanced with extensions:

  • the collections language for intuitive collection API

  • the closures language for easy use of function literals

  • the smodel language for manipulating the code (structure)