Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » "Hiding" a rule
"Hiding" a rule [message #871446] Sun, 13 May 2012 19:56 Go to next message
Haravikk Kh\'arr is currently offline Haravikk Kh\'arrFriend
Messages: 19
Registered: February 2011
Junior Member
Hi there,

Been a while since I touched Xtext, but I'm back to working on a project I put on hiatus for a while.

Anyway, one thing that I never quite decided on a solution for, and still would like to solve, is how to *remove* a rule from an extended grammar.

For example; if I'm building a grammar that is an extension of Xbase, then is it possible to prevent the use of closures by somehow making that rule unusable.


I know how to override a rule, but I'm not sure I'd go about using that to prevent a rule from being used, other than to type some kind of garbage keyword in that nobody's likely to use.

[Updated on: Sun, 13 May 2012 19:57]

Report message to a moderator

Re: "Hiding" a rule [message #871449 is a reply to message #871446] Sun, 13 May 2012 20:15 Go to previous messageGo to next message
Haravikk Kh\'arr is currently offline Haravikk Kh\'arrFriend
Messages: 19
Registered: February 2011
Junior Member
Also as a side-note; is it possible to extend, rather than override a rule.

For example, if I wished to add a new literal type in Xbase's XLiteral rule, is it possible to somehow do the following:
XLiteral returns XExpression: XLiteral | MyNewLiteral;


Obviously the above returns an error, I'm curious to know if there's a way to refer to the Xbase version of XLiteral within my overriding XLiteral rule? Obviously it's not too hard to just copy/paste the Xbase version of XLiteral and add my changes in, but I'd rather just add mine on top, if possible.
Re: "Hiding" a rule [message #871450 is a reply to message #871446] Sun, 13 May 2012 20:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13661
Registered: July 2009
Senior Member
Hi,

you have to adapt the calling rules as well. e.g.

XLiteral returns XExpression:
	XBooleanLiteral |
	XIntLiteral |
	XNullLiteral |
	XStringLiteral |
	XTypeLiteral
;

XConstructorCall returns XExpression:
	{XConstructorCall}
	'new' constructor=[types::JvmConstructor|QualifiedName] 
	('<' typeArguments+=JvmArgumentTypeReference (',' typeArguments+=JvmArgumentTypeReference)* '>')?
	'(' 
		(
		    arguments+=XShortClosure
		  |	arguments+=XExpression (',' arguments+=XExpression)*
		)? 
	')';

...


~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: "Hiding" a rule [message #871451 is a reply to message #871450] Sun, 13 May 2012 20:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13661
Registered: July 2009
Senior Member
And no:

there is no extension => you have to copy and paste.

~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: "Hiding" a rule [message #871454 is a reply to message #871451] Sun, 13 May 2012 20:28 Go to previous message
Haravikk Kh\'arr is currently offline Haravikk Kh\'arrFriend
Messages: 19
Registered: February 2011
Junior Member
Thanks! Since it looks like I need to change XLiteral anyway then it shouldn't be too much trouble!
Previous Topic:Eclipse Juno + XTEXT 2.3 = SWT Error
Next Topic:Specify DSL files to build
Goto Forum:
  


Current Time: Sun Nov 29 23:55:51 GMT 2020

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

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

Back to the top