Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » General Xtext question
General Xtext question [message #1850960] Wed, 23 March 2022 13:50 Go to next message
Gaël DENIAU is currently offline Gaël DENIAUFriend
Messages: 4
Registered: March 2022
Junior Member
Hello,

I am trying to understand how to use Xtext, not the grammar part but rather how to reuse the model.

Right now I have the grammar (file .xtext) but I cannot wrap my head around on how to use it outside the in-built editor of Xtext.

Let's say I start a new project (general purpose) on Eclipse, how do I add the model into Eclipse so that I can have the syntax highlight/autocompletion in a new file?

For example purpose, let's say I defined 'real' and 'complex' as keyword into the model. I wish to start a new project on Eclipse and be able to write in a
new blank file:

real rValue = 1.2;
complex cValue = 1.5 + 2.1i;

Then, the file will be sent through a compiler outside Eclipse.

Being a complete beginner on Eclipse, the Xtext documentation is rather obscure and I keep circling on the same topic without making any progress. Plus, I am not even sure Xtext is the right tool to do that.

Kind regards,

Edit: I am interessted in a number of features of Xtext, not just the highlighting of keywords

[Updated on: Wed, 23 March 2022 14:30]

Report message to a moderator

Re: General Xtext question [message #1850964 is a reply to message #1850960] Wed, 23 March 2022 15:23 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

It is perfectly suited for that, but it will require for you to learn a bit. Xtext produces an Eclipse Plugin (when you did not disable that in the wizard).

The main thing is now: The plugin must be _installed_ into an Eclipse instance to become active. During development this is done by starting a so-called "Runtime Eclipse Instance". Xtext generates a so-called "Launch Configuration" for you. Then a 2nd instance of Eclipse starts up with your editor deployed.

When you later want to use this out of development you need a "p2 repository" from which you can install the plugin. This is also produced automatically with the default configuration.

For the beginning, Xtext makes this non-trivial topic very easy. However, it is really recommended to learn more about Eclipse Plugin Development, which is a more general topic, to understand this more. There are good books and blogs about this.
Re: General Xtext question [message #1850990 is a reply to message #1850964] Thu, 24 March 2022 07:32 Go to previous messageGo to next message
Gaël DENIAU is currently offline Gaël DENIAUFriend
Messages: 4
Registered: March 2022
Junior Member
Thank you, I'll look it up.
Re: General Xtext question [message #1850992 is a reply to message #1850990] Thu, 24 March 2022 07:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I re-use the Xtext model ultimately with the aim of supporting a more efficient LPG execution, but in the interim just to produce an LPG grammar that has stronger LALR grammar checking.

You may find the QVTo transformations and models that start from the *.xtext model in GIT\org.eclipse.ocl\examples\org.eclipse.ocl.examples.xtext2lpg

Regards

Ed Willink
Re: General Xtext question [message #1851017 is a reply to message #1850992] Thu, 24 March 2022 15:23 Go to previous message
Gaël DENIAU is currently offline Gaël DENIAUFriend
Messages: 4
Registered: March 2022
Junior Member
Thank you for your response Ed, but sadly I didn't understand a single word.

That being said, I've found a way to do it. By exporting the grammar+ide+ui and asking eclipse to instal them in 'this' Eclipse in the Export Wizard, I can make new file with the right extension and Xtext detects them. The .jar are indeed in the p2 repo.

Kind regards,
Previous Topic:Specify output directory of generated classes via configuration
Next Topic:Register Xtext Resource Factory in Xtend
Goto Forum:
  


Current Time: Tue Apr 16 04:11:12 GMT 2024

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

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

Back to the top