pygments.rb 1.1.0 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (382) 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 -5
  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 +12 -19
  11. data/bench.rb +8 -7
  12. data/cache-lexers.rb +3 -2
  13. data/lexers +0 -0
  14. data/lib/pygments.rb +11 -16
  15. data/lib/pygments/lexer.rb +6 -4
  16. data/lib/pygments/mentos.py +23 -66
  17. data/lib/pygments/popen.rb +155 -207
  18. data/lib/pygments/version.rb +3 -1
  19. data/pygments.rb.gemspec +11 -9
  20. data/test/test_pygments.rb +53 -83
  21. data/vendor/pygments-main/{AUTHORS → Pygments-2.7.3.dist-info/AUTHORS} +23 -3
  22. data/vendor/pygments-main/Pygments-2.7.3.dist-info/INSTALLER +1 -0
  23. data/vendor/pygments-main/{LICENSE → Pygments-2.7.3.dist-info/LICENSE} +1 -1
  24. data/vendor/pygments-main/Pygments-2.7.3.dist-info/METADATA +49 -0
  25. data/vendor/pygments-main/Pygments-2.7.3.dist-info/RECORD +482 -0
  26. data/vendor/pygments-main/Pygments-2.7.3.dist-info/REQUESTED +0 -0
  27. data/vendor/pygments-main/Pygments-2.7.3.dist-info/WHEEL +5 -0
  28. data/vendor/pygments-main/Pygments-2.7.3.dist-info/entry_points.txt +3 -0
  29. data/vendor/pygments-main/Pygments-2.7.3.dist-info/top_level.txt +1 -0
  30. data/vendor/pygments-main/bin/pygmentize +8 -0
  31. data/vendor/pygments-main/pygments/__init__.py +6 -11
  32. data/vendor/pygments-main/pygments/__main__.py +18 -0
  33. data/vendor/pygments-main/pygments/cmdline.py +94 -41
  34. data/vendor/pygments-main/pygments/console.py +6 -9
  35. data/vendor/pygments-main/pygments/filter.py +4 -6
  36. data/vendor/pygments-main/pygments/filters/__init__.py +609 -21
  37. data/vendor/pygments-main/pygments/formatter.py +4 -4
  38. data/vendor/pygments-main/pygments/formatters/__init__.py +42 -6
  39. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -3
  40. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  41. data/vendor/pygments-main/pygments/formatters/html.py +223 -135
  42. data/vendor/pygments-main/pygments/formatters/img.py +102 -38
  43. data/vendor/pygments-main/pygments/formatters/irc.py +39 -39
  44. data/vendor/pygments-main/pygments/formatters/latex.py +56 -26
  45. data/vendor/pygments-main/pygments/formatters/other.py +12 -8
  46. data/vendor/pygments-main/pygments/formatters/rtf.py +29 -29
  47. data/vendor/pygments-main/pygments/formatters/svg.py +38 -4
  48. data/vendor/pygments-main/pygments/formatters/terminal.py +25 -31
  49. data/vendor/pygments-main/pygments/formatters/terminal256.py +22 -12
  50. data/vendor/pygments-main/pygments/lexer.py +41 -39
  51. data/vendor/pygments-main/pygments/lexers/__init__.py +62 -15
  52. data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +5 -5
  53. data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +15 -15
  54. data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +11 -12
  55. data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1717 -1338
  56. data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +8 -1
  57. data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +2 -4
  58. data/vendor/pygments-main/pygments/lexers/_mapping.py +79 -33
  59. data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +2 -2
  60. data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +1282 -0
  61. data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +1 -1
  62. data/vendor/pygments-main/pygments/lexers/_php_builtins.py +17 -20
  63. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +73 -16
  64. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +2 -2
  65. data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1 -3
  66. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +151 -125
  67. data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +6 -4
  68. data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1 -1
  69. data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +113 -0
  70. data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +280 -0
  71. data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1 -1
  72. data/vendor/pygments-main/pygments/lexers/actionscript.py +8 -3
  73. data/vendor/pygments-main/pygments/lexers/agile.py +1 -1
  74. data/vendor/pygments-main/pygments/lexers/algebra.py +20 -1
  75. data/vendor/pygments-main/pygments/lexers/ambient.py +1 -1
  76. data/vendor/pygments-main/pygments/lexers/ampl.py +3 -3
  77. data/vendor/pygments-main/pygments/lexers/apl.py +15 -15
  78. data/vendor/pygments-main/pygments/lexers/archetype.py +3 -3
  79. data/vendor/pygments-main/pygments/lexers/arrow.py +117 -0
  80. data/vendor/pygments-main/pygments/lexers/asm.py +445 -70
  81. data/vendor/pygments-main/pygments/lexers/automation.py +3 -3
  82. data/vendor/pygments-main/pygments/lexers/bare.py +104 -0
  83. data/vendor/pygments-main/pygments/lexers/basic.py +166 -4
  84. data/vendor/pygments-main/pygments/lexers/bibtex.py +13 -9
  85. data/vendor/pygments-main/pygments/lexers/boa.py +102 -0
  86. data/vendor/pygments-main/pygments/lexers/business.py +69 -36
  87. data/vendor/pygments-main/pygments/lexers/c_cpp.py +137 -45
  88. data/vendor/pygments-main/pygments/lexers/c_like.py +68 -43
  89. data/vendor/pygments-main/pygments/lexers/capnproto.py +20 -21
  90. data/vendor/pygments-main/pygments/lexers/chapel.py +25 -14
  91. data/vendor/pygments-main/pygments/lexers/clean.py +135 -244
  92. data/vendor/pygments-main/pygments/lexers/compiled.py +1 -1
  93. data/vendor/pygments-main/pygments/lexers/configs.py +188 -37
  94. data/vendor/pygments-main/pygments/lexers/console.py +1 -1
  95. data/vendor/pygments-main/pygments/lexers/crystal.py +31 -23
  96. data/vendor/pygments-main/pygments/lexers/csound.py +288 -187
  97. data/vendor/pygments-main/pygments/lexers/css.py +18 -16
  98. data/vendor/pygments-main/pygments/lexers/d.py +10 -5
  99. data/vendor/pygments-main/pygments/lexers/dalvik.py +1 -1
  100. data/vendor/pygments-main/pygments/lexers/data.py +240 -97
  101. data/vendor/pygments-main/pygments/lexers/devicetree.py +109 -0
  102. data/vendor/pygments-main/pygments/lexers/diff.py +4 -4
  103. data/vendor/pygments-main/pygments/lexers/dotnet.py +40 -24
  104. data/vendor/pygments-main/pygments/lexers/dsls.py +147 -65
  105. data/vendor/pygments-main/pygments/lexers/dylan.py +16 -18
  106. data/vendor/pygments-main/pygments/lexers/ecl.py +16 -2
  107. data/vendor/pygments-main/pygments/lexers/eiffel.py +1 -1
  108. data/vendor/pygments-main/pygments/lexers/elm.py +5 -5
  109. data/vendor/pygments-main/pygments/lexers/email.py +151 -0
  110. data/vendor/pygments-main/pygments/lexers/erlang.py +29 -32
  111. data/vendor/pygments-main/pygments/lexers/esoteric.py +54 -25
  112. data/vendor/pygments-main/pygments/lexers/ezhil.py +24 -15
  113. data/vendor/pygments-main/pygments/lexers/factor.py +1 -1
  114. data/vendor/pygments-main/pygments/lexers/fantom.py +1 -1
  115. data/vendor/pygments-main/pygments/lexers/felix.py +1 -1
  116. data/vendor/pygments-main/pygments/lexers/floscript.py +83 -0
  117. data/vendor/pygments-main/pygments/lexers/forth.py +41 -40
  118. data/vendor/pygments-main/pygments/lexers/fortran.py +5 -4
  119. data/vendor/pygments-main/pygments/lexers/foxpro.py +2 -2
  120. data/vendor/pygments-main/pygments/lexers/freefem.py +898 -0
  121. data/vendor/pygments-main/pygments/lexers/functional.py +1 -1
  122. data/vendor/pygments-main/pygments/lexers/gdscript.py +346 -0
  123. data/vendor/pygments-main/pygments/lexers/go.py +1 -1
  124. data/vendor/pygments-main/pygments/lexers/grammar_notation.py +63 -6
  125. data/vendor/pygments-main/pygments/lexers/graph.py +14 -9
  126. data/vendor/pygments-main/pygments/lexers/graphics.py +272 -25
  127. data/vendor/pygments-main/pygments/lexers/haskell.py +52 -22
  128. data/vendor/pygments-main/pygments/lexers/haxe.py +6 -6
  129. data/vendor/pygments-main/pygments/lexers/hdl.py +176 -86
  130. data/vendor/pygments-main/pygments/lexers/hexdump.py +18 -12
  131. data/vendor/pygments-main/pygments/lexers/html.py +31 -19
  132. data/vendor/pygments-main/pygments/lexers/idl.py +20 -9
  133. data/vendor/pygments-main/pygments/lexers/igor.py +244 -112
  134. data/vendor/pygments-main/pygments/lexers/inferno.py +2 -2
  135. data/vendor/pygments-main/pygments/lexers/installers.py +1 -1
  136. data/vendor/pygments-main/pygments/lexers/int_fiction.py +40 -15
  137. data/vendor/pygments-main/pygments/lexers/iolang.py +2 -2
  138. data/vendor/pygments-main/pygments/lexers/j.py +3 -3
  139. data/vendor/pygments-main/pygments/lexers/javascript.py +100 -66
  140. data/vendor/pygments-main/pygments/lexers/julia.py +46 -48
  141. data/vendor/pygments-main/pygments/lexers/jvm.py +265 -165
  142. data/vendor/pygments-main/pygments/lexers/lisp.py +882 -804
  143. data/vendor/pygments-main/pygments/lexers/make.py +10 -6
  144. data/vendor/pygments-main/pygments/lexers/markup.py +213 -43
  145. data/vendor/pygments-main/pygments/lexers/math.py +1 -1
  146. data/vendor/pygments-main/pygments/lexers/matlab.py +98 -41
  147. data/vendor/pygments-main/pygments/lexers/mime.py +226 -0
  148. data/vendor/pygments-main/pygments/lexers/ml.py +198 -9
  149. data/vendor/pygments-main/pygments/lexers/modeling.py +26 -18
  150. data/vendor/pygments-main/pygments/lexers/modula2.py +25 -6
  151. data/vendor/pygments-main/pygments/lexers/monte.py +4 -3
  152. data/vendor/pygments-main/pygments/lexers/mosel.py +448 -0
  153. data/vendor/pygments-main/pygments/lexers/ncl.py +85 -244
  154. data/vendor/pygments-main/pygments/lexers/nimrod.py +4 -4
  155. data/vendor/pygments-main/pygments/lexers/nit.py +1 -1
  156. data/vendor/pygments-main/pygments/lexers/nix.py +1 -1
  157. data/vendor/pygments-main/pygments/lexers/oberon.py +17 -1
  158. data/vendor/pygments-main/pygments/lexers/objective.py +16 -16
  159. data/vendor/pygments-main/pygments/lexers/ooc.py +1 -1
  160. data/vendor/pygments-main/pygments/lexers/other.py +1 -1
  161. data/vendor/pygments-main/pygments/lexers/parasail.py +1 -1
  162. data/vendor/pygments-main/pygments/lexers/parsers.py +23 -58
  163. data/vendor/pygments-main/pygments/lexers/pascal.py +23 -23
  164. data/vendor/pygments-main/pygments/lexers/pawn.py +30 -24
  165. data/vendor/pygments-main/pygments/lexers/perl.py +276 -160
  166. data/vendor/pygments-main/pygments/lexers/php.py +64 -10
  167. data/vendor/pygments-main/pygments/lexers/pointless.py +71 -0
  168. data/vendor/pygments-main/pygments/lexers/pony.py +94 -0
  169. data/vendor/pygments-main/pygments/lexers/praat.py +38 -30
  170. data/vendor/pygments-main/pygments/lexers/prolog.py +36 -36
  171. data/vendor/pygments-main/pygments/lexers/promql.py +183 -0
  172. data/vendor/pygments-main/pygments/lexers/python.py +439 -226
  173. data/vendor/pygments-main/pygments/lexers/qvt.py +6 -6
  174. data/vendor/pygments-main/pygments/lexers/r.py +13 -275
  175. data/vendor/pygments-main/pygments/lexers/rdf.py +232 -39
  176. data/vendor/pygments-main/pygments/lexers/rebol.py +8 -8
  177. data/vendor/pygments-main/pygments/lexers/resource.py +2 -2
  178. data/vendor/pygments-main/pygments/lexers/ride.py +139 -0
  179. data/vendor/pygments-main/pygments/lexers/rnc.py +1 -1
  180. data/vendor/pygments-main/pygments/lexers/roboconf.py +1 -1
  181. data/vendor/pygments-main/pygments/lexers/robotframework.py +23 -31
  182. data/vendor/pygments-main/pygments/lexers/ruby.py +22 -24
  183. data/vendor/pygments-main/pygments/lexers/rust.py +86 -71
  184. data/vendor/pygments-main/pygments/lexers/sas.py +7 -7
  185. data/vendor/pygments-main/pygments/lexers/scdoc.py +83 -0
  186. data/vendor/pygments-main/pygments/lexers/scripting.py +75 -13
  187. data/vendor/pygments-main/pygments/lexers/sgf.py +61 -0
  188. data/vendor/pygments-main/pygments/lexers/shell.py +175 -51
  189. data/vendor/pygments-main/pygments/lexers/sieve.py +69 -0
  190. data/vendor/pygments-main/pygments/lexers/slash.py +185 -0
  191. data/vendor/pygments-main/pygments/lexers/smalltalk.py +2 -2
  192. data/vendor/pygments-main/pygments/lexers/smv.py +30 -26
  193. data/vendor/pygments-main/pygments/lexers/snobol.py +1 -1
  194. data/vendor/pygments-main/pygments/lexers/solidity.py +92 -0
  195. data/vendor/pygments-main/pygments/lexers/special.py +5 -3
  196. data/vendor/pygments-main/pygments/lexers/sql.py +333 -177
  197. data/vendor/pygments-main/pygments/lexers/stata.py +107 -42
  198. data/vendor/pygments-main/pygments/lexers/supercollider.py +6 -1
  199. data/vendor/pygments-main/pygments/lexers/tcl.py +1 -1
  200. data/vendor/pygments-main/pygments/lexers/templates.py +144 -132
  201. data/vendor/pygments-main/pygments/lexers/teraterm.py +335 -0
  202. data/vendor/pygments-main/pygments/lexers/testing.py +6 -6
  203. data/vendor/pygments-main/pygments/lexers/text.py +2 -1
  204. data/vendor/pygments-main/pygments/lexers/textedit.py +4 -4
  205. data/vendor/pygments-main/pygments/lexers/textfmts.py +146 -13
  206. data/vendor/pygments-main/pygments/lexers/theorem.py +69 -53
  207. data/vendor/pygments-main/pygments/lexers/tnt.py +263 -0
  208. data/vendor/pygments-main/pygments/lexers/trafficscript.py +1 -1
  209. data/vendor/pygments-main/pygments/lexers/typoscript.py +8 -14
  210. data/vendor/pygments-main/pygments/lexers/unicon.py +412 -0
  211. data/vendor/pygments-main/pygments/lexers/urbi.py +14 -1
  212. data/vendor/pygments-main/pygments/lexers/usd.py +90 -0
  213. data/vendor/pygments-main/pygments/lexers/varnish.py +5 -5
  214. data/vendor/pygments-main/pygments/lexers/verification.py +15 -12
  215. data/vendor/pygments-main/pygments/lexers/web.py +1 -1
  216. data/vendor/pygments-main/pygments/lexers/webidl.py +299 -0
  217. data/vendor/pygments-main/pygments/lexers/webmisc.py +50 -38
  218. data/vendor/pygments-main/pygments/lexers/whiley.py +11 -12
  219. data/vendor/pygments-main/pygments/lexers/x10.py +1 -1
  220. data/vendor/pygments-main/pygments/lexers/xorg.py +37 -0
  221. data/vendor/pygments-main/pygments/lexers/yang.py +104 -0
  222. data/vendor/pygments-main/pygments/lexers/zig.py +124 -0
  223. data/vendor/pygments-main/pygments/modeline.py +6 -5
  224. data/vendor/pygments-main/pygments/plugin.py +14 -18
  225. data/vendor/pygments-main/pygments/regexopt.py +1 -1
  226. data/vendor/pygments-main/pygments/scanner.py +2 -2
  227. data/vendor/pygments-main/pygments/sphinxext.py +2 -4
  228. data/vendor/pygments-main/pygments/style.py +61 -24
  229. data/vendor/pygments-main/pygments/styles/__init__.py +13 -5
  230. data/vendor/pygments-main/pygments/styles/abap.py +29 -0
  231. data/vendor/pygments-main/pygments/styles/algol.py +1 -1
  232. data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -1
  233. data/vendor/pygments-main/pygments/styles/arduino.py +2 -2
  234. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  235. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  236. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  237. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  238. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  239. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  240. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  241. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  242. data/vendor/pygments-main/pygments/styles/igor.py +1 -1
  243. data/vendor/pygments-main/pygments/styles/inkpot.py +67 -0
  244. data/vendor/pygments-main/pygments/styles/lovelace.py +1 -1
  245. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  246. data/vendor/pygments-main/pygments/styles/monokai.py +4 -3
  247. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  248. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  249. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -1
  250. data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -1
  251. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  252. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  253. data/vendor/pygments-main/pygments/styles/rainbow_dash.py +89 -0
  254. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  255. data/vendor/pygments-main/pygments/styles/sas.py +3 -0
  256. data/vendor/pygments-main/pygments/styles/solarized.py +134 -0
  257. data/vendor/pygments-main/pygments/styles/stata_dark.py +41 -0
  258. data/vendor/pygments-main/pygments/styles/stata_light.py +39 -0
  259. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  260. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  261. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  262. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  263. data/vendor/pygments-main/pygments/styles/xcode.py +1 -1
  264. data/vendor/pygments-main/pygments/token.py +1 -1
  265. data/vendor/pygments-main/pygments/unistring.py +47 -108
  266. data/vendor/pygments-main/pygments/util.py +19 -95
  267. metadata +72 -137
  268. data/CHANGELOG.md +0 -89
  269. data/README.md +0 -121
  270. data/circle.yml +0 -20
  271. data/test/test_data.py +0 -514
  272. data/test/test_data_generated +0 -2582
  273. data/vendor/custom_lexers/github.py +0 -565
  274. data/vendor/pygments-main/CHANGES +0 -1163
  275. data/vendor/pygments-main/MANIFEST.in +0 -6
  276. data/vendor/pygments-main/Makefile +0 -65
  277. data/vendor/pygments-main/README.rst +0 -39
  278. data/vendor/pygments-main/REVISION +0 -1
  279. data/vendor/pygments-main/TODO +0 -12
  280. data/vendor/pygments-main/doc/Makefile +0 -153
  281. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  282. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  283. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  284. data/vendor/pygments-main/doc/_templates/docssidebar.html +0 -3
  285. data/vendor/pygments-main/doc/_templates/indexsidebar.html +0 -25
  286. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +0 -98
  287. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  288. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  289. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  290. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  291. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  292. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +0 -401
  293. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +0 -15
  294. data/vendor/pygments-main/doc/conf.py +0 -241
  295. data/vendor/pygments-main/doc/docs/api.rst +0 -331
  296. data/vendor/pygments-main/doc/docs/authors.rst +0 -4
  297. data/vendor/pygments-main/doc/docs/changelog.rst +0 -1
  298. data/vendor/pygments-main/doc/docs/cmdline.rst +0 -149
  299. data/vendor/pygments-main/doc/docs/filterdevelopment.rst +0 -71
  300. data/vendor/pygments-main/doc/docs/filters.rst +0 -41
  301. data/vendor/pygments-main/doc/docs/formatterdevelopment.rst +0 -169
  302. data/vendor/pygments-main/doc/docs/formatters.rst +0 -48
  303. data/vendor/pygments-main/doc/docs/index.rst +0 -66
  304. data/vendor/pygments-main/doc/docs/integrate.rst +0 -40
  305. data/vendor/pygments-main/doc/docs/java.rst +0 -70
  306. data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +0 -689
  307. data/vendor/pygments-main/doc/docs/lexers.rst +0 -69
  308. data/vendor/pygments-main/doc/docs/moinmoin.rst +0 -39
  309. data/vendor/pygments-main/doc/docs/plugins.rst +0 -93
  310. data/vendor/pygments-main/doc/docs/quickstart.rst +0 -205
  311. data/vendor/pygments-main/doc/docs/rstdirective.rst +0 -22
  312. data/vendor/pygments-main/doc/docs/styles.rst +0 -201
  313. data/vendor/pygments-main/doc/docs/tokens.rst +0 -372
  314. data/vendor/pygments-main/doc/docs/unicode.rst +0 -58
  315. data/vendor/pygments-main/doc/download.rst +0 -41
  316. data/vendor/pygments-main/doc/faq.rst +0 -139
  317. data/vendor/pygments-main/doc/index.rst +0 -54
  318. data/vendor/pygments-main/doc/languages.rst +0 -154
  319. data/vendor/pygments-main/doc/make.bat +0 -190
  320. data/vendor/pygments-main/doc/pygmentize.1 +0 -94
  321. data/vendor/pygments-main/external/autopygmentize +0 -84
  322. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +0 -162
  323. data/vendor/pygments-main/external/markdown-processor.py +0 -67
  324. data/vendor/pygments-main/external/moin-parser.py +0 -112
  325. data/vendor/pygments-main/external/pygments.bashcomp +0 -38
  326. data/vendor/pygments-main/external/rst-directive.py +0 -82
  327. data/vendor/pygments-main/pygmentize +0 -8
  328. data/vendor/pygments-main/pygments/lexers/github.py +0 -565
  329. data/vendor/pygments-main/pygments/styles/stata.py +0 -37
  330. data/vendor/pygments-main/requirements.txt +0 -5
  331. data/vendor/pygments-main/scripts/check_sources.py +0 -211
  332. data/vendor/pygments-main/scripts/debug_lexer.py +0 -246
  333. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +0 -33
  334. data/vendor/pygments-main/scripts/epydoc.css +0 -280
  335. data/vendor/pygments-main/scripts/find_error.py +0 -1
  336. data/vendor/pygments-main/scripts/get_vimkw.py +0 -74
  337. data/vendor/pygments-main/scripts/pylintrc +0 -301
  338. data/vendor/pygments-main/scripts/vim2pygments.py +0 -935
  339. data/vendor/pygments-main/setup.cfg +0 -10
  340. data/vendor/pygments-main/setup.py +0 -77
  341. data/vendor/pygments-main/tox.ini +0 -7
  342. data/vendor/simplejson/.gitignore +0 -10
  343. data/vendor/simplejson/.travis.yml +0 -5
  344. data/vendor/simplejson/CHANGES.txt +0 -291
  345. data/vendor/simplejson/LICENSE.txt +0 -19
  346. data/vendor/simplejson/MANIFEST.in +0 -5
  347. data/vendor/simplejson/README.rst +0 -19
  348. data/vendor/simplejson/conf.py +0 -179
  349. data/vendor/simplejson/index.rst +0 -628
  350. data/vendor/simplejson/scripts/make_docs.py +0 -18
  351. data/vendor/simplejson/setup.py +0 -104
  352. data/vendor/simplejson/simplejson/__init__.py +0 -510
  353. data/vendor/simplejson/simplejson/_speedups.c +0 -2745
  354. data/vendor/simplejson/simplejson/decoder.py +0 -425
  355. data/vendor/simplejson/simplejson/encoder.py +0 -567
  356. data/vendor/simplejson/simplejson/ordered_dict.py +0 -119
  357. data/vendor/simplejson/simplejson/scanner.py +0 -77
  358. data/vendor/simplejson/simplejson/tests/__init__.py +0 -67
  359. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +0 -55
  360. data/vendor/simplejson/simplejson/tests/test_check_circular.py +0 -30
  361. data/vendor/simplejson/simplejson/tests/test_decimal.py +0 -66
  362. data/vendor/simplejson/simplejson/tests/test_decode.py +0 -83
  363. data/vendor/simplejson/simplejson/tests/test_default.py +0 -9
  364. data/vendor/simplejson/simplejson/tests/test_dump.py +0 -67
  365. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +0 -46
  366. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +0 -32
  367. data/vendor/simplejson/simplejson/tests/test_errors.py +0 -34
  368. data/vendor/simplejson/simplejson/tests/test_fail.py +0 -91
  369. data/vendor/simplejson/simplejson/tests/test_float.py +0 -19
  370. data/vendor/simplejson/simplejson/tests/test_indent.py +0 -86
  371. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +0 -20
  372. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +0 -121
  373. data/vendor/simplejson/simplejson/tests/test_pass1.py +0 -76
  374. data/vendor/simplejson/simplejson/tests/test_pass2.py +0 -14
  375. data/vendor/simplejson/simplejson/tests/test_pass3.py +0 -20
  376. data/vendor/simplejson/simplejson/tests/test_recursion.py +0 -67
  377. data/vendor/simplejson/simplejson/tests/test_scanstring.py +0 -117
  378. data/vendor/simplejson/simplejson/tests/test_separators.py +0 -42
  379. data/vendor/simplejson/simplejson/tests/test_speedups.py +0 -20
  380. data/vendor/simplejson/simplejson/tests/test_tuple.py +0 -49
  381. data/vendor/simplejson/simplejson/tests/test_unicode.py +0 -109
  382. data/vendor/simplejson/simplejson/tool.py +0 -39
