c_tokens.txt 8.1 KB

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