|
Re: Comma Seperated List [message #631462 is a reply to message #631458] |
Thu, 07 October 2010 15:12 |
|
hi,
this grammar works for me
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
decisions_section
: 'Decision[' domain=domain ',' decision_list=decision_list ']'
;
decision_list
: decision+=decision (',' decision+=decision)*
;
decision
: ID
| ID '[]'
;
domain : ID;
what does yours look like?
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Re: Comma Seperated List [message #631492 is a reply to message #631464] |
Thu, 07 October 2010 17:08 |
Marian Schiemann Messages: 2 Registered: October 2010 |
Junior Member |
|
|
Sven Efftinge wrote on Thu, 07 October 2010 11:15 | Would be helpful to see your Xtext grammar.
It works just like in Antlr.
DecisionSection :
'Decision[' domain=ID ',' decisions+=ID (',' decisions+=ID)* ']';
Sven
|
Sorry just forgot to post my Xtext grammar.
model :
'Model[' (sections+=section_list)* sections+=section ']' ;
section_list :
sections+=section ',' ;
section :
decisions_section
| parameters_section
;
decisions_section :
'Decisions[' domain=domain ',' (decisions+=decision_list)* decisions+=decision ']' ;
decision_list :
decisions=decision ',' ;
decision :
decision=ID
| decision=ID '[]'
;
parameters_section :
'Parameters[' parameter=ID ']' ;
domain : domain=ID ;
My Problem is that something like
Model[ Decisions[ domain , decision , ] ]
can be made.
Thank you for your fast replys.
Okay, i just tested Christian Dietrich's code, it really seems to work. Thank you.
[Updated on: Thu, 07 October 2010 17:09] Report message to a moderator
|
|
|
Re: Comma Seperated List [message #631502 is a reply to message #631492] |
Thu, 07 October 2010 18:23 |
|
Hi,
i tested you grammar with xtext 1.0.1 and the setup created with the wizard.
testing it with you model i get
Description Resource Path Location Type
no viable alternative at input ']' test.mydsl /x/src line: 1 /x/src/test.mydsl Xtext Check (fast)
as expected
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Comma Seperated List [message #631509 is a reply to message #631492] |
Thu, 07 October 2010 18:47 |
Sven Efftinge Messages: 1823 Registered: July 2009 |
Senior Member |
|
|
Do it like this :
> model :
> 'Model[' sections+=section (',' sections+=section)* ']' ;
>
> section :
> decisions_section
> | parameters_section
> ;
and
> decisions_section :
> 'Decisions[' domain=domain ',' decisions+=decision
> (',' decisions+=decision)* ']' ;
>
> decision :
> decision=ID
> | decision=ID '[]'
> ;
Sven
Am 10/7/10 7:08 PM, schrieb Marian Schiemann:
> Sorry just forgot to post my Xtext grammar.
>
>
> model :
> 'Model[' (sections+=section_list)* sections+=section ']' ;
> section_list :
> sections+=section ',' ;
>
> section :
> decisions_section
> | parameters_section
> ;
>
> decisions_section :
> 'Decisions[' domain=domain ',' (decisions+=decision_list)*
> decisions+=decision ']' ;
>
> decision_list :
> decisions=decision ',' ;
>
> decision :
> decision=ID
> | decision=ID '[]'
> ;
>
> parameters_section :
> 'Parameters[' parameter=ID ']' ;
>
> domain : domain=ID ;
>
>
> My Problem is that something like
>
> Model[ Decisions[ domain , decision , ] ]
>
> can be made.
>
--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
|
|
|
Powered by
FUDForum. Page generated in 0.02237 seconds