Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Reference scope
Reference scope [message #1403310] Tue, 22 July 2014 20:16 Go to next message
De Gumis is currently offline De GumisFriend
Messages: 1
Registered: July 2014
Junior Member
Hi!
I've just started mu journey with Xtext. I've created a simple grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "h_t_t_p://www.xtext.org/example/mydsl/MyDsl"

Services:
	'services' id=MYID name=ID '{'
	(points+=Points)+
	'}'
;

Points:
	'point' id=MYID name=ID '{'
		(entities+=Entity)*
		defaultPoints=DefaultPoints
	'}'
;

DefaultPoints:
	'defaultPoints' defaultPoints+=PointId (',' defaultPoints+=PointId)*
;

PointId:
	ref=[Basic];


Entity:
	Basic | Advanced
;


Basic:
	'basic' id=MYID name=ID '{'
		
	'}'	
;

Advanced:
	'advanced' id=MYID name=ID '{'
		'group' '{'
			defaultPoints+=PointId (',' defaultPoints+=PointId)*
		'}'
	'}'
;

terminal MYID:
	'A'..'Z' '-' INT;


Below is an example of use:
services S-2 whole_config {
	point P-1 point1 {
		basic B-1 basic11 {
			
		}
		basic B-2 basic12 {
			
		}
		basic B-3 basic13 {
			
		}
		advanced A-1 advanced11 {
			group {
				basic11 //here is ok
			}
		}
		defaultPoints basic11 //here is ok
	}

	point P-2 point2 {
		basic B-3 basic21 {
			
		}
		basic B-4 basic22 {
			
		}
		basic B-5 basic23 {
			
		}
		advanced A-2 advanced21 {
			group {
				basic11 //here I have an error
			}
		}
		defaultPoints basic11 //here I have an error
	}
}


In this grammar I use reference (in 'group' and DefaultPoints) a reference to "Basic".
Why I can not point 'basic' elements from P-1 in P-2? I can point only 'basic' elements int this same 'point'

Thank you in advance for any help
Re: Reference scope [message #1403443 is a reply to message #1403310] Wed, 23 July 2014 17:07 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
the reason for that is the default behaviour of defaultdeclarativequalifiednameprovider.
you could customize this one to return only the names of the elements and not to concatenate them with their parents name
which makes them insivible by their simple name.

you could alternatively change the grammar to

PointId:
ref=[Basic|FQN];

FQN: ID ("." ID)*;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtend editor does not see methods generated from IncQuery patterns until restart
Next Topic:errors while exporting to Repository
Goto Forum:
  


Current Time: Fri Apr 26 02:41:46 GMT 2024

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

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

Back to the top