[cfe-dev] accessing if-condition from if-statement node in libclang
Juan Jose Lopez Villarejo
jj.lopezvillarejo at cern.ch
Thu May 29 11:04:44 PDT 2014
Thank you, I’ll try this out.
Juan
Le 29 mai 2014 à 19:57, Jesse van den Kieboom <jesse.vandenkieboom at epfl.ch<mailto:jesse.vandenkieboom at epfl.ch>> a écrit :
Sorry, that example should have been ' '.join([t.spelling for t in cursor.get_tokens()])
I just tried this, and it seems that tokens can be off by one, I had to shave off the last one to get a correct representation.
2014-05-29 19:39 GMT+02:00 Jesse van den Kieboom <jesse.vandenkieboom at epfl.ch<mailto:jesse.vandenkieboom at epfl.ch>>:
Hi Juan,
The easiest way to get the actual text is to simply get the tokens belonging to the respective cursors (e.g. ''.join(cursor.get_tokens())). I think this should get you what you want.
2014-05-29 19:28 GMT+02:00 Juan Jose Lopez Villarejo <jj.lopezvillarejo at cern.ch<mailto:jj.lopezvillarejo at cern.ch>>:
Hello,
I’m using libclang for a visual documentation tool for C++ codes, Flowgen, under current development.
I'd like Flowgen to access automatically the condition of an if-statement. Example:
if ( varMax == 4 &&
varOther ==2 ) {
std::cout << "test";
} else if{
std::cout << "test1";
} else {
std::cout << "test2";
}
Imagine that I have accessed the if-statement node/Cursor with libclang
#clang node types (CursorKind)
#205: if statement
I'd like to have (direct) access to the string "varMax == 4 && varOther ==2".
I'd like to have (direct) access as well to the else-if node and the else node.
Anyone knows how? Thank you and best regards,
Juan J. Lopez-Villarejo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140529/49cc6779/attachment.html>
More information about the cfe-dev
mailing list