Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Split XText Grammar into multiple files
icon5.gif  Split XText Grammar into multiple files [message #898778] Fri, 27 July 2012 14:14 Go to next message
Gregoire de Hemptinne is currently offline Gregoire de Hemptinne
Messages: 3
Registered: January 2012
Junior Member
Hi All,

I created a grammar for Wazaabi (declarative UI framework) but the grammar file is very long and difficult to read. I would like to split the grammar into several files to make contribution easier.

I was not able to find any clear documentation or code sample to do that. Can someone help me?

I'm afraid I'll meet some problems since I have some abstract objects in my model. And if I split my grammar I will have to be able to reference to an abstract class defined in another grammar file.

Thank you in advance for your help Smile
Best regards
Re: Split XText Grammar into multiple files [message #898820 is a reply to message #898778] Fri, 27 July 2012 18:59 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
Hi,

if its only to improve readablity and not about reusing a grammar for several languages (like the default Terminals or Xbase), don't do it. There are too many problems involved (at least think well on the cost/value balance).

Comment the grammar, structure it well (order of elements but also indentation etc for good readability), write a separate documentation for the main concepts and with entry points for working with it. Use the tooling (outline view, find references etc.)

There is no Xtext concept for: take these 5 files and act as if they were defined in a single grammar file. The rule of thumb is that each grammar comes with its own meta model and language infrastructure. Further a grammar can "extend" only one other grammar.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de

[Updated on: Fri, 27 July 2012 19:02]

Report message to a moderator

Re: Split XText Grammar into multiple files [message #899011 is a reply to message #898820] Mon, 30 July 2012 07:28 Go to previous messageGo to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
hi
this means that i can't extend a grammar in another grammar twice ?, so i want to create many different grammar with their own model and i want at the end to import all the grammar created in another one such that the one containing the imported can be consider as a big model.
i also want to know if every grammar created since they have their own model , if i make a change in some of them , should i change my grammar containing that imported file too?
thanks in advance
Re: Split XText Grammar into multiple files [message #899059 is a reply to message #899011] Mon, 30 July 2012 11:40 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2500
Registered: July 2009
Senior Member
On 2012-30-07 9:28, frank fotso wrote:
> hi this means that i can't extend a grammar in another grammar twice ?,
uh,
grammar A and B can both extend grammar X, and grammar P can extend A, T
extend B etc. What you can not do is have a grammar that extends more
than one other grammar.

> so i want to create many different grammar with their own model and i
> want at the end to import all the grammar created in another one such
> that the one containing the imported can be consider as a big model.
No, that will not work.
You can however separate the model from the grammar and do the reuse,
combination in the models, and then use these models in various grammars.

> i also want to know if every grammar created since they have their own
> model , if i make a change in some of them , should i change my grammar
> containing that imported file too?

When a grammar is changed, you need to regenerate all grammars that
makes use of it to make it take effect.

If you import models instead of generating them from the grammar, you do
not need to regenerate the grammar/parsers as long as the model changes
are compatible with what is being used by the already built grammar.

Does that help you?
Regards
- henrik
Re: Split XText Grammar into multiple files [message #899851 is a reply to message #899059] Thu, 02 August 2012 15:23 Go to previous message
Gregoire de Hemptinne is currently offline Gregoire de Hemptinne
Messages: 3
Registered: January 2012
Junior Member
@Alexander, thank you for your answer. This is just the information I needed. Indeed, this is not optimal to split my grammar into several files only for improve readability. So I will continue working with this big file.
Regards
- Gregoire

[Updated on: Thu, 02 August 2012 15:23]

Report message to a moderator

Previous Topic:opening a xtext editor without a file
Next Topic:xtext arithmetics operation
Goto Forum:
  


Current Time: Sun Oct 26 04:30:20 GMT 2014

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

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