Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping and content assist relation
Scoping and content assist relation [message #690803] Thu, 30 June 2011 08:56 Go to next message
Balazs Varnai is currently offline Balazs VarnaiFriend
Messages: 21
Registered: June 2011
Junior Member
I have a simple grammar below, but the content assist displays possibilities like 'include' under 'package'. Should I customize content assist or change the scoping? My impression was that scoping only applies to references a given context?

Model:
	package=PackageDeclaration;

PackageDeclaration:
	'package' name=QualifiedName '{'
	elements+=AbstractPackageElement*
	'}';

AbstractPackageElement:
	ModuleDeclaration | TestDeclaration;

ModuleDeclaration:
	'module' name=QualifiedName '{'
	properties+=Property* &
	elements+=AbstractModuleElement*
	'}';

AbstractModuleElement:
	Include | PreCompileOption | Type;

Include:
	'include' name=STRING;


Feeding this sample input, gives an error "missing '}' at 'module'". Naturally, it should complain about 'include' being in the wrong place.

package myPackge{
	include "inc"
	module myModule {
	}
}


Thanks for helping!
Re: Scoping and content assist relation [message #690918 is a reply to message #690803] Thu, 30 June 2011 12:20 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Balazs,

please be careful with the precedencies of &, | and sequential lists of
grammar elements. Your rule

ModuleDeclaration:
'module' name=QualifiedName '{'
properties+=Property* &
elements+=AbstractModuleElement*
'}';

should probably read like:

ModuleDeclaration:
'module' name=QualifiedName '{'
( properties+=Property* & elements+=AbstractModuleElement* )
'}';

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

On 30.06.11 10:56, Balazs Varnai wrote:
> I have a simple grammar below, but the content assist displays
> possibilities like 'include' under 'package'. Should I customize content
> assist or change the scoping? My impression was that scoping only
> applies to references a given context?
>
>
> Model:
> package=PackageDeclaration;
>
> PackageDeclaration:
> 'package' name=QualifiedName '{'
> elements+=AbstractPackageElement*
> '}';
>
> AbstractPackageElement:
> ModuleDeclaration | TestDeclaration;
>
> ModuleDeclaration:
> 'module' name=QualifiedName '{'
> properties+=Property* &
> elements+=AbstractModuleElement*
> '}';
>
> AbstractModuleElement:
> Include | PreCompileOption | Type;
>
> Include:
> 'include' name=STRING;
>
>
> Feeding this sample input, gives an error "missing '}' at 'module'".
> Naturally, it should complain about 'include' being in the wrong place.
>
>
> package myPackge{
> include "inc"
> module myModule {
> }
> }
>
>
> Thanks for helping!
>
Re: Scoping and content assist relation [message #690925 is a reply to message #690803] Thu, 30 June 2011 12:33 Go to previous messageGo to next message
Balazs Varnai is currently offline Balazs VarnaiFriend
Messages: 21
Registered: June 2011
Junior Member
Hi Sebastian,

Thanks again! Now I get a lot of warnings like below. I guess my grammar smells bad.

Decision can match input such as "'property' RULE_ID RULE_ID" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
Semantic predicates were present but were hidden by actions.
Re: Scoping and content assist relation [message #690949 is a reply to message #690925] Thu, 30 June 2011 12:53 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
It's hard to tell what's wrong without your complete grammar. However,
AntlrWorks may help to spot the errors.

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


On 30.06.11 14:33, Balazs Varnai wrote:
> Hi Sebastian,
>
> Thanks again! Now I get a lot of warnings like below. I guess my grammar
> smells bad.
>
> Decision can match input such as "'property' RULE_ID RULE_ID" using
> multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
> Semantic predicates were present but were hidden by actions.
>
Previous Topic:Bind an action to CTRL and mouse click in XText
Next Topic:XtextReconcilerJob
Goto Forum:
  


Current Time: Fri Mar 29 11:25:44 GMT 2024

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

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

Back to the top