Embedded grammar [message #881543] |
Mon, 04 June 2012 15:57  |
Eclipse User |
|
|
|
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 #881710 is a reply to message #881626] |
Tue, 05 June 2012 02:10  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04132 seconds