D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
usr
/
share
/
doc
/
python3-pycparser
/
examples
/
Filename :
func_defs.py
back
Copy
#----------------------------------------------------------------- # pycparser: func_defs.py # # Using pycparser for printing out all the functions defined in a # C file. # # This is a simple example of traversing the AST generated by # pycparser. # # Copyright (C) 2008-2015, Eli Bendersky # License: BSD #----------------------------------------------------------------- from __future__ import print_function import sys from pycparser import c_parser, c_ast, parse_file # A simple visitor for FuncDef nodes that prints the names and # locations of function definitions. class FuncDefVisitor(c_ast.NodeVisitor): def visit_FuncDef(self, node): print('%s at %s' % (node.decl.name, node.decl.coord)) def show_func_defs(filename): # Note that cpp is used. Provide a path to your own cpp or # make sure one exists in PATH. ast = parse_file(filename, use_cpp=True) v = FuncDefVisitor() v.visit(ast) if __name__ == "__main__": if len(sys.argv) > 1: filename = sys.argv[1] else: filename = 'examples/c_files/memmgr.c' show_func_defs(filename)
Name
Size
Last Modified
Owner
Permissions
Actions
c_files
Dir
July 28 2023 2:56:41
root
0755
c-to-c.py
1.419
KB
November 13 2019 2:57:05
root
0644
cdecl.py
3.048
KB
November 13 2019 2:57:05
root
0644
explore_ast.py
5.27
KB
November 13 2019 2:57:05
root
0644
func_calls.py
1.084
KB
November 13 2019 2:57:05
root
0644
func_defs.py
1.081
KB
November 13 2019 2:57:05
root
0644
rewrite_ast.py
0.585
KB
June 10 2015 3:00:55
root
0644
using_cpp_libc.py
0.727
KB
November 13 2019 2:57:05
root
0644
using_gcc_E_libc.py
0.778
KB
November 13 2019 2:57:05
root
0644
2017 © D7net | D704T team