Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parsing and generating annotations
Parsing and generating annotations [message #871102] Thu, 10 May 2012 20:47 Go to next message
Jens-Uwe Moeller is currently offline Jens-Uwe MoellerFriend
Messages: 12
Registered: March 2012
Location: Hamburg
Junior Member
Hi,

I want to be able to write something similar like in Java:

/** documentation
/*
@annotation1
@annotation2
mylanguagetypeA name1 { xxx }

/** documentation
/*
@annotation2
@annotation1
mylanguagetypeB name2 { xxx }


Using "documentation = e.documentation" in the generation process allows me to access documentation without having defined this feature in the grammar at all - you i.e. xtext provide this feature to me.

When using annotations I get in conflict with the rule "one look ahead", when trying to define a grammar which is in its top rule similar like
Mylanguagetypes: MylanguagetypeA | MylanguagetypeB |MylanguagetypeC;

MylanguagetypeA: ... something for annotation ...
                 'mylanguagetypeA' ...

MylanguagetypeB: ... something for annotation ...
                 'mylanguagetypeB' ...


MylanguagetypeA resp. ..B resp. ..C are subject for code generation with the JVM inferer.

I can solve my problem easily by changing the language and integrating annotations behind the keywords 'mylanguagetypeA' etc. That way I can generate even complex annotations. But is there a better solution without changing the language?

Thanks in advance,
Jens


Re: Parsing and generating annotations [message #871164 is a reply to message #871102] Fri, 11 May 2012 08:21 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
That's a typical usecase for assigned actions.
Have a look at the Xtend.xtext grammar to get an impression.

Am 10.05.12 22:47, schrieb Jens-Uwe Moeller:
> Hi,
>
> I want to be able to write something similar like in Java:
>
>
> /** documentation
> /*
> @annotation1
> @annotation2
> mylanguagetypeA name1 { xxx }
>
> /** documentation
> /*
> @annotation2
> @annotation1
> mylanguagetypeB name2 { xxx }
>
>
> Using "documentation = e.documentation" in the generation process allows
> me to access documentation without having defined this feature in the
> grammar at all - you i.e. xtext provide this feature to me.
>
> When using annotations I get in conflict with the rule "one look ahead",
> when trying to define a grammar which is in its top rule similar like
>
> Mylanguagetypes: MylanguagetypeA | MylanguagetypeB |MylanguagetypeC;
>
> MylanguagetypeA: ... something for annotation ...
> 'mylanguagetypeA' ...
>
> MylanguagetypeB: ... something for annotation ...
> 'mylanguagetypeB' ...
>
>
> MylanguagetypeA resp. ..B resp. ..C are subject for code generation with
> the JVM inferer.
>
> I can solve my problem easily by changing the language and integrating
> annotations behind the keywords 'mylanguagetypeA' etc. That way I can
> generate even complex annotations. But is there a better solution
> without changing the language?
>
> Thanks in advance,
> Jens
>
>
>


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Parsing and generating annotations [message #871190 is a reply to message #871164] Fri, 11 May 2012 11:25 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
It's probably simpler to read the reference documentation about actions.

Regards,
Sebastian

Am 11.05.12 10:21, schrieb Jan Koehnlein:
> That's a typical usecase for assigned actions.
> Have a look at the Xtend.xtext grammar to get an impression.
>
> Am 10.05.12 22:47, schrieb Jens-Uwe Moeller:
>> Hi,
>>
>> I want to be able to write something similar like in Java:
>>
>>
>> /** documentation
>> /*
>> @annotation1
>> @annotation2
>> mylanguagetypeA name1 { xxx }
>>
>> /** documentation
>> /*
>> @annotation2
>> @annotation1
>> mylanguagetypeB name2 { xxx }
>>
>>
>> Using "documentation = e.documentation" in the generation process allows
>> me to access documentation without having defined this feature in the
>> grammar at all - you i.e. xtext provide this feature to me.
>>
>> When using annotations I get in conflict with the rule "one look ahead",
>> when trying to define a grammar which is in its top rule similar like
>>
>> Mylanguagetypes: MylanguagetypeA | MylanguagetypeB |MylanguagetypeC;
>>
>> MylanguagetypeA: ... something for annotation ...
>> 'mylanguagetypeA' ...
>>
>> MylanguagetypeB: ... something for annotation ...
>> 'mylanguagetypeB' ...
>>
>>
>> MylanguagetypeA resp. ..B resp. ..C are subject for code generation with
>> the JVM inferer.
>>
>> I can solve my problem easily by changing the language and integrating
>> annotations behind the keywords 'mylanguagetypeA' etc. That way I can
>> generate even complex annotations. But is there a better solution
>> without changing the language?
>>
>> Thanks in advance,
>> Jens
>>
>>
>>
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:2.3.0 M6 JVM generation and Enums
Next Topic:dangling reference error in XBlockExpression when accessing properties
Goto Forum:
  


Current Time: Tue Jul 07 12:59:01 GMT 2020

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

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

Back to the top