Update for MPS's "The Simplest Language Tutorial"
I take the liberty of making the Errata(or Update) for MPS's "The Simplest Language Tutorial". I think, that it is very useful tutorial especially for beginners, but at this moment there is some differences between tutorial and the current MPS EAP Build.
I've read, that "The Simplest Language Tutorial" might be considered as obsolete tutorial, and that the new more comprehensive tutorial will be (and have been) created (For example RegExp Tutorial , or this Flash Demo).But I stand for basic HelloWorld tutorial, at least for keeping programmers tradition ;).
Of course any comments and errata for this errata are welcome :-)
Disclaimer
I'm only a newbie user of MPS and I don't work in JetBrains. Here I write about MPS EAP Build #470 and I use Windows XP SP 2.
I've make this errata from this forum's messages,
when struggle with Build #470 and "The Simplest Language Tutorial", so let's begin:
Prerequisites:
- JRE 1.5.0
- JetBrains IntelliJ IDEA installed (I use IDEA 7.0). I think you can't use IDEA 6.0 (As Igor Alshannikov said - "Please also be advised that MPS plugin in b 415 is not fully compatible with idea 6.0." )
- JDK 5.0 (1.5.0)
Tips:
-
"After the plugin is installed, MPS starts up with its main window. We will immediately begin by creating a new project using the File > New Project..."
Check that you have pointed your IDEA to your JDK:Run IDEA, Go to File -> Settings -> Project Settings -> Platform Settings (in the same Project Settings window) -> if there isn't JDK 1.5 in the list, then click -> Add new JDK ('Plus' button on top)
You can read this forum message and even see screenshot about this jdk-checking process.
If you don't do the this step, you might see the message "can't find suitable JDK .Install JDK 5.0 and register it in IntelliJ IDEA.", when you try to create new project. -
"The solution 'main' is newly created. Now we should add languages used by the solution."
Then tutorial ask you to add a path to "Language roots" property in Solution Properties dialog.
As I understand we can simply not to do that in Build #470. -
"Next we will add a property to the concept. Click on the empty 'properties' list,..."
When you create TheSimplestConcept don't forget set "isRoot" property to true (in Build #470 it's value is false by default)
If you don't do that you will not be able to create new root node in Model's menu Create Root Node. You can read about this in this message. - In Solution Properties write TheSimplestLanguage (the name of your language) in "dependencies" property. This property is absent on the Tutorial's images.
If you don't do that you can't complete Create New Model step of tutorial. To read more see there. -
"Add a mapping rule to the mapping rules list. MPS currently uses what are called 'query methods' to ...."
When the Tutorial had been written, there wasn't Query Language in MPS. And we have to code the queries in plain Java, but from some build version (unfortunately I can't specify version) we can use Query Language. So when we create generator we need't write the code:ArrayList result = new ArrayList();
for (SNode node : generator.getSourceModel()) {
if (node instanceof TheSimplestConcept) {
result.add(node);
}
}
return result;And when we create the mapping rule we can do that by MPS as it shown there
-
"We will turn this sample text into a macro by pressing Ctrl-Shift-M. This creates a property macro."
When you create "property macro" choose "add/remove property macro", not "add node macro"
And after you choose "add/remove property macro", the tutorial ask you to code that:return ((TheSimplestConcept) sourceNode).getMyText();
You don't do it. You do that by create macro body in query language, see there
And you need to write you language name in template's source field, again see there, I point it out on that picture.
Thank you,
Attachment(s):
mapping rules.JPG
property macro.JPG
Please sign in to leave a comment.
Thanks for helpful feedback.
In future, we are going to recreate hello world tutorial so it will be up to date with MPS state.