mortar-pygments.rb 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (472) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG.md +71 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +17 -0
  5. data/README.md +121 -0
  6. data/Rakefile +66 -0
  7. data/bench.rb +22 -0
  8. data/cache-lexers.rb +8 -0
  9. data/lexers +0 -0
  10. data/lib/pygments/lexer.rb +148 -0
  11. data/lib/pygments/mentos.py +351 -0
  12. data/lib/pygments/popen.rb +406 -0
  13. data/lib/pygments/version.rb +3 -0
  14. data/lib/pygments.rb +8 -0
  15. data/pygments.rb.gemspec +25 -0
  16. data/test/test_data.c +2581 -0
  17. data/test/test_data.py +514 -0
  18. data/test/test_data_generated +2582 -0
  19. data/test/test_pygments.rb +287 -0
  20. data/vendor/custom_lexers/github.py +565 -0
  21. data/vendor/pygments-main/AUTHORS +153 -0
  22. data/vendor/pygments-main/CHANGES +889 -0
  23. data/vendor/pygments-main/LICENSE +25 -0
  24. data/vendor/pygments-main/MANIFEST.in +6 -0
  25. data/vendor/pygments-main/Makefile +59 -0
  26. data/vendor/pygments-main/REVISION +1 -0
  27. data/vendor/pygments-main/TODO +15 -0
  28. data/vendor/pygments-main/docs/generate.py +472 -0
  29. data/vendor/pygments-main/docs/pygmentize.1 +94 -0
  30. data/vendor/pygments-main/docs/src/api.txt +270 -0
  31. data/vendor/pygments-main/docs/src/authors.txt +5 -0
  32. data/vendor/pygments-main/docs/src/changelog.txt +5 -0
  33. data/vendor/pygments-main/docs/src/cmdline.txt +147 -0
  34. data/vendor/pygments-main/docs/src/filterdevelopment.txt +70 -0
  35. data/vendor/pygments-main/docs/src/filters.txt +42 -0
  36. data/vendor/pygments-main/docs/src/formatterdevelopment.txt +169 -0
  37. data/vendor/pygments-main/docs/src/formatters.txt +48 -0
  38. data/vendor/pygments-main/docs/src/index.txt +69 -0
  39. data/vendor/pygments-main/docs/src/installation.txt +71 -0
  40. data/vendor/pygments-main/docs/src/integrate.txt +48 -0
  41. data/vendor/pygments-main/docs/src/java.txt +70 -0
  42. data/vendor/pygments-main/docs/src/lexerdevelopment.txt +603 -0
  43. data/vendor/pygments-main/docs/src/lexers.txt +67 -0
  44. data/vendor/pygments-main/docs/src/moinmoin.txt +39 -0
  45. data/vendor/pygments-main/docs/src/plugins.txt +93 -0
  46. data/vendor/pygments-main/docs/src/quickstart.txt +202 -0
  47. data/vendor/pygments-main/docs/src/rstdirective.txt +22 -0
  48. data/vendor/pygments-main/docs/src/styles.txt +143 -0
  49. data/vendor/pygments-main/docs/src/tokens.txt +349 -0
  50. data/vendor/pygments-main/docs/src/unicode.txt +49 -0
  51. data/vendor/pygments-main/external/autopygmentize +64 -0
  52. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
  53. data/vendor/pygments-main/external/markdown-processor.py +67 -0
  54. data/vendor/pygments-main/external/moin-parser.py +112 -0
  55. data/vendor/pygments-main/external/pygments.bashcomp +38 -0
  56. data/vendor/pygments-main/external/rst-directive-old.py +77 -0
  57. data/vendor/pygments-main/external/rst-directive.py +83 -0
  58. data/vendor/pygments-main/ez_setup.py +276 -0
  59. data/vendor/pygments-main/pygmentize +7 -0
  60. data/vendor/pygments-main/pygments/__init__.py +91 -0
  61. data/vendor/pygments-main/pygments/cmdline.py +441 -0
  62. data/vendor/pygments-main/pygments/console.py +74 -0
  63. data/vendor/pygments-main/pygments/filter.py +74 -0
  64. data/vendor/pygments-main/pygments/filters/__init__.py +356 -0
  65. data/vendor/pygments-main/pygments/formatter.py +95 -0
  66. data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
  67. data/vendor/pygments-main/pygments/formatters/_mapping.py +92 -0
  68. data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
  69. data/vendor/pygments-main/pygments/formatters/html.py +821 -0
  70. data/vendor/pygments-main/pygments/formatters/img.py +553 -0
  71. data/vendor/pygments-main/pygments/formatters/latex.py +378 -0
  72. data/vendor/pygments-main/pygments/formatters/other.py +115 -0
  73. data/vendor/pygments-main/pygments/formatters/rtf.py +136 -0
  74. data/vendor/pygments-main/pygments/formatters/svg.py +154 -0
  75. data/vendor/pygments-main/pygments/formatters/terminal.py +112 -0
  76. data/vendor/pygments-main/pygments/formatters/terminal256.py +222 -0
  77. data/vendor/pygments-main/pygments/lexer.py +765 -0
  78. data/vendor/pygments-main/pygments/lexers/__init__.py +240 -0
  79. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1645 -0
  80. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +232 -0
  81. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
  82. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +249 -0
  83. data/vendor/pygments-main/pygments/lexers/_mapping.py +355 -0
  84. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
  85. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
  86. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +233 -0
  87. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
  88. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +40 -0
  89. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
  90. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
  91. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -0
  92. data/vendor/pygments-main/pygments/lexers/agile.py +2290 -0
  93. data/vendor/pygments-main/pygments/lexers/asm.py +398 -0
  94. data/vendor/pygments-main/pygments/lexers/compiled.py +3723 -0
  95. data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
  96. data/vendor/pygments-main/pygments/lexers/dotnet.py +671 -0
  97. data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
  98. data/vendor/pygments-main/pygments/lexers/functional.py +2731 -0
  99. data/vendor/pygments-main/pygments/lexers/github.py +565 -0
  100. data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
  101. data/vendor/pygments-main/pygments/lexers/jvm.py +1112 -0
  102. data/vendor/pygments-main/pygments/lexers/math.py +1918 -0
  103. data/vendor/pygments-main/pygments/lexers/other.py +3778 -0
  104. data/vendor/pygments-main/pygments/lexers/parsers.py +778 -0
  105. data/vendor/pygments-main/pygments/lexers/shell.py +424 -0
  106. data/vendor/pygments-main/pygments/lexers/special.py +100 -0
  107. data/vendor/pygments-main/pygments/lexers/sql.py +609 -0
  108. data/vendor/pygments-main/pygments/lexers/templates.py +1742 -0
  109. data/vendor/pygments-main/pygments/lexers/text.py +1893 -0
  110. data/vendor/pygments-main/pygments/lexers/web.py +4045 -0
  111. data/vendor/pygments-main/pygments/modeline.py +40 -0
  112. data/vendor/pygments-main/pygments/plugin.py +74 -0
  113. data/vendor/pygments-main/pygments/scanner.py +104 -0
  114. data/vendor/pygments-main/pygments/style.py +117 -0
  115. data/vendor/pygments-main/pygments/styles/__init__.py +70 -0
  116. data/vendor/pygments-main/pygments/styles/autumn.py +65 -0
  117. data/vendor/pygments-main/pygments/styles/borland.py +51 -0
  118. data/vendor/pygments-main/pygments/styles/bw.py +49 -0
  119. data/vendor/pygments-main/pygments/styles/colorful.py +81 -0
  120. data/vendor/pygments-main/pygments/styles/default.py +73 -0
  121. data/vendor/pygments-main/pygments/styles/emacs.py +72 -0
  122. data/vendor/pygments-main/pygments/styles/friendly.py +72 -0
  123. data/vendor/pygments-main/pygments/styles/fruity.py +42 -0
  124. data/vendor/pygments-main/pygments/styles/manni.py +75 -0
  125. data/vendor/pygments-main/pygments/styles/monokai.py +106 -0
  126. data/vendor/pygments-main/pygments/styles/murphy.py +80 -0
  127. data/vendor/pygments-main/pygments/styles/native.py +65 -0
  128. data/vendor/pygments-main/pygments/styles/pastie.py +75 -0
  129. data/vendor/pygments-main/pygments/styles/perldoc.py +69 -0
  130. data/vendor/pygments-main/pygments/styles/rrt.py +33 -0
  131. data/vendor/pygments-main/pygments/styles/tango.py +141 -0
  132. data/vendor/pygments-main/pygments/styles/trac.py +63 -0
  133. data/vendor/pygments-main/pygments/styles/vim.py +63 -0
  134. data/vendor/pygments-main/pygments/styles/vs.py +38 -0
  135. data/vendor/pygments-main/pygments/token.py +195 -0
  136. data/vendor/pygments-main/pygments/unistring.py +140 -0
  137. data/vendor/pygments-main/pygments/util.py +277 -0
  138. data/vendor/pygments-main/scripts/check_sources.py +242 -0
  139. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +32 -0
  140. data/vendor/pygments-main/scripts/epydoc.css +280 -0
  141. data/vendor/pygments-main/scripts/find_codetags.py +205 -0
  142. data/vendor/pygments-main/scripts/find_error.py +170 -0
  143. data/vendor/pygments-main/scripts/get_vimkw.py +43 -0
  144. data/vendor/pygments-main/scripts/pylintrc +301 -0
  145. data/vendor/pygments-main/scripts/reindent.py +291 -0
  146. data/vendor/pygments-main/scripts/vim2pygments.py +933 -0
  147. data/vendor/pygments-main/setup.cfg +7 -0
  148. data/vendor/pygments-main/setup.py +90 -0
  149. data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +37 -0
  150. data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +869 -0
  151. data/vendor/pygments-main/tests/dtds/HTML4.dcl +88 -0
  152. data/vendor/pygments-main/tests/dtds/HTML4.dtd +1092 -0
  153. data/vendor/pygments-main/tests/dtds/HTML4.soc +9 -0
  154. data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +195 -0
  155. data/vendor/pygments-main/tests/dtds/HTMLspec.ent +77 -0
  156. data/vendor/pygments-main/tests/dtds/HTMLsym.ent +241 -0
  157. data/vendor/pygments-main/tests/examplefiles/ANTLRv3.g +608 -0
  158. data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +209 -0
  159. data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +102 -0
  160. data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
  161. data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +611 -0
  162. data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
  163. data/vendor/pygments-main/tests/examplefiles/Constants.mo +158 -0
  164. data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +411 -0
  165. data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
  166. data/vendor/pygments-main/tests/examplefiles/Errors.scala +18 -0
  167. data/vendor/pygments-main/tests/examplefiles/File.hy +174 -0
  168. data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
  169. data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
  170. data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
  171. data/vendor/pygments-main/tests/examplefiles/Intro.java +1660 -0
  172. data/vendor/pygments-main/tests/examplefiles/Makefile +1131 -0
  173. data/vendor/pygments-main/tests/examplefiles/Object.st +4394 -0
  174. data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +584 -0
  175. data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
  176. data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +378 -0
  177. data/vendor/pygments-main/tests/examplefiles/Sorting.mod +470 -0
  178. data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +382 -0
  179. data/vendor/pygments-main/tests/examplefiles/addressbook.proto +30 -0
  180. data/vendor/pygments-main/tests/examplefiles/antlr_throws +1 -0
  181. data/vendor/pygments-main/tests/examplefiles/apache2.conf +393 -0
  182. data/vendor/pygments-main/tests/examplefiles/as3_test.as +143 -0
  183. data/vendor/pygments-main/tests/examplefiles/as3_test2.as +46 -0
  184. data/vendor/pygments-main/tests/examplefiles/as3_test3.as +3 -0
  185. data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +27 -0
  186. data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
  187. data/vendor/pygments-main/tests/examplefiles/badcase.java +2 -0
  188. data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
  189. data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
  190. data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -0
  191. data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
  192. data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
  193. data/vendor/pygments-main/tests/examplefiles/cells.ps +515 -0
  194. data/vendor/pygments-main/tests/examplefiles/ceval.c +2604 -0
  195. data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +13 -0
  196. data/vendor/pygments-main/tests/examplefiles/classes.dylan +125 -0
  197. data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +10 -0
  198. data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +447 -0
  199. data/vendor/pygments-main/tests/examplefiles/database.pytb +20 -0
  200. data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +2461 -0
  201. data/vendor/pygments-main/tests/examplefiles/demo.ahk +181 -0
  202. data/vendor/pygments-main/tests/examplefiles/demo.cfm +38 -0
  203. data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +68 -0
  204. data/vendor/pygments-main/tests/examplefiles/dwarf.cw +17 -0
  205. data/vendor/pygments-main/tests/examplefiles/erl_session +10 -0
  206. data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +1 -0
  207. data/vendor/pygments-main/tests/examplefiles/evil_regex.js +48 -0
  208. data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
  209. data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
  210. data/vendor/pygments-main/tests/examplefiles/example.c +2080 -0
  211. data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
  212. data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
  213. data/vendor/pygments-main/tests/examplefiles/example.cls +15 -0
  214. data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
  215. data/vendor/pygments-main/tests/examplefiles/example.cpp +2363 -0
  216. data/vendor/pygments-main/tests/examplefiles/example.gs +106 -0
  217. data/vendor/pygments-main/tests/examplefiles/example.gst +7 -0
  218. data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
  219. data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
  220. data/vendor/pygments-main/tests/examplefiles/example.kt +47 -0
  221. data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
  222. data/vendor/pygments-main/tests/examplefiles/example.lua +250 -0
  223. data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
  224. data/vendor/pygments-main/tests/examplefiles/example.moo +26 -0
  225. data/vendor/pygments-main/tests/examplefiles/example.moon +629 -0
  226. data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
  227. data/vendor/pygments-main/tests/examplefiles/example.nim +1010 -0
  228. data/vendor/pygments-main/tests/examplefiles/example.ns2 +69 -0
  229. data/vendor/pygments-main/tests/examplefiles/example.p +34 -0
  230. data/vendor/pygments-main/tests/examplefiles/example.pas +2708 -0
  231. data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
  232. data/vendor/pygments-main/tests/examplefiles/example.rb +1852 -0
  233. data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
  234. data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
  235. data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
  236. data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
  237. data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
  238. data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -0
  239. data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
  240. data/vendor/pygments-main/tests/examplefiles/example.sml +156 -0
  241. data/vendor/pygments-main/tests/examplefiles/example.snobol +15 -0
  242. data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
  243. data/vendor/pygments-main/tests/examplefiles/example.tea +34 -0
  244. data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
  245. data/vendor/pygments-main/tests/examplefiles/example.u +548 -0
  246. data/vendor/pygments-main/tests/examplefiles/example.weechatlog +9 -0
  247. data/vendor/pygments-main/tests/examplefiles/example.xhtml +376 -0
  248. data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
  249. data/vendor/pygments-main/tests/examplefiles/example.yaml +302 -0
  250. data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -0
  251. data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
  252. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +363 -0
  253. data/vendor/pygments-main/tests/examplefiles/example_file.fy +128 -0
  254. data/vendor/pygments-main/tests/examplefiles/firefox.mak +586 -0
  255. data/vendor/pygments-main/tests/examplefiles/flipflop.sv +19 -0
  256. data/vendor/pygments-main/tests/examplefiles/foo.sce +6 -0
  257. data/vendor/pygments-main/tests/examplefiles/format.ml +1213 -0
  258. data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +77 -0
  259. data/vendor/pygments-main/tests/examplefiles/function.mu +1 -0
  260. data/vendor/pygments-main/tests/examplefiles/functional.rst +1472 -0
  261. data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
  262. data/vendor/pygments-main/tests/examplefiles/genclass.clj +510 -0
  263. data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +193 -0
  264. data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +33 -0
  265. data/vendor/pygments-main/tests/examplefiles/glsl.frag +7 -0
  266. data/vendor/pygments-main/tests/examplefiles/glsl.vert +13 -0
  267. data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
  268. data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
  269. data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
  270. data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +1 -0
  271. data/vendor/pygments-main/tests/examplefiles/http_request_example +15 -0
  272. data/vendor/pygments-main/tests/examplefiles/http_response_example +29 -0
  273. data/vendor/pygments-main/tests/examplefiles/import.hs +4 -0
  274. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
  275. data/vendor/pygments-main/tests/examplefiles/intro.ik +24 -0
  276. data/vendor/pygments-main/tests/examplefiles/ints.php +10 -0
  277. data/vendor/pygments-main/tests/examplefiles/intsyn.fun +675 -0
  278. data/vendor/pygments-main/tests/examplefiles/intsyn.sig +286 -0
  279. data/vendor/pygments-main/tests/examplefiles/irb_heredoc +8 -0
  280. data/vendor/pygments-main/tests/examplefiles/irc.lsp +214 -0
  281. data/vendor/pygments-main/tests/examplefiles/java.properties +16 -0
  282. data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +28 -0
  283. data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +45 -0
  284. data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +713 -0
  285. data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
  286. data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
  287. data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +13 -0
  288. data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -0
  289. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
  290. data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
  291. data/vendor/pygments-main/tests/examplefiles/ltmain.sh +2849 -0
  292. data/vendor/pygments-main/tests/examplefiles/main.cmake +42 -0
  293. data/vendor/pygments-main/tests/examplefiles/markdown.lsp +679 -0
  294. data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +3 -0
  295. data/vendor/pygments-main/tests/examplefiles/matlab_sample +30 -0
  296. data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -0
  297. data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
  298. data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
  299. data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
  300. data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +4 -0
  301. data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +340 -0
  302. data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +38 -0
  303. data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
  304. data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +96 -0
  305. data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +30 -0
  306. data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +87 -0
  307. data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +118 -0
  308. data/vendor/pygments-main/tests/examplefiles/numbers.c +12 -0
  309. data/vendor/pygments-main/tests/examplefiles/objc_example.m +32 -0
  310. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +24 -0
  311. data/vendor/pygments-main/tests/examplefiles/perl_misc +62 -0
  312. data/vendor/pygments-main/tests/examplefiles/perl_perl5db +998 -0
  313. data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +120 -0
  314. data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +856 -0
  315. data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
  316. data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +567 -0
  317. data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +1223 -0
  318. data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +47 -0
  319. data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +10 -0
  320. data/vendor/pygments-main/tests/examplefiles/psql_session.txt +122 -0
  321. data/vendor/pygments-main/tests/examplefiles/py3_test.txt +2 -0
  322. data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
  323. data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +14 -0
  324. data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -0
  325. data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
  326. data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +234 -0
  327. data/vendor/pygments-main/tests/examplefiles/qsort.prolog +13 -0
  328. data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +38 -0
  329. data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +280 -0
  330. data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +2 -0
  331. data/vendor/pygments-main/tests/examplefiles/regex.js +22 -0
  332. data/vendor/pygments-main/tests/examplefiles/reversi.lsp +427 -0
  333. data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
  334. data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +11 -0
  335. data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
  336. data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -0
  337. data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
  338. data/vendor/pygments-main/tests/examplefiles/sibling.prolog +19 -0
  339. data/vendor/pygments-main/tests/examplefiles/simple.md +747 -0
  340. data/vendor/pygments-main/tests/examplefiles/smarty_example.html +209 -0
  341. data/vendor/pygments-main/tests/examplefiles/source.lgt +343 -0
  342. data/vendor/pygments-main/tests/examplefiles/sources.list +62 -0
  343. data/vendor/pygments-main/tests/examplefiles/sphere.pov +18 -0
  344. data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +27 -0
  345. data/vendor/pygments-main/tests/examplefiles/squid.conf +30 -0
  346. data/vendor/pygments-main/tests/examplefiles/string.jl +1031 -0
  347. data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +21 -0
  348. data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +3 -0
  349. data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
  350. data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
  351. data/vendor/pygments-main/tests/examplefiles/test.R +153 -0
  352. data/vendor/pygments-main/tests/examplefiles/test.adb +211 -0
  353. data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
  354. data/vendor/pygments-main/tests/examplefiles/test.asy +131 -0
  355. data/vendor/pygments-main/tests/examplefiles/test.awk +121 -0
  356. data/vendor/pygments-main/tests/examplefiles/test.bas +29 -0
  357. data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
  358. data/vendor/pygments-main/tests/examplefiles/test.bmx +145 -0
  359. data/vendor/pygments-main/tests/examplefiles/test.boo +39 -0
  360. data/vendor/pygments-main/tests/examplefiles/test.bro +250 -0
  361. data/vendor/pygments-main/tests/examplefiles/test.cs +374 -0
  362. data/vendor/pygments-main/tests/examplefiles/test.css +54 -0
  363. data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
  364. data/vendor/pygments-main/tests/examplefiles/test.d +135 -0
  365. data/vendor/pygments-main/tests/examplefiles/test.dart +23 -0
  366. data/vendor/pygments-main/tests/examplefiles/test.dtd +89 -0
  367. data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
  368. data/vendor/pygments-main/tests/examplefiles/test.ec +605 -0
  369. data/vendor/pygments-main/tests/examplefiles/test.ecl +58 -0
  370. data/vendor/pygments-main/tests/examplefiles/test.eh +315 -0
  371. data/vendor/pygments-main/tests/examplefiles/test.erl +169 -0
  372. data/vendor/pygments-main/tests/examplefiles/test.evoque +33 -0
  373. data/vendor/pygments-main/tests/examplefiles/test.fan +818 -0
  374. data/vendor/pygments-main/tests/examplefiles/test.flx +57 -0
  375. data/vendor/pygments-main/tests/examplefiles/test.gdc +13 -0
  376. data/vendor/pygments-main/tests/examplefiles/test.groovy +97 -0
  377. data/vendor/pygments-main/tests/examplefiles/test.html +339 -0
  378. data/vendor/pygments-main/tests/examplefiles/test.ini +10 -0
  379. data/vendor/pygments-main/tests/examplefiles/test.java +653 -0
  380. data/vendor/pygments-main/tests/examplefiles/test.jsp +24 -0
  381. data/vendor/pygments-main/tests/examplefiles/test.maql +45 -0
  382. data/vendor/pygments-main/tests/examplefiles/test.mod +374 -0
  383. data/vendor/pygments-main/tests/examplefiles/test.moo +51 -0
  384. data/vendor/pygments-main/tests/examplefiles/test.myt +166 -0
  385. data/vendor/pygments-main/tests/examplefiles/test.nim +93 -0
  386. data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
  387. data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
  388. data/vendor/pygments-main/tests/examplefiles/test.pas +743 -0
  389. data/vendor/pygments-main/tests/examplefiles/test.php +505 -0
  390. data/vendor/pygments-main/tests/examplefiles/test.plot +333 -0
  391. data/vendor/pygments-main/tests/examplefiles/test.ps1 +108 -0
  392. data/vendor/pygments-main/tests/examplefiles/test.pypylog +1839 -0
  393. data/vendor/pygments-main/tests/examplefiles/test.r3 +94 -0
  394. data/vendor/pygments-main/tests/examplefiles/test.rb +177 -0
  395. data/vendor/pygments-main/tests/examplefiles/test.rhtml +43 -0
  396. data/vendor/pygments-main/tests/examplefiles/test.scaml +8 -0
  397. data/vendor/pygments-main/tests/examplefiles/test.ssp +12 -0
  398. data/vendor/pygments-main/tests/examplefiles/test.tcsh +830 -0
  399. data/vendor/pygments-main/tests/examplefiles/test.vb +407 -0
  400. data/vendor/pygments-main/tests/examplefiles/test.vhdl +161 -0
  401. data/vendor/pygments-main/tests/examplefiles/test.xqy +138 -0
  402. data/vendor/pygments-main/tests/examplefiles/test.xsl +23 -0
  403. data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
  404. data/vendor/pygments-main/tests/examplefiles/truncated.pytb +15 -0
  405. data/vendor/pygments-main/tests/examplefiles/type.lisp +1218 -0
  406. data/vendor/pygments-main/tests/examplefiles/underscore.coffee +603 -0
  407. data/vendor/pygments-main/tests/examplefiles/unicode.applescript +5 -0
  408. data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +11 -0
  409. data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
  410. data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +3 -0
  411. data/vendor/pygments-main/tests/examplefiles/while.pov +13 -0
  412. data/vendor/pygments-main/tests/examplefiles/wiki.factor +384 -0
  413. data/vendor/pygments-main/tests/examplefiles/xml_example +1897 -0
  414. data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +798 -0
  415. data/vendor/pygments-main/tests/old_run.py +138 -0
  416. data/vendor/pygments-main/tests/run.py +49 -0
  417. data/vendor/pygments-main/tests/support/tags +36 -0
  418. data/vendor/pygments-main/tests/support.py +15 -0
  419. data/vendor/pygments-main/tests/test_basic_api.py +295 -0
  420. data/vendor/pygments-main/tests/test_clexer.py +31 -0
  421. data/vendor/pygments-main/tests/test_cmdline.py +105 -0
  422. data/vendor/pygments-main/tests/test_examplefiles.py +99 -0
  423. data/vendor/pygments-main/tests/test_html_formatter.py +178 -0
  424. data/vendor/pygments-main/tests/test_latex_formatter.py +55 -0
  425. data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
  426. data/vendor/pygments-main/tests/test_perllexer.py +137 -0
  427. data/vendor/pygments-main/tests/test_regexlexer.py +47 -0
  428. data/vendor/pygments-main/tests/test_token.py +46 -0
  429. data/vendor/pygments-main/tests/test_using_api.py +40 -0
  430. data/vendor/pygments-main/tests/test_util.py +135 -0
  431. data/vendor/simplejson/.gitignore +10 -0
  432. data/vendor/simplejson/.travis.yml +5 -0
  433. data/vendor/simplejson/CHANGES.txt +291 -0
  434. data/vendor/simplejson/LICENSE.txt +19 -0
  435. data/vendor/simplejson/MANIFEST.in +5 -0
  436. data/vendor/simplejson/README.rst +19 -0
  437. data/vendor/simplejson/conf.py +179 -0
  438. data/vendor/simplejson/index.rst +628 -0
  439. data/vendor/simplejson/scripts/make_docs.py +18 -0
  440. data/vendor/simplejson/setup.py +104 -0
  441. data/vendor/simplejson/simplejson/__init__.py +510 -0
  442. data/vendor/simplejson/simplejson/_speedups.c +2745 -0
  443. data/vendor/simplejson/simplejson/decoder.py +425 -0
  444. data/vendor/simplejson/simplejson/encoder.py +567 -0
  445. data/vendor/simplejson/simplejson/ordered_dict.py +119 -0
  446. data/vendor/simplejson/simplejson/scanner.py +77 -0
  447. data/vendor/simplejson/simplejson/tests/__init__.py +67 -0
  448. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +55 -0
  449. data/vendor/simplejson/simplejson/tests/test_check_circular.py +30 -0
  450. data/vendor/simplejson/simplejson/tests/test_decimal.py +66 -0
  451. data/vendor/simplejson/simplejson/tests/test_decode.py +83 -0
  452. data/vendor/simplejson/simplejson/tests/test_default.py +9 -0
  453. data/vendor/simplejson/simplejson/tests/test_dump.py +67 -0
  454. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +46 -0
  455. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +32 -0
  456. data/vendor/simplejson/simplejson/tests/test_errors.py +34 -0
  457. data/vendor/simplejson/simplejson/tests/test_fail.py +91 -0
  458. data/vendor/simplejson/simplejson/tests/test_float.py +19 -0
  459. data/vendor/simplejson/simplejson/tests/test_indent.py +86 -0
  460. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +20 -0
  461. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +121 -0
  462. data/vendor/simplejson/simplejson/tests/test_pass1.py +76 -0
  463. data/vendor/simplejson/simplejson/tests/test_pass2.py +14 -0
  464. data/vendor/simplejson/simplejson/tests/test_pass3.py +20 -0
  465. data/vendor/simplejson/simplejson/tests/test_recursion.py +67 -0
  466. data/vendor/simplejson/simplejson/tests/test_scanstring.py +117 -0
  467. data/vendor/simplejson/simplejson/tests/test_separators.py +42 -0
  468. data/vendor/simplejson/simplejson/tests/test_speedups.py +20 -0
  469. data/vendor/simplejson/simplejson/tests/test_tuple.py +49 -0
  470. data/vendor/simplejson/simplejson/tests/test_unicode.py +109 -0
  471. data/vendor/simplejson/simplejson/tool.py +39 -0
  472. metadata +566 -0
