|How to turn an expression String into an Xtext object? [message #785840]
||Sun, 29 January 2012 10:34
| Uli B
Registered: January 2012
I have a DSL and a Debugger with Xtext 2.1.1 under Eclipse 3.7. Now I want to add an "Expressions View". When the expression view calls MyDslWatchExpressionDelegate.evaluateExpression(), the expression is passed as a String. So my question is, how can I turn this String into an Xtext object to which the MyDsl document is linked somehow, so that the expression can be evaluated considering references to the document. (I have a calculator like that from the Xtext arithmetics example in place.)
For example, if we had in a .mydsl document (don't care for the actual language) something like
int a = 3
int b = 4
the user might enter "a + b" in the expression view, and MyDslWatchExpressionDelegate.evaluateExpression() will be called with "a + b". How can I turn "a + b" into an object that can be passed to the calculator's evaluate function?
I could parse the string as a new document, but I don't know how to link the original document to the new one so that a and b could be referenced correctly.
Many thanks in advance for any kind of hint.
Powered by FUDForum
. Page generated in 0.03160 seconds