pygments.rb 1.2.1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (378) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +13 -0
  3. data/.github/workflows/ci.yml +28 -0
  4. data/.github/workflows/release.yml +24 -0
  5. data/.gitignore +5 -6
  6. data/CHANGELOG.adoc +119 -0
  7. data/Gemfile +3 -1
  8. data/LICENSE +1 -1
  9. data/README.adoc +161 -0
  10. data/Rakefile +10 -21
  11. data/bench.rb +8 -7
  12. data/cache-lexers.rb +3 -2
  13. data/lib/pygments.rb +10 -11
  14. data/lib/pygments/lexer.rb +5 -5
  15. data/lib/pygments/mentos.py +23 -66
  16. data/lib/pygments/popen.rb +152 -204
  17. data/lib/pygments/version.rb +2 -2
  18. data/pygments.rb.gemspec +11 -9
  19. data/test/test_pygments.rb +51 -84
  20. data/vendor/pygments-main/{AUTHORS → Pygments-2.7.3.dist-info/AUTHORS} +21 -3
  21. data/vendor/pygments-main/Pygments-2.7.3.dist-info/INSTALLER +1 -0
  22. data/vendor/pygments-main/{LICENSE → Pygments-2.7.3.dist-info/LICENSE} +1 -1
  23. data/vendor/pygments-main/Pygments-2.7.3.dist-info/METADATA +49 -0
  24. data/vendor/pygments-main/Pygments-2.7.3.dist-info/RECORD +482 -0
  25. data/vendor/pygments-main/Pygments-2.7.3.dist-info/REQUESTED +0 -0
  26. data/vendor/pygments-main/Pygments-2.7.3.dist-info/WHEEL +5 -0
  27. data/vendor/pygments-main/Pygments-2.7.3.dist-info/entry_points.txt +3 -0
  28. data/vendor/pygments-main/Pygments-2.7.3.dist-info/top_level.txt +1 -0
  29. data/vendor/pygments-main/bin/pygmentize +8 -0
  30. data/vendor/pygments-main/pygments/__init__.py +6 -11
  31. data/vendor/pygments-main/pygments/__main__.py +18 -0
  32. data/vendor/pygments-main/pygments/cmdline.py +38 -29
  33. data/vendor/pygments-main/pygments/console.py +6 -9
  34. data/vendor/pygments-main/pygments/filter.py +4 -6
  35. data/vendor/pygments-main/pygments/filters/__init__.py +609 -21
  36. data/vendor/pygments-main/pygments/formatter.py +4 -4
  37. data/vendor/pygments-main/pygments/formatters/__init__.py +9 -8
  38. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -3
  39. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  40. data/vendor/pygments-main/pygments/formatters/html.py +223 -135
  41. data/vendor/pygments-main/pygments/formatters/img.py +68 -41
  42. data/vendor/pygments-main/pygments/formatters/irc.py +39 -39
  43. data/vendor/pygments-main/pygments/formatters/latex.py +56 -26
  44. data/vendor/pygments-main/pygments/formatters/other.py +12 -8
  45. data/vendor/pygments-main/pygments/formatters/rtf.py +29 -29
  46. data/vendor/pygments-main/pygments/formatters/svg.py +38 -4
  47. data/vendor/pygments-main/pygments/formatters/terminal.py +25 -31
  48. data/vendor/pygments-main/pygments/formatters/terminal256.py +22 -12
  49. data/vendor/pygments-main/pygments/lexer.py +41 -39
  50. data/vendor/pygments-main/pygments/lexers/__init__.py +342 -0
  51. data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +1645 -0
  52. data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +232 -0
  53. data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +71 -0
  54. data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1725 -0
  55. data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +5327 -0
  56. data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +293 -0
  57. data/vendor/pygments-main/pygments/lexers/_mapping.py +551 -0
  58. data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +1172 -0
  59. data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +1282 -0
  60. data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +2547 -0
  61. data/vendor/pygments-main/pygments/lexers/_php_builtins.py +4753 -0
  62. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +678 -0
  63. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +3094 -0
  64. data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1161 -0
  65. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +558 -0
  66. data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +421 -0
  67. data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1004 -0
  68. data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +113 -0
  69. data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +280 -0
  70. data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1939 -0
  71. data/vendor/pygments-main/pygments/lexers/actionscript.py +245 -0
  72. data/vendor/pygments-main/pygments/lexers/agile.py +24 -0
  73. data/vendor/pygments-main/pygments/lexers/algebra.py +240 -0
  74. data/vendor/pygments-main/pygments/lexers/ambient.py +76 -0
  75. data/vendor/pygments-main/pygments/lexers/ampl.py +87 -0
  76. data/vendor/pygments-main/pygments/lexers/apl.py +101 -0
  77. data/vendor/pygments-main/pygments/lexers/archetype.py +318 -0
  78. data/vendor/pygments-main/pygments/lexers/arrow.py +117 -0
  79. data/vendor/pygments-main/pygments/lexers/asm.py +1005 -0
  80. data/vendor/pygments-main/pygments/lexers/automation.py +374 -0
  81. data/vendor/pygments-main/pygments/lexers/bare.py +104 -0
  82. data/vendor/pygments-main/pygments/lexers/basic.py +662 -0
  83. data/vendor/pygments-main/pygments/lexers/bibtex.py +160 -0
  84. data/vendor/pygments-main/pygments/lexers/boa.py +102 -0
  85. data/vendor/pygments-main/pygments/lexers/business.py +627 -0
  86. data/vendor/pygments-main/pygments/lexers/c_cpp.py +344 -0
  87. data/vendor/pygments-main/pygments/lexers/c_like.py +566 -0
  88. data/vendor/pygments-main/pygments/lexers/capnproto.py +78 -0
  89. data/vendor/pygments-main/pygments/lexers/chapel.py +112 -0
  90. data/vendor/pygments-main/pygments/lexers/clean.py +179 -0
  91. data/vendor/pygments-main/pygments/lexers/compiled.py +34 -0
  92. data/vendor/pygments-main/pygments/lexers/configs.py +984 -0
  93. data/vendor/pygments-main/pygments/lexers/console.py +114 -0
  94. data/vendor/pygments-main/pygments/lexers/crystal.py +392 -0
  95. data/vendor/pygments-main/pygments/lexers/csound.py +467 -0
  96. data/vendor/pygments-main/pygments/lexers/css.py +691 -0
  97. data/vendor/pygments-main/pygments/lexers/d.py +256 -0
  98. data/vendor/pygments-main/pygments/lexers/dalvik.py +125 -0
  99. data/vendor/pygments-main/pygments/lexers/data.py +698 -0
  100. data/vendor/pygments-main/pygments/lexers/devicetree.py +109 -0
  101. data/vendor/pygments-main/pygments/lexers/diff.py +165 -0
  102. data/vendor/pygments-main/pygments/lexers/dotnet.py +707 -0
  103. data/vendor/pygments-main/pygments/lexers/dsls.py +960 -0
  104. data/vendor/pygments-main/pygments/lexers/dylan.py +287 -0
  105. data/vendor/pygments-main/pygments/lexers/ecl.py +139 -0
  106. data/vendor/pygments-main/pygments/lexers/eiffel.py +65 -0
  107. data/vendor/pygments-main/pygments/lexers/elm.py +121 -0
  108. data/vendor/pygments-main/pygments/lexers/email.py +151 -0
  109. data/vendor/pygments-main/pygments/lexers/erlang.py +530 -0
  110. data/vendor/pygments-main/pygments/lexers/esoteric.py +304 -0
  111. data/vendor/pygments-main/pygments/lexers/ezhil.py +77 -0
  112. data/vendor/pygments-main/pygments/lexers/factor.py +344 -0
  113. data/vendor/pygments-main/pygments/lexers/fantom.py +250 -0
  114. data/vendor/pygments-main/pygments/lexers/felix.py +273 -0
  115. data/vendor/pygments-main/pygments/lexers/floscript.py +83 -0
  116. data/vendor/pygments-main/pygments/lexers/forth.py +178 -0
  117. data/vendor/pygments-main/pygments/lexers/fortran.py +206 -0
  118. data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
  119. data/vendor/pygments-main/pygments/lexers/freefem.py +898 -0
  120. data/vendor/pygments-main/pygments/lexers/functional.py +21 -0
  121. data/vendor/pygments-main/pygments/lexers/gdscript.py +346 -0
  122. data/vendor/pygments-main/pygments/lexers/go.py +101 -0
  123. data/vendor/pygments-main/pygments/lexers/grammar_notation.py +270 -0
  124. data/vendor/pygments-main/pygments/lexers/graph.py +85 -0
  125. data/vendor/pygments-main/pygments/lexers/graphics.py +800 -0
  126. data/vendor/pygments-main/pygments/lexers/haskell.py +870 -0
  127. data/vendor/pygments-main/pygments/lexers/haxe.py +936 -0
  128. data/vendor/pygments-main/pygments/lexers/hdl.py +472 -0
  129. data/vendor/pygments-main/pygments/lexers/hexdump.py +103 -0
  130. data/vendor/pygments-main/pygments/lexers/html.py +614 -0
  131. data/vendor/pygments-main/pygments/lexers/idl.py +281 -0
  132. data/vendor/pygments-main/pygments/lexers/igor.py +420 -0
  133. data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
  134. data/vendor/pygments-main/pygments/lexers/installers.py +322 -0
  135. data/vendor/pygments-main/pygments/lexers/int_fiction.py +1368 -0
  136. data/vendor/pygments-main/pygments/lexers/iolang.py +63 -0
  137. data/vendor/pygments-main/pygments/lexers/j.py +146 -0
  138. data/vendor/pygments-main/pygments/lexers/javascript.py +1540 -0
  139. data/vendor/pygments-main/pygments/lexers/julia.py +331 -0
  140. data/vendor/pygments-main/pygments/lexers/jvm.py +1673 -0
  141. data/vendor/pygments-main/pygments/lexers/lisp.py +2699 -0
  142. data/vendor/pygments-main/pygments/lexers/make.py +206 -0
  143. data/vendor/pygments-main/pygments/lexers/markup.py +765 -0
  144. data/vendor/pygments-main/pygments/lexers/math.py +21 -0
  145. data/vendor/pygments-main/pygments/lexers/matlab.py +720 -0
  146. data/vendor/pygments-main/pygments/lexers/mime.py +226 -0
  147. data/vendor/pygments-main/pygments/lexers/ml.py +958 -0
  148. data/vendor/pygments-main/pygments/lexers/modeling.py +366 -0
  149. data/vendor/pygments-main/pygments/lexers/modula2.py +1580 -0
  150. data/vendor/pygments-main/pygments/lexers/monte.py +204 -0
  151. data/vendor/pygments-main/pygments/lexers/mosel.py +448 -0
  152. data/vendor/pygments-main/pygments/lexers/ncl.py +894 -0
  153. data/vendor/pygments-main/pygments/lexers/nimrod.py +159 -0
  154. data/vendor/pygments-main/pygments/lexers/nit.py +64 -0
  155. data/vendor/pygments-main/pygments/lexers/nix.py +136 -0
  156. data/vendor/pygments-main/pygments/lexers/oberon.py +121 -0
  157. data/vendor/pygments-main/pygments/lexers/objective.py +504 -0
  158. data/vendor/pygments-main/pygments/lexers/ooc.py +85 -0
  159. data/vendor/pygments-main/pygments/lexers/other.py +41 -0
  160. data/vendor/pygments-main/pygments/lexers/parasail.py +79 -0
  161. data/vendor/pygments-main/pygments/lexers/parsers.py +800 -0
  162. data/vendor/pygments-main/pygments/lexers/pascal.py +644 -0
  163. data/vendor/pygments-main/pygments/lexers/pawn.py +205 -0
  164. data/vendor/pygments-main/pygments/lexers/perl.py +732 -0
  165. data/vendor/pygments-main/pygments/lexers/php.py +321 -0
  166. data/vendor/pygments-main/pygments/lexers/pointless.py +71 -0
  167. data/vendor/pygments-main/pygments/lexers/pony.py +94 -0
  168. data/vendor/pygments-main/pygments/lexers/praat.py +302 -0
  169. data/vendor/pygments-main/pygments/lexers/prolog.py +306 -0
  170. data/vendor/pygments-main/pygments/lexers/promql.py +183 -0
  171. data/vendor/pygments-main/pygments/lexers/python.py +1151 -0
  172. data/vendor/pygments-main/pygments/lexers/qvt.py +152 -0
  173. data/vendor/pygments-main/pygments/lexers/r.py +191 -0
  174. data/vendor/pygments-main/pygments/lexers/rdf.py +463 -0
  175. data/vendor/pygments-main/pygments/lexers/rebol.py +431 -0
  176. data/vendor/pygments-main/pygments/lexers/resource.py +85 -0
  177. data/vendor/pygments-main/pygments/lexers/ride.py +139 -0
  178. data/vendor/pygments-main/pygments/lexers/rnc.py +67 -0
  179. data/vendor/pygments-main/pygments/lexers/roboconf.py +82 -0
  180. data/vendor/pygments-main/pygments/lexers/robotframework.py +552 -0
  181. data/vendor/pygments-main/pygments/lexers/ruby.py +517 -0
  182. data/vendor/pygments-main/pygments/lexers/rust.py +224 -0
  183. data/vendor/pygments-main/pygments/lexers/sas.py +228 -0
  184. data/vendor/pygments-main/pygments/lexers/scdoc.py +83 -0
  185. data/vendor/pygments-main/pygments/lexers/scripting.py +1284 -0
  186. data/vendor/pygments-main/pygments/lexers/sgf.py +61 -0
  187. data/vendor/pygments-main/pygments/lexers/shell.py +914 -0
  188. data/vendor/pygments-main/pygments/lexers/sieve.py +69 -0
  189. data/vendor/pygments-main/pygments/lexers/slash.py +185 -0
  190. data/vendor/pygments-main/pygments/lexers/smalltalk.py +195 -0
  191. data/vendor/pygments-main/pygments/lexers/smv.py +79 -0
  192. data/vendor/pygments-main/pygments/lexers/snobol.py +83 -0
  193. data/vendor/pygments-main/pygments/lexers/solidity.py +92 -0
  194. data/vendor/pygments-main/pygments/lexers/special.py +105 -0
  195. data/vendor/pygments-main/pygments/lexers/sql.py +837 -0
  196. data/vendor/pygments-main/pygments/lexers/stata.py +171 -0
  197. data/vendor/pygments-main/pygments/lexers/supercollider.py +95 -0
  198. data/vendor/pygments-main/pygments/lexers/tcl.py +145 -0
  199. data/vendor/pygments-main/pygments/lexers/templates.py +2264 -0
  200. data/vendor/pygments-main/pygments/lexers/teraterm.py +335 -0
  201. data/vendor/pygments-main/pygments/lexers/testing.py +207 -0
  202. data/vendor/pygments-main/pygments/lexers/text.py +26 -0
  203. data/vendor/pygments-main/pygments/lexers/textedit.py +169 -0
  204. data/vendor/pygments-main/pygments/lexers/textfmts.py +430 -0
  205. data/vendor/pygments-main/pygments/lexers/theorem.py +474 -0
  206. data/vendor/pygments-main/pygments/lexers/tnt.py +263 -0
  207. data/vendor/pygments-main/pygments/lexers/trafficscript.py +54 -0
  208. data/vendor/pygments-main/pygments/lexers/typoscript.py +219 -0
  209. data/vendor/pygments-main/pygments/lexers/unicon.py +412 -0
  210. data/vendor/pygments-main/pygments/lexers/urbi.py +146 -0
  211. data/vendor/pygments-main/pygments/lexers/usd.py +90 -0
  212. data/vendor/pygments-main/pygments/lexers/varnish.py +190 -0
  213. data/vendor/pygments-main/pygments/lexers/verification.py +114 -0
  214. data/vendor/pygments-main/pygments/lexers/web.py +24 -0
  215. data/vendor/pygments-main/pygments/lexers/webidl.py +299 -0
  216. data/vendor/pygments-main/pygments/lexers/webmisc.py +991 -0
  217. data/vendor/pygments-main/pygments/lexers/whiley.py +116 -0
  218. data/vendor/pygments-main/pygments/lexers/x10.py +69 -0
  219. data/vendor/pygments-main/pygments/lexers/xorg.py +37 -0
  220. data/vendor/pygments-main/pygments/lexers/yang.py +104 -0
  221. data/vendor/pygments-main/pygments/lexers/zig.py +124 -0
  222. data/vendor/pygments-main/pygments/modeline.py +1 -1
  223. data/vendor/pygments-main/pygments/plugin.py +4 -2
  224. data/vendor/pygments-main/pygments/regexopt.py +1 -1
  225. data/vendor/pygments-main/pygments/scanner.py +2 -2
  226. data/vendor/pygments-main/pygments/sphinxext.py +2 -4
  227. data/vendor/pygments-main/pygments/style.py +61 -24
  228. data/vendor/pygments-main/pygments/styles/__init__.py +10 -4
  229. data/vendor/pygments-main/pygments/styles/abap.py +1 -1
  230. data/vendor/pygments-main/pygments/styles/algol.py +1 -1
  231. data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -1
  232. data/vendor/pygments-main/pygments/styles/arduino.py +2 -2
  233. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  234. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  235. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  236. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  237. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  238. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  239. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  240. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  241. data/vendor/pygments-main/pygments/styles/igor.py +1 -1
  242. data/vendor/pygments-main/pygments/styles/inkpot.py +67 -0
  243. data/vendor/pygments-main/pygments/styles/lovelace.py +1 -1
  244. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  245. data/vendor/pygments-main/pygments/styles/monokai.py +4 -3
  246. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  247. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  248. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -1
  249. data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -1
  250. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  251. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  252. data/vendor/pygments-main/pygments/styles/rainbow_dash.py +1 -1
  253. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  254. data/vendor/pygments-main/pygments/styles/sas.py +1 -1
  255. data/vendor/pygments-main/pygments/styles/solarized.py +134 -0
  256. data/vendor/pygments-main/pygments/styles/stata_dark.py +41 -0
  257. data/vendor/pygments-main/pygments/styles/{stata.py → stata_light.py} +14 -15
  258. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  259. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  260. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  261. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  262. data/vendor/pygments-main/pygments/styles/xcode.py +1 -1
  263. data/vendor/pygments-main/pygments/token.py +1 -1
  264. data/vendor/pygments-main/pygments/unistring.py +47 -108
  265. data/vendor/pygments-main/pygments/util.py +15 -92
  266. metadata +69 -136
  267. data/CHANGELOG.md +0 -111
  268. data/README.md +0 -121
  269. data/circle.yml +0 -20
  270. data/test/test_data.py +0 -514
  271. data/test/test_data_generated +0 -2582
  272. data/vendor/custom_lexers/github.py +0 -565
  273. data/vendor/pygments-main/CHANGES +0 -1186
  274. data/vendor/pygments-main/MANIFEST.in +0 -6
  275. data/vendor/pygments-main/Makefile +0 -65
  276. data/vendor/pygments-main/README.rst +0 -39
  277. data/vendor/pygments-main/REVISION +0 -1
  278. data/vendor/pygments-main/TODO +0 -12
  279. data/vendor/pygments-main/doc/Makefile +0 -153
  280. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  281. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  282. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  283. data/vendor/pygments-main/doc/_templates/docssidebar.html +0 -3
  284. data/vendor/pygments-main/doc/_templates/indexsidebar.html +0 -25
  285. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +0 -98
  286. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  287. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  288. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  289. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  290. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  291. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +0 -401
  292. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +0 -15
  293. data/vendor/pygments-main/doc/conf.py +0 -241
  294. data/vendor/pygments-main/doc/docs/api.rst +0 -354
  295. data/vendor/pygments-main/doc/docs/authors.rst +0 -4
  296. data/vendor/pygments-main/doc/docs/changelog.rst +0 -1
  297. data/vendor/pygments-main/doc/docs/cmdline.rst +0 -166
  298. data/vendor/pygments-main/doc/docs/filterdevelopment.rst +0 -71
  299. data/vendor/pygments-main/doc/docs/filters.rst +0 -41
  300. data/vendor/pygments-main/doc/docs/formatterdevelopment.rst +0 -169
  301. data/vendor/pygments-main/doc/docs/formatters.rst +0 -48
  302. data/vendor/pygments-main/doc/docs/index.rst +0 -66
  303. data/vendor/pygments-main/doc/docs/integrate.rst +0 -40
  304. data/vendor/pygments-main/doc/docs/java.rst +0 -70
  305. data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +0 -728
  306. data/vendor/pygments-main/doc/docs/lexers.rst +0 -69
  307. data/vendor/pygments-main/doc/docs/moinmoin.rst +0 -39
  308. data/vendor/pygments-main/doc/docs/plugins.rst +0 -93
  309. data/vendor/pygments-main/doc/docs/quickstart.rst +0 -205
  310. data/vendor/pygments-main/doc/docs/rstdirective.rst +0 -22
  311. data/vendor/pygments-main/doc/docs/styles.rst +0 -201
  312. data/vendor/pygments-main/doc/docs/tokens.rst +0 -372
  313. data/vendor/pygments-main/doc/docs/unicode.rst +0 -58
  314. data/vendor/pygments-main/doc/download.rst +0 -41
  315. data/vendor/pygments-main/doc/faq.rst +0 -139
  316. data/vendor/pygments-main/doc/index.rst +0 -54
  317. data/vendor/pygments-main/doc/languages.rst +0 -154
  318. data/vendor/pygments-main/doc/make.bat +0 -190
  319. data/vendor/pygments-main/doc/pygmentize.1 +0 -94
  320. data/vendor/pygments-main/external/autopygmentize +0 -101
  321. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +0 -162
  322. data/vendor/pygments-main/external/markdown-processor.py +0 -67
  323. data/vendor/pygments-main/external/moin-parser.py +0 -112
  324. data/vendor/pygments-main/external/pygments.bashcomp +0 -38
  325. data/vendor/pygments-main/external/rst-directive.py +0 -82
  326. data/vendor/pygments-main/pygmentize +0 -8
  327. data/vendor/pygments-main/requirements.txt +0 -5
  328. data/vendor/pygments-main/scripts/check_sources.py +0 -211
  329. data/vendor/pygments-main/scripts/debug_lexer.py +0 -246
  330. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +0 -33
  331. data/vendor/pygments-main/scripts/epydoc.css +0 -280
  332. data/vendor/pygments-main/scripts/get_vimkw.py +0 -74
  333. data/vendor/pygments-main/scripts/pylintrc +0 -301
  334. data/vendor/pygments-main/scripts/vim2pygments.py +0 -935
  335. data/vendor/pygments-main/setup.cfg +0 -10
  336. data/vendor/pygments-main/setup.py +0 -77
  337. data/vendor/pygments-main/tox.ini +0 -7
  338. data/vendor/simplejson/.gitignore +0 -10
  339. data/vendor/simplejson/.travis.yml +0 -5
  340. data/vendor/simplejson/CHANGES.txt +0 -291
  341. data/vendor/simplejson/LICENSE.txt +0 -19
  342. data/vendor/simplejson/MANIFEST.in +0 -5
  343. data/vendor/simplejson/README.rst +0 -19
  344. data/vendor/simplejson/conf.py +0 -179
  345. data/vendor/simplejson/index.rst +0 -628
  346. data/vendor/simplejson/scripts/make_docs.py +0 -18
  347. data/vendor/simplejson/setup.py +0 -104
  348. data/vendor/simplejson/simplejson/__init__.py +0 -510
  349. data/vendor/simplejson/simplejson/_speedups.c +0 -2745
  350. data/vendor/simplejson/simplejson/decoder.py +0 -425
  351. data/vendor/simplejson/simplejson/encoder.py +0 -567
  352. data/vendor/simplejson/simplejson/ordered_dict.py +0 -119
  353. data/vendor/simplejson/simplejson/scanner.py +0 -77
  354. data/vendor/simplejson/simplejson/tests/__init__.py +0 -67
  355. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +0 -55
  356. data/vendor/simplejson/simplejson/tests/test_check_circular.py +0 -30
  357. data/vendor/simplejson/simplejson/tests/test_decimal.py +0 -66
  358. data/vendor/simplejson/simplejson/tests/test_decode.py +0 -83
  359. data/vendor/simplejson/simplejson/tests/test_default.py +0 -9
  360. data/vendor/simplejson/simplejson/tests/test_dump.py +0 -67
  361. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +0 -46
  362. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +0 -32
  363. data/vendor/simplejson/simplejson/tests/test_errors.py +0 -34
  364. data/vendor/simplejson/simplejson/tests/test_fail.py +0 -91
  365. data/vendor/simplejson/simplejson/tests/test_float.py +0 -19
  366. data/vendor/simplejson/simplejson/tests/test_indent.py +0 -86
  367. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +0 -20
  368. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +0 -121
  369. data/vendor/simplejson/simplejson/tests/test_pass1.py +0 -76
  370. data/vendor/simplejson/simplejson/tests/test_pass2.py +0 -14
  371. data/vendor/simplejson/simplejson/tests/test_pass3.py +0 -20
  372. data/vendor/simplejson/simplejson/tests/test_recursion.py +0 -67
  373. data/vendor/simplejson/simplejson/tests/test_scanstring.py +0 -117
  374. data/vendor/simplejson/simplejson/tests/test_separators.py +0 -42
  375. data/vendor/simplejson/simplejson/tests/test_speedups.py +0 -20
  376. data/vendor/simplejson/simplejson/tests/test_tuple.py +0 -49
  377. data/vendor/simplejson/simplejson/tests/test_unicode.py +0 -109
  378. data/vendor/simplejson/simplejson/tool.py +0 -39
