Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to deal with optional commas?
How to deal with optional commas? [message #667700] Sun, 01 May 2011 14:17 Go to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hi,
I have a case where I want serialization to insert commas in a list, but
I want to accept missing commas in the grammar to be able to flag this
style as deprecated.

ListOfNames : names += STRING (','? names += STRING) ;

1. The deprecation warning I thought I would add in validation.
i.e. check if there is a nodemodel for ListOfNames. Where should
I look for the commas?

2. How do I make serialization emit a ',' when serializing the model?

Regards
- henrik
Re: How to deal with optional commas? [message #667708 is a reply to message #667700] Sun, 01 May 2011 14:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi Henrik

Try enlarging the alternative; it seems to use the first.

ListOfNames : names += STRING ((',' names += STRING) | (names += STRING)) ;

Regards

Ed Willink


On 01/05/2011 15:17, Henrik Lindberg wrote:
> Hi,
> I have a case where I want serialization to insert commas in a list,
> but I want to accept missing commas in the grammar to be able to flag
> this style as deprecated.
>
> ListOfNames : names += STRING (','? names += STRING) ;
>
> 1. The deprecation warning I thought I would add in validation.
> i.e. check if there is a nodemodel for ListOfNames. Where should
> I look for the commas?
>
> 2. How do I make serialization emit a ',' when serializing the model?
>
> Regards
> - henrik
Re: How to deal with optional commas? [message #667812 is a reply to message #667700] Mon, 02 May 2011 10:23 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Henrik,

Moritz is working on a new version of the serializer that will allow to
customize that. So far Ed's suggestion should work.

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

Am 01.05.11 16:17, schrieb Henrik Lindberg:
> Hi,
> I have a case where I want serialization to insert commas in a list, but
> I want to accept missing commas in the grammar to be able to flag this
> style as deprecated.
>
> ListOfNames : names += STRING (','? names += STRING) ;
>
> 1. The deprecation warning I thought I would add in validation.
> i.e. check if there is a nodemodel for ListOfNames. Where should
> I look for the commas?
>
> 2. How do I make serialization emit a ',' when serializing the model?
>
> Regards
> - henrik
Re: How to deal with optional commas? [message #667845 is a reply to message #667812] Mon, 02 May 2011 12:28 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Thanks Ed and Sebastian,
I tried Ed's tip and it worked fine.

Good to hear there is a better solution on its way - don't really like
to mix concerns - maybe annotations in the grammar would be a good idea
for things like this? (OTOH - it could make the grammar cluttered with
annotations for all sorts of concerns, which is just a different evil).

- henrik

On 5/2/11 12:23 PM, Sebastian Zarnekow wrote:
> Hi Henrik,
>
> Moritz is working on a new version of the serializer that will allow to
> customize that. So far Ed's suggestion should work.
>
> Regards,
> Sebastian
Previous Topic:StackOverflowError
Next Topic:What is the syntax to set the antlr k option from the mwe2 file?
Goto Forum:
  


Current Time: Thu Sep 19 20:25:17 GMT 2024

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

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

Back to the top