Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Language mix-ins?(Mixing in Java or XBase)
Language mix-ins? [message #640515] Mon, 22 November 2010 12:14 Go to next message
Chris Ainsley is currently offline Chris AinsleyFriend
Messages: 78
Registered: March 2010
Location: UK
Member
I have a DSL that allows for some simple expressions at certain locations and also allows for Java Scriptlets to be defined between certain tokens (Scriptlets exist in the model as pure text without parsing). So far, so good.

Now, I really want to be able to leverage the XText editor for the editing of the expressions and to be able to reference expressions as a first class concern of the DSL rather than simply something that is not validated between tokens.

Now, ideally, I would like to be able to mix-in the Java editor at the location of expressions. Is this possible? I know that I can define the rules of Java in my DSL itself, but I think this is a bad idea given the complexity of the specification.

{
   MyUserDefinedFunction() -> result_a;
   Day.FRIDAY.isWeekday() ? "yes" : "no" -> result_b;
}



Additionally, I would like to be able to reference certain static methods that are available within the expression and that are supplied as standard as part of the DSL. The methods may be able to be statically described in the .xtext file or as referenced via a different ECore Model.

I suspect I'm stretching too far here. So, if the Java case is too difficult to implement, what about XBase?

I read the article by Sven and it sounds like an interesting language that may be perfect for my requirements, but I have some questions:



  • Is XBase interpreted at runtime or is it compiled into .java code that requires no interpretation? More specifically, if I wish to loop over a billion integers and perform a simple operation, would it be slower in XBase than a native Java version due to interpretation or is there a fixed compilation cost and the runtime cost is free?
  • Is there a runtime library required for XBase, if so, how large and does it require any Eclipse .jar files?
  • Can XBase be utilized/modified without cost for commercial use?
  • Where do I download XBase?


Thanks,

Chris
Re: Language mix-ins? [message #640776 is a reply to message #640515] Tue, 23 November 2010 07:13 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Chris,

please find the answers to your questions inline.

Am 22.11.10 13:15, schrieb Chris Ainsley:
> I have a DSL that allows for some simple expressions at certain
> locations and also allows for Java Scriptlets to be defined between
> certain tokens (Scriptlets exist in the model as pure text without
> parsing). So far, so good.
>
> Now, I really want to be able to leverage the XText editor for the
> editing of the expressions and to be able to reference expressions as a
> first class concern of the DSL rather than simply something that is not
> validated between tokens.

That's what we aim at with Xbase (see below).

>
> Now, ideally, I would like to be able to mix-in the Java editor at the
> location of expressions. Is this possible? I know that I can define the
> rules of Java in my DSL itself, but I think this is a bad idea given the
> complexity of the specification.

Using the Java Editor features directly would require some effort but it
should be possible to hook some Xtext services with implementations from
the JDT. However, modeling your expressions directly is a better idea
(see Xbase, below).

>
> {
> MyUserDefinedFunction() -> result_a;
> Day.FRIDAY.isWeekday() ? "yes" : "no" -> result_b;
> }
>
>
> Additionally, I would like to be able to reference certain static
> methods that are available within the expression and that are supplied
> as standard as part of the DSL. The methods may be able to be statically
> described in the .xtext file or as referenced via a different ECore Model.

You could try to use scoping and the jvm types ecore model (shipped with
Xtext) to link to static members of java classes. I'd rather not write
the methodnames into the Xtext file itself.

>
> I suspect I'm stretching too far here. So, if the Java case is too
> difficult to implement, what about XBase?

That's the way to go. Use Xbase, customize the expressions as you want
and leverage all the library stuff that is implemented around Xbase.

>
> I read the article by Sven and it sounds like an interesting language
> that may be perfect for my requirements, but I have some questions:
>
>
>
> Is XBase interpreted at runtime or is it compiled into .java code that
> requires no interpretation?

Is is compiled to Java source code without any need for interpretation
at runtime.

More specifically, if I wish to loop over a
> billion integers and perform a simple operation, would it be slower in
> XBase than a native Java version due to interpretation or is there a
> fixed compilation cost and the runtime cost is free?

There is a fixed compilation cost and the rest is for free. You could
even customize the to-java-source-code transformation to tailor it for
your specific needs.

> Is there a runtime library required for XBase, if so, how large and does
> it require any Eclipse .jar files?

It is likely that Xbase's generated code will not depend on any Eclipse
internal stuff. Only a few interfaces to use closures will be rquired.

> Can XBase be utilized/modified without cost for commercial use?

Licensed under EPL.

> Where do I download XBase?

It will be part of Xtext 2.0. Stay tunded for M5 / M6 in Q1/2011
First nightlies are already available but subject to heavy change (Xbase
is currently still kind of a moving target).

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


>
>
> Thanks,
>
> Chris
>
Previous Topic:Comments in the AST
Next Topic:DiagnosticMessage in LazyLinkingResource
Goto Forum:
  


Current Time: Fri Apr 26 15:03:02 GMT 2024

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

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

Back to the top