Home » Modeling » TMF (Xtext) » Reusing xbase
Reusing xbase [message #625264] |
Wed, 22 September 2010 07:48 |
Hallvard Traetteberg 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 |
Sebastian Zarnekow 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 #626164 is a reply to message #625353] |
Wed, 22 September 2010 12:20 |
Hallvard Traetteberg 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 |
Meinte Boersma 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.
Xtext blogs: executable models...again? | workshop material | custom scoping with Xtend
|
|
|
Re: Reusing xbase [message #626311 is a reply to message #626241] |
Wed, 22 September 2010 13:48 |
Hallvard Traetteberg 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 #628274 is a reply to message #626164] |
Thu, 23 September 2010 11:37 |
Sven Efftinge 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
|
|
| |
Goto Forum:
Current Time: Sat May 04 16:52:27 GMT 2024
Powered by FUDForum. Page generated in 0.04139 seconds
|