Meta Programming System
Newbie: Help with "Constants" Tutorial
I've gone through "episode one" of the this tutorial series and while there were some minor differences between my and their version of MPS, I got through it just fine. I've run into trouble with the second episode.
At about 8m30s, the type of the static field declaration is parameterized with a COPYSRC macro. We've defined the input of the template-based generator as a "Constant" (reduce_Constant), which has been given a single child ("initializer") from the Expression structure(?) of the baseLanguage. In the video, completion finds the "type" property(?) of the "initializer".
In my version of the project, I get no such completion for "type" (if I type it in, I get an "AbstractConcept" error). I then opened the sampleJavaExtensions/languages/Constants project for comparison. That project seems to work just fine; I attempted to make mine look as much like the sample without adding new features not yet presented in the tutorial series - no luck. I tried many variations of rebuilding/(project/model)checking, etc.
Since I'm new, I don't know what else to try; can someone recommend how I might debug this?
I've attached the build.number file from my MPS installation directory.
I haven't looked at the video, but one of the common errors with generator templates is to try to add a macro in a wrong context. Make sure you position the cursor over the exact character shown in the video. One character difference to the left or right can be outside of the context that you are trying to replace.
You can verify you are on the correct type of node by navigating to this node (Right-click> Go to > Concept Declaration). If you still have trouble, I would recommend the generator chapters in my book that explains this in detail. See
go to parent
So, I just noticed the "tutorial" tag in this forum. I found,
This appears to have been the same problem I encountered. The issue appears to be that jetbrains.mps.lang.typesystem should be extended where the sandbox needs to "use" both the Constants and baseLanuage languages. Also, there's a note I missed in the comments for the video that would have prevented my confusion.
Given that the problem was not having extended the typesystem, how might I have known that that was the problem?
What sort of thing is node.intializer.type? How could I "look" at a particular language to determine whether or not it would have added such a ".type" to my node.initializer?
Admittedly, the "Constants" video is one of the older ones. Going through the the Fast Track tutorial (
) and especially the Shapes tutorial (
) would probably have given you a smoother experience learning MPS.
To your questions about how to find out what ".type" is:
While looking at such an unknown language element, "Navigate -> Go To Concept Declaration" (Control/Cmd + Shift + S) will get you to the concept defining the thing under cursor. Followed by Alt + F1 you can visualize the concept in the Project View's "Logical View" and thus discover the containing language.
On the other hand, when exploring an unknown language, you may find it useful to first look at its structure aspect and investigate the concepts defined there.
go to parent
Thanks for the suggestions. Regarding ".type", I just followed that procedure and see what you mean. However, I'm struggling to understand how the "concept"/"language"/"solution"/"aspect"/... terms map to Java entities; it's been my experience that it's beneficial to understand the implementation of a meta-programming system in order to comfortably use it.
Regarding "Fast Track to MPS", I was actually following that guide (I'd already worked through the two "Robot Kaja" videos, i.e. first and second "date"). The "Constants" series isn't entirely listed on Fast Track, but the first one is in Step 4 (MPS Basics - Creating your first language).
On tutorials generally, do you know if the "Calculator" and "Generator" ones are recommended and/or up-to-date?
Sure, the Calculator tutorial as well as the one on Generator are up-to-date. They will both give you quite an in-depth tour through MPS. The "Shapes" tutorial, on the other hand, is an easier start into MPS.
go to parent
Standalone IDE with MPS 3.1 - "Dependency on MPS build scripts"
Generate Web Application, use database model
Build #181 (Apr/17/2015 12:58PM)