@@ -5,7 +5,7 @@
5
5
 
6
6
  Just export lexer classes previously contained in this module.
7
7
 
8
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for computer algebra systems.
7
7
 
8
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -68,6 +68,25 @@ class GAPLexer(RegexLexer):
68
68
  ],
69
69
  }
70
70
 
71
+ def analyse_text(text):
72
+ score = 0.0
73
+
74
+ # Declaration part
75
+ if re.search(
76
+ r"(InstallTrueMethod|Declare(Attribute|Category|Filter|Operation" +
77
+ r"|GlobalFunction|Synonym|SynonymAttr|Property))", text
78
+ ):
79
+ score += 0.7
80
+
81
+ # Implementation part
82
+ if re.search(
83
+ r"(DeclareRepresentation|Install(GlobalFunction|Method|" +
84
+ r"ImmediateMethod|OtherMethod)|New(Family|Type)|Objectify)", text
85
+ ):
86
+ score += 0.7
87
+
88
+ return min(score, 1.0)
89
+
71
90
 
72
91
  class MathematicaLexer(RegexLexer):
73
92
  """
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for AmbientTalk language.
7
7
 
8
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -3,9 +3,9 @@
3
3
  pygments.lexers.ampl
4
4
  ~~~~~~~~~~~~~~~~~~~~
5
5
 
6
- Lexers for the ampl language. <http://ampl.com/>
6
+ Lexers for the AMPL language.
7
7
 
8
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -18,7 +18,7 @@ __all__ = ['AmplLexer']
18
18
 
19
19
  class AmplLexer(RegexLexer):
20
20
  """
