Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Accessing enum literals in Generator
Accessing enum literals in Generator [message #1063971] Mon, 17 June 2013 04:02 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I have the following grammar:

Model:
	greetings+=Greeting*;
	
enum Boolean:
	True = 'not' |
	False = 'real'
;

Greeting:
	'Hello' name=ID state=Boolean 'human' '!';


In my generator file, I want to compare the value of "state" to the literal value of the Boolean enum. Basically, I was looking for something like this:

if (state.compareTo(Boolean.True))

What is the equivalent for it in Xtend?
Re: Accessing enum literals in Generator [message #1063974 is a reply to message #1063971] Mon, 17 June 2013 05:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Boolean::True (may be upper case)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing enum literals in Generator [message #1063978 is a reply to message #1063971] Mon, 17 June 2013 06:12 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

is there a reason to use an enum?

Greeting:'Hello' name=ID ('real' | state?='not') 'human' '!';

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Previous Topic:bind scoping class
Next Topic:CTRL+SPACE action
Goto Forum:
  


Current Time: Thu Mar 28 13:48:31 GMT 2024

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

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

Back to the top