token.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #! /usr/bin/env python3
  2. """Token constants (from "token.h")."""
  3. # Taken from Python (r53757) and modified to include some tokens
  4. # originally monkeypatched in by pgen2.tokenize
  5. #--start constants--
  6. ENDMARKER = 0
  7. NAME = 1
  8. NUMBER = 2
  9. STRING = 3
  10. NEWLINE = 4
  11. INDENT = 5
  12. DEDENT = 6
  13. LPAR = 7
  14. RPAR = 8
  15. LSQB = 9
  16. RSQB = 10
  17. COLON = 11
  18. COMMA = 12
  19. SEMI = 13
  20. PLUS = 14
  21. MINUS = 15
  22. STAR = 16
  23. SLASH = 17
  24. VBAR = 18
  25. AMPER = 19
  26. LESS = 20
  27. GREATER = 21
  28. EQUAL = 22
  29. DOT = 23
  30. PERCENT = 24
  31. BACKQUOTE = 25
  32. LBRACE = 26
  33. RBRACE = 27
  34. EQEQUAL = 28
  35. NOTEQUAL = 29
  36. LESSEQUAL = 30
  37. GREATEREQUAL = 31
  38. TILDE = 32
  39. CIRCUMFLEX = 33
  40. LEFTSHIFT = 34
  41. RIGHTSHIFT = 35
  42. DOUBLESTAR = 36
  43. PLUSEQUAL = 37
  44. MINEQUAL = 38
  45. STAREQUAL = 39
  46. SLASHEQUAL = 40
  47. PERCENTEQUAL = 41
  48. AMPEREQUAL = 42
  49. VBAREQUAL = 43
  50. CIRCUMFLEXEQUAL = 44
  51. LEFTSHIFTEQUAL = 45
  52. RIGHTSHIFTEQUAL = 46
  53. DOUBLESTAREQUAL = 47
  54. DOUBLESLASH = 48
  55. DOUBLESLASHEQUAL = 49
  56. AT = 50
  57. ATEQUAL = 51
  58. OP = 52
  59. COMMENT = 53
  60. NL = 54
  61. RARROW = 55
  62. AWAIT = 56
  63. ASYNC = 57
  64. ERRORTOKEN = 58
  65. COLONEQUAL = 59
  66. N_TOKENS = 60
  67. NT_OFFSET = 256
  68. #--end constants--
  69. tok_name = {}
  70. for _name, _value in list(globals().items()):
  71. if isinstance(_value, int):
  72. tok_name[_value] = _name
  73. def ISTERMINAL(x):
  74. return x < NT_OFFSET
  75. def ISNONTERMINAL(x):
  76. return x >= NT_OFFSET
  77. def ISEOF(x):
  78. return x == ENDMARKER