*cough* Alternatively, is there a different list for questions like this?<br><br><div class="gmail_quote">On Thu, Oct 27, 2011 at 11:59 AM, Doug <span dir="ltr"><<a href="mailto:douglas.linder@gmail.com">douglas.linder@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi there,<div><br></div><div>I'm writing a very simple c parser (dumps formatted symbols, something similar to ctags but actually working) using clang-c, which is working well, but I'm hoping to add some support for source comments in the code.</div>
<div><br></div><div>At the moment I'm using the clang-c subset for this, but there doesn't seem to be any api for accessing comments; specifically CXCursorKind doesn't seem to have a type for 'comment', and I've ended up doing something similar to:</div>
<div><br></div><div>for each cursor</div><div> get cursor info</div><div> save info (specifically, offset, filename, display name)</div><div><br></div><div>for each saved symbol:</div><div> find the closest previous symbol</div>
<div> walk backwards through the file from position of symbol -> position of previous symbol looking for closest comment</div><div><br></div><div>This is quite annoying to do, and has a few problems (example: symbols with no filename, unsaved files, large projects means loading every symbol into memory).</div>
<div><br></div><div>Is there a to get comments as elements through to the visitor function?</div><div><br></div><div>If no in clang-c, then perhaps in the full clang api?</div><div><br></div><div>Finally, as a slightly better alternative, is there a way to query a cursor to get the previous lexical cursor? At the very least this would save me having to save the entire set of data in memory first..</div>
<div><br></div><div>Help much appreciated!</div><div><br></div><div>cheers,</div><div>Doug.</div>
</blockquote></div><br>