Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping and the name attribute
Scoping and the name attribute [message #638248] Wed, 10 November 2010 14:42 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

in my grammar I have something like this

Type:
kind=[ecore::EClass] typename=ID
;

and somewhere else I have

{TypeReference} '$' typeRef=[Type]

I've implemented scoping for Type in the desired context, and the list
of possible Type in that context is correct (I've tested it); however
scoping does not work because it uses the 'name' attribute for the
binding right? While in my case it should use 'typename' attribute...

it's not clear what to override to accomplish this.

Of course, I could do

Type:
kind=[ecore::EClass] name=ID
;

and scoping would work... but this would lead to another problem: if I
have in a program two such statements

MyEClass C
....
MyEClass C

I would get an error since I have two duplicate Types with the same name
(but that would be legal in my language)...

any clue please?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: Scoping and the name attribute [message #638321 is a reply to message #638248] Wed, 10 November 2010 20:15 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
org.eclipse.xtext.scoping.Scopes#scopeFor(Iterable, Function) is your friend.

Re: Scoping and the name attribute [message #638369 is a reply to message #638248] Thu, 11 November 2010 03:34 Go to previous messageGo to next message
Pierrick is currently offline PierrickFriend
Messages: 15
Registered: May 2010
Junior Member
what about
// java-based API for validation 
fragment = validation.JavaValidatorFragment {
	composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
	// allow us to define same name variables
	// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
	// registerForImportedPackages = true
}

in your .mwe2 generator file, just remove the
composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
Re: Scoping and the name attribute [message #638574 is a reply to message #638369] Thu, 11 November 2010 16:35 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
@Pierrick: that doesn't solve a different problem which we didn't see yet (yes, this sentence is deliberately hard to interpret Twisted Evil ).

Re: Scoping and the name attribute [message #638779 is a reply to message #638574] Fri, 12 November 2010 14:55 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 11/11/2010 05:35 PM, Meinte Boersma wrote:
> @Pierrick: that doesn't solve a different problem which we didn't see
> yet (yes, this sentence is deliberately hard to interpret :twisted: ).

I don't understand :)

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Previous Topic:xText syntax
Next Topic:debug message eSetBasedAllContainersStateProvider
Goto Forum:
  


Current Time: Fri Apr 26 19:35:48 GMT 2024

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

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

Back to the top