token.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /* Auto-generated by Tools/build/generate_token.py */
  2. #include "Python.h"
  3. #include "pycore_token.h"
  4. /* Token names */
  5. const char * const _PyParser_TokenNames[] = {
  6. "ENDMARKER",
  7. "NAME",
  8. "NUMBER",
  9. "STRING",
  10. "NEWLINE",
  11. "INDENT",
  12. "DEDENT",
  13. "LPAR",
  14. "RPAR",
  15. "LSQB",
  16. "RSQB",
  17. "COLON",
  18. "COMMA",
  19. "SEMI",
  20. "PLUS",
  21. "MINUS",
  22. "STAR",
  23. "SLASH",
  24. "VBAR",
  25. "AMPER",
  26. "LESS",
  27. "GREATER",
  28. "EQUAL",
  29. "DOT",
  30. "PERCENT",
  31. "LBRACE",
  32. "RBRACE",
  33. "EQEQUAL",
  34. "NOTEQUAL",
  35. "LESSEQUAL",
  36. "GREATEREQUAL",
  37. "TILDE",
  38. "CIRCUMFLEX",
  39. "LEFTSHIFT",
  40. "RIGHTSHIFT",
  41. "DOUBLESTAR",
  42. "PLUSEQUAL",
  43. "MINEQUAL",
  44. "STAREQUAL",
  45. "SLASHEQUAL",
  46. "PERCENTEQUAL",
  47. "AMPEREQUAL",
  48. "VBAREQUAL",
  49. "CIRCUMFLEXEQUAL",
  50. "LEFTSHIFTEQUAL",
  51. "RIGHTSHIFTEQUAL",
  52. "DOUBLESTAREQUAL",
  53. "DOUBLESLASH",
  54. "DOUBLESLASHEQUAL",
  55. "AT",
  56. "ATEQUAL",
  57. "RARROW",
  58. "ELLIPSIS",
  59. "COLONEQUAL",
  60. "EXCLAMATION",
  61. "OP",
  62. "AWAIT",
  63. "ASYNC",
  64. "TYPE_IGNORE",
  65. "TYPE_COMMENT",
  66. "SOFT_KEYWORD",
  67. "FSTRING_START",
  68. "FSTRING_MIDDLE",
  69. "FSTRING_END",
  70. "COMMENT",
  71. "NL",
  72. "<ERRORTOKEN>",
  73. "<ENCODING>",
  74. "<N_TOKENS>",
  75. };
  76. /* Return the token corresponding to a single character */
  77. int
  78. _PyToken_OneChar(int c1)
  79. {
  80. switch (c1) {
  81. case '!': return EXCLAMATION;
  82. case '%': return PERCENT;
  83. case '&': return AMPER;
  84. case '(': return LPAR;
  85. case ')': return RPAR;
  86. case '*': return STAR;
  87. case '+': return PLUS;
  88. case ',': return COMMA;
  89. case '-': return MINUS;
  90. case '.': return DOT;
  91. case '/': return SLASH;
  92. case ':': return COLON;
  93. case ';': return SEMI;
  94. case '<': return LESS;
  95. case '=': return EQUAL;
  96. case '>': return GREATER;
  97. case '@': return AT;
  98. case '[': return LSQB;
  99. case ']': return RSQB;
  100. case '^': return CIRCUMFLEX;
  101. case '{': return LBRACE;
  102. case '|': return VBAR;
  103. case '}': return RBRACE;
  104. case '~': return TILDE;
  105. }
  106. return OP;
  107. }
  108. int
  109. _PyToken_TwoChars(int c1, int c2)
  110. {
  111. switch (c1) {
  112. case '!':
  113. switch (c2) {
  114. case '=': return NOTEQUAL;
  115. }
  116. break;
  117. case '%':
  118. switch (c2) {
  119. case '=': return PERCENTEQUAL;
  120. }
  121. break;
  122. case '&':
  123. switch (c2) {
  124. case '=': return AMPEREQUAL;
  125. }
  126. break;
  127. case '*':
  128. switch (c2) {
  129. case '*': return DOUBLESTAR;
  130. case '=': return STAREQUAL;
  131. }
  132. break;
  133. case '+':
  134. switch (c2) {
  135. case '=': return PLUSEQUAL;
  136. }
  137. break;
  138. case '-':
  139. switch (c2) {
  140. case '=': return MINEQUAL;
  141. case '>': return RARROW;
  142. }
  143. break;
  144. case '/':
  145. switch (c2) {
  146. case '/': return DOUBLESLASH;
  147. case '=': return SLASHEQUAL;
  148. }
  149. break;
  150. case ':':
  151. switch (c2) {
  152. case '=': return COLONEQUAL;
  153. }
  154. break;
  155. case '<':
  156. switch (c2) {
  157. case '<': return LEFTSHIFT;
  158. case '=': return LESSEQUAL;
  159. case '>': return NOTEQUAL;
  160. }
  161. break;
  162. case '=':
  163. switch (c2) {
  164. case '=': return EQEQUAL;
  165. }
  166. break;
  167. case '>':
  168. switch (c2) {
  169. case '=': return GREATEREQUAL;
  170. case '>': return RIGHTSHIFT;
  171. }
  172. break;
  173. case '@':
  174. switch (c2) {
  175. case '=': return ATEQUAL;
  176. }
  177. break;
  178. case '^':
  179. switch (c2) {
  180. case '=': return CIRCUMFLEXEQUAL;
  181. }
  182. break;
  183. case '|':
  184. switch (c2) {
  185. case '=': return VBAREQUAL;
  186. }
  187. break;
  188. }
  189. return OP;
  190. }
  191. int
  192. _PyToken_ThreeChars(int c1, int c2, int c3)
  193. {
  194. switch (c1) {
  195. case '*':
  196. switch (c2) {
  197. case '*':
  198. switch (c3) {
  199. case '=': return DOUBLESTAREQUAL;
  200. }
  201. break;
  202. }
  203. break;
  204. case '.':
  205. switch (c2) {
  206. case '.':
  207. switch (c3) {
  208. case '.': return ELLIPSIS;
  209. }
  210. break;
  211. }
  212. break;
  213. case '/':
  214. switch (c2) {
  215. case '/':
  216. switch (c3) {
  217. case '=': return DOUBLESLASHEQUAL;
  218. }
  219. break;
  220. }
  221. break;
  222. case '<':
  223. switch (c2) {
  224. case '<':
  225. switch (c3) {
  226. case '=': return LEFTSHIFTEQUAL;
  227. }
  228. break;
  229. }
  230. break;
  231. case '>':
  232. switch (c2) {
  233. case '>':
  234. switch (c3) {
  235. case '=': return RIGHTSHIFTEQUAL;
  236. }
  237. break;
  238. }
  239. break;
  240. }
  241. return OP;
  242. }