Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » When to use XExpression, XblockExpression and just plain parser rule
When to use XExpression, XblockExpression and just plain parser rule [message #1736257] Mon, 27 June 2016 22:57 Go to next message
Mansour Al is currently offline Mansour AlFriend
Messages: 44
Registered: June 2016
Member
I have been prototyping and playing with xText/Xbase for few weeks. I am still lost as there are many components in the system that I have not seen.

Now, I would to understand when to use an XExpression, and when not use it. And if I need an expression, why not use XBlockExpression.

So what factors others use to decide if they need to use an expression or not.


Re: When to use XExpression, XblockExpression and just plain parser rule [message #1736267 is a reply to message #1736257] Tue, 28 June 2016 07:01 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 742
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Usually DSLs won't make any restriction on the kind of expression they allow at a certain position, so XExpression is often right. But if you would like to force that an expression has to be encapsulated in curly brackets, you go with XBlockExpression. For example, if you would like something like an Operation which has a Body, as seen in the Domainmodel example.

As always, it depends...
Re: When to use XExpression, XblockExpression and just plain parser rule [message #1736293 is a reply to message #1736267] Tue, 28 June 2016 09:53 Go to previous messageGo to next message
Mansour Al is currently offline Mansour AlFriend
Messages: 44
Registered: June 2016
Member
Karsten,
Thank you a lot.
I understand that XExpression can be created any where. But when do I use
MyElement returns XExpression:
{MyElement} ...... 


And when to use

MyElement:
{MyElement} ....... 


Thank you
Re: When to use XExpression, XblockExpression and just plain parser rule [message #1736302 is a reply to message #1736293] Tue, 28 June 2016 10:29 Go to previous message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
MyElement returns XExpression makes your expression an xexpression so that

- it can be used as initializer of a field or a body of a method, can be handled by typecomputer etc.

MyElement:
{MyElement}

does not


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:[Xtext] NPE in ResourceDescriptionsProvider.createResourceDescriptions() after update to 2.9 / 2.10
Next Topic:Xtext grammar
Goto Forum:
  


Current Time: Tue Jan 19 06:18:22 GMT 2021

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

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

Back to the top