Debian Codegraph @

pycparser223/examples/dump_ast.py

raw symbols SCIP
1 #-----------------------------------------------------------------
2 # pycparser: dump_ast.py
3 #
4 # Basic example of parsing a file and dumping its parsed AST.
5 #
6 # Eli Bendersky [https://eli.thegreenplace.net/]
7 # License: BSD
8 #-----------------------------------------------------------------
9 import argparse
10 import sys
11
12 # This is not required if you've installed pycparser into
13 # your site-packages/ with setup.py
14 sys.path.extend(['.', '..'])
15
16 from pycparser import parse_file
17
18 if __name__ == "__main__":
19 argparser = argparse.ArgumentParser('Dump AST')
20 argparser.add_argument('filename',
21 default='examples/c_files/basic.c',
22 nargs='?',
23 help='name of file to parse')
24 argparser.add_argument('--coord', help='show coordinates in the dump',
25 action='store_true')
26 args = argparser.parse_args()
27
28 ast = parse_file(args.filename, use_cpp=False)
29 ast.show(showcoord=args.coord)