Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to include some multiline comments in the model instance ?
How to include some multiline comments in the model instance ? [message #1862907] Fri, 05 January 2024 14:40 Go to next message
Ronan Babin is currently offline Ronan BabinFriend
Messages: 18
Registered: July 2023
Junior Member
Hi,

My project is processing specific language (una) provided by the supplier tool.
A grammar file has been built to support the language and I built some code to load a una file, validate it then serialize it in xmi.
After I can work on the xmi file with Python to play with the model instance of the una file.

This is an example of the una file I'm parsing. It's simplified, the __TestGroup object contains much more information.
Unison:SyntaxRevision1709.9;
/**
		@brief my documentation
**/
__TestGroup test_tg {
}


The grammar is:
UnaFile:
 header=Header (una_elements+=UnaElement)*;

Header:
 'Unison:SyntaxRevision' version=Decimal ';';

UnaElement:
 TestGroup | CommentSection;

CommentSection:
 {CommentSection}
 comment=ML_COMMENT;

TestGroup:
 '__TestGroup' name=ID '{'
 '}';


In my Java main, I'm loading the Resource (una file), validate it then serialize it to xmi using the save() method of the Resource class.

My problem is that the comments from my original una file are not present in the xmi.
Is there a way to serialize also the comments ?

I did try in the grammar to have a CommentSection rule which takes terminal ML_COMMENT as value but I think that ML_COMMENT are ignored by the lexer (? not sure if it's the correct word).
Any help would be appreciated.
Re: How to include some multiline comments in the model instance ? [message #1862917 is a reply to message #1862907] Sat, 06 January 2024 06:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14695
Registered: July 2009
Senior Member
can you try unhide the comment?

Rulename hidden(WS, SL_COMMENT): ....


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to include some multiline comments in the model instance ? [message #1862940 is a reply to message #1862917] Mon, 08 January 2024 10:15 Go to previous message
Ronan Babin is currently offline Ronan BabinFriend
Messages: 18
Registered: July 2023
Junior Member
Hi Christian,

I looked around the hidden feature.
I move the default terminal in my grammar file and add the hidden() at the top of my file (without the ML_COMMENT).
Now my CommentSection rules is used when multline comments are detected and serialized in the .xmi.
It works like a charm !
Thanks for the support
Previous Topic:Cross references
Next Topic:How to generate synchronized code
Goto Forum:
  


Current Time: Thu Jul 18 04:53:13 GMT 2024

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

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

Back to the top