js_tokens.txt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. {await :cat=keyword |identifier_chars>LST_identifier
  18. {break :cat=keyword |identifier_chars>LST_identifier
  19. {case :cat=keyword |identifier_chars>LST_identifier
  20. {catch :cat=keyword |identifier_chars>LST_identifier
  21. {class :cat=keyword |identifier_chars>LST_identifier
  22. {const :cat=keyword |identifier_chars>LST_identifier
  23. {continue :cat=keyword |identifier_chars>LST_identifier
  24. {debugger :cat=keyword |identifier_chars>LST_identifier
  25. {default :cat=keyword |identifier_chars>LST_identifier
  26. {delete :cat=keyword |identifier_chars>LST_identifier
  27. {do :cat=keyword |identifier_chars>LST_identifier
  28. {else :cat=keyword |identifier_chars>LST_identifier
  29. {export :cat=keyword |identifier_chars>LST_identifier
  30. {extends :cat=keyword |identifier_chars>LST_identifier
  31. {false :cat=keyword |identifier_chars>LST_identifier
  32. {finally :cat=keyword |identifier_chars>LST_identifier
  33. {for :cat=keyword |identifier_chars>LST_identifier
  34. {function :cat=keyword |identifier_chars>LST_identifier
  35. {if :cat=keyword |identifier_chars>LST_identifier
  36. {import :cat=keyword |identifier_chars>LST_identifier
  37. {in :cat=keyword |identifier_chars>LST_identifier
  38. {instanceof :cat=keyword |identifier_chars>LST_identifier
  39. {let :cat=keyword |identifier_chars>LST_identifier
  40. {new :cat=keyword |identifier_chars>LST_identifier
  41. {null :cat=keyword |identifier_chars>LST_identifier
  42. {return :cat=keyword |identifier_chars>LST_identifier
  43. {of :cat=keyword |identifier_chars>LST_identifier
  44. {super :cat=keyword |identifier_chars>LST_identifier
  45. {switch :cat=keyword |identifier_chars>LST_identifier
  46. {this :cat=keyword |identifier_chars>LST_identifier
  47. {throw :cat=keyword |identifier_chars>LST_identifier
  48. {true :cat=keyword |identifier_chars>LST_identifier
  49. {try :cat=keyword |identifier_chars>LST_identifier
  50. {typeof :cat=keyword |identifier_chars>LST_identifier
  51. {var :cat=keyword |identifier_chars>LST_identifier
  52. {void :cat=keyword |identifier_chars>LST_identifier
  53. {while :cat=keyword |identifier_chars>LST_identifier
  54. {with :cat=keyword |identifier_chars>LST_identifier
  55. {yield :cat=keyword |identifier_chars>LST_identifier
  56. # operators and punctuation
  57. {+ :cat=operator
  58. {& :cat=operator
  59. {+= :cat=operator
  60. {&= :cat=operator
  61. {&& :cat=operator
  62. {== :cat=operator
  63. {=== :cat=operator
  64. {!= :cat=operator
  65. {!== :cat=operator
  66. {?? :cat=operator
  67. {( :cat=punct
  68. {) :cat=punct
  69. {- :cat=operator
  70. {| :cat=operator
  71. {-= :cat=operator
  72. {|= :cat=operator
  73. {|| :cat=operator
  74. {< :cat=operator
  75. {<= :cat=operator
  76. {[ :cat=punct
  77. {] :cat=punct
  78. {* :cat=operator
  79. {** :cat=operator
  80. {**- :cat=operator
  81. {^ :cat=operator
  82. {*= :cat=operator
  83. {^= :cat=operator
  84. {<- :cat=operator
  85. {> :cat=operator
  86. {>= :cat=operator
  87. {{ :cat=punct
  88. {} :cat=punct
  89. {/ :cat=operator
  90. :LST_NULL___slash @/>LST_sl_comment
  91. :LST_NULL___slash @*>LST_ml_comment
  92. {<< :cat=operator
  93. {<<< :cat=operator
  94. {/= :cat=operator
  95. {<<= :cat=operator
  96. {<<<= :cat=operator
  97. {++ :cat=operator
  98. {= :cat=operator
  99. {, :cat=operator
  100. {; :cat=punct
  101. {% :cat=operator
  102. {>> :cat=operator
  103. {>>> :cat=operator
  104. {%= :cat=operator
  105. {>>= :cat=operator
  106. {>>>= :cat=operator
  107. {-- :cat=operator
  108. {! :cat=operator
  109. {? :cat=operator
  110. {... :cat=operator
  111. {. :cat=operator +num_chars>LST_float
  112. {: :cat=operator
  113. {:: :cat=operator
  114. # mark some terminal states
  115. &LST_float :cat=number
  116. &LST_probenum :cat=number
  117. &LST_intnum :cat=number
  118. &LST_octalnum :cat=number
  119. &LST_hexnum :cat=number
  120. &LST_identifier :cat=identifier
  121. &LST_float_exp :cat=number
  122. # all other identifiers
  123. # + is transition on a character set
  124. :LST_identifier +identifier_chars>LST_identifier
  125. :LST_NULL +identifier_schars>LST_identifier
  126. # ignore whitespace
  127. # ^ discards the char while moving to the next state
  128. :LST_NULL +ws^LST_NULL
  129. # double-quote strings
  130. # @ is a single-char transition
  131. :LST_string @"=LST_string
  132. :LST_NULL @">LST_string
  133. &LST_string_end :cat=string
  134. :LST_string @\\>LST_string_esc
  135. :LST_string !+slash>LST_string
  136. :LST_string_esc @">LST_string
  137. # single-quote strings
  138. :LST_sq_string @'=LST_sq_string
  139. :LST_NULL @'>LST_sq_string
  140. &LST_sq_string_end :cat=string
  141. :LST_sq_string @\\>LST_sq_string_esc
  142. :LST_sq_string !+slash>LST_sq_string
  143. :LST_sq_string_esc @'>LST_sq_string
  144. # regex literals
  145. #:LST___slash @'=LST_sq_string
  146. #:LST_NULL @/>LST_sq_string
  147. #&LST_sq_string_end :cat=regex
  148. #:LST_sq_string @\\>LST_sq_string_esc
  149. #:LST_sq_string !+slash>LST_sq_string
  150. #:LST_sq_string_esc @'>LST_sq_string
  151. # numbers
  152. :LST_NULL @0>LST_probenum
  153. :LST_NULL @1>LST_intnum
  154. :LST_NULL @2>LST_intnum
  155. :LST_NULL @3>LST_intnum
  156. :LST_NULL @4>LST_intnum
  157. :LST_NULL @5>LST_intnum
  158. :LST_NULL @6>LST_intnum
  159. :LST_NULL @7>LST_intnum
  160. :LST_NULL @8>LST_intnum
  161. :LST_NULL @9>LST_intnum
  162. :LST_probenum @.>LST_float
  163. :LST_probenum @x>LST_hexnum
  164. :LST_probenum @X>LST_hexnum
  165. :LST_probefixed @x>LST_hexnum
  166. :LST_probefixed @X>LST_hexnum
  167. :LST_probenum +num_chars>LST_octalnum
  168. :LST_probefixed +num_chars>LST_octalnum
  169. :LST_intnum @.>LST_float
  170. :LST_intnum +num_chars>LST_intnum
  171. :LST_octalnum +octal_chars>LST_octalnum
  172. :LST_hexnum +hex_chars>LST_hexnum
  173. :LST_float @.>LST_INVALID
  174. :LST_float +num_chars>LST_float
  175. :LST_float @e>LST_float_exp_start
  176. :LST_float @E>LST_float_exp_start
  177. :LST_float @d=LST_float
  178. :LST_float @f=LST_float
  179. :LST_float_exp_start +num_chars>LST_float_exp
  180. :LST_float_exp_start @->LST_float_exp
  181. :LST_float_exp_start @+>LST_float_exp
  182. :LST_float_exp +num_chars>LST_float_exp
  183. :LST_float_exp @d=LST_float
  184. :LST_float_exp @f=LST_float
  185. # comments
  186. # ! inverts a character set
  187. # = finishes a token, including the character tested
  188. # ~ finishes a token but does not consume the character tested
  189. &LST_sl_comment :cat=comment
  190. :LST_sl_comment !+endl>LST_sl_comment
  191. :LST_sl_comment @\r~LST_sl_comment
  192. :LST_sl_comment @\n~LST_sl_comment
  193. &LST_ml_comment :cat=comment
  194. :LST_ml_comment @*>LST_ml_comment_star
  195. :LST_ml_comment !+star>LST_ml_comment
  196. :LST_ml_comment_star @/=LST_ml_comment
  197. :LST_ml_comment_star !+slash>LST_ml_comment