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>