Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parsing doxygen with xtext(non-quoted free text)
Parsing doxygen with xtext [message #1805331] Thu, 11 April 2019 22:34 Go to next message
Peter LustigFriend
Messages: 8
Registered: January 2019
Junior Member
Hi,

I'm getting good results with Xtext so far when I was choosing the layout of my language myself, but now I need to parse doxygen
e.g.

/**
* a normal member taking two arguments and returning an integer value.
* @param a an integer argument.
* @param s a constant character pointer.
* @see Javadoc_Test()
* @see ~Javadoc_Test()
* @see testMeToo()
* @see publicVar()
* @return The test results
*/
int testMe(int a,const char *s);

In the end I need to have all the comments in my model and want to validate whether all parameters are commented, no parameters are commented that do not exist etc.

It's obvious that somehow /** and */ and @param and similar need to be keywords or terminals. But I fail to wrap my head around how I can "catch" the "unquoted free text". If the free text was quoted, we could write somehting like
ParamDoc: "@param" [parameter] doc=STRING

and it would be very simple. But since there's a lot of doxygen existing, that's not possible. So basically, when "inside a @param", I need to parse until the next @xx comes or the comment ends. But how to do that?

Can someone push me into the right direction please?

Thanks!
Re: Parsing doxygen with xtext [message #1805341 is a reply to message #1805331] Fri, 12 April 2019 05:56 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Perhaps this article may help: https://stackoverflow.com/questions/13992686/matching-a-text-in-line-by-line-file-with-xtext
terminal PROPERTY_VALUE: (':' | '=') !('\n' | '\r')*;

And you can have a look into the specification of the single line comment in org.eclipse.xtext.common.Terminals

HIH, Uli
Re: Parsing doxygen with xtext [message #1805533 is a reply to message #1805341] Tue, 16 April 2019 20:33 Go to previous message
Peter LustigFriend
Messages: 8
Registered: January 2019
Junior Member
Hi Uli,

thanks for the pointer. I read the article and played around a bit with the approach and I learned something new thanks.

I now get how I can capture the unquoted text in a variable. But I feel like I'm "loosing all xtext-features" in doing so.

1. As pointed out in the origianl post, I would like xtext to understand that the "a" after the @param is a reference to the first parameter of the function, so that it can be found by "go to definition", "find all references" and the rename refactoring. Just a string from the whole doxygen item is better than nothing of course. I feel what I originally wanted is not possible with this approach, please correct me if I'm wrong.

2. Another smaller detail is that in the referenced post, the language allows to identify "end of unquoted text" by detecting a newline. In doxygen, I need to detect "*/". That seems to cause problems in the parsing process as well.

Works OK, but is a bit wrong:

DOX: DOX_START
stmts+=DOXSTATEMENT+
DOX_END
;

terminal DOX_START: '/**';
terminal DOX_END: '/';

Does not work, but would be more right if it did:

DOX: DOX_START
stmts+=DOXSTATEMENT+
DOX_END
;

terminal DOX_START: '/**';
terminal DOX_END: '*/';

This does not come out of the DOXSTATEMENT rule when */ occurs. Instead, it just reads all the input until EOF (as can be seen in the screenshot).

I read somewhere that custom lexer can solve this problem, but it looked complicated to me so I decided the "/" vs "*/" problem is second priority to me.

  • Attachment: dox.png
    (Size: 20.28KB, Downloaded 66 times)
Previous Topic:References to UML elements
Next Topic:Multiple unittest files to be executed by Maven
Goto Forum:
  


Current Time: Tue Apr 23 12:04:50 GMT 2024

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

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

Back to the top