@@ -0,0 +1,331 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.julia
4
+ ~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for the Julia language.
7
+
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ import re
13
+
14
+ from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, \
15
+ words, include
16
+ from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
17
+ Number, Punctuation, Generic
18
+ from pygments.util import shebang_matches
19
+
20
+ __all__ = ['JuliaLexer', 'JuliaConsoleLexer']
21
+
22
+ allowed_variable = \
23
+ '(?:[a-zA-Z_\u00A1-\U0010ffff]|%s)(?:[a-zA-Z_0-9\u00A1-\U0010ffff])*!*'
24
+
25
+
26
+ class JuliaLexer(RegexLexer):
27
+ """
28
+ For `Julia <http://julialang.org/>`_ source code.
29
+
30
+ .. versionadded:: 1.6
31
+ """
32
+
33
+ name = 'Julia'
34
+ aliases = ['julia', 'jl']
35
+ filenames = ['*.jl']
36
+ mimetypes = ['text/x-julia', 'application/x-julia']
37
+
38
+ flags = re.MULTILINE | re.UNICODE
39
+
40
+ tokens = {
41
+ 'root': [
42
+ (r'\n', Text),
43
+ (r'[^\S\n]+', Text),
44
+ (r'#=', Comment.Multiline, "blockcomment"),
45
+ (r'#.*$', Comment),
46
+ (r'[\[\]{}(),;]', Punctuation),
47
+
48
+ # keywords
49
+ (r'in\b', Keyword.Pseudo),
50
+ (r'isa\b', Keyword.Pseudo),
51
+ (r'(true|false)\b', Keyword.Constant),
52
+ (r'(local|global|const)\b', Keyword.Declaration),
53
+ (words([
54
+ 'function', 'type', 'typealias', 'abstract', 'immutable',
55
+ 'baremodule', 'begin', 'bitstype', 'break', 'catch', 'ccall',
56
+ 'continue', 'do', 'else', 'elseif', 'end', 'export', 'finally',
57
+ 'for', 'if', 'import', 'importall', 'let', 'macro', 'module',
58
+ 'mutable', 'primitive', 'quote', 'return', 'struct', 'try',
59
+ 'using', 'while'],
60
+ suffix=r'\b'), Keyword),
61
+
62
+ # NOTE
63
+ # Patterns below work only for definition sites and thus hardly reliable.
64
+ #
65
+ # functions
66
+ # (r'(function)(\s+)(' + allowed_variable + ')',
67
+ # bygroups(Keyword, Text, Name.Function)),
68
+ #
69
+ # types
70
+ # (r'(type|typealias|abstract|immutable)(\s+)(' + allowed_variable + ')',
71
+ # bygroups(Keyword, Text, Name.Class)),
72
+
73
+ # type names
74
+ (words([
75
+ 'ANY', 'ASCIIString', 'AbstractArray', 'AbstractChannel',
76
+ 'AbstractFloat', 'AbstractMatrix', 'AbstractRNG',
77
+ 'AbstractSparseArray', 'AbstractSparseMatrix',
78
+ 'AbstractSparseVector', 'AbstractString', 'AbstractVecOrMat',
79
+ 'AbstractVector', 'Any', 'ArgumentError', 'Array',
80
+ 'AssertionError', 'Associative', 'Base64DecodePipe',
81
+ 'Base64EncodePipe', 'Bidiagonal', 'BigFloat', 'BigInt',
82
+ 'BitArray', 'BitMatrix', 'BitVector', 'Bool', 'BoundsError',
83
+ 'Box', 'BufferStream', 'CapturedException', 'CartesianIndex',
84
+ 'CartesianRange', 'Cchar', 'Cdouble', 'Cfloat', 'Channel',
85
+ 'Char', 'Cint', 'Cintmax_t', 'Clong', 'Clonglong',
86
+ 'ClusterManager', 'Cmd', 'Coff_t', 'Colon', 'Complex',
87
+ 'Complex128', 'Complex32', 'Complex64', 'CompositeException',
88
+ 'Condition', 'Cptrdiff_t', 'Cshort', 'Csize_t', 'Cssize_t',
89
+ 'Cstring', 'Cuchar', 'Cuint', 'Cuintmax_t', 'Culong',
90
+ 'Culonglong', 'Cushort', 'Cwchar_t', 'Cwstring', 'DataType',
91
+ 'Date', 'DateTime', 'DenseArray', 'DenseMatrix',
92
+ 'DenseVecOrMat', 'DenseVector', 'Diagonal', 'Dict',
93
+ 'DimensionMismatch', 'Dims', 'DirectIndexString', 'Display',
94
+ 'DivideError', 'DomainError', 'EOFError', 'EachLine', 'Enum',
95
+ 'Enumerate', 'ErrorException', 'Exception', 'Expr',
96
+ 'Factorization', 'FileMonitor', 'FileOffset', 'Filter',
97
+ 'Float16', 'Float32', 'Float64', 'FloatRange', 'Function',
98
+ 'GenSym', 'GlobalRef', 'GotoNode', 'HTML', 'Hermitian', 'IO',
99
+ 'IOBuffer', 'IOStream', 'IPv4', 'IPv6', 'InexactError',
100
+ 'InitError', 'Int', 'Int128', 'Int16', 'Int32', 'Int64', 'Int8',
101
+ 'IntSet', 'Integer', 'InterruptException', 'IntrinsicFunction',
102
+ 'InvalidStateException', 'Irrational', 'KeyError', 'LabelNode',
103
+ 'LambdaStaticData', 'LinSpace', 'LineNumberNode', 'LoadError',
104
+ 'LocalProcess', 'LowerTriangular', 'MIME', 'Matrix',
105
+ 'MersenneTwister', 'Method', 'MethodError', 'MethodTable',
106
+ 'Module', 'NTuple', 'NewvarNode', 'NullException', 'Nullable',
107
+ 'Number', 'ObjectIdDict', 'OrdinalRange', 'OutOfMemoryError',
108
+ 'OverflowError', 'Pair', 'ParseError', 'PartialQuickSort',
109
+ 'Pipe', 'PollingFileWatcher', 'ProcessExitedException',
110
+ 'ProcessGroup', 'Ptr', 'QuoteNode', 'RandomDevice', 'Range',
111
+ 'Rational', 'RawFD', 'ReadOnlyMemoryError', 'Real',
112
+ 'ReentrantLock', 'Ref', 'Regex', 'RegexMatch',
113
+ 'RemoteException', 'RemoteRef', 'RepString', 'RevString',
114
+ 'RopeString', 'RoundingMode', 'SegmentationFault',
115
+ 'SerializationState', 'Set', 'SharedArray', 'SharedMatrix',
116
+ 'SharedVector', 'Signed', 'SimpleVector', 'SparseMatrixCSC',
117
+ 'StackOverflowError', 'StatStruct', 'StepRange', 'StridedArray',
118
+ 'StridedMatrix', 'StridedVecOrMat', 'StridedVector', 'SubArray',
119
+ 'SubString', 'SymTridiagonal', 'Symbol', 'SymbolNode',
120
+ 'Symmetric', 'SystemError', 'TCPSocket', 'Task', 'Text',
121
+ 'TextDisplay', 'Timer', 'TopNode', 'Tridiagonal', 'Tuple',
122
+ 'Type', 'TypeConstructor', 'TypeError', 'TypeName', 'TypeVar',
123
+ 'UDPSocket', 'UInt', 'UInt128', 'UInt16', 'UInt32', 'UInt64',
124
+ 'UInt8', 'UTF16String', 'UTF32String', 'UTF8String',
125
+ 'UndefRefError', 'UndefVarError', 'UnicodeError', 'UniformScaling',
126
+ 'Union', 'UnitRange', 'Unsigned', 'UpperTriangular', 'Val',
127
+ 'Vararg', 'VecOrMat', 'Vector', 'VersionNumber', 'Void', 'WString',
128
+ 'WeakKeyDict', 'WeakRef', 'WorkerConfig', 'Zip'], suffix=r'\b'),
129
+ Keyword.Type),
130
+
131
+ # builtins
132
+ (words([
133
+ 'ARGS', 'CPU_CORES', 'C_NULL', 'DevNull', 'ENDIAN_BOM',
134
+ 'ENV', 'I', 'Inf', 'Inf16', 'Inf32', 'Inf64',
135
+ 'InsertionSort', 'JULIA_HOME', 'LOAD_PATH', 'MergeSort',
136
+ 'NaN', 'NaN16', 'NaN32', 'NaN64', 'OS_NAME',
137
+ 'QuickSort', 'RoundDown', 'RoundFromZero', 'RoundNearest',
138
+ 'RoundNearestTiesAway', 'RoundNearestTiesUp',
139
+ 'RoundToZero', 'RoundUp', 'STDERR', 'STDIN', 'STDOUT',
140
+ 'VERSION', 'WORD_SIZE', 'catalan', 'e', 'eu',
141
+ 'eulergamma', 'golden', 'im', 'nothing', 'pi', 'γ', 'π', 'φ'],
142
+ suffix=r'\b'), Name.Builtin),
143
+
144
+ # operators
145
+ # see: https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm
146
+ (words((
147
+ # prec-assignment
148
+ '=', ':=', '+=', '-=', '*=', '/=', '//=', './/=', '.*=', './=',
149
+ '\\=', '.\\=', '^=', '.^=', '÷=', '.÷=', '%=', '.%=', '|=', '&=',
150
+ '$=', '=>', '<<=', '>>=', '>>>=', '~', '.+=', '.-=',
151
+ # prec-conditional
152
+ '?',
153
+ # prec-arrow
154
+ '--', '-->',
155
+ # prec-lazy-or
156
+ '||',
157
+ # prec-lazy-and
158
+ '&&',
159
+ # prec-comparison
160
+ '>', '<', '>=', '≥', '<=', '≤', '==', '===', '≡', '!=', '≠',
161
+ '!==', '≢', '.>', '.<', '.>=', '.≥', '.<=', '.≤', '.==', '.!=',
162
+ '.≠', '.=', '.!', '<:', '>:', '∈', '∉', '∋', '∌', '⊆',
163
+ '⊈', '⊂',
164
+ '⊄', '⊊',
165
+ # prec-pipe
166
+ '|>', '<|',
167
+ # prec-colon
168
+ ':',
169
+ # prec-plus
170
+ '.+', '.-', '|', '∪', '$',
171
+ # prec-bitshift
172
+ '<<', '>>', '>>>', '.<<', '.>>', '.>>>',
173
+ # prec-times
174
+ '*', '/', './', '÷', '.÷', '%', '⋅', '.%', '.*', '\\', '.\\', '&', '∩',
175
+ # prec-rational
176
+ '//', './/',
177
+ # prec-power
178
+ '^', '.^',
179
+ # prec-decl
180
+ '::',
181
+ # prec-dot
182
+ '.',
183
+ # unary op
184
+ '+', '-', '!', '√', '∛', '∜',
185
+ )), Operator),
186
+
187
+ # chars
188
+ (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|"
189
+ r"\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'", String.Char),
190
+
191
+ # try to match trailing transpose
192
+ (r'(?<=[.\w)\]])\'+', Operator),
193
+
194
+ # strings
195
+ (r'"""', String, 'tqstring'),
196
+ (r'"', String, 'string'),
197
+
198
+ # regular expressions
199
+ (r'r"""', String.Regex, 'tqregex'),
200
+ (r'r"', String.Regex, 'regex'),
201
+
202
+ # backticks
203
+ (r'`', String.Backtick, 'command'),
204
+
205
+ # names
206
+ (allowed_variable, Name),
207
+ (r'@' + allowed_variable, Name.Decorator),
208
+
209
+ # numbers
210
+ (r'(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?', Number.Float),
211
+ (r'(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?', Number.Float),
212
+ (r'\d+(_\d+)+[eEf][+-]?[0-9]+', Number.Float),
213
+ (r'\d+[eEf][+-]?[0-9]+', Number.Float),
214
+ (r'0b[01]+(_[01]+)+', Number.Bin),
215
+ (r'0b[01]+', Number.Bin),
216
+ (r'0o[0-7]+(_[0-7]+)+', Number.Oct),
217
+ (r'0o[0-7]+', Number.Oct),
218
+ (r'0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+', Number.Hex),
219
+ (r'0x[a-fA-F0-9]+', Number.Hex),
220
+ (r'\d+(_\d+)+', Number.Integer),
221
+ (r'\d+', Number.Integer)
222
+ ],
223
+
224
+ "blockcomment": [
225
+ (r'[^=#]', Comment.Multiline),
226
+ (r'#=', Comment.Multiline, '#push'),
227
+ (r'=#', Comment.Multiline, '#pop'),
228
+ (r'[=#]', Comment.Multiline),
229
+ ],
230
+
231
+ 'string': [
232
+ (r'"', String, '#pop'),
233
+ # FIXME: This escape pattern is not perfect.
234
+ (r'\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)', String.Escape),
235
+ # Interpolation is defined as "$" followed by the shortest full
236
+ # expression, which is something we can't parse.
237
+ # Include the most common cases here: $word, and $(paren'd expr).
238
+ (r'\$' + allowed_variable, String.Interpol),
239
+ # (r'\$[a-zA-Z_]+', String.Interpol),
240
+ (r'(\$)(\()', bygroups(String.Interpol, Punctuation), 'in-intp'),
241
+ # @printf and @sprintf formats
242
+ (r'%[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]',
243
+ String.Interpol),
244
+ (r'.|\s', String),
245
+ ],
246
+
247
+ 'tqstring': [
248
+ (r'"""', String, '#pop'),
249
+ (r'\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)', String.Escape),
250
+ (r'\$' + allowed_variable, String.Interpol),
251
+ (r'(\$)(\()', bygroups(String.Interpol, Punctuation), 'in-intp'),
252
+ (r'.|\s', String),
253
+ ],
254
+
255
+ 'regex': [
256
+ (r'"', String.Regex, '#pop'),
257
+ (r'\\"', String.Regex),
258
+ (r'.|\s', String.Regex),
259
+ ],
260
+
261
+ 'tqregex': [
262
+ (r'"""', String.Regex, '#pop'),
263
+ (r'.|\s', String.Regex),
264
+ ],
265
+
266
+ 'command': [
267
+ (r'`', String.Backtick, '#pop'),
268
+ (r'\$' + allowed_variable, String.Interpol),
269
+ (r'(\$)(\()', bygroups(String.Interpol, Punctuation), 'in-intp'),
270
+ (r'.|\s', String.Backtick)
271
+ ],
272
+
273
+ 'in-intp': [
274
+ (r'\(', Punctuation, '#push'),
275
+ (r'\)', Punctuation, '#pop'),
276
+ include('root'),
277
+ ]
278
+ }
279
+
280
+ def analyse_text(text):
281
+ return shebang_matches(text, r'julia')
282
+
283
+
284
+ class JuliaConsoleLexer(Lexer):
285
+ """
286
+ For Julia console sessions. Modeled after MatlabSessionLexer.
287
+
288
+ .. versionadded:: 1.6
289
+ """
290
+ name = 'Julia console'
291
+ aliases = ['jlcon']
292
+
293
+ def get_tokens_unprocessed(self, text):
294
+ jllexer = JuliaLexer(**self.options)
295
+ start = 0
296
+ curcode = ''
297
+ insertions = []
298
+ output = False
299
+ error = False
300
+
301
+ for line in text.splitlines(True):
302
+ if line.startswith('julia>'):
303
+ insertions.append((len(curcode), [(0, Generic.Prompt, line[:6])]))
304
+ curcode += line[6:]
305
+ output = False
306
+ error = False
307
+ elif line.startswith('help?>') or line.startswith('shell>'):
308
+ yield start, Generic.Prompt, line[:6]
309
+ yield start + 6, Text, line[6:]
310
+ output = False
311
+ error = False
312
+ elif line.startswith(' ') and not output:
313
+ insertions.append((len(curcode), [(0, Text, line[:6])]))
314
+ curcode += line[6:]
315
+ else:
316
+ if curcode:
317
+ yield from do_insertions(
318
+ insertions, jllexer.get_tokens_unprocessed(curcode))
319
+ curcode = ''
320
+ insertions = []
321
+ if line.startswith('ERROR: ') or error:
322
+ yield start, Generic.Error, line
323
+ error = True
324
+ else:
325
+ yield start, Generic.Output, line
326
+ output = True
327
+ start += len(line)
328
+
329
+ if curcode:
330
+ yield from do_insertions(
331
+ insertions, jllexer.get_tokens_unprocessed(curcode))
@@ -0,0 +1,1673 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.jvm
4
+ ~~~~~~~~~~~~~~~~~~~
5
+
6
+ Pygments lexers for JVM languages.
7
+
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ import re
13
+
14
+ from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
15
+ this, combined, default, words
16
+ from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
17
+ Number, Punctuation
18
+ from pygments.util import shebang_matches
19
+ from pygments import unistring as uni
20
+
21
+ __all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer',
22
+ 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'ClojureScriptLexer',
23
+ 'KotlinLexer', 'XtendLexer', 'AspectJLexer', 'CeylonLexer',
24
+ 'PigLexer', 'GoloLexer', 'JasminLexer', 'SarlLexer']
25
+
26
+
27
+ class JavaLexer(RegexLexer):
28
+ """
29
+ For `Java <https://www.oracle.com/technetwork/java/>`_ source code.
30
+ """
31
+
32
+ name = 'Java'
33
+ aliases = ['java']
34
+ filenames = ['*.java']
35
+ mimetypes = ['text/x-java']
36
+
37
+ flags = re.MULTILINE | re.DOTALL | re.UNICODE
38
+
39
+ tokens = {
40
+ 'root': [
41
+ (r'[^\S\n]+', Text),
42
+ (r'//.*?\n', Comment.Single),
43
+ (r'/\*.*?\*/', Comment.Multiline),
44
+ # keywords: go before method names to avoid lexing "throw new XYZ"
45
+ # as a method signature
46
+ (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
47
+ r'if|goto|instanceof|new|return|switch|this|throw|try|while)\b',
48
+ Keyword),
49
+ # method names
50
+ (r'((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)' # return arguments
51
+ r'((?:[^\W\d]|\$)[\w$]*)' # method name
52
+ r'(\s*)(\()', # signature start
53
+ bygroups(using(this), Name.Function, Text, Punctuation)),
54
+ (r'@[^\W\d][\w.]*', Name.Decorator),
55
+ (r'(abstract|const|enum|extends|final|implements|native|private|'
56
+ r'protected|public|static|strictfp|super|synchronized|throws|'
57
+ r'transient|volatile)\b', Keyword.Declaration),
58
+ (r'(boolean|byte|char|double|float|int|long|short|void)\b',
59
+ Keyword.Type),
60
+ (r'(package)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
61
+ (r'(true|false|null)\b', Keyword.Constant),
62
+ (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text),
63
+ 'class'),
64
+ (r'(var)(\s+)', bygroups(Keyword.Declaration, Text),
65
+ 'var'),
66
+ (r'(import(?:\s+static)?)(\s+)', bygroups(Keyword.Namespace, Text),
67
+ 'import'),
68
+ (r'"', String, 'string'),
69
+ (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
70
+ (r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Punctuation,
71
+ Name.Attribute)),
72
+ (r'^\s*([^\W\d]|\$)[\w$]*:', Name.Label),
73
+ (r'([^\W\d]|\$)[\w$]*', Name),
74
+ (r'([0-9][0-9_]*\.([0-9][0-9_]*)?|'
75
+ r'\.[0-9][0-9_]*)'
76
+ r'([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|'
77
+ r'[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|'
78
+ r'[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|'
79
+ r'0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|'
80
+ r'([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)'
81
+ r'[pP][+\-]?[0-9][0-9_]*[fFdD]?', Number.Float),
82
+ (r'0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?', Number.Hex),
83
+ (r'0[bB][01][01_]*[lL]?', Number.Bin),
84
+ (r'0[0-7_]+[lL]?', Number.Oct),
85
+ (r'0|[1-9][0-9_]*[lL]?', Number.Integer),
86
+ (r'[~^*!%&\[\]<>|+=/?-]', Operator),
87
+ (r'[{}();:.,]', Punctuation),
88
+ (r'\n', Text)
89
+ ],
90
+ 'class': [
91
+ (r'([^\W\d]|\$)[\w$]*', Name.Class, '#pop')
92
+ ],
93
+ 'var': [
94
+ (r'([^\W\d]|\$)[\w$]*', Name, '#pop')
95
+ ],
96
+ 'import': [
97
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
98
+ ],
99
+ 'string': [
100
+ (r'[^\\"]+', String),
101
+ (r'\\\\', String), # Escaped backslash
102
+ (r'\\"', String), # Escaped quote
103
+ (r'\\', String), # Bare backslash
104
+ (r'"', String, '#pop'), # Closing quote
105
+ ],
106
+ }
107
+
108
+
109
+ class AspectJLexer(JavaLexer):
110
+ """
111
+ For `AspectJ <http://www.eclipse.org/aspectj/>`_ source code.
112
+
113
+ .. versionadded:: 1.6
114
+ """
115
+
116
+ name = 'AspectJ'
117
+ aliases = ['aspectj']
118
+ filenames = ['*.aj']
119
+ mimetypes = ['text/x-aspectj']
120
+
121
+ aj_keywords = {
122
+ 'aspect', 'pointcut', 'privileged', 'call', 'execution',
123
+ 'initialization', 'preinitialization', 'handler', 'get', 'set',
124
+ 'staticinitialization', 'target', 'args', 'within', 'withincode',
125
+ 'cflow', 'cflowbelow', 'annotation', 'before', 'after', 'around',
126
+ 'proceed', 'throwing', 'returning', 'adviceexecution', 'declare',
127
+ 'parents', 'warning', 'error', 'soft', 'precedence', 'thisJoinPoint',
128
+ 'thisJoinPointStaticPart', 'thisEnclosingJoinPointStaticPart',
129
+ 'issingleton', 'perthis', 'pertarget', 'percflow', 'percflowbelow',
130
+ 'pertypewithin', 'lock', 'unlock', 'thisAspectInstance'
131
+ }
132
+ aj_inter_type = {'parents:', 'warning:', 'error:', 'soft:', 'precedence:'}
133
+ aj_inter_type_annotation = {'@type', '@method', '@constructor', '@field'}
134
+
135
+ def get_tokens_unprocessed(self, text):
136
+ for index, token, value in JavaLexer.get_tokens_unprocessed(self, text):
137
+ if token is Name and value in self.aj_keywords:
138
+ yield index, Keyword, value
139
+ elif token is Name.Label and value in self.aj_inter_type:
140
+ yield index, Keyword, value[:-1]
141
+ yield index, Operator, value[-1]
142
+ elif token is Name.Decorator and value in self.aj_inter_type_annotation:
143
+ yield index, Keyword, value
144
+ else:
145
+ yield index, token, value
146
+
147
+
148
+ class ScalaLexer(RegexLexer):
149
+ """
150
+ For `Scala <http://www.scala-lang.org>`_ source code.
151
+ """
152
+
153
+ name = 'Scala'
154
+ aliases = ['scala']
155
+ filenames = ['*.scala']
156
+ mimetypes = ['text/x-scala']
157
+
158
+ flags = re.MULTILINE | re.DOTALL
159
+
160
+ # don't use raw unicode strings!
161
+ op = ('[-~\\^\\*!%&\\\\<>\\|+=:/?@\u00a6-\u00a7\u00a9\u00ac\u00ae\u00b0-\u00b1'
162
+ '\u00b6\u00d7\u00f7\u03f6\u0482\u0606-\u0608\u060e-\u060f\u06e9'
163
+ '\u06fd-\u06fe\u07f6\u09fa\u0b70\u0bf3-\u0bf8\u0bfa\u0c7f\u0cf1-\u0cf2'
164
+ '\u0d79\u0f01-\u0f03\u0f13-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38'
165
+ '\u0fbe-\u0fc5\u0fc7-\u0fcf\u109e-\u109f\u1360\u1390-\u1399\u1940'
166
+ '\u19e0-\u19ff\u1b61-\u1b6a\u1b74-\u1b7c\u2044\u2052\u207a-\u207c'
167
+ '\u208a-\u208c\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118'
168
+ '\u211e-\u2123\u2125\u2127\u2129\u212e\u213a-\u213b\u2140-\u2144'
169
+ '\u214a-\u214d\u214f\u2190-\u2328\u232b-\u244a\u249c-\u24e9\u2500-\u2767'
170
+ '\u2794-\u27c4\u27c7-\u27e5\u27f0-\u2982\u2999-\u29d7\u29dc-\u29fb'
171
+ '\u29fe-\u2b54\u2ce5-\u2cea\u2e80-\u2ffb\u3004\u3012-\u3013\u3020'
172
+ '\u3036-\u3037\u303e-\u303f\u3190-\u3191\u3196-\u319f\u31c0-\u31e3'
173
+ '\u3200-\u321e\u322a-\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff'
174
+ '\u4dc0-\u4dff\ua490-\ua4c6\ua828-\ua82b\ufb29\ufdfd\ufe62\ufe64-\ufe66'
175
+ '\uff0b\uff1c-\uff1e\uff5c\uff5e\uffe2\uffe4\uffe8-\uffee\ufffc-\ufffd]+')
176
+
177
+ letter = ('[a-zA-Z\\$_\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6'
178
+ '\u00f8-\u02af\u0370-\u0373\u0376-\u0377\u037b-\u037d\u0386'
179
+ '\u0388-\u03f5\u03f7-\u0481\u048a-\u0556\u0561-\u0587\u05d0-\u05f2'
180
+ '\u0621-\u063f\u0641-\u064a\u066e-\u066f\u0671-\u06d3\u06d5'
181
+ '\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5'
182
+ '\u07b1\u07ca-\u07ea\u0904-\u0939\u093d\u0950\u0958-\u0961'
183
+ '\u0972-\u097f\u0985-\u09b9\u09bd\u09ce\u09dc-\u09e1\u09f0-\u09f1'
184
+ '\u0a05-\u0a39\u0a59-\u0a5e\u0a72-\u0a74\u0a85-\u0ab9\u0abd'
185
+ '\u0ad0-\u0ae1\u0b05-\u0b39\u0b3d\u0b5c-\u0b61\u0b71\u0b83-\u0bb9'
186
+ '\u0bd0\u0c05-\u0c3d\u0c58-\u0c61\u0c85-\u0cb9\u0cbd\u0cde-\u0ce1'
187
+ '\u0d05-\u0d3d\u0d60-\u0d61\u0d7a-\u0d7f\u0d85-\u0dc6\u0e01-\u0e30'
188
+ '\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0eb0\u0eb2-\u0eb3\u0ebd-\u0ec4'
189
+ '\u0edc-\u0f00\u0f40-\u0f6c\u0f88-\u0f8b\u1000-\u102a\u103f'
190
+ '\u1050-\u1055\u105a-\u105d\u1061\u1065-\u1066\u106e-\u1070'
191
+ '\u1075-\u1081\u108e\u10a0-\u10fa\u1100-\u135a\u1380-\u138f'
192
+ '\u13a0-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u16ee-\u1711'
193
+ '\u1720-\u1731\u1740-\u1751\u1760-\u1770\u1780-\u17b3\u17dc'
194
+ '\u1820-\u1842\u1844-\u18a8\u18aa-\u191c\u1950-\u19a9\u19c1-\u19c7'
195
+ '\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae-\u1baf'
196
+ '\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c77\u1d00-\u1d2b\u1d62-\u1d77'
197
+ '\u1d79-\u1d9a\u1e00-\u1fbc\u1fbe\u1fc2-\u1fcc\u1fd0-\u1fdb'
198
+ '\u1fe0-\u1fec\u1ff2-\u1ffc\u2071\u207f\u2102\u2107\u210a-\u2113'
199
+ '\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139'
200
+ '\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c7c'
201
+ '\u2c80-\u2ce4\u2d00-\u2d65\u2d80-\u2dde\u3006-\u3007\u3021-\u3029'
202
+ '\u3038-\u303a\u303c\u3041-\u3096\u309f\u30a1-\u30fa\u30ff-\u318e'
203
+ '\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\ua014\ua016-\ua48c'
204
+ '\ua500-\ua60b\ua610-\ua61f\ua62a-\ua66e\ua680-\ua697\ua722-\ua76f'
205
+ '\ua771-\ua787\ua78b-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822'
206
+ '\ua840-\ua873\ua882-\ua8b3\ua90a-\ua925\ua930-\ua946\uaa00-\uaa28'
207
+ '\uaa40-\uaa42\uaa44-\uaa4b\uac00-\ud7a3\uf900-\ufb1d\ufb1f-\ufb28'
208
+ '\ufb2a-\ufd3d\ufd50-\ufdfb\ufe70-\ufefc\uff21-\uff3a\uff41-\uff5a'
209
+ '\uff66-\uff6f\uff71-\uff9d\uffa0-\uffdc]')
210
+
211
+ upper = ('[A-Z\\$_\u00c0-\u00d6\u00d8-\u00de\u0100\u0102\u0104\u0106\u0108'
212
+ '\u010a\u010c\u010e\u0110\u0112\u0114\u0116\u0118\u011a\u011c'
213
+ '\u011e\u0120\u0122\u0124\u0126\u0128\u012a\u012c\u012e\u0130'
214
+ '\u0132\u0134\u0136\u0139\u013b\u013d\u013f\u0141\u0143\u0145'
215
+ '\u0147\u014a\u014c\u014e\u0150\u0152\u0154\u0156\u0158\u015a'
216
+ '\u015c\u015e\u0160\u0162\u0164\u0166\u0168\u016a\u016c\u016e'
217
+ '\u0170\u0172\u0174\u0176\u0178-\u0179\u017b\u017d\u0181-\u0182'
218
+ '\u0184\u0186-\u0187\u0189-\u018b\u018e-\u0191\u0193-\u0194'
219
+ '\u0196-\u0198\u019c-\u019d\u019f-\u01a0\u01a2\u01a4\u01a6-\u01a7'
220
+ '\u01a9\u01ac\u01ae-\u01af\u01b1-\u01b3\u01b5\u01b7-\u01b8\u01bc'
221
+ '\u01c4\u01c7\u01ca\u01cd\u01cf\u01d1\u01d3\u01d5\u01d7\u01d9'
222
+ '\u01db\u01de\u01e0\u01e2\u01e4\u01e6\u01e8\u01ea\u01ec\u01ee'
223
+ '\u01f1\u01f4\u01f6-\u01f8\u01fa\u01fc\u01fe\u0200\u0202\u0204'
224
+ '\u0206\u0208\u020a\u020c\u020e\u0210\u0212\u0214\u0216\u0218'
225
+ '\u021a\u021c\u021e\u0220\u0222\u0224\u0226\u0228\u022a\u022c'
226
+ '\u022e\u0230\u0232\u023a-\u023b\u023d-\u023e\u0241\u0243-\u0246'
227
+ '\u0248\u024a\u024c\u024e\u0370\u0372\u0376\u0386\u0388-\u038f'
228
+ '\u0391-\u03ab\u03cf\u03d2-\u03d4\u03d8\u03da\u03dc\u03de\u03e0'
229
+ '\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7'
230
+ '\u03f9-\u03fa\u03fd-\u042f\u0460\u0462\u0464\u0466\u0468\u046a'
231
+ '\u046c\u046e\u0470\u0472\u0474\u0476\u0478\u047a\u047c\u047e'
232
+ '\u0480\u048a\u048c\u048e\u0490\u0492\u0494\u0496\u0498\u049a'
233
+ '\u049c\u049e\u04a0\u04a2\u04a4\u04a6\u04a8\u04aa\u04ac\u04ae'
234
+ '\u04b0\u04b2\u04b4\u04b6\u04b8\u04ba\u04bc\u04be\u04c0-\u04c1'
235
+ '\u04c3\u04c5\u04c7\u04c9\u04cb\u04cd\u04d0\u04d2\u04d4\u04d6'
236
+ '\u04d8\u04da\u04dc\u04de\u04e0\u04e2\u04e4\u04e6\u04e8\u04ea'
237
+ '\u04ec\u04ee\u04f0\u04f2\u04f4\u04f6\u04f8\u04fa\u04fc\u04fe'
238
+ '\u0500\u0502\u0504\u0506\u0508\u050a\u050c\u050e\u0510\u0512'
239
+ '\u0514\u0516\u0518\u051a\u051c\u051e\u0520\u0522\u0531-\u0556'
240
+ '\u10a0-\u10c5\u1e00\u1e02\u1e04\u1e06\u1e08\u1e0a\u1e0c\u1e0e'
241
+ '\u1e10\u1e12\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1e1e\u1e20\u1e22'
242
+ '\u1e24\u1e26\u1e28\u1e2a\u1e2c\u1e2e\u1e30\u1e32\u1e34\u1e36'
243
+ '\u1e38\u1e3a\u1e3c\u1e3e\u1e40\u1e42\u1e44\u1e46\u1e48\u1e4a'
244
+ '\u1e4c\u1e4e\u1e50\u1e52\u1e54\u1e56\u1e58\u1e5a\u1e5c\u1e5e'
245
+ '\u1e60\u1e62\u1e64\u1e66\u1e68\u1e6a\u1e6c\u1e6e\u1e70\u1e72'
246
+ '\u1e74\u1e76\u1e78\u1e7a\u1e7c\u1e7e\u1e80\u1e82\u1e84\u1e86'
247
+ '\u1e88\u1e8a\u1e8c\u1e8e\u1e90\u1e92\u1e94\u1e9e\u1ea0\u1ea2'
248
+ '\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6'
249
+ '\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6\u1ec8\u1eca'
250
+ '\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede'
251
+ '\u1ee0\u1ee2\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0\u1ef2'
252
+ '\u1ef4\u1ef6\u1ef8\u1efa\u1efc\u1efe\u1f08-\u1f0f\u1f18-\u1f1d'
253
+ '\u1f28-\u1f2f\u1f38-\u1f3f\u1f48-\u1f4d\u1f59-\u1f5f'
254
+ '\u1f68-\u1f6f\u1fb8-\u1fbb\u1fc8-\u1fcb\u1fd8-\u1fdb'
255
+ '\u1fe8-\u1fec\u1ff8-\u1ffb\u2102\u2107\u210b-\u210d\u2110-\u2112'
256
+ '\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u2130-\u2133'
257
+ '\u213e-\u213f\u2145\u2183\u2c00-\u2c2e\u2c60\u2c62-\u2c64\u2c67'
258
+ '\u2c69\u2c6b\u2c6d-\u2c6f\u2c72\u2c75\u2c80\u2c82\u2c84\u2c86'
259
+ '\u2c88\u2c8a\u2c8c\u2c8e\u2c90\u2c92\u2c94\u2c96\u2c98\u2c9a'
260
+ '\u2c9c\u2c9e\u2ca0\u2ca2\u2ca4\u2ca6\u2ca8\u2caa\u2cac\u2cae'
261
+ '\u2cb0\u2cb2\u2cb4\u2cb6\u2cb8\u2cba\u2cbc\u2cbe\u2cc0\u2cc2'
262
+ '\u2cc4\u2cc6\u2cc8\u2cca\u2ccc\u2cce\u2cd0\u2cd2\u2cd4\u2cd6'
263
+ '\u2cd8\u2cda\u2cdc\u2cde\u2ce0\u2ce2\ua640\ua642\ua644\ua646'
264
+ '\ua648\ua64a\ua64c\ua64e\ua650\ua652\ua654\ua656\ua658\ua65a'
265
+ '\ua65c\ua65e\ua662\ua664\ua666\ua668\ua66a\ua66c\ua680\ua682'
266
+ '\ua684\ua686\ua688\ua68a\ua68c\ua68e\ua690\ua692\ua694\ua696'
267
+ '\ua722\ua724\ua726\ua728\ua72a\ua72c\ua72e\ua732\ua734\ua736'
268
+ '\ua738\ua73a\ua73c\ua73e\ua740\ua742\ua744\ua746\ua748\ua74a'
269
+ '\ua74c\ua74e\ua750\ua752\ua754\ua756\ua758\ua75a\ua75c\ua75e'
270
+ '\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b'
271
+ '\ua77d-\ua77e\ua780\ua782\ua784\ua786\ua78b\uff21-\uff3a]')
272
+
273
+ idrest = '%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op)
274
+ letter_letter_digit = '%s(?:%s|\\d)*' % (letter, letter)
275
+
276
+ tokens = {
277
+ 'root': [
278
+ # method names
279
+ (r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'),
280
+ (r'[^\S\n]+', Text),
281
+ include('comments'),
282
+ (r'@%s' % idrest, Name.Decorator),
283
+ (r'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|'
284
+ r'f(?:inal(?:ly)?|or(?:Some)?)|i(?:f|mplicit)|'
285
+ r'lazy|match|new|override|pr(?:ivate|otected)'
286
+ r'|re(?:quires|turn)|s(?:ealed|uper)|'
287
+ r't(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\b|'
288
+ r'(<[%:-]|=>|>:|[#=@_\u21D2\u2190])\b', Keyword),
289
+ (r':(?!%s)' % op, Keyword, 'type'),
290
+ (r'%s%s\b' % (upper, idrest), Name.Class),
291
+ (r'(true|false|null)\b', Keyword.Constant),
292
+ (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
293
+ (r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
294
+ (r'""".*?"""(?!")', String),
295
+ (r'"(\\\\|\\"|[^"])*"', String),
296
+ (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
297
+ (r"'%s" % idrest, Text.Symbol),
298
+ (r'[fs]"""', String, 'interptriplestring'), # interpolated strings
299
+ (r'[fs]"', String, 'interpstring'), # interpolated strings
300
+ (r'raw"(\\\\|\\"|[^"])*"', String), # raw strings
301
+ # (r'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
302
+ # Name.Attribute)),
303
+ (idrest, Name),
304
+ (r'`[^`]+`', Name),
305
+ (r'\[', Operator, 'typeparam'),
306
+ (r'[(){};,.#]', Operator),
307
+ (op, Operator),
308
+ (r'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?',
309
+ Number.Float),
310
+ (r'0x[0-9a-fA-F]+', Number.Hex),
311
+ (r'[0-9]+L?', Number.Integer),
312
+ (r'\n', Text)
313
+ ],
314
+ 'class': [
315
+ (r'(%s|%s|`[^`]+`)(\s*)(\[)' % (idrest, op),
316
+ bygroups(Name.Class, Text, Operator), ('#pop', 'typeparam')),
317
+ (r'\s+', Text),
318
+ include('comments'),
319
+ (r'\{', Operator, '#pop'),
320
+ (r'\(', Operator, '#pop'),
321
+ (r'%s|%s|`[^`]+`' % (idrest, op), Name.Class, '#pop'),
322
+ ],
323
+ 'type': [
324
+ (r'\s+', Text),
325
+ include('comments'),
326
+ (r'<[%:]|>:|[#_]|\bforSome\b|\btype\b', Keyword),
327
+ (r'([,);}]|=>|=|\u21d2)(\s*)', bygroups(Operator, Text), '#pop'),
328
+ (r'[({]', Operator, '#push'),
329
+ (r'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)(\[)' %
330
+ (idrest, op, idrest, op),
331
+ bygroups(Keyword.Type, Text, Operator), ('#pop', 'typeparam')),
332
+ (r'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)$' %
333
+ (idrest, op, idrest, op),
334
+ bygroups(Keyword.Type, Text), '#pop'),
335
+ (r'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
336
+ ],
337
+ 'typeparam': [
338
+ (r'\s+', Text),
339
+ include('comments'),
340
+ (r',+', Punctuation),
341
+ (r'<[%:]|=>|>:|[#_\u21D2]|\bforSome\b|\btype\b', Keyword),
342
+ (r'([\])}])', Operator, '#pop'),
343
+ (r'[(\[{]', Operator, '#push'),
344
+ (r'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
345
+ ],
346
+ 'comments': [
347
+ (r'//.*?\n', Comment.Single),
348
+ (r'/\*', Comment.Multiline, 'comment'),
349
+ ],
350
+ 'comment': [
351
+ (r'[^/*]+', Comment.Multiline),
352
+ (r'/\*', Comment.Multiline, '#push'),
353
+ (r'\*/', Comment.Multiline, '#pop'),
354
+ (r'[*/]', Comment.Multiline)
355
+ ],
356
+ 'import': [
357
+ (r'(%s|\.)+' % idrest, Name.Namespace, '#pop')
358
+ ],
359
+ 'interpstringcommon': [
360
+ (r'[^"$\\]+', String),
361
+ (r'\$\$', String),
362
+ (r'\$' + letter_letter_digit, String.Interpol),
363
+ (r'\$\{', String.Interpol, 'interpbrace'),
364
+ (r'\\.', String),
365
+ ],
366
+ 'interptriplestring': [
367
+ (r'"""(?!")', String, '#pop'),
368
+ (r'"', String),
369
+ include('interpstringcommon'),
370
+ ],
371
+ 'interpstring': [
372
+ (r'"', String, '#pop'),
373
+ include('interpstringcommon'),
374
+ ],
375
+ 'interpbrace': [
376
+ (r'\}', String.Interpol, '#pop'),
377
+ (r'\{', String.Interpol, '#push'),
378
+ include('root'),
379
+ ],
380
+ }
381
+
382
+
383
+ class GosuLexer(RegexLexer):
384
+ """
385
+ For Gosu source code.
386
+
387
+ .. versionadded:: 1.5
388
+ """
389
+
390
+ name = 'Gosu'
391
+ aliases = ['gosu']
392
+ filenames = ['*.gs', '*.gsx', '*.gsp', '*.vark']
393
+ mimetypes = ['text/x-gosu']
394
+
395
+ flags = re.MULTILINE | re.DOTALL
396
+
397
+ tokens = {
398
+ 'root': [
399
+ # method names
400
+ (r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # modifiers etc.
401
+ r'([a-zA-Z_]\w*)' # method name
402
+ r'(\s*)(\()', # signature start
403
+ bygroups(using(this), Name.Function, Text, Operator)),
404
+ (r'[^\S\n]+', Text),
405
+ (r'//.*?\n', Comment.Single),
406
+ (r'/\*.*?\*/', Comment.Multiline),
407
+ (r'@[a-zA-Z_][\w.]*', Name.Decorator),
408
+ (r'(in|as|typeof|statictypeof|typeis|typeas|if|else|foreach|for|'
409
+ r'index|while|do|continue|break|return|try|catch|finally|this|'
410
+ r'throw|new|switch|case|default|eval|super|outer|classpath|'
411
+ r'using)\b', Keyword),
412
+ (r'(var|delegate|construct|function|private|internal|protected|'
413
+ r'public|abstract|override|final|static|extends|transient|'
414
+ r'implements|represents|readonly)\b', Keyword.Declaration),
415
+ (r'(property\s+)(get|set)?', Keyword.Declaration),
416
+ (r'(boolean|byte|char|double|float|int|long|short|void|block)\b',
417
+ Keyword.Type),
418
+ (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
419
+ (r'(true|false|null|NaN|Infinity)\b', Keyword.Constant),
420
+ (r'(class|interface|enhancement|enum)(\s+)([a-zA-Z_]\w*)',
421
+ bygroups(Keyword.Declaration, Text, Name.Class)),
422
+ (r'(uses)(\s+)([\w.]+\*?)',
423
+ bygroups(Keyword.Namespace, Text, Name.Namespace)),
424
+ (r'"', String, 'string'),
425
+ (r'(\??[.#])([a-zA-Z_]\w*)',
426
+ bygroups(Operator, Name.Attribute)),
427
+ (r'(:)([a-zA-Z_]\w*)',
428
+ bygroups(Operator, Name.Attribute)),
429
+ (r'[a-zA-Z_$]\w*', Name),
430
+ (r'and|or|not|[\\~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
431
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
432
+ (r'[0-9]+', Number.Integer),
433
+ (r'\n', Text)
434
+ ],
435
+ 'templateText': [
436
+ (r'(\\<)|(\\\$)', String),
437
+ (r'(<%@\s+)(extends|params)',
438
+ bygroups(Operator, Name.Decorator), 'stringTemplate'),
439
+ (r'<%!--.*?--%>', Comment.Multiline),
440
+ (r'(<%)|(<%=)', Operator, 'stringTemplate'),
441
+ (r'\$\{', Operator, 'stringTemplateShorthand'),
442
+ (r'.', String)
443
+ ],
444
+ 'string': [
445
+ (r'"', String, '#pop'),
446
+ include('templateText')
447
+ ],
448
+ 'stringTemplate': [
449
+ (r'"', String, 'string'),
450
+ (r'%>', Operator, '#pop'),
451
+ include('root')
452
+ ],
453
+ 'stringTemplateShorthand': [
454
+ (r'"', String, 'string'),
455
+ (r'\{', Operator, 'stringTemplateShorthand'),
456
+ (r'\}', Operator, '#pop'),
457
+ include('root')
458
+ ],
459
+ }
460
+
461
+
462
+ class GosuTemplateLexer(Lexer):
463
+ """
464
+ For Gosu templates.
465
+
466
+ .. versionadded:: 1.5
467
+ """
468
+
469
+ name = 'Gosu Template'
470
+ aliases = ['gst']
471
+ filenames = ['*.gst']
472
+ mimetypes = ['text/x-gosu-template']
473
+
474
+ def get_tokens_unprocessed(self, text):
475
+ lexer = GosuLexer()
476
+ stack = ['templateText']
477
+ yield from lexer.get_tokens_unprocessed(text, stack)
478
+
479
+
480
+ class GroovyLexer(RegexLexer):
481
+ """
482
+ For `Groovy <http://groovy.codehaus.org/>`_ source code.
483
+
484
+ .. versionadded:: 1.5
485
+ """
486
+
487
+ name = 'Groovy'
488
+ aliases = ['groovy']
489
+ filenames = ['*.groovy','*.gradle']
490
+ mimetypes = ['text/x-groovy']
491
+
492
+ flags = re.MULTILINE | re.DOTALL
493
+
494
+ tokens = {
495
+ 'root': [
496
+ # Groovy allows a file to start with a shebang
497
+ (r'#!(.*?)$', Comment.Preproc, 'base'),
498
+ default('base'),
499
+ ],
500
+ 'base': [
501
+ # method names
502
+ (r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
503
+ r'([a-zA-Z_]\w*)' # method name
504
+ r'(\s*)(\()', # signature start
505
+ bygroups(using(this), Name.Function, Text, Operator)),
506
+ (r'[^\S\n]+', Text),
507
+ (r'//.*?\n', Comment.Single),
508
+ (r'/\*.*?\*/', Comment.Multiline),
509
+ (r'@[a-zA-Z_][\w.]*', Name.Decorator),
510
+ (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
511
+ r'if|goto|instanceof|new|return|switch|this|throw|try|while|in|as)\b',
512
+ Keyword),
513
+ (r'(abstract|const|enum|extends|final|implements|native|private|'
514
+ r'protected|public|static|strictfp|super|synchronized|throws|'
515
+ r'transient|volatile)\b', Keyword.Declaration),
516
+ (r'(def|boolean|byte|char|double|float|int|long|short|void)\b',
517
+ Keyword.Type),
518
+ (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
519
+ (r'(true|false|null)\b', Keyword.Constant),
520
+ (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text),
521
+ 'class'),
522
+ (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
523
+ (r'""".*?"""', String.Double),
524
+ (r"'''.*?'''", String.Single),
525
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
526
+ (r"'(\\\\|\\'|[^'])*'", String.Single),
527
+ (r'\$/((?!/\$).)*/\$', String),
528
+ (r'/(\\\\|\\"|[^/])*/', String),
529
+ (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
530
+ (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
531
+ (r'[a-zA-Z_]\w*:', Name.Label),
532
+ (r'[a-zA-Z_$]\w*', Name),
533
+ (r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
534
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
535
+ (r'0x[0-9a-fA-F]+', Number.Hex),
536
+ (r'[0-9]+L?', Number.Integer),
537
+ (r'\n', Text)
538
+ ],
539
+ 'class': [
540
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
541
+ ],
542
+ 'import': [
543
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
544
+ ],
545
+ }
546
+
547
+ def analyse_text(text):
548
+ return shebang_matches(text, r'groovy')
549
+
550
+
551
+ class IokeLexer(RegexLexer):
552
+ """
553
+ For `Ioke <http://ioke.org/>`_ (a strongly typed, dynamic,
554
+ prototype based programming language) source.
555
+
556
+ .. versionadded:: 1.4
557
+ """
558
+ name = 'Ioke'
559
+ filenames = ['*.ik']
560
+ aliases = ['ioke', 'ik']
561
+ mimetypes = ['text/x-iokesrc']
562
+ tokens = {
563
+ 'interpolatableText': [
564
+ (r'(\\b|\\e|\\t|\\n|\\f|\\r|\\"|\\\\|\\#|\\\Z|\\u[0-9a-fA-F]{1,4}'
565
+ r'|\\[0-3]?[0-7]?[0-7])', String.Escape),
566
+ (r'#\{', Punctuation, 'textInterpolationRoot')
567
+ ],
568
+
569
+ 'text': [
570
+ (r'(?<!\\)"', String, '#pop'),
571
+ include('interpolatableText'),
572
+ (r'[^"]', String)
573
+ ],
574
+
575
+ 'documentation': [
576
+ (r'(?<!\\)"', String.Doc, '#pop'),
577
+ include('interpolatableText'),
578
+ (r'[^"]', String.Doc)
579
+ ],
580
+
581
+ 'textInterpolationRoot': [
582
+ (r'\}', Punctuation, '#pop'),
583
+ include('root')
584
+ ],
585
+
586
+ 'slashRegexp': [
587
+ (r'(?<!\\)/[im-psux]*', String.Regex, '#pop'),
588
+ include('interpolatableText'),
589
+ (r'\\/', String.Regex),
590
+ (r'[^/]', String.Regex)
591
+ ],
592
+
593
+ 'squareRegexp': [
594
+ (r'(?<!\\)][im-psux]*', String.Regex, '#pop'),
595
+ include('interpolatableText'),
596
+ (r'\\]', String.Regex),
597
+ (r'[^\]]', String.Regex)
598
+ ],
599
+
600
+ 'squareText': [
601
+ (r'(?<!\\)]', String, '#pop'),
602
+ include('interpolatableText'),
603
+ (r'[^\]]', String)
604
+ ],
605
+
606
+ 'root': [
607
+ (r'\n', Text),
608
+ (r'\s+', Text),
609
+
610
+ # Comments
611
+ (r';(.*?)\n', Comment),
612
+ (r'\A#!(.*?)\n', Comment),
613
+
614
+ # Regexps
615
+ (r'#/', String.Regex, 'slashRegexp'),
616
+ (r'#r\[', String.Regex, 'squareRegexp'),
617
+
618
+ # Symbols
619
+ (r':[\w!:?]+', String.Symbol),
620
+ (r'[\w!:?]+:(?![\w!?])', String.Other),
621
+ (r':"(\\\\|\\"|[^"])*"', String.Symbol),
622
+
623
+ # Documentation
624
+ (r'((?<=fn\()|(?<=fnx\()|(?<=method\()|(?<=macro\()|(?<=lecro\()'
625
+ r'|(?<=syntax\()|(?<=dmacro\()|(?<=dlecro\()|(?<=dlecrox\()'
626
+ r'|(?<=dsyntax\())\s*"', String.Doc, 'documentation'),
627
+
628
+ # Text
629
+ (r'"', String, 'text'),
630
+ (r'#\[', String, 'squareText'),
631
+
632
+ # Mimic
633
+ (r'\w[\w!:?]+(?=\s*=.*mimic\s)', Name.Entity),
634
+
635
+ # Assignment
636
+ (r'[a-zA-Z_][\w!:?]*(?=[\s]*[+*/-]?=[^=].*($|\.))',
637
+ Name.Variable),
638
+
639
+ # keywords
640
+ (r'(break|cond|continue|do|ensure|for|for:dict|for:set|if|let|'
641
+ r'loop|p:for|p:for:dict|p:for:set|return|unless|until|while|'
642
+ r'with)(?![\w!:?])', Keyword.Reserved),
643
+
644
+ # Origin
645
+ (r'(eval|mimic|print|println)(?![\w!:?])', Keyword),
646
+
647
+ # Base
648
+ (r'(cell\?|cellNames|cellOwner\?|cellOwner|cells|cell|'
649
+ r'documentation|hash|identity|mimic|removeCell\!|undefineCell\!)'
650
+ r'(?![\w!:?])', Keyword),
651
+
652
+ # Ground
653
+ (r'(stackTraceAsText)(?![\w!:?])', Keyword),
654
+
655
+ # DefaultBehaviour Literals
656
+ (r'(dict|list|message|set)(?![\w!:?])', Keyword.Reserved),
657
+
658
+ # DefaultBehaviour Case
659
+ (r'(case|case:and|case:else|case:nand|case:nor|case:not|case:or|'
660
+ r'case:otherwise|case:xor)(?![\w!:?])', Keyword.Reserved),
661
+
662
+ # DefaultBehaviour Reflection
663
+ (r'(asText|become\!|derive|freeze\!|frozen\?|in\?|is\?|kind\?|'
664
+ r'mimic\!|mimics|mimics\?|prependMimic\!|removeAllMimics\!|'
665
+ r'removeMimic\!|same\?|send|thaw\!|uniqueHexId)'
666
+ r'(?![\w!:?])', Keyword),
667
+
668
+ # DefaultBehaviour Aspects
669
+ (r'(after|around|before)(?![\w!:?])', Keyword.Reserved),
670
+
671
+ # DefaultBehaviour
672
+ (r'(kind|cellDescriptionDict|cellSummary|genSym|inspect|notice)'
673
+ r'(?![\w!:?])', Keyword),
674
+ (r'(use|destructuring)', Keyword.Reserved),
675
+
676
+ # DefaultBehavior BaseBehavior
677
+ (r'(cell\?|cellOwner\?|cellOwner|cellNames|cells|cell|'
678
+ r'documentation|identity|removeCell!|undefineCell)'
679
+ r'(?![\w!:?])', Keyword),
680
+
681
+ # DefaultBehavior Internal
682
+ (r'(internal:compositeRegexp|internal:concatenateText|'
683
+ r'internal:createDecimal|internal:createNumber|'
684
+ r'internal:createRegexp|internal:createText)'
685
+ r'(?![\w!:?])', Keyword.Reserved),
686
+
687
+ # DefaultBehaviour Conditions
688
+ (r'(availableRestarts|bind|error\!|findRestart|handle|'
689
+ r'invokeRestart|rescue|restart|signal\!|warn\!)'
690
+ r'(?![\w!:?])', Keyword.Reserved),
691
+
692
+ # constants
693
+ (r'(nil|false|true)(?![\w!:?])', Name.Constant),
694
+
695
+ # names
696
+ (r'(Arity|Base|Call|Condition|DateTime|Aspects|Pointcut|'
697
+ r'Assignment|BaseBehavior|Boolean|Case|AndCombiner|Else|'
698
+ r'NAndCombiner|NOrCombiner|NotCombiner|OrCombiner|XOrCombiner|'
699
+ r'Conditions|Definitions|FlowControl|Internal|Literals|'
700
+ r'Reflection|DefaultMacro|DefaultMethod|DefaultSyntax|Dict|'
701
+ r'FileSystem|Ground|Handler|Hook|IO|IokeGround|Struct|'
702
+ r'LexicalBlock|LexicalMacro|List|Message|Method|Mixins|'
703
+ r'NativeMethod|Number|Origin|Pair|Range|Reflector|Regexp Match|'
704
+ r'Regexp|Rescue|Restart|Runtime|Sequence|Set|Symbol|'
705
+ r'System|Text|Tuple)(?![\w!:?])', Name.Builtin),
706
+
707
+ # functions
708
+ ('(generateMatchMethod|aliasMethod|\u03bb|\u028E|fnx|fn|method|'
709
+ 'dmacro|dlecro|syntax|macro|dlecrox|lecrox|lecro|syntax)'
710
+ '(?![\\w!:?])', Name.Function),
711
+
712
+ # Numbers
713
+ (r'-?0[xX][0-9a-fA-F]+', Number.Hex),
714
+ (r'-?(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
715
+ (r'-?\d+', Number.Integer),
716
+
717
+ (r'#\(', Punctuation),
718
+
719
+ # Operators
720
+ (r'(&&>>|\|\|>>|\*\*>>|:::|::|\.\.\.|===|\*\*>|\*\*=|&&>|&&=|'
721
+ r'\|\|>|\|\|=|\->>|\+>>|!>>|<>>>|<>>|&>>|%>>|#>>|@>>|/>>|\*>>|'
722
+ r'\?>>|\|>>|\^>>|~>>|\$>>|=>>|<<=|>>=|<=>|<\->|=~|!~|=>|\+\+|'
723
+ r'\-\-|<=|>=|==|!=|&&|\.\.|\+=|\-=|\*=|\/=|%=|&=|\^=|\|=|<\-|'
724
+ r'\+>|!>|<>|&>|%>|#>|\@>|\/>|\*>|\?>|\|>|\^>|~>|\$>|<\->|\->|'
725
+ r'<<|>>|\*\*|\?\||\?&|\|\||>|<|\*|\/|%|\+|\-|&|\^|\||=|\$|!|~|'
726
+ r'\?|#|\u2260|\u2218|\u2208|\u2209)', Operator),
727
+ (r'(and|nand|or|xor|nor|return|import)(?![\w!?])',
728
+ Operator),
729
+
730
+ # Punctuation
731
+ (r'(\`\`|\`|\'\'|\'|\.|\,|@@|@|\[|\]|\(|\)|\{|\})', Punctuation),
732
+
733
+ # kinds
734
+ (r'[A-Z][\w!:?]*', Name.Class),
735
+
736
+ # default cellnames
737
+ (r'[a-z_][\w!:?]*', Name)
738
+ ]
739
+ }
740
+
741
+
742
+ class ClojureLexer(RegexLexer):
743
+ """
744
+ Lexer for `Clojure <http://clojure.org/>`_ source code.
745
+
746
+ .. versionadded:: 0.11
747
+ """
748
+ name = 'Clojure'
749
+ aliases = ['clojure', 'clj']
750
+ filenames = ['*.clj']
751
+ mimetypes = ['text/x-clojure', 'application/x-clojure']
752
+
753
+ special_forms = (
754
+ '.', 'def', 'do', 'fn', 'if', 'let', 'new', 'quote', 'var', 'loop'
755
+ )
756
+
757
+ # It's safe to consider 'ns' a declaration thing because it defines a new
758
+ # namespace.
759
+ declarations = (
760
+ 'def-', 'defn', 'defn-', 'defmacro', 'defmulti', 'defmethod',
761
+ 'defstruct', 'defonce', 'declare', 'definline', 'definterface',
762
+ 'defprotocol', 'defrecord', 'deftype', 'defproject', 'ns'
763
+ )
764
+
765
+ builtins = (
766
+ '*', '+', '-', '->', '/', '<', '<=', '=', '==', '>', '>=', '..',
767
+ 'accessor', 'agent', 'agent-errors', 'aget', 'alength', 'all-ns',
768
+ 'alter', 'and', 'append-child', 'apply', 'array-map', 'aset',
769
+ 'aset-boolean', 'aset-byte', 'aset-char', 'aset-double', 'aset-float',
770
+ 'aset-int', 'aset-long', 'aset-short', 'assert', 'assoc', 'await',
771
+ 'await-for', 'bean', 'binding', 'bit-and', 'bit-not', 'bit-or',
772
+ 'bit-shift-left', 'bit-shift-right', 'bit-xor', 'boolean', 'branch?',
773
+ 'butlast', 'byte', 'cast', 'char', 'children', 'class',
774
+ 'clear-agent-errors', 'comment', 'commute', 'comp', 'comparator',
775
+ 'complement', 'concat', 'conj', 'cons', 'constantly', 'cond', 'if-not',
776
+ 'construct-proxy', 'contains?', 'count', 'create-ns', 'create-struct',
777
+ 'cycle', 'dec', 'deref', 'difference', 'disj', 'dissoc', 'distinct',
778
+ 'doall', 'doc', 'dorun', 'doseq', 'dosync', 'dotimes', 'doto',
779
+ 'double', 'down', 'drop', 'drop-while', 'edit', 'end?', 'ensure',
780
+ 'eval', 'every?', 'false?', 'ffirst', 'file-seq', 'filter', 'find',
781
+ 'find-doc', 'find-ns', 'find-var', 'first', 'float', 'flush', 'for',
782
+ 'fnseq', 'frest', 'gensym', 'get-proxy-class', 'get',
783
+ 'hash-map', 'hash-set', 'identical?', 'identity', 'if-let', 'import',
784
+ 'in-ns', 'inc', 'index', 'insert-child', 'insert-left', 'insert-right',
785
+ 'inspect-table', 'inspect-tree', 'instance?', 'int', 'interleave',
786
+ 'intersection', 'into', 'into-array', 'iterate', 'join', 'key', 'keys',
787
+ 'keyword', 'keyword?', 'last', 'lazy-cat', 'lazy-cons', 'left',
788
+ 'lefts', 'line-seq', 'list*', 'list', 'load', 'load-file',
789
+ 'locking', 'long', 'loop', 'macroexpand', 'macroexpand-1',
790
+ 'make-array', 'make-node', 'map', 'map-invert', 'map?', 'mapcat',
791
+ 'max', 'max-key', 'memfn', 'merge', 'merge-with', 'meta', 'min',
792
+ 'min-key', 'name', 'namespace', 'neg?', 'new', 'newline', 'next',
793
+ 'nil?', 'node', 'not', 'not-any?', 'not-every?', 'not=', 'ns-imports',
794
+ 'ns-interns', 'ns-map', 'ns-name', 'ns-publics', 'ns-refers',
795
+ 'ns-resolve', 'ns-unmap', 'nth', 'nthrest', 'or', 'parse', 'partial',
796
+ 'path', 'peek', 'pop', 'pos?', 'pr', 'pr-str', 'print', 'print-str',
797
+ 'println', 'println-str', 'prn', 'prn-str', 'project', 'proxy',
798
+ 'proxy-mappings', 'quot', 'rand', 'rand-int', 'range', 're-find',
799
+ 're-groups', 're-matcher', 're-matches', 're-pattern', 're-seq',
800
+ 'read', 'read-line', 'reduce', 'ref', 'ref-set', 'refer', 'rem',
801
+ 'remove', 'remove-method', 'remove-ns', 'rename', 'rename-keys',
802
+ 'repeat', 'replace', 'replicate', 'resolve', 'rest', 'resultset-seq',
803
+ 'reverse', 'rfirst', 'right', 'rights', 'root', 'rrest', 'rseq',
804
+ 'second', 'select', 'select-keys', 'send', 'send-off', 'seq',
805
+ 'seq-zip', 'seq?', 'set', 'short', 'slurp', 'some', 'sort',
806
+ 'sort-by', 'sorted-map', 'sorted-map-by', 'sorted-set',
807
+ 'special-symbol?', 'split-at', 'split-with', 'str', 'string?',
808
+ 'struct', 'struct-map', 'subs', 'subvec', 'symbol', 'symbol?',
809
+ 'sync', 'take', 'take-nth', 'take-while', 'test', 'time', 'to-array',
810
+ 'to-array-2d', 'tree-seq', 'true?', 'union', 'up', 'update-proxy',
811
+ 'val', 'vals', 'var-get', 'var-set', 'var?', 'vector', 'vector-zip',
812
+ 'vector?', 'when', 'when-first', 'when-let', 'when-not',
813
+ 'with-local-vars', 'with-meta', 'with-open', 'with-out-str',
814
+ 'xml-seq', 'xml-zip', 'zero?', 'zipmap', 'zipper')
815
+
816
+ # valid names for identifiers
817
+ # well, names can only not consist fully of numbers
818
+ # but this should be good enough for now
819
+
820
+ # TODO / should divide keywords/symbols into namespace/rest
821
+ # but that's hard, so just pretend / is part of the name
822
+ valid_name = r'(?!#)[\w!$%*+<=>?/.#|-]+'
823
+
824
+ tokens = {
825
+ 'root': [
826
+ # the comments - always starting with semicolon
827
+ # and going to the end of the line
828
+ (r';.*$', Comment.Single),
829
+
830
+ # whitespaces - usually not relevant
831
+ (r'[,\s]+', Text),
832
+
833
+ # numbers
834
+ (r'-?\d+\.\d+', Number.Float),
835
+ (r'-?\d+', Number.Integer),
836
+ (r'0x-?[abcdef\d]+', Number.Hex),
837
+
838
+ # strings, symbols and characters
839
+ (r'"(\\\\|\\"|[^"])*"', String),
840
+ (r"'" + valid_name, String.Symbol),
841
+ (r"\\(.|[a-z]+)", String.Char),
842
+
843
+ # keywords
844
+ (r'::?#?' + valid_name, String.Symbol),
845
+
846
+ # special operators
847
+ (r'~@|[`\'#^~&@]', Operator),
848
+
849
+ # highlight the special forms
850
+ (words(special_forms, suffix=' '), Keyword),
851
+
852
+ # Technically, only the special forms are 'keywords'. The problem
853
+ # is that only treating them as keywords means that things like
854
+ # 'defn' and 'ns' need to be highlighted as builtins. This is ugly
855
+ # and weird for most styles. So, as a compromise we're going to
856
+ # highlight them as Keyword.Declarations.
857
+ (words(declarations, suffix=' '), Keyword.Declaration),
858
+
859
+ # highlight the builtins
860
+ (words(builtins, suffix=' '), Name.Builtin),
861
+
862
+ # the remaining functions
863
+ (r'(?<=\()' + valid_name, Name.Function),
864
+
865
+ # find the remaining variables
866
+ (valid_name, Name.Variable),
867
+
868
+ # Clojure accepts vector notation
869
+ (r'(\[|\])', Punctuation),
870
+
871
+ # Clojure accepts map notation
872
+ (r'(\{|\})', Punctuation),
873
+
874
+ # the famous parentheses!
875
+ (r'(\(|\))', Punctuation),
876
+ ],
877
+ }
878
+
879
+
880
+ class ClojureScriptLexer(ClojureLexer):
881
+ """
882
+ Lexer for `ClojureScript <http://clojure.org/clojurescript>`_
883
+ source code.
884
+
885
+ .. versionadded:: 2.0
886
+ """
887
+ name = 'ClojureScript'
888
+ aliases = ['clojurescript', 'cljs']
889
+ filenames = ['*.cljs']
890
+ mimetypes = ['text/x-clojurescript', 'application/x-clojurescript']
891
+
892
+
893
+ class TeaLangLexer(RegexLexer):
894
+ """
895
+ For `Tea <http://teatrove.org/>`_ source code. Only used within a
896
+ TeaTemplateLexer.
897
+
898
+ .. versionadded:: 1.5
899
+ """
900
+
901
+ flags = re.MULTILINE | re.DOTALL
902
+
903
+ tokens = {
904
+ 'root': [
905
+ # method names
906
+ (r'^(\s*(?:[a-zA-Z_][\w\.\[\]]*\s+)+?)' # return arguments
907
+ r'([a-zA-Z_]\w*)' # method name
908
+ r'(\s*)(\()', # signature start
909
+ bygroups(using(this), Name.Function, Text, Operator)),
910
+ (r'[^\S\n]+', Text),
911
+ (r'//.*?\n', Comment.Single),
912
+ (r'/\*.*?\*/', Comment.Multiline),
913
+ (r'@[a-zA-Z_][\w\.]*', Name.Decorator),
914
+ (r'(and|break|else|foreach|if|in|not|or|reverse)\b',
915
+ Keyword),
916
+ (r'(as|call|define)\b', Keyword.Declaration),
917
+ (r'(true|false|null)\b', Keyword.Constant),
918
+ (r'(template)(\s+)', bygroups(Keyword.Declaration, Text), 'template'),
919
+ (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
920
+ (r'"(\\\\|\\"|[^"])*"', String),
921
+ (r'\'(\\\\|\\\'|[^\'])*\'', String),
922
+ (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
923
+ (r'[a-zA-Z_]\w*:', Name.Label),
924
+ (r'[a-zA-Z_\$]\w*', Name),
925
+ (r'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', Operator),
926
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
927
+ (r'0x[0-9a-fA-F]+', Number.Hex),
928
+ (r'[0-9]+L?', Number.Integer),
929
+ (r'\n', Text)
930
+ ],
931
+ 'template': [
932
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
933
+ ],
934
+ 'import': [
935
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
936
+ ],
937
+ }
938
+
939
+
940
+ class CeylonLexer(RegexLexer):
941
+ """
942
+ For `Ceylon <http://ceylon-lang.org/>`_ source code.
943
+
944
+ .. versionadded:: 1.6
945
+ """
946
+
947
+ name = 'Ceylon'
948
+ aliases = ['ceylon']
949
+ filenames = ['*.ceylon']
950
+ mimetypes = ['text/x-ceylon']
951
+
952
+ flags = re.MULTILINE | re.DOTALL
953
+
954
+ #: optional Comment or Whitespace
955
+ _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
956
+
957
+ tokens = {
958
+ 'root': [
959
+ # method names
960
+ (r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
961
+ r'([a-zA-Z_]\w*)' # method name
962
+ r'(\s*)(\()', # signature start
963
+ bygroups(using(this), Name.Function, Text, Operator)),
964
+ (r'[^\S\n]+', Text),
965
+ (r'//.*?\n', Comment.Single),
966
+ (r'/\*', Comment.Multiline, 'comment'),
967
+ (r'(shared|abstract|formal|default|actual|variable|deprecated|small|'
968
+ r'late|literal|doc|by|see|throws|optional|license|tagged|final|native|'
969
+ r'annotation|sealed)\b', Name.Decorator),
970
+ (r'(break|case|catch|continue|else|finally|for|in|'
971
+ r'if|return|switch|this|throw|try|while|is|exists|dynamic|'
972
+ r'nonempty|then|outer|assert|let)\b', Keyword),
973
+ (r'(abstracts|extends|satisfies|'
974
+ r'super|given|of|out|assign)\b', Keyword.Declaration),
975
+ (r'(function|value|void|new)\b',
976
+ Keyword.Type),
977
+ (r'(assembly|module|package)(\s+)', bygroups(Keyword.Namespace, Text)),
978
+ (r'(true|false|null)\b', Keyword.Constant),
979
+ (r'(class|interface|object|alias)(\s+)',
980
+ bygroups(Keyword.Declaration, Text), 'class'),
981
+ (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
982
+ (r'"(\\\\|\\"|[^"])*"', String),
983
+ (r"'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'", String.Char),
984
+ (r'".*``.*``.*"', String.Interpol),
985
+ (r'(\.)([a-z_]\w*)',
986
+ bygroups(Operator, Name.Attribute)),
987
+ (r'[a-zA-Z_]\w*:', Name.Label),
988
+ (r'[a-zA-Z_]\w*', Name),
989
+ (r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
990
+ (r'\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
991
+ (r'\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
992
+ Number.Float),
993
+ (r'[0-9][0-9]*\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
994
+ (r'[0-9][0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
995
+ Number.Float),
996
+ (r'#([0-9a-fA-F]{4})(_[0-9a-fA-F]{4})+', Number.Hex),
997
+ (r'#[0-9a-fA-F]+', Number.Hex),
998
+ (r'\$([01]{4})(_[01]{4})+', Number.Bin),
999
+ (r'\$[01]+', Number.Bin),
1000
+ (r'\d{1,3}(_\d{3})+[kMGTP]?', Number.Integer),
1001
+ (r'[0-9]+[kMGTP]?', Number.Integer),
1002
+ (r'\n', Text)
1003
+ ],
1004
+ 'class': [
1005
+ (r'[A-Za-z_]\w*', Name.Class, '#pop')
1006
+ ],
1007
+ 'import': [
1008
+ (r'[a-z][\w.]*',
1009
+ Name.Namespace, '#pop')
1010
+ ],
1011
+ 'comment': [
1012
+ (r'[^*/]', Comment.Multiline),
1013
+ (r'/\*', Comment.Multiline, '#push'),
1014
+ (r'\*/', Comment.Multiline, '#pop'),
1015
+ (r'[*/]', Comment.Multiline)
1016
+ ],
1017
+ }
1018
+
1019
+
1020
+ class KotlinLexer(RegexLexer):
1021
+ """
1022
+ For `Kotlin <http://kotlinlang.org/>`_
1023
+ source code.
1024
+
1025
+ .. versionadded:: 1.5
1026
+ """
1027
+
1028
+ name = 'Kotlin'
1029
+ aliases = ['kotlin']
1030
+ filenames = ['*.kt', '*.kts']
1031
+ mimetypes = ['text/x-kotlin']
1032
+
1033
+ flags = re.MULTILINE | re.DOTALL | re.UNICODE
1034
+
1035
+ kt_name = ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' +
1036
+ '[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc', 'Cf',
1037
+ 'Mn', 'Mc') + ']*')
1038
+
1039
+ kt_space_name = ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' +
1040
+ '[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc', 'Cf',
1041
+ 'Mn', 'Mc', 'Zs') + ',-]*')
1042
+
1043
+ kt_id = '(' + kt_name + '|`' + kt_space_name + '`)'
1044
+
1045
+ tokens = {
1046
+ 'root': [
1047
+ (r'^\s*\[.*?\]', Name.Attribute),
1048
+ (r'[^\S\n]+', Text),
1049
+ (r'\s+', Text),
1050
+ (r'\\\n', Text), # line continuation
1051
+ (r'//.*?\n', Comment.Single),
1052
+ (r'^#!/.+?\n', Comment.Single), # shebang for kotlin scripts
1053
+ (r'/[*].*?[*]/', Comment.Multiline),
1054
+ (r'""".*?"""', String),
1055
+ (r'\n', Text),
1056
+ (r'::|!!|\?[:.]', Operator),
1057
+ (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
1058
+ (r'[{}]', Punctuation),
1059
+ (r'@"(""|[^"])*"', String),
1060
+ (r'"(\\\\|\\"|[^"\n])*["\n]', String),
1061
+ (r"'\\.'|'[^\\]'", String.Char),
1062
+ (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFL]?|"
1063
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
1064
+ (r'(object)(\s+)(:)(\s+)', bygroups(Keyword, Text, Punctuation, Text), 'class'),
1065
+ (r'(companion)(\s+)(object)', bygroups(Keyword, Text, Keyword)),
1066
+ (r'(class|interface|object)(\s+)', bygroups(Keyword, Text), 'class'),
1067
+ (r'(package|import)(\s+)', bygroups(Keyword, Text), 'package'),
1068
+ (r'(val|var)(\s+)([(])', bygroups(Keyword, Text, Punctuation), 'property_dec'),
1069
+ (r'(val|var)(\s+)', bygroups(Keyword, Text), 'property'),
1070
+ (r'(fun)(\s+)', bygroups(Keyword, Text), 'function'),
1071
+ (r'(inline fun)(\s+)', bygroups(Keyword, Text), 'function'),
1072
+ (r'(abstract|annotation|as|break|by|catch|class|companion|const|'
1073
+ r'constructor|continue|crossinline|data|do|dynamic|else|enum|'
1074
+ r'external|false|final|finally|for|fun|get|if|import|in|infix|'
1075
+ r'inline|inner|interface|internal|is|lateinit|noinline|null|'
1076
+ r'object|open|operator|out|override|package|private|protected|'
1077
+ r'public|reified|return|sealed|set|super|tailrec|this|throw|'
1078
+ r'true|try|val|var|vararg|when|where|while)\b', Keyword),
1079
+ (kt_id, Name),
1080
+ ],
1081
+ 'package': [
1082
+ (r'\S+', Name.Namespace, '#pop')
1083
+ ],
1084
+ 'class': [
1085
+ (kt_id, Name.Class, '#pop')
1086
+ ],
1087
+ 'property': [
1088
+ (kt_id, Name.Property, '#pop')
1089
+ ],
1090
+ 'property_dec': [
1091
+ (r'(,)(\s*)', bygroups(Punctuation, Text)),
1092
+ (r'(:)(\s*)', bygroups(Punctuation, Text)),
1093
+ (r'<', Punctuation, 'generic'),
1094
+ (r'([)])', Punctuation, '#pop'),
1095
+ (kt_id, Name.Property)
1096
+ ],
1097
+ 'function': [
1098
+ (r'<', Punctuation, 'generic'),
1099
+ (r''+kt_id+'([.])'+kt_id, bygroups(Name.Class, Punctuation, Name.Function), '#pop'),
1100
+ (kt_id, Name.Function, '#pop')
1101
+ ],
1102
+ 'generic': [
1103
+ (r'(>)(\s*)', bygroups(Punctuation, Text), '#pop'),
1104
+ (r':',Punctuation),
1105
+ (r'(reified|out|in)\b', Keyword),
1106
+ (r',',Text),
1107
+ (r'\s+',Text),
1108
+ (kt_id,Name)
1109
+ ]
1110
+ }
1111
+
1112
+
1113
+ class XtendLexer(RegexLexer):
1114
+ """
1115
+ For `Xtend <http://xtend-lang.org/>`_ source code.
1116
+
1117
+ .. versionadded:: 1.6
1118
+ """
1119
+
1120
+ name = 'Xtend'
1121
+ aliases = ['xtend']
1122
+ filenames = ['*.xtend']
1123
+ mimetypes = ['text/x-xtend']
1124
+
1125
+ flags = re.MULTILINE | re.DOTALL
1126
+
1127
+ tokens = {
1128
+ 'root': [
1129
+ # method names
1130
+ (r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
1131
+ r'([a-zA-Z_$][\w$]*)' # method name
1132
+ r'(\s*)(\()', # signature start
1133
+ bygroups(using(this), Name.Function, Text, Operator)),
1134
+ (r'[^\S\n]+', Text),
1135
+ (r'//.*?\n', Comment.Single),
1136
+ (r'/\*.*?\*/', Comment.Multiline),
1137
+ (r'@[a-zA-Z_][\w.]*', Name.Decorator),
1138
+ (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
1139
+ r'if|goto|instanceof|new|return|switch|this|throw|try|while|IF|'
1140
+ r'ELSE|ELSEIF|ENDIF|FOR|ENDFOR|SEPARATOR|BEFORE|AFTER)\b',
1141
+ Keyword),
1142
+ (r'(def|abstract|const|enum|extends|final|implements|native|private|'
1143
+ r'protected|public|static|strictfp|super|synchronized|throws|'
1144
+ r'transient|volatile)\b', Keyword.Declaration),
1145
+ (r'(boolean|byte|char|double|float|int|long|short|void)\b',
1146
+ Keyword.Type),
1147
+ (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
1148
+ (r'(true|false|null)\b', Keyword.Constant),
1149
+ (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text),
1150
+ 'class'),
1151
+ (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
1152
+ (r"(''')", String, 'template'),
1153
+ (r'(\u00BB)', String, 'template'),
1154
+ (r'"(\\\\|\\"|[^"])*"', String),
1155
+ (r"'(\\\\|\\'|[^'])*'", String),
1156
+ (r'[a-zA-Z_]\w*:', Name.Label),
1157
+ (r'[a-zA-Z_$]\w*', Name),
1158
+ (r'[~^*!%&\[\](){}<>\|+=:;,./?-]', Operator),
1159
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1160
+ (r'0x[0-9a-fA-F]+', Number.Hex),
1161
+ (r'[0-9]+L?', Number.Integer),
1162
+ (r'\n', Text)
1163
+ ],
1164
+ 'class': [
1165
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
1166
+ ],
1167
+ 'import': [
1168
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
1169
+ ],
1170
+ 'template': [
1171
+ (r"'''", String, '#pop'),
1172
+ (r'\u00AB', String, '#pop'),
1173
+ (r'.', String)
1174
+ ],
1175
+ }
1176
+
1177
+
1178
+ class PigLexer(RegexLexer):
1179
+ """
1180
+ For `Pig Latin <https://pig.apache.org/>`_ source code.
1181
+
1182
+ .. versionadded:: 2.0
1183
+ """
1184
+
1185
+ name = 'Pig'
1186
+ aliases = ['pig']
1187
+ filenames = ['*.pig']
1188
+ mimetypes = ['text/x-pig']
1189
+
1190
+ flags = re.MULTILINE | re.IGNORECASE
1191
+
1192
+ tokens = {
1193
+ 'root': [
1194
+ (r'\s+', Text),
1195
+ (r'--.*', Comment),
1196
+ (r'/\*[\w\W]*?\*/', Comment.Multiline),
1197
+ (r'\\\n', Text),
1198
+ (r'\\', Text),
1199
+ (r'\'(?:\\[ntbrf\\\']|\\u[0-9a-f]{4}|[^\'\\\n\r])*\'', String),
1200
+ include('keywords'),
1201
+ include('types'),
1202
+ include('builtins'),
1203
+ include('punct'),
1204
+ include('operators'),
1205
+ (r'[0-9]*\.[0-9]+(e[0-9]+)?[fd]?', Number.Float),
1206
+ (r'0x[0-9a-f]+', Number.Hex),
1207
+ (r'[0-9]+L?', Number.Integer),
1208
+ (r'\n', Text),
1209
+ (r'([a-z_]\w*)(\s*)(\()',
1210
+ bygroups(Name.Function, Text, Punctuation)),
1211
+ (r'[()#:]', Text),
1212
+ (r'[^(:#\'")\s]+', Text),
1213
+ (r'\S+\s+', Text) # TODO: make tests pass without \s+
1214
+ ],
1215
+ 'keywords': [
1216
+ (r'(assert|and|any|all|arrange|as|asc|bag|by|cache|CASE|cat|cd|cp|'
1217
+ r'%declare|%default|define|dense|desc|describe|distinct|du|dump|'
1218
+ r'eval|exex|explain|filter|flatten|foreach|full|generate|group|'
1219
+ r'help|if|illustrate|import|inner|input|into|is|join|kill|left|'
1220
+ r'limit|load|ls|map|matches|mkdir|mv|not|null|onschema|or|order|'
1221
+ r'outer|output|parallel|pig|pwd|quit|register|returns|right|rm|'
1222
+ r'rmf|rollup|run|sample|set|ship|split|stderr|stdin|stdout|store|'
1223
+ r'stream|through|union|using|void)\b', Keyword)
1224
+ ],
1225
+ 'builtins': [
1226
+ (r'(AVG|BinStorage|cogroup|CONCAT|copyFromLocal|copyToLocal|COUNT|'
1227
+ r'cross|DIFF|MAX|MIN|PigDump|PigStorage|SIZE|SUM|TextLoader|'
1228
+ r'TOKENIZE)\b', Name.Builtin)
1229
+ ],
1230
+ 'types': [
1231
+ (r'(bytearray|BIGINTEGER|BIGDECIMAL|chararray|datetime|double|float|'
1232
+ r'int|long|tuple)\b', Keyword.Type)
1233
+ ],
1234
+ 'punct': [
1235
+ (r'[;(){}\[\]]', Punctuation),
1236
+ ],
1237
+ 'operators': [
1238
+ (r'[#=,./%+\-?]', Operator),
1239
+ (r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
1240
+ (r'(==|<=|<|>=|>|!=)', Operator),
1241
+ ],
1242
+ }
1243
+
1244
+
1245
+ class GoloLexer(RegexLexer):
1246
+ """
1247
+ For `Golo <http://golo-lang.org/>`_ source code.
1248
+
1249
+ .. versionadded:: 2.0
1250
+ """
1251
+
1252
+ name = 'Golo'
1253
+ filenames = ['*.golo']
1254
+ aliases = ['golo']
1255
+
1256
+ tokens = {
1257
+ 'root': [
1258
+ (r'[^\S\n]+', Text),
1259
+
1260
+ (r'#.*$', Comment),
1261
+
1262
+ (r'(\^|\.\.\.|:|\?:|->|==|!=|=|\+|\*|%|/|<=|<|>=|>|=|\.)',
1263
+ Operator),
1264
+ (r'(?<=[^-])(-)(?=[^-])', Operator),
1265
+
1266
+ (r'(?<=[^`])(is|isnt|and|or|not|oftype|in|orIfNull)\b', Operator.Word),
1267
+ (r'[]{}|(),[]', Punctuation),
1268
+
1269
+ (r'(module|import)(\s+)',
1270
+ bygroups(Keyword.Namespace, Text),
1271
+ 'modname'),
1272
+ (r'\b([a-zA-Z_][\w$.]*)(::)', bygroups(Name.Namespace, Punctuation)),
1273
+ (r'\b([a-zA-Z_][\w$]*(?:\.[a-zA-Z_][\w$]*)+)\b', Name.Namespace),
1274
+
1275
+ (r'(let|var)(\s+)',
1276
+ bygroups(Keyword.Declaration, Text),
1277
+ 'varname'),
1278
+ (r'(struct)(\s+)',
1279
+ bygroups(Keyword.Declaration, Text),
1280
+ 'structname'),
1281
+ (r'(function)(\s+)',
1282
+ bygroups(Keyword.Declaration, Text),
1283
+ 'funcname'),
1284
+
1285
+ (r'(null|true|false)\b', Keyword.Constant),
1286
+ (r'(augment|pimp'
1287
+ r'|if|else|case|match|return'
1288
+ r'|case|when|then|otherwise'
1289
+ r'|while|for|foreach'
1290
+ r'|try|catch|finally|throw'
1291
+ r'|local'
1292
+ r'|continue|break)\b', Keyword),
1293
+
1294
+ (r'(map|array|list|set|vector|tuple)(\[)',
1295
+ bygroups(Name.Builtin, Punctuation)),
1296
+ (r'(print|println|readln|raise|fun'
1297
+ r'|asInterfaceInstance)\b', Name.Builtin),
1298
+ (r'(`?[a-zA-Z_][\w$]*)(\()',
1299
+ bygroups(Name.Function, Punctuation)),
1300
+
1301
+ (r'-?[\d_]*\.[\d_]*([eE][+-]?\d[\d_]*)?F?', Number.Float),
1302
+ (r'0[0-7]+j?', Number.Oct),
1303
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
1304
+ (r'-?\d[\d_]*L', Number.Integer.Long),
1305
+ (r'-?\d[\d_]*', Number.Integer),
1306
+
1307
+ (r'`?[a-zA-Z_][\w$]*', Name),
1308
+ (r'@[a-zA-Z_][\w$.]*', Name.Decorator),
1309
+
1310
+ (r'"""', String, combined('stringescape', 'triplestring')),
1311
+ (r'"', String, combined('stringescape', 'doublestring')),
1312
+ (r"'", String, combined('stringescape', 'singlestring')),
1313
+ (r'----((.|\n)*?)----', String.Doc)
1314
+
1315
+ ],
1316
+
1317
+ 'funcname': [
1318
+ (r'`?[a-zA-Z_][\w$]*', Name.Function, '#pop'),
1319
+ ],
1320
+ 'modname': [
1321
+ (r'[a-zA-Z_][\w$.]*\*?', Name.Namespace, '#pop')
1322
+ ],
1323
+ 'structname': [
1324
+ (r'`?[\w.]+\*?', Name.Class, '#pop')
1325
+ ],
1326
+ 'varname': [
1327
+ (r'`?[a-zA-Z_][\w$]*', Name.Variable, '#pop'),
1328
+ ],
1329
+ 'string': [
1330
+ (r'[^\\\'"\n]+', String),
1331
+ (r'[\'"\\]', String)
1332
+ ],
1333
+ 'stringescape': [
1334
+ (r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
1335
+ r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
1336
+ ],
1337
+ 'triplestring': [
1338
+ (r'"""', String, '#pop'),
1339
+ include('string'),
1340
+ (r'\n', String),
1341
+ ],
1342
+ 'doublestring': [
1343
+ (r'"', String.Double, '#pop'),
1344
+ include('string'),
1345
+ ],
1346
+ 'singlestring': [
1347
+ (r"'", String, '#pop'),
1348
+ include('string'),
1349
+ ],
1350
+ 'operators': [
1351
+ (r'[#=,./%+\-?]', Operator),
1352
+ (r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
1353
+ (r'(==|<=|<|>=|>|!=)', Operator),
1354
+ ],
1355
+ }
1356
+
1357
+
1358
+ class JasminLexer(RegexLexer):
1359
+ """
1360
+ For `Jasmin <http://jasmin.sourceforge.net/>`_ assembly code.
1361
+
1362
+ .. versionadded:: 2.0
1363
+ """
1364
+
1365
+ name = 'Jasmin'
1366
+ aliases = ['jasmin', 'jasminxt']
1367
+ filenames = ['*.j']
1368
+
1369
+ _whitespace = r' \n\t\r'
1370
+ _ws = r'(?:[%s]+)' % _whitespace
1371
+ _separator = r'%s:=' % _whitespace
1372
+ _break = r'(?=[%s]|$)' % _separator
1373
+ _name = r'[^%s]+' % _separator
1374
+ _unqualified_name = r'(?:[^%s.;\[/]+)' % _separator
1375
+
1376
+ tokens = {
1377
+ 'default': [
1378
+ (r'\n', Text, '#pop'),
1379
+ (r"'", String.Single, ('#pop', 'quote')),
1380
+ (r'"', String.Double, 'string'),
1381
+ (r'=', Punctuation),
1382
+ (r':', Punctuation, 'label'),
1383
+ (_ws, Text),
1384
+ (r';.*', Comment.Single),
1385
+ (r'(\$[-+])?0x-?[\da-fA-F]+%s' % _break, Number.Hex),
1386
+ (r'(\$[-+]|\+)?-?\d+%s' % _break, Number.Integer),
1387
+ (r'-?(\d+\.\d*|\.\d+)([eE][-+]?\d+)?[fFdD]?'
1388
+ r'[\x00-\x08\x0b\x0c\x0e-\x1f]*%s' % _break, Number.Float),
1389
+ (r'\$%s' % _name, Name.Variable),
1390
+
1391
+ # Directives
1392
+ (r'\.annotation%s' % _break, Keyword.Reserved, 'annotation'),
1393
+ (r'(\.attribute|\.bytecode|\.debug|\.deprecated|\.enclosing|'
1394
+ r'\.interface|\.line|\.signature|\.source|\.stack|\.var|abstract|'
1395
+ r'annotation|bridge|class|default|enum|field|final|fpstrict|'
1396
+ r'interface|native|private|protected|public|signature|static|'
1397
+ r'synchronized|synthetic|transient|varargs|volatile)%s' % _break,
1398
+ Keyword.Reserved),
1399
+ (r'\.catch%s' % _break, Keyword.Reserved, 'caught-exception'),
1400
+ (r'(\.class|\.implements|\.inner|\.super|inner|invisible|'
1401
+ r'invisibleparam|outer|visible|visibleparam)%s' % _break,
1402
+ Keyword.Reserved, 'class/convert-dots'),
1403
+ (r'\.field%s' % _break, Keyword.Reserved,
1404
+ ('descriptor/convert-dots', 'field')),
1405
+ (r'(\.end|\.limit|use)%s' % _break, Keyword.Reserved,
1406
+ 'no-verification'),
1407
+ (r'\.method%s' % _break, Keyword.Reserved, 'method'),
1408
+ (r'\.set%s' % _break, Keyword.Reserved, 'var'),
1409
+ (r'\.throws%s' % _break, Keyword.Reserved, 'exception'),
1410
+ (r'(from|offset|to|using)%s' % _break, Keyword.Reserved, 'label'),
1411
+ (r'is%s' % _break, Keyword.Reserved,
1412
+ ('descriptor/convert-dots', 'var')),
1413
+ (r'(locals|stack)%s' % _break, Keyword.Reserved, 'verification'),
1414
+ (r'method%s' % _break, Keyword.Reserved, 'enclosing-method'),
1415
+
1416
+ # Instructions
1417
+ (words((
1418
+ 'aaload', 'aastore', 'aconst_null', 'aload', 'aload_0', 'aload_1', 'aload_2',
1419
+ 'aload_3', 'aload_w', 'areturn', 'arraylength', 'astore', 'astore_0', 'astore_1',
1420
+ 'astore_2', 'astore_3', 'astore_w', 'athrow', 'baload', 'bastore', 'bipush',
1421
+ 'breakpoint', 'caload', 'castore', 'd2f', 'd2i', 'd2l', 'dadd', 'daload', 'dastore',
1422
+ 'dcmpg', 'dcmpl', 'dconst_0', 'dconst_1', 'ddiv', 'dload', 'dload_0', 'dload_1',
1423
+ 'dload_2', 'dload_3', 'dload_w', 'dmul', 'dneg', 'drem', 'dreturn', 'dstore', 'dstore_0',
1424
+ 'dstore_1', 'dstore_2', 'dstore_3', 'dstore_w', 'dsub', 'dup', 'dup2', 'dup2_x1',
1425
+ 'dup2_x2', 'dup_x1', 'dup_x2', 'f2d', 'f2i', 'f2l', 'fadd', 'faload', 'fastore', 'fcmpg',
1426
+ 'fcmpl', 'fconst_0', 'fconst_1', 'fconst_2', 'fdiv', 'fload', 'fload_0', 'fload_1',
1427
+ 'fload_2', 'fload_3', 'fload_w', 'fmul', 'fneg', 'frem', 'freturn', 'fstore', 'fstore_0',
1428
+ 'fstore_1', 'fstore_2', 'fstore_3', 'fstore_w', 'fsub', 'i2b', 'i2c', 'i2d', 'i2f', 'i2l',
1429
+ 'i2s', 'iadd', 'iaload', 'iand', 'iastore', 'iconst_0', 'iconst_1', 'iconst_2',
1430
+ 'iconst_3', 'iconst_4', 'iconst_5', 'iconst_m1', 'idiv', 'iinc', 'iinc_w', 'iload',
1431
+ 'iload_0', 'iload_1', 'iload_2', 'iload_3', 'iload_w', 'imul', 'ineg', 'int2byte',
1432
+ 'int2char', 'int2short', 'ior', 'irem', 'ireturn', 'ishl', 'ishr', 'istore', 'istore_0',
1433
+ 'istore_1', 'istore_2', 'istore_3', 'istore_w', 'isub', 'iushr', 'ixor', 'l2d', 'l2f',
1434
+ 'l2i', 'ladd', 'laload', 'land', 'lastore', 'lcmp', 'lconst_0', 'lconst_1', 'ldc2_w',
1435
+ 'ldiv', 'lload', 'lload_0', 'lload_1', 'lload_2', 'lload_3', 'lload_w', 'lmul', 'lneg',
1436
+ 'lookupswitch', 'lor', 'lrem', 'lreturn', 'lshl', 'lshr', 'lstore', 'lstore_0',
1437
+ 'lstore_1', 'lstore_2', 'lstore_3', 'lstore_w', 'lsub', 'lushr', 'lxor',
1438
+ 'monitorenter', 'monitorexit', 'nop', 'pop', 'pop2', 'ret', 'ret_w', 'return', 'saload',
1439
+ 'sastore', 'sipush', 'swap'), suffix=_break), Keyword.Reserved),
1440
+ (r'(anewarray|checkcast|instanceof|ldc|ldc_w|new)%s' % _break,
1441
+ Keyword.Reserved, 'class/no-dots'),
1442
+ (r'invoke(dynamic|interface|nonvirtual|special|'
1443
+ r'static|virtual)%s' % _break, Keyword.Reserved,
1444
+ 'invocation'),
1445
+ (r'(getfield|putfield)%s' % _break, Keyword.Reserved,
1446
+ ('descriptor/no-dots', 'field')),
1447
+ (r'(getstatic|putstatic)%s' % _break, Keyword.Reserved,
1448
+ ('descriptor/no-dots', 'static')),
1449
+ (words((
1450
+ 'goto', 'goto_w', 'if_acmpeq', 'if_acmpne', 'if_icmpeq',
1451
+ 'if_icmpge', 'if_icmpgt', 'if_icmple', 'if_icmplt', 'if_icmpne',
1452
+ 'ifeq', 'ifge', 'ifgt', 'ifle', 'iflt', 'ifne', 'ifnonnull',
1453
+ 'ifnull', 'jsr', 'jsr_w'), suffix=_break),
1454
+ Keyword.Reserved, 'label'),
1455
+ (r'(multianewarray|newarray)%s' % _break, Keyword.Reserved,
1456
+ 'descriptor/convert-dots'),
1457
+ (r'tableswitch%s' % _break, Keyword.Reserved, 'table')
1458
+ ],
1459
+ 'quote': [
1460
+ (r"'", String.Single, '#pop'),
1461
+ (r'\\u[\da-fA-F]{4}', String.Escape),
1462
+ (r"[^'\\]+", String.Single)
1463
+ ],
1464
+ 'string': [
1465
+ (r'"', String.Double, '#pop'),
1466
+ (r'\\([nrtfb"\'\\]|u[\da-fA-F]{4}|[0-3]?[0-7]{1,2})',
1467
+ String.Escape),
1468
+ (r'[^"\\]+', String.Double)
1469
+ ],
1470
+ 'root': [
1471
+ (r'\n+', Text),
1472
+ (r"'", String.Single, 'quote'),
1473
+ include('default'),
1474
+ (r'(%s)([ \t\r]*)(:)' % _name,
1475
+ bygroups(Name.Label, Text, Punctuation)),
1476
+ (_name, String.Other)
1477
+ ],
1478
+ 'annotation': [
1479
+ (r'\n', Text, ('#pop', 'annotation-body')),
1480
+ (r'default%s' % _break, Keyword.Reserved,
1481
+ ('#pop', 'annotation-default')),
1482
+ include('default')
1483
+ ],
1484
+ 'annotation-body': [
1485
+ (r'\n+', Text),
1486
+ (r'\.end%s' % _break, Keyword.Reserved, '#pop'),
1487
+ include('default'),
1488
+ (_name, String.Other, ('annotation-items', 'descriptor/no-dots'))
1489
+ ],
1490
+ 'annotation-default': [
1491
+ (r'\n+', Text),
1492
+ (r'\.end%s' % _break, Keyword.Reserved, '#pop'),
1493
+ include('default'),
1494
+ default(('annotation-items', 'descriptor/no-dots'))
1495
+ ],
1496
+ 'annotation-items': [
1497
+ (r"'", String.Single, 'quote'),
1498
+ include('default'),
1499
+ (_name, String.Other)
1500
+ ],
1501
+ 'caught-exception': [
1502
+ (r'all%s' % _break, Keyword, '#pop'),
1503
+ include('exception')
1504
+ ],
1505
+ 'class/convert-dots': [
1506
+ include('default'),
1507
+ (r'(L)((?:%s[/.])*)(%s)(;)' % (_unqualified_name, _name),
1508
+ bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
1509
+ '#pop'),
1510
+ (r'((?:%s[/.])*)(%s)' % (_unqualified_name, _name),
1511
+ bygroups(Name.Namespace, Name.Class), '#pop')
1512
+ ],
1513
+ 'class/no-dots': [
1514
+ include('default'),
1515
+ (r'\[+', Punctuation, ('#pop', 'descriptor/no-dots')),
1516
+ (r'(L)((?:%s/)*)(%s)(;)' % (_unqualified_name, _name),
1517
+ bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
1518
+ '#pop'),
1519
+ (r'((?:%s/)*)(%s)' % (_unqualified_name, _name),
1520
+ bygroups(Name.Namespace, Name.Class), '#pop')
1521
+ ],
1522
+ 'descriptor/convert-dots': [
1523
+ include('default'),
1524
+ (r'\[+', Punctuation),
1525
+ (r'(L)((?:%s[/.])*)(%s?)(;)' % (_unqualified_name, _name),
1526
+ bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
1527
+ '#pop'),
1528
+ (r'[^%s\[)L]+' % _separator, Keyword.Type, '#pop'),
1529
+ default('#pop')
1530
+ ],
1531
+ 'descriptor/no-dots': [
1532
+ include('default'),
1533
+ (r'\[+', Punctuation),
1534
+ (r'(L)((?:%s/)*)(%s)(;)' % (_unqualified_name, _name),
1535
+ bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
1536
+ '#pop'),
1537
+ (r'[^%s\[)L]+' % _separator, Keyword.Type, '#pop'),
1538
+ default('#pop')
1539
+ ],
1540
+ 'descriptors/convert-dots': [
1541
+ (r'\)', Punctuation, '#pop'),
1542
+ default('descriptor/convert-dots')
1543
+ ],
1544
+ 'enclosing-method': [
1545
+ (_ws, Text),
1546
+ (r'(?=[^%s]*\()' % _separator, Text, ('#pop', 'invocation')),
1547
+ default(('#pop', 'class/convert-dots'))
1548
+ ],
1549
+ 'exception': [
1550
+ include('default'),
1551
+ (r'((?:%s[/.])*)(%s)' % (_unqualified_name, _name),
1552
+ bygroups(Name.Namespace, Name.Exception), '#pop')
1553
+ ],
1554
+ 'field': [
1555
+ (r'static%s' % _break, Keyword.Reserved, ('#pop', 'static')),
1556
+ include('default'),
1557
+ (r'((?:%s[/.](?=[^%s]*[/.]))*)(%s[/.])?(%s)' %
1558
+ (_unqualified_name, _separator, _unqualified_name, _name),
1559
+ bygroups(Name.Namespace, Name.Class, Name.Variable.Instance),
1560
+ '#pop')
1561
+ ],
1562
+ 'invocation': [
1563
+ include('default'),
1564
+ (r'((?:%s[/.](?=[^%s(]*[/.]))*)(%s[/.])?(%s)(\()' %
1565
+ (_unqualified_name, _separator, _unqualified_name, _name),
1566
+ bygroups(Name.Namespace, Name.Class, Name.Function, Punctuation),
1567
+ ('#pop', 'descriptor/convert-dots', 'descriptors/convert-dots',
1568
+ 'descriptor/convert-dots'))
1569
+ ],
1570
+ 'label': [
1571
+ include('default'),
1572
+ (_name, Name.Label, '#pop')
1573
+ ],
1574
+ 'method': [
1575
+ include('default'),
1576
+ (r'(%s)(\()' % _name, bygroups(Name.Function, Punctuation),
1577
+ ('#pop', 'descriptor/convert-dots', 'descriptors/convert-dots',
1578
+ 'descriptor/convert-dots'))
1579
+ ],
1580
+ 'no-verification': [
1581
+ (r'(locals|method|stack)%s' % _break, Keyword.Reserved, '#pop'),
1582
+ include('default')
1583
+ ],
1584
+ 'static': [
1585
+ include('default'),
1586
+ (r'((?:%s[/.](?=[^%s]*[/.]))*)(%s[/.])?(%s)' %
1587
+ (_unqualified_name, _separator, _unqualified_name, _name),
1588
+ bygroups(Name.Namespace, Name.Class, Name.Variable.Class), '#pop')
1589
+ ],
1590
+ 'table': [
1591
+ (r'\n+', Text),
1592
+ (r'default%s' % _break, Keyword.Reserved, '#pop'),
1593
+ include('default'),
1594
+ (_name, Name.Label)
1595
+ ],
1596
+ 'var': [
1597
+ include('default'),
1598
+ (_name, Name.Variable, '#pop')
1599
+ ],
1600
+ 'verification': [
1601
+ include('default'),
1602
+ (r'(Double|Float|Integer|Long|Null|Top|UninitializedThis)%s' %
1603
+ _break, Keyword, '#pop'),
1604
+ (r'Object%s' % _break, Keyword, ('#pop', 'class/no-dots')),
1605
+ (r'Uninitialized%s' % _break, Keyword, ('#pop', 'label'))
1606
+ ]
1607
+ }
1608
+
1609
+ def analyse_text(text):
1610
+ score = 0
1611
+ if re.search(r'^\s*\.class\s', text, re.MULTILINE):
1612
+ score += 0.5
1613
+ if re.search(r'^\s*[a-z]+_[a-z]+\b', text, re.MULTILINE):
1614
+ score += 0.3
1615
+ if re.search(r'^\s*\.(attribute|bytecode|debug|deprecated|enclosing|'
1616
+ r'inner|interface|limit|set|signature|stack)\b', text,
1617
+ re.MULTILINE):
1618
+ score += 0.6
1619
+ return score
1620
+
1621
+
1622
+ class SarlLexer(RegexLexer):
1623
+ """
1624
+ For `SARL <http://www.sarl.io>`_ source code.
1625
+
1626
+ .. versionadded:: 2.4
1627
+ """
1628
+
1629
+ name = 'SARL'
1630
+ aliases = ['sarl']
1631
+ filenames = ['*.sarl']
1632
+ mimetypes = ['text/x-sarl']
1633
+
1634
+ flags = re.MULTILINE | re.DOTALL
1635
+
1636
+ tokens = {
1637
+ 'root': [
1638
+ # method names
1639
+ (r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
1640
+ r'([a-zA-Z_$][\w$]*)' # method name
1641
+ r'(\s*)(\()', # signature start
1642
+ bygroups(using(this), Name.Function, Text, Operator)),
1643
+ (r'[^\S\n]+', Text),
1644
+ (r'//.*?\n', Comment.Single),
1645
+ (r'/\*.*?\*/', Comment.Multiline),
1646
+ (r'@[a-zA-Z_][\w.]*', Name.Decorator),
1647
+ (r'(as|break|case|catch|default|do|else|extends|extension|finally|fires|for|if|implements|instanceof|new|on|requires|return|super|switch|throw|throws|try|typeof|uses|while|with)\b',
1648
+ Keyword),
1649
+ (r'(abstract|def|dispatch|final|native|override|private|protected|public|static|strictfp|synchronized|transient|val|var|volatile)\b', Keyword.Declaration),
1650
+ (r'(boolean|byte|char|double|float|int|long|short|void)\b',
1651
+ Keyword.Type),
1652
+ (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
1653
+ (r'(false|it|null|occurrence|this|true|void)\b', Keyword.Constant),
1654
+ (r'(agent|annotation|artifact|behavior|capacity|class|enum|event|interface|skill|space)(\s+)', bygroups(Keyword.Declaration, Text),
1655
+ 'class'),
1656
+ (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
1657
+ (r'"(\\\\|\\"|[^"])*"', String),
1658
+ (r"'(\\\\|\\'|[^'])*'", String),
1659
+ (r'[a-zA-Z_]\w*:', Name.Label),
1660
+ (r'[a-zA-Z_$]\w*', Name),
1661
+ (r'[~^*!%&\[\](){}<>\|+=:;,./?-]', Operator),
1662
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1663
+ (r'0x[0-9a-fA-F]+', Number.Hex),
1664
+ (r'[0-9]+L?', Number.Integer),
1665
+ (r'\n', Text)
1666
+ ],
1667
+ 'class': [
1668
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
1669
+ ],
1670
+ 'import': [
1671
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
1672
+ ],
1673
+ }