Skip to main content



      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 10:36 Go to next message
Eclipse UserFriend
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 04:07 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Mapping a grammar rule to possible resulting EClasses [message #659933 is a reply to message #659924] Wed, 16 March 2011 04:51 Go to previous messageGo to next message
Eclipse UserFriend
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 06:15 Go to previous message
Eclipse UserFriend
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
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 Jul 09 23:37:36 EDT 2025

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

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

Back to the top