I'm using clang in python to parse c++ code file, here's my code:
def traverse(node, depth):
print("%s%s %s" % ("| " * depth, str(node.kind), node.spelling))
for n in node.get_children():
traverse(n, depth + 1)
if __name__ == '__main__':
index = clang.cindex.Index.create()
parser = index.parse("M3UParser.cpp")
cursor = parser.cursor
traverse(cursor, 0)
it works well in the following c++ code:
static ssize_t FindNextUnquoted(
const AString &line, char what, size_t offset){...}
But it can't parse the following code:
status_t M3UParser::parseStreamInf(
const AString &line, sp<AMessage> *meta){...}
It appears to just skip this kind of code. How can I fix it?