Hi Cédric,<br><br>High bit: yes, I think this is a good idea.<br><br>While I'm not exactly sure the form the callback should take, this should not conflict with anything else in the system and if you want to experiment with using it to build new tools that would be very cool. <br>
<br>I agree that some sort of callback mechanism is the right approach, this is in line with the current clang design. It probably makes sense for this to be both a preprocessor callback and a parser (Action) callback. This would allow the parser to potentially add additional information about the current parsing state to the callback, or defer the comment Action callback in some cases (for example, until the end of statement).<br>
<br>Are you planning on writing this concurrently with a consumer of the callback?<br><br>Also, I think it might be reasonable to use this to replace the current -verify mechanism. I believe this would make it more robust and also somewhat easier to use. Thoughts?<br>
<br> - Daniel<br><br><div class="gmail_quote">On Thu, Oct 23, 2008 at 9:56 AM, Cédric Venet <span dir="ltr"><<a href="mailto:cedric.venet@laposte.net">cedric.venet@laposte.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
Adding information in comment is useful for documentation purpose or for<br>
 adding information/metadata for others tools like formal proof or DSL<br>
code generator...<br>
<br>
Actually, there isn't (AFAIK) a facility to extract the comment and the<br>
AST at the same time.<br>
<br>
Since managing comment token in the parser is to complex (they can<br>
appear everywhere) I propose that the lexer or the preprocessor use<br>
callback to inform the client that he encoutered a comment.<br>
<br>
For example, for doxygen like tools, the callback would check if the<br>
comment is a documentation one, and if so, store it for later use. Once<br>
the AST complete, it would walk the def and associate the corresponding<br>
comment (or the other way around).<br>
<br>
Does this seems good, any other idea? alternatively, the lexer/PP could<br>
create a list of comment token.<br>
<br>
The callback could be added to clang::PPCallbacks. It is the best place<br>
, isn't it?<br>
<br>
This modification would have zero cost for classical use since lexer<br>
already has a condition keep comment. It would only had a conditionnal<br>
in the PP when a comment token is consumed.<br>
<br>
If this is ok, I will prepare a patch.<br>
<br>
regards,<br>
<br>
Cédric<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br>