@@ -0,0 +1,2731 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.functional
4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for functional languages.
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
+
14
+ from pygments.lexer import Lexer, RegexLexer, bygroups, include, do_insertions
15
+ from pygments.token import Text, Comment, Operator, Keyword, Name, \
16
+ String, Number, Punctuation, Literal, Generic, Error
17
+
18
+ __all__ = ['RacketLexer', 'SchemeLexer', 'CommonLispLexer', 'HaskellLexer',
19
+ 'AgdaLexer', 'LiterateHaskellLexer', 'LiterateAgdaLexer',
20
+ 'SMLLexer', 'OcamlLexer', 'ErlangLexer', 'ErlangShellLexer',
21
+ 'OpaLexer', 'CoqLexer', 'NewLispLexer', 'ElixirLexer',
22
+ 'ElixirConsoleLexer', 'KokaLexer']
23
+
24
+
25
+ line_re = re.compile('.*?\n')
26
+
27
+
28
+ class RacketLexer(RegexLexer):
29
+ """
30
+ Lexer for `Racket <http://racket-lang.org/>`_ source code (formerly known as
31
+ PLT Scheme).
32
+
33
+ *New in Pygments 1.6.*
34
+ """
35
+
36
+ name = 'Racket'
37
+ aliases = ['racket', 'rkt']
38
+ filenames = ['*.rkt', '*.rktl']
39
+ mimetypes = ['text/x-racket', 'application/x-racket']
40
+
41
+ # From namespace-mapped-symbols
42
+ keywords = [
43
+ '#%app', '#%datum', '#%expression', '#%module-begin',
44
+ '#%plain-app', '#%plain-lambda', '#%plain-module-begin',
45
+ '#%provide', '#%require', '#%stratified-body', '#%top',
46
+ '#%top-interaction', '#%variable-reference', '...', 'and', 'begin',
47
+ 'begin-for-syntax', 'begin0', 'case', 'case-lambda', 'cond',
48
+ 'datum->syntax-object', 'define', 'define-for-syntax',
49
+ 'define-struct', 'define-syntax', 'define-syntax-rule',
50
+ 'define-syntaxes', 'define-values', 'define-values-for-syntax',
51
+ 'delay', 'do', 'expand-path', 'fluid-let', 'hash-table-copy',
52
+ 'hash-table-count', 'hash-table-for-each', 'hash-table-get',
53
+ 'hash-table-iterate-first', 'hash-table-iterate-key',
54
+ 'hash-table-iterate-next', 'hash-table-iterate-value',
55
+ 'hash-table-map', 'hash-table-put!', 'hash-table-remove!',
56
+ 'hash-table?', 'if', 'lambda', 'let', 'let*', 'let*-values',
57
+ 'let-struct', 'let-syntax', 'let-syntaxes', 'let-values', 'let/cc',
58
+ 'let/ec', 'letrec', 'letrec-syntax', 'letrec-syntaxes',
59
+ 'letrec-syntaxes+values', 'letrec-values', 'list-immutable',
60
+ 'make-hash-table', 'make-immutable-hash-table', 'make-namespace',
61
+ 'module', 'module-identifier=?', 'module-label-identifier=?',
62
+ 'module-template-identifier=?', 'module-transformer-identifier=?',
63
+ 'namespace-transformer-require', 'or', 'parameterize',
64
+ 'parameterize*', 'parameterize-break', 'provide',
65
+ 'provide-for-label', 'provide-for-syntax', 'quasiquote',
66
+ 'quasisyntax', 'quasisyntax/loc', 'quote', 'quote-syntax',
67
+ 'quote-syntax/prune', 'require', 'require-for-label',
68
+ 'require-for-syntax', 'require-for-template', 'set!',
69
+ 'set!-values', 'syntax', 'syntax-case', 'syntax-case*',
70
+ 'syntax-id-rules', 'syntax-object->datum', 'syntax-rules',
71
+ 'syntax/loc', 'time', 'transcript-off', 'transcript-on', 'unless',
72
+ 'unquote', 'unquote-splicing', 'unsyntax', 'unsyntax-splicing',
73
+ 'when', 'with-continuation-mark', 'with-handlers',
74
+ 'with-handlers*', 'with-syntax', 'λ'
75
+ ]
76
+
77
+ # From namespace-mapped-symbols
78
+ builtins = [
79
+ '*', '+', '-', '/', '<', '<=', '=', '>', '>=',
80
+ 'abort-current-continuation', 'abs', 'absolute-path?', 'acos',
81
+ 'add1', 'alarm-evt', 'always-evt', 'andmap', 'angle', 'append',
82
+ 'apply', 'arithmetic-shift', 'arity-at-least',
83
+ 'arity-at-least-value', 'arity-at-least?', 'asin', 'assoc', 'assq',
84
+ 'assv', 'atan', 'banner', 'bitwise-and', 'bitwise-bit-field',
85
+ 'bitwise-bit-set?', 'bitwise-ior', 'bitwise-not', 'bitwise-xor',
86
+ 'boolean?', 'bound-identifier=?', 'box', 'box-immutable', 'box?',
87
+ 'break-enabled', 'break-thread', 'build-path',
88
+ 'build-path/convention-type', 'byte-pregexp', 'byte-pregexp?',
89
+ 'byte-ready?', 'byte-regexp', 'byte-regexp?', 'byte?', 'bytes',
90
+ 'bytes->immutable-bytes', 'bytes->list', 'bytes->path',
91
+ 'bytes->path-element', 'bytes->string/latin-1',
92
+ 'bytes->string/locale', 'bytes->string/utf-8', 'bytes-append',
93
+ 'bytes-close-converter', 'bytes-convert', 'bytes-convert-end',
94
+ 'bytes-converter?', 'bytes-copy', 'bytes-copy!', 'bytes-fill!',
95
+ 'bytes-length', 'bytes-open-converter', 'bytes-ref', 'bytes-set!',
96
+ 'bytes-utf-8-index', 'bytes-utf-8-length', 'bytes-utf-8-ref',
97
+ 'bytes<?', 'bytes=?', 'bytes>?', 'bytes?', 'caaaar', 'caaadr',
98
+ 'caaar', 'caadar', 'caaddr', 'caadr', 'caar', 'cadaar', 'cadadr',
99
+ 'cadar', 'caddar', 'cadddr', 'caddr', 'cadr',
100
+ 'call-in-nested-thread', 'call-with-break-parameterization',
101
+ 'call-with-composable-continuation',
102
+ 'call-with-continuation-barrier', 'call-with-continuation-prompt',
103
+ 'call-with-current-continuation', 'call-with-escape-continuation',
104
+ 'call-with-exception-handler',
105
+ 'call-with-immediate-continuation-mark', 'call-with-input-file',
106
+ 'call-with-output-file', 'call-with-parameterization',
107
+ 'call-with-semaphore', 'call-with-semaphore/enable-break',
108
+ 'call-with-values', 'call/cc', 'call/ec', 'car', 'cdaaar',
109
+ 'cdaadr', 'cdaar', 'cdadar', 'cdaddr', 'cdadr', 'cdar', 'cddaar',
110
+ 'cddadr', 'cddar', 'cdddar', 'cddddr', 'cdddr', 'cddr', 'cdr',
111
+ 'ceiling', 'channel-get', 'channel-put', 'channel-put-evt',
112
+ 'channel-try-get', 'channel?', 'chaperone-box', 'chaperone-evt',
113
+ 'chaperone-hash', 'chaperone-of?', 'chaperone-procedure',
114
+ 'chaperone-struct', 'chaperone-struct-type', 'chaperone-vector',
115
+ 'chaperone?', 'char->integer', 'char-alphabetic?', 'char-blank?',
116
+ 'char-ci<=?', 'char-ci<?', 'char-ci=?', 'char-ci>=?', 'char-ci>?',
117
+ 'char-downcase', 'char-foldcase', 'char-general-category',
118
+ 'char-graphic?', 'char-iso-control?', 'char-lower-case?',
119
+ 'char-numeric?', 'char-punctuation?', 'char-ready?',
120
+ 'char-symbolic?', 'char-title-case?', 'char-titlecase',
121
+ 'char-upcase', 'char-upper-case?', 'char-utf-8-length',
122
+ 'char-whitespace?', 'char<=?', 'char<?', 'char=?', 'char>=?',
123
+ 'char>?', 'char?', 'check-duplicate-identifier',
124
+ 'checked-procedure-check-and-extract', 'choice-evt',
125
+ 'cleanse-path', 'close-input-port', 'close-output-port',
126
+ 'collect-garbage', 'collection-file-path', 'collection-path',
127
+ 'compile', 'compile-allow-set!-undefined',
128
+ 'compile-context-preservation-enabled',
129
+ 'compile-enforce-module-constants', 'compile-syntax',
130
+ 'compiled-expression?', 'compiled-module-expression?',
131
+ 'complete-path?', 'complex?', 'cons',
132
+ 'continuation-mark-set->context', 'continuation-mark-set->list',
133
+ 'continuation-mark-set->list*', 'continuation-mark-set-first',
134
+ 'continuation-mark-set?', 'continuation-marks',
135
+ 'continuation-prompt-available?', 'continuation-prompt-tag?',
136
+ 'continuation?', 'copy-file', 'cos',
137
+ 'current-break-parameterization', 'current-code-inspector',
138
+ 'current-command-line-arguments', 'current-compile',
139
+ 'current-continuation-marks', 'current-custodian',
140
+ 'current-directory', 'current-drive', 'current-error-port',
141
+ 'current-eval', 'current-evt-pseudo-random-generator',
142
+ 'current-gc-milliseconds', 'current-get-interaction-input-port',
143
+ 'current-inexact-milliseconds', 'current-input-port',
144
+ 'current-inspector', 'current-library-collection-paths',
145
+ 'current-load', 'current-load-extension',
146
+ 'current-load-relative-directory', 'current-load/use-compiled',
147
+ 'current-locale', 'current-memory-use', 'current-milliseconds',
148
+ 'current-module-declare-name', 'current-module-declare-source',
149
+ 'current-module-name-resolver', 'current-namespace',
150
+ 'current-output-port', 'current-parameterization',
151
+ 'current-preserved-thread-cell-values', 'current-print',
152
+ 'current-process-milliseconds', 'current-prompt-read',
153
+ 'current-pseudo-random-generator', 'current-read-interaction',
154
+ 'current-reader-guard', 'current-readtable', 'current-seconds',
155
+ 'current-security-guard', 'current-subprocess-custodian-mode',
156
+ 'current-thread', 'current-thread-group',
157
+ 'current-thread-initial-stack-size',
158
+ 'current-write-relative-directory', 'custodian-box-value',
159
+ 'custodian-box?', 'custodian-limit-memory',
160
+ 'custodian-managed-list', 'custodian-memory-accounting-available?',
161
+ 'custodian-require-memory', 'custodian-shutdown-all', 'custodian?',
162
+ 'custom-print-quotable-accessor', 'custom-print-quotable?',
163
+ 'custom-write-accessor', 'custom-write?', 'date', 'date*',
164
+ 'date*-nanosecond', 'date*-time-zone-name', 'date*?', 'date-day',
165
+ 'date-dst?', 'date-hour', 'date-minute', 'date-month',
166
+ 'date-second', 'date-time-zone-offset', 'date-week-day',
167
+ 'date-year', 'date-year-day', 'date?', 'datum-intern-literal',
168
+ 'default-continuation-prompt-tag', 'delete-directory',
169
+ 'delete-file', 'denominator', 'directory-exists?',
170
+ 'directory-list', 'display', 'displayln', 'dump-memory-stats',
171
+ 'dynamic-require', 'dynamic-require-for-syntax', 'dynamic-wind',
172
+ 'eof', 'eof-object?', 'ephemeron-value', 'ephemeron?', 'eprintf',
173
+ 'eq-hash-code', 'eq?', 'equal-hash-code',
174
+ 'equal-secondary-hash-code', 'equal?', 'equal?/recur',
175
+ 'eqv-hash-code', 'eqv?', 'error', 'error-display-handler',
176
+ 'error-escape-handler', 'error-print-context-length',
177
+ 'error-print-source-location', 'error-print-width',
178
+ 'error-value->string-handler', 'eval', 'eval-jit-enabled',
179
+ 'eval-syntax', 'even?', 'evt?', 'exact->inexact', 'exact-integer?',
180
+ 'exact-nonnegative-integer?', 'exact-positive-integer?', 'exact?',
181
+ 'executable-yield-handler', 'exit', 'exit-handler', 'exn',
182
+ 'exn-continuation-marks', 'exn-message', 'exn:break',
183
+ 'exn:break-continuation', 'exn:break?', 'exn:fail',
184
+ 'exn:fail:contract', 'exn:fail:contract:arity',
185
+ 'exn:fail:contract:arity?', 'exn:fail:contract:continuation',
186
+ 'exn:fail:contract:continuation?',
187
+ 'exn:fail:contract:divide-by-zero',
188
+ 'exn:fail:contract:divide-by-zero?',
189
+ 'exn:fail:contract:non-fixnum-result',
190
+ 'exn:fail:contract:non-fixnum-result?',
191
+ 'exn:fail:contract:variable', 'exn:fail:contract:variable-id',
192
+ 'exn:fail:contract:variable?', 'exn:fail:contract?',
193
+ 'exn:fail:filesystem', 'exn:fail:filesystem:exists',
194
+ 'exn:fail:filesystem:exists?', 'exn:fail:filesystem:version',
195
+ 'exn:fail:filesystem:version?', 'exn:fail:filesystem?',
196
+ 'exn:fail:network', 'exn:fail:network?', 'exn:fail:out-of-memory',
197
+ 'exn:fail:out-of-memory?', 'exn:fail:read',
198
+ 'exn:fail:read-srclocs', 'exn:fail:read:eof', 'exn:fail:read:eof?',
199
+ 'exn:fail:read:non-char', 'exn:fail:read:non-char?',
200
+ 'exn:fail:read?', 'exn:fail:syntax', 'exn:fail:syntax-exprs',
201
+ 'exn:fail:syntax:unbound', 'exn:fail:syntax:unbound?',
202
+ 'exn:fail:syntax?', 'exn:fail:unsupported',
203
+ 'exn:fail:unsupported?', 'exn:fail:user', 'exn:fail:user?',
204
+ 'exn:fail?', 'exn:srclocs-accessor', 'exn:srclocs?', 'exn?', 'exp',
205
+ 'expand', 'expand-once', 'expand-syntax', 'expand-syntax-once',
206
+ 'expand-syntax-to-top-form', 'expand-to-top-form',
207
+ 'expand-user-path', 'expt', 'file-exists?',
208
+ 'file-or-directory-identity', 'file-or-directory-modify-seconds',
209
+ 'file-or-directory-permissions', 'file-position', 'file-size',
210
+ 'file-stream-buffer-mode', 'file-stream-port?',
211
+ 'filesystem-root-list', 'find-executable-path',
212
+ 'find-library-collection-paths', 'find-system-path', 'fixnum?',
213
+ 'floating-point-bytes->real', 'flonum?', 'floor', 'flush-output',
214
+ 'for-each', 'force', 'format', 'fprintf', 'free-identifier=?',
215
+ 'gcd', 'generate-temporaries', 'gensym', 'get-output-bytes',
216
+ 'get-output-string', 'getenv', 'global-port-print-handler',
217
+ 'guard-evt', 'handle-evt', 'handle-evt?', 'hash', 'hash-equal?',
218
+ 'hash-eqv?', 'hash-has-key?', 'hash-placeholder?', 'hash-ref!',
219
+ 'hasheq', 'hasheqv', 'identifier-binding',
220
+ 'identifier-label-binding', 'identifier-prune-lexical-context',
221
+ 'identifier-prune-to-source-module',
222
+ 'identifier-remove-from-definition-context',
223
+ 'identifier-template-binding', 'identifier-transformer-binding',
224
+ 'identifier?', 'imag-part', 'immutable?', 'impersonate-box',
225
+ 'impersonate-hash', 'impersonate-procedure', 'impersonate-struct',
226
+ 'impersonate-vector', 'impersonator-of?',
227
+ 'impersonator-prop:application-mark',
228
+ 'impersonator-property-accessor-procedure?',
229
+ 'impersonator-property?', 'impersonator?', 'inexact->exact',
230
+ 'inexact-real?', 'inexact?', 'input-port?', 'inspector?',
231
+ 'integer->char', 'integer->integer-bytes',
232
+ 'integer-bytes->integer', 'integer-length', 'integer-sqrt',
233
+ 'integer-sqrt/remainder', 'integer?',
234
+ 'internal-definition-context-seal', 'internal-definition-context?',
235
+ 'keyword->string', 'keyword<?', 'keyword?', 'kill-thread', 'lcm',
236
+ 'length', 'liberal-define-context?', 'link-exists?', 'list',
237
+ 'list*', 'list->bytes', 'list->string', 'list->vector', 'list-ref',
238
+ 'list-tail', 'list?', 'load', 'load-extension',
239
+ 'load-on-demand-enabled', 'load-relative',
240
+ 'load-relative-extension', 'load/cd', 'load/use-compiled',
241
+ 'local-expand', 'local-expand/capture-lifts',
242
+ 'local-transformer-expand',
243
+ 'local-transformer-expand/capture-lifts', 'locale-string-encoding',
244
+ 'log', 'magnitude', 'make-arity-at-least', 'make-bytes',
245
+ 'make-channel', 'make-continuation-prompt-tag', 'make-custodian',
246
+ 'make-custodian-box', 'make-date', 'make-date*',
247
+ 'make-derived-parameter', 'make-directory', 'make-ephemeron',
248
+ 'make-exn', 'make-exn:break', 'make-exn:fail',
249
+ 'make-exn:fail:contract', 'make-exn:fail:contract:arity',
250
+ 'make-exn:fail:contract:continuation',
251
+ 'make-exn:fail:contract:divide-by-zero',
252
+ 'make-exn:fail:contract:non-fixnum-result',
253
+ 'make-exn:fail:contract:variable', 'make-exn:fail:filesystem',
254
+ 'make-exn:fail:filesystem:exists',
255
+ 'make-exn:fail:filesystem:version', 'make-exn:fail:network',
256
+ 'make-exn:fail:out-of-memory', 'make-exn:fail:read',
257
+ 'make-exn:fail:read:eof', 'make-exn:fail:read:non-char',
258
+ 'make-exn:fail:syntax', 'make-exn:fail:syntax:unbound',
259
+ 'make-exn:fail:unsupported', 'make-exn:fail:user',
260
+ 'make-file-or-directory-link', 'make-hash-placeholder',
261
+ 'make-hasheq-placeholder', 'make-hasheqv',
262
+ 'make-hasheqv-placeholder', 'make-immutable-hasheqv',
263
+ 'make-impersonator-property', 'make-input-port', 'make-inspector',
264
+ 'make-known-char-range-list', 'make-output-port', 'make-parameter',
265
+ 'make-pipe', 'make-placeholder', 'make-polar',
266
+ 'make-prefab-struct', 'make-pseudo-random-generator',
267
+ 'make-reader-graph', 'make-readtable', 'make-rectangular',
268
+ 'make-rename-transformer', 'make-resolved-module-path',
269
+ 'make-security-guard', 'make-semaphore', 'make-set!-transformer',
270
+ 'make-shared-bytes', 'make-sibling-inspector',
271
+ 'make-special-comment', 'make-srcloc', 'make-string',
272
+ 'make-struct-field-accessor', 'make-struct-field-mutator',
273
+ 'make-struct-type', 'make-struct-type-property',
274
+ 'make-syntax-delta-introducer', 'make-syntax-introducer',
275
+ 'make-thread-cell', 'make-thread-group', 'make-vector',
276
+ 'make-weak-box', 'make-weak-hasheqv', 'make-will-executor', 'map',
277
+ 'max', 'mcar', 'mcdr', 'mcons', 'member', 'memq', 'memv', 'min',
278
+ 'module->exports', 'module->imports', 'module->language-info',
279
+ 'module->namespace', 'module-compiled-exports',
280
+ 'module-compiled-imports', 'module-compiled-language-info',
281
+ 'module-compiled-name', 'module-path-index-join',
282
+ 'module-path-index-resolve', 'module-path-index-split',
283
+ 'module-path-index?', 'module-path?', 'module-predefined?',
284
+ 'module-provide-protected?', 'modulo', 'mpair?', 'nack-guard-evt',
285
+ 'namespace-attach-module', 'namespace-attach-module-declaration',
286
+ 'namespace-base-phase', 'namespace-mapped-symbols',
287
+ 'namespace-module-identifier', 'namespace-module-registry',
288
+ 'namespace-require', 'namespace-require/constant',
289
+ 'namespace-require/copy', 'namespace-require/expansion-time',
290
+ 'namespace-set-variable-value!', 'namespace-symbol->identifier',
291
+ 'namespace-syntax-introduce', 'namespace-undefine-variable!',
292
+ 'namespace-unprotect-module', 'namespace-variable-value',
293
+ 'namespace?', 'negative?', 'never-evt', 'newline',
294
+ 'normal-case-path', 'not', 'null', 'null?', 'number->string',
295
+ 'number?', 'numerator', 'object-name', 'odd?', 'open-input-bytes',
296
+ 'open-input-file', 'open-input-output-file', 'open-input-string',
297
+ 'open-output-bytes', 'open-output-file', 'open-output-string',
298
+ 'ormap', 'output-port?', 'pair?', 'parameter-procedure=?',
299
+ 'parameter?', 'parameterization?', 'path->bytes',
300
+ 'path->complete-path', 'path->directory-path', 'path->string',
301
+ 'path-add-suffix', 'path-convention-type', 'path-element->bytes',
302
+ 'path-element->string', 'path-for-some-system?',
303
+ 'path-list-string->path-list', 'path-replace-suffix',
304
+ 'path-string?', 'path?', 'peek-byte', 'peek-byte-or-special',
305
+ 'peek-bytes', 'peek-bytes!', 'peek-bytes-avail!',
306
+ 'peek-bytes-avail!*', 'peek-bytes-avail!/enable-break',
307
+ 'peek-char', 'peek-char-or-special', 'peek-string', 'peek-string!',
308
+ 'pipe-content-length', 'placeholder-get', 'placeholder-set!',
309
+ 'placeholder?', 'poll-guard-evt', 'port-closed-evt',
310
+ 'port-closed?', 'port-commit-peeked', 'port-count-lines!',
311
+ 'port-count-lines-enabled', 'port-display-handler',
312
+ 'port-file-identity', 'port-file-unlock', 'port-next-location',
313
+ 'port-print-handler', 'port-progress-evt',
314
+ 'port-provides-progress-evts?', 'port-read-handler',
315
+ 'port-try-file-lock?', 'port-write-handler', 'port-writes-atomic?',
316
+ 'port-writes-special?', 'port?', 'positive?',
317
+ 'prefab-key->struct-type', 'prefab-struct-key', 'pregexp',
318
+ 'pregexp?', 'primitive-closure?', 'primitive-result-arity',
319
+ 'primitive?', 'print', 'print-as-expression',
320
+ 'print-boolean-long-form', 'print-box', 'print-graph',
321
+ 'print-hash-table', 'print-mpair-curly-braces',
322
+ 'print-pair-curly-braces', 'print-reader-abbreviations',
323
+ 'print-struct', 'print-syntax-width', 'print-unreadable',
324
+ 'print-vector-length', 'printf', 'procedure->method',
325
+ 'procedure-arity', 'procedure-arity-includes?', 'procedure-arity?',
326
+ 'procedure-closure-contents-eq?', 'procedure-extract-target',
327
+ 'procedure-reduce-arity', 'procedure-rename',
328
+ 'procedure-struct-type?', 'procedure?', 'promise?',
329
+ 'prop:arity-string', 'prop:checked-procedure',
330
+ 'prop:custom-print-quotable', 'prop:custom-write',
331
+ 'prop:equal+hash', 'prop:evt', 'prop:exn:srclocs',
332
+ 'prop:impersonator-of', 'prop:input-port',
333
+ 'prop:liberal-define-context', 'prop:output-port',
334
+ 'prop:procedure', 'prop:rename-transformer',
335
+ 'prop:set!-transformer', 'pseudo-random-generator->vector',
336
+ 'pseudo-random-generator-vector?', 'pseudo-random-generator?',
337
+ 'putenv', 'quotient', 'quotient/remainder', 'raise',
338
+ 'raise-arity-error', 'raise-mismatch-error', 'raise-syntax-error',
339
+ 'raise-type-error', 'raise-user-error', 'random', 'random-seed',
340
+ 'rational?', 'rationalize', 'read', 'read-accept-bar-quote',
341
+ 'read-accept-box', 'read-accept-compiled', 'read-accept-dot',
342
+ 'read-accept-graph', 'read-accept-infix-dot', 'read-accept-lang',
343
+ 'read-accept-quasiquote', 'read-accept-reader', 'read-byte',
344
+ 'read-byte-or-special', 'read-bytes', 'read-bytes!',
345
+ 'read-bytes-avail!', 'read-bytes-avail!*',
346
+ 'read-bytes-avail!/enable-break', 'read-bytes-line',
347
+ 'read-case-sensitive', 'read-char', 'read-char-or-special',
348
+ 'read-curly-brace-as-paren', 'read-decimal-as-inexact',
349
+ 'read-eval-print-loop', 'read-language', 'read-line',
350
+ 'read-on-demand-source', 'read-square-bracket-as-paren',
351
+ 'read-string', 'read-string!', 'read-syntax',
352
+ 'read-syntax/recursive', 'read/recursive', 'readtable-mapping',
353
+ 'readtable?', 'real->double-flonum', 'real->floating-point-bytes',
354
+ 'real->single-flonum', 'real-part', 'real?', 'regexp',
355
+ 'regexp-match', 'regexp-match-peek', 'regexp-match-peek-immediate',
356
+ 'regexp-match-peek-positions',
357
+ 'regexp-match-peek-positions-immediate',
358
+ 'regexp-match-peek-positions-immediate/end',
359
+ 'regexp-match-peek-positions/end', 'regexp-match-positions',
360
+ 'regexp-match-positions/end', 'regexp-match/end', 'regexp-match?',
361
+ 'regexp-max-lookbehind', 'regexp-replace', 'regexp-replace*',
362
+ 'regexp?', 'relative-path?', 'remainder',
363
+ 'rename-file-or-directory', 'rename-transformer-target',
364
+ 'rename-transformer?', 'resolve-path', 'resolved-module-path-name',
365
+ 'resolved-module-path?', 'reverse', 'round', 'seconds->date',
366
+ 'security-guard?', 'semaphore-peek-evt', 'semaphore-post',
367
+ 'semaphore-try-wait?', 'semaphore-wait',
368
+ 'semaphore-wait/enable-break', 'semaphore?',
369
+ 'set!-transformer-procedure', 'set!-transformer?', 'set-box!',
370
+ 'set-mcar!', 'set-mcdr!', 'set-port-next-location!',
371
+ 'shared-bytes', 'shell-execute', 'simplify-path', 'sin',
372
+ 'single-flonum?', 'sleep', 'special-comment-value',
373
+ 'special-comment?', 'split-path', 'sqrt', 'srcloc',
374
+ 'srcloc-column', 'srcloc-line', 'srcloc-position', 'srcloc-source',
375
+ 'srcloc-span', 'srcloc?', 'string', 'string->bytes/latin-1',
376
+ 'string->bytes/locale', 'string->bytes/utf-8',
377
+ 'string->immutable-string', 'string->keyword', 'string->list',
378
+ 'string->number', 'string->path', 'string->path-element',
379
+ 'string->symbol', 'string->uninterned-symbol',
380
+ 'string->unreadable-symbol', 'string-append', 'string-ci<=?',
381
+ 'string-ci<?', 'string-ci=?', 'string-ci>=?', 'string-ci>?',
382
+ 'string-copy', 'string-copy!', 'string-downcase', 'string-fill!',
383
+ 'string-foldcase', 'string-length', 'string-locale-ci<?',
384
+ 'string-locale-ci=?', 'string-locale-ci>?',
385
+ 'string-locale-downcase', 'string-locale-upcase',
386
+ 'string-locale<?', 'string-locale=?', 'string-locale>?',
387
+ 'string-normalize-nfc', 'string-normalize-nfd',
388
+ 'string-normalize-nfkc', 'string-normalize-nfkd', 'string-ref',
389
+ 'string-set!', 'string-titlecase', 'string-upcase',
390
+ 'string-utf-8-length', 'string<=?', 'string<?', 'string=?',
391
+ 'string>=?', 'string>?', 'string?', 'struct->vector',
392
+ 'struct-accessor-procedure?', 'struct-constructor-procedure?',
393
+ 'struct-info', 'struct-mutator-procedure?',
394
+ 'struct-predicate-procedure?', 'struct-type-info',
395
+ 'struct-type-make-constructor', 'struct-type-make-predicate',
396
+ 'struct-type-property-accessor-procedure?',
397
+ 'struct-type-property?', 'struct-type?', 'struct:arity-at-least',
398
+ 'struct:date', 'struct:date*', 'struct:exn', 'struct:exn:break',
399
+ 'struct:exn:fail', 'struct:exn:fail:contract',
400
+ 'struct:exn:fail:contract:arity',
401
+ 'struct:exn:fail:contract:continuation',
402
+ 'struct:exn:fail:contract:divide-by-zero',
403
+ 'struct:exn:fail:contract:non-fixnum-result',
404
+ 'struct:exn:fail:contract:variable', 'struct:exn:fail:filesystem',
405
+ 'struct:exn:fail:filesystem:exists',
406
+ 'struct:exn:fail:filesystem:version', 'struct:exn:fail:network',
407
+ 'struct:exn:fail:out-of-memory', 'struct:exn:fail:read',
408
+ 'struct:exn:fail:read:eof', 'struct:exn:fail:read:non-char',
409
+ 'struct:exn:fail:syntax', 'struct:exn:fail:syntax:unbound',
410
+ 'struct:exn:fail:unsupported', 'struct:exn:fail:user',
411
+ 'struct:srcloc', 'struct?', 'sub1', 'subbytes', 'subprocess',
412
+ 'subprocess-group-enabled', 'subprocess-kill', 'subprocess-pid',
413
+ 'subprocess-status', 'subprocess-wait', 'subprocess?', 'substring',
414
+ 'symbol->string', 'symbol-interned?', 'symbol-unreadable?',
415
+ 'symbol?', 'sync', 'sync/enable-break', 'sync/timeout',
416
+ 'sync/timeout/enable-break', 'syntax->list', 'syntax-arm',
417
+ 'syntax-column', 'syntax-disarm', 'syntax-e', 'syntax-line',
418
+ 'syntax-local-bind-syntaxes', 'syntax-local-certifier',
419
+ 'syntax-local-context', 'syntax-local-expand-expression',
420
+ 'syntax-local-get-shadower', 'syntax-local-introduce',
421
+ 'syntax-local-lift-context', 'syntax-local-lift-expression',
422
+ 'syntax-local-lift-module-end-declaration',
423
+ 'syntax-local-lift-provide', 'syntax-local-lift-require',
424
+ 'syntax-local-lift-values-expression',
425
+ 'syntax-local-make-definition-context',
426
+ 'syntax-local-make-delta-introducer',
427
+ 'syntax-local-module-defined-identifiers',
428
+ 'syntax-local-module-exports',
429
+ 'syntax-local-module-required-identifiers', 'syntax-local-name',
430
+ 'syntax-local-phase-level',
431
+ 'syntax-local-transforming-module-provides?', 'syntax-local-value',
432
+ 'syntax-local-value/immediate', 'syntax-original?',
433
+ 'syntax-position', 'syntax-property',
434
+ 'syntax-property-symbol-keys', 'syntax-protect', 'syntax-rearm',
435
+ 'syntax-recertify', 'syntax-shift-phase-level', 'syntax-source',
436
+ 'syntax-source-module', 'syntax-span', 'syntax-taint',
437
+ 'syntax-tainted?', 'syntax-track-origin',
438
+ 'syntax-transforming-module-expression?', 'syntax-transforming?',
439
+ 'syntax?', 'system-big-endian?', 'system-idle-evt',
440
+ 'system-language+country', 'system-library-subpath',
441
+ 'system-path-convention-type', 'system-type', 'tan',
442
+ 'tcp-abandon-port', 'tcp-accept', 'tcp-accept-evt',
443
+ 'tcp-accept-ready?', 'tcp-accept/enable-break', 'tcp-addresses',
444
+ 'tcp-close', 'tcp-connect', 'tcp-connect/enable-break',
445
+ 'tcp-listen', 'tcp-listener?', 'tcp-port?', 'terminal-port?',
446
+ 'thread', 'thread-cell-ref', 'thread-cell-set!', 'thread-cell?',
447
+ 'thread-dead-evt', 'thread-dead?', 'thread-group?',
448
+ 'thread-resume', 'thread-resume-evt', 'thread-rewind-receive',
449
+ 'thread-running?', 'thread-suspend', 'thread-suspend-evt',
450
+ 'thread-wait', 'thread/suspend-to-kill', 'thread?', 'time-apply',
451
+ 'truncate', 'udp-addresses', 'udp-bind!', 'udp-bound?',
452
+ 'udp-close', 'udp-connect!', 'udp-connected?', 'udp-open-socket',
453
+ 'udp-receive!', 'udp-receive!*', 'udp-receive!-evt',
454
+ 'udp-receive!/enable-break', 'udp-receive-ready-evt', 'udp-send',
455
+ 'udp-send*', 'udp-send-evt', 'udp-send-ready-evt', 'udp-send-to',
456
+ 'udp-send-to*', 'udp-send-to-evt', 'udp-send-to/enable-break',
457
+ 'udp-send/enable-break', 'udp?', 'unbox',
458
+ 'uncaught-exception-handler', 'use-collection-link-paths',
459
+ 'use-compiled-file-paths', 'use-user-specific-search-paths',
460
+ 'values', 'variable-reference->empty-namespace',
461
+ 'variable-reference->module-base-phase',
462
+ 'variable-reference->module-declaration-inspector',
463
+ 'variable-reference->module-source',
464
+ 'variable-reference->namespace', 'variable-reference->phase',
465
+ 'variable-reference->resolved-module-path',
466
+ 'variable-reference-constant?', 'variable-reference?', 'vector',
467
+ 'vector->immutable-vector', 'vector->list',
468
+ 'vector->pseudo-random-generator',
469
+ 'vector->pseudo-random-generator!', 'vector->values',
470
+ 'vector-fill!', 'vector-immutable', 'vector-length', 'vector-ref',
471
+ 'vector-set!', 'vector-set-performance-stats!', 'vector?',
472
+ 'version', 'void', 'void?', 'weak-box-value', 'weak-box?',
473
+ 'will-execute', 'will-executor?', 'will-register',
474
+ 'will-try-execute', 'with-input-from-file', 'with-output-to-file',
475
+ 'wrap-evt', 'write', 'write-byte', 'write-bytes',
476
+ 'write-bytes-avail', 'write-bytes-avail*', 'write-bytes-avail-evt',
477
+ 'write-bytes-avail/enable-break', 'write-char', 'write-special',
478
+ 'write-special-avail*', 'write-special-evt', 'write-string', 'zero?'
479
+ ]
480
+
481
+ # From SchemeLexer
482
+ valid_name = r'[a-zA-Z0-9!$%&*+,/:<=>?@^_~|-]+'
483
+
484
+ tokens = {
485
+ 'root' : [
486
+ (r';.*$', Comment.Single),
487
+ (r'#\|[^|]+\|#', Comment.Multiline),
488
+
489
+ # whitespaces - usually not relevant
490
+ (r'\s+', Text),
491
+
492
+ ## numbers: Keep in mind Racket reader hash prefixes,
493
+ ## which can denote the base or the type. These don't map
494
+ ## neatly onto pygments token types; some judgment calls
495
+ ## here. Note that none of these regexps attempt to
496
+ ## exclude identifiers that start with a number, such as a
497
+ ## variable named "100-Continue".
498
+
499
+ # #b
500
+ (r'#b[-+]?[01]+\.[01]+', Number.Float),
501
+ (r'#b[01]+e[-+]?[01]+', Number.Float),
502
+ (r'#b[-+]?[01]/[01]+', Number),
503
+ (r'#b[-+]?[01]+', Number.Integer),
504
+ (r'#b\S*', Error),
505
+
506
+ # #d OR no hash prefix
507
+ (r'(#d)?[-+]?\d+\.\d+', Number.Float),
508
+ (r'(#d)?\d+e[-+]?\d+', Number.Float),
509
+ (r'(#d)?[-+]?\d+/\d+', Number),
510
+ (r'(#d)?[-+]?\d+', Number.Integer),
511
+ (r'#d\S*', Error),
512
+
513
+ # #e
514
+ (r'#e[-+]?\d+\.\d+', Number.Float),
515
+ (r'#e\d+e[-+]?\d+', Number.Float),
516
+ (r'#e[-+]?\d+/\d+', Number),
517
+ (r'#e[-+]?\d+', Number),
518
+ (r'#e\S*', Error),
519
+
520
+ # #i is always inexact-real, i.e. float
521
+ (r'#i[-+]?\d+\.\d+', Number.Float),
522
+ (r'#i\d+e[-+]?\d+', Number.Float),
523
+ (r'#i[-+]?\d+/\d+', Number.Float),
524
+ (r'#i[-+]?\d+', Number.Float),
525
+ (r'#i\S*', Error),
526
+
527
+ # #o
528
+ (r'#o[-+]?[0-7]+\.[0-7]+', Number.Oct),
529
+ (r'#o[0-7]+e[-+]?[0-7]+', Number.Oct),
530
+ (r'#o[-+]?[0-7]+/[0-7]+', Number.Oct),
531
+ (r'#o[-+]?[0-7]+', Number.Oct),
532
+ (r'#o\S*', Error),
533
+
534
+ # #x
535
+ (r'#x[-+]?[0-9a-fA-F]+\.[0-9a-fA-F]+', Number.Hex),
536
+ # the exponent variation (e.g. #x1e1) is N/A
537
+ (r'#x[-+]?[0-9a-fA-F]+/[0-9a-fA-F]+', Number.Hex),
538
+ (r'#x[-+]?[0-9a-fA-F]+', Number.Hex),
539
+ (r'#x\S*', Error),
540
+
541
+
542
+ # strings, symbols and characters
543
+ (r'"(\\\\|\\"|[^"])*"', String),
544
+ (r"'" + valid_name, String.Symbol),
545
+ (r"#\\([()/'\"._!§$%& ?=+-]{1}|[a-zA-Z0-9]+)", String.Char),
546
+ (r'#rx".+"', String.Regex),
547
+ (r'#px".+"', String.Regex),
548
+
549
+ # constants
550
+ (r'(#t|#f)', Name.Constant),
551
+
552
+ # keyword argument names (e.g. #:keyword)
553
+ (r'#:\S+', Keyword.Declaration),
554
+
555
+ # #lang
556
+ (r'#lang \S+', Keyword.Namespace),
557
+
558
+ # special operators
559
+ (r"('|#|`|,@|,|\.)", Operator),
560
+
561
+ # highlight the keywords
562
+ ('(%s)' % '|'.join([
563
+ re.escape(entry) + ' ' for entry in keywords]),
564
+ Keyword
565
+ ),
566
+
567
+ # first variable in a quoted string like
568
+ # '(this is syntactic sugar)
569
+ (r"(?<='\()" + valid_name, Name.Variable),
570
+ (r"(?<=#\()" + valid_name, Name.Variable),
571
+
572
+ # highlight the builtins
573
+ ("(?<=\()(%s)" % '|'.join([
574
+ re.escape(entry) + ' ' for entry in builtins]),
575
+ Name.Builtin
576
+ ),
577
+
578
+ # the remaining functions; handle both ( and [
579
+ (r'(?<=(\(|\[|\{))' + valid_name, Name.Function),
580
+
581
+ # find the remaining variables
582
+ (valid_name, Name.Variable),
583
+
584
+ # the famous parentheses!
585
+ (r'(\(|\)|\[|\]|\{|\})', Punctuation),
586
+ ],
587
+ }
588
+
589
+
590
+ class SchemeLexer(RegexLexer):
591
+ """
592
+ A Scheme lexer, parsing a stream and outputting the tokens
593
+ needed to highlight scheme code.
594
+ This lexer could be most probably easily subclassed to parse
595
+ other LISP-Dialects like Common Lisp, Emacs Lisp or AutoLisp.
596
+
597
+ This parser is checked with pastes from the LISP pastebin
598
+ at http://paste.lisp.org/ to cover as much syntax as possible.
599
+
600
+ It supports the full Scheme syntax as defined in R5RS.
601
+
602
+ *New in Pygments 0.6.*
603
+ """
604
+ name = 'Scheme'
605
+ aliases = ['scheme', 'scm']
606
+ filenames = ['*.scm', '*.ss']
607
+ mimetypes = ['text/x-scheme', 'application/x-scheme']
608
+
609
+ # list of known keywords and builtins taken form vim 6.4 scheme.vim
610
+ # syntax file.
611
+ keywords = [
612
+ 'lambda', 'define', 'if', 'else', 'cond', 'and', 'or', 'case', 'let',
613
+ 'let*', 'letrec', 'begin', 'do', 'delay', 'set!', '=>', 'quote',
614
+ 'quasiquote', 'unquote', 'unquote-splicing', 'define-syntax',
615
+ 'let-syntax', 'letrec-syntax', 'syntax-rules'
616
+ ]
617
+ builtins = [
618
+ '*', '+', '-', '/', '<', '<=', '=', '>', '>=', 'abs', 'acos', 'angle',
619
+ 'append', 'apply', 'asin', 'assoc', 'assq', 'assv', 'atan',
620
+ 'boolean?', 'caaaar', 'caaadr', 'caaar', 'caadar', 'caaddr', 'caadr',
621
+ 'caar', 'cadaar', 'cadadr', 'cadar', 'caddar', 'cadddr', 'caddr',
622
+ 'cadr', 'call-with-current-continuation', 'call-with-input-file',
623
+ 'call-with-output-file', 'call-with-values', 'call/cc', 'car',
624
+ 'cdaaar', 'cdaadr', 'cdaar', 'cdadar', 'cdaddr', 'cdadr', 'cdar',
625
+ 'cddaar', 'cddadr', 'cddar', 'cdddar', 'cddddr', 'cdddr', 'cddr',
626
+ 'cdr', 'ceiling', 'char->integer', 'char-alphabetic?', 'char-ci<=?',
627
+ 'char-ci<?', 'char-ci=?', 'char-ci>=?', 'char-ci>?', 'char-downcase',
628
+ 'char-lower-case?', 'char-numeric?', 'char-ready?', 'char-upcase',
629
+ 'char-upper-case?', 'char-whitespace?', 'char<=?', 'char<?', 'char=?',
630
+ 'char>=?', 'char>?', 'char?', 'close-input-port', 'close-output-port',
631
+ 'complex?', 'cons', 'cos', 'current-input-port', 'current-output-port',
632
+ 'denominator', 'display', 'dynamic-wind', 'eof-object?', 'eq?',
633
+ 'equal?', 'eqv?', 'eval', 'even?', 'exact->inexact', 'exact?', 'exp',
634
+ 'expt', 'floor', 'for-each', 'force', 'gcd', 'imag-part',
635
+ 'inexact->exact', 'inexact?', 'input-port?', 'integer->char',
636
+ 'integer?', 'interaction-environment', 'lcm', 'length', 'list',
637
+ 'list->string', 'list->vector', 'list-ref', 'list-tail', 'list?',
638
+ 'load', 'log', 'magnitude', 'make-polar', 'make-rectangular',
639
+ 'make-string', 'make-vector', 'map', 'max', 'member', 'memq', 'memv',
640
+ 'min', 'modulo', 'negative?', 'newline', 'not', 'null-environment',
641
+ 'null?', 'number->string', 'number?', 'numerator', 'odd?',
642
+ 'open-input-file', 'open-output-file', 'output-port?', 'pair?',
643
+ 'peek-char', 'port?', 'positive?', 'procedure?', 'quotient',
644
+ 'rational?', 'rationalize', 'read', 'read-char', 'real-part', 'real?',
645
+ 'remainder', 'reverse', 'round', 'scheme-report-environment',
646
+ 'set-car!', 'set-cdr!', 'sin', 'sqrt', 'string', 'string->list',
647
+ 'string->number', 'string->symbol', 'string-append', 'string-ci<=?',
648
+ 'string-ci<?', 'string-ci=?', 'string-ci>=?', 'string-ci>?',
649
+ 'string-copy', 'string-fill!', 'string-length', 'string-ref',
650
+ 'string-set!', 'string<=?', 'string<?', 'string=?', 'string>=?',
651
+ 'string>?', 'string?', 'substring', 'symbol->string', 'symbol?',
652
+ 'tan', 'transcript-off', 'transcript-on', 'truncate', 'values',
653
+ 'vector', 'vector->list', 'vector-fill!', 'vector-length',
654
+ 'vector-ref', 'vector-set!', 'vector?', 'with-input-from-file',
655
+ 'with-output-to-file', 'write', 'write-char', 'zero?'
656
+ ]
657
+
658
+ # valid names for identifiers
659
+ # well, names can only not consist fully of numbers
660
+ # but this should be good enough for now
661
+ valid_name = r'[a-zA-Z0-9!$%&*+,/:<=>?@^_~|-]+'
662
+
663
+ tokens = {
664
+ 'root' : [
665
+ # the comments - always starting with semicolon
666
+ # and going to the end of the line
667
+ (r';.*$', Comment.Single),
668
+
669
+ # whitespaces - usually not relevant
670
+ (r'\s+', Text),
671
+
672
+ # numbers
673
+ (r'-?\d+\.\d+', Number.Float),
674
+ (r'-?\d+', Number.Integer),
675
+ # support for uncommon kinds of numbers -
676
+ # have to figure out what the characters mean
677
+ #(r'(#e|#i|#b|#o|#d|#x)[\d.]+', Number),
678
+
679
+ # strings, symbols and characters
680
+ (r'"(\\\\|\\"|[^"])*"', String),
681
+ (r"'" + valid_name, String.Symbol),
682
+ (r"#\\([()/'\"._!§$%& ?=+-]{1}|[a-zA-Z0-9]+)", String.Char),
683
+
684
+ # constants
685
+ (r'(#t|#f)', Name.Constant),
686
+
687
+ # special operators
688
+ (r"('|#|`|,@|,|\.)", Operator),
689
+
690
+ # highlight the keywords
691
+ ('(%s)' % '|'.join([
692
+ re.escape(entry) + ' ' for entry in keywords]),
693
+ Keyword
694
+ ),
695
+
696
+ # first variable in a quoted string like
697
+ # '(this is syntactic sugar)
698
+ (r"(?<='\()" + valid_name, Name.Variable),
699
+ (r"(?<=#\()" + valid_name, Name.Variable),
700
+
701
+ # highlight the builtins
702
+ ("(?<=\()(%s)" % '|'.join([
703
+ re.escape(entry) + ' ' for entry in builtins]),
704
+ Name.Builtin
705
+ ),
706
+
707
+ # the remaining functions
708
+ (r'(?<=\()' + valid_name, Name.Function),
709
+ # find the remaining variables
710
+ (valid_name, Name.Variable),
711
+
712
+ # the famous parentheses!
713
+ (r'(\(|\))', Punctuation),
714
+ (r'(\[|\])', Punctuation),
715
+ ],
716
+ }
717
+
718
+
719
+ class CommonLispLexer(RegexLexer):
720
+ """
721
+ A Common Lisp lexer.
722
+
723
+ *New in Pygments 0.9.*
724
+ """
725
+ name = 'Common Lisp'
726
+ aliases = ['common-lisp', 'cl', 'lisp']
727
+ filenames = ['*.cl', '*.lisp', '*.el'] # use for Elisp too
728
+ mimetypes = ['text/x-common-lisp']
729
+
730
+ flags = re.IGNORECASE | re.MULTILINE
731
+
732
+ ### couple of useful regexes
733
+
734
+ # characters that are not macro-characters and can be used to begin a symbol
735
+ nonmacro = r'\\.|[a-zA-Z0-9!$%&*+-/<=>?@\[\]^_{}~]'
736
+ constituent = nonmacro + '|[#.:]'
737
+ terminated = r'(?=[ "()\'\n,;`])' # whitespace or terminating macro characters
738
+
739
+ ### symbol token, reverse-engineered from hyperspec
740
+ # Take a deep breath...
741
+ symbol = r'(\|[^|]+\||(?:%s)(?:%s)*)' % (nonmacro, constituent)
742
+
743
+ def __init__(self, **options):
744
+ from pygments.lexers._clbuiltins import BUILTIN_FUNCTIONS, \
745
+ SPECIAL_FORMS, MACROS, LAMBDA_LIST_KEYWORDS, DECLARATIONS, \
746
+ BUILTIN_TYPES, BUILTIN_CLASSES
747
+ self.builtin_function = BUILTIN_FUNCTIONS
748
+ self.special_forms = SPECIAL_FORMS
749
+ self.macros = MACROS
750
+ self.lambda_list_keywords = LAMBDA_LIST_KEYWORDS
751
+ self.declarations = DECLARATIONS
752
+ self.builtin_types = BUILTIN_TYPES
753
+ self.builtin_classes = BUILTIN_CLASSES
754
+ RegexLexer.__init__(self, **options)
755
+
756
+ def get_tokens_unprocessed(self, text):
757
+ stack = ['root']
758
+ for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack):
759
+ if token is Name.Variable:
760
+ if value in self.builtin_function:
761
+ yield index, Name.Builtin, value
762
+ continue
763
+ if value in self.special_forms:
764
+ yield index, Keyword, value
765
+ continue
766
+ if value in self.macros:
767
+ yield index, Name.Builtin, value
768
+ continue
769
+ if value in self.lambda_list_keywords:
770
+ yield index, Keyword, value
771
+ continue
772
+ if value in self.declarations:
773
+ yield index, Keyword, value
774
+ continue
775
+ if value in self.builtin_types:
776
+ yield index, Keyword.Type, value
777
+ continue
778
+ if value in self.builtin_classes:
779
+ yield index, Name.Class, value
780
+ continue
781
+ yield index, token, value
782
+
783
+ tokens = {
784
+ 'root' : [
785
+ ('', Text, 'body'),
786
+ ],
787
+ 'multiline-comment' : [
788
+ (r'#\|', Comment.Multiline, '#push'), # (cf. Hyperspec 2.4.8.19)
789
+ (r'\|#', Comment.Multiline, '#pop'),
790
+ (r'[^|#]+', Comment.Multiline),
791
+ (r'[|#]', Comment.Multiline),
792
+ ],
793
+ 'commented-form' : [
794
+ (r'\(', Comment.Preproc, '#push'),
795
+ (r'\)', Comment.Preproc, '#pop'),
796
+ (r'[^()]+', Comment.Preproc),
797
+ ],
798
+ 'body' : [
799
+ # whitespace
800
+ (r'\s+', Text),
801
+
802
+ # single-line comment
803
+ (r';.*$', Comment.Single),
804
+
805
+ # multi-line comment
806
+ (r'#\|', Comment.Multiline, 'multiline-comment'),
807
+
808
+ # encoding comment (?)
809
+ (r'#\d*Y.*$', Comment.Special),
810
+
811
+ # strings and characters
812
+ (r'"(\\.|\\\n|[^"\\])*"', String),
813
+ # quoting
814
+ (r":" + symbol, String.Symbol),
815
+ (r"::" + symbol, String.Symbol),
816
+ (r":#" + symbol, String.Symbol),
817
+ (r"'" + symbol, String.Symbol),
818
+ (r"'", Operator),
819
+ (r"`", Operator),
820
+
821
+ # decimal numbers
822
+ (r'[-+]?\d+\.?' + terminated, Number.Integer),
823
+ (r'[-+]?\d+/\d+' + terminated, Number),
824
+ (r'[-+]?(\d*\.\d+([defls][-+]?\d+)?|\d+(\.\d*)?[defls][-+]?\d+)' \
825
+ + terminated, Number.Float),
826
+
827
+ # sharpsign strings and characters
828
+ (r"#\\." + terminated, String.Char),
829
+ (r"#\\" + symbol, String.Char),
830
+
831
+ # vector
832
+ (r'#\(', Operator, 'body'),
833
+
834
+ # bitstring
835
+ (r'#\d*\*[01]*', Literal.Other),
836
+
837
+ # uninterned symbol
838
+ (r'#:' + symbol, String.Symbol),
839
+
840
+ # read-time and load-time evaluation
841
+ (r'#[.,]', Operator),
842
+
843
+ # function shorthand
844
+ (r'#\'', Name.Function),
845
+
846
+ # binary rational
847
+ (r'#[bB][+-]?[01]+(/[01]+)?', Number),
848
+
849
+ # octal rational
850
+ (r'#[oO][+-]?[0-7]+(/[0-7]+)?', Number.Oct),
851
+
852
+ # hex rational
853
+ (r'#[xX][+-]?[0-9a-fA-F]+(/[0-9a-fA-F]+)?', Number.Hex),
854
+
855
+ # radix rational
856
+ (r'#\d+[rR][+-]?[0-9a-zA-Z]+(/[0-9a-zA-Z]+)?', Number),
857
+
858
+ # complex
859
+ (r'(#[cC])(\()', bygroups(Number, Punctuation), 'body'),
860
+
861
+ # array
862
+ (r'(#\d+[aA])(\()', bygroups(Literal.Other, Punctuation), 'body'),
863
+
864
+ # structure
865
+ (r'(#[sS])(\()', bygroups(Literal.Other, Punctuation), 'body'),
866
+
867
+ # path
868
+ (r'#[pP]?"(\\.|[^"])*"', Literal.Other),
869
+
870
+ # reference
871
+ (r'#\d+=', Operator),
872
+ (r'#\d+#', Operator),
873
+
874
+ # read-time comment
875
+ (r'#+nil' + terminated + '\s*\(', Comment.Preproc, 'commented-form'),
876
+
877
+ # read-time conditional
878
+ (r'#[+-]', Operator),
879
+
880
+ # special operators that should have been parsed already
881
+ (r'(,@|,|\.)', Operator),
882
+
883
+ # special constants
884
+ (r'(t|nil)' + terminated, Name.Constant),
885
+
886
+ # functions and variables
887
+ (r'\*' + symbol + '\*', Name.Variable.Global),
888
+ (symbol, Name.Variable),
889
+
890
+ # parentheses
891
+ (r'\(', Punctuation, 'body'),
892
+ (r'\)', Punctuation, '#pop'),
893
+ ],
894
+ }
895
+
896
+
897
+ class HaskellLexer(RegexLexer):
898
+ """
899
+ A Haskell lexer based on the lexemes defined in the Haskell 98 Report.
900
+
901
+ *New in Pygments 0.8.*
902
+ """
903
+ name = 'Haskell'
904
+ aliases = ['haskell', 'hs']
905
+ filenames = ['*.hs']
906
+ mimetypes = ['text/x-haskell']
907
+
908
+ reserved = ['case','class','data','default','deriving','do','else',
909
+ 'if','in','infix[lr]?','instance',
910
+ 'let','newtype','of','then','type','where','_']
911
+ ascii = ['NUL','SOH','[SE]TX','EOT','ENQ','ACK',
912
+ 'BEL','BS','HT','LF','VT','FF','CR','S[OI]','DLE',
913
+ 'DC[1-4]','NAK','SYN','ETB','CAN',
914
+ 'EM','SUB','ESC','[FGRU]S','SP','DEL']
915
+
916
+ tokens = {
917
+ 'root': [
918
+ # Whitespace:
919
+ (r'\s+', Text),
920
+ #(r'--\s*|.*$', Comment.Doc),
921
+ (r'--(?![!#$%&*+./<=>?@\^|_~:\\]).*?$', Comment.Single),
922
+ (r'{-', Comment.Multiline, 'comment'),
923
+ # Lexemes:
924
+ # Identifiers
925
+ (r'\bimport\b', Keyword.Reserved, 'import'),
926
+ (r'\bmodule\b', Keyword.Reserved, 'module'),
927
+ (r'\berror\b', Name.Exception),
928
+ (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
929
+ (r'^[_a-z][\w\']*', Name.Function),
930
+ (r"'?[_a-z][\w']*", Name),
931
+ (r"('')?[A-Z][\w\']*", Keyword.Type),
932
+ # Operators
933
+ (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
934
+ (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
935
+ (r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators
936
+ (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators
937
+ # Numbers
938
+ (r'\d+[eE][+-]?\d+', Number.Float),
939
+ (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
940
+ (r'0[oO][0-7]+', Number.Oct),
941
+ (r'0[xX][\da-fA-F]+', Number.Hex),
942
+ (r'\d+', Number.Integer),
943
+ # Character/String Literals
944
+ (r"'", String.Char, 'character'),
945
+ (r'"', String, 'string'),
946
+ # Special
947
+ (r'\[\]', Keyword.Type),
948
+ (r'\(\)', Name.Builtin),
949
+ (r'[][(),;`{}]', Punctuation),
950
+ ],
951
+ 'import': [
952
+ # Import statements
953
+ (r'\s+', Text),
954
+ (r'"', String, 'string'),
955
+ # after "funclist" state
956
+ (r'\)', Punctuation, '#pop'),
957
+ (r'qualified\b', Keyword),
958
+ # import X as Y
959
+ (r'([A-Z][a-zA-Z0-9_.]*)(\s+)(as)(\s+)([A-Z][a-zA-Z0-9_.]*)',
960
+ bygroups(Name.Namespace, Text, Keyword, Text, Name), '#pop'),
961
+ # import X hiding (functions)
962
+ (r'([A-Z][a-zA-Z0-9_.]*)(\s+)(hiding)(\s+)(\()',
963
+ bygroups(Name.Namespace, Text, Keyword, Text, Punctuation), 'funclist'),
964
+ # import X (functions)
965
+ (r'([A-Z][a-zA-Z0-9_.]*)(\s+)(\()',
966
+ bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
967
+ # import X
968
+ (r'[a-zA-Z0-9_.]+', Name.Namespace, '#pop'),
969
+ ],
970
+ 'module': [
971
+ (r'\s+', Text),
972
+ (r'([A-Z][a-zA-Z0-9_.]*)(\s+)(\()',
973
+ bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
974
+ (r'[A-Z][a-zA-Z0-9_.]*', Name.Namespace, '#pop'),
975
+ ],
976
+ 'funclist': [
977
+ (r'\s+', Text),
978
+ (r'[A-Z][a-zA-Z0-9_]*', Keyword.Type),
979
+ (r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
980
+ (r'--.*$', Comment.Single),
981
+ (r'{-', Comment.Multiline, 'comment'),
982
+ (r',', Punctuation),
983
+ (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
984
+ # (HACK, but it makes sense to push two instances, believe me)
985
+ (r'\(', Punctuation, ('funclist', 'funclist')),
986
+ (r'\)', Punctuation, '#pop:2'),
987
+ ],
988
+ # NOTE: the next four states are shared in the AgdaLexer; make sure
989
+ # any change is compatible with Agda as well or copy over and change
990
+ 'comment': [
991
+ # Multiline Comments
992
+ (r'[^-{}]+', Comment.Multiline),
993
+ (r'{-', Comment.Multiline, '#push'),
994
+ (r'-}', Comment.Multiline, '#pop'),
995
+ (r'[-{}]', Comment.Multiline),
996
+ ],
997
+ 'character': [
998
+ # Allows multi-chars, incorrectly.
999
+ (r"[^\\']", String.Char),
1000
+ (r"\\", String.Escape, 'escape'),
1001
+ ("'", String.Char, '#pop'),
1002
+ ],
1003
+ 'string': [
1004
+ (r'[^\\"]+', String),
1005
+ (r"\\", String.Escape, 'escape'),
1006
+ ('"', String, '#pop'),
1007
+ ],
1008
+ 'escape': [
1009
+ (r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
1010
+ (r'\^[][A-Z@\^_]', String.Escape, '#pop'),
1011
+ ('|'.join(ascii), String.Escape, '#pop'),
1012
+ (r'o[0-7]+', String.Escape, '#pop'),
1013
+ (r'x[\da-fA-F]+', String.Escape, '#pop'),
1014
+ (r'\d+', String.Escape, '#pop'),
1015
+ (r'\s+\\', String.Escape, '#pop'),
1016
+ ],
1017
+ }
1018
+
1019
+
1020
+ class AgdaLexer(RegexLexer):
1021
+ """
1022
+ For the `Agda <http://wiki.portal.chalmers.se/agda/pmwiki.php>`_
1023
+ dependently typed functional programming language and proof assistant.
1024
+
1025
+ *New in Pygments 1.7.*
1026
+ """
1027
+
1028
+ name = 'Agda'
1029
+ aliases = ['agda']
1030
+ filenames = ['*.agda']
1031
+ mimetypes = ['text/x-agda']
1032
+
1033
+ reserved = ['abstract', 'codata', 'coinductive', 'constructor', 'data',
1034
+ 'field', 'forall', 'hiding', 'in', 'inductive', 'infix',
1035
+ 'infixl', 'infixr', 'let', 'open', 'pattern', 'primitive',
1036
+ 'private', 'mutual', 'quote', 'quoteGoal', 'quoteTerm',
1037
+ 'record', 'syntax', 'rewrite', 'unquote', 'using', 'where',
1038
+ 'with']
1039
+
1040
+ tokens = {
1041
+ 'root': [
1042
+ # Declaration
1043
+ (r'^(\s*)([^\s\(\)\{\}]+)(\s*)(:)(\s*)',
1044
+ bygroups(Text, Name.Function, Text, Operator.Word, Text)),
1045
+ # Comments
1046
+ (r'--(?![!#$%&*+./<=>?@\^|_~:\\]).*?$', Comment.Single),
1047
+ (r'{-', Comment.Multiline, 'comment'),
1048
+ # Holes
1049
+ (r'{!', Comment.Directive, 'hole'),
1050
+ # Lexemes:
1051
+ # Identifiers
1052
+ (ur'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
1053
+ (r'(import|module)(\s+)', bygroups(Keyword.Reserved, Text), 'module'),
1054
+ (r'\b(Set|Prop)\b', Keyword.Type),
1055
+ # Special Symbols
1056
+ (r'(\(|\)|\{|\})', Operator),
1057
+ (ur'(\.{1,3}|\||[\u039B]|[\u2200]|[\u2192]|:|=|->)', Operator.Word),
1058
+ # Numbers
1059
+ (r'\d+[eE][+-]?\d+', Number.Float),
1060
+ (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
1061
+ (r'0[xX][\da-fA-F]+', Number.Hex),
1062
+ (r'\d+', Number.Integer),
1063
+ # Strings
1064
+ (r"'", String.Char, 'character'),
1065
+ (r'"', String, 'string'),
1066
+ (r'[^\s\(\)\{\}]+', Text),
1067
+ (r'\s+?', Text), # Whitespace
1068
+ ],
1069
+ 'hole': [
1070
+ # Holes
1071
+ (r'[^!{}]+', Comment.Directive),
1072
+ (r'{!', Comment.Directive, '#push'),
1073
+ (r'!}', Comment.Directive, '#pop'),
1074
+ (r'[!{}]', Comment.Directive),
1075
+ ],
1076
+ 'module': [
1077
+ (r'{-', Comment.Multiline, 'comment'),
1078
+ (r'[a-zA-Z][a-zA-Z0-9_.]*', Name, '#pop'),
1079
+ (r'[^a-zA-Z]*', Text)
1080
+ ],
1081
+ 'comment': HaskellLexer.tokens['comment'],
1082
+ 'character': HaskellLexer.tokens['character'],
1083
+ 'string': HaskellLexer.tokens['string'],
1084
+ 'escape': HaskellLexer.tokens['escape']
1085
+ }
1086
+
1087
+
1088
+ class LiterateLexer(Lexer):
1089
+ """
1090
+ Base class for lexers of literate file formats based on LaTeX or Bird-style
1091
+ (prefixing each code line with ">").
1092
+
1093
+ Additional options accepted:
1094
+
1095
+ `litstyle`
1096
+ If given, must be ``"bird"`` or ``"latex"``. If not given, the style
1097
+ is autodetected: if the first non-whitespace character in the source
1098
+ is a backslash or percent character, LaTeX is assumed, else Bird.
1099
+ """
1100
+
1101
+ bird_re = re.compile(r'(>[ \t]*)(.*\n)')
1102
+
1103
+ def __init__(self, baselexer, **options):
1104
+ self.baselexer = baselexer
1105
+ Lexer.__init__(self, **options)
1106
+
1107
+ def get_tokens_unprocessed(self, text):
1108
+ style = self.options.get('litstyle')
1109
+ if style is None:
1110
+ style = (text.lstrip()[0:1] in '%\\') and 'latex' or 'bird'
1111
+
1112
+ code = ''
1113
+ insertions = []
1114
+ if style == 'bird':
1115
+ # bird-style
1116
+ for match in line_re.finditer(text):
1117
+ line = match.group()
1118
+ m = self.bird_re.match(line)
1119
+ if m:
1120
+ insertions.append((len(code),
1121
+ [(0, Comment.Special, m.group(1))]))
1122
+ code += m.group(2)
1123
+ else:
1124
+ insertions.append((len(code), [(0, Text, line)]))
1125
+ else:
1126
+ # latex-style
1127
+ from pygments.lexers.text import TexLexer
1128
+ lxlexer = TexLexer(**self.options)
1129
+ codelines = 0
1130
+ latex = ''
1131
+ for match in line_re.finditer(text):
1132
+ line = match.group()
1133
+ if codelines:
1134
+ if line.lstrip().startswith('\\end{code}'):
1135
+ codelines = 0
1136
+ latex += line
1137
+ else:
1138
+ code += line
1139
+ elif line.lstrip().startswith('\\begin{code}'):
1140
+ codelines = 1
1141
+ latex += line
1142
+ insertions.append((len(code),
1143
+ list(lxlexer.get_tokens_unprocessed(latex))))
1144
+ latex = ''
1145
+ else:
1146
+ latex += line
1147
+ insertions.append((len(code),
1148
+ list(lxlexer.get_tokens_unprocessed(latex))))
1149
+ for item in do_insertions(insertions, self.baselexer.get_tokens_unprocessed(code)):
1150
+ yield item
1151
+
1152
+
1153
+ class LiterateHaskellLexer(LiterateLexer):
1154
+ """
1155
+ For Literate Haskell (Bird-style or LaTeX) source.
1156
+
1157
+ Additional options accepted:
1158
+
1159
+ `litstyle`
1160
+ If given, must be ``"bird"`` or ``"latex"``. If not given, the style
1161
+ is autodetected: if the first non-whitespace character in the source
1162
+ is a backslash or percent character, LaTeX is assumed, else Bird.
1163
+
1164
+ *New in Pygments 0.9.*
1165
+ """
1166
+ name = 'Literate Haskell'
1167
+ aliases = ['lhs', 'literate-haskell', 'lhaskell']
1168
+ filenames = ['*.lhs']
1169
+ mimetypes = ['text/x-literate-haskell']
1170
+
1171
+ def __init__(self, **options):
1172
+ hslexer = HaskellLexer(**options)
1173
+ LiterateLexer.__init__(self, hslexer, **options)
1174
+
1175
+
1176
+ class LiterateAgdaLexer(LiterateLexer):
1177
+ """
1178
+ For Literate Agda source.
1179
+
1180
+ Additional options accepted:
1181
+
1182
+ `litstyle`
1183
+ If given, must be ``"bird"`` or ``"latex"``. If not given, the style
1184
+ is autodetected: if the first non-whitespace character in the source
1185
+ is a backslash or percent character, LaTeX is assumed, else Bird.
1186
+
1187
+ *New in Pygments 1.7.*
1188
+ """
1189
+ name = 'Literate Agda'
1190
+ aliases = ['lagda', 'literate-agda']
1191
+ filenames = ['*.lagda']
1192
+ mimetypes = ['text/x-literate-agda']
1193
+
1194
+ def __init__(self, **options):
1195
+ agdalexer = AgdaLexer(**options)
1196
+ LiterateLexer.__init__(self, agdalexer, litstyle='latex', **options)
1197
+
1198
+
1199
+ class SMLLexer(RegexLexer):
1200
+ """
1201
+ For the Standard ML language.
1202
+
1203
+ *New in Pygments 1.5.*
1204
+ """
1205
+
1206
+ name = 'Standard ML'
1207
+ aliases = ['sml']
1208
+ filenames = ['*.sml', '*.sig', '*.fun',]
1209
+ mimetypes = ['text/x-standardml', 'application/x-standardml']
1210
+
1211
+ alphanumid_reserved = [
1212
+ # Core
1213
+ 'abstype', 'and', 'andalso', 'as', 'case', 'datatype', 'do', 'else',
1214
+ 'end', 'exception', 'fn', 'fun', 'handle', 'if', 'in', 'infix',
1215
+ 'infixr', 'let', 'local', 'nonfix', 'of', 'op', 'open', 'orelse',
1216
+ 'raise', 'rec', 'then', 'type', 'val', 'with', 'withtype', 'while',
1217
+ # Modules
1218
+ 'eqtype', 'functor', 'include', 'sharing', 'sig', 'signature',
1219
+ 'struct', 'structure', 'where',
1220
+ ]
1221
+
1222
+ symbolicid_reserved = [
1223
+ # Core
1224
+ ':', '\|', '=', '=>', '->', '#',
1225
+ # Modules
1226
+ ':>',
1227
+ ]
1228
+
1229
+ nonid_reserved = [ '(', ')', '[', ']', '{', '}', ',', ';', '...', '_' ]
1230
+
1231
+ alphanumid_re = r"[a-zA-Z][a-zA-Z0-9_']*"
1232
+ symbolicid_re = r"[!%&$#+\-/:<=>?@\\~`^|*]+"
1233
+
1234
+ # A character constant is a sequence of the form #s, where s is a string
1235
+ # constant denoting a string of size one character. This setup just parses
1236
+ # the entire string as either a String.Double or a String.Char (depending
1237
+ # on the argument), even if the String.Char is an erronous
1238
+ # multiple-character string.
1239
+ def stringy (whatkind):
1240
+ return [
1241
+ (r'[^"\\]', whatkind),
1242
+ (r'\\[\\\"abtnvfr]', String.Escape),
1243
+ # Control-character notation is used for codes < 32,
1244
+ # where \^@ == \000
1245
+ (r'\\\^[\x40-\x5e]', String.Escape),
1246
+ # Docs say 'decimal digits'
1247
+ (r'\\[0-9]{3}', String.Escape),
1248
+ (r'\\u[0-9a-fA-F]{4}', String.Escape),
1249
+ (r'\\\s+\\', String.Interpol),
1250
+ (r'"', whatkind, '#pop'),
1251
+ ]
1252
+
1253
+ # Callbacks for distinguishing tokens and reserved words
1254
+ def long_id_callback(self, match):
1255
+ if match.group(1) in self.alphanumid_reserved: token = Error
1256
+ else: token = Name.Namespace
1257
+ yield match.start(1), token, match.group(1)
1258
+ yield match.start(2), Punctuation, match.group(2)
1259
+
1260
+ def end_id_callback(self, match):
1261
+ if match.group(1) in self.alphanumid_reserved: token = Error
1262
+ elif match.group(1) in self.symbolicid_reserved: token = Error
1263
+ else: token = Name
1264
+ yield match.start(1), token, match.group(1)
1265
+
1266
+ def id_callback(self, match):
1267
+ str = match.group(1)
1268
+ if str in self.alphanumid_reserved: token = Keyword.Reserved
1269
+ elif str in self.symbolicid_reserved: token = Punctuation
1270
+ else: token = Name
1271
+ yield match.start(1), token, str
1272
+
1273
+ tokens = {
1274
+ # Whitespace and comments are (almost) everywhere
1275
+ 'whitespace': [
1276
+ (r'\s+', Text),
1277
+ (r'\(\*', Comment.Multiline, 'comment'),
1278
+ ],
1279
+
1280
+ 'delimiters': [
1281
+ # This lexer treats these delimiters specially:
1282
+ # Delimiters define scopes, and the scope is how the meaning of
1283
+ # the `|' is resolved - is it a case/handle expression, or function
1284
+ # definition by cases? (This is not how the Definition works, but
1285
+ # it's how MLton behaves, see http://mlton.org/SMLNJDeviations)
1286
+ (r'\(|\[|{', Punctuation, 'main'),
1287
+ (r'\)|\]|}', Punctuation, '#pop'),
1288
+ (r'\b(let|if|local)\b(?!\')', Keyword.Reserved, ('main', 'main')),
1289
+ (r'\b(struct|sig|while)\b(?!\')', Keyword.Reserved, 'main'),
1290
+ (r'\b(do|else|end|in|then)\b(?!\')', Keyword.Reserved, '#pop'),
1291
+ ],
1292
+
1293
+ 'core': [
1294
+ # Punctuation that doesn't overlap symbolic identifiers
1295
+ (r'(%s)' % '|'.join([re.escape(z) for z in nonid_reserved]),
1296
+ Punctuation),
1297
+
1298
+ # Special constants: strings, floats, numbers in decimal and hex
1299
+ (r'#"', String.Char, 'char'),
1300
+ (r'"', String.Double, 'string'),
1301
+ (r'~?0x[0-9a-fA-F]+', Number.Hex),
1302
+ (r'0wx[0-9a-fA-F]+', Number.Hex),
1303
+ (r'0w\d+', Number.Integer),
1304
+ (r'~?\d+\.\d+[eE]~?\d+', Number.Float),
1305
+ (r'~?\d+\.\d+', Number.Float),
1306
+ (r'~?\d+[eE]~?\d+', Number.Float),
1307
+ (r'~?\d+', Number.Integer),
1308
+
1309
+ # Labels
1310
+ (r'#\s*[1-9][0-9]*', Name.Label),
1311
+ (r'#\s*(%s)' % alphanumid_re, Name.Label),
1312
+ (r'#\s+(%s)' % symbolicid_re, Name.Label),
1313
+ # Some reserved words trigger a special, local lexer state change
1314
+ (r'\b(datatype|abstype)\b(?!\')', Keyword.Reserved, 'dname'),
1315
+ (r'(?=\b(exception)\b(?!\'))', Text, ('ename')),
1316
+ (r'\b(functor|include|open|signature|structure)\b(?!\')',
1317
+ Keyword.Reserved, 'sname'),
1318
+ (r'\b(type|eqtype)\b(?!\')', Keyword.Reserved, 'tname'),
1319
+
1320
+ # Regular identifiers, long and otherwise
1321
+ (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
1322
+ (r'(%s)(\.)' % alphanumid_re, long_id_callback, "dotted"),
1323
+ (r'(%s)' % alphanumid_re, id_callback),
1324
+ (r'(%s)' % symbolicid_re, id_callback),
1325
+ ],
1326
+ 'dotted': [
1327
+ (r'(%s)(\.)' % alphanumid_re, long_id_callback),
1328
+ (r'(%s)' % alphanumid_re, end_id_callback, "#pop"),
1329
+ (r'(%s)' % symbolicid_re, end_id_callback, "#pop"),
1330
+ (r'\s+', Error),
1331
+ (r'\S+', Error),
1332
+ ],
1333
+
1334
+
1335
+ # Main parser (prevents errors in files that have scoping errors)
1336
+ 'root': [ (r'', Text, 'main') ],
1337
+
1338
+ # In this scope, I expect '|' to not be followed by a function name,
1339
+ # and I expect 'and' to be followed by a binding site
1340
+ 'main': [
1341
+ include('whitespace'),
1342
+
1343
+ # Special behavior of val/and/fun
1344
+ (r'\b(val|and)\b(?!\')', Keyword.Reserved, 'vname'),
1345
+ (r'\b(fun)\b(?!\')', Keyword.Reserved,
1346
+ ('#pop', 'main-fun', 'fname')),
1347
+
1348
+ include('delimiters'),
1349
+ include('core'),
1350
+ (r'\S+', Error),
1351
+ ],
1352
+
1353
+ # In this scope, I expect '|' and 'and' to be followed by a function
1354
+ 'main-fun': [
1355
+ include('whitespace'),
1356
+
1357
+ (r'\s', Text),
1358
+ (r'\(\*', Comment.Multiline, 'comment'),
1359
+
1360
+ # Special behavior of val/and/fun
1361
+ (r'\b(fun|and)\b(?!\')', Keyword.Reserved, 'fname'),
1362
+ (r'\b(val)\b(?!\')', Keyword.Reserved,
1363
+ ('#pop', 'main', 'vname')),
1364
+
1365
+ # Special behavior of '|' and '|'-manipulating keywords
1366
+ (r'\|', Punctuation, 'fname'),
1367
+ (r'\b(case|handle)\b(?!\')', Keyword.Reserved,
1368
+ ('#pop', 'main')),
1369
+
1370
+ include('delimiters'),
1371
+ include('core'),
1372
+ (r'\S+', Error),
1373
+ ],
1374
+
1375
+ # Character and string parsers
1376
+ 'char': stringy(String.Char),
1377
+ 'string': stringy(String.Double),
1378
+
1379
+ 'breakout': [
1380
+ (r'(?=\b(%s)\b(?!\'))' % '|'.join(alphanumid_reserved), Text, '#pop'),
1381
+ ],
1382
+
1383
+ # Dealing with what comes after module system keywords
1384
+ 'sname': [
1385
+ include('whitespace'),
1386
+ include('breakout'),
1387
+
1388
+ (r'(%s)' % alphanumid_re, Name.Namespace),
1389
+ (r'', Text, '#pop'),
1390
+ ],
1391
+
1392
+ # Dealing with what comes after the 'fun' (or 'and' or '|') keyword
1393
+ 'fname': [
1394
+ include('whitespace'),
1395
+ (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
1396
+ (r'\(', Punctuation, 'tyvarseq'),
1397
+
1398
+ (r'(%s)' % alphanumid_re, Name.Function, '#pop'),
1399
+ (r'(%s)' % symbolicid_re, Name.Function, '#pop'),
1400
+
1401
+ # Ignore interesting function declarations like "fun (x + y) = ..."
1402
+ (r'', Text, '#pop'),
1403
+ ],
1404
+
1405
+ # Dealing with what comes after the 'val' (or 'and') keyword
1406
+ 'vname': [
1407
+ include('whitespace'),
1408
+ (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
1409
+ (r'\(', Punctuation, 'tyvarseq'),
1410
+
1411
+ (r'(%s)(\s*)(=(?!%s))' % (alphanumid_re, symbolicid_re),
1412
+ bygroups(Name.Variable, Text, Punctuation), '#pop'),
1413
+ (r'(%s)(\s*)(=(?!%s))' % (symbolicid_re, symbolicid_re),
1414
+ bygroups(Name.Variable, Text, Punctuation), '#pop'),
1415
+ (r'(%s)' % alphanumid_re, Name.Variable, '#pop'),
1416
+ (r'(%s)' % symbolicid_re, Name.Variable, '#pop'),
1417
+
1418
+ # Ignore interesting patterns like 'val (x, y)'
1419
+ (r'', Text, '#pop'),
1420
+ ],
1421
+
1422
+ # Dealing with what comes after the 'type' (or 'and') keyword
1423
+ 'tname': [
1424
+ include('whitespace'),
1425
+ include('breakout'),
1426
+
1427
+ (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
1428
+ (r'\(', Punctuation, 'tyvarseq'),
1429
+ (r'=(?!%s)' % symbolicid_re, Punctuation, ('#pop', 'typbind')),
1430
+
1431
+ (r'(%s)' % alphanumid_re, Keyword.Type),
1432
+ (r'(%s)' % symbolicid_re, Keyword.Type),
1433
+ (r'\S+', Error, '#pop'),
1434
+ ],
1435
+
1436
+ # A type binding includes most identifiers
1437
+ 'typbind': [
1438
+ include('whitespace'),
1439
+
1440
+ (r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')),
1441
+
1442
+ include('breakout'),
1443
+ include('core'),
1444
+ (r'\S+', Error, '#pop'),
1445
+ ],
1446
+
1447
+ # Dealing with what comes after the 'datatype' (or 'and') keyword
1448
+ 'dname': [
1449
+ include('whitespace'),
1450
+ include('breakout'),
1451
+
1452
+ (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
1453
+ (r'\(', Punctuation, 'tyvarseq'),
1454
+ (r'(=)(\s*)(datatype)',
1455
+ bygroups(Punctuation, Text, Keyword.Reserved), '#pop'),
1456
+ (r'=(?!%s)' % symbolicid_re, Punctuation,
1457
+ ('#pop', 'datbind', 'datcon')),
1458
+
1459
+ (r'(%s)' % alphanumid_re, Keyword.Type),
1460
+ (r'(%s)' % symbolicid_re, Keyword.Type),
1461
+ (r'\S+', Error, '#pop'),
1462
+ ],
1463
+
1464
+ # common case - A | B | C of int
1465
+ 'datbind': [
1466
+ include('whitespace'),
1467
+
1468
+ (r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'dname')),
1469
+ (r'\b(withtype)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')),
1470
+ (r'\b(of)\b(?!\')', Keyword.Reserved),
1471
+
1472
+ (r'(\|)(\s*)(%s)' % alphanumid_re,
1473
+ bygroups(Punctuation, Text, Name.Class)),
1474
+ (r'(\|)(\s+)(%s)' % symbolicid_re,
1475
+ bygroups(Punctuation, Text, Name.Class)),
1476
+
1477
+ include('breakout'),
1478
+ include('core'),
1479
+ (r'\S+', Error),
1480
+ ],
1481
+
1482
+ # Dealing with what comes after an exception
1483
+ 'ename': [
1484
+ include('whitespace'),
1485
+
1486
+ (r'(exception|and)\b(\s+)(%s)' % alphanumid_re,
1487
+ bygroups(Keyword.Reserved, Text, Name.Class)),
1488
+ (r'(exception|and)\b(\s*)(%s)' % symbolicid_re,
1489
+ bygroups(Keyword.Reserved, Text, Name.Class)),
1490
+ (r'\b(of)\b(?!\')', Keyword.Reserved),
1491
+
1492
+ include('breakout'),
1493
+ include('core'),
1494
+ (r'\S+', Error),
1495
+ ],
1496
+
1497
+ 'datcon': [
1498
+ include('whitespace'),
1499
+ (r'(%s)' % alphanumid_re, Name.Class, '#pop'),
1500
+ (r'(%s)' % symbolicid_re, Name.Class, '#pop'),
1501
+ (r'\S+', Error, '#pop'),
1502
+ ],
1503
+
1504
+ # Series of type variables
1505
+ 'tyvarseq': [
1506
+ (r'\s', Text),
1507
+ (r'\(\*', Comment.Multiline, 'comment'),
1508
+
1509
+ (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
1510
+ (alphanumid_re, Name),
1511
+ (r',', Punctuation),
1512
+ (r'\)', Punctuation, '#pop'),
1513
+ (symbolicid_re, Name),
1514
+ ],
1515
+
1516
+ 'comment': [
1517
+ (r'[^(*)]', Comment.Multiline),
1518
+ (r'\(\*', Comment.Multiline, '#push'),
1519
+ (r'\*\)', Comment.Multiline, '#pop'),
1520
+ (r'[(*)]', Comment.Multiline),
1521
+ ],
1522
+ }
1523
+
1524
+
1525
+ class OcamlLexer(RegexLexer):
1526
+ """
1527
+ For the OCaml language.
1528
+
1529
+ *New in Pygments 0.7.*
1530
+ """
1531
+
1532
+ name = 'OCaml'
1533
+ aliases = ['ocaml']
1534
+ filenames = ['*.ml', '*.mli', '*.mll', '*.mly']
1535
+ mimetypes = ['text/x-ocaml']
1536
+
1537
+ keywords = [
1538
+ 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done',
1539
+ 'downto', 'else', 'end', 'exception', 'external', 'false',
1540
+ 'for', 'fun', 'function', 'functor', 'if', 'in', 'include',
1541
+ 'inherit', 'initializer', 'lazy', 'let', 'match', 'method',
1542
+ 'module', 'mutable', 'new', 'object', 'of', 'open', 'private',
1543
+ 'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try',
1544
+ 'type', 'value', 'val', 'virtual', 'when', 'while', 'with',
1545
+ ]
1546
+ keyopts = [
1547
+ '!=','#','&','&&','\(','\)','\*','\+',',','-',
1548
+ '-\.','->','\.','\.\.',':','::',':=',':>',';',';;','<',
1549
+ '<-','=','>','>]','>}','\?','\?\?','\[','\[<','\[>','\[\|',
1550
+ ']','_','`','{','{<','\|','\|]','}','~'
1551
+ ]
1552
+
1553
+ operators = r'[!$%&*+\./:<=>?@^|~-]'
1554
+ word_operators = ['and', 'asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'or']
1555
+ prefix_syms = r'[!?~]'
1556
+ infix_syms = r'[=<>@^|&+\*/$%-]'
1557
+ primitives = ['unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array']
1558
+
1559
+ tokens = {
1560
+ 'escape-sequence': [
1561
+ (r'\\[\\\"\'ntbr]', String.Escape),
1562
+ (r'\\[0-9]{3}', String.Escape),
1563
+ (r'\\x[0-9a-fA-F]{2}', String.Escape),
1564
+ ],
1565
+ 'root': [
1566
+ (r'\s+', Text),
1567
+ (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo),
1568
+ (r'\b([A-Z][A-Za-z0-9_\']*)(?=\s*\.)',
1569
+ Name.Namespace, 'dotted'),
1570
+ (r'\b([A-Z][A-Za-z0-9_\']*)', Name.Class),
1571
+ (r'\(\*(?![)])', Comment, 'comment'),
1572
+ (r'\b(%s)\b' % '|'.join(keywords), Keyword),
1573
+ (r'(%s)' % '|'.join(keyopts[::-1]), Operator),
1574
+ (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
1575
+ (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word),
1576
+ (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
1577
+
1578
+ (r"[^\W\d][\w']*", Name),
1579
+
1580
+ (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
1581
+ (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
1582
+ (r'0[oO][0-7][0-7_]*', Number.Oct),
1583
+ (r'0[bB][01][01_]*', Number.Binary),
1584
+ (r'\d[\d_]*', Number.Integer),
1585
+
1586
+ (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
1587
+ String.Char),
1588
+ (r"'.'", String.Char),
1589
+ (r"'", Keyword), # a stray quote is another syntax element
1590
+
1591
+ (r'"', String.Double, 'string'),
1592
+
1593
+ (r'[~?][a-z][\w\']*:', Name.Variable),
1594
+ ],
1595
+ 'comment': [
1596
+ (r'[^(*)]+', Comment),
1597
+ (r'\(\*', Comment, '#push'),
1598
+ (r'\*\)', Comment, '#pop'),
1599
+ (r'[(*)]', Comment),
1600
+ ],
1601
+ 'string': [
1602
+ (r'[^\\"]+', String.Double),
1603
+ include('escape-sequence'),
1604
+ (r'\\\n', String.Double),
1605
+ (r'"', String.Double, '#pop'),
1606
+ ],
1607
+ 'dotted': [
1608
+ (r'\s+', Text),
1609
+ (r'\.', Punctuation),
1610
+ (r'[A-Z][A-Za-z0-9_\']*(?=\s*\.)', Name.Namespace),
1611
+ (r'[A-Z][A-Za-z0-9_\']*', Name.Class, '#pop'),
1612
+ (r'[a-z_][A-Za-z0-9_\']*', Name, '#pop'),
1613
+ ],
1614
+ }
1615
+
1616
+
1617
+ class ErlangLexer(RegexLexer):
1618
+ """
1619
+ For the Erlang functional programming language.
1620
+
1621
+ Blame Jeremy Thurgood (http://jerith.za.net/).
1622
+
1623
+ *New in Pygments 0.9.*
1624
+ """
1625
+
1626
+ name = 'Erlang'
1627
+ aliases = ['erlang']
1628
+ filenames = ['*.erl', '*.hrl', '*.es', '*.escript']
1629
+ mimetypes = ['text/x-erlang']
1630
+
1631
+ keywords = [
1632
+ 'after', 'begin', 'case', 'catch', 'cond', 'end', 'fun', 'if',
1633
+ 'let', 'of', 'query', 'receive', 'try', 'when',
1634
+ ]
1635
+
1636
+ builtins = [ # See erlang(3) man page
1637
+ 'abs', 'append_element', 'apply', 'atom_to_list', 'binary_to_list',
1638
+ 'bitstring_to_list', 'binary_to_term', 'bit_size', 'bump_reductions',
1639
+ 'byte_size', 'cancel_timer', 'check_process_code', 'delete_module',
1640
+ 'demonitor', 'disconnect_node', 'display', 'element', 'erase', 'exit',
1641
+ 'float', 'float_to_list', 'fun_info', 'fun_to_list',
1642
+ 'function_exported', 'garbage_collect', 'get', 'get_keys',
1643
+ 'group_leader', 'hash', 'hd', 'integer_to_list', 'iolist_to_binary',
1644
+ 'iolist_size', 'is_atom', 'is_binary', 'is_bitstring', 'is_boolean',
1645
+ 'is_builtin', 'is_float', 'is_function', 'is_integer', 'is_list',
1646
+ 'is_number', 'is_pid', 'is_port', 'is_process_alive', 'is_record',
1647
+ 'is_reference', 'is_tuple', 'length', 'link', 'list_to_atom',
1648
+ 'list_to_binary', 'list_to_bitstring', 'list_to_existing_atom',
1649
+ 'list_to_float', 'list_to_integer', 'list_to_pid', 'list_to_tuple',
1650
+ 'load_module', 'localtime_to_universaltime', 'make_tuple', 'md5',
1651
+ 'md5_final', 'md5_update', 'memory', 'module_loaded', 'monitor',
1652
+ 'monitor_node', 'node', 'nodes', 'open_port', 'phash', 'phash2',
1653
+ 'pid_to_list', 'port_close', 'port_command', 'port_connect',
1654
+ 'port_control', 'port_call', 'port_info', 'port_to_list',
1655
+ 'process_display', 'process_flag', 'process_info', 'purge_module',
1656
+ 'put', 'read_timer', 'ref_to_list', 'register', 'resume_process',
1657
+ 'round', 'send', 'send_after', 'send_nosuspend', 'set_cookie',
1658
+ 'setelement', 'size', 'spawn', 'spawn_link', 'spawn_monitor',
1659
+ 'spawn_opt', 'split_binary', 'start_timer', 'statistics',
1660
+ 'suspend_process', 'system_flag', 'system_info', 'system_monitor',
1661
+ 'system_profile', 'term_to_binary', 'tl', 'trace', 'trace_delivered',
1662
+ 'trace_info', 'trace_pattern', 'trunc', 'tuple_size', 'tuple_to_list',
1663
+ 'universaltime_to_localtime', 'unlink', 'unregister', 'whereis'
1664
+ ]
1665
+
1666
+ operators = r'(\+\+?|--?|\*|/|<|>|/=|=:=|=/=|=<|>=|==?|<-|!|\?)'
1667
+ word_operators = [
1668
+ 'and', 'andalso', 'band', 'bnot', 'bor', 'bsl', 'bsr', 'bxor',
1669
+ 'div', 'not', 'or', 'orelse', 'rem', 'xor'
1670
+ ]
1671
+
1672
+ atom_re = r"(?:[a-z][a-zA-Z0-9_]*|'[^\n']*[^\\]')"
1673
+
1674
+ variable_re = r'(?:[A-Z_][a-zA-Z0-9_]*)'
1675
+
1676
+ escape_re = r'(?:\\(?:[bdefnrstv\'"\\/]|[0-7][0-7]?[0-7]?|\^[a-zA-Z]))'
1677
+
1678
+ macro_re = r'(?:'+variable_re+r'|'+atom_re+r')'
1679
+
1680
+ base_re = r'(?:[2-9]|[12][0-9]|3[0-6])'
1681
+
1682
+ tokens = {
1683
+ 'root': [
1684
+ (r'\s+', Text),
1685
+ (r'%.*\n', Comment),
1686
+ ('(' + '|'.join(keywords) + r')\b', Keyword),
1687
+ ('(' + '|'.join(builtins) + r')\b', Name.Builtin),
1688
+ ('(' + '|'.join(word_operators) + r')\b', Operator.Word),
1689
+ (r'^-', Punctuation, 'directive'),
1690
+ (operators, Operator),
1691
+ (r'"', String, 'string'),
1692
+ (r'<<', Name.Label),
1693
+ (r'>>', Name.Label),
1694
+ ('(' + atom_re + ')(:)', bygroups(Name.Namespace, Punctuation)),
1695
+ ('(?:^|(?<=:))(' + atom_re + r')(\s*)(\()',
1696
+ bygroups(Name.Function, Text, Punctuation)),
1697
+ (r'[+-]?'+base_re+r'#[0-9a-zA-Z]+', Number.Integer),
1698
+ (r'[+-]?\d+', Number.Integer),
1699
+ (r'[+-]?\d+.\d+', Number.Float),
1700
+ (r'[]\[:_@\".{}()|;,]', Punctuation),
1701
+ (variable_re, Name.Variable),
1702
+ (atom_re, Name),
1703
+ (r'\?'+macro_re, Name.Constant),
1704
+ (r'\$(?:'+escape_re+r'|\\[ %]|[^\\])', String.Char),
1705
+ (r'#'+atom_re+r'(:?\.'+atom_re+r')?', Name.Label),
1706
+ ],
1707
+ 'string': [
1708
+ (escape_re, String.Escape),
1709
+ (r'"', String, '#pop'),
1710
+ (r'~[0-9.*]*[~#+bBcdefginpPswWxX]', String.Interpol),
1711
+ (r'[^"\\~]+', String),
1712
+ (r'~', String),
1713
+ ],
1714
+ 'directive': [
1715
+ (r'(define)(\s*)(\()('+macro_re+r')',
1716
+ bygroups(Name.Entity, Text, Punctuation, Name.Constant), '#pop'),
1717
+ (r'(record)(\s*)(\()('+macro_re+r')',
1718
+ bygroups(Name.Entity, Text, Punctuation, Name.Label), '#pop'),
1719
+ (atom_re, Name.Entity, '#pop'),
1720
+ ],
1721
+ }
1722
+
1723
+
1724
+ class ErlangShellLexer(Lexer):
1725
+ """
1726
+ Shell sessions in erl (for Erlang code).
1727
+
1728
+ *New in Pygments 1.1.*
1729
+ """
1730
+ name = 'Erlang erl session'
1731
+ aliases = ['erl']
1732
+ filenames = ['*.erl-sh']
1733
+ mimetypes = ['text/x-erl-shellsession']
1734
+
1735
+ _prompt_re = re.compile(r'\d+>(?=\s|\Z)')
1736
+
1737
+ def get_tokens_unprocessed(self, text):
1738
+ erlexer = ErlangLexer(**self.options)
1739
+
1740
+ curcode = ''
1741
+ insertions = []
1742
+ for match in line_re.finditer(text):
1743
+ line = match.group()
1744
+ m = self._prompt_re.match(line)
1745
+ if m is not None:
1746
+ end = m.end()
1747
+ insertions.append((len(curcode),
1748
+ [(0, Generic.Prompt, line[:end])]))
1749
+ curcode += line[end:]
1750
+ else:
1751
+ if curcode:
1752
+ for item in do_insertions(insertions,
1753
+ erlexer.get_tokens_unprocessed(curcode)):
1754
+ yield item
1755
+ curcode = ''
1756
+ insertions = []
1757
+ if line.startswith('*'):
1758
+ yield match.start(), Generic.Traceback, line
1759
+ else:
1760
+ yield match.start(), Generic.Output, line
1761
+ if curcode:
1762
+ for item in do_insertions(insertions,
1763
+ erlexer.get_tokens_unprocessed(curcode)):
1764
+ yield item
1765
+
1766
+
1767
+ class OpaLexer(RegexLexer):
1768
+ """
1769
+ Lexer for the Opa language (http://opalang.org).
1770
+
1771
+ *New in Pygments 1.5.*
1772
+ """
1773
+
1774
+ name = 'Opa'
1775
+ aliases = ['opa']
1776
+ filenames = ['*.opa']
1777
+ mimetypes = ['text/x-opa']
1778
+
1779
+ # most of these aren't strictly keywords
1780
+ # but if you color only real keywords, you might just
1781
+ # as well not color anything
1782
+ keywords = [
1783
+ 'and', 'as', 'begin', 'case', 'client', 'css', 'database', 'db', 'do',
1784
+ 'else', 'end', 'external', 'forall', 'function', 'if', 'import',
1785
+ 'match', 'module', 'or', 'package', 'parser', 'rec', 'server', 'then',
1786
+ 'type', 'val', 'with', 'xml_parser',
1787
+ ]
1788
+
1789
+ # matches both stuff and `stuff`
1790
+ ident_re = r'(([a-zA-Z_]\w*)|(`[^`]*`))'
1791
+
1792
+ op_re = r'[.=\-<>,@~%/+?*&^!]'
1793
+ punc_re = r'[()\[\],;|]' # '{' and '}' are treated elsewhere
1794
+ # because they are also used for inserts
1795
+
1796
+ tokens = {
1797
+ # copied from the caml lexer, should be adapted
1798
+ 'escape-sequence': [
1799
+ (r'\\[\\\"\'ntr}]', String.Escape),
1800
+ (r'\\[0-9]{3}', String.Escape),
1801
+ (r'\\x[0-9a-fA-F]{2}', String.Escape),
1802
+ ],
1803
+
1804
+ # factorizing these rules, because they are inserted many times
1805
+ 'comments': [
1806
+ (r'/\*', Comment, 'nested-comment'),
1807
+ (r'//.*?$', Comment),
1808
+ ],
1809
+ 'comments-and-spaces': [
1810
+ include('comments'),
1811
+ (r'\s+', Text),
1812
+ ],
1813
+
1814
+ 'root': [
1815
+ include('comments-and-spaces'),
1816
+ # keywords
1817
+ (r'\b(%s)\b' % '|'.join(keywords), Keyword),
1818
+ # directives
1819
+ # we could parse the actual set of directives instead of anything
1820
+ # starting with @, but this is troublesome
1821
+ # because it needs to be adjusted all the time
1822
+ # and assuming we parse only sources that compile, it is useless
1823
+ (r'@'+ident_re+r'\b', Name.Builtin.Pseudo),
1824
+
1825
+ # number literals
1826
+ (r'-?.[\d]+([eE][+\-]?\d+)', Number.Float),
1827
+ (r'-?\d+.\d*([eE][+\-]?\d+)', Number.Float),
1828
+ (r'-?\d+[eE][+\-]?\d+', Number.Float),
1829
+ (r'0[xX][\da-fA-F]+', Number.Hex),
1830
+ (r'0[oO][0-7]+', Number.Oct),
1831
+ (r'0[bB][01]+', Number.Binary),
1832
+ (r'\d+', Number.Integer),
1833
+ # color literals
1834
+ (r'#[\da-fA-F]{3,6}', Number.Integer),
1835
+
1836
+ # string literals
1837
+ (r'"', String.Double, 'string'),
1838
+ # char literal, should be checked because this is the regexp from
1839
+ # the caml lexer
1840
+ (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2})|.)'",
1841
+ String.Char),
1842
+
1843
+ # this is meant to deal with embedded exprs in strings
1844
+ # every time we find a '}' we pop a state so that if we were
1845
+ # inside a string, we are back in the string state
1846
+ # as a consequence, we must also push a state every time we find a
1847
+ # '{' or else we will have errors when parsing {} for instance
1848
+ (r'{', Operator, '#push'),
1849
+ (r'}', Operator, '#pop'),
1850
+
1851
+ # html literals
1852
+ # this is a much more strict that the actual parser,
1853
+ # since a<b would not be parsed as html
1854
+ # but then again, the parser is way too lax, and we can't hope
1855
+ # to have something as tolerant
1856
+ (r'<(?=[a-zA-Z>])', String.Single, 'html-open-tag'),
1857
+
1858
+ # db path
1859
+ # matching the '[_]' in '/a[_]' because it is a part
1860
+ # of the syntax of the db path definition
1861
+ # unfortunately, i don't know how to match the ']' in
1862
+ # /a[1], so this is somewhat inconsistent
1863
+ (r'[@?!]?(/\w+)+(\[_\])?', Name.Variable),
1864
+ # putting the same color on <- as on db path, since
1865
+ # it can be used only to mean Db.write
1866
+ (r'<-(?!'+op_re+r')', Name.Variable),
1867
+
1868
+ # 'modules'
1869
+ # although modules are not distinguished by their names as in caml
1870
+ # the standard library seems to follow the convention that modules
1871
+ # only area capitalized
1872
+ (r'\b([A-Z]\w*)(?=\.)', Name.Namespace),
1873
+
1874
+ # operators
1875
+ # = has a special role because this is the only
1876
+ # way to syntactic distinguish binding constructions
1877
+ # unfortunately, this colors the equal in {x=2} too
1878
+ (r'=(?!'+op_re+r')', Keyword),
1879
+ (r'(%s)+' % op_re, Operator),
1880
+ (r'(%s)+' % punc_re, Operator),
1881
+
1882
+ # coercions
1883
+ (r':', Operator, 'type'),
1884
+ # type variables
1885
+ # we need this rule because we don't parse specially type
1886
+ # definitions so in "type t('a) = ...", "'a" is parsed by 'root'
1887
+ ("'"+ident_re, Keyword.Type),
1888
+
1889
+ # id literal, #something, or #{expr}
1890
+ (r'#'+ident_re, String.Single),
1891
+ (r'#(?={)', String.Single),
1892
+
1893
+ # identifiers
1894
+ # this avoids to color '2' in 'a2' as an integer
1895
+ (ident_re, Text),
1896
+
1897
+ # default, not sure if that is needed or not
1898
+ # (r'.', Text),
1899
+ ],
1900
+
1901
+ # it is quite painful to have to parse types to know where they end
1902
+ # this is the general rule for a type
1903
+ # a type is either:
1904
+ # * -> ty
1905
+ # * type-with-slash
1906
+ # * type-with-slash -> ty
1907
+ # * type-with-slash (, type-with-slash)+ -> ty
1908
+ #
1909
+ # the code is pretty funky in here, but this code would roughly
1910
+ # translate in caml to:
1911
+ # let rec type stream =
1912
+ # match stream with
1913
+ # | [< "->"; stream >] -> type stream
1914
+ # | [< ""; stream >] ->
1915
+ # type_with_slash stream
1916
+ # type_lhs_1 stream;
1917
+ # and type_1 stream = ...
1918
+ 'type': [
1919
+ include('comments-and-spaces'),
1920
+ (r'->', Keyword.Type),
1921
+ (r'', Keyword.Type, ('#pop', 'type-lhs-1', 'type-with-slash')),
1922
+ ],
1923
+
1924
+ # parses all the atomic or closed constructions in the syntax of type
1925
+ # expressions: record types, tuple types, type constructors, basic type
1926
+ # and type variables
1927
+ 'type-1': [
1928
+ include('comments-and-spaces'),
1929
+ (r'\(', Keyword.Type, ('#pop', 'type-tuple')),
1930
+ (r'~?{', Keyword.Type, ('#pop', 'type-record')),
1931
+ (ident_re+r'\(', Keyword.Type, ('#pop', 'type-tuple')),
1932
+ (ident_re, Keyword.Type, '#pop'),
1933
+ ("'"+ident_re, Keyword.Type),
1934
+ # this case is not in the syntax but sometimes
1935
+ # we think we are parsing types when in fact we are parsing
1936
+ # some css, so we just pop the states until we get back into
1937
+ # the root state
1938
+ (r'', Keyword.Type, '#pop'),
1939
+ ],
1940
+
1941
+ # type-with-slash is either:
1942
+ # * type-1
1943
+ # * type-1 (/ type-1)+
1944
+ 'type-with-slash': [
1945
+ include('comments-and-spaces'),
1946
+ (r'', Keyword.Type, ('#pop', 'slash-type-1', 'type-1')),
1947
+ ],
1948
+ 'slash-type-1': [
1949
+ include('comments-and-spaces'),
1950
+ ('/', Keyword.Type, ('#pop', 'type-1')),
1951
+ # same remark as above
1952
+ (r'', Keyword.Type, '#pop'),
1953
+ ],
1954
+
1955
+ # we go in this state after having parsed a type-with-slash
1956
+ # while trying to parse a type
1957
+ # and at this point we must determine if we are parsing an arrow
1958
+ # type (in which case we must continue parsing) or not (in which
1959
+ # case we stop)
1960
+ 'type-lhs-1': [
1961
+ include('comments-and-spaces'),
1962
+ (r'->', Keyword.Type, ('#pop', 'type')),
1963
+ (r'(?=,)', Keyword.Type, ('#pop', 'type-arrow')),
1964
+ (r'', Keyword.Type, '#pop'),
1965
+ ],
1966
+ 'type-arrow': [
1967
+ include('comments-and-spaces'),
1968
+ # the look ahead here allows to parse f(x : int, y : float -> truc)
1969
+ # correctly
1970
+ (r',(?=[^:]*?->)', Keyword.Type, 'type-with-slash'),
1971
+ (r'->', Keyword.Type, ('#pop', 'type')),
1972
+ # same remark as above
1973
+ (r'', Keyword.Type, '#pop'),
1974
+ ],
1975
+
1976
+ # no need to do precise parsing for tuples and records
1977
+ # because they are closed constructions, so we can simply
1978
+ # find the closing delimiter
1979
+ # note that this function would be not work if the source
1980
+ # contained identifiers like `{)` (although it could be patched
1981
+ # to support it)
1982
+ 'type-tuple': [
1983
+ include('comments-and-spaces'),
1984
+ (r'[^\(\)/*]+', Keyword.Type),
1985
+ (r'[/*]', Keyword.Type),
1986
+ (r'\(', Keyword.Type, '#push'),
1987
+ (r'\)', Keyword.Type, '#pop'),
1988
+ ],
1989
+ 'type-record': [
1990
+ include('comments-and-spaces'),
1991
+ (r'[^{}/*]+', Keyword.Type),
1992
+ (r'[/*]', Keyword.Type),
1993
+ (r'{', Keyword.Type, '#push'),
1994
+ (r'}', Keyword.Type, '#pop'),
1995
+ ],
1996
+
1997
+ # 'type-tuple': [
1998
+ # include('comments-and-spaces'),
1999
+ # (r'\)', Keyword.Type, '#pop'),
2000
+ # (r'', Keyword.Type, ('#pop', 'type-tuple-1', 'type-1')),
2001
+ # ],
2002
+ # 'type-tuple-1': [
2003
+ # include('comments-and-spaces'),
2004
+ # (r',?\s*\)', Keyword.Type, '#pop'), # ,) is a valid end of tuple, in (1,)
2005
+ # (r',', Keyword.Type, 'type-1'),
2006
+ # ],
2007
+ # 'type-record':[
2008
+ # include('comments-and-spaces'),
2009
+ # (r'}', Keyword.Type, '#pop'),
2010
+ # (r'~?(?:\w+|`[^`]*`)', Keyword.Type, 'type-record-field-expr'),
2011
+ # ],
2012
+ # 'type-record-field-expr': [
2013
+ #
2014
+ # ],
2015
+
2016
+ 'nested-comment': [
2017
+ (r'[^/*]+', Comment),
2018
+ (r'/\*', Comment, '#push'),
2019
+ (r'\*/', Comment, '#pop'),
2020
+ (r'[/*]', Comment),
2021
+ ],
2022
+
2023
+ # the copy pasting between string and single-string
2024
+ # is kinda sad. Is there a way to avoid that??
2025
+ 'string': [
2026
+ (r'[^\\"{]+', String.Double),
2027
+ (r'"', String.Double, '#pop'),
2028
+ (r'{', Operator, 'root'),
2029
+ include('escape-sequence'),
2030
+ ],
2031
+ 'single-string': [
2032
+ (r'[^\\\'{]+', String.Double),
2033
+ (r'\'', String.Double, '#pop'),
2034
+ (r'{', Operator, 'root'),
2035
+ include('escape-sequence'),
2036
+ ],
2037
+
2038
+ # all the html stuff
2039
+ # can't really reuse some existing html parser
2040
+ # because we must be able to parse embedded expressions
2041
+
2042
+ # we are in this state after someone parsed the '<' that
2043
+ # started the html literal
2044
+ 'html-open-tag': [
2045
+ (r'[\w\-:]+', String.Single, ('#pop', 'html-attr')),
2046
+ (r'>', String.Single, ('#pop', 'html-content')),
2047
+ ],
2048
+
2049
+ # we are in this state after someone parsed the '</' that
2050
+ # started the end of the closing tag
2051
+ 'html-end-tag': [
2052
+ # this is a star, because </> is allowed
2053
+ (r'[\w\-:]*>', String.Single, '#pop'),
2054
+ ],
2055
+
2056
+ # we are in this state after having parsed '<ident(:ident)?'
2057
+ # we thus parse a possibly empty list of attributes
2058
+ 'html-attr': [
2059
+ (r'\s+', Text),
2060
+ (r'[\w\-:]+=', String.Single, 'html-attr-value'),
2061
+ (r'/>', String.Single, '#pop'),
2062
+ (r'>', String.Single, ('#pop', 'html-content')),
2063
+ ],
2064
+
2065
+ 'html-attr-value': [
2066
+ (r"'", String.Single, ('#pop', 'single-string')),
2067
+ (r'"', String.Single, ('#pop', 'string')),
2068
+ (r'#'+ident_re, String.Single, '#pop'),
2069
+ (r'#(?={)', String.Single, ('#pop', 'root')),
2070
+ (r'[^"\'{`=<>]+', String.Single, '#pop'),
2071
+ (r'{', Operator, ('#pop', 'root')), # this is a tail call!
2072
+ ],
2073
+
2074
+ # we should probably deal with '\' escapes here
2075
+ 'html-content': [
2076
+ (r'<!--', Comment, 'html-comment'),
2077
+ (r'</', String.Single, ('#pop', 'html-end-tag')),
2078
+ (r'<', String.Single, 'html-open-tag'),
2079
+ (r'{', Operator, 'root'),
2080
+ (r'[^<{]+', String.Single),
2081
+ ],
2082
+
2083
+ 'html-comment': [
2084
+ (r'-->', Comment, '#pop'),
2085
+ (r'[^\-]+|-', Comment),
2086
+ ],
2087
+ }
2088
+
2089
+
2090
+ class CoqLexer(RegexLexer):
2091
+ """
2092
+ For the `Coq <http://coq.inria.fr/>`_ theorem prover.
2093
+
2094
+ *New in Pygments 1.5.*
2095
+ """
2096
+
2097
+ name = 'Coq'
2098
+ aliases = ['coq']
2099
+ filenames = ['*.v']
2100
+ mimetypes = ['text/x-coq']
2101
+
2102
+ keywords1 = [
2103
+ # Vernacular commands
2104
+ 'Section', 'Module', 'End', 'Require', 'Import', 'Export', 'Variable',
2105
+ 'Variables', 'Parameter', 'Parameters', 'Axiom', 'Hypothesis',
2106
+ 'Hypotheses', 'Notation', 'Local', 'Tactic', 'Reserved', 'Scope',
2107
+ 'Open', 'Close', 'Bind', 'Delimit', 'Definition', 'Let', 'Ltac',
2108
+ 'Fixpoint', 'CoFixpoint', 'Morphism', 'Relation', 'Implicit',
2109
+ 'Arguments', 'Set', 'Unset', 'Contextual', 'Strict', 'Prenex',
2110
+ 'Implicits', 'Inductive', 'CoInductive', 'Record', 'Structure',
2111
+ 'Canonical', 'Coercion', 'Theorem', 'Lemma', 'Corollary',
2112
+ 'Proposition', 'Fact', 'Remark', 'Example', 'Proof', 'Goal', 'Save',
2113
+ 'Qed', 'Defined', 'Hint', 'Resolve', 'Rewrite', 'View', 'Search',
2114
+ 'Show', 'Print', 'Printing', 'All', 'Graph', 'Projections', 'inside',
2115
+ 'outside',
2116
+ ]
2117
+ keywords2 = [
2118
+ # Gallina
2119
+ 'forall', 'exists', 'exists2', 'fun', 'fix', 'cofix', 'struct',
2120
+ 'match', 'end', 'in', 'return', 'let', 'if', 'is', 'then', 'else',
2121
+ 'for', 'of', 'nosimpl', 'with', 'as',
2122
+ ]
2123
+ keywords3 = [
2124
+ # Sorts
2125
+ 'Type', 'Prop',
2126
+ ]
2127
+ keywords4 = [
2128
+ # Tactics
2129
+ 'pose', 'set', 'move', 'case', 'elim', 'apply', 'clear', 'hnf', 'intro',
2130
+ 'intros', 'generalize', 'rename', 'pattern', 'after', 'destruct',
2131
+ 'induction', 'using', 'refine', 'inversion', 'injection', 'rewrite',
2132
+ 'congr', 'unlock', 'compute', 'ring', 'field', 'replace', 'fold',
2133
+ 'unfold', 'change', 'cutrewrite', 'simpl', 'have', 'suff', 'wlog',
2134
+ 'suffices', 'without', 'loss', 'nat_norm', 'assert', 'cut', 'trivial',
2135
+ 'revert', 'bool_congr', 'nat_congr', 'symmetry', 'transitivity', 'auto',
2136
+ 'split', 'left', 'right', 'autorewrite',
2137
+ ]
2138
+ keywords5 = [
2139
+ # Terminators
2140
+ 'by', 'done', 'exact', 'reflexivity', 'tauto', 'romega', 'omega',
2141
+ 'assumption', 'solve', 'contradiction', 'discriminate',
2142
+ ]
2143
+ keywords6 = [
2144
+ # Control
2145
+ 'do', 'last', 'first', 'try', 'idtac', 'repeat',
2146
+ ]
2147
+ # 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done',
2148
+ # 'downto', 'else', 'end', 'exception', 'external', 'false',
2149
+ # 'for', 'fun', 'function', 'functor', 'if', 'in', 'include',
2150
+ # 'inherit', 'initializer', 'lazy', 'let', 'match', 'method',
2151
+ # 'module', 'mutable', 'new', 'object', 'of', 'open', 'private',
2152
+ # 'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try',
2153
+ # 'type', 'val', 'virtual', 'when', 'while', 'with'
2154
+ keyopts = [
2155
+ '!=', '#', '&', '&&', r'\(', r'\)', r'\*', r'\+', ',', '-',
2156
+ r'-\.', '->', r'\.', r'\.\.', ':', '::', ':=', ':>', ';', ';;', '<',
2157
+ '<-', '=', '>', '>]', '>}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>',
2158
+ r'\[\|', ']', '_', '`', '{', '{<', r'\|', r'\|]', '}', '~', '=>',
2159
+ r'/\\', r'\\/',
2160
+ u'Π', u'λ',
2161
+ ]
2162
+ operators = r'[!$%&*+\./:<=>?@^|~-]'
2163
+ word_operators = ['and', 'asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'or']
2164
+ prefix_syms = r'[!?~]'
2165
+ infix_syms = r'[=<>@^|&+\*/$%-]'
2166
+ primitives = ['unit', 'int', 'float', 'bool', 'string', 'char', 'list',
2167
+ 'array']
2168
+
2169
+ tokens = {
2170
+ 'root': [
2171
+ (r'\s+', Text),
2172
+ (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo),
2173
+ (r'\(\*', Comment, 'comment'),
2174
+ (r'\b(%s)\b' % '|'.join(keywords1), Keyword.Namespace),
2175
+ (r'\b(%s)\b' % '|'.join(keywords2), Keyword),
2176
+ (r'\b(%s)\b' % '|'.join(keywords3), Keyword.Type),
2177
+ (r'\b(%s)\b' % '|'.join(keywords4), Keyword),
2178
+ (r'\b(%s)\b' % '|'.join(keywords5), Keyword.Pseudo),
2179
+ (r'\b(%s)\b' % '|'.join(keywords6), Keyword.Reserved),
2180
+ (r'\b([A-Z][A-Za-z0-9_\']*)(?=\s*\.)',
2181
+ Name.Namespace, 'dotted'),
2182
+ (r'\b([A-Z][A-Za-z0-9_\']*)', Name.Class),
2183
+ (r'(%s)' % '|'.join(keyopts[::-1]), Operator),
2184
+ (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
2185
+ (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word),
2186
+ (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
2187
+
2188
+ (r"[^\W\d][\w']*", Name),
2189
+
2190
+ (r'\d[\d_]*', Number.Integer),
2191
+ (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
2192
+ (r'0[oO][0-7][0-7_]*', Number.Oct),
2193
+ (r'0[bB][01][01_]*', Number.Binary),
2194
+ (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
2195
+
2196
+ (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
2197
+ String.Char),
2198
+ (r"'.'", String.Char),
2199
+ (r"'", Keyword), # a stray quote is another syntax element
2200
+
2201
+ (r'"', String.Double, 'string'),
2202
+
2203
+ (r'[~?][a-z][\w\']*:', Name.Variable),
2204
+ ],
2205
+ 'comment': [
2206
+ (r'[^(*)]+', Comment),
2207
+ (r'\(\*', Comment, '#push'),
2208
+ (r'\*\)', Comment, '#pop'),
2209
+ (r'[(*)]', Comment),
2210
+ ],
2211
+ 'string': [
2212
+ (r'[^"]+', String.Double),
2213
+ (r'""', String.Double),
2214
+ (r'"', String.Double, '#pop'),
2215
+ ],
2216
+ 'dotted': [
2217
+ (r'\s+', Text),
2218
+ (r'\.', Punctuation),
2219
+ (r'[A-Z][A-Za-z0-9_\']*(?=\s*\.)', Name.Namespace),
2220
+ (r'[A-Z][A-Za-z0-9_\']*', Name.Class, '#pop'),
2221
+ (r'[a-z][a-z0-9_\']*', Name, '#pop'),
2222
+ (r'', Text, '#pop')
2223
+ ],
2224
+ }
2225
+
2226
+ def analyse_text(text):
2227
+ if text.startswith('(*'):
2228
+ return True
2229
+
2230
+
2231
+ class NewLispLexer(RegexLexer):
2232
+ """
2233
+ For `newLISP. <www.newlisp.org>`_ source code (version 10.3.0).
2234
+
2235
+ *New in Pygments 1.5.*
2236
+ """
2237
+
2238
+ name = 'NewLisp'
2239
+ aliases = ['newlisp']
2240
+ filenames = ['*.lsp', '*.nl']
2241
+ mimetypes = ['text/x-newlisp', 'application/x-newlisp']
2242
+
2243
+ flags = re.IGNORECASE | re.MULTILINE | re.UNICODE
2244
+
2245
+ # list of built-in functions for newLISP version 10.3
2246
+ builtins = [
2247
+ '^', '--', '-', ':', '!', '!=', '?', '@', '*', '/', '&', '%', '+', '++',
2248
+ '<', '<<', '<=', '=', '>', '>=', '>>', '|', '~', '$', '$0', '$1', '$10',
2249
+ '$11', '$12', '$13', '$14', '$15', '$2', '$3', '$4', '$5', '$6', '$7',
2250
+ '$8', '$9', '$args', '$idx', '$it', '$main-args', 'abort', 'abs',
2251
+ 'acos', 'acosh', 'add', 'address', 'amb', 'and', 'and', 'append-file',
2252
+ 'append', 'apply', 'args', 'array-list', 'array?', 'array', 'asin',
2253
+ 'asinh', 'assoc', 'atan', 'atan2', 'atanh', 'atom?', 'base64-dec',
2254
+ 'base64-enc', 'bayes-query', 'bayes-train', 'begin', 'begin', 'begin',
2255
+ 'beta', 'betai', 'bind', 'binomial', 'bits', 'callback', 'case', 'case',
2256
+ 'case', 'catch', 'ceil', 'change-dir', 'char', 'chop', 'Class', 'clean',
2257
+ 'close', 'command-event', 'cond', 'cond', 'cond', 'cons', 'constant',
2258
+ 'context?', 'context', 'copy-file', 'copy', 'cos', 'cosh', 'count',
2259
+ 'cpymem', 'crc32', 'crit-chi2', 'crit-z', 'current-line', 'curry',
2260
+ 'date-list', 'date-parse', 'date-value', 'date', 'debug', 'dec',
2261
+ 'def-new', 'default', 'define-macro', 'define-macro', 'define',
2262
+ 'delete-file', 'delete-url', 'delete', 'destroy', 'det', 'device',
2263
+ 'difference', 'directory?', 'directory', 'div', 'do-until', 'do-while',
2264
+ 'doargs', 'dolist', 'dostring', 'dotimes', 'dotree', 'dump', 'dup',
2265
+ 'empty?', 'encrypt', 'ends-with', 'env', 'erf', 'error-event',
2266
+ 'eval-string', 'eval', 'exec', 'exists', 'exit', 'exp', 'expand',
2267
+ 'explode', 'extend', 'factor', 'fft', 'file-info', 'file?', 'filter',
2268
+ 'find-all', 'find', 'first', 'flat', 'float?', 'float', 'floor', 'flt',
2269
+ 'fn', 'for-all', 'for', 'fork', 'format', 'fv', 'gammai', 'gammaln',
2270
+ 'gcd', 'get-char', 'get-float', 'get-int', 'get-long', 'get-string',
2271
+ 'get-url', 'global?', 'global', 'if-not', 'if', 'ifft', 'import', 'inc',
2272
+ 'index', 'inf?', 'int', 'integer?', 'integer', 'intersect', 'invert',
2273
+ 'irr', 'join', 'lambda-macro', 'lambda?', 'lambda', 'last-error',
2274
+ 'last', 'legal?', 'length', 'let', 'let', 'let', 'letex', 'letn',
2275
+ 'letn', 'letn', 'list?', 'list', 'load', 'local', 'log', 'lookup',
2276
+ 'lower-case', 'macro?', 'main-args', 'MAIN', 'make-dir', 'map', 'mat',
2277
+ 'match', 'max', 'member', 'min', 'mod', 'module', 'mul', 'multiply',
2278
+ 'NaN?', 'net-accept', 'net-close', 'net-connect', 'net-error',
2279
+ 'net-eval', 'net-interface', 'net-ipv', 'net-listen', 'net-local',
2280
+ 'net-lookup', 'net-packet', 'net-peek', 'net-peer', 'net-ping',
2281
+ 'net-receive-from', 'net-receive-udp', 'net-receive', 'net-select',
2282
+ 'net-send-to', 'net-send-udp', 'net-send', 'net-service',
2283
+ 'net-sessions', 'new', 'nil?', 'nil', 'normal', 'not', 'now', 'nper',
2284
+ 'npv', 'nth', 'null?', 'number?', 'open', 'or', 'ostype', 'pack',
2285
+ 'parse-date', 'parse', 'peek', 'pipe', 'pmt', 'pop-assoc', 'pop',
2286
+ 'post-url', 'pow', 'prefix', 'pretty-print', 'primitive?', 'print',
2287
+ 'println', 'prob-chi2', 'prob-z', 'process', 'prompt-event',
2288
+ 'protected?', 'push', 'put-url', 'pv', 'quote?', 'quote', 'rand',
2289
+ 'random', 'randomize', 'read', 'read-char', 'read-expr', 'read-file',
2290
+ 'read-key', 'read-line', 'read-utf8', 'read', 'reader-event',
2291
+ 'real-path', 'receive', 'ref-all', 'ref', 'regex-comp', 'regex',
2292
+ 'remove-dir', 'rename-file', 'replace', 'reset', 'rest', 'reverse',
2293
+ 'rotate', 'round', 'save', 'search', 'seed', 'seek', 'select', 'self',
2294
+ 'semaphore', 'send', 'sequence', 'series', 'set-locale', 'set-ref-all',
2295
+ 'set-ref', 'set', 'setf', 'setq', 'sgn', 'share', 'signal', 'silent',
2296
+ 'sin', 'sinh', 'sleep', 'slice', 'sort', 'source', 'spawn', 'sqrt',
2297
+ 'starts-with', 'string?', 'string', 'sub', 'swap', 'sym', 'symbol?',
2298
+ 'symbols', 'sync', 'sys-error', 'sys-info', 'tan', 'tanh', 'term',
2299
+ 'throw-error', 'throw', 'time-of-day', 'time', 'timer', 'title-case',
2300
+ 'trace-highlight', 'trace', 'transpose', 'Tree', 'trim', 'true?',
2301
+ 'true', 'unicode', 'unify', 'unique', 'unless', 'unpack', 'until',
2302
+ 'upper-case', 'utf8', 'utf8len', 'uuid', 'wait-pid', 'when', 'while',
2303
+ 'write', 'write-char', 'write-file', 'write-line', 'write',
2304
+ 'xfer-event', 'xml-error', 'xml-parse', 'xml-type-tags', 'zero?',
2305
+ ]
2306
+
2307
+ # valid names
2308
+ valid_name = r'([a-zA-Z0-9!$%&*+.,/<=>?@^_~|-])+|(\[.*?\])+'
2309
+
2310
+ tokens = {
2311
+ 'root': [
2312
+ # shebang
2313
+ (r'#!(.*?)$', Comment.Preproc),
2314
+ # comments starting with semicolon
2315
+ (r';.*$', Comment.Single),
2316
+ # comments starting with #
2317
+ (r'#.*$', Comment.Single),
2318
+
2319
+ # whitespace
2320
+ (r'\s+', Text),
2321
+
2322
+ # strings, symbols and characters
2323
+ (r'"(\\\\|\\"|[^"])*"', String),
2324
+
2325
+ # braces
2326
+ (r"{", String, "bracestring"),
2327
+
2328
+ # [text] ... [/text] delimited strings
2329
+ (r'\[text\]*', String, "tagstring"),
2330
+
2331
+ # 'special' operators...
2332
+ (r"('|:)", Operator),
2333
+
2334
+ # highlight the builtins
2335
+ ('(%s)' % '|'.join(re.escape(entry) + '\\b' for entry in builtins),
2336
+ Keyword),
2337
+
2338
+ # the remaining functions
2339
+ (r'(?<=\()' + valid_name, Name.Variable),
2340
+
2341
+ # the remaining variables
2342
+ (valid_name, String.Symbol),
2343
+
2344
+ # parentheses
2345
+ (r'(\(|\))', Punctuation),
2346
+ ],
2347
+
2348
+ # braced strings...
2349
+ 'bracestring': [
2350
+ ("{", String, "#push"),
2351
+ ("}", String, "#pop"),
2352
+ ("[^{}]+", String),
2353
+ ],
2354
+
2355
+ # tagged [text]...[/text] delimited strings...
2356
+ 'tagstring': [
2357
+ (r'(?s)(.*?)(\[/text\])', String, '#pop'),
2358
+ ],
2359
+ }
2360
+
2361
+
2362
+ class ElixirLexer(RegexLexer):
2363
+ """
2364
+ For the `Elixir language <http://elixir-lang.org>`_.
2365
+
2366
+ *New in Pygments 1.5.*
2367
+ """
2368
+
2369
+ name = 'Elixir'
2370
+ aliases = ['elixir', 'ex', 'exs']
2371
+ filenames = ['*.ex', '*.exs']
2372
+ mimetypes = ['text/x-elixir']
2373
+
2374
+ def gen_elixir_sigil_rules():
2375
+ states = {}
2376
+
2377
+ states['strings'] = [
2378
+ (r'(%[A-Ba-z])?"""(?:.|\n)*?"""', String.Doc),
2379
+ (r"'''(?:.|\n)*?'''", String.Doc),
2380
+ (r'"', String.Double, 'dqs'),
2381
+ (r"'.*'", String.Single),
2382
+ (r'(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b|'
2383
+ r'[^x0MC])|(\\[MC]-)+\w|[^\s\\])', String.Other)
2384
+ ]
2385
+
2386
+ for lbrace, rbrace, name, in ('\\{', '\\}', 'cb'), \
2387
+ ('\\[', '\\]', 'sb'), \
2388
+ ('\\(', '\\)', 'pa'), \
2389
+ ('\\<', '\\>', 'lt'):
2390
+
2391
+ states['strings'] += [
2392
+ (r'%[a-z]' + lbrace, String.Double, name + 'intp'),
2393
+ (r'%[A-Z]' + lbrace, String.Double, name + 'no-intp')
2394
+ ]
2395
+
2396
+ states[name +'intp'] = [
2397
+ (r'' + rbrace + '[a-z]*', String.Double, "#pop"),
2398
+ include('enddoublestr')
2399
+ ]
2400
+
2401
+ states[name +'no-intp'] = [
2402
+ (r'.*' + rbrace + '[a-z]*', String.Double , "#pop")
2403
+ ]
2404
+
2405
+ return states
2406
+
2407
+ tokens = {
2408
+ 'root': [
2409
+ (r'\s+', Text),
2410
+ (r'#.*$', Comment.Single),
2411
+ (r'\b(case|cond|end|bc|lc|if|unless|try|loop|receive|fn|defmodule|'
2412
+ r'defp?|defprotocol|defimpl|defrecord|defmacrop?|defdelegate|'
2413
+ r'defexception|exit|raise|throw|unless|after|rescue|catch|else)\b(?![?!])|'
2414
+ r'(?<!\.)\b(do|\-\>)\b\s*', Keyword),
2415
+ (r'\b(import|require|use|recur|quote|unquote|super|refer)\b(?![?!])',
2416
+ Keyword.Namespace),
2417
+ (r'(?<!\.)\b(and|not|or|when|xor|in)\b', Operator.Word),
2418
+ (r'%=|\*=|\*\*=|\+=|\-=|\^=|\|\|=|'
2419
+ r'<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?=[ \t])\?|'
2420
+ r'(?<=[ \t])!+|&&|\|\||\^|\*|\+|\-|/|'
2421
+ r'\||\+\+|\-\-|\*\*|\/\/|\<\-|\<\>|<<|>>|=|\.', Operator),
2422
+ (r'(?<!:)(:)([a-zA-Z_]\w*([?!]|=(?![>=]))?|\<\>|===?|>=?|<=?|'
2423
+ r'<=>|&&?|%\(\)|%\[\]|%\{\}|\+\+?|\-\-?|\|\|?|\!|//|[%&`/\|]|'
2424
+ r'\*\*?|=?~|<\-)|([a-zA-Z_]\w*([?!])?)(:)(?!:)', String.Symbol),
2425
+ (r':"', String.Symbol, 'interpoling_symbol'),
2426
+ (r'\b(nil|true|false)\b(?![?!])|\b[A-Z]\w*\b', Name.Constant),
2427
+ (r'\b(__(FILE|LINE|MODULE|MAIN|FUNCTION)__)\b(?![?!])', Name.Builtin.Pseudo),
2428
+ (r'[a-zA-Z_!][\w_]*[!\?]?', Name),
2429
+ (r'[(){};,/\|:\\\[\]]', Punctuation),
2430
+ (r'@[a-zA-Z_]\w*|&\d', Name.Variable),
2431
+ (r'\b(0[xX][0-9A-Fa-f]+|\d(_?\d)*(\.(?![^\d\s])'
2432
+ r'(_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b', Number),
2433
+ (r'%r\/.*\/', String.Regex),
2434
+ include('strings'),
2435
+ ],
2436
+ 'dqs': [
2437
+ (r'"', String.Double, "#pop"),
2438
+ include('enddoublestr')
2439
+ ],
2440
+ 'interpoling': [
2441
+ (r'#{', String.Interpol, 'interpoling_string'),
2442
+ ],
2443
+ 'interpoling_string' : [
2444
+ (r'}', String.Interpol, "#pop"),
2445
+ include('root')
2446
+ ],
2447
+ 'interpoling_symbol': [
2448
+ (r'"', String.Symbol, "#pop"),
2449
+ include('interpoling'),
2450
+ (r'[^#"]+', String.Symbol),
2451
+ ],
2452
+ 'enddoublestr' : [
2453
+ include('interpoling'),
2454
+ (r'[^#"]+', String.Double),
2455
+ ]
2456
+ }
2457
+ tokens.update(gen_elixir_sigil_rules())
2458
+
2459
+
2460
+ class ElixirConsoleLexer(Lexer):
2461
+ """
2462
+ For Elixir interactive console (iex) output like:
2463
+
2464
+ .. sourcecode:: iex
2465
+
2466
+ iex> [head | tail] = [1,2,3]
2467
+ [1,2,3]
2468
+ iex> head
2469
+ 1
2470
+ iex> tail
2471
+ [2,3]
2472
+ iex> [head | tail]
2473
+ [1,2,3]
2474
+ iex> length [head | tail]
2475
+ 3
2476
+
2477
+ *New in Pygments 1.5.*
2478
+ """
2479
+
2480
+ name = 'Elixir iex session'
2481
+ aliases = ['iex']
2482
+ mimetypes = ['text/x-elixir-shellsession']
2483
+
2484
+ _prompt_re = re.compile('(iex|\.{3})> ')
2485
+
2486
+ def get_tokens_unprocessed(self, text):
2487
+ exlexer = ElixirLexer(**self.options)
2488
+
2489
+ curcode = ''
2490
+ insertions = []
2491
+ for match in line_re.finditer(text):
2492
+ line = match.group()
2493
+ if line.startswith(u'** '):
2494
+ insertions.append((len(curcode),
2495
+ [(0, Generic.Error, line[:-1])]))
2496
+ curcode += line[-1:]
2497
+ else:
2498
+ m = self._prompt_re.match(line)
2499
+ if m is not None:
2500
+ end = m.end()
2501
+ insertions.append((len(curcode),
2502
+ [(0, Generic.Prompt, line[:end])]))
2503
+ curcode += line[end:]
2504
+ else:
2505
+ if curcode:
2506
+ for item in do_insertions(insertions,
2507
+ exlexer.get_tokens_unprocessed(curcode)):
2508
+ yield item
2509
+ curcode = ''
2510
+ insertions = []
2511
+ yield match.start(), Generic.Output, line
2512
+ if curcode:
2513
+ for item in do_insertions(insertions,
2514
+ exlexer.get_tokens_unprocessed(curcode)):
2515
+ yield item
2516
+
2517
+
2518
+ class KokaLexer(RegexLexer):
2519
+ """
2520
+ Lexer for the `Koka <http://koka.codeplex.com>`_
2521
+ language.
2522
+
2523
+ *New in Pygments 1.6.*
2524
+ """
2525
+
2526
+ name = 'Koka'
2527
+ aliases = ['koka']
2528
+ filenames = ['*.kk', '*.kki']
2529
+ mimetypes = ['text/x-koka']
2530
+
2531
+ keywords = [
2532
+ 'infix', 'infixr', 'infixl',
2533
+ 'type', 'cotype', 'rectype', 'alias',
2534
+ 'struct', 'con',
2535
+ 'fun', 'function', 'val', 'var',
2536
+ 'external',
2537
+ 'if', 'then', 'else', 'elif', 'return', 'match',
2538
+ 'private', 'public', 'private',
2539
+ 'module', 'import', 'as',
2540
+ 'include', 'inline',
2541
+ 'rec',
2542
+ 'try', 'yield', 'enum',
2543
+ 'interface', 'instance',
2544
+ ]
2545
+
2546
+ # keywords that are followed by a type
2547
+ typeStartKeywords = [
2548
+ 'type', 'cotype', 'rectype', 'alias', 'struct', 'enum',
2549
+ ]
2550
+
2551
+ # keywords valid in a type
2552
+ typekeywords = [
2553
+ 'forall', 'exists', 'some', 'with',
2554
+ ]
2555
+
2556
+ # builtin names and special names
2557
+ builtin = [
2558
+ 'for', 'while', 'repeat',
2559
+ 'foreach', 'foreach-indexed',
2560
+ 'error', 'catch', 'finally',
2561
+ 'cs', 'js', 'file', 'ref', 'assigned',
2562
+ ]
2563
+
2564
+ # symbols that can be in an operator
2565
+ symbols = '[\$%&\*\+@!/\\\^~=\.:\-\?\|<>]+'
2566
+
2567
+ # symbol boundary: an operator keyword should not be followed by any of these
2568
+ sboundary = '(?!'+symbols+')'
2569
+
2570
+ # name boundary: a keyword should not be followed by any of these
2571
+ boundary = '(?![\w/])'
2572
+
2573
+ # koka token abstractions
2574
+ tokenType = Name.Attribute
2575
+ tokenTypeDef = Name.Class
2576
+ tokenConstructor = Generic.Emph
2577
+
2578
+ # main lexer
2579
+ tokens = {
2580
+ 'root': [
2581
+ include('whitespace'),
2582
+
2583
+ # go into type mode
2584
+ (r'::?' + sboundary, tokenType, 'type'),
2585
+ (r'(alias)(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
2586
+ 'alias-type'),
2587
+ (r'(struct)(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
2588
+ 'struct-type'),
2589
+ ((r'(%s)' % '|'.join(typeStartKeywords)) +
2590
+ r'(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
2591
+ 'type'),
2592
+
2593
+ # special sequences of tokens (we use ?: for non-capturing group as
2594
+ # required by 'bygroups')
2595
+ (r'(module)(\s+)(interface\s+)?((?:[a-z]\w*/)*[a-z]\w*)',
2596
+ bygroups(Keyword, Text, Keyword, Name.Namespace)),
2597
+ (r'(import)(\s+)((?:[a-z]\w*/)*[a-z]\w*)'
2598
+ r'(?:(\s*)(=)(\s*)((?:qualified\s*)?)'
2599
+ r'((?:[a-z]\w*/)*[a-z]\w*))?',
2600
+ bygroups(Keyword, Text, Name.Namespace, Text, Keyword, Text,
2601
+ Keyword, Name.Namespace)),
2602
+
2603
+ (r'(^(?:(?:public|private)\s*)?(?:function|fun|val))'
2604
+ r'(\s+)([a-z]\w*|\((?:' + symbols + r'|/)\))',
2605
+ bygroups(Keyword, Text, Name.Function)),
2606
+ (r'(^(?:(?:public|private)\s*)?external)(\s+)(inline\s+)?'
2607
+ r'([a-z]\w*|\((?:' + symbols + r'|/)\))',
2608
+ bygroups(Keyword, Text, Keyword, Name.Function)),
2609
+
2610
+ # keywords
2611
+ (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword.Type),
2612
+ (r'(%s)' % '|'.join(keywords) + boundary, Keyword),
2613
+ (r'(%s)' % '|'.join(builtin) + boundary, Keyword.Pseudo),
2614
+ (r'::?|:=|\->|[=\.]' + sboundary, Keyword),
2615
+
2616
+ # names
2617
+ (r'((?:[a-z]\w*/)*)([A-Z]\w*)',
2618
+ bygroups(Name.Namespace, tokenConstructor)),
2619
+ (r'((?:[a-z]\w*/)*)([a-z]\w*)', bygroups(Name.Namespace, Name)),
2620
+ (r'((?:[a-z]\w*/)*)(\((?:' + symbols + r'|/)\))',
2621
+ bygroups(Name.Namespace, Name)),
2622
+ (r'_\w*', Name.Variable),
2623
+
2624
+ # literal string
2625
+ (r'@"', String.Double, 'litstring'),
2626
+
2627
+ # operators
2628
+ (symbols + "|/(?![\*/])", Operator),
2629
+ (r'`', Operator),
2630
+ (r'[\{\}\(\)\[\];,]', Punctuation),
2631
+
2632
+ # literals. No check for literal characters with len > 1
2633
+ (r'[0-9]+\.[0-9]+([eE][\-\+]?[0-9]+)?', Number.Float),
2634
+ (r'0[xX][0-9a-fA-F]+', Number.Hex),
2635
+ (r'[0-9]+', Number.Integer),
2636
+
2637
+ (r"'", String.Char, 'char'),
2638
+ (r'"', String.Double, 'string'),
2639
+ ],
2640
+
2641
+ # type started by alias
2642
+ 'alias-type': [
2643
+ (r'=',Keyword),
2644
+ include('type')
2645
+ ],
2646
+
2647
+ # type started by struct
2648
+ 'struct-type': [
2649
+ (r'(?=\((?!,*\)))',Punctuation, '#pop'),
2650
+ include('type')
2651
+ ],
2652
+
2653
+ # type started by colon
2654
+ 'type': [
2655
+ (r'[\(\[<]', tokenType, 'type-nested'),
2656
+ include('type-content')
2657
+ ],
2658
+
2659
+ # type nested in brackets: can contain parameters, comma etc.
2660
+ 'type-nested': [
2661
+ (r'[\)\]>]', tokenType, '#pop'),
2662
+ (r'[\(\[<]', tokenType, 'type-nested'),
2663
+ (r',', tokenType),
2664
+ (r'([a-z]\w*)(\s*)(:)(?!:)',
2665
+ bygroups(Name, Text, tokenType)), # parameter name
2666
+ include('type-content')
2667
+ ],
2668
+
2669
+ # shared contents of a type
2670
+ 'type-content': [
2671
+ include('whitespace'),
2672
+
2673
+ # keywords
2674
+ (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword),
2675
+ (r'(?=((%s)' % '|'.join(keywords) + boundary + '))',
2676
+ Keyword, '#pop'), # need to match because names overlap...
2677
+
2678
+ # kinds
2679
+ (r'[EPHVX]' + boundary, tokenType),
2680
+
2681
+ # type names
2682
+ (r'[a-z][0-9]*(?![\w/])', tokenType ),
2683
+ (r'_\w*', tokenType.Variable), # Generic.Emph
2684
+ (r'((?:[a-z]\w*/)*)([A-Z]\w*)',
2685
+ bygroups(Name.Namespace, tokenType)),
2686
+ (r'((?:[a-z]\w*/)*)([a-z]\w+)',
2687
+ bygroups(Name.Namespace, tokenType)),
2688
+
2689
+ # type keyword operators
2690
+ (r'::|\->|[\.:|]', tokenType),
2691
+
2692
+ #catchall
2693
+ (r'', Text, '#pop')
2694
+ ],
2695
+
2696
+ # comments and literals
2697
+ 'whitespace': [
2698
+ (r'\n\s*#.*$', Comment.Preproc),
2699
+ (r'\s+', Text),
2700
+ (r'/\*', Comment.Multiline, 'comment'),
2701
+ (r'//.*$', Comment.Single)
2702
+ ],
2703
+ 'comment': [
2704
+ (r'[^/\*]+', Comment.Multiline),
2705
+ (r'/\*', Comment.Multiline, '#push'),
2706
+ (r'\*/', Comment.Multiline, '#pop'),
2707
+ (r'[\*/]', Comment.Multiline),
2708
+ ],
2709
+ 'litstring': [
2710
+ (r'[^"]+', String.Double),
2711
+ (r'""', String.Escape),
2712
+ (r'"', String.Double, '#pop'),
2713
+ ],
2714
+ 'string': [
2715
+ (r'[^\\"\n]+', String.Double),
2716
+ include('escape-sequence'),
2717
+ (r'["\n]', String.Double, '#pop'),
2718
+ ],
2719
+ 'char': [
2720
+ (r'[^\\\'\n]+', String.Char),
2721
+ include('escape-sequence'),
2722
+ (r'[\'\n]', String.Char, '#pop'),
2723
+ ],
2724
+ 'escape-sequence': [
2725
+ (r'\\[nrt\\\"\']', String.Escape),
2726
+ (r'\\x[0-9a-fA-F]{2}', String.Escape),
2727
+ (r'\\u[0-9a-fA-F]{4}', String.Escape),
2728
+ # Yes, \U literals are 6 hex digits.
2729
+ (r'\\U[0-9a-fA-F]{6}', String.Escape)
2730
+ ]
2731
+ }