[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.tmf] Re: looking for a xtext C/Java like expression language

Michael,

We're embedding Xtend expressions in our grammar to do that. The major 
drawback is that the expressions themselves are not captured by grammar 
rules, but are instead defined within a String literal. So to the user of 
the language, it looks a bit like this:

define template 'ClassDescription' for ecore::EClass
 if '!this.isAbstract && this.eAttributes.size() > 0'
 
 heading '"EClass " + this.name'
 body
  ...
 end body
end template

But using Xtend has to nice advantages:

1) We can reuse the Xtend content assist facility. So at the right places, 
we just delegate from our Xtext language content assist code to Xtend 
content assist. Works like a charm.

2) We can analyze and evaluate these expressions for free.

Maybe that's applicable in your situation, too. You may, however, have to 
write an Xtend metamodel for your language constructs if your expressions 
operate on the things defined in the language itself.

Cheers,
 Achim

Knut Wannheden wrote:

> Hi Michael,
> 
> Here you can find a basic grammar for the Xtend expression language:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=264188.
> 
> I don't know about any other current grammars for Java like expression
> languages.
> 
> Regards,
> 
> --knut
> 
> Michael Scharf wrote:
>> Hi,
>> 
>> I am about to define a C/Java like expression language
>> and I wonder if there is some example to start from.
>> 
>> 
>> Michael