aosp12/external/python/pycparser/utils/internal/zz_parse.py

22 lines
487 B
Python
Raw Permalink Normal View History

2023-01-09 17:11:35 +08:00
from __future__ import print_function
import sys
from pycparser import c_parser, c_generator, c_ast, parse_file
if __name__ == "__main__":
parser = c_parser.CParser()
code = r'''
void* ptr = (int[ ]){0};
'''
print(code)
ast = parser.parse(code)
ast.show(attrnames=True, nodenames=True)
print(ast.ext[0].__slots__)
print(dir(ast.ext[0]))
print("==== From C generator:")
generator = c_generator.CGenerator()
print(generator.visit(ast))