Skip to main content



      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 09:40 Go to next message
Eclipse UserFriend
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 01:49 Go to previous messageGo to next message
Eclipse UserFriend
can you try unhide the comment?

Rulename hidden(WS, SL_COMMENT): ....
Re: How to include some multiline comments in the model instance ? [message #1862940 is a reply to message #1862917] Mon, 08 January 2024 05:15 Go to previous message
Eclipse UserFriend
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: Wed Mar 19 03:19:03 EDT 2025

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

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

Back to the top