Skip to main content



      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 18:57 Go to next message
Eclipse UserFriend
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 03:01 Go to previous messageGo to next message
Eclipse UserFriend
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 05:53 Go to previous messageGo to next message
Eclipse UserFriend
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 06:29 Go to previous message
Eclipse UserFriend
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
Previous Topic:[Xtext] NPE in ResourceDescriptionsProvider.createResourceDescriptions() after update to 2.9 / 2.10
Next Topic:Xtext grammar
Goto Forum:
  


Current Time: Wed Mar 12 00:18:28 EDT 2025

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

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

Back to the top