21
- For AMPL source code.
21
+ For `AMPL <http://ampl.com/>`_ source code.
22
22
 
23
23
  .. versionadded:: 2.2
24
24
  """
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for APL.
7
7
 
8
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -18,7 +18,7 @@ __all__ = ['APLLexer']
18
18
 
19
19
  class APLLexer(RegexLexer):
20
20
  """
21
- A simple APL lexer.
21
+ A simple `APL <https://en.m.wikipedia.org/wiki/APL_(programming_language)>`_ lexer.
22
22
 
23
23
  .. versionadded:: 2.0
24
24
  """
@@ -35,7 +35,7 @@ class APLLexer(RegexLexer):
35
35
  # Comment
36
36
  # =======
37
37
  # '⍝' is traditional; '#' is supported by GNU APL and NGN (but not Dyalog)
38
- (u'[⍝#].*$', Comment.Single),
38
+ (r'[⍝#].*$', Comment.Single),
39
39
  #
40
40
  # Strings
41
41
  # =======
@@ -46,7 +46,7 @@ class APLLexer(RegexLexer):
46
46
  # ===========
47
47
  # This token type is used for diamond and parenthesis
48
48
  # but not for bracket and ; (see below)
49
- (u'[⋄◇()]', Punctuation),
49
+ (r'[⋄◇()]', Punctuation),
50
50
  #
51
51
  # Array indexing
52
52
  # ==============
@@ -57,45 +57,45 @@ class APLLexer(RegexLexer):
57
57
  # Distinguished names
58
58
  # ===================
59
59
  # following IBM APL2 standard
60
- (u'⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Function),
60
+ (r'⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Function),
61
61
  #
62
62
  # Labels
63
63
  # ======
64
64
  # following IBM APL2 standard
65
- # (u'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*:', Name.Label),
65
+ # (r'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*:', Name.Label),
66
66
  #
67
67
  # Variables
68
68
  # =========
69
69
  # following IBM APL2 standard
70
- (u'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Variable),
70
+ (r'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Variable),
71
71
  #
72
72
  # Numbers
73
73
  # =======
74
- (u'¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)'
75
- u'([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?',
74
+ (r'¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)'
75
+ r'([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?',
76
76
  Number),
77
77
  #
78
78
  # Operators
79
79
  # ==========
80
- (u'[\.\\\/⌿⍀¨⍣⍨⍠⍤∘]', Name.Attribute), # closest token type
81
- (u'[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗]',
80
+ (r'[\.\\\/⌿⍀¨⍣⍨⍠⍤∘⌸&⌶@⌺⍥⍛⍢]', Name.Attribute), # closest token type
81
+ (r'[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗⊆⊇⍸√⌾…⍮]',
82
82
  Operator),
83
83
  #
84
84
  # Constant
85
85
  # ========
86
- (u'⍬', Name.Constant),
86
+ (r'⍬', Name.Constant),
87
87
  #
88
88
  # Quad symbol
89
89
  # ===========
90
- (u'[⎕⍞]', Name.Variable.Global),
90
+ (r'[⎕⍞]', Name.Variable.Global),
91
91
  #
92
92
  # Arrows left/right
93
93
  # =================
94
- (u'[←→]', Keyword.Declaration),
94
+ (r'[←→]', Keyword.Declaration),
95
95
  #
96
96
  # D-Fn
97
97
  # ====
98
- (u'[⍺⍵⍶⍹∇:]', Name.Builtin.Pseudo),
98
+ (r'[⍺⍵⍶⍹∇:]', Name.Builtin.Pseudo),
99
99
  (r'[{}]', Keyword.Type),
100
100
  ],
101
101
  }
@@ -14,7 +14,7 @@
14
14
  Contributed by Thomas Beale <https://github.com/wolandscat>,
15
15
  <https://bitbucket.org/thomas_beale>.
16
16
 
17
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
17
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
18
18
  :license: BSD, see LICENSE for details.
19
19
  """
