Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Implementing infix dot operator
Implementing infix dot operator [message #667891] Mon, 02 May 2011 15:50 Go to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Hello everybody,

I have to implement the infix dot operator to access inner members of objects. For example, I have this grammar:

Domain:
	'Name:' name=ID
	 numericEnumeratedValues=NumericEnumeratedValues
;

NumericEnumeratedValues :
	('Values:' '{' enumeratedvalues+=NumericEnumeratedValue (',' enumeratedvalues+=NumericEnumeratedValue)* '}')
;

NumericEnumeratedValue :
	value=NUMBER name=ID
;


, so I could write something like:

Name: testDomain
Values: {
          0 MyTrueValue
          1 MyFalseValue
}


Now I would like to access any of those values from different objects:

      testDomain.MyTrueValue


For now, is it not really important if the possible values (MyTrueValue and MyFalseValue) are shown automatically after writing the dot. I can work with the Ctrl-space autocompletion.

I was thinking of writing something like:

ConstantReference :
	DomainReference ({Point.left = current} '.' right=ValueReference)	
;

DomainReference:
	dom=[domainRef::Domain]
;

ValueReference:
	val=[ecore::EObject]  //I dont know what to write here
;



and somehow filter the content shown at the right side of the dot operator, but first, I think the NumericEnumeratedValue of the Domain is not being exported, even though it has a name feature, and second if they were exportend and shown in the ValueReference, I would be able to get and filter by NumericEnumeratedValue type, but I will need to get only the NumericEnumeratedValue belonging to the Domain I wrote at the right side of the dot operator and I don't know how to do it.

I think I maybe going on the wrong path here.

Any advise?

Thank you very much for your help.
Re: Implementing infix dot operator [message #667943 is a reply to message #667891] Mon, 02 May 2011 21:22 Go to previous message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
It was easier than I thought. I did something like the explanation from:
http:// www.eclipse.org/forums/index.php?t=msg&th=172683&sta rt=0&

Thank you!

[Updated on: Mon, 02 May 2011 21:32]

Report message to a moderator

Previous Topic:No squiggly for error on newline
Next Topic:OCL Execution Environment for Xtext?
Goto Forum:
  


Current Time: Thu Apr 18 23:10:05 GMT 2024

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

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

Back to the top