QtContextKeywords.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #include "QtContextKeywords.h"
  2. using namespace CPlusPlus;
  3. static inline int classify4(const char *s) {
  4. if (s[0] == 'R') {
  5. if (s[1] == 'E') {
  6. if (s[2] == 'A') {
  7. if (s[3] == 'D') {
  8. return Token_READ;
  9. }
  10. }
  11. }
  12. }
  13. else if (s[0] == 'U') {
  14. if (s[1] == 'S') {
  15. if (s[2] == 'E') {
  16. if (s[3] == 'R') {
  17. return Token_USER;
  18. }
  19. }
  20. }
  21. }
  22. return Token_not_Qt_context_keyword;
  23. }
  24. static inline int classify5(const char *s) {
  25. if (s[0] == 'F') {
  26. if (s[1] == 'I') {
  27. if (s[2] == 'N') {
  28. if (s[3] == 'A') {
  29. if (s[4] == 'L') {
  30. return Token_FINAL;
  31. }
  32. }
  33. }
  34. }
  35. }
  36. else if (s[0] == 'R') {
  37. if (s[1] == 'E') {
  38. if (s[2] == 'S') {
  39. if (s[3] == 'E') {
  40. if (s[4] == 'T') {
  41. return Token_RESET;
  42. }
  43. }
  44. }
  45. }
  46. }
  47. else if (s[0] == 'W') {
  48. if (s[1] == 'R') {
  49. if (s[2] == 'I') {
  50. if (s[3] == 'T') {
  51. if (s[4] == 'E') {
  52. return Token_WRITE;
  53. }
  54. }
  55. }
  56. }
  57. }
  58. return Token_not_Qt_context_keyword;
  59. }
  60. static inline int classify6(const char *s) {
  61. if (s[0] == 'M') {
  62. if (s[1] == 'E') {
  63. if (s[2] == 'M') {
  64. if (s[3] == 'B') {
  65. if (s[4] == 'E') {
  66. if (s[5] == 'R') {
  67. return Token_MEMBER;
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. else if (s[0] == 'N') {
  75. if (s[1] == 'O') {
  76. if (s[2] == 'T') {
  77. if (s[3] == 'I') {
  78. if (s[4] == 'F') {
  79. if (s[5] == 'Y') {
  80. return Token_NOTIFY;
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. else if (s[0] == 'S') {
  88. if (s[1] == 'T') {
  89. if (s[2] == 'O') {
  90. if (s[3] == 'R') {
  91. if (s[4] == 'E') {
  92. if (s[5] == 'D') {
  93. return Token_STORED;
  94. }
  95. }
  96. }
  97. }
  98. }
  99. }
  100. return Token_not_Qt_context_keyword;
  101. }
  102. static inline int classify8(const char *s) {
  103. if (s[0] == 'C') {
  104. if (s[1] == 'O') {
  105. if (s[2] == 'N') {
  106. if (s[3] == 'S') {
  107. if (s[4] == 'T') {
  108. if (s[5] == 'A') {
  109. if (s[6] == 'N') {
  110. if (s[7] == 'T') {
  111. return Token_CONSTANT;
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. if (s[0] == 'R') {
  121. if (s[1] == 'E') {
  122. if (s[2] == 'V') {
  123. if (s[3] == 'I') {
  124. if (s[4] == 'S') {
  125. if (s[5] == 'I') {
  126. if (s[6] == 'O') {
  127. if (s[7] == 'N') {
  128. return Token_REVISION;
  129. }
  130. }
  131. }
  132. }
  133. }
  134. }
  135. }
  136. }
  137. return Token_not_Qt_context_keyword;
  138. }
  139. static inline int classify10(const char *s) {
  140. if (s[0] == 'D') {
  141. if (s[1] == 'E') {
  142. if (s[2] == 'S') {
  143. if (s[3] == 'I') {
  144. if (s[4] == 'G') {
  145. if (s[5] == 'N') {
  146. if (s[6] == 'A') {
  147. if (s[7] == 'B') {
  148. if (s[8] == 'L') {
  149. if (s[9] == 'E') {
  150. return Token_DESIGNABLE;
  151. }
  152. }
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160. }
  161. else if (s[0] == 'S') {
  162. if (s[1] == 'C') {
  163. if (s[2] == 'R') {
  164. if (s[3] == 'I') {
  165. if (s[4] == 'P') {
  166. if (s[5] == 'T') {
  167. if (s[6] == 'A') {
  168. if (s[7] == 'B') {
  169. if (s[8] == 'L') {
  170. if (s[9] == 'E') {
  171. return Token_SCRIPTABLE;
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }
  182. return Token_not_Qt_context_keyword;
  183. }
  184. int CPlusPlus::classifyQtContextKeyword(const char *s, int n) {
  185. switch (n) {
  186. case 4: return classify4(s);
  187. case 5: return classify5(s);
  188. case 6: return classify6(s);
  189. case 8: return classify8(s);
  190. case 10: return classify10(s);
  191. default: return Token_not_Qt_context_keyword;
  192. } // switch
  193. }