20
20
 
@@ -212,9 +212,9 @@ class CadlLexer(AtomsLexer):
212
212
  (r'(not)\W', Operator),
213
213
  (r'(matches|is_in)\W', Operator),
214
214
  # is_in / not is_in char
215
- (u'(\u2208|\u2209)', Operator),
215
+ ('(\u2208|\u2209)', Operator),
216
216
  # there_exists / not there_exists / for_all / and / or
217
- (u'(\u2203|\u2204|\u2200|\u2227|\u2228|\u22BB|\223C)',
217
+ ('(\u2203|\u2204|\u2200|\u2227|\u2228|\u22BB|\223C)',
218
218
  Operator),
219
219
  # regex in slot or as string constraint
220
220
  (r'(\{)(\s*/[^}]+/\s*)(\})',
@@ -0,0 +1,117 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.arrow
4
+ ~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexer for Arrow.
7
+
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ from pygments.lexer import RegexLexer, bygroups, default, include
13
+ from pygments.token import Text, Operator, Keyword, Punctuation, Name, \
14
+ String, Number
15
+
16
+ __all__ = ['ArrowLexer']
17
+
18
+ TYPES = r'\b(int|bool|char)((?:\[\])*)(?=\s+)'
19
+ IDENT = r'([a-zA-Z_][a-zA-Z0-9_]*)'
20
+ DECL = TYPES + r'(\s+)' + IDENT
21
+
22
+
23
+ class ArrowLexer(RegexLexer):
24
+ """
25
+ Lexer for Arrow: https://pypi.org/project/py-arrow-lang/
26
+
27
+ .. versionadded:: 2.7
28
+ """
29
+
30
+ name = 'Arrow'
31
+ aliases = ['arrow']
32
+ filenames = ['*.arw']
33
+
34
+ tokens = {
35
+ 'root': [
36
+ (r'\s+', Text),
37
+ (r'^[|\s]+', Punctuation),
38
+ include('blocks'),
39
+ include('statements'),
40
+ include('expressions'),
41
+ ],
42
+ 'blocks': [
43
+ (r'(function)(\n+)(/-->)(\s*)' +
44
+ DECL + # 4 groups
45
+ r'(\()', bygroups(
46
+ Keyword.Reserved, Text, Punctuation,
47
+ Text, Keyword.Type, Punctuation, Text,
48
+ Name.Function, Punctuation
49
+ ), 'fparams'),
50
+ (r'/-->$|\\-->$|/--<|\\--<|\^', Punctuation),
51
+ ],
52
+ 'statements': [
53
+ (DECL, bygroups(Keyword.Type, Punctuation, Text, Name.Variable)),
54
+ (r'\[', Punctuation, 'index'),
55
+ (r'=', Operator),
56
+ (r'require|main', Keyword.Reserved),
57
+ (r'print', Keyword.Reserved, 'print'),
58
+ ],
59
+ 'expressions': [
60
+ (r'\s+', Text),
61
+ (r'[0-9]+', Number.Integer),
62
+ (r'true|false', Keyword.Constant),
63
+ (r"'", String.Char, 'char'),
64
+ (r'"', String.Double, 'string'),
65
+ (r'\{', Punctuation, 'array'),
66
+ (r'==|!=|<|>|\+|-|\*|/|%', Operator),
67
+ (r'and|or|not|length', Operator.Word),
68
+ (r'(input)(\s+)(int|char\[\])', bygroups(
69
+ Keyword.Reserved, Text, Keyword.Type
70
+ )),
71
+ (IDENT + r'(\()', bygroups(
72
+ Name.Function, Punctuation
73
+ ), 'fargs'),
74
+ (IDENT, Name.Variable),
75
+ (r'\[', Punctuation, 'index'),
76
+ (r'\(', Punctuation, 'expressions'),
77
+ (r'\)', Punctuation, '#pop'),
78
+ ],
79
+ 'print': [
80
+ include('expressions'),
81
+ (r',', Punctuation),
82
+ default('#pop'),
83
+ ],
84
+ 'fparams': [
85
+ (DECL, bygroups(Keyword.Type, Punctuation, Text, Name.Variable)),
86
+ (r',', Punctuation),
87
+ (r'\)', Punctuation, '#pop'),
88
+ ],
89
+ 'escape': [
90
+ (r'\\(["\\/abfnrtv]|[0-9]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})',
91
+ String.Escape),
92
+ ],
93
+ 'char': [
94
+ (r"'", String.Char, '#pop'),
95
+ include('escape'),
96
+ (r"[^'\\]", String.Char),
97
+ ],
98
+ 'string': [
99
+ (r'"', String.Double, '#pop'),
100
+ include('escape'),
101
+ (r'[^"\\]+', String.Double),
102
+ ],
103
+ 'array': [
104
+ include('expressions'),
105
+ (r'\}', Punctuation, '#pop'),
106
+ (r',', Punctuation),
107
+ ],
108
+ 'fargs': [
109
+ include('expressions'),
110
+ (r'\)', Punctuation, '#pop'),
111
+ (r',', Punctuation),
112
+ ],
113
+ 'index': [
114
+ include('expressions'),
115
+ (r'\]', Punctuation, '#pop'),
116
+ ],
117
+ }
@@ -5,22 +5,23 @@
5
5
 
6
6
  Lexers for assembly languages.
7
7
 
8
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
12
12
  import re
13
13
 
14
14
  from pygments.lexer import RegexLexer, include, bygroups, using, words, \
15
- DelegatingLexer
15
+ DelegatingLexer, default
16
16
  from pygments.lexers.c_cpp import CppLexer, CLexer
17
17
  from pygments.lexers.d import DLexer
18
18
  from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
19
- Other, Keyword, Operator
19
+ Other, Keyword, Operator, Literal
20
20
 
21
21
  __all__ = ['GasLexer', 'ObjdumpLexer', 'DObjdumpLexer', 'CppObjdumpLexer',
22
- 'CObjdumpLexer', 'HsailLexer', 'LlvmLexer', 'NasmLexer',
23
- 'NasmObjdumpLexer', 'TasmLexer', 'Ca65Lexer']
22
+ 'CObjdumpLexer', 'HsailLexer', 'LlvmLexer', 'LlvmMirBodyLexer',
23
+ 'LlvmMirLexer', 'NasmLexer', 'NasmObjdumpLexer', 'TasmLexer',
24
+ 'Ca65Lexer', 'Dasm16Lexer']
24
25
 
25
26
 
26
27
  class GasLexer(RegexLexer):
@@ -35,8 +36,9 @@ class GasLexer(RegexLexer):
35
36
  #: optional Comment or Whitespace
36
37
  string = r'"(\\"|[^"])*"'
37
38
  char = r'[\w$.@-]'
38
- identifier = r'(?:[a-zA-Z$_]' + char + '*|\.' + char + '+)'
39
- number = r'(?:0[xX][a-zA-Z0-9]+|\d+)'
39
+ identifier = r'(?:[a-zA-Z$_]' + char + r'*|\.' + char + '+)'
40
+ number = r'(?:0[xX][a-fA-F0-9]+|#?-?\d+)'
41
+ register = '%' + identifier
40
42
 
41
43
  tokens = {
42
44
  'root': [
@@ -52,9 +54,11 @@ class GasLexer(RegexLexer):
52
54
  (string, String),
53
55
  ('@' + identifier, Name.Attribute),
54
56
  (number, Number.Integer),
57
+ (register, Name.Variable),
55
58
  (r'[\r\n]+', Text, '#pop'),
56
-
57
- (r'#.*?$', Comment, '#pop'),
59
+ (r'([;#]|//).*?\n', Comment.Single, '#pop'),
60
+ (r'/[*].*?[*]/', Comment.Multiline),
61
+ (r'/[*].*?\n[\w\W]*?[*]/', Comment.Multiline, '#pop'),
58
62
 
59
63
  include('punctuation'),
60
64
  include('whitespace')
@@ -73,19 +77,23 @@ class GasLexer(RegexLexer):
73
77
  (identifier, Name.Constant),
74
78
  (number, Number.Integer),
75
79
  # Registers
76
- ('%' + identifier, Name.Variable),
80
+ (register, Name.Variable),
77
81
  # Numeric constants
78
82
  ('$'+number, Number.Integer),
79
83
  (r"$'(.|\\')'", String.Char),
80
84
  (r'[\r\n]+', Text, '#pop'),
81
- (r'#.*?$', Comment, '#pop'),
85
+ (r'([;#]|//).*?\n', Comment.Single, '#pop'),
86
+ (r'/[*].*?[*]/', Comment.Multiline),
87
+ (r'/[*].*?\n[\w\W]*?[*]/', Comment.Multiline, '#pop'),
88
+
82
89
  include('punctuation'),
83
90
  include('whitespace')
84
91
  ],
85
92
  'whitespace': [
86
93
  (r'\n', Text),
87
94
  (r'\s+', Text),
88
- (r'#.*?\n', Comment)
95
+ (r'([;#]|//).*?\n', Comment.Single),
96
+ (r'/[*][\w\W]*?[*]/', Comment.Multiline)
89
97
  ],
90
98
  'punctuation': [
91
99
  (r'[-*,.()\[\]!:]+', Punctuation)
@@ -93,9 +101,9 @@ class GasLexer(RegexLexer):
93
101
  }
94
102
 
95
103
  def analyse_text(text):
96
- if re.match(r'^\.(text|data|section)', text, re.M):
104
+ if re.search(r'^\.(text|data|section)', text, re.M):
97
105
  return True
98
- elif re.match(r'^\.\w+', text, re.M):
106
+ elif re.search(r'^\.\w+', text, re.M):
99
107
  return 0.1
100
108
 
101
109
 
@@ -150,7 +158,7 @@ def _objdump_lexer_tokens(asm_lexer):
150
158
 
151
159
  class ObjdumpLexer(RegexLexer):
152
160
  """
153
- For the output of 'objdump -dr'
161
+ For the output of ``objdump -dr``.
154
162
  """
155
163
  name = 'objdump'
156
164
  aliases = ['objdump']
@@ -162,7 +170,7 @@ class ObjdumpLexer(RegexLexer):
162
170
 
163
171
  class DObjdumpLexer(DelegatingLexer):
164
172
  """
165
- For the output of 'objdump -Sr on compiled D files'
173
+ For the output of ``objdump -Sr`` on compiled D files.
166
174
  """
167
175
  name = 'd-objdump'
168
176
  aliases = ['d-objdump']
@@ -170,12 +178,12 @@ class DObjdumpLexer(DelegatingLexer):
170
178
  mimetypes = ['text/x-d-objdump']
171
179
 
172
180
  def __init__(self, **options):
173
- super(DObjdumpLexer, self).__init__(DLexer, ObjdumpLexer, **options)
181
+ super().__init__(DLexer, ObjdumpLexer, **options)
174
182
 
175
183
 
176
184
  class CppObjdumpLexer(DelegatingLexer):
177
185
  """
178
- For the output of 'objdump -Sr on compiled C++ files'
186
+ For the output of ``objdump -Sr`` on compiled C++ files.
179
187
  """
180
188
  name = 'cpp-objdump'
181
189
  aliases = ['cpp-objdump', 'c++-objdumb', 'cxx-objdump']
@@ -183,12 +191,12 @@ class CppObjdumpLexer(DelegatingLexer):
183
191
  mimetypes = ['text/x-cpp-objdump']
184
192
 
185
193
  def __init__(self, **options):
186
- super(CppObjdumpLexer, self).__init__(CppLexer, ObjdumpLexer, **options)
194
+ super().__init__(CppLexer, ObjdumpLexer, **options)
187
195
 
188
196
 
189
197
  class CObjdumpLexer(DelegatingLexer):
190
198
  """
191
- For the output of 'objdump -Sr on compiled C files'
199
+ For the output of ``objdump -Sr`` on compiled C files.
192
200
  """
193
201
  name = 'c-objdump'
194
202
  aliases = ['c-objdump']
@@ -196,7 +204,7 @@ class CObjdumpLexer(DelegatingLexer):
196
204
  mimetypes = ['text/x-c-objdump']
197
205
 
198
206
  def __init__(self, **options):
199
- super(CObjdumpLexer, self).__init__(CLexer, ObjdumpLexer, **options)
207
+ super().__init__(CLexer, ObjdumpLexer, **options)
200
208
 
201
209
 
202
210
  class HsailLexer(RegexLexer):
@@ -258,7 +266,7 @@ class HsailLexer(RegexLexer):
258
266
  (r'0[xX][a-fA-F0-9]+', Number.Hex),
259
267
  (ieeefloat, Number.Float),
260
268
  (float, Number.Float),
261
- ('\d+', Number.Integer),
269
+ (r'\d+', Number.Integer),
262
270
 
263
271
  (r'[=<>{}\[\]()*.,:;!]|x\b', Punctuation)
264
272
  ],
@@ -267,7 +275,7 @@ class HsailLexer(RegexLexer):
267
275
  ],
