Feedback about Calculator tutorial

Thanks a lot. I managed to move forward but there seems to be another trick. I don’t really understand what I’m doing here but at some point there is the following instructions:

“Now let’s do the same thing with output fields. Again, we need to create the initialization code, and surround it with a $LOOP$ macro. Create a label for field declaration and put it on outputField’s $LOOP$. Then we need to use this label to create a reference. Your code in the template should look like this after making these changes : ”

But if I add a reference macro to outputField, the generated code is this.null. If I leave it without any reference macro, the generated code is correct: this.outputField0.

Did I do something wrong or something?

0
15 comments

skotik answered:

"Hello, Sebastien.

Did you regenerate your generator?
What code did you put in reference macro?
Did you put OutputFieldDeclaration label on declaration of output fields?"

0

skotik answered:

"Hello, Sebastien.

Did you regenerate your generator?
What code did you put in reference macro?
Did you put OutputFieldDeclaration label on declaration of output fields?"

I did regenerate my generator.

Here is the code in my reference macro:

genContext . get output OutputFieldDeclaration for ( node ) ;

And here is my mapping configuration:

                                                                       
mapping configuration main                                             
top-priority group false                                               
                                                                       
mapping labels:                                                        
   label InputFieldDeclaration : InputField -> FieldDeclaration        
   label OutputFieldDeclaration : OutputField -> FieldDeclaration      
   label LocalVar : InputField -> LocalVariableDeclaration             
                                                                       
conditional root rules:                                                
   << ... >>                                                           
                                                                       
mapping rules:                                                         
   concept Calculator      --> CalculatorImpl                          
   inheritors false                                                    
   condition <always>                                                  
   keep input root default                                             
                                                                       
                                                                       
weaving rules:                                                         
   << ... >>                                                           
                                                                       
reduction rules:                                                       
   concept InputFieldReference --> <T  ->$ <no variableDeclaration>  T>
   inheritors false                                                    
   condition <always>                                                  
                                                                       
                                                                       
abandon roots:                                                         
   << ... >>                                                           
                                                                       
pre-processing scripts:                                                
   << ... >>                                                           
                                                                       
post-processing scripts:                                               
   << ... >>          
                                                                                         

0
Avatar
Permanently deleted user

Could you send me your project at Konstantin.Solomatov@jetbrains.com and I will try to find out why code isn't generated.    

0

I just sent it to you.

0
Avatar
Permanently deleted user

I've taken a look at your code. You didn't assigne OutputFieldDeclaration label to the second $LOOP$ macro. You should have something like this:



Attachment(s):
calc.png
0

You were right. It works great now. Thanks a lot!

0

Now that I completed the Calculator tutorial, my general feedback is that it's very frustrating: the original idea of simplifying external DSL design was very ambitious, but this getting started guide is simply not enough to get started. There are far too many new concepts to understand, far too many levels of abstractions to integrate, and the cell-based editor is very weird to use. As a result, I just followed the instructions screen by screen but I understood only 1% of what I was doing.

Maybe this getting started covers too much information. Maybe a simple Hello World with more explanations about why we do things would have been less frightening.

I'll try to read the user guide to see if it helps.

0
Avatar
Permanently deleted user

It's the first beta version of our tutorual. We are reworking it in order to add more explanation so users can start developing in MPS more easily. If you highlight areas which you most interested in, we can improve them.

0
Avatar
Permanently deleted user

It's the first beta version of our tutorual. We are reworking it in order to add more explanation so users can start developing in MPS more easily. If you highlight areas which you most interested in, we can improve them.

0

Hi,

I'm working through the tutorial and have reached the step "Then, add try ... catch block. You will have this:".

However, I cannot find a way to add the code below the $LOOP$ macro.  What ever I do I am extending the macro.  How do I add the code outside of the macro?

I'm using the Mac version of the application.

Bob

0

Hi Bob,

To add next statement put cursor at any place in current statement and press <Enter>.

0

Bob, I also suspect that you somehow managed to attach the $LOOP$ macro not to 'int i = 0;' statement but to the containing statement list (method body?).

If thit is the case, then delete the $LOOP$ macro (press mac equivalent of ctrl-del while cursor is on $LOOP$) and create $LOOP$ again, wrapping the statement only.

0

I had tried hitting enter (and many other things).  The maco attachment seems to have been the problem.  I've got it now.

Thanks.

0
Sebastien, please check out generator demos - http://www.jetbrains.net/confluence/display/MPS/Generator+Demos
They are focused  exclusively on generator development and contain step-by-step guide with  explanation of what is happening.
The generator demos  are part of generator user guide - http://www.jetbrains.net/confluence/display/MPS/Generator
Igor.
0

Wouldn't inputFields, outputFields be more appropriate names for inputFild, outputField children cells of the Calculator?

0

Please sign in to leave a comment.