XbaseInterpreter evaluation [message #1265606] |
Thu, 06 March 2014 10:04 |
Ana Farcasi Messages: 1 Registered: March 2014 |
Junior Member |
|
|
Dear all,
I am working on a DSL for platoons of Lego mindstorms. I am generating code in NXC from the DSL model. In the models I have a command that instructs the robots to move forward for a certain distance. I have a working version of the DSL where the distance is an integer.
Now I switched to a new version of the DSL, where I use the partial language Xbase for the distance attribute of the forward command. In this new language, I the distance is of type XExpression. So, when the user types "forward(10 + 2)" in the DSL, I want to generate code in NXC that moves the robots forward with 12 units.
I have modified the grammar accordingly and I injected the xbase interpreter into the generator. Then I simply used the evaluate method with the XExpression argument on the interpreter. When I type a simple integer as a distance in the forward command, then the Xbase interpreter correctly outputs the integer as a result of the evaluation, but when I write "10 + 2" as the distance in the foward command, I obtain the following exception:
!STACK 0
java.lang.IllegalStateException: feature was simple feature call but got receiver instead of null. Receiver: 10
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._invokeFeature(XbaseInterpreter.java:894)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeFeature(XbaseInterpreter.java:881)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:863)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:218)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:196)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:182)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:173)
at org.xtext.example.newplatoon.generator.Master.createMasterText(Master.java:469)
at org.xtext.example.newplatoon.generator.NewPlatoonGenerator.doGenerate(NewPlatoonGenerator.java:41)
...
In another version I also injected the evaluation context provider and the interpreter, and I used the evaluate method on the interpreter with the XExpression and IEvaluationContext arguments, but I obtain the same exception.
I followed the stack trace and I am not able to grasp the exact problem. I think I am using the interpreter in a wrong way. If anyone could please give me any hints on where the problem could be, I would be really grateful.
Best regards,
Ana.
|
|
|
Powered by
FUDForum. Page generated in 0.02013 seconds