Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:00 Go to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 10:18 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
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.



---
Get professional support from the Xtext committers at www.typefox.io
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 10:19 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

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 15:45 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 18:34 Go to previous messageGo to next message
Daniel Cardin is currently offline Daniel CardinFriend
Messages: 109
Registered: July 2009
Senior Member
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 18:35]

Report message to a 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 08:35 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 21:29 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Yes

---
Get professional support from the Xtext committers at www.typefox.io
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 12:51 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
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 13:18 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Yes, you just have to add a dependency from the referring to the referred language plug-ins

---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:apparent wizard failure
Next Topic: XMI file error.
Goto Forum:
  


Current Time: Sun Oct 24 01:10:35 GMT 2021

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

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

Back to the top