Skip to content

Commit

Permalink
Move code to __main__ block
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben committed Apr 15, 2020
1 parent 66fc243 commit ac2fef5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions examples/rewrite_ast.py
Expand Up @@ -18,14 +18,15 @@
}
"""

parser = c_parser.CParser()
ast = parser.parse(text)
print("Before:")
ast.show(offset=2)
if __name__ == '__main__':
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
assign = ast.ext[0].body.block_items[0]
assign.lvalue.name = "y"
assign.rvalue.value = 2

print("After:")
ast.show(offset=2)
print("After:")
ast.show(offset=2)

0 comments on commit ac2fef5

Please sign in to comment.