Skip to main content



      Home
Home » Modeling » TMF (Xtext) » EBNF how to specify a list separated by commas
EBNF how to specify a list separated by commas [message #47906] Thu, 04 June 2009 08:04 Go to next message
Eclipse UserFriend
Hello

I am having trouble specifying a comma separated list of elements, would
you know how to do this in EBNF for Xtext?

I have in my EBNF:

TOperation :
name=ID ( "(" (listOfArguments+=TArgument")" )? ;

TArgument : type=TDataType name=ID;

I would like to have the arguments separated by a comma.
for example:
operation1(myBoolean arg1, myBoolean arg2);

The arguments must be contained in the "listOfArguments" variable in
TOperation.

Any help would be appreciated,

Kind regards.
Re: EBNF how to specify a list separated by commas [message #47936 is a reply to message #47906] Thu, 04 June 2009 08:05 Go to previous messageGo to next message
Eclipse UserFriend
Sorry let me revise my grammar declaration...


> TOperation :
> name=ID ( "(" (listOfArguments+=TArgument)* ")" )? ;

> TArgument : type=TDataType name=ID;
Re: EBNF how to specify a list separated by commas [message #47965 is a reply to message #47906] Thu, 04 June 2009 08:30 Go to previous messageGo to next message
Eclipse UserFriend
Typically one writes something like this:

TOperation :
name=ID ( "(" listOfArgs+=TArgument (',' listOfArgs+=TArgument)* ")" )?;

Cheers,
Sven


dw schrieb:
> Hello
>
> I am having trouble specifying a comma separated list of elements, would
> you know how to do this in EBNF for Xtext?
>
> I have in my EBNF:
>
> TOperation :
> name=ID ( "(" (listOfArguments+=TArgument")" )? ;
>
> TArgument : type=TDataType name=ID;
>
> I would like to have the arguments separated by a comma.
> for example:
> operation1(myBoolean arg1, myBoolean arg2);
>
> The arguments must be contained in the "listOfArguments" variable in
> TOperation.
>
> Any help would be appreciated,
>
> Kind regards.
>
Re: EBNF how to specify a list separated by commas [message #47996 is a reply to message #47936] Thu, 04 June 2009 08:31 Go to previous messageGo to next message
Eclipse UserFriend
Please ignore my previous post, I didnt know that this was possible:

TOperation :
name=ID ( '(' (arguments+=TArgument (',' arguments+=TArgument)*)? ')'
)?
;

It appears to work!
Re: EBNF how to specify a list separated by commas [message #48025 is a reply to message #47965] Thu, 04 June 2009 08:39 Go to previous message
Eclipse UserFriend
Many thanks Sven.
Previous Topic:Installation Problems with Ganymede
Next Topic:Exception "Unresolved proxy ..." to subpackage in externel meta-model
Goto Forum:
  


Current Time: Tue Jul 22 17:55:18 EDT 2025

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

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

Back to the top