Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Using parser fragments with imported metamodel
Using parser fragments with imported metamodel [message #1720951] Fri, 22 January 2016 02:19 Go to next message
Eclipse UserFriend
Hi,

I've tried to reduce redundancies in my grammar by introducing some
parser fragments.

Example:

Variable:
TextVar | IntVar | ...;

Currently all sub type rules share some common attributes.

If I now define the following:

fragment VarFragment:
('documentation' documentation=EString)?
('value' value=EString)?;

This leads to the following error message:

Cannot create type for VarFragment because its EPackage is unknown.

Is it possible to use this feature nevertheless or is this not appropriate?

Thanks for your advice,

Axel
Re: Using parser fragments with imported metamodel [message #1720953 is a reply to message #1720951] Fri, 22 January 2016 02:55 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

if you have a look at the generated metamodel for a grammar using fragments you can see that the fragment type becomes a supertype of the types it uses

e.g.

Model:
Class|Method;

Class : Documented 'class' name2=ID ;
Method: Documented returnType=STRING name=ID ;

fragment Documented :
documentation=STRING;

=> Interfaces Class and Method inherit from both, model and Documented

=> i guess it works only if you have this structure in your metamodel as well.
Re: Using parser fragments with imported metamodel [message #1720997 is a reply to message #1720953] Fri, 22 January 2016 06:37 Go to previous message
Eclipse UserFriend
Thank you Christian.


Am 22.01.2016 um 08:55 schrieb Christian Dietrich:
> Hi,
>
> if you have a look at the generated metamodel for a grammar using
> fragments you can see that the fragment type becomes a supertype of the
> types it uses
>
> e.g.
>
> Model:
> Class|Method;
>
> Class : Documented 'class' name2=ID ;
> Method: Documented returnType=STRING name=ID ;
>
> fragment Documented :
> documentation=STRING;
>
> => Interfaces Class and Method inherit from both, model and Documented
>
> => i guess it works only if you have this structure in your metamodel as
> well.
Previous Topic:Change Editor
Next Topic:Couldn't resolve reference to JvmType 'ecore2xtext.FormatterFragment'
Goto Forum:
  


Current Time: Tue Jul 15 05:12:52 EDT 2025

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

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

Back to the top