Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Deafult value for enums(Deafult value for enums)
icon5.gif  Deafult value for enums [message #1722028] Tue, 02 February 2016 05:58 Go to next message
Eclipse UserFriend
Hi All,
I have a clarification related to enums.
Always first enum value is set by default. For E.g.

enum MyEnum :
val1 | val2 ;

If some value is not set in the editor, by default it takes as val1. How do we avoid this ? Can we do something in the grammar?


Thanks in advance Smile


Regards,
Arshad
Re: Deafult value for enums [message #1722029 is a reply to message #1722028] Tue, 02 February 2016 06:00 Go to previous messageGo to next message
Eclipse UserFriend
You have to define the enum type in an ecore model and import that in your language. In that external model you can declare a default enum literal and omit that one in the grammar rule for the enum type so it's not part of the syntax.
icon5.gif  Re: Deafult value for enums [message #1722034 is a reply to message #1722029] Tue, 02 February 2016 06:40 Go to previous messageGo to next message
Eclipse UserFriend
Hi Miro,

Thanks for the reply.

But now say that, if that enum field is optional in my grammar then it will still consider the first element .. So we will have to check explicitly if it's set or not..


Regards,
Arshad
Re: Deafult value for enums [message #1722040 is a reply to message #1722034] Tue, 02 February 2016 07:10 Go to previous message
Eclipse UserFriend
yes you can use ecore unsettable eIsSet/eIsAttributeSet for that
Previous Topic:Changing the port for web DSL module
Next Topic:Loading XMI fails due to unresolved references that are provided by the LazyLinker when using DSL
Goto Forum:
  


Current Time: Mon Jul 14 00:34:46 EDT 2025

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

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

Back to the top