Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Whitespace problem in comma separated list
Whitespace problem in comma separated list [message #756569] Mon, 14 November 2011 11:26 Go to next message
Steffen Schuette is currently offline Steffen SchuetteFriend
Messages: 26
Registered: August 2010
Junior Member
Dear xtexters,

I'm trying to specify the grammar for a comma separated list, like "[1, 2, 3]".
However, I cannot manage to solve the whitespace problem. My editor forces me to write "[1,2,3]". How do I enable some form of whitespace insensitivity?

Here is my grammar:

Array:
'[' values+=INT ((',' values+=INT)*)?']';



Thank you very much.
Re: Whitespace problem in comma separated list [message #756585 is a reply to message #756569] Mon, 14 November 2011 12:16 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
This is described in the documentation.

hidden(WS, SL_COMMENT, ML_COMMENT)

If you are using the default terminals, you get this out of the box. If
not, you have to make your terminals hidden (whatever you call the
hidden ones).

As an example, in my DSL, I have this:
grammar org.cloudsmith.geppetto.pp.dsl.PP hidden(WS, SL_COMMENT, ML_COMMENT)

Regards
- henrik

On 11/14/11 12:26 PM, steffen.schuette wrote:
> Dear xtexters,
>
> I'm trying to specify the grammar for a comma separated list, like "[1,
> 2, 3]".
> However, I cannot manage to solve the whitespace problem. My editor
> forces me to write "[1,2,3]". How do I enable some form of whitespace
> insensitivity?
>
> Here is my grammar:
>
> Array:
> '[' values+=INT ((',' values+=INT)*)?']';
>
>
>
> Thank you very much.
Re: Whitespace problem in comma separated list [message #756668 is a reply to message #756585] Mon, 14 November 2011 15:51 Go to previous messageGo to next message
Steffen Schuette is currently offline Steffen SchuetteFriend
Messages: 26
Registered: August 2010
Junior Member
Hi,

thanks for the fast response. I am using the default terminals so it should work. But it doesn't. Just to be sure I created a demo project using the Project wizard. Then, an array like defined above works also with whitespaces. However, for my grammar it doesn't.

Ther must be some other token confusing the parser (or me). Do you have any idea where I can take a closer look?
The grammar is too large for dissecting it here.

The syntax error highlighted by the editor is: "mismatched input ', ' expecting ']'"

Here is my exact definition:

grammar de.offis.mosaik.mosl.MoSL with org.eclipse.xtext.common.Terminals
//...
ParameterValues:
parameter=[Parameter] '=' '[' values+=INT((',' values+=INT)*)?']';
//...


Thanks.
Re: Whitespace problem in comma separated list [message #756717 is a reply to message #756668] Mon, 14 November 2011 19:13 Go to previous message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Ditching the '?' might be a good idea, as * already means 0 or more times.

Furthermore, check whether any of the "rule call paths" to ParameterValues define a hidden without the WS terminal. hidden() works in a cascading way.


Previous Topic:Xtend and Charset fun
Next Topic:Cannot override final binding bug in 2.2?
Goto Forum:
  


Current Time: Fri Mar 29 06:02:43 GMT 2024

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

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

Back to the top