pycparserext icon indicating copy to clipboard operation
pycparserext copied to clipboard

Cannot traverse nodes using NodeVisitor, FuncDeclExt is not iterable

Open julianneswinoga opened this issue 6 years ago • 4 comments

Using GnuCParser() and subclassing c_ast.NodeVisitor, I cannot traverse the nodes as in the FuncDefs example in https://github.com/eliben/pycparser/blob/master/examples/func_defs.py

It results in the following error:

Traceback (most recent call last):
  [...]
  File "main_script.py", line 77, in verify
    FuncDefVisitor().visit(self.ast)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 158, in visit
    return visitor(node)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 165, in generic_visit
    self.visit(c)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 158, in visit
    return visitor(node)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 165, in generic_visit
    self.visit(c)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 158, in visit
    return visitor(node)
  File "/path/venv/lib/python3.6/site-packages/pycparser/c_ast.py", line 164, in generic_visit
    for c in node:
TypeError: 'FuncDeclExt' object is not iterable

julianneswinoga avatar Aug 28 '19 15:08 julianneswinoga

I'd be happy to review a PR fixing that.

inducer avatar Aug 28 '19 15:08 inducer

I can try and implement a fix, but it's still not super clear to me how these functions interact with the code path.

julianneswinoga avatar Aug 28 '19 15:08 julianneswinoga

@inducer Can you actually reopen this issue? I think #46 needs to be done for all of the classes in ext_c_parser.py that subclass c_ast.Node

julianneswinoga avatar Aug 28 '19 17:08 julianneswinoga

Sure, thanks.

inducer avatar Aug 28 '19 17:08 inducer