Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Extract keywords from grammar
Extract keywords from grammar [message #650521] Tue, 25 January 2011 12:12 Go to next message
drew frantz is currently offline drew frantzFriend
Messages: 340
Registered: July 2009
Senior Member
Is there a way to grab the collection of keywords in the grammar? I see
GrammarAccess has findKeywords, but I want to list them all.
Re: Extract keywords from grammar [message #650529 is a reply to message #650521] Tue, 25 January 2011 12:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Stefan-Isele.gmx.de

He, try it like this :
@Test
public void testKeywords() throws Exception {
TreeIterator<EObject> allContents = grammarAccess.getGrammar().eResource().getAllContents();
while (allContents.hasNext()) {
EObject o = allContents.next();
if (o instanceof Keyword) {
log("keyword : %s", o);
}
}
}

Stefan Isele

drew schrieb:
> Is there a way to grab the collection of keywords in the grammar? I see
> GrammarAccess has findKeywords, but I want to list them all.
>
>
>
Re: Extract keywords from grammar [message #650634 is a reply to message #650521] Tue, 25 January 2011 19:04 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

I guess the combination GrammarUtil.getAllKeywords and GrammarAccess' getGrammar() will do the trick as well.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Previous Topic:derived properties
Next Topic:customizing selection of text from outline
Goto Forum:
  


Current Time: Sat Apr 27 04:25:11 GMT 2024

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

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

Back to the top