cpp_tokens.txt 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. # character sets
  2. [identifier_schars a-zA-Z_
  3. [identifier_chars a-zA-Z0-9_
  4. [num_chars_start 0-9
  5. [num_chars 0-9
  6. [octal_chars 0-7
  7. [hex_chars 0-9a-fA-F
  8. [float_chars_start 0-9.\-\+
  9. [float_chars 0-9.eE
  10. [float_chars_start 0-9.\-\+
  11. [ws \ \t\r\n
  12. [endl \r\n
  13. # single-character transitions can't be inverted yet, but csets can
  14. [slash \\
  15. [star *
  16. # keywords
  17. # : is extra user data to be carried through
  18. # | is a failover on a character set on discontinuity in the word
  19. {alignas :keyword |identifier_chars>LST_identifier
  20. {alignof :keyword |identifier_chars>LST_identifier
  21. {break :keyword |identifier_chars>LST_identifier
  22. {case :keyword |identifier_chars>LST_identifier
  23. {catch :keyword |identifier_chars>LST_identifier
  24. {class :keyword |identifier_chars>LST_identifier
  25. {compl :keyword |identifier_chars>LST_identifier
  26. {continue :keyword |identifier_chars>LST_identifier
  27. {const :keyword |identifier_chars>LST_identifier
  28. {constexpr :keyword |identifier_chars>LST_identifier
  29. {const_cast :keyword |identifier_chars>LST_identifier
  30. {co_await :keyword |identifier_chars>LST_identifier
  31. {co_return :keyword |identifier_chars>LST_identifier
  32. {co_yield :keyword |identifier_chars>LST_identifier
  33. {default :keyword |identifier_chars>LST_identifier
  34. {delete :keyword |identifier_chars>LST_identifier
  35. {do :keyword |identifier_chars>LST_identifier
  36. {dynamic_cast :keyword |identifier_chars>LST_identifier
  37. {else :keyword |identifier_chars>LST_identifier
  38. {enum :keyword |identifier_chars>LST_identifier
  39. {explicit :keyword |identifier_chars>LST_identifier
  40. {export :keyword |identifier_chars>LST_identifier
  41. {extern :keyword |identifier_chars>LST_identifier
  42. {false :keyword |identifier_chars>LST_identifier
  43. {for :keyword |identifier_chars>LST_identifier
  44. {friend :keyword |identifier_chars>LST_identifier
  45. {goto :keyword |identifier_chars>LST_identifier
  46. {if :keyword |identifier_chars>LST_identifier
  47. {inline :keyword |identifier_chars>LST_identifier
  48. {namespace :keyword |identifier_chars>LST_identifier
  49. {new :keyword |identifier_chars>LST_identifier
  50. {noexcept :keyword |identifier_chars>LST_identifier
  51. {nullptr :keyword |identifier_chars>LST_identifier
  52. {operator :keyword |identifier_chars>LST_identifier
  53. {private :keyword |identifier_chars>LST_identifier
  54. {protected :keyword |identifier_chars>LST_identifier
  55. {public :keyword |identifier_chars>LST_identifier
  56. {return :keyword |identifier_chars>LST_identifier
  57. {reinterpret_cast :keyword |identifier_chars>LST_identifier
  58. {sizeof :keyword |identifier_chars>LST_identifier
  59. {static :keyword |identifier_chars>LST_identifier
  60. {static_cast :keyword |identifier_chars>LST_identifier
  61. {struct :keyword |identifier_chars>LST_identifier
  62. {switch :keyword |identifier_chars>LST_identifier
  63. {this :keyword |identifier_chars>LST_identifier
  64. {throw :keyword |identifier_chars>LST_identifier
  65. {true :keyword |identifier_chars>LST_identifier
  66. {try :keyword |identifier_chars>LST_identifier
  67. {typedef :keyword |identifier_chars>LST_identifier
  68. {typeid :keyword |identifier_chars>LST_identifier
  69. {typename :keyword |identifier_chars>LST_identifier
  70. {union :keyword |identifier_chars>LST_identifier
  71. {using :keyword |identifier_chars>LST_identifier
  72. {virtual :keyword |identifier_chars>LST_identifier
  73. {while :keyword |identifier_chars>LST_identifier
  74. # operators and punctuation
  75. {+ :operator
  76. {& :operator
  77. {+= :operator
  78. {&= :operator
  79. {&& :operator
  80. {== :operator
  81. {!= :operator
  82. {( :punct
  83. {) :punct
  84. {- :operator
  85. {| :operator
  86. {-= :operator
  87. {|= :operator
  88. {|| :operator
  89. {< :operator
  90. {<= :operator
  91. {[ :punct
  92. {] :punct
  93. {* :operator
  94. {^ :operator
  95. {*= :operator
  96. {^= :operator
  97. {<- :operator
  98. {> :operator
  99. {>= :operator
  100. {{ :punct
  101. {} :punct
  102. {/ :operator
  103. :LST_NULL___slash @/>LST_sl_comment
  104. :LST_NULL___slash @*>LST_ml_comment
  105. {<< :operator
  106. {/= :operator
  107. {<<= :operator
  108. {++ :operator
  109. {= :operator
  110. {, :operator
  111. {; :punct
  112. {% :operator
  113. {>> :operator
  114. {%= :operator
  115. {>>= :operator
  116. {-- :operator
  117. {! :operator
  118. {? :operator
  119. {... :operator
  120. {. :operator +num_chars>LST_float
  121. {: :operator
  122. {:: :operator
  123. # types
  124. {register :storespec |identifier_chars>LST_identifier
  125. {thread_local :storespec|identifier_chars>LST_identifier
  126. {volatile :storespec |identifier_chars>LST_identifier
  127. {const :typespec |identifier_chars>LST_identifier
  128. {mutable :typespec |identifier_chars>LST_identifier
  129. {signed :typespec |identifier_chars>LST_identifier
  130. {unsigned :typespec |identifier_chars>LST_identifier
  131. {auto :type |identifier_chars>LST_identifier
  132. {bool :type |identifier_chars>LST_identifier
  133. {uint8_t :type |identifier_chars>LST_identifier
  134. {uint16_t :type |identifier_chars>LST_identifier
  135. {uint32_t :type |identifier_chars>LST_identifier
  136. {uint64_t :type |identifier_chars>LST_identifier
  137. {int8_t :type |identifier_chars>LST_identifier
  138. {int16_t :type |identifier_chars>LST_identifier
  139. {int32_t :type |identifier_chars>LST_identifier
  140. {int64_t :type |identifier_chars>LST_identifier
  141. {char16_t :type |identifier_chars>LST_identifier
  142. {char32_t :type |identifier_chars>LST_identifier
  143. {float :type |identifier_chars>LST_identifier
  144. {double :type |identifier_chars>LST_identifier
  145. {char :type |identifier_chars>LST_identifier
  146. {short :type |identifier_chars>LST_identifier
  147. {int :type |identifier_chars>LST_identifier
  148. {long :type |identifier_chars>LST_identifier
  149. # no support for spaces yet {"long double" :type |identifier_chars>LST_identifier
  150. # no support for spaces yet {"long long" :type |identifier_chars>LST_identifier
  151. {intptr_t :type |identifier_chars>LST_identifier
  152. {ptrdiff_t :type |identifier_chars>LST_identifier
  153. {size_t :type |identifier_chars>LST_identifier
  154. {void :type |identifier_chars>LST_identifier
  155. {wchar_t :type |identifier_chars>LST_identifier
  156. {__int64 :type |identifier_chars>LST_identifier
  157. {__m64 :type |identifier_chars>LST_identifier
  158. {__m128 :type |identifier_chars>LST_identifier
  159. {__m128i :type |identifier_chars>LST_identifier
  160. {__m128d :type |identifier_chars>LST_identifier
  161. {__m256 :type |identifier_chars>LST_identifier
  162. {__m256i :type |identifier_chars>LST_identifier
  163. {__m256d :type |identifier_chars>LST_identifier
  164. {__m512 :type |identifier_chars>LST_identifier
  165. {__m512i :type |identifier_chars>LST_identifier
  166. {__m512d :type |identifier_chars>LST_identifier
  167. {__mmask8 :type |identifier_chars>LST_identifier
  168. {__mmask16 :type |identifier_chars>LST_identifier
  169. {__mmask32 :type |identifier_chars>LST_identifier
  170. {__mmask64 :type |identifier_chars>LST_identifier
  171. # mark some terminal states
  172. &LST_float
  173. &LST_probenum
  174. &LST_intnum
  175. &LST_octalnum
  176. &LST_hexnum
  177. &LST_identifier
  178. &LST_float_exp
  179. # all other identifiers
  180. # + is transition on a character set
  181. :LST_identifier +identifier_chars>LST_identifier
  182. :LST_NULL +identifier_schars>LST_identifier
  183. # ignore whitespace
  184. # ^ discards the char while moving to the next state
  185. :LST_NULL +ws^LST_NULL
  186. # strings
  187. # @ is a single-char transition
  188. :LST_string @"=LST_string
  189. :LST_NULL @">LST_string
  190. &LST_string_end
  191. :LST_string @\\>LST_string_esc
  192. :LST_string !+slash>LST_string
  193. :LST_string_esc @">LST_string
  194. # char literals
  195. :LST_charlit @'=LST_charlit
  196. :LST_NULL @'>LST_charlit
  197. &LST_charlit_end
  198. :LST_charlit @\\>LST_charlit_esc
  199. :LST_charlit !+slash>LST_charlit
  200. :LST_charlit_esc @'>LST_charlit
  201. # numbers
  202. :LST_NULL @0>LST_probenum
  203. :LST_NULL @1>LST_intnum
  204. :LST_NULL @2>LST_intnum
  205. :LST_NULL @3>LST_intnum
  206. :LST_NULL @4>LST_intnum
  207. :LST_NULL @5>LST_intnum
  208. :LST_NULL @6>LST_intnum
  209. :LST_NULL @7>LST_intnum
  210. :LST_NULL @8>LST_intnum
  211. :LST_NULL @9>LST_intnum
  212. :LST_probenum @.>LST_float
  213. :LST_probenum @x>LST_hexnum
  214. :LST_probenum @X>LST_hexnum
  215. :LST_probefixed @x>LST_hexnum
  216. :LST_probefixed @X>LST_hexnum
  217. :LST_probenum +num_chars>LST_octalnum
  218. :LST_probefixed +num_chars>LST_octalnum
  219. :LST_intnum @.>LST_float
  220. :LST_intnum +num_chars>LST_intnum
  221. :LST_octalnum +octal_chars>LST_octalnum
  222. :LST_hexnum +hex_chars>LST_hexnum
  223. :LST_float @.>LST_INVALID
  224. :LST_float +num_chars>LST_float
  225. :LST_float @e>LST_float_exp_start
  226. :LST_float @E>LST_float_exp_start
  227. :LST_float @d=LST_float
  228. :LST_float @f=LST_float
  229. :LST_float_exp_start +num_chars>LST_float_exp
  230. :LST_float_exp_start @->LST_float_exp
  231. :LST_float_exp_start @+>LST_float_exp
  232. :LST_float_exp +num_chars>LST_float_exp
  233. :LST_float_exp @d=LST_float
  234. :LST_float_exp @f=LST_float
  235. # comments
  236. # ! inverts a character set
  237. # = finishes a token, including the character tested
  238. # ~ finishes a token but does not consume the character tested
  239. &LST_sl_comment
  240. :LST_sl_comment !+endl>LST_sl_comment
  241. :LST_sl_comment @\r~LST_sl_comment
  242. :LST_sl_comment @\n~LST_sl_comment
  243. &LST_ml_comment
  244. :LST_ml_comment @*>LST_ml_comment_star
  245. :LST_ml_comment !+star>LST_ml_comment
  246. :LST_ml_comment_star @/=LST_ml_comment
  247. :LST_ml_comment_star !+slash>LST_ml_comment