Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Reusing xbase
Reusing xbase [message #625264] Wed, 22 September 2010 07:48 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I'm writing a grammar where I need something expression-like. A simple
attempt that works is to use a terminal with a special start and end
that cannot appear inside the expression:
terminal SCRIPT_EXPRESSION : '[[' -> ']]';
Technically, this works for my purpose, since the expression will be
evaluated as a String using the Rhino Javascript. I.e. I don't need a
fully parsed variant. However, for the user of my language it's less
than ideal, since there is no syntax check and the [[ and ]] delimiters
clutter the code.

So I thought I'd reuse xbase's xpression, and evaluate the serialized
model using Rhino. But that's not easy either, since the grammar is
slightly different than Javascript's. What I think would work is reuse
xpression's underlying model, but modify/simplify the grammar. However,
if xpression's model is generated from the grammar, then I could just as
well regenerate from the modified grammar.

Any suggestions?

Hallvard
Re: Reusing xbase [message #625353 is a reply to message #625264] Wed, 22 September 2010 08:23 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Hallvard,

xbase is currently under development and you may still expect
significant changes in the grammar and the meta model. I'm not sure that
using it directly is a good idea - at least not yet.
So yes, I'd use the existing grammar as an inspiration or stick with
black box literals which are far easier to develop but less convenient
for the user.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 22.09.10 09:48, schrieb Hallvard Trætteberg:
> Hi,
>
> I'm writing a grammar where I need something expression-like. A simple
> attempt that works is to use a terminal with a special start and end
> that cannot appear inside the expression:
> terminal SCRIPT_EXPRESSION : '[[' -> ']]';
> Technically, this works for my purpose, since the expression will be
> evaluated as a String using the Rhino Javascript. I.e. I don't need a
> fully parsed variant. However, for the user of my language it's less
> than ideal, since there is no syntax check and the [[ and ]] delimiters
> clutter the code.
>
> So I thought I'd reuse xbase's xpression, and evaluate the serialized
> model using Rhino. But that's not easy either, since the grammar is
> slightly different than Javascript's. What I think would work is reuse
> xpression's underlying model, but modify/simplify the grammar. However,
> if xpression's model is generated from the grammar, then I could just as
> well regenerate from the modified grammar.
>
> Any suggestions?
>
> Hallvard
Re: Reusing xbase [message #625355 is a reply to message #625264] Wed, 22 September 2010 08:29 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
I guess you'd need a mapping/template from Xbase's original model to JavaScript code anyway, so whether it's wise to re-use Xbase's metamodel depends on other things like whether you want to be able to move along with Xbase evolution. Also, if you're modifying/simplifying the Xbase grammar, chances are that you're not going to be able to mold the grammar in such a way that you can continue to re-use the existing metamodel.


Re: Reusing xbase [message #626164 is a reply to message #625353] Wed, 22 September 2010 12:20 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 22.09.10 10.23, Sebastian Zarnekow wrote:
>
> xbase is currently under development and you may still expect
> significant changes in the grammar and the meta model.

OK.

> So yes, I'd use the existing grammar as an inspiration or stick with
> black box literals which are far easier to develop but less convenient
> for the user.

I'll try a combination: Use the existing grammar as inspiration, and use
the black box literal _within_ the grammar so you can use it if the
grammar is too limited.

BTW, there seems to be many people that's interested in xbase (or
perhaps xpression) since expressions are common to many languages. But
from reading the model and grammar, I get the impression that the goal
is not to provide a least common denominator expression language, it's
more than that? What is actually the goal, and is it something that the
xtext community could take part in discussing?

Another comment: From my limited experience with reworking xpression's
grammar, I get the feeling that it's impossible to make a general
grammar that 1) does not include features/operators that you may not
want to include (like the new operator) and 2) isn't too limiting (by
omitting some operators). What I think is possible, is to make a general
_model_ and several grammars for this model, with various levels of
features.

Hallvard
Re: Reusing xbase [message #626241 is a reply to message #626164] Wed, 22 September 2010 13:13 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Hallvard Traetteberg wrote on Wed, 22 September 2010 14:20

Another comment: From my limited experience with reworking xpression's
grammar, I get the feeling that it's impossible to make a general
grammar that 1) does not include features/operators that you may not
want to include (like the new operator) and 2) isn't too limiting (by
omitting some operators). What I think is possible, is to make a general
_model_ and several grammars for this model, with various levels of
features.


