home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 January / Chip_2003-01_cd2.bin / convert / eJayMp3Pro / mp3pro_demo.exe / TOKEN.PYC (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-06-05  |  3.8 KB  |  139 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. ENDMARKER = 0
  5. NAME = 1
  6. NUMBER = 2
  7. STRING = 3
  8. NEWLINE = 4
  9. INDENT = 5
  10. DEDENT = 6
  11. LPAR = 7
  12. RPAR = 8
  13. LSQB = 9
  14. RSQB = 10
  15. COLON = 11
  16. COMMA = 12
  17. SEMI = 13
  18. PLUS = 14
  19. MINUS = 15
  20. STAR = 16
  21. SLASH = 17
  22. VBAR = 18
  23. AMPER = 19
  24. LESS = 20
  25. GREATER = 21
  26. EQUAL = 22
  27. DOT = 23
  28. PERCENT = 24
  29. BACKQUOTE = 25
  30. LBRACE = 26
  31. RBRACE = 27
  32. EQEQUAL = 28
  33. NOTEQUAL = 29
  34. LESSEQUAL = 30
  35. GREATEREQUAL = 31
  36. TILDE = 32
  37. CIRCUMFLEX = 33
  38. LEFTSHIFT = 34
  39. RIGHTSHIFT = 35
  40. DOUBLESTAR = 36
  41. OP = 37
  42. ERRORTOKEN = 38
  43. N_TOKENS = 39
  44. NT_OFFSET = 256
  45. tok_name = { }
  46. for _name, _value in globals().items():
  47.     pass
  48.  
  49.  
  50. def ISTERMINAL(x):
  51.     return x < NT_OFFSET
  52.  
  53.  
  54. def ISNONTERMINAL(x):
  55.     return x >= NT_OFFSET
  56.  
  57.  
  58. def ISEOF(x):
  59.     return x == ENDMARKER
  60.  
  61.  
  62. def main():
  63.     import re
  64.     import string
  65.     import sys
  66.     args = sys.argv[1:]
  67.     if not args and args[0]:
  68.         pass
  69.     inFileName = 'Include/token.h'
  70.     outFileName = 'Lib/token.py'
  71.     if len(args) > 1:
  72.         outFileName = args[1]
  73.     
  74.     
  75.     try:
  76.         fp = open(inFileName)
  77.     except IOError:
  78.         err = None
  79.         sys.stdout.write('I/O error: %s\n' % str(err))
  80.         sys.exit(1)
  81.  
  82.     lines = string.splitfields(fp.read(), '\n')
  83.     fp.close()
  84.     prog = re.compile('#define[ \t][ \t]*([A-Z][A-Z_]*)[ \t][ \t]*([0-9][0-9]*)', re.IGNORECASE)
  85.     tokens = { }
  86.     for line in lines:
  87.         match = prog.match(line)
  88.     
  89.     keys = tokens.keys()
  90.     keys.sort()
  91.     
  92.     try:
  93.         fp = open(outFileName)
  94.     except IOError:
  95.         None if match else lines
  96.         err = None if match else lines
  97.         sys.stderr.write('I/O error: %s\n' % str(err))
  98.         sys.exit(2)
  99.     except:
  100.         None if match else lines
  101.  
  102.     format = string.splitfields(fp.read(), '\n')
  103.     fp.close()
  104.     
  105.     try:
  106.         start = format.index('#--start constants--') + 1
  107.         end = format.index('#--end constants--')
  108.     except ValueError:
  109.         None if match else lines
  110.         None if match else lines
  111.         sys.stderr.write('target does not contain format markers')
  112.         sys.exit(3)
  113.     except:
  114.         None if match else lines
  115.  
  116.     lines = []
  117.     for val in keys:
  118.         lines.append('%s = %d' % (tokens[val], val))
  119.     
  120.     format[start:end] = lines
  121.     
  122.     try:
  123.         fp = open(outFileName, 'w')
  124.     except IOError:
  125.         0
  126.         err = 0
  127.         keys
  128.         sys.stderr.write('I/O error: %s\n' % str(err))
  129.         sys.exit(4)
  130.     except:
  131.         None if match else lines
  132.  
  133.     fp.write(string.joinfields(format, '\n'))
  134.     fp.close()
  135.  
  136. if __name__ == '__main__':
  137.     main()
  138.  
  139.