pygments.rb 1.2.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (386) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +13 -0
  3. data/.github/workflows/ci.yml +40 -0
  4. data/.github/workflows/release.yml +24 -0
  5. data/.gitignore +4 -6
  6. data/.rubocop.yml +16 -0
  7. data/CHANGELOG.adoc +137 -0
  8. data/Gemfile +3 -1
  9. data/LICENSE +1 -1
  10. data/README.adoc +159 -0
  11. data/Rakefile +8 -32
  12. data/bench.rb +14 -8
  13. data/lib/pygments.rb +16 -14
  14. data/lib/pygments/lexer.rb +87 -65
  15. data/lib/pygments/mentos.py +23 -110
  16. data/lib/pygments/popen.rb +188 -284
  17. data/lib/pygments/version.rb +2 -2
  18. data/pygments.rb.gemspec +20 -13
  19. data/test/test_pygments.rb +50 -110
  20. data/vendor/pygments-main/{AUTHORS → Pygments-2.8.1.dist-info/AUTHORS} +26 -3
  21. data/vendor/pygments-main/Pygments-2.8.1.dist-info/INSTALLER +1 -0
  22. data/vendor/pygments-main/{LICENSE → Pygments-2.8.1.dist-info/LICENSE} +1 -1
  23. data/vendor/pygments-main/Pygments-2.8.1.dist-info/METADATA +48 -0
  24. data/vendor/pygments-main/Pygments-2.8.1.dist-info/RECORD +494 -0
  25. data/vendor/pygments-main/Pygments-2.8.1.dist-info/REQUESTED +0 -0
  26. data/vendor/pygments-main/Pygments-2.8.1.dist-info/WHEEL +5 -0
  27. data/vendor/pygments-main/Pygments-2.8.1.dist-info/entry_points.txt +3 -0
  28. data/vendor/pygments-main/Pygments-2.8.1.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 -12
  31. data/vendor/pygments-main/pygments/__main__.py +17 -0
  32. data/vendor/pygments-main/pygments/cmdline.py +213 -184
  33. data/vendor/pygments-main/pygments/console.py +6 -10
  34. data/vendor/pygments-main/pygments/filter.py +4 -7
  35. data/vendor/pygments-main/pygments/filters/__init__.py +609 -22
  36. data/vendor/pygments-main/pygments/formatter.py +4 -5
  37. data/vendor/pygments-main/pygments/formatters/__init__.py +10 -10
  38. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -4
  39. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -2
  40. data/vendor/pygments-main/pygments/formatters/html.py +242 -139
  41. data/vendor/pygments-main/pygments/formatters/img.py +91 -50
  42. data/vendor/pygments-main/pygments/formatters/irc.py +39 -40
  43. data/vendor/pygments-main/pygments/formatters/latex.py +62 -33
  44. data/vendor/pygments-main/pygments/formatters/other.py +18 -17
  45. data/vendor/pygments-main/pygments/formatters/rtf.py +29 -30
  46. data/vendor/pygments-main/pygments/formatters/svg.py +40 -5
  47. data/vendor/pygments-main/pygments/formatters/terminal.py +25 -32
  48. data/vendor/pygments-main/pygments/formatters/terminal256.py +45 -14
  49. data/vendor/pygments-main/pygments/lexer.py +47 -44
  50. data/vendor/pygments-main/pygments/lexers/__init__.py +341 -0
  51. data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +1644 -0
  52. data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +231 -0
  53. data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +75 -0
  54. data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1724 -0
  55. data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +5326 -0
  56. data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +292 -0
  57. data/vendor/pygments-main/pygments/lexers/_mapping.py +554 -0
  58. data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +1171 -0
  59. data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +1281 -0
  60. data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +2600 -0
  61. data/vendor/pygments-main/pygments/lexers/_php_builtins.py +4752 -0
  62. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +677 -0
  63. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +3093 -0
  64. data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1160 -0
  65. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +557 -0
  66. data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +457 -0
  67. data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1003 -0
  68. data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +112 -0
  69. data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +279 -0
  70. data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1938 -0
  71. data/vendor/pygments-main/pygments/lexers/actionscript.py +244 -0
  72. data/vendor/pygments-main/pygments/lexers/agile.py +23 -0
  73. data/vendor/pygments-main/pygments/lexers/algebra.py +239 -0
  74. data/vendor/pygments-main/pygments/lexers/ambient.py +75 -0
  75. data/vendor/pygments-main/pygments/lexers/amdgpu.py +48 -0
  76. data/vendor/pygments-main/pygments/lexers/ampl.py +86 -0
  77. data/vendor/pygments-main/pygments/lexers/apl.py +100 -0
  78. data/vendor/pygments-main/pygments/lexers/archetype.py +317 -0
  79. data/vendor/pygments-main/pygments/lexers/arrow.py +116 -0
  80. data/vendor/pygments-main/pygments/lexers/asm.py +1004 -0
  81. data/vendor/pygments-main/pygments/lexers/automation.py +379 -0
  82. data/vendor/pygments-main/pygments/lexers/bare.py +103 -0
  83. data/vendor/pygments-main/pygments/lexers/basic.py +661 -0
  84. data/vendor/pygments-main/pygments/lexers/bibtex.py +159 -0
  85. data/vendor/pygments-main/pygments/lexers/boa.py +101 -0
  86. data/vendor/pygments-main/pygments/lexers/business.py +626 -0
  87. data/vendor/pygments-main/pygments/lexers/c_cpp.py +342 -0
  88. data/vendor/pygments-main/pygments/lexers/c_like.py +565 -0
  89. data/vendor/pygments-main/pygments/lexers/capnproto.py +77 -0
  90. data/vendor/pygments-main/pygments/lexers/cddl.py +190 -0
  91. data/vendor/pygments-main/pygments/lexers/chapel.py +111 -0
  92. data/vendor/pygments-main/pygments/lexers/clean.py +178 -0
  93. data/vendor/pygments-main/pygments/lexers/compiled.py +33 -0
  94. data/vendor/pygments-main/pygments/lexers/configs.py +985 -0
  95. data/vendor/pygments-main/pygments/lexers/console.py +113 -0
  96. data/vendor/pygments-main/pygments/lexers/crystal.py +366 -0
  97. data/vendor/pygments-main/pygments/lexers/csound.py +466 -0
  98. data/vendor/pygments-main/pygments/lexers/css.py +694 -0
  99. data/vendor/pygments-main/pygments/lexers/d.py +255 -0
  100. data/vendor/pygments-main/pygments/lexers/dalvik.py +124 -0
  101. data/vendor/pygments-main/pygments/lexers/data.py +697 -0
  102. data/vendor/pygments-main/pygments/lexers/devicetree.py +108 -0
  103. data/vendor/pygments-main/pygments/lexers/diff.py +164 -0
  104. data/vendor/pygments-main/pygments/lexers/dotnet.py +706 -0
  105. data/vendor/pygments-main/pygments/lexers/dsls.py +959 -0
  106. data/vendor/pygments-main/pygments/lexers/dylan.py +286 -0
  107. data/vendor/pygments-main/pygments/lexers/ecl.py +137 -0
  108. data/vendor/pygments-main/pygments/lexers/eiffel.py +64 -0
  109. data/vendor/pygments-main/pygments/lexers/elm.py +120 -0
  110. data/vendor/pygments-main/pygments/lexers/email.py +150 -0
  111. data/vendor/pygments-main/pygments/lexers/erlang.py +529 -0
  112. data/vendor/pygments-main/pygments/lexers/esoteric.py +303 -0
  113. data/vendor/pygments-main/pygments/lexers/ezhil.py +76 -0
  114. data/vendor/pygments-main/pygments/lexers/factor.py +343 -0
  115. data/vendor/pygments-main/pygments/lexers/fantom.py +249 -0
  116. data/vendor/pygments-main/pygments/lexers/felix.py +272 -0
  117. data/vendor/pygments-main/pygments/lexers/floscript.py +82 -0
  118. data/vendor/pygments-main/pygments/lexers/forth.py +177 -0
  119. data/vendor/pygments-main/pygments/lexers/fortran.py +208 -0
  120. data/vendor/pygments-main/pygments/lexers/foxpro.py +427 -0
  121. data/vendor/pygments-main/pygments/lexers/freefem.py +897 -0
  122. data/vendor/pygments-main/pygments/lexers/functional.py +20 -0
  123. data/vendor/pygments-main/pygments/lexers/futhark.py +110 -0
  124. data/vendor/pygments-main/pygments/lexers/gdscript.py +345 -0
  125. data/vendor/pygments-main/pygments/lexers/go.py +100 -0
  126. data/vendor/pygments-main/pygments/lexers/grammar_notation.py +269 -0
  127. data/vendor/pygments-main/pygments/lexers/graph.py +84 -0
  128. data/vendor/pygments-main/pygments/lexers/graphics.py +799 -0
  129. data/vendor/pygments-main/pygments/lexers/graphviz.py +57 -0
  130. data/vendor/pygments-main/pygments/lexers/haskell.py +869 -0
  131. data/vendor/pygments-main/pygments/lexers/haxe.py +935 -0
  132. data/vendor/pygments-main/pygments/lexers/hdl.py +468 -0
  133. data/vendor/pygments-main/pygments/lexers/hexdump.py +102 -0
  134. data/vendor/pygments-main/pygments/lexers/html.py +613 -0
  135. data/vendor/pygments-main/pygments/lexers/idl.py +280 -0
  136. data/vendor/pygments-main/pygments/lexers/igor.py +419 -0
  137. data/vendor/pygments-main/pygments/lexers/inferno.py +95 -0
  138. data/vendor/pygments-main/pygments/lexers/installers.py +321 -0
  139. data/vendor/pygments-main/pygments/lexers/int_fiction.py +1367 -0
  140. data/vendor/pygments-main/pygments/lexers/iolang.py +62 -0
  141. data/vendor/pygments-main/pygments/lexers/j.py +145 -0
  142. data/vendor/pygments-main/pygments/lexers/javascript.py +1536 -0
  143. data/vendor/pygments-main/pygments/lexers/julia.py +330 -0
  144. data/vendor/pygments-main/pygments/lexers/jvm.py +1739 -0
  145. data/vendor/pygments-main/pygments/lexers/lisp.py +2698 -0
  146. data/vendor/pygments-main/pygments/lexers/make.py +205 -0
  147. data/vendor/pygments-main/pygments/lexers/markup.py +762 -0
  148. data/vendor/pygments-main/pygments/lexers/math.py +20 -0
  149. data/vendor/pygments-main/pygments/lexers/matlab.py +3280 -0
  150. data/vendor/pygments-main/pygments/lexers/mime.py +225 -0
  151. data/vendor/pygments-main/pygments/lexers/ml.py +957 -0
  152. data/vendor/pygments-main/pygments/lexers/modeling.py +365 -0
  153. data/vendor/pygments-main/pygments/lexers/modula2.py +1579 -0
  154. data/vendor/pygments-main/pygments/lexers/monte.py +203 -0
  155. data/vendor/pygments-main/pygments/lexers/mosel.py +447 -0
  156. data/vendor/pygments-main/pygments/lexers/ncl.py +893 -0
  157. data/vendor/pygments-main/pygments/lexers/nimrod.py +158 -0
  158. data/vendor/pygments-main/pygments/lexers/nit.py +63 -0
  159. data/vendor/pygments-main/pygments/lexers/nix.py +135 -0
  160. data/vendor/pygments-main/pygments/lexers/oberon.py +120 -0
  161. data/vendor/pygments-main/pygments/lexers/objective.py +503 -0
  162. data/vendor/pygments-main/pygments/lexers/ooc.py +84 -0
  163. data/vendor/pygments-main/pygments/lexers/other.py +40 -0
  164. data/vendor/pygments-main/pygments/lexers/parasail.py +78 -0
  165. data/vendor/pygments-main/pygments/lexers/parsers.py +799 -0
  166. data/vendor/pygments-main/pygments/lexers/pascal.py +643 -0
  167. data/vendor/pygments-main/pygments/lexers/pawn.py +202 -0
  168. data/vendor/pygments-main/pygments/lexers/perl.py +731 -0
  169. data/vendor/pygments-main/pygments/lexers/php.py +320 -0
  170. data/vendor/pygments-main/pygments/lexers/pointless.py +70 -0
  171. data/vendor/pygments-main/pygments/lexers/pony.py +93 -0
  172. data/vendor/pygments-main/pygments/lexers/praat.py +301 -0
  173. data/vendor/pygments-main/pygments/lexers/prolog.py +305 -0
  174. data/vendor/pygments-main/pygments/lexers/promql.py +182 -0
  175. data/vendor/pygments-main/pygments/lexers/python.py +1158 -0
  176. data/vendor/pygments-main/pygments/lexers/qvt.py +151 -0
  177. data/vendor/pygments-main/pygments/lexers/r.py +190 -0
  178. data/vendor/pygments-main/pygments/lexers/rdf.py +462 -0
  179. data/vendor/pygments-main/pygments/lexers/rebol.py +430 -0
  180. data/vendor/pygments-main/pygments/lexers/resource.py +84 -0
  181. data/vendor/pygments-main/pygments/lexers/ride.py +138 -0
  182. data/vendor/pygments-main/pygments/lexers/rnc.py +66 -0
  183. data/vendor/pygments-main/pygments/lexers/roboconf.py +81 -0
  184. data/vendor/pygments-main/pygments/lexers/robotframework.py +551 -0
  185. data/vendor/pygments-main/pygments/lexers/ruby.py +523 -0
  186. data/vendor/pygments-main/pygments/lexers/rust.py +223 -0
  187. data/vendor/pygments-main/pygments/lexers/sas.py +227 -0
  188. data/vendor/pygments-main/pygments/lexers/scdoc.py +82 -0
  189. data/vendor/pygments-main/pygments/lexers/scripting.py +1283 -0
  190. data/vendor/pygments-main/pygments/lexers/sgf.py +60 -0
  191. data/vendor/pygments-main/pygments/lexers/shell.py +909 -0
  192. data/vendor/pygments-main/pygments/lexers/sieve.py +68 -0
  193. data/vendor/pygments-main/pygments/lexers/slash.py +184 -0
  194. data/vendor/pygments-main/pygments/lexers/smalltalk.py +194 -0
  195. data/vendor/pygments-main/pygments/lexers/smv.py +78 -0
  196. data/vendor/pygments-main/pygments/lexers/snobol.py +82 -0
  197. data/vendor/pygments-main/pygments/lexers/solidity.py +91 -0
  198. data/vendor/pygments-main/pygments/lexers/special.py +106 -0
  199. data/vendor/pygments-main/pygments/lexers/sql.py +832 -0
  200. data/vendor/pygments-main/pygments/lexers/stata.py +170 -0
  201. data/vendor/pygments-main/pygments/lexers/supercollider.py +94 -0
  202. data/vendor/pygments-main/pygments/lexers/tcl.py +144 -0
  203. data/vendor/pygments-main/pygments/lexers/templates.py +2263 -0
  204. data/vendor/pygments-main/pygments/lexers/teraterm.py +334 -0
  205. data/vendor/pygments-main/pygments/lexers/testing.py +206 -0
  206. data/vendor/pygments-main/pygments/lexers/text.py +25 -0
  207. data/vendor/pygments-main/pygments/lexers/textedit.py +168 -0
  208. data/vendor/pygments-main/pygments/lexers/textfmts.py +429 -0
  209. data/vendor/pygments-main/pygments/lexers/theorem.py +476 -0
  210. data/vendor/pygments-main/pygments/lexers/tnt.py +262 -0
  211. data/vendor/pygments-main/pygments/lexers/trafficscript.py +53 -0
  212. data/vendor/pygments-main/pygments/lexers/typoscript.py +218 -0
  213. data/vendor/pygments-main/pygments/lexers/unicon.py +411 -0
  214. data/vendor/pygments-main/pygments/lexers/urbi.py +145 -0
  215. data/vendor/pygments-main/pygments/lexers/usd.py +89 -0
  216. data/vendor/pygments-main/pygments/lexers/varnish.py +189 -0
  217. data/vendor/pygments-main/pygments/lexers/verification.py +113 -0
  218. data/vendor/pygments-main/pygments/lexers/web.py +23 -0
  219. data/vendor/pygments-main/pygments/lexers/webidl.py +298 -0
  220. data/vendor/pygments-main/pygments/lexers/webmisc.py +991 -0
  221. data/vendor/pygments-main/pygments/lexers/whiley.py +115 -0
  222. data/vendor/pygments-main/pygments/lexers/x10.py +68 -0
  223. data/vendor/pygments-main/pygments/lexers/xorg.py +36 -0
  224. data/vendor/pygments-main/pygments/lexers/yang.py +103 -0
  225. data/vendor/pygments-main/pygments/lexers/zig.py +123 -0
  226. data/vendor/pygments-main/pygments/modeline.py +1 -2
  227. data/vendor/pygments-main/pygments/plugin.py +4 -3
  228. data/vendor/pygments-main/pygments/regexopt.py +1 -2
  229. data/vendor/pygments-main/pygments/scanner.py +2 -3
  230. data/vendor/pygments-main/pygments/sphinxext.py +2 -5
  231. data/vendor/pygments-main/pygments/style.py +61 -25
  232. data/vendor/pygments-main/pygments/styles/__init__.py +12 -5
  233. data/vendor/pygments-main/pygments/styles/abap.py +1 -2
  234. data/vendor/pygments-main/pygments/styles/algol.py +1 -2
  235. data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -2
  236. data/vendor/pygments-main/pygments/styles/arduino.py +2 -3
  237. data/vendor/pygments-main/pygments/styles/autumn.py +1 -2
  238. data/vendor/pygments-main/pygments/styles/borland.py +1 -2
  239. data/vendor/pygments-main/pygments/styles/bw.py +1 -2
  240. data/vendor/pygments-main/pygments/styles/colorful.py +1 -2
  241. data/vendor/pygments-main/pygments/styles/default.py +1 -2
  242. data/vendor/pygments-main/pygments/styles/emacs.py +1 -2
  243. data/vendor/pygments-main/pygments/styles/friendly.py +1 -2
  244. data/vendor/pygments-main/pygments/styles/fruity.py +1 -2
  245. data/vendor/pygments-main/pygments/styles/igor.py +1 -2
  246. data/vendor/pygments-main/pygments/styles/inkpot.py +66 -0
  247. data/vendor/pygments-main/pygments/styles/lovelace.py +1 -2
  248. data/vendor/pygments-main/pygments/styles/manni.py +1 -2
  249. data/vendor/pygments-main/pygments/styles/material.py +118 -0
  250. data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
  251. data/vendor/pygments-main/pygments/styles/murphy.py +1 -2
  252. data/vendor/pygments-main/pygments/styles/native.py +1 -2
  253. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -2
  254. data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -2
  255. data/vendor/pygments-main/pygments/styles/pastie.py +1 -2
  256. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -2
  257. data/vendor/pygments-main/pygments/styles/rainbow_dash.py +1 -2
  258. data/vendor/pygments-main/pygments/styles/rrt.py +1 -2
  259. data/vendor/pygments-main/pygments/styles/sas.py +1 -2
  260. data/vendor/pygments-main/pygments/styles/solarized.py +136 -0
  261. data/vendor/pygments-main/pygments/styles/stata_dark.py +40 -0
  262. data/vendor/pygments-main/pygments/styles/{stata.py → stata_light.py} +14 -16
  263. data/vendor/pygments-main/pygments/styles/tango.py +1 -2
  264. data/vendor/pygments-main/pygments/styles/trac.py +1 -2
  265. data/vendor/pygments-main/pygments/styles/vim.py +1 -2
  266. data/vendor/pygments-main/pygments/styles/vs.py +1 -2
  267. data/vendor/pygments-main/pygments/styles/xcode.py +1 -2
  268. data/vendor/pygments-main/pygments/styles/zenburn.py +80 -0
  269. data/vendor/pygments-main/pygments/token.py +1 -2
  270. data/vendor/pygments-main/pygments/unistring.py +47 -109
  271. data/vendor/pygments-main/pygments/util.py +16 -96
  272. metadata +81 -139
  273. data/CHANGELOG.md +0 -111
  274. data/README.md +0 -121
  275. data/cache-lexers.rb +0 -8
  276. data/circle.yml +0 -20
  277. data/test/test_data.c +0 -2581
  278. data/test/test_data.py +0 -514
  279. data/test/test_data_generated +0 -2582
  280. data/vendor/custom_lexers/github.py +0 -565
  281. data/vendor/pygments-main/CHANGES +0 -1186
  282. data/vendor/pygments-main/MANIFEST.in +0 -6
  283. data/vendor/pygments-main/Makefile +0 -65
  284. data/vendor/pygments-main/README.rst +0 -39
  285. data/vendor/pygments-main/REVISION +0 -1
  286. data/vendor/pygments-main/TODO +0 -12
  287. data/vendor/pygments-main/doc/Makefile +0 -153
  288. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  289. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  290. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  291. data/vendor/pygments-main/doc/_templates/docssidebar.html +0 -3
  292. data/vendor/pygments-main/doc/_templates/indexsidebar.html +0 -25
  293. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +0 -98
  294. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  295. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  296. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  297. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  298. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  299. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +0 -401
  300. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +0 -15
  301. data/vendor/pygments-main/doc/conf.py +0 -241
  302. data/vendor/pygments-main/doc/docs/api.rst +0 -354
  303. data/vendor/pygments-main/doc/docs/authors.rst +0 -4
  304. data/vendor/pygments-main/doc/docs/changelog.rst +0 -1
  305. data/vendor/pygments-main/doc/docs/cmdline.rst +0 -166
  306. data/vendor/pygments-main/doc/docs/filterdevelopment.rst +0 -71
  307. data/vendor/pygments-main/doc/docs/filters.rst +0 -41
  308. data/vendor/pygments-main/doc/docs/formatterdevelopment.rst +0 -169
  309. data/vendor/pygments-main/doc/docs/formatters.rst +0 -48
  310. data/vendor/pygments-main/doc/docs/index.rst +0 -66
  311. data/vendor/pygments-main/doc/docs/integrate.rst +0 -40
  312. data/vendor/pygments-main/doc/docs/java.rst +0 -70
  313. data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +0 -728
  314. data/vendor/pygments-main/doc/docs/lexers.rst +0 -69
  315. data/vendor/pygments-main/doc/docs/moinmoin.rst +0 -39
  316. data/vendor/pygments-main/doc/docs/plugins.rst +0 -93
  317. data/vendor/pygments-main/doc/docs/quickstart.rst +0 -205
  318. data/vendor/pygments-main/doc/docs/rstdirective.rst +0 -22
  319. data/vendor/pygments-main/doc/docs/styles.rst +0 -201
  320. data/vendor/pygments-main/doc/docs/tokens.rst +0 -372
  321. data/vendor/pygments-main/doc/docs/unicode.rst +0 -58
  322. data/vendor/pygments-main/doc/download.rst +0 -41
  323. data/vendor/pygments-main/doc/faq.rst +0 -139
  324. data/vendor/pygments-main/doc/index.rst +0 -54
  325. data/vendor/pygments-main/doc/languages.rst +0 -154
  326. data/vendor/pygments-main/doc/make.bat +0 -190
  327. data/vendor/pygments-main/doc/pygmentize.1 +0 -94
  328. data/vendor/pygments-main/external/autopygmentize +0 -101
  329. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +0 -162
  330. data/vendor/pygments-main/external/markdown-processor.py +0 -67
  331. data/vendor/pygments-main/external/moin-parser.py +0 -112
  332. data/vendor/pygments-main/external/pygments.bashcomp +0 -38
  333. data/vendor/pygments-main/external/rst-directive.py +0 -82
  334. data/vendor/pygments-main/pygmentize +0 -8
  335. data/vendor/pygments-main/requirements.txt +0 -5
  336. data/vendor/pygments-main/scripts/check_sources.py +0 -211
  337. data/vendor/pygments-main/scripts/debug_lexer.py +0 -246
  338. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +0 -33
  339. data/vendor/pygments-main/scripts/epydoc.css +0 -280
  340. data/vendor/pygments-main/scripts/get_vimkw.py +0 -74
  341. data/vendor/pygments-main/scripts/pylintrc +0 -301
  342. data/vendor/pygments-main/scripts/vim2pygments.py +0 -935
  343. data/vendor/pygments-main/setup.cfg +0 -10
  344. data/vendor/pygments-main/setup.py +0 -77
  345. data/vendor/pygments-main/tox.ini +0 -7
  346. data/vendor/simplejson/.gitignore +0 -10
  347. data/vendor/simplejson/.travis.yml +0 -5
  348. data/vendor/simplejson/CHANGES.txt +0 -291
  349. data/vendor/simplejson/LICENSE.txt +0 -19
  350. data/vendor/simplejson/MANIFEST.in +0 -5
  351. data/vendor/simplejson/README.rst +0 -19
  352. data/vendor/simplejson/conf.py +0 -179
  353. data/vendor/simplejson/index.rst +0 -628
  354. data/vendor/simplejson/scripts/make_docs.py +0 -18
  355. data/vendor/simplejson/setup.py +0 -104
  356. data/vendor/simplejson/simplejson/__init__.py +0 -510
  357. data/vendor/simplejson/simplejson/_speedups.c +0 -2745
  358. data/vendor/simplejson/simplejson/decoder.py +0 -425
  359. data/vendor/simplejson/simplejson/encoder.py +0 -567
  360. data/vendor/simplejson/simplejson/ordered_dict.py +0 -119
  361. data/vendor/simplejson/simplejson/scanner.py +0 -77
  362. data/vendor/simplejson/simplejson/tests/__init__.py +0 -67
  363. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +0 -55
  364. data/vendor/simplejson/simplejson/tests/test_check_circular.py +0 -30
  365. data/vendor/simplejson/simplejson/tests/test_decimal.py +0 -66
  366. data/vendor/simplejson/simplejson/tests/test_decode.py +0 -83
  367. data/vendor/simplejson/simplejson/tests/test_default.py +0 -9
  368. data/vendor/simplejson/simplejson/tests/test_dump.py +0 -67
  369. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +0 -46
  370. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +0 -32
  371. data/vendor/simplejson/simplejson/tests/test_errors.py +0 -34
  372. data/vendor/simplejson/simplejson/tests/test_fail.py +0 -91
  373. data/vendor/simplejson/simplejson/tests/test_float.py +0 -19
  374. data/vendor/simplejson/simplejson/tests/test_indent.py +0 -86
  375. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +0 -20
  376. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +0 -121
  377. data/vendor/simplejson/simplejson/tests/test_pass1.py +0 -76
  378. data/vendor/simplejson/simplejson/tests/test_pass2.py +0 -14
  379. data/vendor/simplejson/simplejson/tests/test_pass3.py +0 -20
  380. data/vendor/simplejson/simplejson/tests/test_recursion.py +0 -67
  381. data/vendor/simplejson/simplejson/tests/test_scanstring.py +0 -117
  382. data/vendor/simplejson/simplejson/tests/test_separators.py +0 -42
  383. data/vendor/simplejson/simplejson/tests/test_speedups.py +0 -20
  384. data/vendor/simplejson/simplejson/tests/test_tuple.py +0 -49
  385. data/vendor/simplejson/simplejson/tests/test_unicode.py +0 -109
  386. data/vendor/simplejson/simplejson/tool.py +0 -39