I don't quite agree: getting the language (grammar + customizations) right certainly gets more difficult with each language construct, in a somewhat-worse-than-linear way because you sometimes have to disambiguate the grammar and introduce "combination types" to comfortably implement the customizations. But it's not "impossible", as the Xbase language itself shows. Expression (sub-)languages generally are by far the most difficult part of any grammar, because of left-factorization, precedence and associativiy.


Re: Reusing xbase [message #626311 is a reply to message #626241] Wed, 22 September 2010 13:48 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 22.09.10 15.13, Meinte Boersma wrote:
> Hallvard Traetteberg wrote on Wed, 22 September 2010 14:20
>> Another comment: From my limited experience with reworking xpression's
>> grammar, I get the feeling that it's impossible to make a general
>> grammar that 1) does not include features/operators that you may not
>> want to include (like the new operator) and 2) isn't too limiting (by
>> omitting some operators). What I think is possible, is to make a
>> general _model_ and several grammars for this model, with various
>> levels of features.
>
> I don't quite agree: getting the language (grammar + customizations)
> right certainly gets more difficult with each language construct, in a
> somewhat-worse-than-linear way because you sometimes have to
> disambiguate the grammar and introduce "combination types" to
> comfortably implement the customizations. But it's not "impossible", as
> the Xbase language itself shows.

Well, so far the Xbase language has _not_ shown that it is possible,
because it has not been reused by others, as far as I know. My point was
not that it's technically impossible to create a grammar, but that
there's so too details that have to be right for it to be reusable by
others. Since a model supports many grammars, it's potential for reuse
is greater.

Hallvard
Re: Reusing xbase [message #626932 is a reply to message #626311] Wed, 22 September 2010 18:51 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Ah, OK, so you mean to re-use a grammar and at the same time "customize" it by disabling specific constructs. That's quite difficult as some constructs might rely on other constructs (either purely for type or for the actual parser rule). Also, DSLs are usually quite specific (dûh!) and generally not very composable because of typing (e.g. expression languages built on top of a type system defined in another part of the language) -although I haven't tried to make such a thing work.


Re: Reusing xbase [message #628274 is a reply to message #626164] Thu, 23 September 2010 11:37 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Am 9/22/10 2:20 PM, schrieb Hallvard Trætteberg:
> BTW, there seems to be many people that's interested in xbase (or
> perhaps xpression) since expressions are common to many languages. But
> from reading the model and grammar, I get the impression that the goal
> is not to provide a least common denominator expression language, it's
> more than that? What is actually the goal, and is it something that the
> xtext community could take part in discussing?

The goal of Xbase is to provide a simple, java-like expression language,
which can be reused in other languages.

I'm writing up the language specification these days, and will come up
with a blog post about it soon, so that we can discuss the concpets and
ideas.

>
> Another comment: From my limited experience with reworking xpression's
> grammar, I get the feeling that it's impossible to make a general
> grammar that 1) does not include features/operators that you may not
> want to include (like the new operator) and 2) isn't too limiting (by
> omitting some operators). What I think is possible, is to make a general
> _model_ and several grammars for this model, with various levels of
> features.

You can override any rule. By removing alteratives in e.g. primary
expression, you could remove the constructor call.
Adding operators or new expression constructs can also be done by
overriding rules.

We're also thinking about enhancing the grammar reuse possibilities with
different concepts.

Sven

--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: Reusing xbase [message #628652 is a reply to message #628274] Thu, 23 September 2010 14:35 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 23.09.10 13.37, Sven Efftinge wrote:
>
> The goal of Xbase is to provide a simple, java-like expression language,
> which can be reused in other languages.
>
> I'm writing up the language specification these days, and will come up
> with a blog post about it soon, so that we can discuss the concpets and
> ideas.

I'm looking forward to it!

Hallvard
Previous Topic:my last problem with typing
Next Topic:how to serialised back a DSL ecore instance in its textual DSL representation
Goto Forum:
  


Current Time: Sat May 04 16:52:27 GMT 2024

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

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

Back to the top