268
276
  'comments': [
269
277
  (r'/\*.*?\*/', Comment.Multiline),
270
- (r'//.*?\n', Comment.Singleline),
278
+ (r'//.*?\n', Comment.Single),
271
279
  ],
272
280
  'keyword': [
273
281
  # Types
@@ -281,7 +289,7 @@ class HsailLexer(RegexLexer):
281
289
  'enabledetectexceptions', 'maxdynamicgroupsize', 'maxflatgridsize',
282
290
  'maxflatworkgroupsize', 'requireddim', 'requiredgridsize',
283
291
  'requiredworkgroupsize', 'requirenopartialworkgroups'),
284
- suffix=r'\b'), Keyword),
292
+ suffix=r'\b'), Keyword),
285
293
 
286
294
  # instructions
287
295
  (roundingMod, Keyword),
@@ -352,7 +360,7 @@ class LlvmLexer(RegexLexer):
352
360
  include('whitespace'),
353
361
 
354
362
  # Before keywords, because keywords are valid label names :(...
355
- (identifier + '\s*:', Name.Label),
363
+ (identifier + r'\s*:', Name.Label),
356
364
 
357
365
  include('keyword'),
358
366
 
@@ -377,53 +385,298 @@ class LlvmLexer(RegexLexer):
377
385
  'keyword': [
378
386
  # Regular keywords
379
387
  (words((
380
- 'begin', 'end', 'true', 'false', 'declare', 'define', 'global',
381
- 'constant', 'private', 'linker_private', 'internal',
382
- 'available_externally', 'linkonce', 'linkonce_odr', 'weak',
383
- 'weak_odr', 'appending', 'dllimport', 'dllexport', 'common',
384
- 'default', 'hidden', 'protected', 'extern_weak', 'external',
385
- 'thread_local', 'zeroinitializer', 'undef', 'null', 'to', 'tail',
386
- 'target', 'triple', 'datalayout', 'volatile', 'nuw', 'nsw', 'nnan',
387
- 'ninf', 'nsz', 'arcp', 'fast', 'exact', 'inbounds', 'align',
388
- 'addrspace', 'section', 'alias', 'module', 'asm', 'sideeffect',
389
- 'gc', 'dbg', 'linker_private_weak', 'attributes', 'blockaddress',
390
- 'initialexec', 'localdynamic', 'localexec', 'prefix', 'unnamed_addr',
391
- 'ccc', 'fastcc', 'coldcc', 'x86_stdcallcc', 'x86_fastcallcc',
392
- 'arm_apcscc', 'arm_aapcscc', 'arm_aapcs_vfpcc', 'ptx_device',
393
- 'ptx_kernel', 'intel_ocl_bicc', 'msp430_intrcc', 'spir_func',
394
- 'spir_kernel', 'x86_64_sysvcc', 'x86_64_win64cc', 'x86_thiscallcc',
395
- 'cc', 'c', 'signext', 'zeroext', 'inreg', 'sret', 'nounwind',
396
- 'noreturn', 'noalias', 'nocapture', 'byval', 'nest', 'readnone',
397
- 'readonly', 'inlinehint', 'noinline', 'alwaysinline', 'optsize', 'ssp',
398
- 'sspreq', 'noredzone', 'noimplicitfloat', 'naked', 'builtin', 'cold',
399
- 'nobuiltin', 'noduplicate', 'nonlazybind', 'optnone', 'returns_twice',
400
- 'sanitize_address', 'sanitize_memory', 'sanitize_thread', 'sspstrong',
401
- 'uwtable', 'returned', 'type', 'opaque', 'eq', 'ne', 'slt', 'sgt',
402
- 'sle', 'sge', 'ult', 'ugt', 'ule', 'uge', 'oeq', 'one', 'olt', 'ogt',
403
- 'ole', 'oge', 'ord', 'uno', 'ueq', 'une', 'x', 'acq_rel', 'acquire',
404
- 'alignstack', 'atomic', 'catch', 'cleanup', 'filter', 'inteldialect',
405
- 'max', 'min', 'monotonic', 'nand', 'personality', 'release', 'seq_cst',
406
- 'singlethread', 'umax', 'umin', 'unordered', 'xchg', 'add', 'fadd',
407
- 'sub', 'fsub', 'mul', 'fmul', 'udiv', 'sdiv', 'fdiv', 'urem', 'srem',
408
- 'frem', 'shl', 'lshr', 'ashr', 'and', 'or', 'xor', 'icmp', 'fcmp',
409
- 'phi', 'call', 'trunc', 'zext', 'sext', 'fptrunc', 'fpext', 'uitofp',
410
- 'sitofp', 'fptoui', 'fptosi', 'inttoptr', 'ptrtoint', 'bitcast',
411
- 'addrspacecast', 'select', 'va_arg', 'ret', 'br', 'switch', 'invoke',
412
- 'unwind', 'unreachable', 'indirectbr', 'landingpad', 'resume',
413
- 'malloc', 'alloca', 'free', 'load', 'store', 'getelementptr',
414
- 'extractelement', 'insertelement', 'shufflevector', 'getresult',
415
- 'extractvalue', 'insertvalue', 'atomicrmw', 'cmpxchg', 'fence'),
416
- suffix=r'\b'), Keyword),
388
+ 'acq_rel', 'acquire', 'add', 'addrspace', 'addrspacecast', 'afn', 'alias',
389
+ 'aliasee', 'align', 'alignLog2', 'alignstack', 'alloca', 'allocsize', 'allOnes',
390
+ 'alwaysinline', 'amdgpu_cs', 'amdgpu_es', 'amdgpu_gs', 'amdgpu_hs',
391
+ 'amdgpu_kernel', 'amdgpu_ls', 'amdgpu_ps', 'amdgpu_vs', 'and', 'any',
392
+ 'anyregcc', 'appending', 'arcp', 'argmemonly', 'args', 'arm_aapcs_vfpcc',
393
+ 'arm_aapcscc', 'arm_apcscc', 'ashr', 'asm', 'atomic', 'atomicrmw', 'attributes',
394
+ 'available_externally', 'avr_intrcc', 'avr_signalcc', 'bit', 'bitcast',
395
+ 'bitMask', 'blockaddress', 'br', 'branchFunnel', 'builtin', 'byArg', 'byte',
396
+ 'byteArray', 'byval', 'c', 'call', 'callee', 'caller', 'calls', 'catch',
397
+ 'catchpad', 'catchret', 'catchswitch', 'cc', 'ccc', 'cleanup', 'cleanuppad',
398
+ 'cleanupret', 'cmpxchg', 'cold', 'coldcc', 'comdat', 'common', 'constant',
399
+ 'contract', 'convergent', 'critical', 'cxx_fast_tlscc', 'datalayout', 'declare',
400
+ 'default', 'define', 'deplibs', 'dereferenceable', 'dereferenceable_or_null',
401
+ 'distinct', 'dllexport', 'dllimport', 'dso_local', 'dso_preemptable',
402
+ 'dsoLocal', 'eq', 'exact', 'exactmatch', 'extern_weak', 'external',
403
+ 'externally_initialized', 'extractelement', 'extractvalue', 'fadd', 'false',
404
+ 'fast', 'fastcc', 'fcmp', 'fdiv', 'fence', 'filter', 'flags', 'fmul',
405
+ 'fpext', 'fptosi', 'fptoui', 'fptrunc', 'freeze', 'frem', 'from', 'fsub',
406
+ 'funcFlags', 'function', 'gc', 'getelementptr', 'ghccc', 'global', 'guid', 'gv',
407
+ 'hash', 'hhvm_ccc', 'hhvmcc', 'hidden', 'hot', 'hotness', 'icmp',
408
+ 'ifunc', 'inaccessiblemem_or_argmemonly', 'inaccessiblememonly', 'inalloca',
409
+ 'inbounds', 'indir', 'indirectbr', 'info', 'initialexec', 'inline',
410
+ 'inlineBits', 'inlinehint', 'inrange', 'inreg', 'insertelement', 'insertvalue',
411
+ 'insts', 'intel_ocl_bicc', 'inteldialect', 'internal', 'inttoptr', 'invoke',
412
+ 'jumptable', 'kind', 'landingpad', 'largest', 'linkage', 'linkonce',
413
+ 'linkonce_odr', 'live', 'load', 'local_unnamed_addr', 'localdynamic',
414
+ 'localexec', 'lshr', 'max', 'metadata', 'min', 'minsize', 'module', 'monotonic',
415
+ 'msp430_intrcc', 'mul', 'musttail', 'naked', 'name', 'nand', 'ne', 'nest',
416
+ 'ninf', 'nnan', 'noalias', 'nobuiltin', 'nocapture', 'nocf_check',
417
+ 'noduplicate', 'noduplicates', 'noimplicitfloat', 'noinline', 'none',
418
+ 'nonlazybind', 'nonnull', 'norecurse', 'noRecurse', 'noredzone', 'noreturn',
419
+ 'notail', 'notEligibleToImport', 'nounwind', 'nsw', 'nsz', 'null', 'nuw', 'oeq',
420
+ 'offset', 'oge', 'ogt', 'ole', 'olt', 'one', 'opaque', 'optforfuzzing',
421
+ 'optnone', 'optsize', 'or', 'ord', 'path', 'personality', 'phi', 'poison',
422
+ 'prefix', 'preserve_allcc', 'preserve_mostcc', 'private', 'prologue',
423
+ 'protected', 'ptrtoint', 'ptx_device', 'ptx_kernel', 'readnone', 'readNone',
424
+ 'readonly', 'readOnly', 'reassoc', 'refs', 'relbf', 'release', 'resByArg',
425
+ 'resume', 'ret', 'returnDoesNotAlias', 'returned', 'returns_twice', 'safestack',
426
+ 'samesize', 'sanitize_address', 'sanitize_hwaddress', 'sanitize_memory',
427
+ 'sanitize_thread', 'sdiv', 'section', 'select', 'seq_cst', 'sext', 'sge', 'sgt',
428
+ 'shadowcallstack', 'shl', 'shufflevector', 'sideeffect', 'signext', 'single',
429
+ 'singleImpl', 'singleImplName', 'sitofp', 'sizeM1', 'sizeM1BitWidth', 'sle',
430
+ 'slt', 'source_filename', 'speculatable', 'spir_func', 'spir_kernel', 'srem',
431
+ 'sret', 'ssp', 'sspreq', 'sspstrong', 'store', 'strictfp', 'sub', 'summaries',
432
+ 'summary', 'swiftcc', 'swifterror', 'swiftself', 'switch', 'syncscope', 'tail',
433
+ 'target', 'thread_local', 'to', 'token', 'triple', 'true', 'trunc', 'type',
434
+ 'typeCheckedLoadConstVCalls', 'typeCheckedLoadVCalls', 'typeid', 'typeIdInfo',
435
+ 'typeTestAssumeConstVCalls', 'typeTestAssumeVCalls', 'typeTestRes', 'typeTests',
436
+ 'udiv', 'ueq', 'uge', 'ugt', 'uitofp', 'ule', 'ult', 'umax', 'umin', 'undef',
437
+ 'une', 'uniformRetVal', 'uniqueRetVal', 'unknown', 'unnamed_addr', 'uno',
438
+ 'unordered', 'unreachable', 'unsat', 'unwind', 'urem', 'uselistorder',
439
+ 'uselistorder_bb', 'uwtable', 'va_arg', 'variable', 'vFuncId',
440
+ 'virtualConstProp', 'void', 'volatile', 'weak', 'weak_odr', 'webkit_jscc',
441
+ 'win64cc', 'within', 'wpdRes', 'wpdResolutions', 'writeonly',
442
+ 'x86_64_sysvcc', 'x86_fastcallcc', 'x86_intrcc', 'x86_mmx',
443
+ 'x86_regcallcc', 'x86_stdcallcc', 'x86_thiscallcc', 'x86_vectorcallcc', 'xchg',
444
+ 'xor', 'zeroext', 'zeroinitializer', 'zext', 'immarg', 'willreturn'),
445
+ suffix=r'\b'), Keyword),
417
446
 
