#----------------------------------------------------------------- # pycparser: func_write.py # # Tiny example of rewriting a AST node # # Copyright (C) 2014, Akira Hayakawa # License: BSD #----------------------------------------------------------------- from __future__ import print_function import sys from pycparser import c_parser text = r""" void func(void) { x = 1; } """ parser = c_parser.CParser() ast = parser.parse(text) print("Before:") ast.show(offset=2) assign = ast.ext[0].body.block_items[0] assign.lvalue.name = "y" assign.rvalue.value = 2 print("After:") ast.show(offset=2)
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
c_files | Folder | 0755 |
|
|
c-to-c.py | File | 1.42 KB | 0644 |
|
cdecl.py | File | 3.05 KB | 0644 |
|
explore_ast.py | File | 5.27 KB | 0644 |
|
func_calls.py | File | 1.08 KB | 0644 |
|
func_defs.py | File | 1.08 KB | 0644 |
|
rewrite_ast.py | File | 599 B | 0644 |
|
using_cpp_libc.py | File | 744 B | 0644 |
|
using_gcc_E_libc.py | File | 797 B | 0644 |
|