eliben / pycparser

:snake: Complete C99 parser in pure Python
Other
3.21k stars 612 forks source link

Is there a way to find the function declaration matching a function call? #525

Closed HendrikHuebner closed 7 months ago

HendrikHuebner commented 7 months ago

Of course, a function call node contains the name of the function being called. But this function might be overloaded, so if there are multiple declarations by that name, you can't just search the tree for a declaration with the same name. Is there an easy way of getting the declaration for a function call or will I have to implement some kind of algorithm that finds the types of the arguments of the function call?

eliben commented 7 months ago

This would require constructing a symbol table, a kind of semantic analysis built on top of ASTs. pycparser doesn't provide this, as it concludes its job at constructing an AST. You can build semantic analysis on top of this, but it's out of scope for the core pycparser library.

(P.S. for reference, this was discussed before a couple of times (e.g. #342, #318))