Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Quoted Strings in Enums?
Quoted Strings in Enums? [message #60503] Fri, 17 July 2009 23:16 Go to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
I'm wanting to allow a quoted string to be used for an enum value. This
is because I want to provide some built-in attribute enums that match
the allowed values of STRING tokens for an analagous rule. Generating
something like that give's me:

enum SomeEnum :
AN_OPTION = '\"An Option\"';

AN_OPTION(0, "AN_OPTION", ""An Option"");

Which is of course an error.

Is this a bug, i.e. the generator isn't escaping properly, or if not is
there a way to accomplish this (that doesn't require too much hacking)?
I can find a way around this, so I'm just curious.
Re: Quoted Strings in Enums? [message #60523 is a reply to message #60503] Fri, 17 July 2009 23:44 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
It looks like quoted strings aren't allowed in any kind of entity. To
accomplish this using Rules or Enums I'm thinking I'd need to do some
kind of customization with ValueConverters or something. And I'm
thinking that that would be much easier to do taking a token value and
providing a contrained set of values from there.. which begs another
quesiton that I'll ask in a seperate thread. :)

On 2009-07-17 16:16:32 -0700, Miles Parker <milesparker@gmail.com> said:

>
> I'm wanting to allow a quoted string to be used for an enum value. This
> is because I want to provide some built-in attribute enums that match
> the allowed values of STRING tokens for an analagous rule. Generating
> something like that give's me:
>
> enum SomeEnum :
> AN_OPTION = '\"An Option\"';
>
> AN_OPTION(0, "AN_OPTION", ""An Option"");
>
> Which is of course an error.
>
> Is this a bug, i.e. the generator isn't escaping properly, or if not is
> there a way to accomplish this (that doesn't require too much hacking)?
> I can find a way around this, so I'm just curious.
Re: Quoted Strings in Enums? [message #60831 is a reply to message #60523] Sat, 18 July 2009 10:34 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Miles,

it seems, that you are stumbling upon a bug in the genmodel, if I get
your post right.
I guess that enum literals are not escaped properly. Maybe you want to
double check this?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 18.07.2009 1:44 Uhr, schrieb Miles Parker:
>
> It looks like quoted strings aren't allowed in any kind of entity. To
> accomplish this using Rules or Enums I'm thinking I'd need to do some
> kind of customization with ValueConverters or something. And I'm
> thinking that that would be much easier to do taking a token value and
> providing a contrained set of values from there.. which begs another
> quesiton that I'll ask in a seperate thread. :)
>
> On 2009-07-17 16:16:32 -0700, Miles Parker <milesparker@gmail.com> said:
>
>>
>> I'm wanting to allow a quoted string to be used for an enum value.
>> This is because I want to provide some built-in attribute enums that
>> match the allowed values of STRING tokens for an analagous rule.
>> Generating something like that give's me:
>>
>> enum SomeEnum :
>> AN_OPTION = '\"An Option\"';
>>
>> AN_OPTION(0, "AN_OPTION", ""An Option"");
>>
>> Which is of course an error.
>>
>> Is this a bug, i.e. the generator isn't escaping properly, or if not
>> is there a way to accomplish this (that doesn't require too much
>> hacking)? I can find a way around this, so I'm just curious.
>
>
Re: Quoted Strings in Enums? [message #60853 is a reply to message #60831] Sat, 18 July 2009 21:30 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Hi Sebastian,

Yes i think so too. I tried both ways I could think of for escaping..

https://bugs.eclipse.org/bugs/show_bug.cgi?id=283935

-Miles


On 2009-07-18 03:34:25 -0700, Sebastian Zarnekow
<Sebastian.Zarnekow@itemis.de> said:

> Hi Miles,
>
> it seems, that you are stumbling upon a bug in the genmodel, if I get
> your post right.
> I guess that enum literals are not escaped properly. Maybe you want to
> double check this?
>
> Regards,
> Sebastian
Previous Topic:Unsatisfied dependency on interim update site
Next Topic:[Xtext] Matching Value for a locale Rule not allowed in other Rules?
Goto Forum:
  


Current Time: Fri Nov 08 22:14:48 GMT 2024

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

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

Back to the top