blob: 2cff874c7d79c48349c4bbe985fe53ab5b2aeb87 [file] [log] [blame]
Eli Benderskyaac7b052017-04-07 05:12:51 -07001#-----------------------------------------------------------------
2# pycparser: dump_ast.py
3#
4# Basic example of parsing a file and dumping its parsed AST.
5#
Jon Dufresne1d866992018-06-26 13:49:35 -07006# Eli Bendersky [https://eli.thegreenplace.net/]
Eli Benderskyaac7b052017-04-07 05:12:51 -07007# License: BSD
8#-----------------------------------------------------------------
9from __future__ import print_function
10import argparse
11import sys
12
13# This is not required if you've installed pycparser into
14# your site-packages/ with setup.py
15sys.path.extend(['.', '..'])
16
17from pycparser import c_parser, c_ast, parse_file
18
19if __name__ == "__main__":
20 argparser = argparse.ArgumentParser('Dump AST')
21 argparser.add_argument('filename', help='name of file to parse')
22 args = argparser.parse_args()
23
24 ast = parse_file(args.filename, use_cpp=False)
25 ast.show()