Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Newbie-- JVM Language-Extend Xbase and add joda.time.Interval as literal and add new operators
Newbie-- JVM Language-Extend Xbase and add joda.time.Interval as literal and add new operators [message #1723000] Wed, 10 February 2016 18:17 Go to next message
Dildar Mising name is currently offline Dildar Mising nameFriend
Messages: 4
Registered: April 2011
Junior Member
Hi All,

I am new to XText, Xtend and Xbase. I have reviewed practically all the material available on the internet. I am working on creating a new JVM DSL by inheriting Xbase grammar and adding 'temporal' syntax by incorporating joda.time.Interval.

The idea is to have literals and/or expressions that will help in a variety of situations dealing with the "interval" like constructs such as time periods.

I am trying to make some design decisions and will definitely benefit from your experience.

My questions is as follows:
i. Create new operators and Literals or ii. Use Expressions with statically imported methods?

I am trying to use the first approach and not finding much guidance about creating new operators on the internet. As an experiment, in my grammar I redefined:

OpCompare:
super
| '|-|' // equals
| '|>-' // starts
| '>-|' // finishes
| '|||' // overlaps
| '<->' // meets
| '<-|' // before
| '|->' // after
;

When I run the generated DSL and try to use one of these operators I get

"|-| cannot be resolved."

Please point me to the right direction.

In the mean time, I will work on using ImplicitlyImportedFeatures so that methods such as "overlaps", "meets" etc become available without having to import and with better integration with my DSL.

Thanks in advance.

Dildar




Re: Newbie-- JVM Language-Extend Xbase and add joda.time.Interval as literal and add new operators [message #1723005 is a reply to message #1723000] Wed, 10 February 2016 18:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
Have a look at

- OperatorMapping (this class maps Operators to Methods)
- ImplicitlyImportedFeatures (this class lets you add implicit extension classes)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Newbie-- JVM Language-Extend Xbase and add joda.time.Interval as literal and add new operators [message #1723024 is a reply to message #1723005] Thu, 11 February 2016 05:31 Go to previous messageGo to next message
Dildar Mising name is currently offline Dildar Mising nameFriend
Messages: 4
Registered: April 2011
Junior Member
I see a sample for using ImplicitlyImportedFeatures in the "BuildDsl" example from the Seven JVM languages but it seems it works with 2.7 and the configuration is a bit different from 2.9 defaults. Do you recommend I change the default configuration to look more like "BuildDsl" example?

I am wondering if it is possible to gen the required stubs for ImplicitlyImportedFeatures and hook them up with the runtime module. I did this manually but I am not sure if I missed anything. Everything compiles fine.

Also, I see a warning:

"Discouraged access: The type ImplicitlyImportedFeatures is not accessible due to restriction on required project ...". I went ahead and ignored it. Has something changed since 2.7 in this area? Or can I go ahead and change the access rules?
Re: Newbie-- JVM Language-Extend Xbase and add joda.time.Interval as literal and add new operators [message #1723025 is a reply to message #1723024] Thu, 11 February 2016 06:15 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
Xtext may have 1000 extension points (this is just a wild guess) so
generating stubs for all of them would be a mess. Thus the "add a binding
manually" pattern is fine and good practice for non standard extension
points. The api warning you can ignore if you can live with potential api
changes in future xtext releases


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:is it possible to swallow all syntax errors at certain conditions?
Next Topic:Wrong GrammarAccess called by XbaseIdeContentProposalProvider(2.9.0) for re-written rule
Goto Forum:
  


Current Time: Tue Sep 21 20:27:12 GMT 2021

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

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

Back to the top