Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Mapping a grammar rule to possible resulting EClasses
Mapping a grammar rule to possible resulting EClasses [message #659770] Tue, 15 March 2011 14:36 Go to next message
Mark Christiaens is currently offline Mark ChristiaensFriend
Messages: 63
Registered: October 2010
Member
I would like to (programmatically) know what type of model objects (so the EClasses) can be generated by a certain rule.

I can get at the ParserRules of our grammar through the IGrammarAccess interface but I can't yet figure out how to go from such a rule to the EClasses of the model objects that can be generated by the rule.

Is there a way?
---
Mark Christiaens
Discover the Future of VHDL Design
Go to www.sigasi.com
Re: Mapping a grammar rule to possible resulting EClasses [message #659924 is a reply to message #659770] Wed, 16 March 2011 08:07 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Did you try

parserRule.getType().getEClassifier()?

Am 15.03.11 15:36, schrieb Mark Christiaens:
> I would like to (programmatically) know what type of model objects (so
> the EClasses) can be generated by a certain rule.
> I can get at the ParserRules of our grammar through the IGrammarAccess
> interface but I can't yet figure out how to go from such a rule to the
> EClasses of the model objects that can be generated by the rule.
> Is there a way?
> ---
> Mark Christiaens
> Discover the Future of VHDL Design
> Go to http://www.sigasi.com


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Mapping a grammar rule to possible resulting EClasses [message #659933 is a reply to message #659924] Wed, 16 March 2011 08:51 Go to previous messageGo to next message
Mark Christiaens is currently offline Mark ChristiaensFriend
Messages: 63
Registered: October 2010
Member
As I understand it, that gives me just one type. I was looking for a list of all the types that can result due to the embedded rule actions and the inheritance from other rules.

---
Mark Christiaens
Discover the Future of VHDL Design
Go to www.sigasi.com
Re: Mapping a grammar rule to possible resulting EClasses [message #659953 is a reply to message #659933] Wed, 16 March 2011 10:15 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
It will return the common supertype of all possible return types. Note
that an inheriting language could override some called parser rules and
return a different subtype. So you have to know all child languages in
order to get a correct result.

There is no shortcut/helper method I am aware of. You have to iterate
the contents of the rule and find all elements that could create the
returned semantic EObject, i.e. Actions and unassigned rule calls. The
union of their types and the return type of the rule should be what
you're looking for.

Am 16.03.11 09:51, schrieb Mark Christiaens:
> As I understand it, that gives me just one type. I was looking for a
> list of all the types that can result due to the embedded rule actions
> and the inheritance from other rules.
>
> ---
> Mark Christiaens
> Discover the Future of VHDL Design
> Go to http://www.sigasi.com


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:Updating the resource decorations
Next Topic:Preserving single and mult-line comments from separate editor when an EObject is deleted
Goto Forum:
  


Current Time: Wed Sep 25 13:20:55 GMT 2024

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

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

Back to the top