Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » derive in xtext(inheritance in long dsl grammar definition)
derive in xtext [message #723624] Fri, 09 September 2011 01:40 Go to next message
lulu  is currently offline lulu Friend
Messages: 19
Registered: August 2011
Junior Member
Hi, All,

I want to rewrite mysql grammar in Xtext. Because it is too long, writing in one .xtext file is difficult to parser.

Can I use "import" like in ANTLR 3.3 which can seperate long grammar to several grammar files?

Or, How to use single inheritance in xtext grammar?

e.g. A.xtext is derive from B.xtext, B.xtext is derive from C.xtext, ..., X.xtext is derive from Terminal.xtext.

Can I use this solution?

If it is OK, And how to definition in the beginning of those xtext grammars?


Thanks.

Lulu
Re: derive in xtext [message #723712 is a reply to message #723624] Fri, 09 September 2011 08:07 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Splitting up the grammar won't help you as Xtext will flatten that again
when generating the code.

Have you tried to set useClassSplitting=true in the *AntlrGenerator
fragments?


Am 09.09.11 03:40, schrieb lulu:
> Hi, All,
> I want to rewrite mysql grammar in Xtext. Because it is too long,
> writing in one .xtext file is difficult to parser.
> Can I use "import" like in ANTLR 3.3 which can seperate long grammar to
> several grammar files?
>
> Or, How to use single inheritance in xtext grammar?
>
> e.g. A.xtext is derive from B.xtext, B.xtext is derive from C.xtext,
> ..., X.xtext is derive from Terminal.xtext.
>
> Can I use this solution?
>
> If it is OK, And how to definition in the beginning of those xtext
> grammars?
>
>
> Thanks.
>
> Lulu
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: derive in xtext [message #723743 is a reply to message #723712] Fri, 09 September 2011 10:27 Go to previous messageGo to next message
lulu  is currently offline lulu Friend
Messages: 19
Registered: August 2011
Junior Member
Jan Koehnlein wrote on Fri, 09 September 2011 04:07
Splitting up the grammar won't help you as Xtext will flatten that again
when generating the code.

Have you tried to set useClassSplitting=true in the *AntlrGenerator
fragments?


Am 09.09.11 03:40, schrieb lulu:
> Hi, All,
> I want to rewrite mysql grammar in Xtext. Because it is too long,
> writing in one .xtext file is difficult to parser.
> Can I use "import" like in ANTLR 3.3 which can seperate long grammar to
> several grammar files?
>
> Or, How to use single inheritance in xtext grammar?
>
> e.g. A.xtext is derive from B.xtext, B.xtext is derive from C.xtext,
> ..., X.xtext is derive from Terminal.xtext.
>
> Can I use this solution?
>
> If it is OK, And how to definition in the beginning of those xtext
> grammars?
>
>
> Thanks.
>
> Lulu
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com



Yes, I set this classspliting=true in antlr generator fragment.

Because MySQL grammar is very complicate, can not write in one file?
Xtext will validate grammar file while it has some changes.
Re: derive in xtext [message #723986 is a reply to message #723743] Sat, 10 September 2011 07:27 Go to previous messageGo to next message
lulu  is currently offline lulu Friend
Messages: 19
Registered: August 2011
Junior Member
Any other suggestions?

I am focus on this solution those days.

Thanks
Re: derive in xtext [message #724023 is a reply to message #723986] Sat, 10 September 2011 11:23 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Sorry, I don't get your question.

grammar my.company.A with my.company.B

import ".."

...


doesn't work for you?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 10.09.11 09:27, lulu wrote:
> Any other suggestions?
>
> I am focus on this solution those days.
>
> Thanks
Re: derive in xtext [message #724039 is a reply to message #724023] Sat, 10 September 2011 13:04 Go to previous message
Ingo Meyer is currently offline Ingo MeyerFriend
Messages: 162
Registered: July 2009
Senior Member
Hi,

just as a hint...
I also integrated most of the SQL stuff in my grammar as 4 XExpressions (CRUD commands) and the full set of the corresponding SQL grammar elements.
And it is just a very small part of my 3300 loc Xtext grammar.
My Internal...Parser.java (the longer UI one) is 302525 loc ! Thats quite huge, but also here just a small part is the SQL one.

To achive this I reused Xbase and made all SQL functions as featurecalls via Java extension classes.
This will minimize the grammar part by maybe 80%. but you have to learn how to reuse Xbase in the field of Scoping, Typesystem and overloading operators.

HTH,
Ingo
Previous Topic:New composite update sites are available
Next Topic:[XBase] Overwriting Xbase Grammar Elements
Goto Forum:
  


Current Time: Thu Sep 19 19:22:09 GMT 2024

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

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

Back to the top