pygments.rb-jruby 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (473) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/CHANGELOG.md +71 -0
  4. data/Gemfile +2 -0
  5. data/LICENSE +17 -0
  6. data/README.md +118 -0
  7. data/Rakefile +66 -0
  8. data/bench.rb +22 -0
  9. data/cache-lexers.rb +8 -0
  10. data/lexers +0 -0
  11. data/lib/pygments.rb +8 -0
  12. data/lib/pygments/lexer.rb +148 -0
  13. data/lib/pygments/mentos.py +351 -0
  14. data/lib/pygments/popen.rb +404 -0
  15. data/lib/pygments/version.rb +3 -0
  16. data/pygments.rb.gemspec +24 -0
  17. data/test/test_data.c +2581 -0
  18. data/test/test_data.py +514 -0
  19. data/test/test_data_generated +2582 -0
  20. data/test/test_pygments.rb +287 -0
  21. data/vendor/custom_lexers/github.py +565 -0
  22. data/vendor/pygments-main/AUTHORS +153 -0
  23. data/vendor/pygments-main/CHANGES +889 -0
  24. data/vendor/pygments-main/LICENSE +25 -0
  25. data/vendor/pygments-main/MANIFEST.in +6 -0
  26. data/vendor/pygments-main/Makefile +59 -0
  27. data/vendor/pygments-main/REVISION +1 -0
  28. data/vendor/pygments-main/TODO +15 -0
  29. data/vendor/pygments-main/docs/generate.py +472 -0
  30. data/vendor/pygments-main/docs/pygmentize.1 +94 -0
  31. data/vendor/pygments-main/docs/src/api.txt +270 -0
  32. data/vendor/pygments-main/docs/src/authors.txt +5 -0
  33. data/vendor/pygments-main/docs/src/changelog.txt +5 -0
  34. data/vendor/pygments-main/docs/src/cmdline.txt +147 -0
  35. data/vendor/pygments-main/docs/src/filterdevelopment.txt +70 -0
  36. data/vendor/pygments-main/docs/src/filters.txt +42 -0
  37. data/vendor/pygments-main/docs/src/formatterdevelopment.txt +169 -0
  38. data/vendor/pygments-main/docs/src/formatters.txt +48 -0
  39. data/vendor/pygments-main/docs/src/index.txt +69 -0
  40. data/vendor/pygments-main/docs/src/installation.txt +71 -0
  41. data/vendor/pygments-main/docs/src/integrate.txt +48 -0
  42. data/vendor/pygments-main/docs/src/java.txt +70 -0
  43. data/vendor/pygments-main/docs/src/lexerdevelopment.txt +603 -0
  44. data/vendor/pygments-main/docs/src/lexers.txt +67 -0
  45. data/vendor/pygments-main/docs/src/moinmoin.txt +39 -0
  46. data/vendor/pygments-main/docs/src/plugins.txt +93 -0
  47. data/vendor/pygments-main/docs/src/quickstart.txt +202 -0
  48. data/vendor/pygments-main/docs/src/rstdirective.txt +22 -0
  49. data/vendor/pygments-main/docs/src/styles.txt +143 -0
  50. data/vendor/pygments-main/docs/src/tokens.txt +349 -0
  51. data/vendor/pygments-main/docs/src/unicode.txt +49 -0
  52. data/vendor/pygments-main/external/autopygmentize +64 -0
  53. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
  54. data/vendor/pygments-main/external/markdown-processor.py +67 -0
  55. data/vendor/pygments-main/external/moin-parser.py +112 -0
  56. data/vendor/pygments-main/external/pygments.bashcomp +38 -0
  57. data/vendor/pygments-main/external/rst-directive-old.py +77 -0
  58. data/vendor/pygments-main/external/rst-directive.py +83 -0
  59. data/vendor/pygments-main/ez_setup.py +276 -0
  60. data/vendor/pygments-main/pygmentize +7 -0
  61. data/vendor/pygments-main/pygments/__init__.py +91 -0
  62. data/vendor/pygments-main/pygments/cmdline.py +441 -0
  63. data/vendor/pygments-main/pygments/console.py +74 -0
  64. data/vendor/pygments-main/pygments/filter.py +74 -0
  65. data/vendor/pygments-main/pygments/filters/__init__.py +356 -0
  66. data/vendor/pygments-main/pygments/formatter.py +95 -0
  67. data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
  68. data/vendor/pygments-main/pygments/formatters/_mapping.py +92 -0
  69. data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
  70. data/vendor/pygments-main/pygments/formatters/html.py +821 -0
  71. data/vendor/pygments-main/pygments/formatters/img.py +553 -0
  72. data/vendor/pygments-main/pygments/formatters/latex.py +378 -0
  73. data/vendor/pygments-main/pygments/formatters/other.py +115 -0
  74. data/vendor/pygments-main/pygments/formatters/rtf.py +136 -0
  75. data/vendor/pygments-main/pygments/formatters/svg.py +154 -0
  76. data/vendor/pygments-main/pygments/formatters/terminal.py +112 -0
  77. data/vendor/pygments-main/pygments/formatters/terminal256.py +222 -0
  78. data/vendor/pygments-main/pygments/lexer.py +765 -0
  79. data/vendor/pygments-main/pygments/lexers/__init__.py +240 -0
  80. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1645 -0
  81. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +232 -0
  82. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
  83. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +249 -0
  84. data/vendor/pygments-main/pygments/lexers/_mapping.py +354 -0
  85. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
  86. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
  87. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +233 -0
  88. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
  89. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +40 -0
  90. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
  91. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
  92. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -0
  93. data/vendor/pygments-main/pygments/lexers/agile.py +2290 -0
  94. data/vendor/pygments-main/pygments/lexers/asm.py +398 -0
  95. data/vendor/pygments-main/pygments/lexers/compiled.py +3723 -0
  96. data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
  97. data/vendor/pygments-main/pygments/lexers/dotnet.py +671 -0
  98. data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
  99. data/vendor/pygments-main/pygments/lexers/functional.py +2731 -0
  100. data/vendor/pygments-main/pygments/lexers/github.py +565 -0
  101. data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
  102. data/vendor/pygments-main/pygments/lexers/jvm.py +1112 -0
  103. data/vendor/pygments-main/pygments/lexers/math.py +1918 -0
  104. data/vendor/pygments-main/pygments/lexers/other.py +3778 -0
  105. data/vendor/pygments-main/pygments/lexers/parsers.py +778 -0
  106. data/vendor/pygments-main/pygments/lexers/shell.py +424 -0
  107. data/vendor/pygments-main/pygments/lexers/special.py +100 -0
  108. data/vendor/pygments-main/pygments/lexers/sql.py +559 -0
  109. data/vendor/pygments-main/pygments/lexers/templates.py +1742 -0
  110. data/vendor/pygments-main/pygments/lexers/text.py +1893 -0
  111. data/vendor/pygments-main/pygments/lexers/web.py +4045 -0
  112. data/vendor/pygments-main/pygments/modeline.py +40 -0
  113. data/vendor/pygments-main/pygments/plugin.py +74 -0
  114. data/vendor/pygments-main/pygments/scanner.py +104 -0
  115. data/vendor/pygments-main/pygments/style.py +117 -0
  116. data/vendor/pygments-main/pygments/styles/__init__.py +70 -0
  117. data/vendor/pygments-main/pygments/styles/autumn.py +65 -0
  118. data/vendor/pygments-main/pygments/styles/borland.py +51 -0
  119. data/vendor/pygments-main/pygments/styles/bw.py +49 -0
  120. data/vendor/pygments-main/pygments/styles/colorful.py +81 -0
  121. data/vendor/pygments-main/pygments/styles/default.py +73 -0
  122. data/vendor/pygments-main/pygments/styles/emacs.py +72 -0
  123. data/vendor/pygments-main/pygments/styles/friendly.py +72 -0
  124. data/vendor/pygments-main/pygments/styles/fruity.py +42 -0
  125. data/vendor/pygments-main/pygments/styles/manni.py +75 -0
  126. data/vendor/pygments-main/pygments/styles/monokai.py +106 -0
  127. data/vendor/pygments-main/pygments/styles/murphy.py +80 -0
  128. data/vendor/pygments-main/pygments/styles/native.py +65 -0
  129. data/vendor/pygments-main/pygments/styles/pastie.py +75 -0
  130. data/vendor/pygments-main/pygments/styles/perldoc.py +69 -0
  131. data/vendor/pygments-main/pygments/styles/rrt.py +33 -0
  132. data/vendor/pygments-main/pygments/styles/tango.py +141 -0
  133. data/vendor/pygments-main/pygments/styles/trac.py +63 -0
  134. data/vendor/pygments-main/pygments/styles/vim.py +63 -0
  135. data/vendor/pygments-main/pygments/styles/vs.py +38 -0
  136. data/vendor/pygments-main/pygments/token.py +195 -0
  137. data/vendor/pygments-main/pygments/unistring.py +140 -0
  138. data/vendor/pygments-main/pygments/util.py +277 -0
  139. data/vendor/pygments-main/scripts/check_sources.py +242 -0
  140. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +32 -0
  141. data/vendor/pygments-main/scripts/epydoc.css +280 -0
  142. data/vendor/pygments-main/scripts/find_codetags.py +205 -0
  143. data/vendor/pygments-main/scripts/find_error.py +170 -0
  144. data/vendor/pygments-main/scripts/get_vimkw.py +43 -0
  145. data/vendor/pygments-main/scripts/pylintrc +301 -0
  146. data/vendor/pygments-main/scripts/reindent.py +291 -0
  147. data/vendor/pygments-main/scripts/vim2pygments.py +933 -0
  148. data/vendor/pygments-main/setup.cfg +7 -0
  149. data/vendor/pygments-main/setup.py +90 -0
  150. data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +37 -0
  151. data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +869 -0
  152. data/vendor/pygments-main/tests/dtds/HTML4.dcl +88 -0
  153. data/vendor/pygments-main/tests/dtds/HTML4.dtd +1092 -0
  154. data/vendor/pygments-main/tests/dtds/HTML4.soc +9 -0
  155. data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +195 -0
  156. data/vendor/pygments-main/tests/dtds/HTMLspec.ent +77 -0
  157. data/vendor/pygments-main/tests/dtds/HTMLsym.ent +241 -0
  158. data/vendor/pygments-main/tests/examplefiles/ANTLRv3.g +608 -0
  159. data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +209 -0
  160. data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +102 -0
  161. data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
  162. data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +611 -0
  163. data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
  164. data/vendor/pygments-main/tests/examplefiles/Constants.mo +158 -0
  165. data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +411 -0
  166. data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
  167. data/vendor/pygments-main/tests/examplefiles/Errors.scala +18 -0
  168. data/vendor/pygments-main/tests/examplefiles/File.hy +174 -0
  169. data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
  170. data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
  171. data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
  172. data/vendor/pygments-main/tests/examplefiles/Intro.java +1660 -0
  173. data/vendor/pygments-main/tests/examplefiles/Makefile +1131 -0
  174. data/vendor/pygments-main/tests/examplefiles/Object.st +4394 -0
  175. data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +584 -0
  176. data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
  177. data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +378 -0
  178. data/vendor/pygments-main/tests/examplefiles/Sorting.mod +470 -0
  179. data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +382 -0
  180. data/vendor/pygments-main/tests/examplefiles/addressbook.proto +30 -0
  181. data/vendor/pygments-main/tests/examplefiles/antlr_throws +1 -0
  182. data/vendor/pygments-main/tests/examplefiles/apache2.conf +393 -0
  183. data/vendor/pygments-main/tests/examplefiles/as3_test.as +143 -0
  184. data/vendor/pygments-main/tests/examplefiles/as3_test2.as +46 -0
  185. data/vendor/pygments-main/tests/examplefiles/as3_test3.as +3 -0
  186. data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +27 -0
  187. data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
  188. data/vendor/pygments-main/tests/examplefiles/badcase.java +2 -0
  189. data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
  190. data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
  191. data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -0
  192. data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
  193. data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
  194. data/vendor/pygments-main/tests/examplefiles/cells.ps +515 -0
  195. data/vendor/pygments-main/tests/examplefiles/ceval.c +2604 -0
  196. data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +13 -0
  197. data/vendor/pygments-main/tests/examplefiles/classes.dylan +125 -0
  198. data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +10 -0
  199. data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +447 -0
  200. data/vendor/pygments-main/tests/examplefiles/database.pytb +20 -0
  201. data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +2461 -0
  202. data/vendor/pygments-main/tests/examplefiles/demo.ahk +181 -0
  203. data/vendor/pygments-main/tests/examplefiles/demo.cfm +38 -0
  204. data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +68 -0
  205. data/vendor/pygments-main/tests/examplefiles/dwarf.cw +17 -0
  206. data/vendor/pygments-main/tests/examplefiles/erl_session +10 -0
  207. data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +1 -0
  208. data/vendor/pygments-main/tests/examplefiles/evil_regex.js +48 -0
  209. data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
  210. data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
  211. data/vendor/pygments-main/tests/examplefiles/example.c +2080 -0
  212. data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
  213. data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
  214. data/vendor/pygments-main/tests/examplefiles/example.cls +15 -0
  215. data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
  216. data/vendor/pygments-main/tests/examplefiles/example.cpp +2363 -0
  217. data/vendor/pygments-main/tests/examplefiles/example.gs +106 -0
  218. data/vendor/pygments-main/tests/examplefiles/example.gst +7 -0
  219. data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
  220. data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
  221. data/vendor/pygments-main/tests/examplefiles/example.kt +47 -0
  222. data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
  223. data/vendor/pygments-main/tests/examplefiles/example.lua +250 -0
  224. data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
  225. data/vendor/pygments-main/tests/examplefiles/example.moo +26 -0
  226. data/vendor/pygments-main/tests/examplefiles/example.moon +629 -0
  227. data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
  228. data/vendor/pygments-main/tests/examplefiles/example.nim +1010 -0
  229. data/vendor/pygments-main/tests/examplefiles/example.ns2 +69 -0
  230. data/vendor/pygments-main/tests/examplefiles/example.p +34 -0
  231. data/vendor/pygments-main/tests/examplefiles/example.pas +2708 -0
  232. data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
  233. data/vendor/pygments-main/tests/examplefiles/example.rb +1852 -0
  234. data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
  235. data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
  236. data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
  237. data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
  238. data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
  239. data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -0
  240. data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
  241. data/vendor/pygments-main/tests/examplefiles/example.sml +156 -0
  242. data/vendor/pygments-main/tests/examplefiles/example.snobol +15 -0
  243. data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
  244. data/vendor/pygments-main/tests/examplefiles/example.tea +34 -0
  245. data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
  246. data/vendor/pygments-main/tests/examplefiles/example.u +548 -0
  247. data/vendor/pygments-main/tests/examplefiles/example.weechatlog +9 -0
  248. data/vendor/pygments-main/tests/examplefiles/example.xhtml +376 -0
  249. data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
  250. data/vendor/pygments-main/tests/examplefiles/example.yaml +302 -0
  251. data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -0
  252. data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
  253. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +363 -0
  254. data/vendor/pygments-main/tests/examplefiles/example_file.fy +128 -0
  255. data/vendor/pygments-main/tests/examplefiles/firefox.mak +586 -0
  256. data/vendor/pygments-main/tests/examplefiles/flipflop.sv +19 -0
  257. data/vendor/pygments-main/tests/examplefiles/foo.sce +6 -0
  258. data/vendor/pygments-main/tests/examplefiles/format.ml +1213 -0
  259. data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +77 -0
  260. data/vendor/pygments-main/tests/examplefiles/function.mu +1 -0
  261. data/vendor/pygments-main/tests/examplefiles/functional.rst +1472 -0
  262. data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
  263. data/vendor/pygments-main/tests/examplefiles/genclass.clj +510 -0
  264. data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +193 -0
  265. data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +33 -0
  266. data/vendor/pygments-main/tests/examplefiles/glsl.frag +7 -0
  267. data/vendor/pygments-main/tests/examplefiles/glsl.vert +13 -0
  268. data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
  269. data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
  270. data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
  271. data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +1 -0
  272. data/vendor/pygments-main/tests/examplefiles/http_request_example +15 -0
  273. data/vendor/pygments-main/tests/examplefiles/http_response_example +29 -0
  274. data/vendor/pygments-main/tests/examplefiles/import.hs +4 -0
  275. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
  276. data/vendor/pygments-main/tests/examplefiles/intro.ik +24 -0
  277. data/vendor/pygments-main/tests/examplefiles/ints.php +10 -0
  278. data/vendor/pygments-main/tests/examplefiles/intsyn.fun +675 -0
  279. data/vendor/pygments-main/tests/examplefiles/intsyn.sig +286 -0
  280. data/vendor/pygments-main/tests/examplefiles/irb_heredoc +8 -0
  281. data/vendor/pygments-main/tests/examplefiles/irc.lsp +214 -0
  282. data/vendor/pygments-main/tests/examplefiles/java.properties +16 -0
  283. data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +28 -0
  284. data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +45 -0
  285. data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +713 -0
  286. data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
  287. data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
  288. data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +13 -0
  289. data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -0
  290. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
  291. data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
  292. data/vendor/pygments-main/tests/examplefiles/ltmain.sh +2849 -0
  293. data/vendor/pygments-main/tests/examplefiles/main.cmake +42 -0
  294. data/vendor/pygments-main/tests/examplefiles/markdown.lsp +679 -0
  295. data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +3 -0
  296. data/vendor/pygments-main/tests/examplefiles/matlab_sample +30 -0
  297. data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -0
  298. data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
  299. data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
  300. data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
  301. data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +4 -0
  302. data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +340 -0
  303. data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +38 -0
  304. data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
  305. data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +96 -0
  306. data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +30 -0
  307. data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +87 -0
  308. data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +118 -0
  309. data/vendor/pygments-main/tests/examplefiles/numbers.c +12 -0
  310. data/vendor/pygments-main/tests/examplefiles/objc_example.m +32 -0
  311. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +24 -0
  312. data/vendor/pygments-main/tests/examplefiles/perl_misc +62 -0
  313. data/vendor/pygments-main/tests/examplefiles/perl_perl5db +998 -0
  314. data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +120 -0
  315. data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +856 -0
  316. data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
  317. data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +567 -0
  318. data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +1223 -0
  319. data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +47 -0
  320. data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +10 -0
  321. data/vendor/pygments-main/tests/examplefiles/psql_session.txt +122 -0
  322. data/vendor/pygments-main/tests/examplefiles/py3_test.txt +2 -0
  323. data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
  324. data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +14 -0
  325. data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -0
  326. data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
  327. data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +234 -0
  328. data/vendor/pygments-main/tests/examplefiles/qsort.prolog +13 -0
  329. data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +38 -0
  330. data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +280 -0
  331. data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +2 -0
  332. data/vendor/pygments-main/tests/examplefiles/regex.js +22 -0
  333. data/vendor/pygments-main/tests/examplefiles/reversi.lsp +427 -0
  334. data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
  335. data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +11 -0
  336. data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
  337. data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -0
  338. data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
  339. data/vendor/pygments-main/tests/examplefiles/sibling.prolog +19 -0
  340. data/vendor/pygments-main/tests/examplefiles/simple.md +747 -0
  341. data/vendor/pygments-main/tests/examplefiles/smarty_example.html +209 -0
  342. data/vendor/pygments-main/tests/examplefiles/source.lgt +343 -0
  343. data/vendor/pygments-main/tests/examplefiles/sources.list +62 -0
  344. data/vendor/pygments-main/tests/examplefiles/sphere.pov +18 -0
  345. data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +27 -0
  346. data/vendor/pygments-main/tests/examplefiles/squid.conf +30 -0
  347. data/vendor/pygments-main/tests/examplefiles/string.jl +1031 -0
  348. data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +21 -0
  349. data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +3 -0
  350. data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
  351. data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
  352. data/vendor/pygments-main/tests/examplefiles/test.R +153 -0
  353. data/vendor/pygments-main/tests/examplefiles/test.adb +211 -0
  354. data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
  355. data/vendor/pygments-main/tests/examplefiles/test.asy +131 -0
  356. data/vendor/pygments-main/tests/examplefiles/test.awk +121 -0
  357. data/vendor/pygments-main/tests/examplefiles/test.bas +29 -0
  358. data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
  359. data/vendor/pygments-main/tests/examplefiles/test.bmx +145 -0
  360. data/vendor/pygments-main/tests/examplefiles/test.boo +39 -0
  361. data/vendor/pygments-main/tests/examplefiles/test.bro +250 -0
  362. data/vendor/pygments-main/tests/examplefiles/test.cs +374 -0
  363. data/vendor/pygments-main/tests/examplefiles/test.css +54 -0
  364. data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
  365. data/vendor/pygments-main/tests/examplefiles/test.d +135 -0
  366. data/vendor/pygments-main/tests/examplefiles/test.dart +23 -0
  367. data/vendor/pygments-main/tests/examplefiles/test.dtd +89 -0
  368. data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
  369. data/vendor/pygments-main/tests/examplefiles/test.ec +605 -0
  370. data/vendor/pygments-main/tests/examplefiles/test.ecl +58 -0
  371. data/vendor/pygments-main/tests/examplefiles/test.eh +315 -0
  372. data/vendor/pygments-main/tests/examplefiles/test.erl +169 -0
  373. data/vendor/pygments-main/tests/examplefiles/test.evoque +33 -0
  374. data/vendor/pygments-main/tests/examplefiles/test.fan +818 -0
  375. data/vendor/pygments-main/tests/examplefiles/test.flx +57 -0
  376. data/vendor/pygments-main/tests/examplefiles/test.gdc +13 -0
  377. data/vendor/pygments-main/tests/examplefiles/test.groovy +97 -0
  378. data/vendor/pygments-main/tests/examplefiles/test.html +339 -0
  379. data/vendor/pygments-main/tests/examplefiles/test.ini +10 -0
  380. data/vendor/pygments-main/tests/examplefiles/test.java +653 -0
  381. data/vendor/pygments-main/tests/examplefiles/test.jsp +24 -0
  382. data/vendor/pygments-main/tests/examplefiles/test.maql +45 -0
  383. data/vendor/pygments-main/tests/examplefiles/test.mod +374 -0
  384. data/vendor/pygments-main/tests/examplefiles/test.moo +51 -0
  385. data/vendor/pygments-main/tests/examplefiles/test.myt +166 -0
  386. data/vendor/pygments-main/tests/examplefiles/test.nim +93 -0
  387. data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
  388. data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
  389. data/vendor/pygments-main/tests/examplefiles/test.pas +743 -0
  390. data/vendor/pygments-main/tests/examplefiles/test.php +505 -0
  391. data/vendor/pygments-main/tests/examplefiles/test.plot +333 -0
  392. data/vendor/pygments-main/tests/examplefiles/test.ps1 +108 -0
  393. data/vendor/pygments-main/tests/examplefiles/test.pypylog +1839 -0
  394. data/vendor/pygments-main/tests/examplefiles/test.r3 +94 -0
  395. data/vendor/pygments-main/tests/examplefiles/test.rb +177 -0
  396. data/vendor/pygments-main/tests/examplefiles/test.rhtml +43 -0
  397. data/vendor/pygments-main/tests/examplefiles/test.scaml +8 -0
  398. data/vendor/pygments-main/tests/examplefiles/test.ssp +12 -0
  399. data/vendor/pygments-main/tests/examplefiles/test.tcsh +830 -0
  400. data/vendor/pygments-main/tests/examplefiles/test.vb +407 -0
  401. data/vendor/pygments-main/tests/examplefiles/test.vhdl +161 -0
  402. data/vendor/pygments-main/tests/examplefiles/test.xqy +138 -0
  403. data/vendor/pygments-main/tests/examplefiles/test.xsl +23 -0
  404. data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
  405. data/vendor/pygments-main/tests/examplefiles/truncated.pytb +15 -0
  406. data/vendor/pygments-main/tests/examplefiles/type.lisp +1218 -0
  407. data/vendor/pygments-main/tests/examplefiles/underscore.coffee +603 -0
  408. data/vendor/pygments-main/tests/examplefiles/unicode.applescript +5 -0
  409. data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +11 -0
  410. data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
  411. data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +3 -0
  412. data/vendor/pygments-main/tests/examplefiles/while.pov +13 -0
  413. data/vendor/pygments-main/tests/examplefiles/wiki.factor +384 -0
  414. data/vendor/pygments-main/tests/examplefiles/xml_example +1897 -0
  415. data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +798 -0
  416. data/vendor/pygments-main/tests/old_run.py +138 -0
  417. data/vendor/pygments-main/tests/run.py +49 -0
  418. data/vendor/pygments-main/tests/support.py +15 -0
  419. data/vendor/pygments-main/tests/support/tags +36 -0
  420. data/vendor/pygments-main/tests/test_basic_api.py +295 -0
  421. data/vendor/pygments-main/tests/test_clexer.py +31 -0
  422. data/vendor/pygments-main/tests/test_cmdline.py +105 -0
  423. data/vendor/pygments-main/tests/test_examplefiles.py +99 -0
  424. data/vendor/pygments-main/tests/test_html_formatter.py +178 -0
  425. data/vendor/pygments-main/tests/test_latex_formatter.py +55 -0
  426. data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
  427. data/vendor/pygments-main/tests/test_perllexer.py +137 -0
  428. data/vendor/pygments-main/tests/test_regexlexer.py +47 -0
  429. data/vendor/pygments-main/tests/test_token.py +46 -0
  430. data/vendor/pygments-main/tests/test_using_api.py +40 -0
  431. data/vendor/pygments-main/tests/test_util.py +135 -0
  432. data/vendor/simplejson/.gitignore +10 -0
  433. data/vendor/simplejson/.travis.yml +5 -0
  434. data/vendor/simplejson/CHANGES.txt +291 -0
  435. data/vendor/simplejson/LICENSE.txt +19 -0
  436. data/vendor/simplejson/MANIFEST.in +5 -0
  437. data/vendor/simplejson/README.rst +19 -0
  438. data/vendor/simplejson/conf.py +179 -0
  439. data/vendor/simplejson/index.rst +628 -0
  440. data/vendor/simplejson/scripts/make_docs.py +18 -0
  441. data/vendor/simplejson/setup.py +104 -0
  442. data/vendor/simplejson/simplejson/__init__.py +510 -0
  443. data/vendor/simplejson/simplejson/_speedups.c +2745 -0
  444. data/vendor/simplejson/simplejson/decoder.py +425 -0
  445. data/vendor/simplejson/simplejson/encoder.py +567 -0
  446. data/vendor/simplejson/simplejson/ordered_dict.py +119 -0
  447. data/vendor/simplejson/simplejson/scanner.py +77 -0
  448. data/vendor/simplejson/simplejson/tests/__init__.py +67 -0
  449. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +55 -0
  450. data/vendor/simplejson/simplejson/tests/test_check_circular.py +30 -0
  451. data/vendor/simplejson/simplejson/tests/test_decimal.py +66 -0
  452. data/vendor/simplejson/simplejson/tests/test_decode.py +83 -0
  453. data/vendor/simplejson/simplejson/tests/test_default.py +9 -0
  454. data/vendor/simplejson/simplejson/tests/test_dump.py +67 -0
  455. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +46 -0
  456. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +32 -0
  457. data/vendor/simplejson/simplejson/tests/test_errors.py +34 -0
  458. data/vendor/simplejson/simplejson/tests/test_fail.py +91 -0
  459. data/vendor/simplejson/simplejson/tests/test_float.py +19 -0
  460. data/vendor/simplejson/simplejson/tests/test_indent.py +86 -0
  461. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +20 -0
  462. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +121 -0
  463. data/vendor/simplejson/simplejson/tests/test_pass1.py +76 -0
  464. data/vendor/simplejson/simplejson/tests/test_pass2.py +14 -0
  465. data/vendor/simplejson/simplejson/tests/test_pass3.py +20 -0
  466. data/vendor/simplejson/simplejson/tests/test_recursion.py +67 -0
  467. data/vendor/simplejson/simplejson/tests/test_scanstring.py +117 -0
  468. data/vendor/simplejson/simplejson/tests/test_separators.py +42 -0
  469. data/vendor/simplejson/simplejson/tests/test_speedups.py +20 -0
  470. data/vendor/simplejson/simplejson/tests/test_tuple.py +49 -0
  471. data/vendor/simplejson/simplejson/tests/test_unicode.py +109 -0
  472. data/vendor/simplejson/simplejson/tool.py +39 -0
  473. metadata +557 -0
