Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Combining Grammars
Combining Grammars [message #1256891] Tue, 25 February 2014 22:46 Go to next message
Alan Grixti is currently offline Alan GrixtiFriend
Messages: 2
Registered: February 2014
Junior Member
Consider there being two grammars in two different projects, Grammar A and Grammar B and some rules of grammar B point to non-terminals in grammar A resulting in B sitting on top of A.

I have two main questions. The first question is that of if there are any validations / generations related to Grammar A, must they be located in A's project or in B's project? (Preferably in A)...

...and if there is a way of putting the validations / generations in A's projects, is there a way to link them?

So far what I have managed to achieve is to extend A's validation from B, resulting in B's validation acquiring A's validation. However I cannot do this as generation makes use of IGenerator, and even if one extends A's generator class the Resource parameter is difficult to bypass.

Any help is greatly appreciated, thanks Smile
Re: Combining Grammars [message #1257794 is a reply to message #1256891] Wed, 26 February 2014 20:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13641
Registered: July 2009
Senior Member
Hi,

validation should inherit automatically

(you may have to override getEPackages() to return the parent dsls epackage too.

for the generator you have to care yourself. (of course you may reuse the code from the parents generator too...
i dont get your point regarding this..


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: Combining Grammars [message #1257881 is a reply to message #1257794] Wed, 26 February 2014 22:16 Go to previous message
Alan Grixti is currently offline Alan GrixtiFriend
Messages: 2
Registered: February 2014
Junior Member
First of all I would like to thank you for your reply. I've read a couple of posts on your blog and they've been very helpful.

What I am trying to do here is to create "a system" which can be easily altered and extended with a "plug and play" feature, kind of. I have an "abstract" grammar one can say, let it be A -> B1 | B2 | B3 where all the B's are non-terminal rules. A client / colleague would give me another grammar C, which contains instructions B1 -> a1|b2|c2 , B2 -> a2|b2|c2 and B3-> a3|b3|c3. By having such a setup I can reuse several parts of the project onto several other projects by simply changing a couple of references.

I managed to make the generator of grammar B work by extending the generator of grammar A and passing everything to the super class and have the code generated. If you know of any "neater" ways of doing this it would be greatly appreciated:) Thanks Smile
Previous Topic:DSLProposalProvider (access external data)
Next Topic:Syntactic sugar with assigned actions
Goto Forum:
  


Current Time: Tue Oct 27 16:42:34 GMT 2020

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

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

Back to the top