diff options
author | Eli Bendersky <eliben@gmail.com> | 2014-04-23 16:56:48 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2014-04-23 16:56:48 -0700 |
commit | 80d4838daee237cc25d59e017f5b59be060ccdc9 (patch) | |
tree | 6727231d782fdf2813cec3eca17a0ba6afa36c79 /examples | |
parent | 64782f58fb0416408d15ef35aa7bd6cc87075a03 (diff) | |
download | pycparser-80d4838daee237cc25d59e017f5b59be060ccdc9.tar.gz |
Add an example: using gcc -E instead of cpp for preprocessing.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/using_gcc_E_libc.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/using_gcc_E_libc.py b/examples/using_gcc_E_libc.py new file mode 100644 index 0000000..e8ea745 --- /dev/null +++ b/examples/using_gcc_E_libc.py @@ -0,0 +1,30 @@ +#------------------------------------------------------------------------------- +# pycparser: using_gcc_E_libc.py +# +# Similar to the using_cpp_libc.py example, but uses 'gcc -E' instead +# of 'cpp'. +# +# Copyright (C) 2008-2014, Eli Bendersky +# License: BSD +#------------------------------------------------------------------------------- +import sys + +# This is not required if you've installed pycparser into +# your site-packages/ with setup.py +# +sys.path.extend(['.', '..']) + +from pycparser import parse_file + + +if __name__ == "__main__": + if len(sys.argv) > 1: + filename = sys.argv[1] + else: + filename = 'c_files/year.c' + + ast = parse_file(filename, use_cpp=True, + cpp_path='gcc', + cpp_args=['-E', r'-I../utils/fake_libc_include']) + + ast.show() |