Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Lists and Attributes without order(How to mix lists and attributes?)
icon5.gif  Lists and Attributes without order [message #881345] Mon, 04 June 2012 11:30 Go to next message
Nicole BehlenFriend
Messages: 8
Registered: May 2012
Location: Madrid
Junior Member
Can anyone help me with the following grammar. We need to be able to allow
lists and unique values (attributes) mixed up, without any order, so I defined
the following grammar. (It is just an example, but I need it in a very similar case)

Town:
'TOWN' name=STRING
'START'
(size = Size) &
(elevation = Elevation)? &
(inhabitant += (Adult | Child)+
'END'
;

Size:
'SIZE' size=INT;

Elevation:
'ELEVATION' elevation=INT 'm';

Adult:
'ADULT' name=STRING;

Child:
'CHILD' name=STRING;


Actually this definition, doesn't allow the following syntax. The CHILD Ana Belen wouldn't be allowed, as ELEVATION is coming after ADULT.


TOWN "Madrid"
START
SIZE 3265038
ADULT "Mariano Rajoy"
ELEVATION 667m
CHILD "Ana Belen"
END


Anyone can knows, how I could improve the grammar.

I would need some grammar definition like this, but actually it is not supported.

Town:
'TOWN' name=STRING
'START'
description=(Size | Evelation? | Adult* | Child*)
'END'
;


Is there a workaround? Thanks a lot in advance.

[Updated on: Mon, 04 June 2012 12:01]

Report message to a moderator

Re: Lists and Attributes without order [message #881369 is a reply to message #881345] Mon, 04 June 2012 12:23 Go to previous messageGo to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 430
Registered: July 2009
Location: Gothenburg
Senior Member
Hi!

AFAIK, lists have to be in one chunk. Maybe you can have
Town:
'TOWN' name=STRING
'START'
description+=(Size | Elevation | Adult | Child)*
'END'
;

and do some validation afterwards (one Size only, max one Elevation). Your model can filter the description list to deliver the inhabitants.

regards,
Vlad
Re: Lists and Attributes without order [message #881549 is a reply to message #881369] Mon, 04 June 2012 20:17 Go to previous message
Nicole BehlenFriend
Messages: 8
Registered: May 2012
Location: Madrid
Junior Member
Vlad, thanks a lot for your help. Tomorrow I will discuss this with our colleagues, probably we will do as you recommend. Again, many thanks!

[Updated on: Mon, 04 June 2012 20:17]

Report message to a moderator

Previous Topic:Xtext: src-gen is empty
Next Topic:Embedded grammar
Goto Forum:
  


Current Time: Mon Oct 26 19:58:16 GMT 2020

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

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

Back to the top