Skip to main content



      Home
Home » Modeling » TMF (Xtext) » is it possible to add more than one grammer in same plugin?(is it possible to add more than one grammer in same plugin?)
is it possible to add more than one grammer in same plugin? [message #1722916] Wed, 10 February 2016 05:00 Go to next message
Eclipse UserFriend
is it possible to add more than one grammer in same plugin?

I already created a grammer and its working as expected
is it possible to add another one and switch between them based on some conditions?

in certain condition i will use parser1, in other conditions i will convert to parser2
Re: is it possible to add more than one grammer in same plugin? [message #1722919 is a reply to message #1722916] Wed, 10 February 2016 05:18 Go to previous messageGo to next message
Eclipse UserFriend
Multiple grammars (languages) in the same plug-in are possible. You have to merge the language section in the MWE2 workflow.

Whether language switching is possible depends on the condition. You'd have to define and register content types. Content types are meant to be detected based on simple and fast mechanisms, e.g. a regexp, and should not require complex actions such as parsing. Once the content types are defined, register the resource factory to the content type instead of the file extension (plugin.xml of the runtime plug-in). There are could be issues with Xtext and content types.

I'd rather merge the two grammars, or have a dispatcher grammar to do the switching.

Re: is it possible to add more than one grammer in same plugin? [message #1722920 is a reply to message #1722916] Wed, 10 February 2016 05:19 Go to previous messageGo to next message
Eclipse UserFriend
Yes, it is possible.
You'll need to write a composed mwe2 file, with two language elements in it.
In the eclipse plug-in there will be an injector for each language.

What version of Xtext do you use?
Re: is it possible to add more than one grammer in same plugin? [message #1722973 is a reply to message #1722920] Wed, 10 February 2016 10:45 Go to previous messageGo to next message
Eclipse UserFriend
i am using version 2.8
Re: is it possible to add more than one grammer in same plugin? [message #1723002 is a reply to message #1722973] Wed, 10 February 2016 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Don't forget that if you add a new grammar, and you add a new language in your mwe2, you need to also make sure you update your plugin.xml files from the plugin.xml_gen, for example in your ....model.ui plugin.
If you don't your language will not be recognized even if everything is generated properly.

In eclipse, check control-shift-r and type "plugin.xml_gen"
you will see everywhere those files are generated.

[Updated on: Wed, 10 February 2016 13:35] by Moderator

Re: is it possible to add more than one grammer in same plugin? [message #1726416 is a reply to message #1723002] Sun, 13 March 2016 04:35 Go to previous messageGo to next message
Eclipse UserFriend
I will be able to link one EOBject from first grammar to the second one, right ?
Re: is it possible to add more than one grammer in same plugin? [message #1726715 is a reply to message #1726416] Tue, 15 March 2016 17:29 Go to previous messageGo to next message
Eclipse UserFriend
Yes
Re: is it possible to add more than one grammer in same plugin? [message #1726776 is a reply to message #1726715] Wed, 16 March 2016 08:51 Go to previous messageGo to next message
Eclipse UserFriend
If we have two different languages (with different file extensions), is it better to write the grammars in the same plugin or in two different plugins?
In case of two different plugin solution, i will be able to link objects from one language to the other, right?
Re: is it possible to add more than one grammer in same plugin? [message #1726779 is a reply to message #1726776] Wed, 16 March 2016 09:18 Go to previous message
Eclipse UserFriend
Yes, you just have to add a dependency from the referring to the referred language plug-ins
Previous Topic:apparent wizard failure
Next Topic: XMI file error.
Goto Forum:
  


Current Time: Tue Jul 15 06:14:30 EDT 2025

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

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

Back to the top