Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Embedded grammar
Embedded grammar [message #881543] Mon, 04 June 2012 19:57 Go to next message
Lionel Villard is currently offline Lionel VillardFriend
Messages: 11
Registered: January 2012
Junior Member
Hi,

I wonder if XText supports embedding grammars in a main grammar.

I'm aware of the grammar mixins feature, but it is limited to reusing grammars. Internally XText builds only one big ANTLR grammar, whereas in the embedding scenario, XText would have to generate multiple ANTLR grammars, where typically the main grammar would call the other sub-grammars.

How this could be done in XText?

Thanks!
Lionel
Re: Embedded grammar [message #881567 is a reply to message #881543] Mon, 04 June 2012 21:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13645
Registered: July 2009
Senior Member
hi,

xtext allows a linear inheritance hierarchy only

~Christian


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: Embedded grammar [message #881626 is a reply to message #881567] Tue, 05 June 2012 00:04 Go to previous messageGo to next message
Lionel Villard is currently offline Lionel VillardFriend
Messages: 11
Registered: January 2012
Junior Member
Are there any plans to support grammar embedding in XText?

For instance, I can imagine a Java editor which directly embed SQL/JQL statements. It would be very powerful if this can be done by just importing an SQL/JQL grammar directly without messing up too much the Java grammar. (this is just an example)

Thanks
Re: Embedded grammar [message #881710 is a reply to message #881626] Tue, 05 June 2012 06:10 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6880
Registered: July 2009
Senior Member
Hi

My use case is similar. I pass the body of a 'JavaDoc' comment to a
Documentation Language such as Xdoc, which in turn may have markup
expressions in the first or a third language.

I discussed this with Sebastian at EclipseCon. We agreed that all this
requires is a very minor Xtext grammar extension so that the outer
grammar associates the 'comment' terminal with the inner grammar name.

The outer grammar therefore parses a comment without worrying about the
inner grammar; then the inner grammar handles the nested parse. It
'just' requires a 'little' knitting to ensure that error messages,
selections etc tunnel up and down the grammar hierarchy.

We just need to get sufficient user enthusiasm to motivate someone to do
this.

Regards

Ed Willink




On 05/06/2012 01:04, Lionel Villard wrote:
> Are there any plans to support grammar embedding in XText?
>
> For instance, I can imagine a Java editor which directly embed SQL/JQL
> statements. It would be very powerful if this can be done by just
> importing an SQL/JQL grammar directly without messing up too much the
> Java grammar. (this is just an example)
>
> Thanks
Previous Topic:Lists and Attributes without order
Next Topic:Predicated unordered group - what is that?
Goto Forum:
  


Current Time: Sat Oct 31 14:29:44 GMT 2020

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

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

Back to the top