1from __future__ import print_function 2 3import sys 4from pycparser import c_parser, c_generator, c_ast, parse_file 5 6 7if __name__ == "__main__": 8 parser = c_parser.CParser() 9 code = r''' 10 void* ptr = (int[ ]){0}; 11 ''' 12 13 print(code) 14 ast = parser.parse(code) 15 ast.show(attrnames=True, nodenames=True) 16 print(ast.ext[0].__slots__) 17 print(dir(ast.ext[0])) 18 19 print("==== From C generator:") 20 generator = c_generator.CGenerator() 21 print(generator.visit(ast)) 22