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 Last
Messages: 15
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 Dietrich
Messages: 6388
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"''')]
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 Traetteberg
Messages: 601
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:Auto convert keywords to uppercase while typing
Goto Forum:
  


Current Time: Fri Oct 24 21:25:39 GMT 2014

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

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