Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Embedded grammar
Embedded grammar [message #881543] Mon, 04 June 2012 15:57 Go to next message
Eclipse UserFriend
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 17:07 Go to previous messageGo to next message
Eclipse UserFriend
hi,

xtext allows a linear inheritance hierarchy only

~Christian
Re: Embedded grammar [message #881626 is a reply to message #881567] Mon, 04 June 2012 20:04 Go to previous messageGo to next message
Eclipse UserFriend
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 02:10 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 16:13:51 EDT 2025

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

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

Back to the top