Getting all values under a category [message #1721551] |
Thu, 28 January 2016 09:22 |
pranay roy 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 |
|
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 |
pranay roy 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
|
|
|
Powered by
FUDForum. Page generated in 0.03347 seconds