PageRenderTime 32ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/extern/llvm/utils/DSAclean.py

https://bitbucket.org/dwilliamson/clreflect/
Python | 32 lines | 18 code | 1 blank | 13 comment | 2 complexity | 30c9f326b89874e89d379406ae345f1f MD5 | raw file
Possible License(s): JSON, BSD-3-Clause
  1. #! /usr/bin/python
  2. #changelog:
  3. #10/13/2005b: replaced the # in tmp(.#*)* with alphanumeric and _, this will then remove
  4. #nodes such as %tmp.1.i and %tmp._i.3
  5. #10/13/2005: exntended to remove variables of the form %tmp(.#)* rather than just
  6. #%tmp.#, i.e. it now will remove %tmp.12.3.15 etc, additionally fixed a spelling error in
  7. #the comments
  8. #10/12/2005: now it only removes nodes and edges for which the label is %tmp.# rather
  9. #than removing all lines for which the lable CONTAINS %tmp.#
  10. import re
  11. import sys
  12. if( len(sys.argv) < 3 ):
  13. print 'usage is: ./DSAclean <dot_file_to_be_cleaned> <out_put_file>'
  14. sys.exit(1)
  15. #get a file object
  16. input = open(sys.argv[1], 'r')
  17. output = open(sys.argv[2], 'w')
  18. #we'll get this one line at a time...while we could just put the whole thing in a string
  19. #it would kill old computers
  20. buffer = input.readline()
  21. while buffer != '':
  22. if re.compile("label(\s*)=(\s*)\"\s%tmp(.\w*)*(\s*)\"").search(buffer):
  23. #skip next line, write neither this line nor the next
  24. buffer = input.readline()
  25. else:
  26. #this isn't a tmp Node, we can write it
  27. output.write(buffer)
  28. #prepare for the next iteration
  29. buffer = input.readline()
  30. input.close()
  31. output.close()