Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Grammar generation (How to Customize the way Xtext Generates Grammar)
Xtext Grammar generation [message #1291858] Fri, 11 April 2014 09:29 Go to next message
Salome Maro is currently offline Salome MaroFriend
Messages: 15
Registered: January 2014
Junior Member
Hi,

I am making a huge language (like UML in text). I already have an ecore metamodel and I am therefore using Xtext to generate the grammar automatically. I am wondering if there is a way I can change how Xtext generates the grammar and use my own custom template to generate this grammar.For example get rid of all the curly brackets and commas that are automatically generated.
Something like how the GenericFormatter woks but when the grammar is being generated.

Re: Xtext Grammar generation [message #1291875 is a reply to message #1291858] Fri, 11 April 2014 09:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

The Xtext source is grammar plus metamodel, so if you regard the
metamodel as your master your are auto-creating information.

For very simple languages this can work. For your large UML-like text
language I think you are doomed to fail.

Much better to let Xtext deduce the grammar once, then clean up by hand
once and thereafter maintain *.xtext and *.ecore as distinct but related
primary sources.

Regards

Ed Willink


On 11/04/2014 10:29, Salome Maro wrote:
> Hi,
>
> I am making a huge language (like UML in text). I already have an
> ecore metamodel and I am therefore using Xtext to generate the grammar
> automatically. I am wondering if there is a way I can change how Xtext
> generates the grammar and use my own custom template to generate this
> grammar.For example get rid of all the curly brackets and commas that
> are automatically generated. Something like how the GenericFormatter
> woks but when the grammar is being generated.
>
>
Re: Xtext Grammar generation [message #1291984 is a reply to message #1291875] Fri, 11 April 2014 11:57 Go to previous messageGo to next message
Salome Maro is currently offline Salome MaroFriend
Messages: 15
Registered: January 2014
Junior Member
Hi Ed,

Thanks for your quick reply.
Right now that is what I do, maintaining the .ecore and .xtext files separately.
I was wondering if there is a way to automate in case the language evolves a lot.

regards,
Salome
Re: Xtext Grammar generation [message #1292029 is a reply to message #1291984] Fri, 11 April 2014 12:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hui

If you really want to 'simplify', it is possible to derive the *.ecore
from the *.xtext, but Xtext is not a metamodeling language so getting
details of abstract inheritance and enumerations right can involve
unpleasant fudges.

Fundamentally grammar and metamodel are different - it is quite possible
that you have more than one grammar for the same metamodel, but only if
you keep them separate.

Regards

Ed Willink


On 11/04/2014 12:57, Salome Maro wrote:
> Hi Ed,
>
> Thanks for your quick reply.
> Right now that is what I do, maintaining the .ecore and .xtext files
> separately. I was wondering if there is a way to automate in case the
> language evolves a lot.
>
> regards,
> Salome
Re: Xtext Grammar generation [message #1292066 is a reply to message #1292029] Fri, 11 April 2014 13:33 Go to previous messageGo to next message
Salome Maro is currently offline Salome MaroFriend
Messages: 15
Registered: January 2014
Junior Member
Hi Ed,

Thanks again. This is very helpful.
But lets say from a research point of view I wanted to pursue how to generate grammar according to a different template than that coming with Xtext, where would I start looking?
I am not aware of where exactly Xtext makes/creates the generated grammar from ecore.

regards,
Salome
Re: Xtext Grammar generation [message #1292164 is a reply to message #1292066] Fri, 11 April 2014 15:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

For research, you may be interested in
http://www.eclipse.org/modeling/mdt/ocl/docs/publications/MODELS2010OCLWorkshop/oclxtext.pdf,
and slides 6,7,22 of
http://www.eclipse.org/modeling/mdt/ocl/docs/publications/MODELS2010OCLWorkshop/oclxtext.odp.
The hinted at automation should contribute to OCL 2.5.

Xtext is not the only tool available, so there may be others that
provide more integration, but I suspect they are mostly a little
different rather than a little better. Since Xtext is well established
within the Eclipse Simultaneous Release I have not felt tempted to look
elsewhere. The main size limitation of an Xtext grammar can be tackled
by an Xtext2LPG transformation that I started work on a couple of years
ago, but it's out of sight on my stack.

You can see from the slides that I see grammar and metamodels as
fundamentally separate so I like the way metamodel-annotated EBNF
(Xtext) respects the separation but allows joint usage.

Regards

Ed Willink

On 11/04/2014 14:33, Salome Maro wrote:
> Hi Ed,
>
> Thanks again. This is very helpful. But lets say from a research point
> of view I wanted to pursue how to generate grammar according to a
> different template than that coming with Xtext, where would I start
> looking?
> I am not aware of where exactly Xtext makes/creates the generated
> grammar from ecore.
> regards,
> Salome
Re: Xtext Grammar generation [message #1292356 is a reply to message #1292164] Fri, 11 April 2014 18:55 Go to previous message
Salome Maro is currently offline Salome MaroFriend
Messages: 15
Registered: January 2014
Junior Member
Hi Ed,

Thank you so much. I will look into the links you sent (looks very interesting).

best regards,

Salome.
Previous Topic:Xtend Problem
Next Topic:Can I use external compiler for Xtext?
Goto Forum:
  


Current Time: Fri Apr 26 04:49:29 GMT 2024

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

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

Back to the top