@@ -0,0 +1,255 @@
1
+ """
2
+ pygments.lexers.d
3
+ ~~~~~~~~~~~~~~~~~
4
+
5
+ Lexers for D languages.
6
+
7
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
8
+ :license: BSD, see LICENSE for details.
9
+ """
10
+
11
+ from pygments.lexer import RegexLexer, include, words
12
+ from pygments.token import Text, Comment, Keyword, Name, String, \
13
+ Number, Punctuation
14
+
15
+ __all__ = ['DLexer', 'CrocLexer', 'MiniDLexer']
16
+
17
+
18
+ class DLexer(RegexLexer):
19
+ """
20
+ For D source.
21
+
22
+ .. versionadded:: 1.2
23
+ """
24
+ name = 'D'
25
+ filenames = ['*.d', '*.di']
26
+ aliases = ['d']
27
+ mimetypes = ['text/x-dsrc']
28
+
29
+ tokens = {
30
+ 'root': [
31
+ (r'\n', Text),
32
+ (r'\s+', Text),
33
+ # (r'\\\n', Text), # line continuations
34
+ # Comments
35
+ (r'//(.*?)\n', Comment.Single),
36
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
37
+ (r'/\+', Comment.Multiline, 'nested_comment'),
38
+ # Keywords
39
+ (words((
40
+ 'abstract', 'alias', 'align', 'asm', 'assert', 'auto', 'body',
41
+ 'break', 'case', 'cast', 'catch', 'class', 'const', 'continue',
42
+ 'debug', 'default', 'delegate', 'delete', 'deprecated', 'do', 'else',
43
+ 'enum', 'export', 'extern', 'finally', 'final', 'foreach_reverse',
44
+ 'foreach', 'for', 'function', 'goto', 'if', 'immutable', 'import',
45
+ 'interface', 'invariant', 'inout', 'in', 'is', 'lazy', 'mixin',
46
+ 'module', 'new', 'nothrow', 'out', 'override', 'package', 'pragma',
47
+ 'private', 'protected', 'public', 'pure', 'ref', 'return', 'scope',
48
+ 'shared', 'static', 'struct', 'super', 'switch', 'synchronized',
49
+ 'template', 'this', 'throw', 'try', 'typeid', 'typeof',
50
+ 'union', 'unittest', 'version', 'volatile', 'while', 'with',
51
+ '__gshared', '__traits', '__vector', '__parameters'),
52
+ suffix=r'\b'),
53
+ Keyword),
54
+ (words((
55
+ # Removed in 2.072
56
+ 'typedef', ),
57
+ suffix=r'\b'),
58
+ Keyword.Removed),
59
+ (words((
60
+ 'bool', 'byte', 'cdouble', 'cent', 'cfloat', 'char', 'creal',
61
+ 'dchar', 'double', 'float', 'idouble', 'ifloat', 'int', 'ireal',
62
+ 'long', 'real', 'short', 'ubyte', 'ucent', 'uint', 'ulong',
63
+ 'ushort', 'void', 'wchar'), suffix=r'\b'),
64
+ Keyword.Type),
65
+ (r'(false|true|null)\b', Keyword.Constant),
66
+ (words((
67
+ '__FILE__', '__FILE_FULL_PATH__', '__MODULE__', '__LINE__', '__FUNCTION__',
68
+ '__PRETTY_FUNCTION__', '__DATE__', '__EOF__', '__TIME__', '__TIMESTAMP__',
69
+ '__VENDOR__', '__VERSION__'), suffix=r'\b'),
70
+ Keyword.Pseudo),
71
+ (r'macro\b', Keyword.Reserved),
72
+ (r'(string|wstring|dstring|size_t|ptrdiff_t)\b', Name.Builtin),
73
+ # FloatLiteral
74
+ # -- HexFloat
75
+ (r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)'
76
+ r'[pP][+\-]?[0-9_]+[fFL]?[i]?', Number.Float),
77
+ # -- DecimalFloat
78
+ (r'[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|'
79
+ r'\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?', Number.Float),
80
+ (r'\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?', Number.Float),
81
+ # IntegerLiteral
82
+ # -- Binary
83
+ (r'0[Bb][01_]+', Number.Bin),
84
+ # -- Octal
85
+ (r'0[0-7_]+', Number.Oct),
86
+ # -- Hexadecimal
87
+ (r'0[xX][0-9a-fA-F_]+', Number.Hex),
88
+ # -- Decimal
89
+ (r'(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?', Number.Integer),
90
+ # CharacterLiteral
91
+ (r"""'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
92
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'""",
93
+ String.Char),
94
+ # StringLiteral
95
+ # -- WysiwygString
96
+ (r'r"[^"]*"[cwd]?', String),
97
+ # -- AlternateWysiwygString
98
+ (r'`[^`]*`[cwd]?', String),
99
+ # -- DoubleQuotedString
100
+ (r'"(\\\\|\\[^\\]|[^"\\])*"[cwd]?', String),
101
+ # -- EscapeSequence
102
+ (r"\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}"
103
+ r"|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)",
104
+ String),
105
+ # -- HexString
106
+ (r'x"[0-9a-fA-F_\s]*"[cwd]?', String),
107
+ # -- DelimitedString
108
+ (r'q"\[', String, 'delimited_bracket'),
109
+ (r'q"\(', String, 'delimited_parenthesis'),
110
+ (r'q"<', String, 'delimited_angle'),
111
+ (r'q"\{', String, 'delimited_curly'),
112
+ (r'q"([a-zA-Z_]\w*)\n.*?\n\1"', String),
113
+ (r'q"(.).*?\1"', String),
114
+ # -- TokenString
115
+ (r'q\{', String, 'token_string'),
116
+ # Attributes
117
+ (r'@([a-zA-Z_]\w*)?', Name.Decorator),
118
+ # Tokens
119
+ (r'(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>='
120
+ r'|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)'
121
+ r'|[/.&|\-+<>!()\[\]{}?,;:$=*%^~]', Punctuation),
122
+ # Identifier
123
+ (r'[a-zA-Z_]\w*', Name),
124
+ # Line
125
+ (r'#line\s.*\n', Comment.Special),
126
+ ],
127
+ 'nested_comment': [
128
+ (r'[^+/]+', Comment.Multiline),
129
+ (r'/\+', Comment.Multiline, '#push'),
130
+ (r'\+/', Comment.Multiline, '#pop'),
131
+ (r'[+/]', Comment.Multiline),
132
+ ],
133
+ 'token_string': [
134
+ (r'\{', Punctuation, 'token_string_nest'),
135
+ (r'\}', String, '#pop'),
136
+ include('root'),
137
+ ],
138
+ 'token_string_nest': [
139
+ (r'\{', Punctuation, '#push'),
140
+ (r'\}', Punctuation, '#pop'),
141
+ include('root'),
142
+ ],
143
+ 'delimited_bracket': [
144
+ (r'[^\[\]]+', String),
145
+ (r'\[', String, 'delimited_inside_bracket'),
146
+ (r'\]"', String, '#pop'),
147
+ ],
148
+ 'delimited_inside_bracket': [
149
+ (r'[^\[\]]+', String),
150
+ (r'\[', String, '#push'),
151
+ (r'\]', String, '#pop'),
152
+ ],
153
+ 'delimited_parenthesis': [
154
+ (r'[^()]+', String),
155
+ (r'\(', String, 'delimited_inside_parenthesis'),
156
+ (r'\)"', String, '#pop'),
157
+ ],
158
+ 'delimited_inside_parenthesis': [
159
+ (r'[^()]+', String),
160
+ (r'\(', String, '#push'),
161
+ (r'\)', String, '#pop'),
162
+ ],
163
+ 'delimited_angle': [
164
+ (r'[^<>]+', String),
165
+ (r'<', String, 'delimited_inside_angle'),
166
+ (r'>"', String, '#pop'),
167
+ ],
168
+ 'delimited_inside_angle': [
169
+ (r'[^<>]+', String),
170
+ (r'<', String, '#push'),
171
+ (r'>', String, '#pop'),
172
+ ],
173
+ 'delimited_curly': [
174
+ (r'[^{}]+', String),
175
+ (r'\{', String, 'delimited_inside_curly'),
176
+ (r'\}"', String, '#pop'),
177
+ ],
178
+ 'delimited_inside_curly': [
179
+ (r'[^{}]+', String),
180
+ (r'\{', String, '#push'),
181
+ (r'\}', String, '#pop'),
182
+ ],
183
+ }
184
+
185
+
186
+ class CrocLexer(RegexLexer):
187
+ """
188
+ For `Croc <http://jfbillingsley.com/croc>`_ source.
189
+ """
190
+ name = 'Croc'
191
+ filenames = ['*.croc']
192
+ aliases = ['croc']
193
+ mimetypes = ['text/x-crocsrc']
194
+
195
+ tokens = {
196
+ 'root': [
197
+ (r'\n', Text),
198
+ (r'\s+', Text),
199
+ # Comments
200
+ (r'//(.*?)\n', Comment.Single),
201
+ (r'/\*', Comment.Multiline, 'nestedcomment'),
202
+ # Keywords
203
+ (words((
204
+ 'as', 'assert', 'break', 'case', 'catch', 'class', 'continue',
205
+ 'default', 'do', 'else', 'finally', 'for', 'foreach', 'function',
206
+ 'global', 'namespace', 'if', 'import', 'in', 'is', 'local',
207
+ 'module', 'return', 'scope', 'super', 'switch', 'this', 'throw',
208
+ 'try', 'vararg', 'while', 'with', 'yield'), suffix=r'\b'),
209
+ Keyword),
210
+ (r'(false|true|null)\b', Keyword.Constant),
211
+ # FloatLiteral
212
+ (r'([0-9][0-9_]*)(?=[.eE])(\.[0-9][0-9_]*)?([eE][+\-]?[0-9_]+)?',
213
+ Number.Float),
214
+ # IntegerLiteral
215
+ # -- Binary
216
+ (r'0[bB][01][01_]*', Number.Bin),
217
+ # -- Hexadecimal
218
+ (r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex),
219
+ # -- Decimal
220
+ (r'([0-9][0-9_]*)(?![.eE])', Number.Integer),
221
+ # CharacterLiteral
222
+ (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-9]{1,3}"""
223
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
224
+ String.Char),
225
+ # StringLiteral
226
+ # -- WysiwygString
227
+ (r'@"(""|[^"])*"', String),
228
+ (r'@`(``|[^`])*`', String),
229
+ (r"@'(''|[^'])*'", String),
230
+ # -- DoubleQuotedString
231
+ (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
232
+ # Tokens
233
+ (r'(~=|\^=|%=|\*=|==|!=|>>>=|>>>|>>=|>>|>=|<=>|\?=|-\>'
234
+ r'|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.|/=)'
235
+ r'|[-/.&$@|\+<>!()\[\]{}?,;:=*%^~#\\]', Punctuation),
236
+ # Identifier
237
+ (r'[a-zA-Z_]\w*', Name),
238
+ ],
239
+ 'nestedcomment': [
240
+ (r'[^*/]+', Comment.Multiline),
241
+ (r'/\*', Comment.Multiline, '#push'),
242
+ (r'\*/', Comment.Multiline, '#pop'),
243
+ (r'[*/]', Comment.Multiline),
244
+ ],
245
+ }
246
+
247
+
248
+ class MiniDLexer(CrocLexer):
249
+ """
250
+ For MiniD source. MiniD is now known as Croc.
251
+ """
252
+ name = 'MiniD'
253
+ filenames = [] # don't lex .md as MiniD, reserve for Markdown
254
+ aliases = ['minid']
255
+ mimetypes = ['text/x-minidsrc']
@@ -0,0 +1,124 @@
1
+ """
2
+ pygments.lexers.dalvik
3
+ ~~~~~~~~~~~~~~~~~~~~~~
4
+
5
+ Pygments lexers for Dalvik VM-related languages.
6
+
7
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
8
+ :license: BSD, see LICENSE for details.
9
+ """
10
+
11
+ import re
12
+
13
+ from pygments.lexer import RegexLexer, include, bygroups
14
+ from pygments.token import Keyword, Text, Comment, Name, String, Number, \
15
+ Punctuation
16
+
17
+ __all__ = ['SmaliLexer']
18
+
19
+
20
+ class SmaliLexer(RegexLexer):
21
+ """
22
+ For `Smali <http://code.google.com/p/smali/>`_ (Android/Dalvik) assembly
23
+ code.
24
+
25
+ .. versionadded:: 1.6
26
+ """
27
+ name = 'Smali'
28
+ aliases = ['smali']
29
+ filenames = ['*.smali']
30
+ mimetypes = ['text/smali']
31
+
32
+ tokens = {
33
+ 'root': [
34
+ include('comment'),
35
+ include('label'),
36
+ include('field'),
37
+ include('method'),
38
+ include('class'),
39
+ include('directive'),
40
+ include('access-modifier'),
41
+ include('instruction'),
42
+ include('literal'),
43
+ include('punctuation'),
44
+ include('type'),
45
+ include('whitespace')
46
+ ],
47
+ 'directive': [
48
+ (r'^[ \t]*\.(class|super|implements|field|subannotation|annotation|'
49
+ r'enum|method|registers|locals|array-data|packed-switch|'
50
+ r'sparse-switch|catchall|catch|line|parameter|local|prologue|'
51
+ r'epilogue|source)', Keyword),
52
+ (r'^[ \t]*\.end (field|subannotation|annotation|method|array-data|'
53
+ 'packed-switch|sparse-switch|parameter|local)', Keyword),
54
+ (r'^[ \t]*\.restart local', Keyword),
55
+ ],
56
+ 'access-modifier': [
57
+ (r'(public|private|protected|static|final|synchronized|bridge|'
58
+ r'varargs|native|abstract|strictfp|synthetic|constructor|'
59
+ r'declared-synchronized|interface|enum|annotation|volatile|'
60
+ r'transient)', Keyword),
61
+ ],
62
+ 'whitespace': [
63
+ (r'\n', Text),
64
+ (r'\s+', Text),
65
+ ],
66
+ 'instruction': [
67
+ (r'\b[vp]\d+\b', Name.Builtin), # registers
68
+ (r'\b[a-z][A-Za-z0-9/-]+\s+', Text), # instructions
69
+ ],
70
+ 'literal': [
71
+ (r'".*"', String),
72
+ (r'0x[0-9A-Fa-f]+t?', Number.Hex),
73
+ (r'[0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
74
+ (r'[0-9]+L?', Number.Integer),
75
+ ],
76
+ 'field': [
77
+ (r'(\$?\b)([\w$]*)(:)',
78
+ bygroups(Punctuation, Name.Variable, Punctuation)),
79
+ ],
80
+ 'method': [
81
+ (r'<(?:cl)?init>', Name.Function), # constructor
82
+ (r'(\$?\b)([\w$]*)(\()',
83
+ bygroups(Punctuation, Name.Function, Punctuation)),
84
+ ],
85
+ 'label': [
86
+ (r':\w+', Name.Label),
87
+ ],
88
+ 'class': [
89
+ # class names in the form Lcom/namespace/ClassName;
90
+ # I only want to color the ClassName part, so the namespace part is
91
+ # treated as 'Text'
92
+ (r'(L)((?:[\w$]+/)*)([\w$]+)(;)',
93
+ bygroups(Keyword.Type, Text, Name.Class, Text)),
94
+ ],
95
+ 'punctuation': [
96
+ (r'->', Punctuation),
97
+ (r'[{},():=.-]', Punctuation),
98
+ ],
99
+ 'type': [
100
+ (r'[ZBSCIJFDV\[]+', Keyword.Type),
101
+ ],
102
+ 'comment': [
103
+ (r'#.*?\n', Comment),
104
+ ],
105
+ }
106
+
107
+ def analyse_text(text):
108
+ score = 0
109
+ if re.search(r'^\s*\.class\s', text, re.MULTILINE):
110
+ score += 0.5
111
+ if re.search(r'\b((check-cast|instance-of|throw-verification-error'
112
+ r')\b|(-to|add|[ais]get|[ais]put|and|cmpl|const|div|'
113
+ r'if|invoke|move|mul|neg|not|or|rem|return|rsub|shl|'
114
+ r'shr|sub|ushr)[-/])|{|}', text, re.MULTILINE):
115
+ score += 0.3
116
+ if re.search(r'(\.(catchall|epilogue|restart local|prologue)|'
117
+ r'\b(array-data|class-change-error|declared-synchronized|'
118
+ r'(field|inline|vtable)@0x[0-9a-fA-F]|generic-error|'
119
+ r'illegal-class-access|illegal-field-access|'
120
+ r'illegal-method-access|instantiation-error|no-error|'
121
+ r'no-such-class|no-such-field|no-such-method|'
122
+ r'packed-switch|sparse-switch))\b', text, re.MULTILINE):
123
+ score += 0.6
124
+ return score
@@ -0,0 +1,697 @@
1
+ """
2
+ pygments.lexers.data
3
+ ~~~~~~~~~~~~~~~~~~~~
4
+
5
+ Lexers for data file format.
6
+
7
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
8
+ :license: BSD, see LICENSE for details.
9
+ """
10
+
11
+ import re
12
+
13
+ from pygments.lexer import Lexer, RegexLexer, ExtendedRegexLexer, LexerContext, \
14
+ include, bygroups, inherit
15
+ from pygments.token import Text, Comment, Keyword, Name, String, Number, \
16
+ Punctuation, Literal, Error
17
+
18
+ __all__ = ['YamlLexer', 'JsonLexer', 'JsonBareObjectLexer', 'JsonLdLexer']
19
+
20
+
21
+ class YamlLexerContext(LexerContext):
22
+ """Indentation context for the YAML lexer."""
23
+
24
+ def __init__(self, *args, **kwds):
25
+ super().__init__(*args, **kwds)
26
+ self.indent_stack = []
27
+ self.indent = -1
28
+ self.next_indent = 0
29
+ self.block_scalar_indent = None
30
+
31
+
32
+ class YamlLexer(ExtendedRegexLexer):
33
+ """
34
+ Lexer for `YAML <http://yaml.org/>`_, a human-friendly data serialization
35
+ language.
36
+
37
+ .. versionadded:: 0.11
38
+ """
39
+
40
+ name = 'YAML'
41
+ aliases = ['yaml']
42
+ filenames = ['*.yaml', '*.yml']
43
+ mimetypes = ['text/x-yaml']
44
+
45
+ def something(token_class):
46
+ """Do not produce empty tokens."""
47
+ def callback(lexer, match, context):
48
+ text = match.group()
49
+ if not text:
50
+ return
51
+ yield match.start(), token_class, text
52
+ context.pos = match.end()
53
+ return callback
54
+
55
+ def reset_indent(token_class):
56
+ """Reset the indentation levels."""
57
+ def callback(lexer, match, context):
58
+ text = match.group()
59
+ context.indent_stack = []
60
+ context.indent = -1
61
+ context.next_indent = 0
62
+ context.block_scalar_indent = None
63
+ yield match.start(), token_class, text
64
+ context.pos = match.end()
65
+ return callback
66
+
67
+ def save_indent(token_class, start=False):
68
+ """Save a possible indentation level."""
69
+ def callback(lexer, match, context):
70
+ text = match.group()
71
+ extra = ''
72
+ if start:
73
+ context.next_indent = len(text)
74
+ if context.next_indent < context.indent:
75
+ while context.next_indent < context.indent:
76
+ context.indent = context.indent_stack.pop()
77
+ if context.next_indent > context.indent:
78
+ extra = text[context.indent:]
79
+ text = text[:context.indent]
80
+ else:
81
+ context.next_indent += len(text)
82
+ if text:
83
+ yield match.start(), token_class, text
84
+ if extra:
85
+ yield match.start()+len(text), token_class.Error, extra
86
+ context.pos = match.end()
87
+ return callback
88
+
89
+ def set_indent(token_class, implicit=False):
90
+ """Set the previously saved indentation level."""
91
+ def callback(lexer, match, context):
92
+ text = match.group()
93
+ if context.indent < context.next_indent:
94
+ context.indent_stack.append(context.indent)
95
+ context.indent = context.next_indent
96
+ if not implicit:
97
+ context.next_indent += len(text)
98
+ yield match.start(), token_class, text
99
+ context.pos = match.end()
100
+ return callback
101
+
102
+ def set_block_scalar_indent(token_class):
103
+ """Set an explicit indentation level for a block scalar."""
104
+ def callback(lexer, match, context):
105
+ text = match.group()
106
+ context.block_scalar_indent = None
107
+ if not text:
108
+ return
109
+ increment = match.group(1)
110
+ if increment:
111
+ current_indent = max(context.indent, 0)
112
+ increment = int(increment)
113
+ context.block_scalar_indent = current_indent + increment
114
+ if text:
115
+ yield match.start(), token_class, text
116
+ context.pos = match.end()
117
+ return callback
118
+
119
+ def parse_block_scalar_empty_line(indent_token_class, content_token_class):
120
+ """Process an empty line in a block scalar."""
121
+ def callback(lexer, match, context):
122
+ text = match.group()
123
+ if (context.block_scalar_indent is None or
124
+ len(text) <= context.block_scalar_indent):
125
+ if text:
126
+ yield match.start(), indent_token_class, text
127
+ else:
128
+ indentation = text[:context.block_scalar_indent]
129
+ content = text[context.block_scalar_indent:]
130
+ yield match.start(), indent_token_class, indentation
131
+ yield (match.start()+context.block_scalar_indent,
132
+ content_token_class, content)
133
+ context.pos = match.end()
134
+ return callback
135
+
136
+ def parse_block_scalar_indent(token_class):
137
+ """Process indentation spaces in a block scalar."""
138
+ def callback(lexer, match, context):
139
+ text = match.group()
140
+ if context.block_scalar_indent is None:
141
+ if len(text) <= max(context.indent, 0):
142
+ context.stack.pop()
143
+ context.stack.pop()
144
+ return
145
+ context.block_scalar_indent = len(text)
146
+ else:
147
+ if len(text) < context.block_scalar_indent:
148
+ context.stack.pop()
149
+ context.stack.pop()
150
+ return
151
+ if text:
152
+ yield match.start(), token_class, text
153
+ context.pos = match.end()
154
+ return callback
155
+
156
+ def parse_plain_scalar_indent(token_class):
157
+ """Process indentation spaces in a plain scalar."""
158
+ def callback(lexer, match, context):
159
+ text = match.group()
160
+ if len(text) <= context.indent:
161
+ context.stack.pop()
162
+ context.stack.pop()
163
+ return
164
+ if text:
165
+ yield match.start(), token_class, text
166
+ context.pos = match.end()
167
+ return callback
168
+
169
+ tokens = {
170
+ # the root rules
171
+ 'root': [
172
+ # ignored whitespaces
173
+ (r'[ ]+(?=#|$)', Text),
174
+ # line breaks
175
+ (r'\n+', Text),
176
+ # a comment
177
+ (r'#[^\n]*', Comment.Single),
178
+ # the '%YAML' directive
179
+ (r'^%YAML(?=[ ]|$)', reset_indent(Name.Tag), 'yaml-directive'),
180
+ # the %TAG directive
181
+ (r'^%TAG(?=[ ]|$)', reset_indent(Name.Tag), 'tag-directive'),
182
+ # document start and document end indicators
183
+ (r'^(?:---|\.\.\.)(?=[ ]|$)', reset_indent(Name.Namespace),
184
+ 'block-line'),
185
+ # indentation spaces
186
+ (r'[ ]*(?!\s|$)', save_indent(Text, start=True),
187
+ ('block-line', 'indentation')),
188
+ ],
189
+
190
+ # trailing whitespaces after directives or a block scalar indicator
191
+ 'ignored-line': [
192
+ # ignored whitespaces
193
+ (r'[ ]+(?=#|$)', Text),
194
+ # a comment
195
+ (r'#[^\n]*', Comment.Single),
196
+ # line break
197
+ (r'\n', Text, '#pop:2'),
198
+ ],
199
+
200
+ # the %YAML directive
201
+ 'yaml-directive': [
202
+ # the version number
203
+ (r'([ ]+)([0-9]+\.[0-9]+)',
204
+ bygroups(Text, Number), 'ignored-line'),
205
+ ],
206
+
207
+ # the %TAG directive
208
+ 'tag-directive': [
209
+ # a tag handle and the corresponding prefix
210
+ (r'([ ]+)(!|![\w-]*!)'
211
+ r'([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)',
212
+ bygroups(Text, Keyword.Type, Text, Keyword.Type),
213
+ 'ignored-line'),
214
+ ],
215
+
216
+ # block scalar indicators and indentation spaces
217
+ 'indentation': [
218
+ # trailing whitespaces are ignored
219
+ (r'[ ]*$', something(Text), '#pop:2'),
220
+ # whitespaces preceding block collection indicators
221
+ (r'[ ]+(?=[?:-](?:[ ]|$))', save_indent(Text)),
222
+ # block collection indicators
223
+ (r'[?:-](?=[ ]|$)', set_indent(Punctuation.Indicator)),
224
+ # the beginning a block line
225
+ (r'[ ]*', save_indent(Text), '#pop'),
226
+ ],
227
+
228
+ # an indented line in the block context
229
+ 'block-line': [
230
+ # the line end
231
+ (r'[ ]*(?=#|$)', something(Text), '#pop'),
232
+ # whitespaces separating tokens
233
+ (r'[ ]+', Text),
234
+ # key with colon
235
+ (r'''([^#,:?\[\]{}"'\n]+)(:)(?=[ ]|$)''',
236
+ bygroups(Name.Tag, set_indent(Punctuation, implicit=True))),
237
+ # tags, anchors and aliases,
238
+ include('descriptors'),
239
+ # block collections and scalars
240
+ include('block-nodes'),
241
+ # flow collections and quoted scalars
242
+ include('flow-nodes'),
243
+ # a plain scalar
244
+ (r'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)',
245
+ something(Name.Variable),
246
+ 'plain-scalar-in-block-context'),
247
+ ],
248
+
249
+ # tags, anchors, aliases
250
+ 'descriptors': [
251
+ # a full-form tag
252
+ (r'!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>', Keyword.Type),
253
+ # a tag in the form '!', '!suffix' or '!handle!suffix'
254
+ (r'!(?:[\w-]+!)?'
255
+ r'[\w#;/?:@&=+$,.!~*\'()\[\]%-]*', Keyword.Type),
256
+ # an anchor
257
+ (r'&[\w-]+', Name.Label),
258
+ # an alias
259
+ (r'\*[\w-]+', Name.Variable),
260
+ ],
261
+
262
+ # block collections and scalars
263
+ 'block-nodes': [
264
+ # implicit key
265
+ (r':(?=[ ]|$)', set_indent(Punctuation.Indicator, implicit=True)),
266
+ # literal and folded scalars
267
+ (r'[|>]', Punctuation.Indicator,
268
+ ('block-scalar-content', 'block-scalar-header')),
269
+ ],
270
+
271
+ # flow collections and quoted scalars
272
+ 'flow-nodes': [
273
+ # a flow sequence
274
+ (r'\[', Punctuation.Indicator, 'flow-sequence'),
275
+ # a flow mapping
276
+ (r'\{', Punctuation.Indicator, 'flow-mapping'),
277
+ # a single-quoted scalar
278
+ (r'\'', String, 'single-quoted-scalar'),
279
+ # a double-quoted scalar
280
+ (r'\"', String, 'double-quoted-scalar'),
281
+ ],
282
+
283
+ # the content of a flow collection
284
+ 'flow-collection': [
285
+ # whitespaces
286
+ (r'[ ]+', Text),
287
+ # line breaks
288
+ (r'\n+', Text),
289
+ # a comment
290
+ (r'#[^\n]*', Comment.Single),
291
+ # simple indicators
292
+ (r'[?:,]', Punctuation.Indicator),
293
+ # tags, anchors and aliases
294
+ include('descriptors'),
295
+ # nested collections and quoted scalars
296
+ include('flow-nodes'),
297
+ # a plain scalar
298
+ (r'(?=[^\s?:,\[\]{}#&*!|>\'"%@`])',
299
+ something(Name.Variable),
300
+ 'plain-scalar-in-flow-context'),
301
+ ],
302
+
303
+ # a flow sequence indicated by '[' and ']'
304
+ 'flow-sequence': [
305
+ # include flow collection rules
306
+ include('flow-collection'),
307
+ # the closing indicator
308
+ (r'\]', Punctuation.Indicator, '#pop'),
309
+ ],
310
+
311
+ # a flow mapping indicated by '{' and '}'
312
+ 'flow-mapping': [
313
+ # key with colon
314
+ (r'''([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$)''',
315
+ bygroups(Name.Tag, Punctuation)),
316
+ # include flow collection rules
317
+ include('flow-collection'),
318
+ # the closing indicator
319
+ (r'\}', Punctuation.Indicator, '#pop'),
320
+ ],
321
+
322
+ # block scalar lines
323
+ 'block-scalar-content': [
324
+ # line break
325
+ (r'\n', Text),
326
+ # empty line
327
+ (r'^[ ]+$',
328
+ parse_block_scalar_empty_line(Text, Name.Constant)),
329
+ # indentation spaces (we may leave the state here)
330
+ (r'^[ ]*', parse_block_scalar_indent(Text)),
331
+ # line content
332
+ (r'[\S\t ]+', Name.Constant),
333
+ ],
334
+
335
+ # the content of a literal or folded scalar
336
+ 'block-scalar-header': [
337
+ # indentation indicator followed by chomping flag
338
+ (r'([1-9])?[+-]?(?=[ ]|$)',
339
+ set_block_scalar_indent(Punctuation.Indicator),
340
+ 'ignored-line'),
341
+ # chomping flag followed by indentation indicator
342
+ (r'[+-]?([1-9])?(?=[ ]|$)',
343
+ set_block_scalar_indent(Punctuation.Indicator),
344
+ 'ignored-line'),
345
+ ],
346
+
347
+ # ignored and regular whitespaces in quoted scalars
348
+ 'quoted-scalar-whitespaces': [
349
+ # leading and trailing whitespaces are ignored
350
+ (r'^[ ]+', Text),
351
+ (r'[ ]+$', Text),
352
+ # line breaks are ignored
353
+ (r'\n+', Text),
354
+ # other whitespaces are a part of the value
355
+ (r'[ ]+', Name.Variable),
356
+ ],
357
+
358
+ # single-quoted scalars
359
+ 'single-quoted-scalar': [
360
+ # include whitespace and line break rules
361
+ include('quoted-scalar-whitespaces'),
362
+ # escaping of the quote character
363
+ (r'\'\'', String.Escape),
364
+ # regular non-whitespace characters
365
+ (r'[^\s\']+', String),
366
+ # the closing quote
367
+ (r'\'', String, '#pop'),
368
+ ],
369
+
370
+ # double-quoted scalars
371
+ 'double-quoted-scalar': [
372
+ # include whitespace and line break rules
373
+ include('quoted-scalar-whitespaces'),
374
+ # escaping of special characters
375
+ (r'\\[0abt\tn\nvfre "\\N_LP]', String),
376
+ # escape codes
377
+ (r'\\(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})',
378
+ String.Escape),
379
+ # regular non-whitespace characters
380
+ (r'[^\s"\\]+', String),
381
+ # the closing quote
382
+ (r'"', String, '#pop'),
383
+ ],
384
+
385
+ # the beginning of a new line while scanning a plain scalar
386
+ 'plain-scalar-in-block-context-new-line': [
387
+ # empty lines
388
+ (r'^[ ]+$', Text),
389
+ # line breaks
390
+ (r'\n+', Text),
391
+ # document start and document end indicators
392
+ (r'^(?=---|\.\.\.)', something(Name.Namespace), '#pop:3'),
393
+ # indentation spaces (we may leave the block line state here)
394
+ (r'^[ ]*', parse_plain_scalar_indent(Text), '#pop'),
395
+ ],
396
+
397
+ # a plain scalar in the block context
398
+ 'plain-scalar-in-block-context': [
399
+ # the scalar ends with the ':' indicator
400
+ (r'[ ]*(?=:[ ]|:$)', something(Text), '#pop'),
401
+ # the scalar ends with whitespaces followed by a comment
402
+ (r'[ ]+(?=#)', Text, '#pop'),
403
+ # trailing whitespaces are ignored
404
+ (r'[ ]+$', Text),
405
+ # line breaks are ignored
406
+ (r'\n+', Text, 'plain-scalar-in-block-context-new-line'),
407
+ # other whitespaces are a part of the value
408
+ (r'[ ]+', Literal.Scalar.Plain),
409
+ # regular non-whitespace characters
410
+ (r'(?::(?!\s)|[^\s:])+', Literal.Scalar.Plain),
411
+ ],
412
+
413
+ # a plain scalar is the flow context
414
+ 'plain-scalar-in-flow-context': [
415
+ # the scalar ends with an indicator character
416
+ (r'[ ]*(?=[,:?\[\]{}])', something(Text), '#pop'),
417
+ # the scalar ends with a comment
418
+ (r'[ ]+(?=#)', Text, '#pop'),
419
+ # leading and trailing whitespaces are ignored
420
+ (r'^[ ]+', Text),
421
+ (r'[ ]+$', Text),
422
+ # line breaks are ignored
423
+ (r'\n+', Text),
424
+ # other whitespaces are a part of the value
425
+ (r'[ ]+', Name.Variable),
426
+ # regular non-whitespace characters
427
+ (r'[^\s,:?\[\]{}]+', Name.Variable),
428
+ ],
429
+
430
+ }
431
+
432
+ def get_tokens_unprocessed(self, text=None, context=None):
433
+ if context is None:
434
+ context = YamlLexerContext(text, 0)
435
+ return super().get_tokens_unprocessed(text, context)
436
+
437
+
438
+ class JsonLexer(Lexer):
439
+ """
440
+ For JSON data structures.
441
+
442
+ .. versionadded:: 1.5
443
+ """
444
+
445
+ name = 'JSON'
446
+ aliases = ['json', 'json-object']
447
+ filenames = ['*.json', 'Pipfile.lock']
448
+ mimetypes = ['application/json', 'application/json-object']
449
+
450
+ # No validation of integers, floats, or constants is done.
451
+ # As long as the characters are members of the following
452
+ # sets, the token will be considered valid. For example,
453
+ #
454
+ # "--1--" is parsed as an integer
455
+ # "1...eee" is parsed as a float
456
+ # "trustful" is parsed as a constant
457
+ #
458
+ integers = set('-0123456789')
459
+ floats = set('.eE+')
460
+ constants = set('truefalsenull') # true|false|null
461
+ hexadecimals = set('0123456789abcdefABCDEF')
462
+ punctuations = set('{}[],')
463
+ whitespaces = {'\u0020', '\u000a', '\u000d', '\u0009'}
464
+
465
+ def get_tokens_unprocessed(self, text):
466
+ """Parse JSON data."""
467
+
468
+ in_string = False
469
+ in_escape = False
470
+ in_unicode_escape = 0
471
+ in_whitespace = False
472
+ in_constant = False
473
+ in_number = False
474
+ in_float = False
475
+ in_punctuation = False
476
+
477
+ start = 0
478
+
479
+ # The queue is used to store data that may need to be tokenized
480
+ # differently based on what follows. In particular, JSON object
481
+ # keys are tokenized differently than string values, but cannot
482
+ # be distinguished until punctuation is encountered outside the
483
+ # string.
484
+ #
485
+ # A ":" character after the string indicates that the string is
486
+ # an object key; any other character indicates the string is a
487
+ # regular string value.
488
+ #
489
+ # The queue holds tuples that contain the following data:
490
+ #
491
+ # (start_index, token_type, text)
492
+ #
493
+ # By default the token type of text in double quotes is
494
+ # String.Double. The token type will be replaced if a colon
495
+ # is encountered after the string closes.
496
+ #
497
+ queue = []
498
+
499
+ for stop, character in enumerate(text):
500
+ if in_string:
501
+ if in_unicode_escape:
502
+ if character in self.hexadecimals:
503
+ in_unicode_escape -= 1
504
+ if not in_unicode_escape:
505
+ in_escape = False
506
+ else:
507
+ in_unicode_escape = 0
508
+ in_escape = False
509
+
510
+ elif in_escape:
511
+ if character == 'u':
512
+ in_unicode_escape = 4
513
+ else:
514
+ in_escape = False
515
+
516
+ elif character == '\\':
517
+ in_escape = True
518
+
519
+ elif character == '"':
520
+ queue.append((start, String.Double, text[start:stop + 1]))
521
+ in_string = False
522
+ in_escape = False
523
+ in_unicode_escape = 0
524
+
525
+ continue
526
+
527
+ elif in_whitespace:
528
+ if character in self.whitespaces:
529
+ continue
530
+
531
+ if queue:
532
+ queue.append((start, Text, text[start:stop]))
533
+ else:
534
+ yield start, Text, text[start:stop]
535
+ in_whitespace = False
536
+ # Fall through so the new character can be evaluated.
537
+
538
+ elif in_constant:
539
+ if character in self.constants:
540
+ continue
541
+
542
+ yield start, Keyword.Constant, text[start:stop]
543
+ in_constant = False
544
+ # Fall through so the new character can be evaluated.
545
+
546
+ elif in_number:
547
+ if character in self.integers:
548
+ continue
549
+ elif character in self.floats:
550
+ in_float = True
551
+ continue
552
+
553
+ if in_float:
554
+ yield start, Number.Float, text[start:stop]
555
+ else:
556
+ yield start, Number.Integer, text[start:stop]
557
+ in_number = False
558
+ in_float = False
559
+ # Fall through so the new character can be evaluated.
560
+
561
+ elif in_punctuation:
562
+ if character in self.punctuations:
563
+ continue
564
+
565
+ yield start, Punctuation, text[start:stop]
566
+ in_punctuation = False
567
+ # Fall through so the new character can be evaluated.
568
+
569
+ start = stop
570
+
571
+ if character == '"':
572
+ in_string = True
573
+
574
+ elif character in self.whitespaces:
575
+ in_whitespace = True
576
+
577
+ elif character in {'f', 'n', 't'}: # The first letters of true|false|null
578
+ # Exhaust the queue. Accept the existing token types.
579
+ yield from queue
580
+ queue.clear()
581
+
582
+ in_constant = True
583
+
584
+ elif character in self.integers:
585
+ # Exhaust the queue. Accept the existing token types.
586
+ yield from queue
587
+ queue.clear()
588
+
589
+ in_number = True
590
+
591
+ elif character == ':':
592
+ # Yield from the queue. Replace string token types.
593
+ for _start, _token, _text in queue:
594
+ if _token is Text:
595
+ yield _start, _token, _text
596
+ elif _token is String.Double:
597
+ yield _start, Name.Tag, _text
598
+ else:
599
+ yield _start, Error, _text
600
+ queue.clear()
601
+
602
+ in_punctuation = True
603
+
604
+ elif character in self.punctuations:
605
+ # Exhaust the queue. Accept the existing token types.
606
+ yield from queue
607
+ queue.clear()
608
+
609
+ in_punctuation = True
610
+
611
+ else:
612
+ # Exhaust the queue. Accept the existing token types.
613
+ yield from queue
614
+ queue.clear()
615
+
616
+ yield start, Error, character
617
+
618
+ # Yield any remaining text.
619
+ yield from queue
620
+ if in_string:
621
+ yield start, Error, text[start:]
622
+ elif in_float:
623
+ yield start, Number.Float, text[start:]
624
+ elif in_number:
625
+ yield start, Number.Integer, text[start:]
626
+ elif in_constant:
627
+ yield start, Keyword.Constant, text[start:]
628
+ elif in_whitespace:
629
+ yield start, Text, text[start:]
630
+ elif in_punctuation:
631
+ yield start, Punctuation, text[start:]
632
+
633
+
634
+ class JsonBareObjectLexer(JsonLexer):
635
+ """
636
+ For JSON data structures (with missing object curly braces).
637
+
638
+ .. versionadded:: 2.2
639
+
640
+ .. deprecated:: 2.8.0
641
+
642
+ Behaves the same as `JsonLexer` now.
643
+ """
644
+
645
+ name = 'JSONBareObject'
646
+ aliases = []
647
+ filenames = []
648
+ mimetypes = []
649
+
650
+
651
+ class JsonLdLexer(JsonLexer):
652
+ """
653
+ For `JSON-LD <https://json-ld.org/>`_ linked data.
654
+
655
+ .. versionadded:: 2.0
656
+ """
657
+
658
+ name = 'JSON-LD'
659
+ aliases = ['jsonld', 'json-ld']
660
+ filenames = ['*.jsonld']
661
+ mimetypes = ['application/ld+json']
662
+
663
+ json_ld_keywords = {
664
+ '"@%s"' % keyword
665
+ for keyword in (
666
+ 'base',
667
+ 'container',
668
+ 'context',
669
+ 'direction',
670
+ 'graph',
671
+ 'id',
672
+ 'import',
673
+ 'included',
674
+ 'index',
675
+ 'json',
676
+ 'language',
677
+ 'list',
678
+ 'nest',
679
+ 'none',
680
+ 'prefix',
681
+ 'propagate',
682
+ 'protected',
683
+ 'reverse',
684
+ 'set',
685
+ 'type',
686
+ 'value',
687
+ 'version',
688
+ 'vocab',
689
+ )
690
+ }
691
+
692
+ def get_tokens_unprocessed(self, text):
693
+ for start, token, value in super().get_tokens_unprocessed(text):
694
+ if token is Name.Tag and value in self.json_ld_keywords:
695
+ yield start, Name.Decorator, value
696
+ else:
697
+ yield start, token, value