diff options
author | Eli Bendersky <eliben@gmail.com> | 2018-10-23 14:05:56 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2018-10-23 14:05:56 -0700 |
commit | 2a29d56c280e64b308cd079b507ebee3e108fddc (patch) | |
tree | 5d305fef57673ebf8fe7ef7b848a7e1c9d51c117 /examples | |
parent | 0411963d552207991294347dc75d606b60685334 (diff) | |
download | pycparser-2a29d56c280e64b308cd079b507ebee3e108fddc.tar.gz |
Fix example to properly visit nested function calls
Reported in #285
Diffstat (limited to 'examples')
-rw-r--r-- | examples/func_calls.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/func_calls.py b/examples/func_calls.py index ec31fe5..84e8c27 100644 --- a/examples/func_calls.py +++ b/examples/func_calls.py @@ -17,9 +17,7 @@ sys.path.extend(['.', '..']) from pycparser import c_parser, c_ast, parse_file -# A visitor with some state information (the funcname it's -# looking for) -# +# A visitor with some state information (the funcname it's looking for) class FuncCallVisitor(c_ast.NodeVisitor): def __init__(self, funcname): self.funcname = funcname @@ -27,6 +25,8 @@ class FuncCallVisitor(c_ast.NodeVisitor): def visit_FuncCall(self, node): if node.name.name == self.funcname: print('%s called at %s' % (self.funcname, node.name.coord)) + # Visit args in case they contain more func calls. + self.visit(node.args) def show_func_calls(filename, funcname): |