418
447
  # Types
419
- (words(('void', 'half', 'float', 'double', 'x86_fp80', 'fp128',
420
- 'ppc_fp128', 'label', 'metadata')), Keyword.Type),
448
+ (words(('void', 'half', 'bfloat', 'float', 'double', 'fp128',
449
+ 'x86_fp80', 'ppc_fp128', 'label', 'metadata', 'token')),
450
+ Keyword.Type),
421
451
 
422
452
  # Integer types
423
- (r'i[1-9]\d*', Keyword)
453
+ (r'i[1-9]\d*', Keyword.Type)
424
454
  ]
425
455
  }
426
456
 
457
+
458
+ class LlvmMirBodyLexer(RegexLexer):
459
+ """
460
+ For LLVM MIR examples without the YAML wrapper.
461
+
462
+ For more information on LLVM MIR see https://llvm.org/docs/MIRLangRef.html.
463
+
464
+ .. versionadded:: 2.6
465
+ """
466
+ name = 'LLVM-MIR Body'
467
+ aliases = ['llvm-mir-body']
468
+ filenames = []
469
+ mimetypes = []
470
+
471
+ tokens = {
472
+ 'root': [
473
+ # Attributes on basic blocks
474
+ (words(('liveins', 'successors'), suffix=':'), Keyword),
475
+ # Basic Block Labels
476
+ (r'bb\.[0-9]+(\.[a-zA-Z0-9_.-]+)?( \(address-taken\))?:', Name.Label),
477
+ (r'bb\.[0-9]+ \(%[a-zA-Z0-9_.-]+\)( \(address-taken\))?:', Name.Label),
478
+ (r'%bb\.[0-9]+(\.\w+)?', Name.Label),
479
+ # Stack references
480
+ (r'%stack\.[0-9]+(\.\w+\.addr)?', Name),
481
+ # Subreg indices
482
+ (r'%subreg\.\w+', Name),
483
+ # Virtual registers
484
+ (r'%[a-zA-Z0-9_]+ *', Name.Variable, 'vreg'),
485
+ # Reference to LLVM-IR global
486
+ include('global'),
487
+ # Reference to Intrinsic
488
+ (r'intrinsic\(\@[a-zA-Z0-9_.]+\)', Name.Variable.Global),
489
+ # Comparison predicates
490
+ (words(('eq', 'ne', 'sgt', 'sge', 'slt', 'sle', 'ugt', 'uge', 'ult',
491
+ 'ule'), prefix=r'intpred\(', suffix=r'\)'), Name.Builtin),
492
+ (words(('oeq', 'one', 'ogt', 'oge', 'olt', 'ole', 'ugt', 'uge',
493
+ 'ult', 'ule'), prefix=r'floatpred\(', suffix=r'\)'),
494
+ Name.Builtin),
495
+ # Physical registers
496
+ (r'\$\w+', String.Single),
497
+ # Assignment operator
498
+ (r'=', Operator),
499
+ # gMIR Opcodes
500
+ (r'(G_ANYEXT|G_[SZ]EXT|G_SEXT_INREG|G_TRUNC|G_IMPLICIT_DEF|G_PHI|'
501
+ r'G_FRAME_INDEX|G_GLOBAL_VALUE|G_INTTOPTR|G_PTRTOINT|G_BITCAST|'
502
+ r'G_CONSTANT|G_FCONSTANT|G_VASTART|G_VAARG|G_CTLZ|G_CTLZ_ZERO_UNDEF|'
503
+ r'G_CTTZ|G_CTTZ_ZERO_UNDEF|G_CTPOP|G_BSWAP|G_BITREVERSE|'
504
+ r'G_ADDRSPACE_CAST|G_BLOCK_ADDR|G_JUMP_TABLE|G_DYN_STACKALLOC|'
505
+ r'G_ADD|G_SUB|G_MUL|G_[SU]DIV|G_[SU]REM|G_AND|G_OR|G_XOR|G_SHL|'
506
+ r'G_[LA]SHR|G_[IF]CMP|G_SELECT|G_GEP|G_PTR_MASK|G_SMIN|G_SMAX|'
507
+ r'G_UMIN|G_UMAX|G_[US]ADDO|G_[US]ADDE|G_[US]SUBO|G_[US]SUBE|'
508
+ r'G_[US]MULO|G_[US]MULH|G_FNEG|G_FPEXT|G_FPTRUNC|G_FPTO[US]I|'
509
+ r'G_[US]ITOFP|G_FABS|G_FCOPYSIGN|G_FCANONICALIZE|G_FMINNUM|'
510
+ r'G_FMAXNUM|G_FMINNUM_IEEE|G_FMAXNUM_IEEE|G_FMINIMUM|G_FMAXIMUM|'
511
+ r'G_FADD|G_FSUB|G_FMUL|G_FMA|G_FMAD|G_FDIV|G_FREM|G_FPOW|G_FEXP|'
512
+ r'G_FEXP2|G_FLOG|G_FLOG2|G_FLOG10|G_FCEIL|G_FCOS|G_FSIN|G_FSQRT|'
513
+ r'G_FFLOOR|G_FRINT|G_FNEARBYINT|G_INTRINSIC_TRUNC|'
514
+ r'G_INTRINSIC_ROUND|G_LOAD|G_[ZS]EXTLOAD|G_INDEXED_LOAD|'
515
+ r'G_INDEXED_[ZS]EXTLOAD|G_STORE|G_INDEXED_STORE|'
516
+ r'G_ATOMIC_CMPXCHG_WITH_SUCCESS|G_ATOMIC_CMPXCHG|'
517
+ r'G_ATOMICRMW_(XCHG|ADD|SUB|AND|NAND|OR|XOR|MAX|MIN|UMAX|UMIN|FADD|'
518
+ r'FSUB)'
519
+ r'|G_FENCE|G_EXTRACT|G_UNMERGE_VALUES|G_INSERT|G_MERGE_VALUES|'
520
+ r'G_BUILD_VECTOR|G_BUILD_VECTOR_TRUNC|G_CONCAT_VECTORS|'
521
+ r'G_INTRINSIC|G_INTRINSIC_W_SIDE_EFFECTS|G_BR|G_BRCOND|'
522
+ r'G_BRINDIRECT|G_BRJT|G_INSERT_VECTOR_ELT|G_EXTRACT_VECTOR_ELT|'
523
+ r'G_SHUFFLE_VECTOR)\b',
524
+ Name.Builtin),
525
+ # Target independent opcodes
526
+ (r'(COPY|PHI|INSERT_SUBREG|EXTRACT_SUBREG|REG_SEQUENCE)\b',
527
+ Name.Builtin),
528
+ # Flags
529
+ (words(('killed', 'implicit')), Keyword),
530
+ # ConstantInt values
531
+ (r'i[0-9]+ +', Keyword.Type, 'constantint'),
532
+ # ConstantFloat values
533
+ (r'(half|float|double) +', Keyword.Type, 'constantfloat'),
534
+ # Bare immediates
535
+ include('integer'),
536
+ # MMO's
537
+ (r':: *', Operator, 'mmo'),
538
+ # MIR Comments
539
+ (r';.*', Comment),
540
+ # If we get here, assume it's a target instruction
541
+ (r'[a-zA-Z0-9_]+', Name),
542
+ # Everything else that isn't highlighted
543
+ (r'[(), \n]+', Text),
544
+ ],
545
+ # The integer constant from a ConstantInt value
546
+ 'constantint': [
547
+ include('integer'),
548
+ (r'(?=.)', Text, '#pop'),
549
+ ],
550
+ # The floating point constant from a ConstantFloat value
551
+ 'constantfloat': [
552
+ include('float'),
553
+ (r'(?=.)', Text, '#pop'),
554
+ ],
555
+ 'vreg': [
556
+ # The bank or class if there is one
557
+ (r' *:(?!:)', Keyword, ('#pop', 'vreg_bank_or_class')),
558
+ # The LLT if there is one
559
+ (r' *\(', Text, 'vreg_type'),
560
+ (r'(?=.)', Text, '#pop'),
561
+ ],
562
+ 'vreg_bank_or_class': [
563
+ # The unassigned bank/class
564
+ (r' *_', Name.Variable.Magic),
565
+ (r' *[a-zA-Z0-9_]+', Name.Variable),
566
+ # The LLT if there is one
567
+ (r' *\(', Text, 'vreg_type'),
568
+ (r'(?=.)', Text, '#pop'),
569
+ ],
570
+ 'vreg_type': [
571
+ # Scalar and pointer types
572
+ (r' *[sp][0-9]+', Keyword.Type),
573
+ (r' *<[0-9]+ *x *[sp][0-9]+>', Keyword.Type),
574
+ (r'\)', Text, '#pop'),
575
+ (r'(?=.)', Text, '#pop'),
576
+ ],
577
+ 'mmo': [
578
+ (r'\(', Text),
579
+ (r' +', Text),
580
+ (words(('load', 'store', 'on', 'into', 'from', 'align', 'monotonic',
581
+ 'acquire', 'release', 'acq_rel', 'seq_cst')),
582
+ Keyword),
583
+ # IR references
584
+ (r'%ir\.[a-zA-Z0-9_.-]+', Name),
585
+ (r'%ir-block\.[a-zA-Z0-9_.-]+', Name),
586
+ (r'[-+]', Operator),
587
+ include('integer'),
588
+ include('global'),
589
+ (r',', Punctuation),
590
+ (r'\), \(', Text),
591
+ (r'\)', Text, '#pop'),
592
+ ],
593
+ 'integer': [(r'-?[0-9]+', Number.Integer),],
594
+ 'float': [(r'-?[0-9]+\.[0-9]+(e[+-][0-9]+)?', Number.Float)],
595
+ 'global': [(r'\@[a-zA-Z0-9_.]+', Name.Variable.Global)],
596
+ }
597
+
598
+
599
+ class LlvmMirLexer(RegexLexer):
600
+ """
601
+ Lexer for the overall LLVM MIR document format.
602
+
603
+ MIR is a human readable serialization format that's used to represent LLVM's
604
+ machine specific intermediate representation. It allows LLVM's developers to
605
+ see the state of the compilation process at various points, as well as test
606
+ individual pieces of the compiler.
607
+
608
+ For more information on LLVM MIR see https://llvm.org/docs/MIRLangRef.html.
609
+
610
+ .. versionadded:: 2.6
611
+ """
612
+ name = 'LLVM-MIR'
613
+ aliases = ['llvm-mir']
614
+ filenames = ['*.mir']
615
+
616
+ tokens = {
617
+ 'root': [
618
+ # Comments are hashes at the YAML level
619
+ (r'#.*', Comment),
620
+ # Documents starting with | are LLVM-IR
621
+ (r'--- \|$', Keyword, 'llvm_ir'),
622
+ # Other documents are MIR
623
+ (r'---', Keyword, 'llvm_mir'),
624
+ # Consume everything else in one token for efficiency
625
+ (r'[^-#]+|.', Text),
626
+ ],
627
+ 'llvm_ir': [
628
+ # Documents end with '...' or '---'
629
+ (r'(\.\.\.|(?=---))', Keyword, '#pop'),
630
+ # Delegate to the LlvmLexer
631
+ (r'((?:.|\n)+?)(?=(\.\.\.|---))', bygroups(using(LlvmLexer))),
632
+ ],
633
+ 'llvm_mir': [
634
+ # Comments are hashes at the YAML level
635
+ (r'#.*', Comment),
636
+ # Documents end with '...' or '---'
637
+ (r'(\.\.\.|(?=---))', Keyword, '#pop'),
638
+ # Handle the simple attributes
639
+ (r'name:', Keyword, 'name'),
640
+ (words(('alignment', ),
641
+ suffix=':'), Keyword, 'number'),
642
+ (words(('legalized', 'regBankSelected', 'tracksRegLiveness',
643
+ 'selected', 'exposesReturnsTwice'),
644
+ suffix=':'), Keyword, 'boolean'),
645
+ # Handle the attributes don't highlight inside
646
+ (words(('registers', 'stack', 'fixedStack', 'liveins', 'frameInfo',
647
+ 'machineFunctionInfo'),
648
+ suffix=':'), Keyword),
649
+ # Delegate the body block to the LlvmMirBodyLexer
650
+ (r'body: *\|', Keyword, 'llvm_mir_body'),
651
+ # Consume everything else
652
+ (r'.+', Text),
653
+ (r'\n', Text),
654
+ ],
655
+ 'name': [
656
+ (r'[^\n]+', Name),
657
+ default('#pop'),
658
+ ],
659
+ 'boolean': [
660
+ (r' *(true|false)', Name.Builtin),
661
+ default('#pop'),
662
+ ],
663
+ 'number': [
664
+ (r' *[0-9]+', Number),
665
+ default('#pop'),
666
+ ],
667
+ 'llvm_mir_body': [
668
+ # Documents end with '...' or '---'.
669
+ # We have to pop llvm_mir_body and llvm_mir
670
+ (r'(\.\.\.|(?=---))', Keyword, '#pop:2'),
671
+ # Delegate the body block to the LlvmMirBodyLexer
672
+ (r'((?:.|\n)+?)(?=\.\.\.|---)', bygroups(using(LlvmMirBodyLexer))),
673
+ # The '...' is optional. If we didn't already find it then it isn't
674
+ # there. There might be a '---' instead though.
675
+ (r'(?!\.\.\.|---)((?:.|\n)+)', bygroups(using(LlvmMirBodyLexer))),
676
+ ],
677
+ }
678
+
679
+
427
680
  class NasmLexer(RegexLexer):
