How to do "or" creating DSL? What is the right way?

I am new in MPS world... and wondering what is the right way to do something like...

terminal terminal01 = create bash terminal
terminal terminal02 = create ssh session terminal

Lets forget about this "Terminal terminalXX".

My question is how to do DSL in which I have "create", then "bash" OR "ssh"... and then only if "ssh" was entered "session" is allowed.
I know how to write such grammar in ANTLR for example... but I don't know how to write such thing in MPS... expecialy in proper way.
Should I for example create "create" concept which has "bash" and "ssh" concepts as children and then change its visibility using inspector and... actions(?). Or should I create... concepts... two different or more... But I don't know what these concepts should look like.

So I want to create such flow:

             ----- bash ---------------------
create --|     | --- terminal
             ----- ssh  ---- session -----

Please help.
Comment actions Permalink

from the brief sample you gave I would propose the following solution:
  • Make a "Create" concept with a child "what" of abstract concept "TerminalKind". Give it an alias "create".
  • Create an abstract concept "TerminalKind" with two concrete subconcepts - "BashTerminal" ad "SshTerminal". Set their aliases to "bash" and "ssh" respectively.
  • Define the editor for "Create" as [- create % what % terminal -] (Note the words "create" and "terminal" are constant cells, while %what% is a reference to the "what" child.)

This should give you the desired syntax.
Comment actions Permalink
Hi Vaclav,

Thank you for reply. I fully understand your solution.
So every time one needs "or" one should use subconcepts.

Thank you.

Please sign in to leave a comment.