pygments.rb 1.2.1 → 2.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,256 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.d
4
+ ~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for D languages.
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, include, words
13
+ from pygments.token import Text, Comment, Keyword, Name, String, \
14
+ Number, Punctuation
15
+
16
+ __all__ = ['DLexer', 'CrocLexer', 'MiniDLexer']
17
+
18
+
19
+ class DLexer(RegexLexer):
20
+ """
21
+ For D source.
22
+
23
+ .. versionadded:: 1.2
24
+ """
25
+ name = 'D'
26
+ filenames = ['*.d', '*.di']
27
+ aliases = ['d']
28
+ mimetypes = ['text/x-dsrc']
29
+
30
+ tokens = {
31
+ 'root': [
32
+ (r'\n', Text),
33
+ (r'\s+', Text),
34
+ # (r'\\\n', Text), # line continuations
35
+ # Comments
36
+ (r'//(.*?)\n', Comment.Single),
37
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
38
+ (r'/\+', Comment.Multiline, 'nested_comment'),
39
+ # Keywords
40
+ (words((
41
+ 'abstract', 'alias', 'align', 'asm', 'assert', 'auto', 'body',
42
+ 'break', 'case', 'cast', 'catch', 'class', 'const', 'continue',
43
+ 'debug', 'default', 'delegate', 'delete', 'deprecated', 'do', 'else',
44
+ 'enum', 'export', 'extern', 'finally', 'final', 'foreach_reverse',
45
+ 'foreach', 'for', 'function', 'goto', 'if', 'immutable', 'import',
46
+ 'interface', 'invariant', 'inout', 'in', 'is', 'lazy', 'mixin',
47
+ 'module', 'new', 'nothrow', 'out', 'override', 'package', 'pragma',
48
+ 'private', 'protected', 'public', 'pure', 'ref', 'return', 'scope',
49
+ 'shared', 'static', 'struct', 'super', 'switch', 'synchronized',
50
+ 'template', 'this', 'throw', 'try', 'typeid', 'typeof',
51
+ 'union', 'unittest', 'version', 'volatile', 'while', 'with',
52
+ '__gshared', '__traits', '__vector', '__parameters'),
53
+ suffix=r'\b'),
54
+ Keyword),
55
+ (words((
56
+ # Removed in 2.072
57
+ 'typedef', ),
58
+ suffix=r'\b'),
59
+ Keyword.Removed),
60
+ (words((
61
+ 'bool', 'byte', 'cdouble', 'cent', 'cfloat', 'char', 'creal',
62
+ 'dchar', 'double', 'float', 'idouble', 'ifloat', 'int', 'ireal',
63
+ 'long', 'real', 'short', 'ubyte', 'ucent', 'uint', 'ulong',
64
+ 'ushort', 'void', 'wchar'), suffix=r'\b'),
65
+ Keyword.Type),
66
+ (r'(false|true|null)\b', Keyword.Constant),
67
+ (words((
68
+ '__FILE__', '__FILE_FULL_PATH__', '__MODULE__', '__LINE__', '__FUNCTION__',
69
+ '__PRETTY_FUNCTION__', '__DATE__', '__EOF__', '__TIME__', '__TIMESTAMP__',
70
+ '__VENDOR__', '__VERSION__'), suffix=r'\b'),
71
+ Keyword.Pseudo),
72
+ (r'macro\b', Keyword.Reserved),
73
+ (r'(string|wstring|dstring|size_t|ptrdiff_t)\b', Name.Builtin),
74
+ # FloatLiteral
75
+ # -- HexFloat
76
+ (r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)'
77
+ r'[pP][+\-]?[0-9_]+[fFL]?[i]?', Number.Float),
78
+ # -- DecimalFloat
79
+ (r'[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|'
80
+ r'\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?', Number.Float),
81
+ (r'\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?', Number.Float),
82
+ # IntegerLiteral
83
+ # -- Binary
84
+ (r'0[Bb][01_]+', Number.Bin),
85
+ # -- Octal
86
+ (r'0[0-7_]+', Number.Oct),
87
+ # -- Hexadecimal
88
+ (r'0[xX][0-9a-fA-F_]+', Number.Hex),
89
+ # -- Decimal
90
+ (r'(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?', Number.Integer),
91
+ # CharacterLiteral
92
+ (r"""'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
93
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'""",
94
+ String.Char),
95
+ # StringLiteral
96
+ # -- WysiwygString
97
+ (r'r"[^"]*"[cwd]?', String),
98
+ # -- AlternateWysiwygString
99
+ (r'`[^`]*`[cwd]?', String),
100
+ # -- DoubleQuotedString
101
+ (r'"(\\\\|\\"|[^"])*"[cwd]?', String),
102
+ # -- EscapeSequence
103
+ (r"\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}"
104
+ r"|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)",
105
+ String),
106
+ # -- HexString
107
+ (r'x"[0-9a-fA-F_\s]*"[cwd]?', String),
108
+ # -- DelimitedString
109
+ (r'q"\[', String, 'delimited_bracket'),
110
+ (r'q"\(', String, 'delimited_parenthesis'),
111
+ (r'q"<', String, 'delimited_angle'),
112
+ (r'q"\{', String, 'delimited_curly'),
113
+ (r'q"([a-zA-Z_]\w*)\n.*?\n\1"', String),
114
+ (r'q"(.).*?\1"', String),
115
+ # -- TokenString
116
+ (r'q\{', String, 'token_string'),
117
+ # Attributes
118
+ (r'@([a-zA-Z_]\w*)?', Name.Decorator),
119
+ # Tokens
120
+ (r'(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>='
121
+ r'|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)'
122
+ r'|[/.&|\-+<>!()\[\]{}?,;:$=*%^~]', Punctuation),
123
+ # Identifier
124
+ (r'[a-zA-Z_]\w*', Name),
125
+ # Line
126
+ (r'#line\s.*\n', Comment.Special),
127
+ ],
128
+ 'nested_comment': [
129
+ (r'[^+/]+', Comment.Multiline),
130
+ (r'/\+', Comment.Multiline, '#push'),
131
+ (r'\+/', Comment.Multiline, '#pop'),
132
+ (r'[+/]', Comment.Multiline),
133
+ ],
134
+ 'token_string': [
135
+ (r'\{', Punctuation, 'token_string_nest'),
136
+ (r'\}', String, '#pop'),
137
+ include('root'),
138
+ ],
139
+ 'token_string_nest': [
140
+ (r'\{', Punctuation, '#push'),
141
+ (r'\}', Punctuation, '#pop'),
142
+ include('root'),
143
+ ],
144
+ 'delimited_bracket': [
145
+ (r'[^\[\]]+', String),
146
+ (r'\[', String, 'delimited_inside_bracket'),
147
+ (r'\]"', String, '#pop'),
148
+ ],
149
+ 'delimited_inside_bracket': [
150
+ (r'[^\[\]]+', String),
151
+ (r'\[', String, '#push'),
152
+ (r'\]', String, '#pop'),
153
+ ],
154
+ 'delimited_parenthesis': [
155
+ (r'[^()]+', String),
156
+ (r'\(', String, 'delimited_inside_parenthesis'),
157
+ (r'\)"', String, '#pop'),
158
+ ],
159
+ 'delimited_inside_parenthesis': [
160
+ (r'[^()]+', String),
161
+ (r'\(', String, '#push'),
162
+ (r'\)', String, '#pop'),
163
+ ],
164
+ 'delimited_angle': [
165
+ (r'[^<>]+', String),
166
+ (r'<', String, 'delimited_inside_angle'),
167
+ (r'>"', String, '#pop'),
168
+ ],
169
+ 'delimited_inside_angle': [
170
+ (r'[^<>]+', String),
171
+ (r'<', String, '#push'),
172
+ (r'>', String, '#pop'),
173
+ ],
174
+ 'delimited_curly': [
175
+ (r'[^{}]+', String),
176
+ (r'\{', String, 'delimited_inside_curly'),
177
+ (r'\}"', String, '#pop'),
178
+ ],
179
+ 'delimited_inside_curly': [
180
+ (r'[^{}]+', String),
181
+ (r'\{', String, '#push'),
182
+ (r'\}', String, '#pop'),
183
+ ],
184
+ }
185
+
186
+
187
+ class CrocLexer(RegexLexer):
188
+ """
189
+ For `Croc <http://jfbillingsley.com/croc>`_ source.
190
+ """
191
+ name = 'Croc'
192
+ filenames = ['*.croc']
193
+ aliases = ['croc']
194
+ mimetypes = ['text/x-crocsrc']
195
+
196
+ tokens = {
197
+ 'root': [
198
+ (r'\n', Text),
199
+ (r'\s+', Text),
200
+ # Comments
201
+ (r'//(.*?)\n', Comment.Single),
202
+ (r'/\*', Comment.Multiline, 'nestedcomment'),
203
+ # Keywords
204
+ (words((
205
+ 'as', 'assert', 'break', 'case', 'catch', 'class', 'continue',
206
+ 'default', 'do', 'else', 'finally', 'for', 'foreach', 'function',
207
+ 'global', 'namespace', 'if', 'import', 'in', 'is', 'local',
208
+ 'module', 'return', 'scope', 'super', 'switch', 'this', 'throw',
209
+ 'try', 'vararg', 'while', 'with', 'yield'), suffix=r'\b'),
210
+ Keyword),
211
+ (r'(false|true|null)\b', Keyword.Constant),
212
+ # FloatLiteral
213
+ (r'([0-9][0-9_]*)(?=[.eE])(\.[0-9][0-9_]*)?([eE][+\-]?[0-9_]+)?',
214
+ Number.Float),
215
+ # IntegerLiteral
216
+ # -- Binary
217
+ (r'0[bB][01][01_]*', Number.Bin),
218
+ # -- Hexadecimal
219
+ (r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex),
220
+ # -- Decimal
221
+ (r'([0-9][0-9_]*)(?![.eE])', Number.Integer),
222
+ # CharacterLiteral
223
+ (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-9]{1,3}"""
224
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
225
+ String.Char),
226
+ # StringLiteral
227
+ # -- WysiwygString
228
+ (r'@"(""|[^"])*"', String),
229
+ (r'@`(``|[^`])*`', String),
230
+ (r"@'(''|[^'])*'", String),
231
+ # -- DoubleQuotedString
232
+ (r'"(\\\\|\\"|[^"])*"', String),
233
+ # Tokens
234
+ (r'(~=|\^=|%=|\*=|==|!=|>>>=|>>>|>>=|>>|>=|<=>|\?=|-\>'
235
+ r'|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.|/=)'
236
+ r'|[-/.&$@|\+<>!()\[\]{}?,;:=*%^~#\\]', Punctuation),
237
+ # Identifier
238
+ (r'[a-zA-Z_]\w*', Name),
239
+ ],
240
+ 'nestedcomment': [
241
+ (r'[^*/]+', Comment.Multiline),
242
+ (r'/\*', Comment.Multiline, '#push'),
243
+ (r'\*/', Comment.Multiline, '#pop'),
244
+ (r'[*/]', Comment.Multiline),
245
+ ],
246
+ }
247
+
248
+
249
+ class MiniDLexer(CrocLexer):
250
+ """
251
+ For MiniD source. MiniD is now known as Croc.
252
+ """
253
+ name = 'MiniD'
254
+ filenames = [] # don't lex .md as MiniD, reserve for Markdown
255
+ aliases = ['minid']
256
+ mimetypes = ['text/x-minidsrc']
@@ -0,0 +1,125 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.dalvik
4
+ ~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Pygments lexers for Dalvik VM-related 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 RegexLexer, include, bygroups
15
+ from pygments.token import Keyword, Text, Comment, Name, String, Number, \
16
+ Punctuation
17
+
18
+ __all__ = ['SmaliLexer']
19
+
20
+
21
+ class SmaliLexer(RegexLexer):
22
+ """
23
+ For `Smali <http://code.google.com/p/smali/>`_ (Android/Dalvik) assembly
24
+ code.
25
+
26
+ .. versionadded:: 1.6
27
+ """
28
+ name = 'Smali'
29
+ aliases = ['smali']
30
+ filenames = ['*.smali']
31
+ mimetypes = ['text/smali']
32
+
33
+ tokens = {
34
+ 'root': [
35
+ include('comment'),
36
+ include('label'),
37
+ include('field'),
38
+ include('method'),
39
+ include('class'),
40
+ include('directive'),
41
+ include('access-modifier'),
42
+ include('instruction'),
43
+ include('literal'),
44
+ include('punctuation'),
45
+ include('type'),
46
+ include('whitespace')
47
+ ],
48
+ 'directive': [
49
+ (r'^[ \t]*\.(class|super|implements|field|subannotation|annotation|'
50
+ r'enum|method|registers|locals|array-data|packed-switch|'
51
+ r'sparse-switch|catchall|catch|line|parameter|local|prologue|'
52
+ r'epilogue|source)', Keyword),
53
+ (r'^[ \t]*\.end (field|subannotation|annotation|method|array-data|'
54
+ 'packed-switch|sparse-switch|parameter|local)', Keyword),
55
+ (r'^[ \t]*\.restart local', Keyword),
56
+ ],
57
+ 'access-modifier': [
58
+ (r'(public|private|protected|static|final|synchronized|bridge|'
59
+ r'varargs|native|abstract|strictfp|synthetic|constructor|'
60
+ r'declared-synchronized|interface|enum|annotation|volatile|'
61
+ r'transient)', Keyword),
62
+ ],
63
+ 'whitespace': [
64
+ (r'\n', Text),
65
+ (r'\s+', Text),
66
+ ],
67
+ 'instruction': [
68
+ (r'\b[vp]\d+\b', Name.Builtin), # registers
69
+ (r'\b[a-z][A-Za-z0-9/-]+\s+', Text), # instructions
70
+ ],
71
+ 'literal': [
72
+ (r'".*"', String),
73
+ (r'0x[0-9A-Fa-f]+t?', Number.Hex),
74
+ (r'[0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
75
+ (r'[0-9]+L?', Number.Integer),
76
+ ],
77
+ 'field': [
78
+ (r'(\$?\b)([\w$]*)(:)',
79
+ bygroups(Punctuation, Name.Variable, Punctuation)),
80
+ ],
81
+ 'method': [
82
+ (r'<(?:cl)?init>', Name.Function), # constructor
83
+ (r'(\$?\b)([\w$]*)(\()',
84
+ bygroups(Punctuation, Name.Function, Punctuation)),
85
+ ],
86
+ 'label': [
87
+ (r':\w+', Name.Label),
88
+ ],
89
+ 'class': [
90
+ # class names in the form Lcom/namespace/ClassName;
91
+ # I only want to color the ClassName part, so the namespace part is
92
+ # treated as 'Text'
93
+ (r'(L)((?:[\w$]+/)*)([\w$]+)(;)',
94
+ bygroups(Keyword.Type, Text, Name.Class, Text)),
95
+ ],
96
+ 'punctuation': [
97
+ (r'->', Punctuation),
98
+ (r'[{},():=.-]', Punctuation),
99
+ ],
100
+ 'type': [
101
+ (r'[ZBSCIJFDV\[]+', Keyword.Type),
102
+ ],
103
+ 'comment': [
104
+ (r'#.*?\n', Comment),
105
+ ],
106
+ }
107
+
108
+ def analyse_text(text):
109
+ score = 0
110
+ if re.search(r'^\s*\.class\s', text, re.MULTILINE):
111
+ score += 0.5
112
+ if re.search(r'\b((check-cast|instance-of|throw-verification-error'
113
+ r')\b|(-to|add|[ais]get|[ais]put|and|cmpl|const|div|'
114
+ r'if|invoke|move|mul|neg|not|or|rem|return|rsub|shl|'
115
+ r'shr|sub|ushr)[-/])|{|}', text, re.MULTILINE):
116
+ score += 0.3
117
+ if re.search(r'(\.(catchall|epilogue|restart local|prologue)|'
118
+ r'\b(array-data|class-change-error|declared-synchronized|'
119
+ r'(field|inline|vtable)@0x[0-9a-fA-F]|generic-error|'
120
+ r'illegal-class-access|illegal-field-access|'
121
+ r'illegal-method-access|instantiation-error|no-error|'
122
+ r'no-such-class|no-such-field|no-such-method|'
123
+ r'packed-switch|sparse-switch))\b', text, re.MULTILINE):
124
+ score += 0.6
125
+ return score
@@ -0,0 +1,698 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.data
4
+ ~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for data file format.
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, ExtendedRegexLexer, LexerContext, \
15
+ include, bygroups, inherit
16
+ from pygments.token import Text, Comment, Keyword, Name, String, Number, \
17
+ Punctuation, Literal, Error
18
+
19
+ __all__ = ['YamlLexer', 'JsonLexer', 'JsonBareObjectLexer', 'JsonLdLexer']
20
+
21
+
22
+ class YamlLexerContext(LexerContext):
23
+ """Indentation context for the YAML lexer."""
24
+
25
+ def __init__(self, *args, **kwds):
26
+ super().__init__(*args, **kwds)
27
+ self.indent_stack = []
28
+ self.indent = -1
29
+ self.next_indent = 0
30
+ self.block_scalar_indent = None
31
+
32
+
33
+ class YamlLexer(ExtendedRegexLexer):
34
+ """
35
+ Lexer for `YAML <http://yaml.org/>`_, a human-friendly data serialization
36
+ language.
37
+
38
+ .. versionadded:: 0.11
39
+ """
40
+
41
+ name = 'YAML'
42
+ aliases = ['yaml']
43
+ filenames = ['*.yaml', '*.yml']
44
+ mimetypes = ['text/x-yaml']
45
+
46
+ def something(token_class):
47
+ """Do not produce empty tokens."""
48
+ def callback(lexer, match, context):
49
+ text = match.group()
50
+ if not text:
51
+ return
52
+ yield match.start(), token_class, text
53
+ context.pos = match.end()
54
+ return callback
55
+
56
+ def reset_indent(token_class):
57
+ """Reset the indentation levels."""
58
+ def callback(lexer, match, context):
59
+ text = match.group()
60
+ context.indent_stack = []
61
+ context.indent = -1
62
+ context.next_indent = 0
63
+ context.block_scalar_indent = None
64
+ yield match.start(), token_class, text
65
+ context.pos = match.end()
66
+ return callback
67
+
68
+ def save_indent(token_class, start=False):
69
+ """Save a possible indentation level."""
70
+ def callback(lexer, match, context):
71
+ text = match.group()
72
+ extra = ''
73
+ if start:
74
+ context.next_indent = len(text)
75
+ if context.next_indent < context.indent:
76
+ while context.next_indent < context.indent:
77
+ context.indent = context.indent_stack.pop()
78
+ if context.next_indent > context.indent:
79
+ extra = text[context.indent:]
80
+ text = text[:context.indent]
81
+ else:
82
+ context.next_indent += len(text)
83
+ if text:
84
+ yield match.start(), token_class, text
85
+ if extra:
86
+ yield match.start()+len(text), token_class.Error, extra
87
+ context.pos = match.end()
88
+ return callback
89
+
90
+ def set_indent(token_class, implicit=False):
91
+ """Set the previously saved indentation level."""
92
+ def callback(lexer, match, context):
93
+ text = match.group()
94
+ if context.indent < context.next_indent:
95
+ context.indent_stack.append(context.indent)
96
+ context.indent = context.next_indent
97
+ if not implicit:
98
+ context.next_indent += len(text)
99
+ yield match.start(), token_class, text
100
+ context.pos = match.end()
101
+ return callback
102
+
103
+ def set_block_scalar_indent(token_class):
104
+ """Set an explicit indentation level for a block scalar."""
105
+ def callback(lexer, match, context):
106
+ text = match.group()
107
+ context.block_scalar_indent = None
108
+ if not text:
109
+ return
110
+ increment = match.group(1)
111
+ if increment:
112
+ current_indent = max(context.indent, 0)
113
+ increment = int(increment)
114
+ context.block_scalar_indent = current_indent + increment
115
+ if text:
116
+ yield match.start(), token_class, text
117
+ context.pos = match.end()
118
+ return callback
119
+
120
+ def parse_block_scalar_empty_line(indent_token_class, content_token_class):
121
+ """Process an empty line in a block scalar."""
122
+ def callback(lexer, match, context):
123
+ text = match.group()
124
+ if (context.block_scalar_indent is None or
125
+ len(text) <= context.block_scalar_indent):
126
+ if text:
127
+ yield match.start(), indent_token_class, text
128
+ else:
129
+ indentation = text[:context.block_scalar_indent]
130
+ content = text[context.block_scalar_indent:]
131
+ yield match.start(), indent_token_class, indentation
132
+ yield (match.start()+context.block_scalar_indent,
133
+ content_token_class, content)
134
+ context.pos = match.end()
135
+ return callback
136
+
137
+ def parse_block_scalar_indent(token_class):
138
+ """Process indentation spaces in a block scalar."""
139
+ def callback(lexer, match, context):
140
+ text = match.group()
141
+ if context.block_scalar_indent is None:
142
+ if len(text) <= max(context.indent, 0):
143
+ context.stack.pop()
144
+ context.stack.pop()
145
+ return
146
+ context.block_scalar_indent = len(text)
147
+ else:
148
+ if len(text) < context.block_scalar_indent:
149
+ context.stack.pop()
150
+ context.stack.pop()
151
+ return
152
+ if text:
153
+ yield match.start(), token_class, text
154
+ context.pos = match.end()
155
+ return callback
156
+
157
+ def parse_plain_scalar_indent(token_class):
158
+ """Process indentation spaces in a plain scalar."""
159
+ def callback(lexer, match, context):
160
+ text = match.group()
161
+ if len(text) <= context.indent:
162
+ context.stack.pop()
163
+ context.stack.pop()
164
+ return
165
+ if text:
166
+ yield match.start(), token_class, text
167
+ context.pos = match.end()
168
+ return callback
169
+
170
+ tokens = {
171
+ # the root rules
172
+ 'root': [
173
+ # ignored whitespaces
174
+ (r'[ ]+(?=#|$)', Text),
175
+ # line breaks
176
+ (r'\n+', Text),
177
+ # a comment
178
+ (r'#[^\n]*', Comment.Single),
179
+ # the '%YAML' directive
180
+ (r'^%YAML(?=[ ]|$)', reset_indent(Name.Tag), 'yaml-directive'),
181
+ # the %TAG directive
182
+ (r'^%TAG(?=[ ]|$)', reset_indent(Name.Tag), 'tag-directive'),
183
+ # document start and document end indicators
184
+ (r'^(?:---|\.\.\.)(?=[ ]|$)', reset_indent(Name.Namespace),
185
+ 'block-line'),
186
+ # indentation spaces
187
+ (r'[ ]*(?!\s|$)', save_indent(Text, start=True),
188
+ ('block-line', 'indentation')),
189
+ ],
190
+
191
+ # trailing whitespaces after directives or a block scalar indicator
192
+ 'ignored-line': [
193
+ # ignored whitespaces
194
+ (r'[ ]+(?=#|$)', Text),
195
+ # a comment
196
+ (r'#[^\n]*', Comment.Single),
197
+ # line break
198
+ (r'\n', Text, '#pop:2'),
199
+ ],
200
+
201
+ # the %YAML directive
202
+ 'yaml-directive': [
203
+ # the version number
204
+ (r'([ ]+)([0-9]+\.[0-9]+)',
205
+ bygroups(Text, Number), 'ignored-line'),
206
+ ],
207
+
208
+ # the %TAG directive
209
+ 'tag-directive': [
210
+ # a tag handle and the corresponding prefix
211
+ (r'([ ]+)(!|![\w-]*!)'
212
+ r'([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)',
213
+ bygroups(Text, Keyword.Type, Text, Keyword.Type),
214
+ 'ignored-line'),
215
+ ],
216
+
217
+ # block scalar indicators and indentation spaces
218
+ 'indentation': [
219
+ # trailing whitespaces are ignored
220
+ (r'[ ]*$', something(Text), '#pop:2'),
221
+ # whitespaces preceding block collection indicators
222
+ (r'[ ]+(?=[?:-](?:[ ]|$))', save_indent(Text)),
223
+ # block collection indicators
224
+ (r'[?:-](?=[ ]|$)', set_indent(Punctuation.Indicator)),
225
+ # the beginning a block line
226
+ (r'[ ]*', save_indent(Text), '#pop'),
227
+ ],
228
+
229
+ # an indented line in the block context
230
+ 'block-line': [
231
+ # the line end
232
+ (r'[ ]*(?=#|$)', something(Text), '#pop'),
233
+ # whitespaces separating tokens
234
+ (r'[ ]+', Text),
235
+ # key with colon
236
+ (r'''([^#,:?\[\]{}"'\n]+)(:)(?=[ ]|$)''',
237
+ bygroups(Name.Tag, set_indent(Punctuation, implicit=True))),
238
+ # tags, anchors and aliases,
239
+ include('descriptors'),
240
+ # block collections and scalars
241
+ include('block-nodes'),
242
+ # flow collections and quoted scalars
243
+ include('flow-nodes'),
244
+ # a plain scalar
245
+ (r'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)',
246
+ something(Name.Variable),
247
+ 'plain-scalar-in-block-context'),
248
+ ],
249
+
250
+ # tags, anchors, aliases
251
+ 'descriptors': [
252
+ # a full-form tag
253
+ (r'!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>', Keyword.Type),
254
+ # a tag in the form '!', '!suffix' or '!handle!suffix'
255
+ (r'!(?:[\w-]+!)?'
256
+ r'[\w#;/?:@&=+$,.!~*\'()\[\]%-]*', Keyword.Type),
257
+ # an anchor
258
+ (r'&[\w-]+', Name.Label),
259
+ # an alias
260
+ (r'\*[\w-]+', Name.Variable),
261
+ ],
262
+
263
+ # block collections and scalars
264
+ 'block-nodes': [
265
+ # implicit key
266
+ (r':(?=[ ]|$)', set_indent(Punctuation.Indicator, implicit=True)),
267
+ # literal and folded scalars
268
+ (r'[|>]', Punctuation.Indicator,
269
+ ('block-scalar-content', 'block-scalar-header')),
270
+ ],
271
+
272
+ # flow collections and quoted scalars
273
+ 'flow-nodes': [
274
+ # a flow sequence
275
+ (r'\[', Punctuation.Indicator, 'flow-sequence'),
276
+ # a flow mapping
277
+ (r'\{', Punctuation.Indicator, 'flow-mapping'),
278
+ # a single-quoted scalar
279
+ (r'\'', String, 'single-quoted-scalar'),
280
+ # a double-quoted scalar
281
+ (r'\"', String, 'double-quoted-scalar'),
282
+ ],
283
+
284
+ # the content of a flow collection
285
+ 'flow-collection': [
286
+ # whitespaces
287
+ (r'[ ]+', Text),
288
+ # line breaks
289
+ (r'\n+', Text),
290
+ # a comment
291
+ (r'#[^\n]*', Comment.Single),
292
+ # simple indicators
293
+ (r'[?:,]', Punctuation.Indicator),
294
+ # tags, anchors and aliases
295
+ include('descriptors'),
296
+ # nested collections and quoted scalars
297
+ include('flow-nodes'),
298
+ # a plain scalar
299
+ (r'(?=[^\s?:,\[\]{}#&*!|>\'"%@`])',
300
+ something(Name.Variable),
301
+ 'plain-scalar-in-flow-context'),
302
+ ],
303
+
304
+ # a flow sequence indicated by '[' and ']'
305
+ 'flow-sequence': [
306
+ # include flow collection rules
307
+ include('flow-collection'),
308
+ # the closing indicator
309
+ (r'\]', Punctuation.Indicator, '#pop'),
310
+ ],
311
+
312
+ # a flow mapping indicated by '{' and '}'
313
+ 'flow-mapping': [
314
+ # key with colon
315
+ (r'''([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$)''',
316
+ bygroups(Name.Tag, Punctuation)),
317
+ # include flow collection rules
318
+ include('flow-collection'),
319
+ # the closing indicator
320
+ (r'\}', Punctuation.Indicator, '#pop'),
321
+ ],
322
+
323
+ # block scalar lines
324
+ 'block-scalar-content': [
325
+ # line break
326
+ (r'\n', Text),
327
+ # empty line
328
+ (r'^[ ]+$',
329
+ parse_block_scalar_empty_line(Text, Name.Constant)),
330
+ # indentation spaces (we may leave the state here)
331
+ (r'^[ ]*', parse_block_scalar_indent(Text)),
332
+ # line content
333
+ (r'[\S\t ]+', Name.Constant),
334
+ ],
335
+
336
+ # the content of a literal or folded scalar
337
+ 'block-scalar-header': [
338
+ # indentation indicator followed by chomping flag
339
+ (r'([1-9])?[+-]?(?=[ ]|$)',
340
+ set_block_scalar_indent(Punctuation.Indicator),
341
+ 'ignored-line'),
342
+ # chomping flag followed by indentation indicator
343
+ (r'[+-]?([1-9])?(?=[ ]|$)',
344
+ set_block_scalar_indent(Punctuation.Indicator),
345
+ 'ignored-line'),
346
+ ],
347
+
348
+ # ignored and regular whitespaces in quoted scalars
349
+ 'quoted-scalar-whitespaces': [
350
+ # leading and trailing whitespaces are ignored
351
+ (r'^[ ]+', Text),
352
+ (r'[ ]+$', Text),
353
+ # line breaks are ignored
354
+ (r'\n+', Text),
355
+ # other whitespaces are a part of the value
356
+ (r'[ ]+', Name.Variable),
357
+ ],
358
+
359
+ # single-quoted scalars
360
+ 'single-quoted-scalar': [
361
+ # include whitespace and line break rules
362
+ include('quoted-scalar-whitespaces'),
363
+ # escaping of the quote character
364
+ (r'\'\'', String.Escape),
365
+ # regular non-whitespace characters
366
+ (r'[^\s\']+', String),
367
+ # the closing quote
368
+ (r'\'', String, '#pop'),
369
+ ],
370
+
371
+ # double-quoted scalars
372
+ 'double-quoted-scalar': [
373
+ # include whitespace and line break rules
374
+ include('quoted-scalar-whitespaces'),
375
+ # escaping of special characters
376
+ (r'\\[0abt\tn\nvfre "\\N_LP]', String),
377
+ # escape codes
378
+ (r'\\(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})',
379
+ String.Escape),
380
+ # regular non-whitespace characters
381
+ (r'[^\s"\\]+', String),
382
+ # the closing quote
383
+ (r'"', String, '#pop'),
384
+ ],
385
+
386
+ # the beginning of a new line while scanning a plain scalar
387
+ 'plain-scalar-in-block-context-new-line': [
388
+ # empty lines
389
+ (r'^[ ]+$', Text),
390
+ # line breaks
391
+ (r'\n+', Text),
392
+ # document start and document end indicators
393
+ (r'^(?=---|\.\.\.)', something(Name.Namespace), '#pop:3'),
394
+ # indentation spaces (we may leave the block line state here)
395
+ (r'^[ ]*', parse_plain_scalar_indent(Text), '#pop'),
396
+ ],
397
+
398
+ # a plain scalar in the block context
399
+ 'plain-scalar-in-block-context': [
400
+ # the scalar ends with the ':' indicator
401
+ (r'[ ]*(?=:[ ]|:$)', something(Text), '#pop'),
402
+ # the scalar ends with whitespaces followed by a comment
403
+ (r'[ ]+(?=#)', Text, '#pop'),
404
+ # trailing whitespaces are ignored
405
+ (r'[ ]+$', Text),
406
+ # line breaks are ignored
407
+ (r'\n+', Text, 'plain-scalar-in-block-context-new-line'),
408
+ # other whitespaces are a part of the value
409
+ (r'[ ]+', Literal.Scalar.Plain),
410
+ # regular non-whitespace characters
411
+ (r'(?::(?!\s)|[^\s:])+', Literal.Scalar.Plain),
412
+ ],
413
+
414
+ # a plain scalar is the flow context
415
+ 'plain-scalar-in-flow-context': [
416
+ # the scalar ends with an indicator character
417
+ (r'[ ]*(?=[,:?\[\]{}])', something(Text), '#pop'),
418
+ # the scalar ends with a comment
419
+ (r'[ ]+(?=#)', Text, '#pop'),
420
+ # leading and trailing whitespaces are ignored
421
+ (r'^[ ]+', Text),
422
+ (r'[ ]+$', Text),
423
+ # line breaks are ignored
424
+ (r'\n+', Text),
425
+ # other whitespaces are a part of the value
426
+ (r'[ ]+', Name.Variable),
427
+ # regular non-whitespace characters
428
+ (r'[^\s,:?\[\]{}]+', Name.Variable),
429
+ ],
430
+
431
+ }
432
+
433
+ def get_tokens_unprocessed(self, text=None, context=None):
434
+ if context is None:
435
+ context = YamlLexerContext(text, 0)
436
+ return super().get_tokens_unprocessed(text, context)
437
+
438
+
439
+ class JsonLexer(Lexer):
440
+ """
441
+ For JSON data structures.
442
+
443
+ .. versionadded:: 1.5
444
+ """
445
+
446
+ name = 'JSON'
447
+ aliases = ['json', 'json-object']
448
+ filenames = ['*.json', 'Pipfile.lock']
449
+ mimetypes = ['application/json', 'application/json-object']
450
+
451
+ # No validation of integers, floats, or constants is done.
452
+ # As long as the characters are members of the following
453
+ # sets, the token will be considered valid. For example,
454
+ #
455
+ # "--1--" is parsed as an integer
456
+ # "1...eee" is parsed as a float
457
+ # "trustful" is parsed as a constant
458
+ #
459
+ integers = set('-0123456789')
460
+ floats = set('.eE+')
461
+ constants = set('truefalsenull') # true|false|null
462
+ hexadecimals = set('0123456789abcdefABCDEF')
463
+ punctuations = set('{}[],')
464
+ whitespaces = {'\u0020', '\u000a', '\u000d', '\u0009'}
465
+
466
+ def get_tokens_unprocessed(self, text):
467
+ """Parse JSON data."""
468
+
469
+ in_string = False
470
+ in_escape = False
471
+ in_unicode_escape = 0
472
+ in_whitespace = False
473
+ in_constant = False
474
+ in_number = False
475
+ in_float = False
476
+ in_punctuation = False
477
+
478
+ start = 0
479
+
480
+ # The queue is used to store data that may need to be tokenized
481
+ # differently based on what follows. In particular, JSON object
482
+ # keys are tokenized differently than string values, but cannot
483
+ # be distinguished until punctuation is encountered outside the
484
+ # string.
485
+ #
486
+ # A ":" character after the string indicates that the string is
487
+ # an object key; any other character indicates the string is a
488
+ # regular string value.
489
+ #
490
+ # The queue holds tuples that contain the following data:
491
+ #
492
+ # (start_index, token_type, text)
493
+ #
494
+ # By default the token type of text in double quotes is
495
+ # String.Double. The token type will be replaced if a colon
496
+ # is encountered after the string closes.
497
+ #
498
+ queue = []
499
+
500
+ for stop, character in enumerate(text):
501
+ if in_string:
502
+ if in_unicode_escape:
503
+ if character in self.hexadecimals:
504
+ in_unicode_escape -= 1
505
+ if not in_unicode_escape:
506
+ in_escape = False
507
+ else:
508
+ in_unicode_escape = 0
509
+ in_escape = False
510
+
511
+ elif in_escape:
512
+ if character == 'u':
513
+ in_unicode_escape = 4
514
+ else:
515
+ in_escape = False
516
+
517
+ elif character == '\\':
518
+ in_escape = True
519
+
520
+ elif character == '"':
521
+ queue.append((start, String.Double, text[start:stop + 1]))
522
+ in_string = False
523
+ in_escape = False
524
+ in_unicode_escape = 0
525
+
526
+ continue
527
+
528
+ elif in_whitespace:
529
+ if character in self.whitespaces:
530
+ continue
531
+
532
+ if queue:
533
+ queue.append((start, Text, text[start:stop]))
534
+ else:
535
+ yield start, Text, text[start:stop]
536
+ in_whitespace = False
537
+ # Fall through so the new character can be evaluated.
538
+
539
+ elif in_constant:
540
+ if character in self.constants:
541
+ continue
542
+
543
+ yield start, Keyword.Constant, text[start:stop]
544
+ in_constant = False
545
+ # Fall through so the new character can be evaluated.
546
+
547
+ elif in_number:
548
+ if character in self.integers:
549
+ continue
550
+ elif character in self.floats:
551
+ in_float = True
552
+ continue
553
+
554
+ if in_float:
555
+ yield start, Number.Float, text[start:stop]
556
+ else:
557
+ yield start, Number.Integer, text[start:stop]
558
+ in_number = False
559
+ in_float = False
560
+ # Fall through so the new character can be evaluated.
561
+
562
+ elif in_punctuation:
563
+ if character in self.punctuations:
564
+ continue
565
+
566
+ yield start, Punctuation, text[start:stop]
567
+ in_punctuation = False
568
+ # Fall through so the new character can be evaluated.
569
+
570
+ start = stop
571
+
572
+ if character == '"':
573
+ in_string = True
574
+
575
+ elif character in self.whitespaces:
576
+ in_whitespace = True
577
+
578
+ elif character in {'f', 'n', 't'}: # The first letters of true|false|null
579
+ # Exhaust the queue. Accept the existing token types.
580
+ yield from queue
581
+ queue.clear()
582
+
583
+ in_constant = True
584
+
585
+ elif character in self.integers:
586
+ # Exhaust the queue. Accept the existing token types.
587
+ yield from queue
588
+ queue.clear()
589
+
590
+ in_number = True
591
+
592
+ elif character == ':':
593
+ # Yield from the queue. Replace string token types.
594
+ for _start, _token, _text in queue:
595
+ if _token is Text:
596
+ yield _start, _token, _text
597
+ elif _token is String.Double:
598
+ yield _start, Name.Tag, _text
599
+ else:
600
+ yield _start, Error, _text
601
+ queue.clear()
602
+
603
+ in_punctuation = True
604
+
605
+ elif character in self.punctuations:
606
+ # Exhaust the queue. Accept the existing token types.
607
+ yield from queue
608
+ queue.clear()
609
+
610
+ in_punctuation = True
611
+
612
+ else:
613
+ # Exhaust the queue. Accept the existing token types.
614
+ yield from queue
615
+ queue.clear()
616
+
617
+ yield start, Error, character
618
+
619
+ # Yield any remaining text.
620
+ yield from queue
621
+ if in_string:
622
+ yield start, Error, text[start:]
623
+ elif in_float:
624
+ yield start, Number.Float, text[start:]
625
+ elif in_number:
626
+ yield start, Number.Integer, text[start:]
627
+ elif in_constant:
628
+ yield start, Keyword.Constant, text[start:]
629
+ elif in_whitespace:
630
+ yield start, Text, text[start:]
631
+ elif in_punctuation:
632
+ yield start, Punctuation, text[start:]
633
+
634
+
635
+ class JsonBareObjectLexer(JsonLexer):
636
+ """
637
+ For JSON data structures (with missing object curly braces).
638
+
639
+ .. versionadded:: 2.2
640
+
641
+ .. deprecated:: 2.8.0
642
+
643
+ Behaves the same as `JsonLexer` now.
644
+ """
645
+
646
+ name = 'JSONBareObject'
647
+ aliases = []
648
+ filenames = []
649
+ mimetypes = []
650
+
651
+
652
+ class JsonLdLexer(JsonLexer):
653
+ """
654
+ For `JSON-LD <https://json-ld.org/>`_ linked data.
655
+
656
+ .. versionadded:: 2.0
657
+ """
658
+
659
+ name = 'JSON-LD'
660
+ aliases = ['jsonld', 'json-ld']
661
+ filenames = ['*.jsonld']
662
+ mimetypes = ['application/ld+json']
663
+
664
+ json_ld_keywords = {
665
+ '"@%s"' % keyword
666
+ for keyword in (
667
+ 'base',
668
+ 'container',
669
+ 'context',
670
+ 'direction',
671
+ 'graph',
672
+ 'id',
673
+ 'import',
674
+ 'included',
675
+ 'index',
676
+ 'json',
677
+ 'language',
678
+ 'list',
679
+ 'nest',
680
+ 'none',
681
+ 'prefix',
682
+ 'propagate',
683
+ 'protected',
684
+ 'reverse',
685
+ 'set',
686
+ 'type',
687
+ 'value',
688
+ 'version',
689
+ 'vocab',
690
+ )
691
+ }
692
+
693
+ def get_tokens_unprocessed(self, text):
694
+ for start, token, value in super(JsonLdLexer, self).get_tokens_unprocessed(text):
695
+ if token is Name.Tag and value in self.json_ld_keywords:
696
+ yield start, Name.Decorator, value
697
+ else:
698
+ yield start, token, value