Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multiple languages in one file
Multiple languages in one file [message #759817] Wed, 30 November 2011 08:16 Go to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 431
Registered: July 2009
Location: Gothenburg
Senior Member
Hi!

I couldn't find any example about this, but it feels it should be possible to do.

The Java editor has highlighting and completion for JavaDocs, which is a different language than Java itself. How can I implement that with Xtext?

The regular way is to use partitions and register scanners and other handlers for each partition. I suppose I have to do that now by fiddling with the bindXXX methods in my Utilities class, but I don't see how to mix in different languages - should they be separate grammars, or should I mix in all of them in a big one? Where do I look?

best regards,
Vlad

[Updated on: Wed, 30 November 2011 08:17]

Report message to a moderator

Re: Multiple languages in one file [message #759821 is a reply to message #759817] Wed, 30 November 2011 08:34 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Vlad,

you usually have to define a grammar for the complete file. It is
certainly possible to mix different languages but it's a lot of effort
and usually not recommend.

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

Am 30.11.11 09:16, schrieb Vlad Dumitrescu:
> Hi!
>
> I couldn't find any example about this, but it feels it should be
> possible to do.
>
> The Java editor has highlighting and completion for JavaDocs, which is a
> different language than Java itself. How can I implement that with Xtext?
> The regular way is to use partitions and register scanners and other
> handlers for each partition. I suppose I have to do that now by fiddling
> with the bindXXX methods in my Utilities class, but I don't see how to
> mix in different languages - should they be separate grammars, or should
> I mix in all of them in a big one? Whare do I look?
>
> best regards,
> Vlad
>
Re: Multiple languages in one file [message #780282 is a reply to message #759821] Tue, 17 January 2012 14:26 Go to previous messageGo to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 431
Registered: July 2009
Location: Gothenburg
Senior Member
Thanks Sebastian! (sorry for the late answer)

That's a pity. I will see if I can put all these small languages in the same grammar. For this documentation structure, the only useful functionality is the syntax highlighting, hopefully it works.

Just an idea I just got: if I use semantic highlighting, can I highlight differently parts of a (comment) token? That would be a cleaner alternative.

regards,
Vlad
Re: Multiple languages in one file [message #780295 is a reply to message #780282] Tue, 17 January 2012 14:46 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-17-01 15:26, Vlad Dumitrescu wrote:
> Just an idea I just got: if I use semantic highlighting, can I highlight
> differently parts of a (comment) token? That would be a cleaner
> alternative.
>
Yes that works. I do that in Cloudsmith/Geppetto @ github. Works well.

regards
- henrik
Re: Multiple languages in one file [message #780346 is a reply to message #780295] Tue, 17 January 2012 16:29 Go to previous message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 431
Registered: July 2009
Location: Gothenburg
Senior Member
I'll really have to study the gepetto code in more detail, it's a gold mine! Maybe you should make a list of all the nifty features that you implemented, with pointers to the code. That would make a great FAQ.

Thanks!
/Vlad
Previous Topic:NPE in MyDSLGenerator
Next Topic:fill model for external libraries?
Goto Forum:
  


Current Time: Tue Apr 23 15:11:05 GMT 2024

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

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

Back to the top