Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to use Rules from an inherited grammar ?(I have a grammar chain and in the last grammar can not symbols from the first imported grammar.)
How to use Rules from an inherited grammar ? [message #1765640] Tue, 13 June 2017 00:36 Go to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
I have an import chain of grammar imports:
A -> B -> C -> D

A is my actual grammar and imports B which imports C which imports D.
Now I can not use symbols from B,C, or D in the grammar A.

Why ? is there a work around ?
Re: How to use Rules from an inherited grammar ? [message #1765642 is a reply to message #1765640] Tue, 13 June 2017 03:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
What do you means by symbols

If you mean the types simply import the epackage

Import "http:/...." as <name>


SomeRule returns <name>::SomeType:...


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: How to use Rules from an inherited grammar ? [message #1765648 is a reply to message #1765640] Tue, 13 June 2017 06:22 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 748
Registered: July 2009
Location: Dortmund, Germany
Senior Member

You likely want to build an inheritance chain with the "with" statement.

grammar A with B

grammar B with C

grammar C with D


This makes the rules available.

Similar if your derive from Xbase:

grammar foo.MyDSL with org.eclipse.xtext.xbase.Xbase

grammar org.eclipse.xtext.xbase.Xbase with org.eclipse.xtext.xbase.Xtype

Re: How to use Rules from an inherited grammar ? [message #1765726 is a reply to message #1765648] Tue, 13 June 2017 21:36 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
Karsten Thoms wrote on Tue, 13 June 2017 02:22
You likely want to build an inheritance chain with the "with" statement.

grammar A with B

grammar B with C

grammar C with D


This makes the rules available.



Yes I did use the "with" keyword for the grammar chain in the way you describe but in the last grammar I could not access the terminal rules ID, STRING, ... any more.
Re: How to use Rules from an inherited grammar ? [message #1765861 is a reply to message #1765726] Wed, 14 June 2017 04:05 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
Well that should work. If it does not and you transitively inherit from terminals then it would be nice to have a small reproducing example

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
Previous Topic:Integrating Xtext generated language server with Generic Editor
Next Topic:Preferences -> Templates shows contexts for Xtext, not my DSL
Goto Forum:
  


Current Time: Tue Sep 21 18:10:26 GMT 2021

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

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

Back to the top