Skip to main content



      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 04:22 Go to next message
Eclipse UserFriend
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 04:23] by Moderator

Re: Getting all values under a category [message #1721552 is a reply to message #1721551] Thu, 28 January 2016 04:34 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Getting all values under a category [message #1721665 is a reply to message #1721552] Thu, 28 January 2016 22:24 Go to previous message
Eclipse UserFriend
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: Thu, 28 January 2016 22:25] by Moderator

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


Current Time: Wed Jul 23 14:21:46 EDT 2025

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

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

Back to the top