Skip to main content



      Home
Home » Modeling » TMF (Xtext) » "Hiding" a rule
"Hiding" a rule [message #871446] Sun, 13 May 2012 15:56 Go to next message
Eclipse UserFriend
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 15:57] by Moderator

Re: "Hiding" a rule [message #871449 is a reply to message #871446] Sun, 13 May 2012 16:15 Go to previous messageGo to next message
Eclipse UserFriend
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 16:16 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: "Hiding" a rule [message #871451 is a reply to message #871450] Sun, 13 May 2012 16:17 Go to previous messageGo to next message
Eclipse UserFriend
And no:

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

~Christian
Re: "Hiding" a rule [message #871454 is a reply to message #871451] Sun, 13 May 2012 16:28 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 02:28:30 EDT 2025

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

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

Back to the top