Skip to main content



      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 07:30 Go to next message
Eclipse UserFriend
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 08:01] by Moderator

Re: Lists and Attributes without order [message #881369 is a reply to message #881345] Mon, 04 June 2012 08:23 Go to previous messageGo to next message
Eclipse UserFriend
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 16:17 Go to previous message
Eclipse UserFriend
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 16:17] by Moderator

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


Current Time: Sun Jul 27 16:19:02 EDT 2025

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

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

Back to the top