How to create branching?

Hi all, I have no full comprehension, about creating key words branching in MPS.

For example:

Customers Add <name>
Customers Delete <name>


Am I right that I need to use alternation or if? Have anybody any use cases or links about it?

3 comments
Comment actions Permalink

No. You use concept inheritance in that case.

E.g.

1) create CustomersStatement with reference to Action concept (this is a concept for all "Customers" statement)

2) create 2 concetps inherited from ActionConcept - AddAction and DeleteAction (these are "add" and "remove" parts)

If these statements have nothing in common, then it's better to create a sort of "MyStatement" concept and two inherited concepts - "AddStatement" and "DeleteStatement".

It's hard to say what is better because it depends on the full syntax of your language (can something be used instead of "Customers" in these statements?)

There is no alternation here, it's only a fact that child concepts can be used everywhere where parent concept can.

Regards,

Mihail

0
Comment actions Permalink

Thanks, it was very helpful.
But how to use alternation or if, in what cases? And how it would be looks in editor?

0
Comment actions Permalink

You mean if and alternation for cells in editor? Thean it can be used for conditional cells.

E.g. you have a concept and an editor for it, but in some cases you don't want to show a part of your editor (for default case). In this case, "if" is what you need.

If you need some examples, it's quite easy to find many:

1) in editor, make some cell and create condition for it.

Screen shot 2010-03-27 at 5.48.51 PM.png

2) select the whole condition cell with ctrl-w in inspector

Screen shot 2010-03-27 at 5.48.58 PM.png

3) press ctrl-shift-S. The concept for the selected node will be opened

4) alt-F7 on concept name to search for usages

Screen shot 2010-03-27 at 5.50.16 PM.png

5) check only "node usages" in dialog

Screen shot 2010-03-27 at 5.50.22 PM.png

6) search for usages

Screen shot 2010-03-27 at 5.50.29 PM.png

7) double-click on "rendering condition" if you want examples for conditional cells


8) search for "link instances" on "rendering condition link"

9) voila - 400+ examples for you :-)

You can also search for examples of alternation (see screenshot for step 6). I think the most understandable examples are in baseLanguage.

Regards,

Mihail



Attachment(s):
Screen shot 2010-03-27 at 5.48.51 PM.png
Screen shot 2010-03-27 at 5.48.58 PM.png
Screen shot 2010-03-27 at 5.50.16 PM.png
Screen shot 2010-03-27 at 5.50.22 PM.png
Screen shot 2010-03-27 at 5.50.29 PM.png
0

Please sign in to leave a comment.