Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Getting all values under a category
icon12.gif  Getting all values under a category [message #1721551] Thu, 28 January 2016 09:22 Go to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Hi This is my grammar.

Query:
(key=Greeting)? (to=GroupTo)? from: Name


Greeting:
keyword='hello'
;

Name:
name=ID

GroupTo:
group+='and' name1=Name (','name1+=Name)*

;


I am trying to understand sentences like

hello john and jim from: tim


In the doGenerate method I want to retrieve the names only in GroupTo category. I am unable to take these name under one variable.

Instead of using name1 and name2 .I wish to use one variable to get all the names under Group.

var groupToNames =resource.allContents.filter(typeof(GroupTo)).map[name1].toIterable

How can I use one variable such that all Names under GroupTo is captured and I do not have to use name1 and name 2.

Is there a better way to represent the grammar or the retrieval in doGenerate method.
Also , I see that I cannot use the "to" variable to map.

Am I missing something.?




[Updated on: Thu, 28 January 2016 09:23]

Report message to a moderator

Re: Getting all values under a category [message #1721552 is a reply to message #1721551] Thu, 28 January 2016 09:34 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 748
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Basically you might want something like this:

GroupTo:
group+=Name ('and' group+=Name)*;

This will collect all member names in the collection-valued attribute 'group'. I'm not sure where exactly you want to have the ',' keyword as it is not mentioned in the concrete example.


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Getting all values under a category [message #1721665 is a reply to message #1721552] Fri, 29 January 2016 03:24 Go to previous message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thank You for this.

GroupTo:
group+=Name ('and' group+=Name)*;


I wish to understand ,how can I add another category in the same rule.

For example I want to match

Australia and Jim
Jim and Australia
Australia and Australia
Jim and Jim

So ,in summary

I wish to match "COUNTRY/NAME and NAME/COUNTRY" in any order.

[Updated on: Fri, 29 January 2016 03:25]

Report message to a moderator

Previous Topic:Cannot root twice
Next Topic:Linking of duplicate objects in Xtext
Goto Forum:
  


Current Time: Fri Sep 24 19:09:55 GMT 2021

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

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

Back to the top