428
681
  """
429
682
  For Nasm (Intel) assembly code.
@@ -433,6 +686,10 @@ class NasmLexer(RegexLexer):
433
686
  filenames = ['*.asm', '*.ASM']
434
687
  mimetypes = ['text/x-nasm']
435
688
 
689
+ # Tasm uses the same file endings, but TASM is not as common as NASM, so
690
+ # we prioritize NASM higher by default
691
+ priority = 1.0
692
+
436
693
  identifier = r'[a-z$._?][\w$.?#@~]*'
437
694
  hexn = r'(?:0x[0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)'
438
695
  octn = r'[0-7]+q'
@@ -441,14 +698,16 @@ class NasmLexer(RegexLexer):
441
698
  floatn = decn + r'\.e?' + decn
442
699
  string = r'"(\\"|[^"\n])*"|' + r"'(\\'|[^'\n])*'|" + r"`(\\`|[^`\n])*`"
443
700
  declkw = r'(?:res|d)[bwdqt]|times'
444
- register = (r'r[0-9][0-5]?[bwd]|'
701
+ register = (r'r[0-9][0-5]?[bwd]?|'
445
702
  r'[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|'
446
703
  r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]')
447
704
  wordop = r'seg|wrt|strict'
448
705
  type = r'byte|[dq]?word'
449
- directives = (r'BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|'
706
+ # Directives must be followed by whitespace, otherwise CPU will match
707
+ # cpuid for instance.
708
+ directives = (r'(?:BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|'
450
709
  r'ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|'
451
- r'EXPORT|LIBRARY|MODULE')
710
+ r'EXPORT|LIBRARY|MODULE)\s+')
452
711
 
453
712
  flags = re.IGNORECASE | re.MULTILINE
454
713
  tokens = {
@@ -496,10 +755,15 @@ class NasmLexer(RegexLexer):
496
755
  ],
497
756
  }
498
757
 
758
+ def analyse_text(text):
759
+ # Probably TASM
760
+ if re.match(r'PROC', text, re.IGNORECASE):
761
+ return False
762
+
499
763
 
500
764
  class NasmObjdumpLexer(ObjdumpLexer):
501
765
  """
