Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [xbase] How to parse Xbase expressions in Java code?
[xbase] How to parse Xbase expressions in Java code? [message #895224] Thu, 12 July 2012 08:03 Go to next message
Eclipse UserFriend
Hi,

I want to use the Xbase interpreter to interpret Xbase expressions
contained in my own visual DSL. Currently, I am parsing Xbase
expressions like this (which looks a bit awkward):


Injector injector = Guice.createInjector(new XbaseRuntimeModule());

xbaseInterpreter = injector.getInstance(XbaseInterpreter.class);

resourceSet = new ResourceSetImpl();

Resource r = resourceSet.createResource(URI.createURI("private.___xbase"));

try
{
r.load(new ByteArrayInputStream("true".getBytes()), null);
}
catch (IOException e)
{
...
}

xExpression = (XExpression) r.getContents().get(0);

Is there a more convenient way to parse Xbase expressions from a string?
Another way I found is to use the doParse() method of XbaseParser, which
also looks awkward to me. I would have expected a parse method, which
takes a string parameter and returns an XExpression object.

Futhermore, why is the access to all classes in org.eclipse.xtext.xbase
restricted, e.g., XExpression?

After parsing the expression, I am evaluating it like described in the
Xbase doc.


IEvaluationResult result = xbaseInterpreter.evaluate(xExpression);
....


In my own DSL interpreter, I need to know the type of the expression
result as an EClassifier. Does Xbase already provide a utility method to
derive the result type of an XExpression?


Thanks in advance

Stephan
Re: [xbase] How to parse Xbase expressions in Java code? [message #895252 is a reply to message #895224] Thu, 12 July 2012 09:23 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Answers inline

Am 12.07.12 10:03, schrieb Stephan Hildebrandt:
> Hi,
>
> I want to use the Xbase interpreter to interpret Xbase expressions
> contained in my own visual DSL. Currently, I am parsing Xbase
> expressions like this (which looks a bit awkward):
>
>
> Injector injector = Guice.createInjector(new XbaseRuntimeModule());
>
> xbaseInterpreter = injector.getInstance(XbaseInterpreter.class);
>
> resourceSet = new ResourceSetImpl();
>
> Resource r = resourceSet.createResource(URI.createURI("private.___xbase"));
>
> try
> {
> r.load(new ByteArrayInputStream("true".getBytes()), null);
> }
> catch (IOException e)
> {
> ...
> }
>
> xExpression = (XExpression) r.getContents().get(0);
>
> Is there a more convenient way to parse Xbase expressions from a string?
> Another way I found is to use the doParse() method of XbaseParser, which
> also looks awkward to me. I would have expected a parse method, which
> takes a string parameter and returns an XExpression object.

Did you have a look at the ParseHelper?

> Futhermore, why is the access to all classes in org.eclipse.xtext.xbase
> restricted, e.g., XExpression?

Because it's provisional API, i.e. could change if necessary.
nevertheless, we try to keep it stable.

> After parsing the expression, I am evaluating it like described in the
> Xbase doc.
>
> IEvaluationResult result = xbaseInterpreter.evaluate(xExpression);
> ...
>
> In my own DSL interpreter, I need to know the type of the expression
> result as an EClassifier. Does Xbase already provide a utility method to
> derive the result type of an XExpression?

ITypeProvider is your friend.

--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: [xbase] How to parse Xbase expressions in Java code? [message #895322 is a reply to message #895252] Thu, 12 July 2012 12:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jan,

thanks for your answer. Now, I am stuck with the following problem: How
do I tell the parser, which external variables already exist? I can add
them to the EvaluationContext like this:

final IEvaluationContext ec =
this.injector.getInstance(IEvaluationContext.class);

ec.newValue(qualifiedNameConverter.toQualifiedName("a"), aObject);

The evaluation of the expression should simply return aObject. But when
the Xbase interpreter evaluates the expression, an
IllegalArgumentException is thrown in QualifiedName.create() ("Segment
cannot be null"). When I inspect the AST of the expression, it consists
of an XFeatureCallImplCustom object, which seems wrong. I would have
expected something like a variable reference. Obviously, I need to
already tell the parser that "a" is a variable name, not a feature. But
how can I do that? The ParseHelper does not contain anything in this
direction.

Thanks a lot

Stephan

Am 12.07.2012 11:23, schrieb Jan Koehnlein:
> Answers inline
>
> Am 12.07.12 10:03, schrieb Stephan Hildebrandt:
>> Hi,
>>
>> I want to use the Xbase interpreter to interpret Xbase expressions
>> contained in my own visual DSL. Currently, I am parsing Xbase
>> expressions like this (which looks a bit awkward):
>>
>>
>> Injector injector = Guice.createInjector(new XbaseRuntimeModule());
>>
>> xbaseInterpreter = injector.getInstance(XbaseInterpreter.class);
>>
>> resourceSet = new ResourceSetImpl();
>>
>> Resource r =
>> resourceSet.createResource(URI.createURI("private.___xbase"));
>>
>> try
>> {
>> r.load(new ByteArrayInputStream("true".getBytes()), null);
>> }
>> catch (IOException e)
>> {
>> ...
>> }
>>
>> xExpression = (XExpression) r.getContents().get(0);
>>
>> Is there a more convenient way to parse Xbase expressions from a string?
>> Another way I found is to use the doParse() method of XbaseParser, which
>> also looks awkward to me. I would have expected a parse method, which
>> takes a string parameter and returns an XExpression object.
>
> Did you have a look at the ParseHelper?
>
>> Futhermore, why is the access to all classes in org.eclipse.xtext.xbase
>> restricted, e.g., XExpression?
>
> Because it's provisional API, i.e. could change if necessary.
> nevertheless, we try to keep it stable.
>
>> After parsing the expression, I am evaluating it like described in the
>> Xbase doc.
>>
>> IEvaluationResult result = xbaseInterpreter.evaluate(xExpression);
>> ...
>>
>> In my own DSL interpreter, I need to know the type of the expression
>> result as an EClassifier. Does Xbase already provide a utility method to
>> derive the result type of an XExpression?
>
> ITypeProvider is your friend.
>
Re: [xbase] How to parse Xbase expressions in Java code? [message #895550 is a reply to message #895322] Fri, 13 July 2012 13:59 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
XFeatureCall(ImplCustom) is fine, as variables are considered features,
thus evaluating a variable is a feature call. Must be a different problem.

Your variable setting looks good, too, given that you get the
qualifiedNameConverter form the injector as well.

Need more information to help. A stack trace, maybe. Usually, it's quite
easy to debug the interpreter.

Am 12.07.12 14:52, schrieb Stephan Hildebrandt:
> Hi Jan,
>
> thanks for your answer. Now, I am stuck with the following problem: How
> do I tell the parser, which external variables already exist? I can add
> them to the EvaluationContext like this:
>
> final IEvaluationContext ec =
> this.injector.getInstance(IEvaluationContext.class);
>
> ec.newValue(qualifiedNameConverter.toQualifiedName("a"), aObject);
>
> The evaluation of the expression should simply return aObject. But when
> the Xbase interpreter evaluates the expression, an
> IllegalArgumentException is thrown in QualifiedName.create() ("Segment
> cannot be null"). When I inspect the AST of the expression, it consists
> of an XFeatureCallImplCustom object, which seems wrong. I would have
> expected something like a variable reference. Obviously, I need to
> already tell the parser that "a" is a variable name, not a feature. But
> how can I do that? The ParseHelper does not contain anything in this
> direction.
>
> Thanks a lot
>
> Stephan
>
> Am 12.07.2012 11:23, schrieb Jan Koehnlein:
>> Answers inline
>>
>> Am 12.07.12 10:03, schrieb Stephan Hildebrandt:
>>> Hi,
>>>
>>> I want to use the Xbase interpreter to interpret Xbase expressions
>>> contained in my own visual DSL. Currently, I am parsing Xbase
>>> expressions like this (which looks a bit awkward):
>>>
>>>
>>> Injector injector = Guice.createInjector(new XbaseRuntimeModule());
>>>
>>> xbaseInterpreter = injector.getInstance(XbaseInterpreter.class);
>>>
>>> resourceSet = new ResourceSetImpl();
>>>
>>> Resource r =
>>> resourceSet.createResource(URI.createURI("private.___xbase"));
>>>
>>> try
>>> {
>>> r.load(new ByteArrayInputStream("true".getBytes()), null);
>>> }
>>> catch (IOException e)
>>> {
>>> ...
>>> }
>>>
>>> xExpression = (XExpression) r.getContents().get(0);
>>>
>>> Is there a more convenient way to parse Xbase expressions from a string?
>>> Another way I found is to use the doParse() method of XbaseParser, which
>>> also looks awkward to me. I would have expected a parse method, which
>>> takes a string parameter and returns an XExpression object.
>>
>> Did you have a look at the ParseHelper?
>>
>>> Futhermore, why is the access to all classes in org.eclipse.xtext.xbase
>>> restricted, e.g., XExpression?
>>
>> Because it's provisional API, i.e. could change if necessary.
>> nevertheless, we try to keep it stable.
>>
>>> After parsing the expression, I am evaluating it like described in the
>>> Xbase doc.
>>>
>>> IEvaluationResult result = xbaseInterpreter.evaluate(xExpression);
>>> ...
>>>
>>> In my own DSL interpreter, I need to know the type of the expression
>>> result as an EClassifier. Does Xbase already provide a utility method to
>>> derive the result type of an XExpression?
>>
>> ITypeProvider is your friend.
>>
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: [xbase] How to parse Xbase expressions in Java code? [message #895830 is a reply to message #895550] Mon, 16 July 2012 08:40 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jan,

the stack trace is as follows:

java.lang.IllegalArgumentException: Segment cannot be null
at org.eclipse.xtext.naming.QualifiedName.create(QualifiedName.java:97)
at
org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallJvmIdentifyableElement(XbaseInterpreter.java:675)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
at
org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalFeatureCallDispatch(XbaseInterpreter.java:663)
at
org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
at
org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218)
at
org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204)
at
de.mdelab.sdm.interpreter.xbase.XbaseExpressionInterpreter.evaluateExpression(XbaseExpressionInterpreter.java:85)
at
de.mdelab.sdm.interpreter.xbase.XbaseExpressionInterpreter.evaluateExpression(XbaseExpressionInterpreter.java:1)
at
de.mdelab.sdm.interpreter.core.expressions.ExpressionInterpreterManager.evaluateExpression(ExpressionInterpreterManager.java:105)
at
de.mdelab.sdm.interpreter.core.SDMInterpreter.executeActivity(SDMInterpreter.java:242)
at
de.mdelab.workflow.components.sdmInterpreterComponent.impl.SDMInterpreterComponentImpl.execute(SDMInterpreterComponentImpl.java:879)
at de.mdelab.workflow.impl.WorkflowImpl.execute(WorkflowImpl.java:500)
at de.mdelab.workflow.impl.WorkflowImpl.execute(WorkflowImpl.java:253)
at de.mdelab.workflow.ui.WorkflowJob.runInWorkspace(WorkflowJob.java:65)
at
org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


I noticed that the feature reference of xExpression contains an
unresolved proxy (JvmVoid: (eProxyURI:
private.___xbase#xtextLink_::0::0::/1)) of type JvmVoidImplCustom. In
_featureCallJvmIdentifyableElement, the proxy cannot be resolved and,
therefore, localVarName is null, which is used as parameter for
QualifiedName.create(). I also tried calling
EcoreUtil.resolveAll(xExpression) but the proxy cannot be resolved. Why
is the parser inserting this proxy anyway?


Best regards,

Stephan

Am 13.07.2012 15:59, schrieb Jan Koehnlein:
> XFeatureCall(ImplCustom) is fine, as variables are considered features,
> thus evaluating a variable is a feature call. Must be a different problem.
>
> Your variable setting looks good, too, given that you get the
> qualifiedNameConverter form the injector as well.
>
> Need more information to help. A stack trace, maybe. Usually, it's quite
> easy to debug the interpreter.
>
> Am 12.07.12 14:52, schrieb Stephan Hildebrandt:
>> Hi Jan,
>>
>> thanks for your answer. Now, I am stuck with the following problem: How
>> do I tell the parser, which external variables already exist? I can add
>> them to the EvaluationContext like this:
>>
>> final IEvaluationContext ec =
>> this.injector.getInstance(IEvaluationContext.class);
>>
>> ec.newValue(qualifiedNameConverter.toQualifiedName("a"), aObject);
>>
>> The evaluation of the expression should simply return aObject. But when
>> the Xbase interpreter evaluates the expression, an
>> IllegalArgumentException is thrown in QualifiedName.create() ("Segment
>> cannot be null"). When I inspect the AST of the expression, it consists
>> of an XFeatureCallImplCustom object, which seems wrong. I would have
>> expected something like a variable reference. Obviously, I need to
>> already tell the parser that "a" is a variable name, not a feature. But
>> how can I do that? The ParseHelper does not contain anything in this
>> direction.
>>
>> Thanks a lot
>>
>> Stephan
>>
>> Am 12.07.2012 11:23, schrieb Jan Koehnlein:
>>> Answers inline
>>>
>>> Am 12.07.12 10:03, schrieb Stephan Hildebrandt:
>>>> Hi,
>>>>
>>>> I want to use the Xbase interpreter to interpret Xbase expressions
>>>> contained in my own visual DSL. Currently, I am parsing Xbase
>>>> expressions like this (which looks a bit awkward):
>>>>
>>>>
>>>> Injector injector = Guice.createInjector(new XbaseRuntimeModule());
>>>>
>>>> xbaseInterpreter = injector.getInstance(XbaseInterpreter.class);
>>>>
>>>> resourceSet = new ResourceSetImpl();
>>>>
>>>> Resource r =
>>>> resourceSet.createResource(URI.createURI("private.___xbase"));
>>>>
>>>> try
>>>> {
>>>> r.load(new ByteArrayInputStream("true".getBytes()), null);
>>>> }
>>>> catch (IOException e)
>>>> {
>>>> ...
>>>> }
>>>>
>>>> xExpression = (XExpression) r.getContents().get(0);
>>>>
>>>> Is there a more convenient way to parse Xbase expressions from a
>>>> string?
>>>> Another way I found is to use the doParse() method of XbaseParser,
>>>> which
>>>> also looks awkward to me. I would have expected a parse method, which
>>>> takes a string parameter and returns an XExpression object.
>>>
>>> Did you have a look at the ParseHelper?
>>>
>>>> Futhermore, why is the access to all classes in org.eclipse.xtext.xbase
>>>> restricted, e.g., XExpression?
>>>
>>> Because it's provisional API, i.e. could change if necessary.
>>> nevertheless, we try to keep it stable.
>>>
>>>> After parsing the expression, I am evaluating it like described in the
>>>> Xbase doc.
>>>>
>>>> IEvaluationResult result = xbaseInterpreter.evaluate(xExpression);
>>>> ...
>>>>
>>>> In my own DSL interpreter, I need to know the type of the expression
>>>> result as an EClassifier. Does Xbase already provide a utility
>>>> method to
>>>> derive the result type of an XExpression?
>>>
>>> ITypeProvider is your friend.
>>>
>>
>>
>
>
Re: [xbase] How to parse Xbase expressions in Java code? [message #895852 is a reply to message #895830] Mon, 16 July 2012 10:12 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Are you sure you have set the classloader of the XbaseInterpreter such
that all required classes are loadable? That would explain the
unresolvable type proxy.

Is the feature that causes the exception really the variable 'a'? Try to
find which type the feature should have and make sure it is loadable.

If you used an inferred JVM model, you might want to have a look at the
Tortoise example
http://www.eclipse.org/Xtext/7languagesDoc.html#tortoise (code on github)
I had to override the IdentifiableSimpleNameProvider to return 'this'
for the inferred class which was never generated.

Am 16.07.12 10:40, schrieb Stephan Hildebrandt:
> Hi Jan,
>
> the stack trace is as follows:
>
> java.lang.IllegalArgumentException: Segment cannot be null
> at org.eclipse.xtext.naming.QualifiedName.create(QualifiedName.java:97)
> at
> org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallJvmIdentifyableElement(XbaseInterpreter.java:675)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
>
> at
> org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalFeatureCallDispatch(XbaseInterpreter.java:663)
>
> at
> org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
>
> at
> org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218)
>
> at
> org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204)
>
> at
> de.mdelab.sdm.interpreter.xbase.XbaseExpressionInterpreter.evaluateExpression(XbaseExpressionInterpreter.java:85)
>
> at
> de.mdelab.sdm.interpreter.xbase.XbaseExpressionInterpreter.evaluateExpression(XbaseExpressionInterpreter.java:1)
>
> at
> de.mdelab.sdm.interpreter.core.expressions.ExpressionInterpreterManager.evaluateExpression(ExpressionInterpreterManager.java:105)
>
> at
> de.mdelab.sdm.interpreter.core.SDMInterpreter.executeActivity(SDMInterpreter.java:242)
>
> at
> de.mdelab.workflow.components.sdmInterpreterComponent.impl.SDMInterpreterComponentImpl.execute(SDMInterpreterComponentImpl.java:879)
>
> at de.mdelab.workflow.impl.WorkflowImpl.execute(WorkflowImpl.java:500)
> at de.mdelab.workflow.impl.WorkflowImpl.execute(WorkflowImpl.java:253)
> at de.mdelab.workflow.ui.WorkflowJob.runInWorkspace(WorkflowJob.java:65)
> at
> org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
>
>
> I noticed that the feature reference of xExpression contains an
> unresolved proxy (JvmVoid: (eProxyURI:
> private.___xbase#xtextLink_::0::0::/1)) of type JvmVoidImplCustom. In
> _featureCallJvmIdentifyableElement, the proxy cannot be resolved and,
> therefore, localVarName is null, which is used as parameter for
> QualifiedName.create(). I also tried calling
> EcoreUtil.resolveAll(xExpression) but the proxy cannot be resolved. Why
> is the parser inserting this proxy anyway?
>
>
> Best regards,
>
> Stephan
>
> Am 13.07.2012 15:59, schrieb Jan Koehnlein:
>> XFeatureCall(ImplCustom) is fine, as variables are considered features,
>> thus evaluating a variable is a feature call. Must be a different
>> problem.
>>
>> Your variable setting looks good, too, given that you get the
>> qualifiedNameConverter form the injector as well.
>>
>> Need more information to help. A stack trace, maybe. Usually, it's quite
>> easy to debug the interpreter.
>>
>> Am 12.07.12 14:52, schrieb Stephan Hildebrandt:
>>> Hi Jan,
>>>
>>> thanks for your answer. Now, I am stuck with the following problem: How
>>> do I tell the parser, which external variables already exist? I can add
>>> them to the EvaluationContext like this:
>>>
>>> final IEvaluationContext ec =
>>> this.injector.getInstance(IEvaluationContext.class);
>>>
>>> ec.newValue(qualifiedNameConverter.toQualifiedName("a"), aObject);
>>>
>>> The evaluation of the expression should simply return aObject. But when
>>> the Xbase interpreter evaluates the expression, an
>>> IllegalArgumentException is thrown in QualifiedName.create() ("Segment
>>> cannot be null"). When I inspect the AST of the expression, it consists
>>> of an XFeatureCallImplCustom object, which seems wrong. I would have
>>> expected something like a variable reference. Obviously, I need to
>>> already tell the parser that "a" is a variable name, not a feature. But
>>> how can I do that? The ParseHelper does not contain anything in this
>>> direction.
>>>
>>> Thanks a lot
>>>
>>> Stephan
>>>
>>> Am 12.07.2012 11:23, schrieb Jan Koehnlein:
>>>> Answers inline
>>>>
>>>> Am 12.07.12 10:03, schrieb Stephan Hildebrandt:
>>>>> Hi,
>>>>>
>>>>> I want to use the Xbase interpreter to interpret Xbase expressions
>>>>> contained in my own visual DSL. Currently, I am parsing Xbase
>>>>> expressions like this (which looks a bit awkward):
>>>>>
>>>>>
>>>>> Injector injector = Guice.createInjector(new XbaseRuntimeModule());
>>>>>
>>>>> xbaseInterpreter = injector.getInstance(XbaseInterpreter.class);
>>>>>
>>>>> resourceSet = new ResourceSetImpl();
>>>>>
>>>>> Resource r =
>>>>> resourceSet.createResource(URI.createURI("private.___xbase"));
>>>>>
>>>>> try
>>>>> {
>>>>> r.load(new ByteArrayInputStream("true".getBytes()), null);
>>>>> }
>>>>> catch (IOException e)
>>>>> {
>>>>> ...
>>>>> }
>>>>>
>>>>> xExpression = (XExpression) r.getContents().get(0);
>>>>>
>>>>> Is there a more convenient way to parse Xbase expressions from a
>>>>> string?
>>>>> Another way I found is to use the doParse() method of XbaseParser,
>>>>> which
>>>>> also looks awkward to me. I would have expected a parse method, which
>>>>> takes a string parameter and returns an XExpression object.
>>>>
>>>> Did you have a look at the ParseHelper?
>>>>
>>>>> Futhermore, why is the access to all classes in
>>>>> org.eclipse.xtext.xbase
>>>>> restricted, e.g., XExpression?
>>>>
>>>> Because it's provisional API, i.e. could change if necessary.
>>>> nevertheless, we try to keep it stable.
>>>>
>>>>> After parsing the expression, I am evaluating it like described in the
>>>>> Xbase doc.
>>>>>
>>>>> IEvaluationResult result = xbaseInterpreter.evaluate(xExpression);
>>>>> ...
>>>>>
>>>>> In my own DSL interpreter, I need to know the type of the expression
>>>>> result as an EClassifier. Does Xbase already provide a utility
>>>>> method to
>>>>> derive the result type of an XExpression?
>>>>
>>>> ITypeProvider is your friend.
>>>>
>>>
>>>
>>
>>
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:This is a bug with the quikfix?
Next Topic:How to set value for a name attribute in a composite relationship?
Goto Forum:
  


Current Time: Thu Apr 25 01:59:51 GMT 2024

Powered by FUDForum. Page generated in 0.04133 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top