What is a reference in structure

What is the use of reference in structure. I am confused with children and reference

For example, add=value1+value2 

I have to create a concept add with children value1 and value2

In both children, I have to create a property called value1/value2 with integer datatype
In this case, what is the role of reference.

1 comment
Comment actions Permalink

Rahul, have you already had a look at the MPS fast track? There is also a nice set of screencasts that help you understanding the basic concepts of MPS.

With regard to your question: a reference allows you referring from one node to another across the AST. For instance, we can refer to a variable declaration node using a node of the VariableReference concept (find the concept using cmd/ctrl + n). As we point in the reference's default editor to the variable declaration's name, altering the declaration's name results in automatically altering the callee's name.

Try something like the following to see it in action and understand the AST by using the node explorer (alt+f12):

int x;
x = 5;

Regarding your task I suggest you to have a look at the BinaryOperation concept. It might provide you a good basis for what you like to achieve.



Please sign in to leave a comment.