502
- For the output of 'objdump -d -M intel'.
766
+ For the output of ``objdump -d -M intel``.
503
767
 
504
768
  .. versionadded:: 2.0
505
769
  """
@@ -590,6 +854,11 @@ class TasmLexer(RegexLexer):
590
854
  ],
591
855
  }
592
856
 
857
+ def analyse_text(text):
858
+ # See above
859
+ if re.match(r'PROC', text, re.I):
860
+ return True
861
+
593
862
 
594
863
  class Ca65Lexer(RegexLexer):
595
864
  """
@@ -626,5 +895,111 @@ class Ca65Lexer(RegexLexer):
626
895
 
627
896
  def analyse_text(self, text):
628
897
  # comments in GAS start with "#"
629
- if re.match(r'^\s*;', text, re.MULTILINE):
898
+ if re.search(r'^\s*;', text, re.MULTILINE):
630
899
  return 0.9
900
+
901
+
902
+ class Dasm16Lexer(RegexLexer):
903
+ """
904
+ For DCPU-16 Assembly.
905
+
906
+ Check http://0x10c.com/doc/dcpu-16.txt
907
+
908
+ .. versionadded:: 2.4
909
+ """
910
+ name = 'DASM16'
911
+ aliases = ['dasm16']
912
+ filenames = ['*.dasm16', '*.dasm']
913
+ mimetypes = ['text/x-dasm16']
914
+
915
+ INSTRUCTIONS = [
916
+ 'SET',
917
+ 'ADD', 'SUB',
918
+ 'MUL', 'MLI',
919
+ 'DIV', 'DVI',
920
+ 'MOD', 'MDI',
921
+ 'AND', 'BOR', 'XOR',
922
+ 'SHR', 'ASR', 'SHL',
923
+ 'IFB', 'IFC', 'IFE', 'IFN', 'IFG', 'IFA', 'IFL', 'IFU',
924
+ 'ADX', 'SBX',
925
+ 'STI', 'STD',
926
+ 'JSR',
927
+ 'INT', 'IAG', 'IAS', 'RFI', 'IAQ', 'HWN', 'HWQ', 'HWI',
928
+ ]
929
+
930
+ REGISTERS = [
931
+ 'A', 'B', 'C',
932
+ 'X', 'Y', 'Z',
933
+ 'I', 'J',
934
+ 'SP', 'PC', 'EX',
935
+ 'POP', 'PEEK', 'PUSH'
936
+ ]
937
+
938
+ # Regexes yo
939
+ char = r'[a-zA-Z0-9_$@.]'
940
+ identifier = r'(?:[a-zA-Z$_]' + char + r'*|\.' + char + '+)'
941
+ number = r'[+-]?(?:0[xX][a-zA-Z0-9]+|\d+)'
942
+ binary_number = r'0b[01_]+'
943
+ instruction = r'(?i)(' + '|'.join(INSTRUCTIONS) + ')'
944
+ single_char = r"'\\?" + char + "'"
945
+ string = r'"(\\"|[^"])*"'
946
+
947
+ def guess_identifier(lexer, match):
948
+ ident = match.group(0)
949
+ klass = Name.Variable if ident.upper() in lexer.REGISTERS else Name.Label
950
+ yield match.start(), klass, ident
951
+
952
+ tokens = {
953
+ 'root': [
954
+ include('whitespace'),
955
+ (':' + identifier, Name.Label),
956
+ (identifier + ':', Name.Label),
957
+ (instruction, Name.Function, 'instruction-args'),
958
+ (r'\.' + identifier, Name.Function, 'data-args'),
959
+ (r'[\r\n]+', Text)
960
+ ],
961
+
962
+ 'numeric' : [
963
+ (binary_number, Number.Integer),
964
+ (number, Number.Integer),
965
+ (single_char, String),
966
+ ],
967
+
968
+ 'arg' : [
969
+ (identifier, guess_identifier),
970
+ include('numeric')
971
+ ],
972
+
973
+ 'deref' : [
974
+ (r'\+', Punctuation),
975
+ (r'\]', Punctuation, '#pop'),
976
+ include('arg'),
977
+ include('whitespace')
978
+ ],
979
+
980
+ 'instruction-line' : [
981
+ (r'[\r\n]+', Text, '#pop'),
982
+ (r';.*?$', Comment, '#pop'),
983
+ include('whitespace')
984
+ ],
985
+
986
+ 'instruction-args': [
987
+ (r',', Punctuation),
988
+ (r'\[', Punctuation, 'deref'),
989
+ include('arg'),
990
+ include('instruction-line')
991
+ ],
992
+
993
+ 'data-args' : [
994
+ (r',', Punctuation),
995
+ include('numeric'),
996
+ (string, String),
997
+ include('instruction-line')
998
+ ],
999
+
1000
+ 'whitespace': [
1001
+ (r'\n', Text),
1002
+ (r'\s+', Text),
1003
+ (r';.*?\n', Comment)
1004
+ ],
1005
+ }