blob: 3b6aae4676ff3b2f761d284e65800f153bb3f672 [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#
6# Eli Bendersky [http://eli.thegreenplace.net]
7# 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()