@@ -0,0 +1,1893 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.text
4
+ ~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for non-source code file types.
7
+
8
+ :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ import re
13
+ from bisect import bisect
14
+
15
+ from pygments.lexer import Lexer, LexerContext, RegexLexer, ExtendedRegexLexer, \
16
+ bygroups, include, using, this, do_insertions
17
+ from pygments.token import Punctuation, Text, Comment, Keyword, Name, String, \
18
+ Generic, Operator, Number, Whitespace, Literal
19
+ from pygments.util import get_bool_opt, ClassNotFound
20
+ from pygments.lexers.other import BashLexer
21
+
22
+ __all__ = ['IniLexer', 'PropertiesLexer', 'SourcesListLexer', 'BaseMakefileLexer',
23
+ 'MakefileLexer', 'DiffLexer', 'IrcLogsLexer', 'TexLexer',
24
+ 'GroffLexer', 'ApacheConfLexer', 'BBCodeLexer', 'MoinWikiLexer',
25
+ 'RstLexer', 'VimLexer', 'GettextLexer', 'SquidConfLexer',
26
+ 'DebianControlLexer', 'DarcsPatchLexer', 'YamlLexer',
27
+ 'LighttpdConfLexer', 'NginxConfLexer', 'CMakeLexer', 'HttpLexer',
28
+ 'PyPyLogLexer', 'RegeditLexer', 'HxmlLexer', 'EbnfLexer']
29
+
30
+
31
+ class IniLexer(RegexLexer):
32
+ """
33
+ Lexer for configuration files in INI style.
34
+ """
35
+
36
+ name = 'INI'
37
+ aliases = ['ini', 'cfg', 'dosini']
38
+ filenames = ['*.ini', '*.cfg']
39
+ mimetypes = ['text/x-ini']
40
+
41
+ tokens = {
42
+ 'root': [
43
+ (r'\s+', Text),
44
+ (r'[;#].*', Comment.Single),
45
+ (r'\[.*?\]$', Keyword),
46
+ (r'(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)',
47
+ bygroups(Name.Attribute, Text, Operator, Text, String))
48
+ ]
49
+ }
50
+
51
+ def analyse_text(text):
52
+ npos = text.find('\n')
53
+ if npos < 3:
54
+ return False
55
+ return text[0] == '[' and text[npos-1] == ']'
56
+
57
+
58
+ class RegeditLexer(RegexLexer):
59
+ """
60
+ Lexer for `Windows Registry
61
+ <http://en.wikipedia.org/wiki/Windows_Registry#.REG_files>`_ files produced
62
+ by regedit.
63
+
64
+ *New in Pygments 1.6.*
65
+ """
66
+
67
+ name = 'reg'
68
+ aliases = ['registry']
69
+ filenames = ['*.reg']
70
+ mimetypes = ['text/x-windows-registry']
71
+
72
+ tokens = {
73
+ 'root': [
74
+ (r'Windows Registry Editor.*', Text),
75
+ (r'\s+', Text),
76
+ (r'[;#].*', Comment.Single),
77
+ (r'(\[)(-?)(HKEY_[A-Z_]+)(.*?\])$',
78
+ bygroups(Keyword, Operator, Name.Builtin, Keyword)),
79
+ # String keys, which obey somewhat normal escaping
80
+ (r'("(?:\\"|\\\\|[^"])+")([ \t]*)(=)([ \t]*)',
81
+ bygroups(Name.Attribute, Text, Operator, Text),
82
+ 'value'),
83
+ # Bare keys (includes @)
84
+ (r'(.*?)([ \t]*)(=)([ \t]*)',
85
+ bygroups(Name.Attribute, Text, Operator, Text),
86
+ 'value'),
87
+ ],
88
+ 'value': [
89
+ (r'-', Operator, '#pop'), # delete value
90
+ (r'(dword|hex(?:\([0-9a-fA-F]\))?)(:)([0-9a-fA-F,]+)',
91
+ bygroups(Name.Variable, Punctuation, Number), '#pop'),
92
+ # As far as I know, .reg files do not support line continuation.
93
+ (r'.*', String, '#pop'),
94
+ ]
95
+ }
96
+
97
+ def analyse_text(text):
98
+ return text.startswith('Windows Registry Editor')
99
+
100
+
101
+ class PropertiesLexer(RegexLexer):
102
+ """
103
+ Lexer for configuration files in Java's properties format.
104
+
105
+ *New in Pygments 1.4.*
106
+ """
107
+
108
+ name = 'Properties'
109
+ aliases = ['properties', 'jproperties']
110
+ filenames = ['*.properties']
111
+ mimetypes = ['text/x-java-properties']
112
+
113
+ tokens = {
114
+ 'root': [
115
+ (r'\s+', Text),
116
+ (r'(?:[;#]|//).*$', Comment),
117
+ (r'(.*?)([ \t]*)([=:])([ \t]*)(.*(?:(?<=\\)\n.*)*)',
118
+ bygroups(Name.Attribute, Text, Operator, Text, String)),
119
+ ],
120
+ }
121
+
122
+
123
+ class SourcesListLexer(RegexLexer):
124
+ """
125
+ Lexer that highlights debian sources.list files.
126
+
127
+ *New in Pygments 0.7.*
128
+ """
129
+
130
+ name = 'Debian Sourcelist'
131
+ aliases = ['sourceslist', 'sources.list', 'debsources']
132
+ filenames = ['sources.list']
133
+ mimetype = ['application/x-debian-sourceslist']
134
+
135
+ tokens = {
136
+ 'root': [
137
+ (r'\s+', Text),
138
+ (r'#.*?$', Comment),
139
+ (r'^(deb(?:-src)?)(\s+)',
140
+ bygroups(Keyword, Text), 'distribution')
141
+ ],
142
+ 'distribution': [
143
+ (r'#.*?$', Comment, '#pop'),
144
+ (r'\$\(ARCH\)', Name.Variable),
145
+ (r'[^\s$[]+', String),
146
+ (r'\[', String.Other, 'escaped-distribution'),
147
+ (r'\$', String),
148
+ (r'\s+', Text, 'components')
149
+ ],
150
+ 'escaped-distribution': [
151
+ (r'\]', String.Other, '#pop'),
152
+ (r'\$\(ARCH\)', Name.Variable),
153
+ (r'[^\]$]+', String.Other),
154
+ (r'\$', String.Other)
155
+ ],
156
+ 'components': [
157
+ (r'#.*?$', Comment, '#pop:2'),
158
+ (r'$', Text, '#pop:2'),
159
+ (r'\s+', Text),
160
+ (r'\S+', Keyword.Pseudo),
161
+ ]
162
+ }
163
+
164
+ def analyse_text(text):
165
+ for line in text.split('\n'):
166
+ line = line.strip()
167
+ if not (line.startswith('#') or line.startswith('deb ') or
168
+ line.startswith('deb-src ') or not line):
169
+ return False
170
+ return True
171
+
172
+
173
+ class MakefileLexer(Lexer):
174
+ """
175
+ Lexer for BSD and GNU make extensions (lenient enough to handle both in
176
+ the same file even).
177
+
178
+ *Rewritten in Pygments 0.10.*
179
+ """
180
+
181
+ name = 'Makefile'
182
+ aliases = ['make', 'makefile', 'mf', 'bsdmake']
183
+ filenames = ['*.mak', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile']
184
+ mimetypes = ['text/x-makefile']
185
+
186
+ r_special = re.compile(r'^(?:'
187
+ # BSD Make
188
+ r'\.\s*(include|undef|error|warning|if|else|elif|endif|for|endfor)|'
189
+ # GNU Make
190
+ r'\s*(ifeq|ifneq|ifdef|ifndef|else|endif|-?include|define|endef|:))(?=\s)')
191
+ r_comment = re.compile(r'^\s*@?#')
192
+
193
+ def get_tokens_unprocessed(self, text):
194
+ ins = []
195
+ lines = text.splitlines(True)
196
+ done = ''
197
+ lex = BaseMakefileLexer(**self.options)
198
+ backslashflag = False
199
+ for line in lines:
200
+ if self.r_special.match(line) or backslashflag:
201
+ ins.append((len(done), [(0, Comment.Preproc, line)]))
202
+ backslashflag = line.strip().endswith('\\')
203
+ elif self.r_comment.match(line):
204
+ ins.append((len(done), [(0, Comment, line)]))
205
+ else:
206
+ done += line
207
+ for item in do_insertions(ins, lex.get_tokens_unprocessed(done)):
208
+ yield item
209
+
210
+
211
+ class BaseMakefileLexer(RegexLexer):
212
+ """
213
+ Lexer for simple Makefiles (no preprocessing).
214
+
215
+ *New in Pygments 0.10.*
216
+ """
217
+
218
+ name = 'Base Makefile'
219
+ aliases = ['basemake']
220
+ filenames = []
221
+ mimetypes = []
222
+
223
+ tokens = {
224
+ 'root': [
225
+ (r'^(?:[\t ]+.*\n|\n)+', using(BashLexer)),
226
+ (r'\$\((?:.*\\\n|.*\n)+', using(BashLexer)),
227
+ (r'\s+', Text),
228
+ (r'#.*?\n', Comment),
229
+ (r'(export)(\s+)(?=[a-zA-Z0-9_${}\t -]+\n)',
230
+ bygroups(Keyword, Text), 'export'),
231
+ (r'export\s+', Keyword),
232
+ # assignment
233
+ (r'([a-zA-Z0-9_${}.-]+)(\s*)([!?:+]?=)([ \t]*)((?:.*\\\n)+|.*\n)',
234
+ bygroups(Name.Variable, Text, Operator, Text, using(BashLexer))),
235
+ # strings
236
+ (r'(?s)"(\\\\|\\.|[^"\\])*"', String.Double),
237
+ (r"(?s)'(\\\\|\\.|[^'\\])*'", String.Single),
238
+ # targets
239
+ (r'([^\n:]+)(:+)([ \t]*)', bygroups(Name.Function, Operator, Text),
240
+ 'block-header'),
241
+ # TODO: add paren handling (grr)
242
+ ],
243
+ 'export': [
244
+ (r'[a-zA-Z0-9_${}-]+', Name.Variable),
245
+ (r'\n', Text, '#pop'),
246
+ (r'\s+', Text),
247
+ ],
248
+ 'block-header': [
249
+ (r'[^,\\\n#]+', Number),
250
+ (r',', Punctuation),
251
+ (r'#.*?\n', Comment),
252
+ (r'\\\n', Text), # line continuation
253
+ (r'\\.', Text),
254
+ (r'(?:[\t ]+.*\n|\n)+', using(BashLexer), '#pop'),
255
+ ],
256
+ }
257
+
258
+
259
+ class DiffLexer(RegexLexer):
260
+ """
261
+ Lexer for unified or context-style diffs or patches.
262
+ """
263
+
264
+ name = 'Diff'
265
+ aliases = ['diff', 'udiff']
266
+ filenames = ['*.diff', '*.patch']
267
+ mimetypes = ['text/x-diff', 'text/x-patch']
268
+
269
+ tokens = {
270
+ 'root': [
271
+ (r' .*\n', Text),
272
+ (r'\+.*\n', Generic.Inserted),
273
+ (r'-.*\n', Generic.Deleted),
274
+ (r'!.*\n', Generic.Strong),
275
+ (r'@.*\n', Generic.Subheading),
276
+ (r'([Ii]ndex|diff).*\n', Generic.Heading),
277
+ (r'=.*\n', Generic.Heading),
278
+ (r'.*\n', Text),
279
+ ]
280
+ }
281
+
282
+ def analyse_text(text):
283
+ if text[:7] == 'Index: ':
284
+ return True
285
+ if text[:5] == 'diff ':
286
+ return True
287
+ if text[:4] == '--- ':
288
+ return 0.9
289
+
290
+
291
+ DPATCH_KEYWORDS = ['hunk', 'addfile', 'adddir', 'rmfile', 'rmdir', 'move',
292
+ 'replace']
293
+
294
+ class DarcsPatchLexer(RegexLexer):
295
+ """
296
+ DarcsPatchLexer is a lexer for the various versions of the darcs patch
297
+ format. Examples of this format are derived by commands such as
298
+ ``darcs annotate --patch`` and ``darcs send``.
299
+
300
+ *New in Pygments 0.10.*
301
+ """
302
+ name = 'Darcs Patch'
303
+ aliases = ['dpatch']
304
+ filenames = ['*.dpatch', '*.darcspatch']
305
+
306
+ tokens = {
307
+ 'root': [
308
+ (r'<', Operator),
309
+ (r'>', Operator),
310
+ (r'{', Operator),
311
+ (r'}', Operator),
312
+ (r'(\[)((?:TAG )?)(.*)(\n)(.*)(\*\*)(\d+)(\s?)(\])',
313
+ bygroups(Operator, Keyword, Name, Text, Name, Operator,
314
+ Literal.Date, Text, Operator)),
315
+ (r'(\[)((?:TAG )?)(.*)(\n)(.*)(\*\*)(\d+)(\s?)',
316
+ bygroups(Operator, Keyword, Name, Text, Name, Operator,
317
+ Literal.Date, Text), 'comment'),
318
+ (r'New patches:', Generic.Heading),
319
+ (r'Context:', Generic.Heading),
320
+ (r'Patch bundle hash:', Generic.Heading),
321
+ (r'(\s*)(%s)(.*\n)' % '|'.join(DPATCH_KEYWORDS),
322
+ bygroups(Text, Keyword, Text)),
323
+ (r'\+', Generic.Inserted, "insert"),
324
+ (r'-', Generic.Deleted, "delete"),
325
+ (r'.*\n', Text),
326
+ ],
327
+ 'comment': [
328
+ (r'[^\]].*\n', Comment),
329
+ (r'\]', Operator, "#pop"),
330
+ ],
331
+ 'specialText': [ # darcs add [_CODE_] special operators for clarity
332
+ (r'\n', Text, "#pop"), # line-based
333
+ (r'\[_[^_]*_]', Operator),
334
+ ],
335
+ 'insert': [
336
+ include('specialText'),
337
+ (r'\[', Generic.Inserted),
338
+ (r'[^\n\[]+', Generic.Inserted),
339
+ ],
340
+ 'delete': [
341
+ include('specialText'),
342
+ (r'\[', Generic.Deleted),
343
+ (r'[^\n\[]+', Generic.Deleted),
344
+ ],
345
+ }
346
+
347
+
348
+ class IrcLogsLexer(RegexLexer):
349
+ """
350
+ Lexer for IRC logs in *irssi*, *xchat* or *weechat* style.
351
+ """
352
+
353
+ name = 'IRC logs'
354
+ aliases = ['irc']
355
+ filenames = ['*.weechatlog']
356
+ mimetypes = ['text/x-irclog']
357
+
358
+ flags = re.VERBOSE | re.MULTILINE
359
+ timestamp = r"""
360
+ (
361
+ # irssi / xchat and others
362
+ (?: \[|\()? # Opening bracket or paren for the timestamp
363
+ (?: # Timestamp
364
+ (?: (?:\d{1,4} [-/]?)+ # Date as - or /-separated groups of digits
365
+ [T ])? # Date/time separator: T or space
366
+ (?: \d?\d [:.]?)+ # Time as :/.-separated groups of 1 or 2 digits
367
+ )
368
+ (?: \]|\))?\s+ # Closing bracket or paren for the timestamp
369
+ |
370
+ # weechat
371
+ \d{4}\s\w{3}\s\d{2}\s # Date
372
+ \d{2}:\d{2}:\d{2}\s+ # Time + Whitespace
373
+ |
374
+ # xchat
375
+ \w{3}\s\d{2}\s # Date
376
+ \d{2}:\d{2}:\d{2}\s+ # Time + Whitespace
377
+ )?
378
+ """
379
+ tokens = {
380
+ 'root': [
381
+ # log start/end
382
+ (r'^\*\*\*\*(.*)\*\*\*\*$', Comment),
383
+ # hack
384
+ ("^" + timestamp + r'(\s*<[^>]*>\s*)$', bygroups(Comment.Preproc, Name.Tag)),
385
+ # normal msgs
386
+ ("^" + timestamp + r"""
387
+ (\s*<.*?>\s*) # Nick """,
388
+ bygroups(Comment.Preproc, Name.Tag), 'msg'),
389
+ # /me msgs
390
+ ("^" + timestamp + r"""
391
+ (\s*[*]\s+) # Star
392
+ (\S+\s+.*?\n) # Nick + rest of message """,
393
+ bygroups(Comment.Preproc, Keyword, Generic.Inserted)),
394
+ # join/part msgs
395
+ ("^" + timestamp + r"""
396
+ (\s*(?:\*{3}|<?-[!@=P]?->?)\s*) # Star(s) or symbols
397
+ (\S+\s+) # Nick + Space
398
+ (.*?\n) # Rest of message """,
399
+ bygroups(Comment.Preproc, Keyword, String, Comment)),
400
+ (r"^.*?\n", Text),
401
+ ],
402
+ 'msg': [
403
+ (r"\S+:(?!//)", Name.Attribute), # Prefix
404
+ (r".*\n", Text, '#pop'),
405
+ ],
406
+ }
407
+
408
+
409
+ class BBCodeLexer(RegexLexer):
410
+ """
411
+ A lexer that highlights BBCode(-like) syntax.
412
+
413
+ *New in Pygments 0.6.*
414
+ """
415
+
416
+ name = 'BBCode'
417
+ aliases = ['bbcode']
418
+ mimetypes = ['text/x-bbcode']
419
+
420
+ tokens = {
421
+ 'root': [
422
+ (r'[^[]+', Text),
423
+ # tag/end tag begin
424
+ (r'\[/?\w+', Keyword, 'tag'),
425
+ # stray bracket
426
+ (r'\[', Text),
427
+ ],
428
+ 'tag': [
429
+ (r'\s+', Text),
430
+ # attribute with value
431
+ (r'(\w+)(=)("?[^\s"\]]+"?)',
432
+ bygroups(Name.Attribute, Operator, String)),
433
+ # tag argument (a la [color=green])
434
+ (r'(=)("?[^\s"\]]+"?)',
435
+ bygroups(Operator, String)),
436
+ # tag end
437
+ (r'\]', Keyword, '#pop'),
438
+ ],
439
+ }
440
+
441
+
442
+ class TexLexer(RegexLexer):
443
+ """
444
+ Lexer for the TeX and LaTeX typesetting languages.
445
+ """
446
+
447
+ name = 'TeX'
448
+ aliases = ['tex', 'latex']
449
+ filenames = ['*.tex', '*.aux', '*.toc']
450
+ mimetypes = ['text/x-tex', 'text/x-latex']
451
+
452
+ tokens = {
453
+ 'general': [
454
+ (r'%.*?\n', Comment),
455
+ (r'[{}]', Name.Builtin),
456
+ (r'[&_^]', Name.Builtin),
457
+ ],
458
+ 'root': [
459
+ (r'\\\[', String.Backtick, 'displaymath'),
460
+ (r'\\\(', String, 'inlinemath'),
461
+ (r'\$\$', String.Backtick, 'displaymath'),
462
+ (r'\$', String, 'inlinemath'),
463
+ (r'\\([a-zA-Z]+|.)', Keyword, 'command'),
464
+ include('general'),
465
+ (r'[^\\$%&_^{}]+', Text),
466
+ ],
467
+ 'math': [
468
+ (r'\\([a-zA-Z]+|.)', Name.Variable),
469
+ include('general'),
470
+ (r'[0-9]+', Number),
471
+ (r'[-=!+*/()\[\]]', Operator),
472
+ (r'[^=!+*/()\[\]\\$%&_^{}0-9-]+', Name.Builtin),
473
+ ],
474
+ 'inlinemath': [
475
+ (r'\\\)', String, '#pop'),
476
+ (r'\$', String, '#pop'),
477
+ include('math'),
478
+ ],
479
+ 'displaymath': [
480
+ (r'\\\]', String, '#pop'),
481
+ (r'\$\$', String, '#pop'),
482
+ (r'\$', Name.Builtin),
483
+ include('math'),
484
+ ],
485
+ 'command': [
486
+ (r'\[.*?\]', Name.Attribute),
487
+ (r'\*', Keyword),
488
+ (r'', Text, '#pop'),
489
+ ],
490
+ }
491
+
492
+ def analyse_text(text):
493
+ for start in ("\\documentclass", "\\input", "\\documentstyle",
494
+ "\\relax"):
495
+ if text[:len(start)] == start:
496
+ return True
497
+
498
+
499
+ class GroffLexer(RegexLexer):
500
+ """
501
+ Lexer for the (g)roff typesetting language, supporting groff
502
+ extensions. Mainly useful for highlighting manpage sources.
503
+
504
+ *New in Pygments 0.6.*
505
+ """
506
+
507
+ name = 'Groff'
508
+ aliases = ['groff', 'nroff', 'man']
509
+ filenames = ['*.[1234567]', '*.man']
510
+ mimetypes = ['application/x-troff', 'text/troff']
511
+
512
+ tokens = {
513
+ 'root': [
514
+ (r'(\.)(\w+)', bygroups(Text, Keyword), 'request'),
515
+ (r'\.', Punctuation, 'request'),
516
+ # Regular characters, slurp till we find a backslash or newline
517
+ (r'[^\\\n]*', Text, 'textline'),
518
+ ],
519
+ 'textline': [
520
+ include('escapes'),
521
+ (r'[^\\\n]+', Text),
522
+ (r'\n', Text, '#pop'),
523
+ ],
524
+ 'escapes': [
525
+ # groff has many ways to write escapes.
526
+ (r'\\"[^\n]*', Comment),
527
+ (r'\\[fn]\w', String.Escape),
528
+ (r'\\\(.{2}', String.Escape),
529
+ (r'\\.\[.*\]', String.Escape),
530
+ (r'\\.', String.Escape),
531
+ (r'\\\n', Text, 'request'),
532
+ ],
533
+ 'request': [
534
+ (r'\n', Text, '#pop'),
535
+ include('escapes'),
536
+ (r'"[^\n"]+"', String.Double),
537
+ (r'\d+', Number),
538
+ (r'\S+', String),
539
+ (r'\s+', Text),
540
+ ],
541
+ }
542
+
543
+ def analyse_text(text):
544
+ if text[:1] != '.':
545
+ return False
546
+ if text[:3] == '.\\"':
547
+ return True
548
+ if text[:4] == '.TH ':
549
+ return True
550
+ if text[1:3].isalnum() and text[3].isspace():
551
+ return 0.9
552
+
553
+
554
+ class ApacheConfLexer(RegexLexer):
555
+ """
556
+ Lexer for configuration files following the Apache config file
557
+ format.
558
+
559
+ *New in Pygments 0.6.*
560
+ """
561
+
562
+ name = 'ApacheConf'
563
+ aliases = ['apacheconf', 'aconf', 'apache']
564
+ filenames = ['.htaccess', 'apache.conf', 'apache2.conf']
565
+ mimetypes = ['text/x-apacheconf']
566
+ flags = re.MULTILINE | re.IGNORECASE
567
+
568
+ tokens = {
569
+ 'root': [
570
+ (r'\s+', Text),
571
+ (r'(#.*?)$', Comment),
572
+ (r'(<[^\s>]+)(?:(\s+)(.*?))?(>)',
573
+ bygroups(Name.Tag, Text, String, Name.Tag)),
574
+ (r'([a-zA-Z][a-zA-Z0-9_]*)(\s+)',
575
+ bygroups(Name.Builtin, Text), 'value'),
576
+ (r'\.+', Text),
577
+ ],
578
+ 'value': [
579
+ (r'$', Text, '#pop'),
580
+ (r'[^\S\n]+', Text),
581
+ (r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number),
582
+ (r'\d+', Number),
583
+ (r'/([a-zA-Z0-9][a-zA-Z0-9_./-]+)', String.Other),
584
+ (r'(on|off|none|any|all|double|email|dns|min|minimal|'
585
+ r'os|productonly|full|emerg|alert|crit|error|warn|'
586
+ r'notice|info|debug|registry|script|inetd|standalone|'
587
+ r'user|group)\b', Keyword),
588
+ (r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double),
589
+ (r'[^\s"]+', Text)
590
+ ]
591
+ }
592
+
593
+
594
+ class MoinWikiLexer(RegexLexer):
595
+ """
596
+ For MoinMoin (and Trac) Wiki markup.
597
+
598
+ *New in Pygments 0.7.*
599
+ """
600
+
601
+ name = 'MoinMoin/Trac Wiki markup'
602
+ aliases = ['trac-wiki', 'moin']
603
+ filenames = []
604
+ mimetypes = ['text/x-trac-wiki']
605
+ flags = re.MULTILINE | re.IGNORECASE
606
+
607
+ tokens = {
608
+ 'root': [
609
+ (r'^#.*$', Comment),
610
+ (r'(!)(\S+)', bygroups(Keyword, Text)), # Ignore-next
611
+ # Titles
612
+ (r'^(=+)([^=]+)(=+)(\s*#.+)?$',
613
+ bygroups(Generic.Heading, using(this), Generic.Heading, String)),
614
+ # Literal code blocks, with optional shebang
615
+ (r'({{{)(\n#!.+)?', bygroups(Name.Builtin, Name.Namespace), 'codeblock'),
616
+ (r'(\'\'\'?|\|\||`|__|~~|\^|,,|::)', Comment), # Formatting
617
+ # Lists
618
+ (r'^( +)([.*-])( )', bygroups(Text, Name.Builtin, Text)),
619
+ (r'^( +)([a-z]{1,5}\.)( )', bygroups(Text, Name.Builtin, Text)),
620
+ # Other Formatting
621
+ (r'\[\[\w+.*?\]\]', Keyword), # Macro
622
+ (r'(\[[^\s\]]+)(\s+[^\]]+?)?(\])',
623
+ bygroups(Keyword, String, Keyword)), # Link
624
+ (r'^----+$', Keyword), # Horizontal rules
625
+ (r'[^\n\'\[{!_~^,|]+', Text),
626
+ (r'\n', Text),
627
+ (r'.', Text),
628
+ ],
629
+ 'codeblock': [
630
+ (r'}}}', Name.Builtin, '#pop'),
631
+ # these blocks are allowed to be nested in Trac, but not MoinMoin
632
+ (r'{{{', Text, '#push'),
633
+ (r'[^{}]+', Comment.Preproc), # slurp boring text
634
+ (r'.', Comment.Preproc), # allow loose { or }
635
+ ],
636
+ }
637
+
638
+
639
+ class RstLexer(RegexLexer):
640
+ """
641
+ For `reStructuredText <http://docutils.sf.net/rst.html>`_ markup.
642
+
643
+ *New in Pygments 0.7.*
644
+
645
+ Additional options accepted:
646
+
647
+ `handlecodeblocks`
648
+ Highlight the contents of ``.. sourcecode:: langauge`` and
649
+ ``.. code:: language`` directives with a lexer for the given
650
+ language (default: ``True``). *New in Pygments 0.8.*
651
+ """
652
+ name = 'reStructuredText'
653
+ aliases = ['rst', 'rest', 'restructuredtext']
654
+ filenames = ['*.rst', '*.rest']
655
+ mimetypes = ["text/x-rst", "text/prs.fallenstein.rst"]
656
+ flags = re.MULTILINE
657
+
658
+ def _handle_sourcecode(self, match):
659
+ from pygments.lexers import get_lexer_by_name
660
+
661
+ # section header
662
+ yield match.start(1), Punctuation, match.group(1)
663
+ yield match.start(2), Text, match.group(2)
664
+ yield match.start(3), Operator.Word, match.group(3)
665
+ yield match.start(4), Punctuation, match.group(4)
666
+ yield match.start(5), Text, match.group(5)
667
+ yield match.start(6), Keyword, match.group(6)
668
+ yield match.start(7), Text, match.group(7)
669
+
670
+ # lookup lexer if wanted and existing
671
+ lexer = None
672
+ if self.handlecodeblocks:
673
+ try:
674
+ lexer = get_lexer_by_name(match.group(6).strip())
675
+ except ClassNotFound:
676
+ pass
677
+ indention = match.group(8)
678
+ indention_size = len(indention)
679
+ code = (indention + match.group(9) + match.group(10) + match.group(11))
680
+
681
+ # no lexer for this language. handle it like it was a code block
682
+ if lexer is None:
683
+ yield match.start(8), String, code
684
+ return
685
+
686
+ # highlight the lines with the lexer.
687
+ ins = []
688
+ codelines = code.splitlines(True)
689
+ code = ''
690
+ for line in codelines:
691
+ if len(line) > indention_size:
692
+ ins.append((len(code), [(0, Text, line[:indention_size])]))
693
+ code += line[indention_size:]
694
+ else:
695
+ code += line
696
+ for item in do_insertions(ins, lexer.get_tokens_unprocessed(code)):
697
+ yield item
698
+
699
+ # from docutils.parsers.rst.states
700
+ closers = u'\'")]}>\u2019\u201d\xbb!?'
701
+ unicode_delimiters = u'\u2010\u2011\u2012\u2013\u2014\u00a0'
702
+ end_string_suffix = (r'((?=$)|(?=[-/:.,; \n\x00%s%s]))'
703
+ % (re.escape(unicode_delimiters),
704
+ re.escape(closers)))
705
+
706
+ tokens = {
707
+ 'root': [
708
+ # Heading with overline
709
+ (r'^(=+|-+|`+|:+|\.+|\'+|"+|~+|\^+|_+|\*+|\++|#+)([ \t]*\n)'
710
+ r'(.+)(\n)(\1)(\n)',
711
+ bygroups(Generic.Heading, Text, Generic.Heading,
712
+ Text, Generic.Heading, Text)),
713
+ # Plain heading
714
+ (r'^(\S.*)(\n)(={3,}|-{3,}|`{3,}|:{3,}|\.{3,}|\'{3,}|"{3,}|'
715
+ r'~{3,}|\^{3,}|_{3,}|\*{3,}|\+{3,}|#{3,})(\n)',
716
+ bygroups(Generic.Heading, Text, Generic.Heading, Text)),
717
+ # Bulleted lists
718
+ (r'^(\s*)([-*+])( .+\n(?:\1 .+\n)*)',
719
+ bygroups(Text, Number, using(this, state='inline'))),
720
+ # Numbered lists
721
+ (r'^(\s*)([0-9#ivxlcmIVXLCM]+\.)( .+\n(?:\1 .+\n)*)',
722
+ bygroups(Text, Number, using(this, state='inline'))),
723
+ (r'^(\s*)(\(?[0-9#ivxlcmIVXLCM]+\))( .+\n(?:\1 .+\n)*)',
724
+ bygroups(Text, Number, using(this, state='inline'))),
725
+ # Numbered, but keep words at BOL from becoming lists
726
+ (r'^(\s*)([A-Z]+\.)( .+\n(?:\1 .+\n)+)',
727
+ bygroups(Text, Number, using(this, state='inline'))),
728
+ (r'^(\s*)(\(?[A-Za-z]+\))( .+\n(?:\1 .+\n)+)',
729
+ bygroups(Text, Number, using(this, state='inline'))),
730
+ # Line blocks
731
+ (r'^(\s*)(\|)( .+\n(?:\| .+\n)*)',
732
+ bygroups(Text, Operator, using(this, state='inline'))),
733
+ # Sourcecode directives
734
+ (r'^( *\.\.)(\s*)((?:source)?code)(::)([ \t]*)([^\n]+)'
735
+ r'(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\8.*|)\n)+)',
736
+ _handle_sourcecode),
737
+ # A directive
738
+ (r'^( *\.\.)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))',
739
+ bygroups(Punctuation, Text, Operator.Word, Punctuation, Text,
740
+ using(this, state='inline'))),
741
+ # A reference target
742
+ (r'^( *\.\.)(\s*)(_(?:[^:\\]|\\.)+:)(.*?)$',
743
+ bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))),
744
+ # A footnote/citation target
745
+ (r'^( *\.\.)(\s*)(\[.+\])(.*?)$',
746
+ bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))),
747
+ # A substitution def
748
+ (r'^( *\.\.)(\s*)(\|.+\|)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))',
749
+ bygroups(Punctuation, Text, Name.Tag, Text, Operator.Word,
750
+ Punctuation, Text, using(this, state='inline'))),
751
+ # Comments
752
+ (r'^ *\.\..*(\n( +.*\n|\n)+)?', Comment.Preproc),
753
+ # Field list
754
+ (r'^( *)(:[a-zA-Z-]+:)(\s*)$', bygroups(Text, Name.Class, Text)),
755
+ (r'^( *)(:.*?:)([ \t]+)(.*?)$',
756
+ bygroups(Text, Name.Class, Text, Name.Function)),
757
+ # Definition list
758
+ (r'^([^ ].*(?<!::)\n)((?:(?: +.*)\n)+)',
759
+ bygroups(using(this, state='inline'), using(this, state='inline'))),
760
+ # Code blocks
761
+ (r'(::)(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\3.*|)\n)+)',
762
+ bygroups(String.Escape, Text, String, String, Text, String)),
763
+ include('inline'),
764
+ ],
765
+ 'inline': [
766
+ (r'\\.', Text), # escape
767
+ (r'``', String, 'literal'), # code
768
+ (r'(`.+?)(<.+?>)(`__?)', # reference with inline target
769
+ bygroups(String, String.Interpol, String)),
770
+ (r'`.+?`__?', String), # reference
771
+ (r'(`.+?`)(:[a-zA-Z0-9:-]+?:)?',
772
+ bygroups(Name.Variable, Name.Attribute)), # role
773
+ (r'(:[a-zA-Z0-9:-]+?:)(`.+?`)',
774
+ bygroups(Name.Attribute, Name.Variable)), # role (content first)
775
+ (r'\*\*.+?\*\*', Generic.Strong), # Strong emphasis
776
+ (r'\*.+?\*', Generic.Emph), # Emphasis
777
+ (r'\[.*?\]_', String), # Footnote or citation
778
+ (r'<.+?>', Name.Tag), # Hyperlink
779
+ (r'[^\\\n\[*`:]+', Text),
780
+ (r'.', Text),
781
+ ],
782
+ 'literal': [
783
+ (r'[^`]+', String),
784
+ (r'``' + end_string_suffix, String, '#pop'),
785
+ (r'`', String),
786
+ ]
787
+ }
788
+
789
+ def __init__(self, **options):
790
+ self.handlecodeblocks = get_bool_opt(options, 'handlecodeblocks', True)
791
+ RegexLexer.__init__(self, **options)
792
+
793
+ def analyse_text(text):
794
+ if text[:2] == '..' and text[2:3] != '.':
795
+ return 0.3
796
+ p1 = text.find("\n")
797
+ p2 = text.find("\n", p1 + 1)
798
+ if (p2 > -1 and # has two lines
799
+ p1 * 2 + 1 == p2 and # they are the same length
800
+ text[p1+1] in '-=' and # the next line both starts and ends with
801
+ text[p1+1] == text[p2-1]): # ...a sufficiently high header
802
+ return 0.5
803
+
804
+
805
+ class VimLexer(RegexLexer):
806
+ """
807
+ Lexer for VimL script files.
808
+
809
+ *New in Pygments 0.8.*
810
+ """
811
+ name = 'VimL'
812
+ aliases = ['vim']
813
+ filenames = ['*.vim', '.vimrc', '.exrc', '.gvimrc',
814
+ '_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc']
815
+ mimetypes = ['text/x-vim']
816
+ flags = re.MULTILINE
817
+
818
+ tokens = {
819
+ 'root': [
820
+ (r'^\s*".*', Comment),
821
+
822
+ (r'[ \t]+', Text),
823
+ # TODO: regexes can have other delims
824
+ (r'/(\\\\|\\/|[^\n/])*/', String.Regex),
825
+ (r'"(\\\\|\\"|[^\n"])*"', String.Double),
826
+ (r"'(\\\\|\\'|[^\n'])*'", String.Single),
827
+
828
+ # Who decided that doublequote was a good comment character??
829
+ (r'(?<=\s)"[^\-:.%#=*].*', Comment),
830
+ (r'-?\d+', Number),
831
+ (r'#[0-9a-f]{6}', Number.Hex),
832
+ (r'^:', Punctuation),
833
+ (r'[()<>+=!|,~-]', Punctuation), # Inexact list. Looks decent.
834
+ (r'\b(let|if|else|endif|elseif|fun|function|endfunction)\b',
835
+ Keyword),
836
+ (r'\b(NONE|bold|italic|underline|dark|light)\b', Name.Builtin),
837
+ (r'\b\w+\b', Name.Other), # These are postprocessed below
838
+ (r'.', Text),
839
+ ],
840
+ }
841
+ def __init__(self, **options):
842
+ from pygments.lexers._vimbuiltins import command, option, auto
843
+ self._cmd = command
844
+ self._opt = option
845
+ self._aut = auto
846
+
847
+ RegexLexer.__init__(self, **options)
848
+
849
+ def is_in(self, w, mapping):
850
+ r"""
851
+ It's kind of difficult to decide if something might be a keyword
852
+ in VimL because it allows you to abbreviate them. In fact,
853
+ 'ab[breviate]' is a good example. :ab, :abbre, or :abbreviate are
854
+ valid ways to call it so rather than making really awful regexps
855
+ like::
856
+
857
+ \bab(?:b(?:r(?:e(?:v(?:i(?:a(?:t(?:e)?)?)?)?)?)?)?)?\b
858
+
859
+ we match `\b\w+\b` and then call is_in() on those tokens. See
860
+ `scripts/get_vimkw.py` for how the lists are extracted.
861
+ """
862
+ p = bisect(mapping, (w,))
863
+ if p > 0:
864
+ if mapping[p-1][0] == w[:len(mapping[p-1][0])] and \
865
+ mapping[p-1][1][:len(w)] == w: return True
866
+ if p < len(mapping):
867
+ return mapping[p][0] == w[:len(mapping[p][0])] and \
868
+ mapping[p][1][:len(w)] == w
869
+ return False
870
+
871
+ def get_tokens_unprocessed(self, text):
872
+ # TODO: builtins are only subsequent tokens on lines
873
+ # and 'keywords' only happen at the beginning except
874
+ # for :au ones
875
+ for index, token, value in \
876
+ RegexLexer.get_tokens_unprocessed(self, text):
877
+ if token is Name.Other:
878
+ if self.is_in(value, self._cmd):
879
+ yield index, Keyword, value
880
+ elif self.is_in(value, self._opt) or \
881
+ self.is_in(value, self._aut):
882
+ yield index, Name.Builtin, value
883
+ else:
884
+ yield index, Text, value
885
+ else:
886
+ yield index, token, value
887
+
888
+
889
+ class GettextLexer(RegexLexer):
890
+ """
891
+ Lexer for Gettext catalog files.
892
+
893
+ *New in Pygments 0.9.*
894
+ """
895
+ name = 'Gettext Catalog'
896
+ aliases = ['pot', 'po']
897
+ filenames = ['*.pot', '*.po']
898
+ mimetypes = ['application/x-gettext', 'text/x-gettext', 'text/gettext']
899
+
900
+ tokens = {
901
+ 'root': [
902
+ (r'^#,\s.*?$', Keyword.Type),
903
+ (r'^#:\s.*?$', Keyword.Declaration),
904
+ #(r'^#$', Comment),
905
+ (r'^(#|#\.\s|#\|\s|#~\s|#\s).*$', Comment.Single),
906
+ (r'^(")([A-Za-z-]+:)(.*")$',
907
+ bygroups(String, Name.Property, String)),
908
+ (r'^".*"$', String),
909
+ (r'^(msgid|msgid_plural|msgstr)(\s+)(".*")$',
910
+ bygroups(Name.Variable, Text, String)),
911
+ (r'^(msgstr\[)(\d)(\])(\s+)(".*")$',
912
+ bygroups(Name.Variable, Number.Integer, Name.Variable, Text, String)),
913
+ ]
914
+ }
915
+
916
+
917
+ class SquidConfLexer(RegexLexer):
918
+ """
919
+ Lexer for `squid <http://www.squid-cache.org/>`_ configuration files.
920
+
921
+ *New in Pygments 0.9.*
922
+ """
923
+
924
+ name = 'SquidConf'
925
+ aliases = ['squidconf', 'squid.conf', 'squid']
926
+ filenames = ['squid.conf']
927
+ mimetypes = ['text/x-squidconf']
928
+ flags = re.IGNORECASE
929
+
930
+ keywords = [
931
+ "access_log", "acl", "always_direct", "announce_host",
932
+ "announce_period", "announce_port", "announce_to", "anonymize_headers",
933
+ "append_domain", "as_whois_server", "auth_param_basic",
934
+ "authenticate_children", "authenticate_program", "authenticate_ttl",
935
+ "broken_posts", "buffered_logs", "cache_access_log", "cache_announce",
936
+ "cache_dir", "cache_dns_program", "cache_effective_group",
937
+ "cache_effective_user", "cache_host", "cache_host_acl",
938
+ "cache_host_domain", "cache_log", "cache_mem", "cache_mem_high",
939
+ "cache_mem_low", "cache_mgr", "cachemgr_passwd", "cache_peer",
940
+ "cache_peer_access", "cahce_replacement_policy", "cache_stoplist",
941
+ "cache_stoplist_pattern", "cache_store_log", "cache_swap",
942
+ "cache_swap_high", "cache_swap_log", "cache_swap_low", "client_db",
943
+ "client_lifetime", "client_netmask", "connect_timeout", "coredump_dir",
944
+ "dead_peer_timeout", "debug_options", "delay_access", "delay_class",
945
+ "delay_initial_bucket_level", "delay_parameters", "delay_pools",
946
+ "deny_info", "dns_children", "dns_defnames", "dns_nameservers",
947
+ "dns_testnames", "emulate_httpd_log", "err_html_text",
948
+ "fake_user_agent", "firewall_ip", "forwarded_for", "forward_snmpd_port",
949
+ "fqdncache_size", "ftpget_options", "ftpget_program", "ftp_list_width",
950
+ "ftp_passive", "ftp_user", "half_closed_clients", "header_access",
951
+ "header_replace", "hierarchy_stoplist", "high_response_time_warning",
952
+ "high_page_fault_warning", "hosts_file", "htcp_port", "http_access",
953
+ "http_anonymizer", "httpd_accel", "httpd_accel_host",
954
+ "httpd_accel_port", "httpd_accel_uses_host_header",
955
+ "httpd_accel_with_proxy", "http_port", "http_reply_access",
956
+ "icp_access", "icp_hit_stale", "icp_port", "icp_query_timeout",
957
+ "ident_lookup", "ident_lookup_access", "ident_timeout",
958
+ "incoming_http_average", "incoming_icp_average", "inside_firewall",
959
+ "ipcache_high", "ipcache_low", "ipcache_size", "local_domain",
960
+ "local_ip", "logfile_rotate", "log_fqdn", "log_icp_queries",
961
+ "log_mime_hdrs", "maximum_object_size", "maximum_single_addr_tries",
962
+ "mcast_groups", "mcast_icp_query_timeout", "mcast_miss_addr",
963
+ "mcast_miss_encode_key", "mcast_miss_port", "memory_pools",
964
+ "memory_pools_limit", "memory_replacement_policy", "mime_table",
965
+ "min_http_poll_cnt", "min_icp_poll_cnt", "minimum_direct_hops",
966
+ "minimum_object_size", "minimum_retry_timeout", "miss_access",
967
+ "negative_dns_ttl", "negative_ttl", "neighbor_timeout",
968
+ "neighbor_type_domain", "netdb_high", "netdb_low", "netdb_ping_period",
969
+ "netdb_ping_rate", "never_direct", "no_cache", "passthrough_proxy",
970
+ "pconn_timeout", "pid_filename", "pinger_program", "positive_dns_ttl",
971
+ "prefer_direct", "proxy_auth", "proxy_auth_realm", "query_icmp",
972
+ "quick_abort", "quick_abort", "quick_abort_max", "quick_abort_min",
973
+ "quick_abort_pct", "range_offset_limit", "read_timeout",
974
+ "redirect_children", "redirect_program",
975
+ "redirect_rewrites_host_header", "reference_age", "reference_age",
976
+ "refresh_pattern", "reload_into_ims", "request_body_max_size",
977
+ "request_size", "request_timeout", "shutdown_lifetime",
978
+ "single_parent_bypass", "siteselect_timeout", "snmp_access",
979
+ "snmp_incoming_address", "snmp_port", "source_ping", "ssl_proxy",
980
+ "store_avg_object_size", "store_objects_per_bucket",
981
+ "strip_query_terms", "swap_level1_dirs", "swap_level2_dirs",
982
+ "tcp_incoming_address", "tcp_outgoing_address", "tcp_recv_bufsize",
983
+ "test_reachability", "udp_hit_obj", "udp_hit_obj_size",
984
+ "udp_incoming_address", "udp_outgoing_address", "unique_hostname",
985
+ "unlinkd_program", "uri_whitespace", "useragent_log",
986
+ "visible_hostname", "wais_relay", "wais_relay_host", "wais_relay_port",
987
+ ]
988
+
989
+ opts = [
990
+ "proxy-only", "weight", "ttl", "no-query", "default", "round-robin",
991
+ "multicast-responder", "on", "off", "all", "deny", "allow", "via",
992
+ "parent", "no-digest", "heap", "lru", "realm", "children", "q1", "q2",
993
+ "credentialsttl", "none", "disable", "offline_toggle", "diskd",
994
+ ]
995
+
996
+ actions = [
997
+ "shutdown", "info", "parameter", "server_list", "client_list",
998
+ r'squid\.conf',
999
+ ]
1000
+
1001
+ actions_stats = [
1002
+ "objects", "vm_objects", "utilization", "ipcache", "fqdncache", "dns",
1003
+ "redirector", "io", "reply_headers", "filedescriptors", "netdb",
1004
+ ]
1005
+
1006
+ actions_log = ["status", "enable", "disable", "clear"]
1007
+
1008
+ acls = [
1009
+ "url_regex", "urlpath_regex", "referer_regex", "port", "proto",
1010
+ "req_mime_type", "rep_mime_type", "method", "browser", "user", "src",
1011
+ "dst", "time", "dstdomain", "ident", "snmp_community",
1012
+ ]
1013
+
1014
+ ip_re = (
1015
+ r'(?:(?:(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|0x0*[0-9a-f]{1,2}|'
1016
+ r'0+[1-3]?[0-7]{0,2})(?:\.(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|'
1017
+ r'0x0*[0-9a-f]{1,2}|0+[1-3]?[0-7]{0,2})){3})|(?!.*::.*::)(?:(?!:)|'
1018
+ r':(?=:))(?:[0-9a-f]{0,4}(?:(?<=::)|(?<!::):)){6}(?:[0-9a-f]{0,4}'
1019
+ r'(?:(?<=::)|(?<!::):)[0-9a-f]{0,4}(?:(?<=::)|(?<!:)|(?<=:)(?<!::):)|'
1020
+ r'(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-4]|2[0-4]\d|1\d\d|'
1021
+ r'[1-9]?\d)){3}))'
1022
+ )
1023
+
1024
+ def makelistre(list):
1025
+ return r'\b(?:' + '|'.join(list) + r')\b'
1026
+
1027
+ tokens = {
1028
+ 'root': [
1029
+ (r'\s+', Whitespace),
1030
+ (r'#', Comment, 'comment'),
1031
+ (makelistre(keywords), Keyword),
1032
+ (makelistre(opts), Name.Constant),
1033
+ # Actions
1034
+ (makelistre(actions), String),
1035
+ (r'stats/'+makelistre(actions), String),
1036
+ (r'log/'+makelistre(actions)+r'=', String),
1037
+ (makelistre(acls), Keyword),
1038
+ (ip_re + r'(?:/(?:' + ip_re + r'|\b\d+\b))?', Number.Float),
1039
+ (r'(?:\b\d+\b(?:-\b\d+|%)?)', Number),
1040
+ (r'\S+', Text),
1041
+ ],
1042
+ 'comment': [
1043
+ (r'\s*TAG:.*', String.Escape, '#pop'),
1044
+ (r'.*', Comment, '#pop'),
1045
+ ],
1046
+ }
1047
+
1048
+
1049
+ class DebianControlLexer(RegexLexer):
1050
+ """
1051
+ Lexer for Debian ``control`` files and ``apt-cache show <pkg>`` outputs.
1052
+
1053
+ *New in Pygments 0.9.*
1054
+ """
1055
+ name = 'Debian Control file'
1056
+ aliases = ['control', 'debcontrol']
1057
+ filenames = ['control']
1058
+
1059
+ tokens = {
1060
+ 'root': [
1061
+ (r'^(Description)', Keyword, 'description'),
1062
+ (r'^(Maintainer)(:\s*)', bygroups(Keyword, Text), 'maintainer'),
1063
+ (r'^((Build-)?Depends)', Keyword, 'depends'),
1064
+ (r'^((?:Python-)?Version)(:\s*)(\S+)$',
1065
+ bygroups(Keyword, Text, Number)),
1066
+ (r'^((?:Installed-)?Size)(:\s*)(\S+)$',
1067
+ bygroups(Keyword, Text, Number)),
1068
+ (r'^(MD5Sum|SHA1|SHA256)(:\s*)(\S+)$',
1069
+ bygroups(Keyword, Text, Number)),
1070
+ (r'^([a-zA-Z\-0-9\.]*?)(:\s*)(.*?)$',
1071
+ bygroups(Keyword, Whitespace, String)),
1072
+ ],
1073
+ 'maintainer': [
1074
+ (r'<[^>]+>', Generic.Strong),
1075
+ (r'<[^>]+>$', Generic.Strong, '#pop'),
1076
+ (r',\n?', Text),
1077
+ (r'.', Text),
1078
+ ],
1079
+ 'description': [
1080
+ (r'(.*)(Homepage)(: )(\S+)',
1081
+ bygroups(Text, String, Name, Name.Class)),
1082
+ (r':.*\n', Generic.Strong),
1083
+ (r' .*\n', Text),
1084
+ ('', Text, '#pop'),
1085
+ ],
1086
+ 'depends': [
1087
+ (r':\s*', Text),
1088
+ (r'(\$)(\{)(\w+\s*:\s*\w+)', bygroups(Operator, Text, Name.Entity)),
1089
+ (r'\(', Text, 'depend_vers'),
1090
+ (r',', Text),
1091
+ (r'\|', Operator),
1092
+ (r'[\s]+', Text),
1093
+ (r'[}\)]\s*$', Text, '#pop'),
1094
+ (r'}', Text),
1095
+ (r'[^,]$', Name.Function, '#pop'),
1096
+ (r'([\+\.a-zA-Z0-9-])(\s*)', bygroups(Name.Function, Text)),
1097
+ (r'\[.*?\]', Name.Entity),
1098
+ ],
1099
+ 'depend_vers': [
1100
+ (r'\),', Text, '#pop'),
1101
+ (r'\)[^,]', Text, '#pop:2'),
1102
+ (r'([><=]+)(\s*)([^\)]+)', bygroups(Operator, Text, Number))
1103
+ ]
1104
+ }
1105
+
1106
+
1107
+ class YamlLexerContext(LexerContext):
1108
+ """Indentation context for the YAML lexer."""
1109
+
1110
+ def __init__(self, *args, **kwds):
1111
+ super(YamlLexerContext, self).__init__(*args, **kwds)
1112
+ self.indent_stack = []
1113
+ self.indent = -1
1114
+ self.next_indent = 0
1115
+ self.block_scalar_indent = None
1116
+
1117
+
1118
+ class YamlLexer(ExtendedRegexLexer):
1119
+ """
1120
+ Lexer for `YAML <http://yaml.org/>`_, a human-friendly data serialization
1121
+ language.
1122
+
1123
+ *New in Pygments 0.11.*
1124
+ """
1125
+
1126
+ name = 'YAML'
1127
+ aliases = ['yaml']
1128
+ filenames = ['*.yaml', '*.yml']
1129
+ mimetypes = ['text/x-yaml']
1130
+
1131
+
1132
+ def something(token_class):
1133
+ """Do not produce empty tokens."""
1134
+ def callback(lexer, match, context):
1135
+ text = match.group()
1136
+ if not text:
1137
+ return
1138
+ yield match.start(), token_class, text
1139
+ context.pos = match.end()
1140
+ return callback
1141
+
1142
+ def reset_indent(token_class):
1143
+ """Reset the indentation levels."""
1144
+ def callback(lexer, match, context):
1145
+ text = match.group()
1146
+ context.indent_stack = []
1147
+ context.indent = -1
1148
+ context.next_indent = 0
1149
+ context.block_scalar_indent = None
1150
+ yield match.start(), token_class, text
1151
+ context.pos = match.end()
1152
+ return callback
1153
+
1154
+ def save_indent(token_class, start=False):
1155
+ """Save a possible indentation level."""
1156
+ def callback(lexer, match, context):
1157
+ text = match.group()
1158
+ extra = ''
1159
+ if start:
1160
+ context.next_indent = len(text)
1161
+ if context.next_indent < context.indent:
1162
+ while context.next_indent < context.indent:
1163
+ context.indent = context.indent_stack.pop()
1164
+ if context.next_indent > context.indent:
1165
+ extra = text[context.indent:]
1166
+ text = text[:context.indent]
1167
+ else:
1168
+ context.next_indent += len(text)
1169
+ if text:
1170
+ yield match.start(), token_class, text
1171
+ if extra:
1172
+ yield match.start()+len(text), token_class.Error, extra
1173
+ context.pos = match.end()
1174
+ return callback
1175
+
1176
+ def set_indent(token_class, implicit=False):
1177
+ """Set the previously saved indentation level."""
1178
+ def callback(lexer, match, context):
1179
+ text = match.group()
1180
+ if context.indent < context.next_indent:
1181
+ context.indent_stack.append(context.indent)
1182
+ context.indent = context.next_indent
1183
+ if not implicit:
1184
+ context.next_indent += len(text)
1185
+ yield match.start(), token_class, text
1186
+ context.pos = match.end()
1187
+ return callback
1188
+
1189
+ def set_block_scalar_indent(token_class):
1190
+ """Set an explicit indentation level for a block scalar."""
1191
+ def callback(lexer, match, context):
1192
+ text = match.group()
1193
+ context.block_scalar_indent = None
1194
+ if not text:
1195
+ return
1196
+ increment = match.group(1)
1197
+ if increment:
1198
+ current_indent = max(context.indent, 0)
1199
+ increment = int(increment)
1200
+ context.block_scalar_indent = current_indent + increment
1201
+ if text:
1202
+ yield match.start(), token_class, text
1203
+ context.pos = match.end()
1204
+ return callback
1205
+
1206
+ def parse_block_scalar_empty_line(indent_token_class, content_token_class):
1207
+ """Process an empty line in a block scalar."""
1208
+ def callback(lexer, match, context):
1209
+ text = match.group()
1210
+ if (context.block_scalar_indent is None or
1211
+ len(text) <= context.block_scalar_indent):
1212
+ if text:
1213
+ yield match.start(), indent_token_class, text
1214
+ else:
1215
+ indentation = text[:context.block_scalar_indent]
1216
+ content = text[context.block_scalar_indent:]
1217
+ yield match.start(), indent_token_class, indentation
1218
+ yield (match.start()+context.block_scalar_indent,
1219
+ content_token_class, content)
1220
+ context.pos = match.end()
1221
+ return callback
1222
+
1223
+ def parse_block_scalar_indent(token_class):
1224
+ """Process indentation spaces in a block scalar."""
1225
+ def callback(lexer, match, context):
1226
+ text = match.group()
1227
+ if context.block_scalar_indent is None:
1228
+ if len(text) <= max(context.indent, 0):
1229
+ context.stack.pop()
1230
+ context.stack.pop()
1231
+ return
1232
+ context.block_scalar_indent = len(text)
1233
+ else:
1234
+ if len(text) < context.block_scalar_indent:
1235
+ context.stack.pop()
1236
+ context.stack.pop()
1237
+ return
1238
+ if text:
1239
+ yield match.start(), token_class, text
1240
+ context.pos = match.end()
1241
+ return callback
1242
+
1243
+ def parse_plain_scalar_indent(token_class):
1244
+ """Process indentation spaces in a plain scalar."""
1245
+ def callback(lexer, match, context):
1246
+ text = match.group()
1247
+ if len(text) <= context.indent:
1248
+ context.stack.pop()
1249
+ context.stack.pop()
1250
+ return
1251
+ if text:
1252
+ yield match.start(), token_class, text
1253
+ context.pos = match.end()
1254
+ return callback
1255
+
1256
+
1257
+
1258
+ tokens = {
1259
+ # the root rules
1260
+ 'root': [
1261
+ # ignored whitespaces
1262
+ (r'[ ]+(?=#|$)', Text),
1263
+ # line breaks
1264
+ (r'\n+', Text),
1265
+ # a comment
1266
+ (r'#[^\n]*', Comment.Single),
1267
+ # the '%YAML' directive
1268
+ (r'^%YAML(?=[ ]|$)', reset_indent(Name.Tag), 'yaml-directive'),
1269
+ # the %TAG directive
1270
+ (r'^%TAG(?=[ ]|$)', reset_indent(Name.Tag), 'tag-directive'),
1271
+ # document start and document end indicators
1272
+ (r'^(?:---|\.\.\.)(?=[ ]|$)', reset_indent(Name.Namespace),
1273
+ 'block-line'),
1274
+ # indentation spaces
1275
+ (r'[ ]*(?![ \t\n\r\f\v]|$)', save_indent(Text, start=True),
1276
+ ('block-line', 'indentation')),
1277
+ ],
1278
+
1279
+ # trailing whitespaces after directives or a block scalar indicator
1280
+ 'ignored-line': [
1281
+ # ignored whitespaces
1282
+ (r'[ ]+(?=#|$)', Text),
1283
+ # a comment
1284
+ (r'#[^\n]*', Comment.Single),
1285
+ # line break
1286
+ (r'\n', Text, '#pop:2'),
1287
+ ],
1288
+
1289
+ # the %YAML directive
1290
+ 'yaml-directive': [
1291
+ # the version number
1292
+ (r'([ ]+)([0-9]+\.[0-9]+)',
1293
+ bygroups(Text, Number), 'ignored-line'),
1294
+ ],
1295
+
1296
+ # the %YAG directive
1297
+ 'tag-directive': [
1298
+ # a tag handle and the corresponding prefix
1299
+ (r'([ ]+)(!|![0-9A-Za-z_-]*!)'
1300
+ r'([ ]+)(!|!?[0-9A-Za-z;/?:@&=+$,_.!~*\'()\[\]%-]+)',
1301
+ bygroups(Text, Keyword.Type, Text, Keyword.Type),
1302
+ 'ignored-line'),
1303
+ ],
1304
+
1305
+ # block scalar indicators and indentation spaces
1306
+ 'indentation': [
1307
+ # trailing whitespaces are ignored
1308
+ (r'[ ]*$', something(Text), '#pop:2'),
1309
+ # whitespaces preceeding block collection indicators
1310
+ (r'[ ]+(?=[?:-](?:[ ]|$))', save_indent(Text)),
1311
+ # block collection indicators
1312
+ (r'[?:-](?=[ ]|$)', set_indent(Punctuation.Indicator)),
1313
+ # the beginning a block line
1314
+ (r'[ ]*', save_indent(Text), '#pop'),
1315
+ ],
1316
+
1317
+ # an indented line in the block context
1318
+ 'block-line': [
1319
+ # the line end
1320
+ (r'[ ]*(?=#|$)', something(Text), '#pop'),
1321
+ # whitespaces separating tokens
1322
+ (r'[ ]+', Text),
1323
+ # tags, anchors and aliases,
1324
+ include('descriptors'),
1325
+ # block collections and scalars
1326
+ include('block-nodes'),
1327
+ # flow collections and quoted scalars
1328
+ include('flow-nodes'),
1329
+ # a plain scalar
1330
+ (r'(?=[^ \t\n\r\f\v?:,\[\]{}#&*!|>\'"%@`-]|[?:-][^ \t\n\r\f\v])',
1331
+ something(Name.Variable),
1332
+ 'plain-scalar-in-block-context'),
1333
+ ],
1334
+
1335
+ # tags, anchors, aliases
1336
+ 'descriptors' : [
1337
+ # a full-form tag
1338
+ (r'!<[0-9A-Za-z;/?:@&=+$,_.!~*\'()\[\]%-]+>', Keyword.Type),
1339
+ # a tag in the form '!', '!suffix' or '!handle!suffix'
1340
+ (r'!(?:[0-9A-Za-z_-]+)?'
1341
+ r'(?:![0-9A-Za-z;/?:@&=+$,_.!~*\'()\[\]%-]+)?', Keyword.Type),
1342
+ # an anchor
1343
+ (r'&[0-9A-Za-z_-]+', Name.Label),
1344
+ # an alias
1345
+ (r'\*[0-9A-Za-z_-]+', Name.Variable),
1346
+ ],
1347
+
1348
+ # block collections and scalars
1349
+ 'block-nodes': [
1350
+ # implicit key
1351
+ (r':(?=[ ]|$)', set_indent(Punctuation.Indicator, implicit=True)),
1352
+ # literal and folded scalars
1353
+ (r'[|>]', Punctuation.Indicator,
1354
+ ('block-scalar-content', 'block-scalar-header')),
1355
+ ],
1356
+
1357
+ # flow collections and quoted scalars
1358
+ 'flow-nodes': [
1359
+ # a flow sequence
1360
+ (r'\[', Punctuation.Indicator, 'flow-sequence'),
1361
+ # a flow mapping
1362
+ (r'\{', Punctuation.Indicator, 'flow-mapping'),
1363
+ # a single-quoted scalar
1364
+ (r'\'', String, 'single-quoted-scalar'),
1365
+ # a double-quoted scalar
1366
+ (r'\"', String, 'double-quoted-scalar'),
1367
+ ],
1368
+
1369
+ # the content of a flow collection
1370
+ 'flow-collection': [
1371
+ # whitespaces
1372
+ (r'[ ]+', Text),
1373
+ # line breaks
1374
+ (r'\n+', Text),
1375
+ # a comment
1376
+ (r'#[^\n]*', Comment.Single),
1377
+ # simple indicators
1378
+ (r'[?:,]', Punctuation.Indicator),
1379
+ # tags, anchors and aliases
1380
+ include('descriptors'),
1381
+ # nested collections and quoted scalars
1382
+ include('flow-nodes'),
1383
+ # a plain scalar
1384
+ (r'(?=[^ \t\n\r\f\v?:,\[\]{}#&*!|>\'"%@`])',
1385
+ something(Name.Variable),
1386
+ 'plain-scalar-in-flow-context'),
1387
+ ],
1388
+
1389
+ # a flow sequence indicated by '[' and ']'
1390
+ 'flow-sequence': [
1391
+ # include flow collection rules
1392
+ include('flow-collection'),
1393
+ # the closing indicator
1394
+ (r'\]', Punctuation.Indicator, '#pop'),
1395
+ ],
1396
+
1397
+ # a flow mapping indicated by '{' and '}'
1398
+ 'flow-mapping': [
1399
+ # include flow collection rules
1400
+ include('flow-collection'),
1401
+ # the closing indicator
1402
+ (r'\}', Punctuation.Indicator, '#pop'),
1403
+ ],
1404
+
1405
+ # block scalar lines
1406
+ 'block-scalar-content': [
1407
+ # line break
1408
+ (r'\n', Text),
1409
+ # empty line
1410
+ (r'^[ ]+$',
1411
+ parse_block_scalar_empty_line(Text, Name.Constant)),
1412
+ # indentation spaces (we may leave the state here)
1413
+ (r'^[ ]*', parse_block_scalar_indent(Text)),
1414
+ # line content
1415
+ (r'[^\n\r\f\v]+', Name.Constant),
1416
+ ],
1417
+
1418
+ # the content of a literal or folded scalar
1419
+ 'block-scalar-header': [
1420
+ # indentation indicator followed by chomping flag
1421
+ (r'([1-9])?[+-]?(?=[ ]|$)',
1422
+ set_block_scalar_indent(Punctuation.Indicator),
1423
+ 'ignored-line'),
1424
+ # chomping flag followed by indentation indicator
1425
+ (r'[+-]?([1-9])?(?=[ ]|$)',
1426
+ set_block_scalar_indent(Punctuation.Indicator),
1427
+ 'ignored-line'),
1428
+ ],
1429
+
1430
+ # ignored and regular whitespaces in quoted scalars
1431
+ 'quoted-scalar-whitespaces': [
1432
+ # leading and trailing whitespaces are ignored
1433
+ (r'^[ ]+', Text),
1434
+ (r'[ ]+$', Text),
1435
+ # line breaks are ignored
1436
+ (r'\n+', Text),
1437
+ # other whitespaces are a part of the value
1438
+ (r'[ ]+', Name.Variable),
1439
+ ],
1440
+
1441
+ # single-quoted scalars
1442
+ 'single-quoted-scalar': [
1443
+ # include whitespace and line break rules
1444
+ include('quoted-scalar-whitespaces'),
1445
+ # escaping of the quote character
1446
+ (r'\'\'', String.Escape),
1447
+ # regular non-whitespace characters
1448
+ (r'[^ \t\n\r\f\v\']+', String),
1449
+ # the closing quote
1450
+ (r'\'', String, '#pop'),
1451
+ ],
1452
+
1453
+ # double-quoted scalars
1454
+ 'double-quoted-scalar': [
1455
+ # include whitespace and line break rules
1456
+ include('quoted-scalar-whitespaces'),
1457
+ # escaping of special characters
1458
+ (r'\\[0abt\tn\nvfre "\\N_LP]', String),
1459
+ # escape codes
1460
+ (r'\\(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})',
1461
+ String.Escape),
1462
+ # regular non-whitespace characters
1463
+ (r'[^ \t\n\r\f\v\"\\]+', String),
1464
+ # the closing quote
1465
+ (r'"', String, '#pop'),
1466
+ ],
1467
+
1468
+ # the beginning of a new line while scanning a plain scalar
1469
+ 'plain-scalar-in-block-context-new-line': [
1470
+ # empty lines
1471
+ (r'^[ ]+$', Text),
1472
+ # line breaks
1473
+ (r'\n+', Text),
1474
+ # document start and document end indicators
1475
+ (r'^(?=---|\.\.\.)', something(Name.Namespace), '#pop:3'),
1476
+ # indentation spaces (we may leave the block line state here)
1477
+ (r'^[ ]*', parse_plain_scalar_indent(Text), '#pop'),
1478
+ ],
1479
+
1480
+ # a plain scalar in the block context
1481
+ 'plain-scalar-in-block-context': [
1482
+ # the scalar ends with the ':' indicator
1483
+ (r'[ ]*(?=:[ ]|:$)', something(Text), '#pop'),
1484
+ # the scalar ends with whitespaces followed by a comment
1485
+ (r'[ ]+(?=#)', Text, '#pop'),
1486
+ # trailing whitespaces are ignored
1487
+ (r'[ ]+$', Text),
1488
+ # line breaks are ignored
1489
+ (r'\n+', Text, 'plain-scalar-in-block-context-new-line'),
1490
+ # other whitespaces are a part of the value
1491
+ (r'[ ]+', Literal.Scalar.Plain),
1492
+ # regular non-whitespace characters
1493
+ (r'(?::(?![ \t\n\r\f\v])|[^ \t\n\r\f\v:])+', Literal.Scalar.Plain),
1494
+ ],
1495
+
1496
+ # a plain scalar is the flow context
1497
+ 'plain-scalar-in-flow-context': [
1498
+ # the scalar ends with an indicator character
1499
+ (r'[ ]*(?=[,:?\[\]{}])', something(Text), '#pop'),
1500
+ # the scalar ends with a comment
1501
+ (r'[ ]+(?=#)', Text, '#pop'),
1502
+ # leading and trailing whitespaces are ignored
1503
+ (r'^[ ]+', Text),
1504
+ (r'[ ]+$', Text),
1505
+ # line breaks are ignored
1506
+ (r'\n+', Text),
1507
+ # other whitespaces are a part of the value
1508
+ (r'[ ]+', Name.Variable),
1509
+ # regular non-whitespace characters
1510
+ (r'[^ \t\n\r\f\v,:?\[\]{}]+', Name.Variable),
1511
+ ],
1512
+
1513
+ }
1514
+
1515
+ def get_tokens_unprocessed(self, text=None, context=None):
1516
+ if context is None:
1517
+ context = YamlLexerContext(text, 0)
1518
+ return super(YamlLexer, self).get_tokens_unprocessed(text, context)
1519
+
1520
+
1521
+ class LighttpdConfLexer(RegexLexer):
1522
+ """
1523
+ Lexer for `Lighttpd <http://lighttpd.net/>`_ configuration files.
1524
+
1525
+ *New in Pygments 0.11.*
1526
+ """
1527
+ name = 'Lighttpd configuration file'
1528
+ aliases = ['lighty', 'lighttpd']
1529
+ filenames = []
1530
+ mimetypes = ['text/x-lighttpd-conf']
1531
+
1532
+ tokens = {
1533
+ 'root': [
1534
+ (r'#.*\n', Comment.Single),
1535
+ (r'/\S*', Name), # pathname
1536
+ (r'[a-zA-Z._-]+', Keyword),
1537
+ (r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number),
1538
+ (r'[0-9]+', Number),
1539
+ (r'=>|=~|\+=|==|=|\+', Operator),
1540
+ (r'\$[A-Z]+', Name.Builtin),
1541
+ (r'[(){}\[\],]', Punctuation),
1542
+ (r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double),
1543
+ (r'\s+', Text),
1544
+ ],
1545
+
1546
+ }
1547
+
1548
+
1549
+ class NginxConfLexer(RegexLexer):
1550
+ """
1551
+ Lexer for `Nginx <http://nginx.net/>`_ configuration files.
1552
+
1553
+ *New in Pygments 0.11.*
1554
+ """
1555
+ name = 'Nginx configuration file'
1556
+ aliases = ['nginx']
1557
+ filenames = []
1558
+ mimetypes = ['text/x-nginx-conf']
1559
+
1560
+ tokens = {
1561
+ 'root': [
1562
+ (r'(include)(\s+)([^\s;]+)', bygroups(Keyword, Text, Name)),
1563
+ (r'[^\s;#]+', Keyword, 'stmt'),
1564
+ include('base'),
1565
+ ],
1566
+ 'block': [
1567
+ (r'}', Punctuation, '#pop:2'),
1568
+ (r'[^\s;#]+', Keyword.Namespace, 'stmt'),
1569
+ include('base'),
1570
+ ],
1571
+ 'stmt': [
1572
+ (r'{', Punctuation, 'block'),
1573
+ (r';', Punctuation, '#pop'),
1574
+ include('base'),
1575
+ ],
1576
+ 'base': [
1577
+ (r'#.*\n', Comment.Single),
1578
+ (r'on|off', Name.Constant),
1579
+ (r'\$[^\s;#()]+', Name.Variable),
1580
+ (r'([a-z0-9.-]+)(:)([0-9]+)',
1581
+ bygroups(Name, Punctuation, Number.Integer)),
1582
+ (r'[a-z-]+/[a-z-+]+', String), # mimetype
1583
+ #(r'[a-zA-Z._-]+', Keyword),
1584
+ (r'[0-9]+[km]?\b', Number.Integer),
1585
+ (r'(~)(\s*)([^\s{]+)', bygroups(Punctuation, Text, String.Regex)),
1586
+ (r'[:=~]', Punctuation),
1587
+ (r'[^\s;#{}$]+', String), # catch all
1588
+ (r'/[^\s;#]*', Name), # pathname
1589
+ (r'\s+', Text),
1590
+ (r'[$;]', Text), # leftover characters
1591
+ ],
1592
+ }
1593
+
1594
+
1595
+ class CMakeLexer(RegexLexer):
1596
+ """
1597
+ Lexer for `CMake <http://cmake.org/Wiki/CMake>`_ files.
1598
+
1599
+ *New in Pygments 1.2.*
1600
+ """
1601
+ name = 'CMake'
1602
+ aliases = ['cmake']
1603
+ filenames = ['*.cmake', 'CMakeLists.txt']
1604
+ mimetypes = ['text/x-cmake']
1605
+
1606
+ tokens = {
1607
+ 'root': [
1608
+ #(r'(ADD_CUSTOM_COMMAND|ADD_CUSTOM_TARGET|ADD_DEFINITIONS|'
1609
+ # r'ADD_DEPENDENCIES|ADD_EXECUTABLE|ADD_LIBRARY|ADD_SUBDIRECTORY|'
1610
+ # r'ADD_TEST|AUX_SOURCE_DIRECTORY|BUILD_COMMAND|BUILD_NAME|'
1611
+ # r'CMAKE_MINIMUM_REQUIRED|CONFIGURE_FILE|CREATE_TEST_SOURCELIST|'
1612
+ # r'ELSE|ELSEIF|ENABLE_LANGUAGE|ENABLE_TESTING|ENDFOREACH|'
1613
+ # r'ENDFUNCTION|ENDIF|ENDMACRO|ENDWHILE|EXEC_PROGRAM|'
1614
+ # r'EXECUTE_PROCESS|EXPORT_LIBRARY_DEPENDENCIES|FILE|FIND_FILE|'
1615
+ # r'FIND_LIBRARY|FIND_PACKAGE|FIND_PATH|FIND_PROGRAM|FLTK_WRAP_UI|'
1616
+ # r'FOREACH|FUNCTION|GET_CMAKE_PROPERTY|GET_DIRECTORY_PROPERTY|'
1617
+ # r'GET_FILENAME_COMPONENT|GET_SOURCE_FILE_PROPERTY|'
1618
+ # r'GET_TARGET_PROPERTY|GET_TEST_PROPERTY|IF|INCLUDE|'
1619
+ # r'INCLUDE_DIRECTORIES|INCLUDE_EXTERNAL_MSPROJECT|'
1620
+ # r'INCLUDE_REGULAR_EXPRESSION|INSTALL|INSTALL_FILES|'
1621
+ # r'INSTALL_PROGRAMS|INSTALL_TARGETS|LINK_DIRECTORIES|'
1622
+ # r'LINK_LIBRARIES|LIST|LOAD_CACHE|LOAD_COMMAND|MACRO|'
1623
+ # r'MAKE_DIRECTORY|MARK_AS_ADVANCED|MATH|MESSAGE|OPTION|'
1624
+ # r'OUTPUT_REQUIRED_FILES|PROJECT|QT_WRAP_CPP|QT_WRAP_UI|REMOVE|'
1625
+ # r'REMOVE_DEFINITIONS|SEPARATE_ARGUMENTS|SET|'
1626
+ # r'SET_DIRECTORY_PROPERTIES|SET_SOURCE_FILES_PROPERTIES|'
1627
+ # r'SET_TARGET_PROPERTIES|SET_TESTS_PROPERTIES|SITE_NAME|'
1628
+ # r'SOURCE_GROUP|STRING|SUBDIR_DEPENDS|SUBDIRS|'
1629
+ # r'TARGET_LINK_LIBRARIES|TRY_COMPILE|TRY_RUN|UNSET|'
1630
+ # r'USE_MANGLED_MESA|UTILITY_SOURCE|VARIABLE_REQUIRES|'
1631
+ # r'VTK_MAKE_INSTANTIATOR|VTK_WRAP_JAVA|VTK_WRAP_PYTHON|'
1632
+ # r'VTK_WRAP_TCL|WHILE|WRITE_FILE|'
1633
+ # r'COUNTARGS)\b', Name.Builtin, 'args'),
1634
+ (r'\b(\w+)([ \t]*)(\()', bygroups(Name.Builtin, Text,
1635
+ Punctuation), 'args'),
1636
+ include('keywords'),
1637
+ include('ws')
1638
+ ],
1639
+ 'args': [
1640
+ (r'\(', Punctuation, '#push'),
1641
+ (r'\)', Punctuation, '#pop'),
1642
+ (r'(\${)(.+?)(})', bygroups(Operator, Name.Variable, Operator)),
1643
+ (r'(?s)".*?"', String.Double),
1644
+ (r'\\\S+', String),
1645
+ (r'[^\)$"# \t\n]+', String),
1646
+ (r'\n', Text), # explicitly legal
1647
+ include('keywords'),
1648
+ include('ws')
1649
+ ],
1650
+ 'string': [
1651
+
1652
+ ],
1653
+ 'keywords': [
1654
+ (r'\b(WIN32|UNIX|APPLE|CYGWIN|BORLAND|MINGW|MSVC|MSVC_IDE|MSVC60|'
1655
+ r'MSVC70|MSVC71|MSVC80|MSVC90)\b', Keyword),
1656
+ ],
1657
+ 'ws': [
1658
+ (r'[ \t]+', Text),
1659
+ (r'#.+\n', Comment),
1660
+ ]
1661
+ }
1662
+
1663
+
1664
+ class HttpLexer(RegexLexer):
1665
+ """
1666
+ Lexer for HTTP sessions.
1667
+
1668
+ *New in Pygments 1.5.*
1669
+ """
1670
+
1671
+ name = 'HTTP'
1672
+ aliases = ['http']
1673
+
1674
+ flags = re.DOTALL
1675
+
1676
+ def header_callback(self, match):
1677
+ if match.group(1).lower() == 'content-type':
1678
+ content_type = match.group(5).strip()
1679
+ if ';' in content_type:
1680
+ content_type = content_type[:content_type.find(';')].strip()
1681
+ self.content_type = content_type
1682
+ yield match.start(1), Name.Attribute, match.group(1)
1683
+ yield match.start(2), Text, match.group(2)
1684
+ yield match.start(3), Operator, match.group(3)
1685
+ yield match.start(4), Text, match.group(4)
1686
+ yield match.start(5), Literal, match.group(5)
1687
+ yield match.start(6), Text, match.group(6)
1688
+
1689
+ def continuous_header_callback(self, match):
1690
+ yield match.start(1), Text, match.group(1)
1691
+ yield match.start(2), Literal, match.group(2)
1692
+ yield match.start(3), Text, match.group(3)
1693
+
1694
+ def content_callback(self, match):
1695
+ content_type = getattr(self, 'content_type', None)
1696
+ content = match.group()
1697
+ offset = match.start()
1698
+ if content_type:
1699
+ from pygments.lexers import get_lexer_for_mimetype
1700
+ try:
1701
+ lexer = get_lexer_for_mimetype(content_type)
1702
+ except ClassNotFound:
1703
+ pass
1704
+ else:
1705
+ for idx, token, value in lexer.get_tokens_unprocessed(content):
1706
+ yield offset + idx, token, value
1707
+ return
1708
+ yield offset, Text, content
1709
+
1710
+ tokens = {
1711
+ 'root': [
1712
+ (r'(GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE|PATCH)( +)([^ ]+)( +)'
1713
+ r'(HTTP)(/)(1\.[01])(\r?\n|$)',
1714
+ bygroups(Name.Function, Text, Name.Namespace, Text,
1715
+ Keyword.Reserved, Operator, Number, Text),
1716
+ 'headers'),
1717
+ (r'(HTTP)(/)(1\.[01])( +)(\d{3})( +)([^\r\n]+)(\r?\n|$)',
1718
+ bygroups(Keyword.Reserved, Operator, Number, Text, Number,
1719
+ Text, Name.Exception, Text),
1720
+ 'headers'),
1721
+ ],
1722
+ 'headers': [
1723
+ (r'([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)', header_callback),
1724
+ (r'([\t ]+)([^\r\n]+)(\r?\n|$)', continuous_header_callback),
1725
+ (r'\r?\n', Text, 'content')
1726
+ ],
1727
+ 'content': [
1728
+ (r'.+', content_callback)
1729
+ ]
1730
+ }
1731
+
1732
+
1733
+ class PyPyLogLexer(RegexLexer):
1734
+ """
1735
+ Lexer for PyPy log files.
1736
+
1737
+ *New in Pygments 1.5.*
1738
+ """
1739
+ name = "PyPy Log"
1740
+ aliases = ["pypylog", "pypy"]
1741
+ filenames = ["*.pypylog"]
1742
+ mimetypes = ['application/x-pypylog']
1743
+
1744
+ tokens = {
1745
+ "root": [
1746
+ (r"\[\w+\] {jit-log-.*?$", Keyword, "jit-log"),
1747
+ (r"\[\w+\] {jit-backend-counts$", Keyword, "jit-backend-counts"),
1748
+ include("extra-stuff"),
1749
+ ],
1750
+ "jit-log": [
1751
+ (r"\[\w+\] jit-log-.*?}$", Keyword, "#pop"),
1752
+ (r"^\+\d+: ", Comment),
1753
+ (r"--end of the loop--", Comment),
1754
+ (r"[ifp]\d+", Name),
1755
+ (r"ptr\d+", Name),
1756
+ (r"(\()(\w+(?:\.\w+)?)(\))",
1757
+ bygroups(Punctuation, Name.Builtin, Punctuation)),
1758
+ (r"[\[\]=,()]", Punctuation),
1759
+ (r"(\d+\.\d+|inf|-inf)", Number.Float),
1760
+ (r"-?\d+", Number.Integer),
1761
+ (r"'.*'", String),
1762
+ (r"(None|descr|ConstClass|ConstPtr|TargetToken)", Name),
1763
+ (r"<.*?>+", Name.Builtin),
1764
+ (r"(label|debug_merge_point|jump|finish)", Name.Class),
1765
+ (r"(int_add_ovf|int_add|int_sub_ovf|int_sub|int_mul_ovf|int_mul|"
1766
+ r"int_floordiv|int_mod|int_lshift|int_rshift|int_and|int_or|"
1767
+ r"int_xor|int_eq|int_ne|int_ge|int_gt|int_le|int_lt|int_is_zero|"
1768
+ r"int_is_true|"
1769
+ r"uint_floordiv|uint_ge|uint_lt|"
1770
+ r"float_add|float_sub|float_mul|float_truediv|float_neg|"
1771
+ r"float_eq|float_ne|float_ge|float_gt|float_le|float_lt|float_abs|"
1772
+ r"ptr_eq|ptr_ne|instance_ptr_eq|instance_ptr_ne|"
1773
+ r"cast_int_to_float|cast_float_to_int|"
1774
+ r"force_token|quasiimmut_field|same_as|virtual_ref_finish|"
1775
+ r"virtual_ref|mark_opaque_ptr|"
1776
+ r"call_may_force|call_assembler|call_loopinvariant|"
1777
+ r"call_release_gil|call_pure|call|"
1778
+ r"new_with_vtable|new_array|newstr|newunicode|new|"
1779
+ r"arraylen_gc|"
1780
+ r"getarrayitem_gc_pure|getarrayitem_gc|setarrayitem_gc|"
1781
+ r"getarrayitem_raw|setarrayitem_raw|getfield_gc_pure|"
1782
+ r"getfield_gc|getinteriorfield_gc|setinteriorfield_gc|"
1783
+ r"getfield_raw|setfield_gc|setfield_raw|"
1784
+ r"strgetitem|strsetitem|strlen|copystrcontent|"
1785
+ r"unicodegetitem|unicodesetitem|unicodelen|"
1786
+ r"guard_true|guard_false|guard_value|guard_isnull|"
1787
+ r"guard_nonnull_class|guard_nonnull|guard_class|guard_no_overflow|"
1788
+ r"guard_not_forced|guard_no_exception|guard_not_invalidated)",
1789
+ Name.Builtin),
1790
+ include("extra-stuff"),
1791
+ ],
1792
+ "jit-backend-counts": [
1793
+ (r"\[\w+\] jit-backend-counts}$", Keyword, "#pop"),
1794
+ (r":", Punctuation),
1795
+ (r"\d+", Number),
1796
+ include("extra-stuff"),
1797
+ ],
1798
+ "extra-stuff": [
1799
+ (r"\s+", Text),
1800
+ (r"#.*?$", Comment),
1801
+ ],
1802
+ }
1803
+
1804
+
1805
+ class HxmlLexer(RegexLexer):
1806
+ """
1807
+ Lexer for `haXe build <http://haxe.org/doc/compiler>`_ files.
1808
+
1809
+ *New in Pygments 1.6.*
1810
+ """
1811
+ name = 'Hxml'
1812
+ aliases = ['haxeml', 'hxml']
1813
+ filenames = ['*.hxml']
1814
+
1815
+ tokens = {
1816
+ 'root': [
1817
+ # Seperator
1818
+ (r'(--)(next)', bygroups(Punctuation, Generic.Heading)),
1819
+ # Compiler switches with one dash
1820
+ (r'(-)(prompt|debug|v)', bygroups(Punctuation, Keyword.Keyword)),
1821
+ # Compilerswitches with two dashes
1822
+ (r'(--)(neko-source|flash-strict|flash-use-stage|no-opt|no-traces|'
1823
+ r'no-inline|times|no-output)', bygroups(Punctuation, Keyword)),
1824
+ # Targets and other options that take an argument
1825
+ (r'(-)(cpp|js|neko|x|as3|swf9?|swf-lib|php|xml|main|lib|D|resource|'
1826
+ r'cp|cmd)( +)(.+)',
1827
+ bygroups(Punctuation, Keyword, Whitespace, String)),
1828
+ # Options that take only numerical arguments
1829
+ (r'(-)(swf-version)( +)(\d+)',
1830
+ bygroups(Punctuation, Keyword, Number.Integer)),
1831
+ # An Option that defines the size, the fps and the background
1832
+ # color of an flash movie
1833
+ (r'(-)(swf-header)( +)(\d+)(:)(\d+)(:)(\d+)(:)([A-Fa-f0-9]{6})',
1834
+ bygroups(Punctuation, Keyword, Whitespace, Number.Integer,
1835
+ Punctuation, Number.Integer, Punctuation, Number.Integer,
1836
+ Punctuation, Number.Hex)),
1837
+ # options with two dashes that takes arguments
1838
+ (r'(--)(js-namespace|php-front|php-lib|remap|gen-hx-classes)( +)'
1839
+ r'(.+)', bygroups(Punctuation, Keyword, Whitespace, String)),
1840
+ # Single line comment, multiline ones are not allowed.
1841
+ (r'#.*', Comment.Single)
1842
+ ]
1843
+ }
1844
+
1845
+
1846
+ class EbnfLexer(RegexLexer):
1847
+ """
1848
+ Lexer for `ISO/IEC 14977 EBNF
1849
+ <http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form>`_
1850
+ grammars.
1851
+
1852
+ *New in Pygments 1.7.*
1853
+ """
1854
+
1855
+ name = 'EBNF'
1856
+ aliases = ['ebnf']
1857
+ filenames = ['*.ebnf']
1858
+ mimetypes = ['text/x-ebnf']
1859
+
1860
+ tokens = {
1861
+ 'root': [
1862
+ include('whitespace'),
1863
+ include('comment_start'),
1864
+ include('identifier'),
1865
+ (r'=', Operator, 'production'),
1866
+ ],
1867
+ 'production': [
1868
+ include('whitespace'),
1869
+ include('comment_start'),
1870
+ include('identifier'),
1871
+ (r'"[^"]*"', String.Double),
1872
+ (r"'[^']*'", String.Single),
1873
+ (r'(\?[^?]*\?)', Name.Entity),
1874
+ (r'[\[\]{}(),|]', Punctuation),
1875
+ (r'-', Operator),
1876
+ (r';', Punctuation, '#pop'),
1877
+ ],
1878
+ 'whitespace': [
1879
+ (r'\s+', Text),
1880
+ ],
1881
+ 'comment_start': [
1882
+ (r'\(\*', Comment.Multiline, 'comment'),
1883
+ ],
1884
+ 'comment': [
1885
+ (r'[^*)]', Comment.Multiline),
1886
+ include('comment_start'),
1887
+ (r'\*\)', Comment.Multiline, '#pop'),
1888
+ (r'[*)]', Comment.Multiline),
1889
+ ],
1890
+ 'identifier': [
1891
+ (r'([a-zA-Z][a-zA-Z0-9 \-]*)', Keyword),
1892
+ ],
1893
+ }