Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Creating XExpressions Manually
Creating XExpressions Manually [message #1027895] Wed, 27 March 2013 15:04 Go to next message
First Last is currently offline First LastFriend
Messages: 17
Registered: March 2013
Junior Member
It seems like it should be possible to create a method body by defining an XExpression, but while this will compile and run without error, it does not generate a method body:

body = XbaseFactory::eINSTANCE.createXBlockExpression => [
  expressions += XbaseFactory::eINSTANCE.createXReturnExpression => [
    expression = XbaseFactory::eINSTANCE.createXStringLiteral => [
      value = 'String'
    ]
  ]
]


While it is useful to generate method bodies using the string-based template approach, it would sometimes be better to avoid the parsing required by that approach and directly generate the necessary AST elements.

What is missing from this example that is necessary to generate code?
Re: Creating XExpressions Manually [message #1028714 is a reply to message #1027895] Thu, 28 March 2013 16:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

hmmm i dont know if this is a bug or not,
never the less

body = [ITreeAppendable a | a.append('''"Hallo"''')]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Creating XExpressions Manually [message #1028724 is a reply to message #1027895] Thu, 28 March 2013 16:50 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
I've also tried something similer, but couldn't make it work. I would
very much like to be able to create a complex method body containing
sub-expressions from several places in the original DSL text. But I
think too much is happening in the linking process to make it easy to do
by manually creating Xbase objects. It would be great to have an
XbaseExpressionBuilder with toXExpression methods (toIf, toReturn,
toBlock, ...) that make this possible.

Hallvard

There's to much happening during linking

On 28.03.13 09.01, First Last wrote:
> It seems like it should be possible to create a method body by defining
> an XExpression, but while this will compile and run without error, it
> does not generate a method body:
>
> body = XbaseFactory::eINSTANCE.createXBlockExpression => [
> expressions += XbaseFactory::eINSTANCE.createXReturnExpression => [
> expression = XbaseFactory::eINSTANCE.createXStringLiteral => [
> value = 'String'
> ]
> ]
> ]
>
> While it is useful to generate method bodies using the string-based
> template approach, it would sometimes be better to avoid the parsing
> required by that approach and directly generate the necessary AST elements.
>
> What is missing from this example that is necessary to generate code?
Previous Topic:Update to Xtext 2.4 and Xtend 2.4
Next Topic:Static Initializers
Goto Forum:
  


Current Time: Thu Apr 25 12:13:01 GMT 2024

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

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

Back to the top