Skip to content

Commit

Permalink
Update file name in serialize_ast and make sure it's in .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben committed Jan 9, 2023
1 parent 489d208 commit c217531
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ utils/z.c
*.egg-info
*.swp
.DS_Store
ast.pickle
5 changes: 3 additions & 2 deletions examples/serialize_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
if __name__ == '__main__':
parser = c_parser.CParser()
ast = parser.parse(text)
dump_filename = 'ast.pickle'

with open('ast', 'wb') as f:
with open(dump_filename, 'wb') as f:
pickle.dump(ast, f, protocol=pickle.HIGHEST_PROTOCOL)

# Deserialize.
with open('ast', 'rb') as f:
with open(dump_filename, 'rb') as f:
ast = pickle.load(f)
ast.show()

0 comments on commit c217531

Please sign in to comment.