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,3723 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.compiled
4
+ ~~~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for compiled 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
+ from string import Template
14
+
15
+ from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
16
+ this, combined, inherit, do_insertions
17
+ from pygments.util import get_bool_opt, get_list_opt
18
+ from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
19
+ Number, Punctuation, Error, Literal, Generic
20
+ from pygments.scanner import Scanner
21
+
22
+ # backwards compatibility
23
+ from pygments.lexers.functional import OcamlLexer
24
+ from pygments.lexers.jvm import JavaLexer, ScalaLexer
25
+
26
+ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer',
27
+ 'NesCLexer', 'DylanLexer', 'ObjectiveCLexer', 'ObjectiveCppLexer',
28
+ 'FortranLexer', 'GLShaderLexer', 'PrologLexer', 'CythonLexer',
29
+ 'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer',
30
+ 'Modula2Lexer', 'BlitzMaxLexer', 'BlitzBasicLexer', 'NimrodLexer',
31
+ 'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', 'SwigLexer',
32
+ 'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer',
33
+ 'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer']
34
+
35
+
36
+ class CFamilyLexer(RegexLexer):
37
+ """
38
+ For C family source code. This is used as a base class to avoid repetitious
39
+ definitions.
40
+ """
41
+
42
+ #: optional Comment or Whitespace
43
+ _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
44
+ #: only one /* */ style comment
45
+ _ws1 = r':\s*/[*].*?[*]/\s*'
46
+
47
+ tokens = {
48
+ 'whitespace': [
49
+ # preprocessor directives: without whitespace
50
+ ('^#if\s+0', Comment.Preproc, 'if0'),
51
+ ('^#', Comment.Preproc, 'macro'),
52
+ # or with whitespace
53
+ ('^(' + _ws1 + r')(#if\s+0)',
54
+ bygroups(using(this), Comment.Preproc), 'if0'),
55
+ ('^(' + _ws1 + ')(#)',
56
+ bygroups(using(this), Comment.Preproc), 'macro'),
57
+ (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))',
58
+ bygroups(Text, Name.Label)),
59
+ (r'\n', Text),
60
+ (r'\s+', Text),
61
+ (r'\\\n', Text), # line continuation
62
+ (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
63
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
64
+ ],
65
+ 'statements': [
66
+ (r'L?"', String, 'string'),
67
+ (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
68
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
69
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
70
+ (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
71
+ (r'0[0-7]+[LlUu]*', Number.Oct),
72
+ (r'\d+[LlUu]*', Number.Integer),
73
+ (r'\*/', Error),
74
+ (r'[~!%^&*+=|?:<>/-]', Operator),
75
+ (r'[()\[\],.]', Punctuation),
76
+ (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
77
+ (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
78
+ r'for|goto|if|register|restricted|return|sizeof|static|struct|'
79
+ r'switch|typedef|union|volatile|while)\b', Keyword),
80
+ (r'(bool|int|long|float|short|double|char|unsigned|signed|void|'
81
+ r'[a-z_][a-z0-9_]*_t)\b',
82
+ Keyword.Type),
83
+ (r'(_{0,2}inline|naked|restrict|thread|typename)\b', Keyword.Reserved),
84
+ # Vector intrinsics
85
+ (r'(__(m128i|m128d|m128|m64))\b', Keyword.Reserved),
86
+ # Microsoft-isms
87
+ (r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
88
+ r'declspec|finally|int64|try|leave|wchar_t|w64|unaligned|'
89
+ r'raise|noop|identifier|forceinline|assume)\b', Keyword.Reserved),
90
+ (r'(true|false|NULL)\b', Name.Builtin),
91
+ ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
92
+ ],
93
+ 'root': [
94
+ include('whitespace'),
95
+ # functions
96
+ (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
97
+ r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
98
+ r'(\s*\([^;]*?\))' # signature
99
+ r'(' + _ws + r')?({)',
100
+ bygroups(using(this), Name.Function, using(this), using(this),
101
+ Punctuation),
102
+ 'function'),
103
+ # function declarations
104
+ (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
105
+ r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
106
+ r'(\s*\([^;]*?\))' # signature
107
+ r'(' + _ws + r')?(;)',
108
+ bygroups(using(this), Name.Function, using(this), using(this),
109
+ Punctuation)),
110
+ ('', Text, 'statement'),
111
+ ],
112
+ 'statement' : [
113
+ include('whitespace'),
114
+ include('statements'),
115
+ ('[{}]', Punctuation),
116
+ (';', Punctuation, '#pop'),
117
+ ],
118
+ 'function': [
119
+ include('whitespace'),
120
+ include('statements'),
121
+ (';', Punctuation),
122
+ ('{', Punctuation, '#push'),
123
+ ('}', Punctuation, '#pop'),
124
+ ],
125
+ 'string': [
126
+ (r'"', String, '#pop'),
127
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
128
+ r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
129
+ (r'[^\\"\n]+', String), # all other characters
130
+ (r'\\\n', String), # line continuation
131
+ (r'\\', String), # stray backslash
132
+ ],
133
+ 'macro': [
134
+ (r'[^/\n]+', Comment.Preproc),
135
+ (r'/[*](.|\n)*?[*]/', Comment.Multiline),
136
+ (r'//.*?\n', Comment.Single, '#pop'),
137
+ (r'/', Comment.Preproc),
138
+ (r'(?<=\\)\n', Comment.Preproc),
139
+ (r'\n', Comment.Preproc, '#pop'),
140
+ ],
141
+ 'if0': [
142
+ (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
143
+ (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
144
+ (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
145
+ (r'.*?\n', Comment),
146
+ ]
147
+ }
148
+
149
+ stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
150
+ 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
151
+ 'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
152
+ 'wctrans_t', 'wint_t', 'wctype_t']
153
+ c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
154
+ 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
155
+ 'int_least16_t', 'int_least32_t', 'int_least64_t',
156
+ 'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
157
+ 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
158
+ 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
159
+ 'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t',
160
+ 'uintmax_t']
161
+
162
+ def __init__(self, **options):
163
+ self.stdlibhighlighting = get_bool_opt(options,
164
+ 'stdlibhighlighting', True)
165
+ self.c99highlighting = get_bool_opt(options,
166
+ 'c99highlighting', True)
167
+ RegexLexer.__init__(self, **options)
168
+
169
+ def get_tokens_unprocessed(self, text):
170
+ for index, token, value in \
171
+ RegexLexer.get_tokens_unprocessed(self, text):
172
+ if token is Name:
173
+ if self.stdlibhighlighting and value in self.stdlib_types:
174
+ token = Keyword.Type
175
+ elif self.c99highlighting and value in self.c99_types:
176
+ token = Keyword.Type
177
+ yield index, token, value
178
+
179
+
180
+ class CLexer(CFamilyLexer):
181
+ """
182
+ For C source code with preprocessor directives.
183
+ """
184
+ name = 'C'
185
+ aliases = ['c']
186
+ filenames = ['*.c', '*.h', '*.idc']
187
+ mimetypes = ['text/x-chdr', 'text/x-csrc']
188
+ priority = 0.1
189
+
190
+ def analyse_text(text):
191
+ return 0.1
192
+
193
+
194
+ class CppLexer(CFamilyLexer):
195
+ """
196
+ For C++ source code with preprocessor directives.
197
+ """
198
+ name = 'C++'
199
+ aliases = ['cpp', 'c++']
200
+ filenames = ['*.cpp', '*.hpp', '*.c++', '*.h++',
201
+ '*.cc', '*.hh', '*.cxx', '*.hxx',
202
+ '*.C', '*.H', '*.cp', '*.CPP']
203
+ mimetypes = ['text/x-c++hdr', 'text/x-c++src']
204
+ priority = 0.1
205
+
206
+ tokens = {
207
+ 'statements': [
208
+ (r'(asm|catch|const_cast|delete|dynamic_cast|explicit|'
209
+ r'export|friend|mutable|namespace|new|operator|'
210
+ r'private|protected|public|reinterpret_cast|'
211
+ r'restrict|static_cast|template|this|throw|throws|'
212
+ r'typeid|typename|using|virtual)\b', Keyword),
213
+ (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
214
+ inherit,
215
+ ],
216
+ 'root': [
217
+ inherit,
218
+ # C++ Microsoft-isms
219
+ (r'__(virtual_inheritance|uuidof|super|single_inheritance|'
220
+ r'multiple_inheritance|interface|event)\b', Keyword.Reserved),
221
+ # Offload C++ extensions, http://offload.codeplay.com/
222
+ (r'(__offload|__blockingoffload|__outer)\b', Keyword.Pseudo),
223
+ ],
224
+ 'classname': [
225
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
226
+ # template specification
227
+ (r'\s*(?=>)', Text, '#pop'),
228
+ ],
229
+ }
230
+
231
+ def analyse_text(text):
232
+ return 0.1
233
+
234
+
235
+ class SwigLexer(CppLexer):
236
+ """
237
+ For `SWIG <http://www.swig.org/>`_ source code.
238
+
239
+ *New in Pygments 1.7.*
240
+ """
241
+ name = 'SWIG'
242
+ aliases = ['Swig', 'swig']
243
+ filenames = ['*.swg', '*.i']
244
+ mimetypes = ['text/swig']
245
+ priority = 0.04 # Lower than C/C++ and Objective C/C++
246
+
247
+ tokens = {
248
+ 'statements': [
249
+ (r'(%[a-z_][a-z0-9_]*)', Name.Function), # SWIG directives
250
+ ('\$\**\&?[a-zA-Z0-9_]+', Name), # Special variables
251
+ (r'##*[a-zA-Z_][a-zA-Z0-9_]*', Comment.Preproc), # Stringification / additional preprocessor directives
252
+ inherit,
253
+ ],
254
+ }
255
+
256
+ # This is a far from complete set of SWIG directives
257
+ swig_directives = (
258
+ # Most common directives
259
+ '%apply', '%define', '%director', '%enddef', '%exception', '%extend',
260
+ '%feature', '%fragment', '%ignore', '%immutable', '%import', '%include',
261
+ '%inline', '%insert', '%module', '%newobject', '%nspace', '%pragma',
262
+ '%rename', '%shared_ptr', '%template', '%typecheck', '%typemap',
263
+ # Less common directives
264
+ '%arg', '%attribute', '%bang', '%begin', '%callback', '%catches', '%clear',
265
+ '%constant', '%copyctor', '%csconst', '%csconstvalue', '%csenum',
266
+ '%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor',
267
+ '%defaultdtor', '%defined', '%delete', '%delobject', '%descriptor',
268
+ '%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments',
269
+ '%header', '%ifcplusplus', '%ignorewarn', '%implicit', '%implicitconv',
270
+ '%init', '%javaconst', '%javaconstvalue', '%javaenum', '%javaexception',
271
+ '%javamethodmodifiers', '%kwargs', '%luacode', '%mutable', '%naturalvar',
272
+ '%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend',
273
+ '%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall',
274
+ '%pythonnondynamic', '%pythonprepend', '%refobject', '%shadow', '%sizeof',
275
+ '%trackobjects', '%types', '%unrefobject', '%varargs', '%warn', '%warnfilter')
276
+
277
+ def analyse_text(text):
278
+ rv = 0.1 # Same as C/C++
279
+ # Search for SWIG directives, which are conventionally at the beginning of
280
+ # a line. The probability of them being within a line is low, so let another
281
+ # lexer win in this case.
282
+ matches = re.findall(r'^\s*(%[a-z_][a-z0-9_]*)', text, re.M)
283
+ for m in matches:
284
+ if m in SwigLexer.swig_directives:
285
+ rv = 0.98
286
+ break
287
+ else:
288
+ rv = 0.91 # Fraction higher than MatlabLexer
289
+ return rv
290
+
291
+
292
+ class ECLexer(CLexer):
293
+ """
294
+ For eC source code with preprocessor directives.
295
+
296
+ *New in Pygments 1.5.*
297
+ """
298
+ name = 'eC'
299
+ aliases = ['ec']
300
+ filenames = ['*.ec', '*.eh']
301
+ mimetypes = ['text/x-echdr', 'text/x-ecsrc']
302
+
303
+ tokens = {
304
+ 'statements': [
305
+ (r'(virtual|class|private|public|property|import|delete|new|new0|'
306
+ r'renew|renew0|define|get|set|remote|dllexport|dllimport|stdcall|'
307
+ r'subclass|__on_register_module|namespace|using|typed_object|'
308
+ r'any_object|incref|register|watch|stopwatching|firewatchers|'
309
+ r'watchable|class_designer|class_fixed|class_no_expansion|isset|'
310
+ r'class_default_property|property_category|class_data|'
311
+ r'class_property|virtual|thisclass|'
312
+ r'dbtable|dbindex|database_open|dbfield)\b', Keyword),
313
+ (r'(uint|uint16|uint32|uint64|bool|byte|unichar|int64)\b',
314
+ Keyword.Type),
315
+ (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
316
+ (r'(null|value|this)\b', Name.Builtin),
317
+ inherit,
318
+ ],
319
+ 'classname': [
320
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
321
+ # template specification
322
+ (r'\s*(?=>)', Text, '#pop'),
323
+ ],
324
+ }
325
+
326
+
327
+ class NesCLexer(CLexer):
328
+ """
329
+ For `nesC <https://github.com/tinyos/nesc>`_ source code with preprocessor
330
+ directives.
331
+
332
+ *New in Pygments 1.7.*
333
+ """
334
+ name = 'nesC'
335
+ aliases = ['nesc']
336
+ filenames = ['*.nc']
337
+ mimetypes = ['text/x-nescsrc']
338
+
339
+ tokens = {
340
+ 'statements': [
341
+ (r'(abstract|as|async|atomic|call|command|component|components|'
342
+ r'configuration|event|extends|generic|implementation|includes|'
343
+ r'interface|module|new|norace|post|provides|signal|task|uses)\b',
344
+ Keyword),
345
+ (r'(nx_struct|nx_union|nx_int8_t|nx_int16_t|nx_int32_t|nx_int64_t|'
346
+ r'nx_uint8_t|nx_uint16_t|nx_uint32_t|nx_uint64_t)\b',
347
+ Keyword.Type),
348
+ inherit,
349
+ ],
350
+ }
351
+
352
+
353
+ class ClayLexer(RegexLexer):
354
+ """
355
+ For `Clay <http://claylabs.com/clay/>`_ source.
356
+
357
+ *New in Pygments 1.7.*
358
+ """
359
+ name = 'Clay'
360
+ filenames = ['*.clay']
361
+ aliases = ['clay']
362
+ mimetypes = ['text/x-clay']
363
+ tokens = {
364
+ 'root': [
365
+ (r'\s', Text),
366
+ (r'//.*?$', Comment.Singleline),
367
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
368
+ (r'\b(public|private|import|as|record|variant|instance'
369
+ r'|define|overload|default|external|alias'
370
+ r'|rvalue|ref|forward|inline|noinline|forceinline'
371
+ r'|enum|var|and|or|not|if|else|goto|return|while'
372
+ r'|switch|case|break|continue|for|in|true|false|try|catch|throw'
373
+ r'|finally|onerror|staticassert|eval|when|newtype'
374
+ r'|__FILE__|__LINE__|__COLUMN__|__ARG__'
375
+ r')\b', Keyword),
376
+ (r'[~!%^&*+=|:<>/-]', Operator),
377
+ (r'[#(){}\[\],;.]', Punctuation),
378
+ (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
379
+ (r'\d+[LlUu]*', Number.Integer),
380
+ (r'\b(true|false)\b', Name.Builtin),
381
+ (r'(?i)[a-z_?][a-z_?0-9]*', Name),
382
+ (r'"""', String, 'tdqs'),
383
+ (r'"', String, 'dqs'),
384
+ ],
385
+ 'strings': [
386
+ (r'(?i)\\(x[0-9a-f]{2}|.)', String.Escape),
387
+ (r'.', String),
388
+ ],
389
+ 'nl': [
390
+ (r'\n', String),
391
+ ],
392
+ 'dqs': [
393
+ (r'"', String, '#pop'),
394
+ include('strings'),
395
+ ],
396
+ 'tdqs': [
397
+ (r'"""', String, '#pop'),
398
+ include('strings'),
399
+ include('nl'),
400
+ ],
401
+ }
402
+
403
+
404
+ class DLexer(RegexLexer):
405
+ """
406
+ For D source.
407
+
408
+ *New in Pygments 1.2.*
409
+ """
410
+ name = 'D'
411
+ filenames = ['*.d', '*.di']
412
+ aliases = ['d']
413
+ mimetypes = ['text/x-dsrc']
414
+
415
+ tokens = {
416
+ 'root': [
417
+ (r'\n', Text),
418
+ (r'\s+', Text),
419
+ #(r'\\\n', Text), # line continuations
420
+ # Comments
421
+ (r'//(.*?)\n', Comment.Single),
422
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
423
+ (r'/\+', Comment.Multiline, 'nested_comment'),
424
+ # Keywords
425
+ (r'(abstract|alias|align|asm|assert|auto|body|break|case|cast'
426
+ r'|catch|class|const|continue|debug|default|delegate|delete'
427
+ r'|deprecated|do|else|enum|export|extern|finally|final'
428
+ r'|foreach_reverse|foreach|for|function|goto|if|import|inout'
429
+ r'|interface|invariant|in|is|lazy|mixin|module|new|nothrow|out'
430
+ r'|override|package|pragma|private|protected|public|pure|ref|return'
431
+ r'|scope|static|struct|super|switch|synchronized|template|this'
432
+ r'|throw|try|typedef|typeid|typeof|union|unittest|version|volatile'
433
+ r'|while|with|__traits)\b', Keyword
434
+ ),
435
+ (r'(bool|byte|cdouble|cent|cfloat|char|creal|dchar|double|float'
436
+ r'|idouble|ifloat|int|ireal|long|real|short|ubyte|ucent|uint|ulong'
437
+ r'|ushort|void|wchar)\b', Keyword.Type
438
+ ),
439
+ (r'(false|true|null)\b', Keyword.Constant),
440
+ (r'macro\b', Keyword.Reserved),
441
+ (r'(string|wstring|dstring)\b', Name.Builtin),
442
+ # FloatLiteral
443
+ # -- HexFloat
444
+ (r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)'
445
+ r'[pP][+\-]?[0-9_]+[fFL]?[i]?', Number.Float),
446
+ # -- DecimalFloat
447
+ (r'[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|'
448
+ r'\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?', Number.Float),
449
+ (r'\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?', Number.Float),
450
+ # IntegerLiteral
451
+ # -- Binary
452
+ (r'0[Bb][01_]+', Number),
453
+ # -- Octal
454
+ (r'0[0-7_]+', Number.Oct),
455
+ # -- Hexadecimal
456
+ (r'0[xX][0-9a-fA-F_]+', Number.Hex),
457
+ # -- Decimal
458
+ (r'(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?', Number.Integer),
459
+ # CharacterLiteral
460
+ (r"""'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
461
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'""",
462
+ String.Char
463
+ ),
464
+ # StringLiteral
465
+ # -- WysiwygString
466
+ (r'r"[^"]*"[cwd]?', String),
467
+ # -- AlternateWysiwygString
468
+ (r'`[^`]*`[cwd]?', String),
469
+ # -- DoubleQuotedString
470
+ (r'"(\\\\|\\"|[^"])*"[cwd]?', String),
471
+ # -- EscapeSequence
472
+ (r"\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}"
473
+ r"|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)",
474
+ String
475
+ ),
476
+ # -- HexString
477
+ (r'x"[0-9a-fA-F_\s]*"[cwd]?', String),
478
+ # -- DelimitedString
479
+ (r'q"\[', String, 'delimited_bracket'),
480
+ (r'q"\(', String, 'delimited_parenthesis'),
481
+ (r'q"<', String, 'delimited_angle'),
482
+ (r'q"{', String, 'delimited_curly'),
483
+ (r'q"([a-zA-Z_]\w*)\n.*?\n\1"', String),
484
+ (r'q"(.).*?\1"', String),
485
+ # -- TokenString
486
+ (r'q{', String, 'token_string'),
487
+ # Tokens
488
+ (r'(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>='
489
+ r'|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)'
490
+ r'|[/.&|\-+<>!()\[\]{}?,;:$=*%^~]', Punctuation
491
+ ),
492
+ # Identifier
493
+ (r'[a-zA-Z_]\w*', Name),
494
+ ],
495
+ 'nested_comment': [
496
+ (r'[^+/]+', Comment.Multiline),
497
+ (r'/\+', Comment.Multiline, '#push'),
498
+ (r'\+/', Comment.Multiline, '#pop'),
499
+ (r'[+/]', Comment.Multiline),
500
+ ],
501
+ 'token_string': [
502
+ (r'{', Punctuation, 'token_string_nest'),
503
+ (r'}', String, '#pop'),
504
+ include('root'),
505
+ ],
506
+ 'token_string_nest': [
507
+ (r'{', Punctuation, '#push'),
508
+ (r'}', Punctuation, '#pop'),
509
+ include('root'),
510
+ ],
511
+ 'delimited_bracket': [
512
+ (r'[^\[\]]+', String),
513
+ (r'\[', String, 'delimited_inside_bracket'),
514
+ (r'\]"', String, '#pop'),
515
+ ],
516
+ 'delimited_inside_bracket': [
517
+ (r'[^\[\]]+', String),
518
+ (r'\[', String, '#push'),
519
+ (r'\]', String, '#pop'),
520
+ ],
521
+ 'delimited_parenthesis': [
522
+ (r'[^\(\)]+', String),
523
+ (r'\(', String, 'delimited_inside_parenthesis'),
524
+ (r'\)"', String, '#pop'),
525
+ ],
526
+ 'delimited_inside_parenthesis': [
527
+ (r'[^\(\)]+', String),
528
+ (r'\(', String, '#push'),
529
+ (r'\)', String, '#pop'),
530
+ ],
531
+ 'delimited_angle': [
532
+ (r'[^<>]+', String),
533
+ (r'<', String, 'delimited_inside_angle'),
534
+ (r'>"', String, '#pop'),
535
+ ],
536
+ 'delimited_inside_angle': [
537
+ (r'[^<>]+', String),
538
+ (r'<', String, '#push'),
539
+ (r'>', String, '#pop'),
540
+ ],
541
+ 'delimited_curly': [
542
+ (r'[^{}]+', String),
543
+ (r'{', String, 'delimited_inside_curly'),
544
+ (r'}"', String, '#pop'),
545
+ ],
546
+ 'delimited_inside_curly': [
547
+ (r'[^{}]+', String),
548
+ (r'{', String, '#push'),
549
+ (r'}', String, '#pop'),
550
+ ],
551
+ }
552
+
553
+
554
+ class DelphiLexer(Lexer):
555
+ """
556
+ For `Delphi <http://www.borland.com/delphi/>`_ (Borland Object Pascal),
557
+ Turbo Pascal and Free Pascal source code.
558
+
559
+ Additional options accepted:
560
+
561
+ `turbopascal`
562
+ Highlight Turbo Pascal specific keywords (default: ``True``).
563
+ `delphi`
564
+ Highlight Borland Delphi specific keywords (default: ``True``).
565
+ `freepascal`
566
+ Highlight Free Pascal specific keywords (default: ``True``).
567
+ `units`
568
+ A list of units that should be considered builtin, supported are
569
+ ``System``, ``SysUtils``, ``Classes`` and ``Math``.
570
+ Default is to consider all of them builtin.
571
+ """
572
+ name = 'Delphi'
573
+ aliases = ['delphi', 'pas', 'pascal', 'objectpascal']
574
+ filenames = ['*.pas']
575
+ mimetypes = ['text/x-pascal']
576
+
577
+ TURBO_PASCAL_KEYWORDS = [
578
+ 'absolute', 'and', 'array', 'asm', 'begin', 'break', 'case',
579
+ 'const', 'constructor', 'continue', 'destructor', 'div', 'do',
580
+ 'downto', 'else', 'end', 'file', 'for', 'function', 'goto',
581
+ 'if', 'implementation', 'in', 'inherited', 'inline', 'interface',
582
+ 'label', 'mod', 'nil', 'not', 'object', 'of', 'on', 'operator',
583
+ 'or', 'packed', 'procedure', 'program', 'record', 'reintroduce',
584
+ 'repeat', 'self', 'set', 'shl', 'shr', 'string', 'then', 'to',
585
+ 'type', 'unit', 'until', 'uses', 'var', 'while', 'with', 'xor'
586
+ ]
587
+
588
+ DELPHI_KEYWORDS = [
589
+ 'as', 'class', 'except', 'exports', 'finalization', 'finally',
590
+ 'initialization', 'is', 'library', 'on', 'property', 'raise',
591
+ 'threadvar', 'try'
592
+ ]
593
+
594
+ FREE_PASCAL_KEYWORDS = [
595
+ 'dispose', 'exit', 'false', 'new', 'true'
596
+ ]
597
+
598
+ BLOCK_KEYWORDS = set([
599
+ 'begin', 'class', 'const', 'constructor', 'destructor', 'end',
600
+ 'finalization', 'function', 'implementation', 'initialization',
601
+ 'label', 'library', 'operator', 'procedure', 'program', 'property',
602
+ 'record', 'threadvar', 'type', 'unit', 'uses', 'var'
603
+ ])
604
+
605
+ FUNCTION_MODIFIERS = set([
606
+ 'alias', 'cdecl', 'export', 'inline', 'interrupt', 'nostackframe',
607
+ 'pascal', 'register', 'safecall', 'softfloat', 'stdcall',
608
+ 'varargs', 'name', 'dynamic', 'near', 'virtual', 'external',
609
+ 'override', 'assembler'
610
+ ])
611
+
612
+ # XXX: those aren't global. but currently we know no way for defining
613
+ # them just for the type context.
614
+ DIRECTIVES = set([
615
+ 'absolute', 'abstract', 'assembler', 'cppdecl', 'default', 'far',
616
+ 'far16', 'forward', 'index', 'oldfpccall', 'private', 'protected',
617
+ 'published', 'public'
618
+ ])
619
+
620
+ BUILTIN_TYPES = set([
621
+ 'ansichar', 'ansistring', 'bool', 'boolean', 'byte', 'bytebool',
622
+ 'cardinal', 'char', 'comp', 'currency', 'double', 'dword',
623
+ 'extended', 'int64', 'integer', 'iunknown', 'longbool', 'longint',
624
+ 'longword', 'pansichar', 'pansistring', 'pbool', 'pboolean',
625
+ 'pbyte', 'pbytearray', 'pcardinal', 'pchar', 'pcomp', 'pcurrency',
626
+ 'pdate', 'pdatetime', 'pdouble', 'pdword', 'pextended', 'phandle',
627
+ 'pint64', 'pinteger', 'plongint', 'plongword', 'pointer',
628
+ 'ppointer', 'pshortint', 'pshortstring', 'psingle', 'psmallint',
629
+ 'pstring', 'pvariant', 'pwidechar', 'pwidestring', 'pword',
630
+ 'pwordarray', 'pwordbool', 'real', 'real48', 'shortint',
631
+ 'shortstring', 'single', 'smallint', 'string', 'tclass', 'tdate',
632
+ 'tdatetime', 'textfile', 'thandle', 'tobject', 'ttime', 'variant',
633
+ 'widechar', 'widestring', 'word', 'wordbool'
634
+ ])
635
+
636
+ BUILTIN_UNITS = {
637
+ 'System': [
638
+ 'abs', 'acquireexceptionobject', 'addr', 'ansitoutf8',
639
+ 'append', 'arctan', 'assert', 'assigned', 'assignfile',
640
+ 'beginthread', 'blockread', 'blockwrite', 'break', 'chdir',
641
+ 'chr', 'close', 'closefile', 'comptocurrency', 'comptodouble',
642
+ 'concat', 'continue', 'copy', 'cos', 'dec', 'delete',
643
+ 'dispose', 'doubletocomp', 'endthread', 'enummodules',
644
+ 'enumresourcemodules', 'eof', 'eoln', 'erase', 'exceptaddr',
645
+ 'exceptobject', 'exclude', 'exit', 'exp', 'filepos', 'filesize',
646
+ 'fillchar', 'finalize', 'findclasshinstance', 'findhinstance',
647
+ 'findresourcehinstance', 'flush', 'frac', 'freemem',
648
+ 'get8087cw', 'getdir', 'getlasterror', 'getmem',
649
+ 'getmemorymanager', 'getmodulefilename', 'getvariantmanager',
650
+ 'halt', 'hi', 'high', 'inc', 'include', 'initialize', 'insert',
651
+ 'int', 'ioresult', 'ismemorymanagerset', 'isvariantmanagerset',
652
+ 'length', 'ln', 'lo', 'low', 'mkdir', 'move', 'new', 'odd',
653
+ 'olestrtostring', 'olestrtostrvar', 'ord', 'paramcount',
654
+ 'paramstr', 'pi', 'pos', 'pred', 'ptr', 'pucs4chars', 'random',
655
+ 'randomize', 'read', 'readln', 'reallocmem',
656
+ 'releaseexceptionobject', 'rename', 'reset', 'rewrite', 'rmdir',
657
+ 'round', 'runerror', 'seek', 'seekeof', 'seekeoln',
658
+ 'set8087cw', 'setlength', 'setlinebreakstyle',
659
+ 'setmemorymanager', 'setstring', 'settextbuf',
660
+ 'setvariantmanager', 'sin', 'sizeof', 'slice', 'sqr', 'sqrt',
661
+ 'str', 'stringofchar', 'stringtoolestr', 'stringtowidechar',
662
+ 'succ', 'swap', 'trunc', 'truncate', 'typeinfo',
663
+ 'ucs4stringtowidestring', 'unicodetoutf8', 'uniquestring',
664
+ 'upcase', 'utf8decode', 'utf8encode', 'utf8toansi',
665
+ 'utf8tounicode', 'val', 'vararrayredim', 'varclear',
666
+ 'widecharlentostring', 'widecharlentostrvar',
667
+ 'widechartostring', 'widechartostrvar',
668
+ 'widestringtoucs4string', 'write', 'writeln'
669
+ ],
670
+ 'SysUtils': [
671
+ 'abort', 'addexitproc', 'addterminateproc', 'adjustlinebreaks',
672
+ 'allocmem', 'ansicomparefilename', 'ansicomparestr',
673
+ 'ansicomparetext', 'ansidequotedstr', 'ansiextractquotedstr',
674
+ 'ansilastchar', 'ansilowercase', 'ansilowercasefilename',
675
+ 'ansipos', 'ansiquotedstr', 'ansisamestr', 'ansisametext',
676
+ 'ansistrcomp', 'ansistricomp', 'ansistrlastchar', 'ansistrlcomp',
677
+ 'ansistrlicomp', 'ansistrlower', 'ansistrpos', 'ansistrrscan',
678
+ 'ansistrscan', 'ansistrupper', 'ansiuppercase',
679
+ 'ansiuppercasefilename', 'appendstr', 'assignstr', 'beep',
680
+ 'booltostr', 'bytetocharindex', 'bytetocharlen', 'bytetype',
681
+ 'callterminateprocs', 'changefileext', 'charlength',
682
+ 'chartobyteindex', 'chartobytelen', 'comparemem', 'comparestr',
683
+ 'comparetext', 'createdir', 'createguid', 'currentyear',
684
+ 'currtostr', 'currtostrf', 'date', 'datetimetofiledate',
685
+ 'datetimetostr', 'datetimetostring', 'datetimetosystemtime',
686
+ 'datetimetotimestamp', 'datetostr', 'dayofweek', 'decodedate',
687
+ 'decodedatefully', 'decodetime', 'deletefile', 'directoryexists',
688
+ 'diskfree', 'disksize', 'disposestr', 'encodedate', 'encodetime',
689
+ 'exceptionerrormessage', 'excludetrailingbackslash',
690
+ 'excludetrailingpathdelimiter', 'expandfilename',
691
+ 'expandfilenamecase', 'expanduncfilename', 'extractfiledir',
692
+ 'extractfiledrive', 'extractfileext', 'extractfilename',
693
+ 'extractfilepath', 'extractrelativepath', 'extractshortpathname',
694
+ 'fileage', 'fileclose', 'filecreate', 'filedatetodatetime',
695
+ 'fileexists', 'filegetattr', 'filegetdate', 'fileisreadonly',
696
+ 'fileopen', 'fileread', 'filesearch', 'fileseek', 'filesetattr',
697
+ 'filesetdate', 'filesetreadonly', 'filewrite', 'finalizepackage',
698
+ 'findclose', 'findcmdlineswitch', 'findfirst', 'findnext',
699
+ 'floattocurr', 'floattodatetime', 'floattodecimal', 'floattostr',
700
+ 'floattostrf', 'floattotext', 'floattotextfmt', 'fmtloadstr',
701
+ 'fmtstr', 'forcedirectories', 'format', 'formatbuf', 'formatcurr',
702
+ 'formatdatetime', 'formatfloat', 'freeandnil', 'getcurrentdir',
703
+ 'getenvironmentvariable', 'getfileversion', 'getformatsettings',
704
+ 'getlocaleformatsettings', 'getmodulename', 'getpackagedescription',
705
+ 'getpackageinfo', 'gettime', 'guidtostring', 'incamonth',
706
+ 'includetrailingbackslash', 'includetrailingpathdelimiter',
707
+ 'incmonth', 'initializepackage', 'interlockeddecrement',
708
+ 'interlockedexchange', 'interlockedexchangeadd',
709
+ 'interlockedincrement', 'inttohex', 'inttostr', 'isdelimiter',
710
+ 'isequalguid', 'isleapyear', 'ispathdelimiter', 'isvalidident',
711
+ 'languages', 'lastdelimiter', 'loadpackage', 'loadstr',
712
+ 'lowercase', 'msecstotimestamp', 'newstr', 'nextcharindex', 'now',
713
+ 'outofmemoryerror', 'quotedstr', 'raiselastoserror',
714
+ 'raiselastwin32error', 'removedir', 'renamefile', 'replacedate',
715
+ 'replacetime', 'safeloadlibrary', 'samefilename', 'sametext',
716
+ 'setcurrentdir', 'showexception', 'sleep', 'stralloc', 'strbufsize',
717
+ 'strbytetype', 'strcat', 'strcharlength', 'strcomp', 'strcopy',
718
+ 'strdispose', 'strecopy', 'strend', 'strfmt', 'stricomp',
719
+ 'stringreplace', 'stringtoguid', 'strlcat', 'strlcomp', 'strlcopy',
720
+ 'strlen', 'strlfmt', 'strlicomp', 'strlower', 'strmove', 'strnew',
721
+ 'strnextchar', 'strpas', 'strpcopy', 'strplcopy', 'strpos',
722
+ 'strrscan', 'strscan', 'strtobool', 'strtobooldef', 'strtocurr',
723
+ 'strtocurrdef', 'strtodate', 'strtodatedef', 'strtodatetime',
724
+ 'strtodatetimedef', 'strtofloat', 'strtofloatdef', 'strtoint',
725
+ 'strtoint64', 'strtoint64def', 'strtointdef', 'strtotime',
726
+ 'strtotimedef', 'strupper', 'supports', 'syserrormessage',
727
+ 'systemtimetodatetime', 'texttofloat', 'time', 'timestamptodatetime',
728
+ 'timestamptomsecs', 'timetostr', 'trim', 'trimleft', 'trimright',
729
+ 'tryencodedate', 'tryencodetime', 'tryfloattocurr', 'tryfloattodatetime',
730
+ 'trystrtobool', 'trystrtocurr', 'trystrtodate', 'trystrtodatetime',
731
+ 'trystrtofloat', 'trystrtoint', 'trystrtoint64', 'trystrtotime',
732
+ 'unloadpackage', 'uppercase', 'widecomparestr', 'widecomparetext',
733
+ 'widefmtstr', 'wideformat', 'wideformatbuf', 'widelowercase',
734
+ 'widesamestr', 'widesametext', 'wideuppercase', 'win32check',
735
+ 'wraptext'
736
+ ],
737
+ 'Classes': [
738
+ 'activateclassgroup', 'allocatehwnd', 'bintohex', 'checksynchronize',
739
+ 'collectionsequal', 'countgenerations', 'deallocatehwnd', 'equalrect',
740
+ 'extractstrings', 'findclass', 'findglobalcomponent', 'getclass',
741
+ 'groupdescendantswith', 'hextobin', 'identtoint',
742
+ 'initinheritedcomponent', 'inttoident', 'invalidpoint',
743
+ 'isuniqueglobalcomponentname', 'linestart', 'objectbinarytotext',
744
+ 'objectresourcetotext', 'objecttexttobinary', 'objecttexttoresource',
745
+ 'pointsequal', 'readcomponentres', 'readcomponentresex',
746
+ 'readcomponentresfile', 'rect', 'registerclass', 'registerclassalias',
747
+ 'registerclasses', 'registercomponents', 'registerintegerconsts',
748
+ 'registernoicon', 'registernonactivex', 'smallpoint', 'startclassgroup',
749
+ 'teststreamformat', 'unregisterclass', 'unregisterclasses',
750
+ 'unregisterintegerconsts', 'unregistermoduleclasses',
751
+ 'writecomponentresfile'
752
+ ],
753
+ 'Math': [
754
+ 'arccos', 'arccosh', 'arccot', 'arccoth', 'arccsc', 'arccsch', 'arcsec',
755
+ 'arcsech', 'arcsin', 'arcsinh', 'arctan2', 'arctanh', 'ceil',
756
+ 'comparevalue', 'cosecant', 'cosh', 'cot', 'cotan', 'coth', 'csc',
757
+ 'csch', 'cycletodeg', 'cycletograd', 'cycletorad', 'degtocycle',
758
+ 'degtograd', 'degtorad', 'divmod', 'doubledecliningbalance',
759
+ 'ensurerange', 'floor', 'frexp', 'futurevalue', 'getexceptionmask',
760
+ 'getprecisionmode', 'getroundmode', 'gradtocycle', 'gradtodeg',
761
+ 'gradtorad', 'hypot', 'inrange', 'interestpayment', 'interestrate',
762
+ 'internalrateofreturn', 'intpower', 'isinfinite', 'isnan', 'iszero',
763
+ 'ldexp', 'lnxp1', 'log10', 'log2', 'logn', 'max', 'maxintvalue',
764
+ 'maxvalue', 'mean', 'meanandstddev', 'min', 'minintvalue', 'minvalue',
765
+ 'momentskewkurtosis', 'netpresentvalue', 'norm', 'numberofperiods',
766
+ 'payment', 'periodpayment', 'poly', 'popnstddev', 'popnvariance',
767
+ 'power', 'presentvalue', 'radtocycle', 'radtodeg', 'radtograd',
768
+ 'randg', 'randomrange', 'roundto', 'samevalue', 'sec', 'secant',
769
+ 'sech', 'setexceptionmask', 'setprecisionmode', 'setroundmode',
770
+ 'sign', 'simpleroundto', 'sincos', 'sinh', 'slndepreciation', 'stddev',
771
+ 'sum', 'sumint', 'sumofsquares', 'sumsandsquares', 'syddepreciation',
772
+ 'tan', 'tanh', 'totalvariance', 'variance'
773
+ ]
774
+ }
775
+
776
+ ASM_REGISTERS = set([
777
+ 'ah', 'al', 'ax', 'bh', 'bl', 'bp', 'bx', 'ch', 'cl', 'cr0',
778
+ 'cr1', 'cr2', 'cr3', 'cr4', 'cs', 'cx', 'dh', 'di', 'dl', 'dr0',
779
+ 'dr1', 'dr2', 'dr3', 'dr4', 'dr5', 'dr6', 'dr7', 'ds', 'dx',
780
+ 'eax', 'ebp', 'ebx', 'ecx', 'edi', 'edx', 'es', 'esi', 'esp',
781
+ 'fs', 'gs', 'mm0', 'mm1', 'mm2', 'mm3', 'mm4', 'mm5', 'mm6',
782
+ 'mm7', 'si', 'sp', 'ss', 'st0', 'st1', 'st2', 'st3', 'st4', 'st5',
783
+ 'st6', 'st7', 'xmm0', 'xmm1', 'xmm2', 'xmm3', 'xmm4', 'xmm5',
784
+ 'xmm6', 'xmm7'
785
+ ])
786
+
787
+ ASM_INSTRUCTIONS = set([
788
+ 'aaa', 'aad', 'aam', 'aas', 'adc', 'add', 'and', 'arpl', 'bound',
789
+ 'bsf', 'bsr', 'bswap', 'bt', 'btc', 'btr', 'bts', 'call', 'cbw',
790
+ 'cdq', 'clc', 'cld', 'cli', 'clts', 'cmc', 'cmova', 'cmovae',
791
+ 'cmovb', 'cmovbe', 'cmovc', 'cmovcxz', 'cmove', 'cmovg',
792
+ 'cmovge', 'cmovl', 'cmovle', 'cmovna', 'cmovnae', 'cmovnb',
793
+ 'cmovnbe', 'cmovnc', 'cmovne', 'cmovng', 'cmovnge', 'cmovnl',
794
+ 'cmovnle', 'cmovno', 'cmovnp', 'cmovns', 'cmovnz', 'cmovo',
795
+ 'cmovp', 'cmovpe', 'cmovpo', 'cmovs', 'cmovz', 'cmp', 'cmpsb',
796
+ 'cmpsd', 'cmpsw', 'cmpxchg', 'cmpxchg486', 'cmpxchg8b', 'cpuid',
797
+ 'cwd', 'cwde', 'daa', 'das', 'dec', 'div', 'emms', 'enter', 'hlt',
798
+ 'ibts', 'icebp', 'idiv', 'imul', 'in', 'inc', 'insb', 'insd',
799
+ 'insw', 'int', 'int01', 'int03', 'int1', 'int3', 'into', 'invd',
800
+ 'invlpg', 'iret', 'iretd', 'iretw', 'ja', 'jae', 'jb', 'jbe',
801
+ 'jc', 'jcxz', 'jcxz', 'je', 'jecxz', 'jg', 'jge', 'jl', 'jle',
802
+ 'jmp', 'jna', 'jnae', 'jnb', 'jnbe', 'jnc', 'jne', 'jng', 'jnge',
803
+ 'jnl', 'jnle', 'jno', 'jnp', 'jns', 'jnz', 'jo', 'jp', 'jpe',
804
+ 'jpo', 'js', 'jz', 'lahf', 'lar', 'lcall', 'lds', 'lea', 'leave',
805
+ 'les', 'lfs', 'lgdt', 'lgs', 'lidt', 'ljmp', 'lldt', 'lmsw',
806
+ 'loadall', 'loadall286', 'lock', 'lodsb', 'lodsd', 'lodsw',
807
+ 'loop', 'loope', 'loopne', 'loopnz', 'loopz', 'lsl', 'lss', 'ltr',
808
+ 'mov', 'movd', 'movq', 'movsb', 'movsd', 'movsw', 'movsx',
809
+ 'movzx', 'mul', 'neg', 'nop', 'not', 'or', 'out', 'outsb', 'outsd',
810
+ 'outsw', 'pop', 'popa', 'popad', 'popaw', 'popf', 'popfd', 'popfw',
811
+ 'push', 'pusha', 'pushad', 'pushaw', 'pushf', 'pushfd', 'pushfw',
812
+ 'rcl', 'rcr', 'rdmsr', 'rdpmc', 'rdshr', 'rdtsc', 'rep', 'repe',
813
+ 'repne', 'repnz', 'repz', 'ret', 'retf', 'retn', 'rol', 'ror',
814
+ 'rsdc', 'rsldt', 'rsm', 'sahf', 'sal', 'salc', 'sar', 'sbb',
815
+ 'scasb', 'scasd', 'scasw', 'seta', 'setae', 'setb', 'setbe',
816
+ 'setc', 'setcxz', 'sete', 'setg', 'setge', 'setl', 'setle',
817
+ 'setna', 'setnae', 'setnb', 'setnbe', 'setnc', 'setne', 'setng',
818
+ 'setnge', 'setnl', 'setnle', 'setno', 'setnp', 'setns', 'setnz',
819
+ 'seto', 'setp', 'setpe', 'setpo', 'sets', 'setz', 'sgdt', 'shl',
820
+ 'shld', 'shr', 'shrd', 'sidt', 'sldt', 'smi', 'smint', 'smintold',
821
+ 'smsw', 'stc', 'std', 'sti', 'stosb', 'stosd', 'stosw', 'str',
822
+ 'sub', 'svdc', 'svldt', 'svts', 'syscall', 'sysenter', 'sysexit',
823
+ 'sysret', 'test', 'ud1', 'ud2', 'umov', 'verr', 'verw', 'wait',
824
+ 'wbinvd', 'wrmsr', 'wrshr', 'xadd', 'xbts', 'xchg', 'xlat',
825
+ 'xlatb', 'xor'
826
+ ])
827
+
828
+ def __init__(self, **options):
829
+ Lexer.__init__(self, **options)
830
+ self.keywords = set()
831
+ if get_bool_opt(options, 'turbopascal', True):
832
+ self.keywords.update(self.TURBO_PASCAL_KEYWORDS)
833
+ if get_bool_opt(options, 'delphi', True):
834
+ self.keywords.update(self.DELPHI_KEYWORDS)
835
+ if get_bool_opt(options, 'freepascal', True):
836
+ self.keywords.update(self.FREE_PASCAL_KEYWORDS)
837
+ self.builtins = set()
838
+ for unit in get_list_opt(options, 'units', self.BUILTIN_UNITS.keys()):
839
+ self.builtins.update(self.BUILTIN_UNITS[unit])
840
+
841
+ def get_tokens_unprocessed(self, text):
842
+ scanner = Scanner(text, re.DOTALL | re.MULTILINE | re.IGNORECASE)
843
+ stack = ['initial']
844
+ in_function_block = False
845
+ in_property_block = False
846
+ was_dot = False
847
+ next_token_is_function = False
848
+ next_token_is_property = False
849
+ collect_labels = False
850
+ block_labels = set()
851
+ brace_balance = [0, 0]
852
+
853
+ while not scanner.eos:
854
+ token = Error
855
+
856
+ if stack[-1] == 'initial':
857
+ if scanner.scan(r'\s+'):
858
+ token = Text
859
+ elif scanner.scan(r'\{.*?\}|\(\*.*?\*\)'):
860
+ if scanner.match.startswith('$'):
861
+ token = Comment.Preproc
862
+ else:
863
+ token = Comment.Multiline
864
+ elif scanner.scan(r'//.*?$'):
865
+ token = Comment.Single
866
+ elif scanner.scan(r'[-+*\/=<>:;,.@\^]'):
867
+ token = Operator
868
+ # stop label highlighting on next ";"
869
+ if collect_labels and scanner.match == ';':
870
+ collect_labels = False
871
+ elif scanner.scan(r'[\(\)\[\]]+'):
872
+ token = Punctuation
873
+ # abort function naming ``foo = Function(...)``
874
+ next_token_is_function = False
875
+ # if we are in a function block we count the open
876
+ # braces because ootherwise it's impossible to
877
+ # determine the end of the modifier context
878
+ if in_function_block or in_property_block:
879
+ if scanner.match == '(':
880
+ brace_balance[0] += 1
881
+ elif scanner.match == ')':
882
+ brace_balance[0] -= 1
883
+ elif scanner.match == '[':
884
+ brace_balance[1] += 1
885
+ elif scanner.match == ']':
886
+ brace_balance[1] -= 1
887
+ elif scanner.scan(r'[A-Za-z_][A-Za-z_0-9]*'):
888
+ lowercase_name = scanner.match.lower()
889
+ if lowercase_name == 'result':
890
+ token = Name.Builtin.Pseudo
891
+ elif lowercase_name in self.keywords:
892
+ token = Keyword
893
+ # if we are in a special block and a
894
+ # block ending keyword occours (and the parenthesis
895
+ # is balanced) we end the current block context
896
+ if (in_function_block or in_property_block) and \
897
+ lowercase_name in self.BLOCK_KEYWORDS and \
898
+ brace_balance[0] <= 0 and \
899
+ brace_balance[1] <= 0:
900
+ in_function_block = False
901
+ in_property_block = False
902
+ brace_balance = [0, 0]
903
+ block_labels = set()
904
+ if lowercase_name in ('label', 'goto'):
905
+ collect_labels = True
906
+ elif lowercase_name == 'asm':
907
+ stack.append('asm')
908
+ elif lowercase_name == 'property':
909
+ in_property_block = True
910
+ next_token_is_property = True
911
+ elif lowercase_name in ('procedure', 'operator',
912
+ 'function', 'constructor',
913
+ 'destructor'):
914
+ in_function_block = True
915
+ next_token_is_function = True
916
+ # we are in a function block and the current name
917
+ # is in the set of registered modifiers. highlight
918
+ # it as pseudo keyword
919
+ elif in_function_block and \
920
+ lowercase_name in self.FUNCTION_MODIFIERS:
921
+ token = Keyword.Pseudo
922
+ # if we are in a property highlight some more
923
+ # modifiers
924
+ elif in_property_block and \
925
+ lowercase_name in ('read', 'write'):
926
+ token = Keyword.Pseudo
927
+ next_token_is_function = True
928
+ # if the last iteration set next_token_is_function
929
+ # to true we now want this name highlighted as
930
+ # function. so do that and reset the state
931
+ elif next_token_is_function:
932
+ # Look if the next token is a dot. If yes it's
933
+ # not a function, but a class name and the
934
+ # part after the dot a function name
935
+ if scanner.test(r'\s*\.\s*'):
936
+ token = Name.Class
937
+ # it's not a dot, our job is done
938
+ else:
939
+ token = Name.Function
940
+ next_token_is_function = False
941
+ # same for properties
942
+ elif next_token_is_property:
943
+ token = Name.Property
944
+ next_token_is_property = False
945
+ # Highlight this token as label and add it
946
+ # to the list of known labels
947
+ elif collect_labels:
948
+ token = Name.Label
949
+ block_labels.add(scanner.match.lower())
950
+ # name is in list of known labels
951
+ elif lowercase_name in block_labels:
952
+ token = Name.Label
953
+ elif lowercase_name in self.BUILTIN_TYPES:
954
+ token = Keyword.Type
955
+ elif lowercase_name in self.DIRECTIVES:
956
+ token = Keyword.Pseudo
957
+ # builtins are just builtins if the token
958
+ # before isn't a dot
959
+ elif not was_dot and lowercase_name in self.builtins:
960
+ token = Name.Builtin
961
+ else:
962
+ token = Name
963
+ elif scanner.scan(r"'"):
964
+ token = String
965
+ stack.append('string')
966
+ elif scanner.scan(r'\#(\d+|\$[0-9A-Fa-f]+)'):
967
+ token = String.Char
968
+ elif scanner.scan(r'\$[0-9A-Fa-f]+'):
969
+ token = Number.Hex
970
+ elif scanner.scan(r'\d+(?![eE]|\.[^.])'):
971
+ token = Number.Integer
972
+ elif scanner.scan(r'\d+(\.\d+([eE][+-]?\d+)?|[eE][+-]?\d+)'):
973
+ token = Number.Float
974
+ else:
975
+ # if the stack depth is deeper than once, pop
976
+ if len(stack) > 1:
977
+ stack.pop()
978
+ scanner.get_char()
979
+
980
+ elif stack[-1] == 'string':
981
+ if scanner.scan(r"''"):
982
+ token = String.Escape
983
+ elif scanner.scan(r"'"):
984
+ token = String
985
+ stack.pop()
986
+ elif scanner.scan(r"[^']*"):
987
+ token = String
988
+ else:
989
+ scanner.get_char()
990
+ stack.pop()
991
+
992
+ elif stack[-1] == 'asm':
993
+ if scanner.scan(r'\s+'):
994
+ token = Text
995
+ elif scanner.scan(r'end'):
996
+ token = Keyword
997
+ stack.pop()
998
+ elif scanner.scan(r'\{.*?\}|\(\*.*?\*\)'):
999
+ if scanner.match.startswith('$'):
1000
+ token = Comment.Preproc
1001
+ else:
1002
+ token = Comment.Multiline
1003
+ elif scanner.scan(r'//.*?$'):
1004
+ token = Comment.Single
1005
+ elif scanner.scan(r"'"):
1006
+ token = String
1007
+ stack.append('string')
1008
+ elif scanner.scan(r'@@[A-Za-z_][A-Za-z_0-9]*'):
1009
+ token = Name.Label
1010
+ elif scanner.scan(r'[A-Za-z_][A-Za-z_0-9]*'):
1011
+ lowercase_name = scanner.match.lower()
1012
+ if lowercase_name in self.ASM_INSTRUCTIONS:
1013
+ token = Keyword
1014
+ elif lowercase_name in self.ASM_REGISTERS:
1015
+ token = Name.Builtin
1016
+ else:
1017
+ token = Name
1018
+ elif scanner.scan(r'[-+*\/=<>:;,.@\^]+'):
1019
+ token = Operator
1020
+ elif scanner.scan(r'[\(\)\[\]]+'):
1021
+ token = Punctuation
1022
+ elif scanner.scan(r'\$[0-9A-Fa-f]+'):
1023
+ token = Number.Hex
1024
+ elif scanner.scan(r'\d+(?![eE]|\.[^.])'):
1025
+ token = Number.Integer
1026
+ elif scanner.scan(r'\d+(\.\d+([eE][+-]?\d+)?|[eE][+-]?\d+)'):
1027
+ token = Number.Float
1028
+ else:
1029
+ scanner.get_char()
1030
+ stack.pop()
1031
+
1032
+ # save the dot!!!11
1033
+ if scanner.match.strip():
1034
+ was_dot = scanner.match == '.'
1035
+ yield scanner.start_pos, token, scanner.match or ''
1036
+
1037
+
1038
+ class DylanLexer(RegexLexer):
1039
+ """
1040
+ For the `Dylan <http://www.opendylan.org/>`_ language.
1041
+
1042
+ *New in Pygments 0.7.*
1043
+ """
1044
+
1045
+ name = 'Dylan'
1046
+ aliases = ['dylan']
1047
+ filenames = ['*.dylan', '*.dyl', '*.intr']
1048
+ mimetypes = ['text/x-dylan']
1049
+
1050
+ flags = re.IGNORECASE
1051
+
1052
+ builtins = set([
1053
+ 'subclass', 'abstract', 'block', 'concrete', 'constant', 'class',
1054
+ 'compiler-open', 'compiler-sideways', 'domain', 'dynamic',
1055
+ 'each-subclass', 'exception', 'exclude', 'function', 'generic',
1056
+ 'handler', 'inherited', 'inline', 'inline-only', 'instance',
1057
+ 'interface', 'import', 'keyword', 'library', 'macro', 'method',
1058
+ 'module', 'open', 'primary', 'required', 'sealed', 'sideways',
1059
+ 'singleton', 'slot', 'thread', 'variable', 'virtual'])
1060
+
1061
+ keywords = set([
1062
+ 'above', 'afterwards', 'begin', 'below', 'by', 'case', 'cleanup',
1063
+ 'create', 'define', 'else', 'elseif', 'end', 'export', 'finally',
1064
+ 'for', 'from', 'if', 'in', 'let', 'local', 'otherwise', 'rename',
1065
+ 'select', 'signal', 'then', 'to', 'unless', 'until', 'use', 'when',
1066
+ 'while'])
1067
+
1068
+ operators = set([
1069
+ '~', '+', '-', '*', '|', '^', '=', '==', '~=', '~==', '<', '<=',
1070
+ '>', '>=', '&', '|'])
1071
+
1072
+ functions = set([
1073
+ 'abort', 'abs', 'add', 'add!', 'add-method', 'add-new', 'add-new!',
1074
+ 'all-superclasses', 'always', 'any?', 'applicable-method?', 'apply',
1075
+ 'aref', 'aref-setter', 'as', 'as-lowercase', 'as-lowercase!',
1076
+ 'as-uppercase', 'as-uppercase!', 'ash', 'backward-iteration-protocol',
1077
+ 'break', 'ceiling', 'ceiling/', 'cerror', 'check-type', 'choose',
1078
+ 'choose-by', 'complement', 'compose', 'concatenate', 'concatenate-as',
1079
+ 'condition-format-arguments', 'condition-format-string', 'conjoin',
1080
+ 'copy-sequence', 'curry', 'default-handler', 'dimension', 'dimensions',
1081
+ 'direct-subclasses', 'direct-superclasses', 'disjoin', 'do',
1082
+ 'do-handlers', 'element', 'element-setter', 'empty?', 'error', 'even?',
1083
+ 'every?', 'false-or', 'fill!', 'find-key', 'find-method', 'first',
1084
+ 'first-setter', 'floor', 'floor/', 'forward-iteration-protocol',
1085
+ 'function-arguments', 'function-return-values',
1086
+ 'function-specializers', 'gcd', 'generic-function-mandatory-keywords',
1087
+ 'generic-function-methods', 'head', 'head-setter', 'identity',
1088
+ 'initialize', 'instance?', 'integral?', 'intersection',
1089
+ 'key-sequence', 'key-test', 'last', 'last-setter', 'lcm', 'limited',
1090
+ 'list', 'logand', 'logbit?', 'logior', 'lognot', 'logxor', 'make',
1091
+ 'map', 'map-as', 'map-into', 'max', 'member?', 'merge-hash-codes',
1092
+ 'min', 'modulo', 'negative', 'negative?', 'next-method',
1093
+ 'object-class', 'object-hash', 'odd?', 'one-of', 'pair', 'pop',
1094
+ 'pop-last', 'positive?', 'push', 'push-last', 'range', 'rank',
1095
+ 'rcurry', 'reduce', 'reduce1', 'remainder', 'remove', 'remove!',
1096
+ 'remove-duplicates', 'remove-duplicates!', 'remove-key!',
1097
+ 'remove-method', 'replace-elements!', 'replace-subsequence!',
1098
+ 'restart-query', 'return-allowed?', 'return-description',
1099
+ 'return-query', 'reverse', 'reverse!', 'round', 'round/',
1100
+ 'row-major-index', 'second', 'second-setter', 'shallow-copy',
1101
+ 'signal', 'singleton', 'size', 'size-setter', 'slot-initialized?',
1102
+ 'sort', 'sort!', 'sorted-applicable-methods', 'subsequence-position',
1103
+ 'subtype?', 'table-protocol', 'tail', 'tail-setter', 'third',
1104
+ 'third-setter', 'truncate', 'truncate/', 'type-error-expected-type',
1105
+ 'type-error-value', 'type-for-copy', 'type-union', 'union', 'values',
1106
+ 'vector', 'zero?'])
1107
+
1108
+ valid_name = '\\\\?[a-zA-Z0-9' + re.escape('!&*<>|^$%@_-+~?/=') + ']+'
1109
+
1110
+ def get_tokens_unprocessed(self, text):
1111
+ for index, token, value in RegexLexer.get_tokens_unprocessed(self, text):
1112
+ if token is Name:
1113
+ lowercase_value = value.lower()
1114
+ if lowercase_value in self.builtins:
1115
+ yield index, Name.Builtin, value
1116
+ continue
1117
+ if lowercase_value in self.keywords:
1118
+ yield index, Keyword, value
1119
+ continue
1120
+ if lowercase_value in self.functions:
1121
+ yield index, Name.Builtin, value
1122
+ continue
1123
+ if lowercase_value in self.operators:
1124
+ yield index, Operator, value
1125
+ continue
1126
+ yield index, token, value
1127
+
1128
+ tokens = {
1129
+ 'root': [
1130
+ # Whitespace
1131
+ (r'\s+', Text),
1132
+
1133
+ # single line comment
1134
+ (r'//.*?\n', Comment.Single),
1135
+
1136
+ # lid header
1137
+ (r'([A-Za-z0-9-]+)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
1138
+ bygroups(Name.Attribute, Operator, Text, String)),
1139
+
1140
+ ('', Text, 'code') # no header match, switch to code
1141
+ ],
1142
+ 'code': [
1143
+ # Whitespace
1144
+ (r'\s+', Text),
1145
+
1146
+ # single line comment
1147
+ (r'//.*?\n', Comment.Single),
1148
+
1149
+ # multi-line comment
1150
+ (r'/\*', Comment.Multiline, 'comment'),
1151
+
1152
+ # strings and characters
1153
+ (r'"', String, 'string'),
1154
+ (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
1155
+
1156
+ # binary integer
1157
+ (r'#[bB][01]+', Number),
1158
+
1159
+ # octal integer
1160
+ (r'#[oO][0-7]+', Number.Oct),
1161
+
1162
+ # floating point
1163
+ (r'[-+]?(\d*\.\d+(e[-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)', Number.Float),
1164
+
1165
+ # decimal integer
1166
+ (r'[-+]?\d+', Number.Integer),
1167
+
1168
+ # hex integer
1169
+ (r'#[xX][0-9a-fA-F]+', Number.Hex),
1170
+
1171
+ # Macro parameters
1172
+ (r'(\?' + valid_name + ')(:)'
1173
+ r'(token|name|variable|expression|body|case-body|\*)',
1174
+ bygroups(Name.Tag, Operator, Name.Builtin)),
1175
+ (r'(\?)(:)(token|name|variable|expression|body|case-body|\*)',
1176
+ bygroups(Name.Tag, Operator, Name.Builtin)),
1177
+ (r'\?' + valid_name, Name.Tag),
1178
+
1179
+ # Punctuation
1180
+ (r'(=>|::|#\(|#\[|##|\?|\?\?|\?=|[(){}\[\],\.;])', Punctuation),
1181
+
1182
+ # Most operators are picked up as names and then re-flagged.
1183
+ # This one isn't valid in a name though, so we pick it up now.
1184
+ (r':=', Operator),
1185
+
1186
+ # Pick up #t / #f before we match other stuff with #.
1187
+ (r'#[tf]', Literal),
1188
+
1189
+ # #"foo" style keywords
1190
+ (r'#"', String.Symbol, 'keyword'),
1191
+
1192
+ # #rest, #key, #all-keys, etc.
1193
+ (r'#[a-zA-Z0-9-]+', Keyword),
1194
+
1195
+ # required-init-keyword: style keywords.
1196
+ (valid_name + ':', Keyword),
1197
+
1198
+ # class names
1199
+ (r'<' + valid_name + '>', Name.Class),
1200
+
1201
+ # define variable forms.
1202
+ (r'\*' + valid_name + '\*', Name.Variable.Global),
1203
+
1204
+ # define constant forms.
1205
+ (r'\$' + valid_name, Name.Constant),
1206
+
1207
+ # everything else. We re-flag some of these in the method above.
1208
+ (valid_name, Name),
1209
+ ],
1210
+ 'comment': [
1211
+ (r'[^*/]', Comment.Multiline),
1212
+ (r'/\*', Comment.Multiline, '#push'),
1213
+ (r'\*/', Comment.Multiline, '#pop'),
1214
+ (r'[*/]', Comment.Multiline)
1215
+ ],
1216
+ 'keyword': [
1217
+ (r'"', String.Symbol, '#pop'),
1218
+ (r'[^\\"]+', String.Symbol), # all other characters
1219
+ ],
1220
+ 'string': [
1221
+ (r'"', String, '#pop'),
1222
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
1223
+ (r'[^\\"\n]+', String), # all other characters
1224
+ (r'\\\n', String), # line continuation
1225
+ (r'\\', String), # stray backslash
1226
+ ]
1227
+ }
1228
+
1229
+
1230
+ class DylanLidLexer(RegexLexer):
1231
+ """
1232
+ For Dylan LID (Library Interchange Definition) files.
1233
+
1234
+ *New in Pygments 1.6.*
1235
+ """
1236
+
1237
+ name = 'DylanLID'
1238
+ aliases = ['dylan-lid', 'lid']
1239
+ filenames = ['*.lid', '*.hdp']
1240
+ mimetypes = ['text/x-dylan-lid']
1241
+
1242
+ flags = re.IGNORECASE
1243
+
1244
+ tokens = {
1245
+ 'root': [
1246
+ # Whitespace
1247
+ (r'\s+', Text),
1248
+
1249
+ # single line comment
1250
+ (r'//.*?\n', Comment.Single),
1251
+
1252
+ # lid header
1253
+ (r'(.*?)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
1254
+ bygroups(Name.Attribute, Operator, Text, String)),
1255
+ ]
1256
+ }
1257
+
1258
+
1259
+ class DylanConsoleLexer(Lexer):
1260
+ """
1261
+ For Dylan interactive console output like:
1262
+
1263
+ .. sourcecode:: dylan-console
1264
+
1265
+ ? let a = 1;
1266
+ => 1
1267
+ ? a
1268
+ => 1
1269
+
1270
+ This is based on a copy of the RubyConsoleLexer.
1271
+
1272
+ *New in Pygments 1.6.*
1273
+ """
1274
+ name = 'Dylan session'
1275
+ aliases = ['dylan-console', 'dylan-repl']
1276
+ filenames = ['*.dylan-console']
1277
+ mimetypes = ['text/x-dylan-console']
1278
+
1279
+ _line_re = re.compile('.*?\n')
1280
+ _prompt_re = re.compile('\?| ')
1281
+
1282
+ def get_tokens_unprocessed(self, text):
1283
+ dylexer = DylanLexer(**self.options)
1284
+
1285
+ curcode = ''
1286
+ insertions = []
1287
+ for match in self._line_re.finditer(text):
1288
+ line = match.group()
1289
+ m = self._prompt_re.match(line)
1290
+ if m is not None:
1291
+ end = m.end()
1292
+ insertions.append((len(curcode),
1293
+ [(0, Generic.Prompt, line[:end])]))
1294
+ curcode += line[end:]
1295
+ else:
1296
+ if curcode:
1297
+ for item in do_insertions(insertions,
1298
+ dylexer.get_tokens_unprocessed(curcode)):
1299
+ yield item
1300
+ curcode = ''
1301
+ insertions = []
1302
+ yield match.start(), Generic.Output, line
1303
+ if curcode:
1304
+ for item in do_insertions(insertions,
1305
+ dylexer.get_tokens_unprocessed(curcode)):
1306
+ yield item
1307
+
1308
+
1309
+ def objective(baselexer):
1310
+ """
1311
+ Generate a subclass of baselexer that accepts the Objective-C syntax
1312
+ extensions.
1313
+ """
1314
+
1315
+ # Have to be careful not to accidentally match JavaDoc/Doxygen syntax here,
1316
+ # since that's quite common in ordinary C/C++ files. It's OK to match
1317
+ # JavaDoc/Doxygen keywords that only apply to Objective-C, mind.
1318
+ #
1319
+ # The upshot of this is that we CANNOT match @class or @interface
1320
+ _oc_keywords = re.compile(r'@(?:end|implementation|protocol)')
1321
+
1322
+ # Matches [ <ws>? identifier <ws> ( identifier <ws>? ] | identifier? : )
1323
+ # (note the identifier is *optional* when there is a ':'!)
1324
+ _oc_message = re.compile(r'\[\s*[a-zA-Z_][a-zA-Z0-9_]*\s+'
1325
+ r'(?:[a-zA-Z_][a-zA-Z0-9_]*\s*\]|'
1326
+ r'(?:[a-zA-Z_][a-zA-Z0-9_]*)?:)')
1327
+
1328
+ class GeneratedObjectiveCVariant(baselexer):
1329
+ """
1330
+ Implements Objective-C syntax on top of an existing C family lexer.
1331
+ """
1332
+
1333
+ tokens = {
1334
+ 'statements': [
1335
+ (r'@"', String, 'string'),
1336
+ (r"@'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
1337
+ String.Char),
1338
+ (r'@(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
1339
+ (r'@(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
1340
+ (r'@0x[0-9a-fA-F]+[Ll]?', Number.Hex),
1341
+ (r'@0[0-7]+[Ll]?', Number.Oct),
1342
+ (r'@\d+[Ll]?', Number.Integer),
1343
+ (r'(in|@selector|@private|@protected|@public|@encode|'
1344
+ r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
1345
+ r'@synthesize|@dynamic|@optional)\b', Keyword),
1346
+ (r'(id|Class|IMP|SEL|BOOL|IBOutlet|IBAction|unichar)\b',
1347
+ Keyword.Type),
1348
+ (r'@(true|false|YES|NO)\n', Name.Builtin),
1349
+ (r'(YES|NO|nil)\b', Name.Builtin),
1350
+ (r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
1351
+ ('#pop', 'oc_classname')),
1352
+ (r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
1353
+ ('#pop', 'oc_forward_classname')),
1354
+ # @ can also prefix other expressions like @{...} or @(...)
1355
+ (r'@', Punctuation),
1356
+ inherit,
1357
+ ],
1358
+ 'oc_classname' : [
1359
+ # interface definition that inherits
1360
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
1361
+ bygroups(Name.Class, Text, Name.Class), '#pop'),
1362
+ # interface definition for a category
1363
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\([a-zA-Z$_][a-zA-Z0-9$_]*\))',
1364
+ bygroups(Name.Class, Text, Name.Label), '#pop'),
1365
+ # simple interface / implementation
1366
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
1367
+ ],
1368
+ 'oc_forward_classname' : [
1369
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*,\s*)',
1370
+ bygroups(Name.Class, Text), 'oc_forward_classname'),
1371
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*;?)',
1372
+ bygroups(Name.Class, Text), '#pop')
1373
+ ],
1374
+ 'root': [
1375
+ # methods
1376
+ (r'^([-+])(\s*)' # method marker
1377
+ r'(\(.*?\))?(\s*)' # return type
1378
+ r'([a-zA-Z$_][a-zA-Z0-9$_]*:?)', # begin of method name
1379
+ bygroups(Keyword, Text, using(this),
1380
+ Text, Name.Function),
1381
+ 'method'),
1382
+ inherit,
1383
+ ],
1384
+ 'method': [
1385
+ include('whitespace'),
1386
+ # TODO unsure if ellipses are allowed elsewhere, see
1387
+ # discussion in Issue 789
1388
+ (r',', Punctuation),
1389
+ (r'\.\.\.', Punctuation),
1390
+ (r'(\(.*?\))([a-zA-Z$_][a-zA-Z0-9$_]*)', bygroups(using(this),
1391
+ Name.Variable)),
1392
+ (r'[a-zA-Z$_][a-zA-Z0-9$_]*:', Name.Function),
1393
+ (';', Punctuation, '#pop'),
1394
+ ('{', Punctuation, 'function'),
1395
+ ('', Text, '#pop'),
1396
+ ],
1397
+ }
1398
+
1399
+ def analyse_text(text):
1400
+ if _oc_keywords.search(text):
1401
+ return 1.0
1402
+ elif '@"' in text: # strings
1403
+ return 0.8
1404
+ elif _oc_message.search(text):
1405
+ return 0.8
1406
+ return 0
1407
+
1408
+ return GeneratedObjectiveCVariant
1409
+
1410
+
1411
+ class ObjectiveCLexer(objective(CLexer)):
1412
+ """
1413
+ For Objective-C source code with preprocessor directives.
1414
+ """
1415
+
1416
+ name = 'Objective-C'
1417
+ aliases = ['objective-c', 'objectivec', 'obj-c', 'objc']
1418
+ filenames = ['*.m', '*.h']
1419
+ mimetypes = ['text/x-objective-c']
1420
+ priority = 0.05 # Lower than C
1421
+
1422
+
1423
+ class ObjectiveCppLexer(objective(CppLexer)):
1424
+ """
1425
+ For Objective-C++ source code with preprocessor directives.
1426
+ """
1427
+
1428
+ name = 'Objective-C++'
1429
+ aliases = ['objective-c++', 'objectivec++', 'obj-c++', 'objc++']
1430
+ filenames = ['*.mm', '*.hh']
1431
+ mimetypes = ['text/x-objective-c++']
1432
+ priority = 0.05 # Lower than C++
1433
+
1434
+
1435
+ class FortranLexer(RegexLexer):
1436
+ """
1437
+ Lexer for FORTRAN 90 code.
1438
+
1439
+ *New in Pygments 0.10.*
1440
+ """
1441
+ name = 'Fortran'
1442
+ aliases = ['fortran']
1443
+ filenames = ['*.f', '*.f90', '*.F', '*.F90']
1444
+ mimetypes = ['text/x-fortran']
1445
+ flags = re.IGNORECASE
1446
+
1447
+ # Data Types: INTEGER, REAL, COMPLEX, LOGICAL, CHARACTER and DOUBLE PRECISION
1448
+ # Operators: **, *, +, -, /, <, >, <=, >=, ==, /=
1449
+ # Logical (?): NOT, AND, OR, EQV, NEQV
1450
+
1451
+ # Builtins:
1452
+ # http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Table-of-Intrinsic-Functions.html
1453
+
1454
+ tokens = {
1455
+ 'root': [
1456
+ (r'!.*\n', Comment),
1457
+ include('strings'),
1458
+ include('core'),
1459
+ (r'[a-z][a-z0-9_]*', Name.Variable),
1460
+ include('nums'),
1461
+ (r'[\s]+', Text),
1462
+ ],
1463
+ 'core': [
1464
+ # Statements
1465
+ (r'\b(ABSTRACT|ACCEPT|ALLOCATABLE|ALLOCATE|ARRAY|ASSIGN|ASYNCHRONOUS|'
1466
+ r'BACKSPACE|BIND|BLOCK( DATA)?|BYTE|CALL|CASE|CLASS|CLOSE|COMMON|CONTAINS|'
1467
+ r'CONTINUE|CYCLE|DATA|DEALLOCATE|DECODE|DEFERRED|DIMENSION|DO|'
1468
+ r'ELEMENTAL|ELSE|ENCODE|END( FILE)?|ENDIF|ENTRY|ENUMERATOR|EQUIVALENCE|'
1469
+ r'EXIT|EXTERNAL|EXTRINSIC|FINAL|FORALL|FORMAT|FUNCTION|GENERIC|'
1470
+ r'GOTO|IF|IMPLICIT|IMPORT|INCLUDE|INQUIRE|INTENT|INTERFACE|'
1471
+ r'INTRINSIC|MODULE|NAMELIST|NULLIFY|NONE|NON_INTRINSIC|'
1472
+ r'NON_OVERRIDABLE|NOPASS|OPEN|OPTIONAL|OPTIONS|PARAMETER|PASS|'
1473
+ r'PAUSE|POINTER|PRINT|PRIVATE|PROGRAM|PROTECTED|PUBLIC|PURE|READ|'
1474
+ r'RECURSIVE|RESULT|RETURN|REWIND|SAVE|SELECT|SEQUENCE|STOP|SUBROUTINE|'
1475
+ r'TARGET|THEN|TYPE|USE|VALUE|VOLATILE|WHERE|WRITE|WHILE)\s*\b',
1476
+ Keyword),
1477
+
1478
+ # Data Types
1479
+ (r'\b(CHARACTER|COMPLEX|DOUBLE PRECISION|DOUBLE COMPLEX|INTEGER|'
1480
+ r'LOGICAL|REAL|C_INT|C_SHORT|C_LONG|C_LONG_LONG|C_SIGNED_CHAR|'
1481
+ r'C_SIZE_T|C_INT8_T|C_INT16_T|C_INT32_T|C_INT64_T|C_INT_LEAST8_T|'
1482
+ r'C_INT_LEAST16_T|C_INT_LEAST32_T|C_INT_LEAST64_T|C_INT_FAST8_T|'
1483
+ r'C_INT_FAST16_T|C_INT_FAST32_T|C_INT_FAST64_T|C_INTMAX_T|'
1484
+ r'C_INTPTR_T|C_FLOAT|C_DOUBLE|C_LONG_DOUBLE|C_FLOAT_COMPLEX|'
1485
+ r'C_DOUBLE_COMPLEX|C_LONG_DOUBLE_COMPLEX|C_BOOL|C_CHAR|C_PTR|'
1486
+ r'C_FUNPTR)\s*\b',
1487
+ Keyword.Type),
1488
+
1489
+ # Operators
1490
+ (r'(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=)', Operator),
1491
+
1492
+ (r'(::)', Keyword.Declaration),
1493
+
1494
+ (r'[(),:&%;]', Punctuation),
1495
+
1496
+ # Intrinsics
1497
+ (r'\b(Abort|Abs|Access|AChar|ACos|AdjustL|AdjustR|AImag|AInt|Alarm|'
1498
+ r'All|Allocated|ALog|AMax|AMin|AMod|And|ANInt|Any|ASin|Associated|'
1499
+ r'ATan|BesJ|BesJN|BesY|BesYN|Bit_Size|BTest|CAbs|CCos|Ceiling|'
1500
+ r'CExp|Char|ChDir|ChMod|CLog|Cmplx|Command_Argument_Count|Complex|'
1501
+ r'Conjg|Cos|CosH|Count|CPU_Time|CShift|CSin|CSqRt|CTime|C_Funloc|'
1502
+ r'C_Loc|C_Associated|C_Null_Ptr|C_Null_Funptr|C_F_Pointer|'
1503
+ r'C_Null_Char|C_Alert|C_Backspace|C_Form_Feed|C_New_Line|'
1504
+ r'C_Carriage_Return|C_Horizontal_Tab|C_Vertical_Tab|'
1505
+ r'DAbs|DACos|DASin|DATan|Date_and_Time|DbesJ|'
1506
+ r'DbesJ|DbesJN|DbesY|DbesY|DbesYN|Dble|DCos|DCosH|DDiM|DErF|DErFC|'
1507
+ r'DExp|Digits|DiM|DInt|DLog|DLog|DMax|DMin|DMod|DNInt|Dot_Product|'
1508
+ r'DProd|DSign|DSinH|DSin|DSqRt|DTanH|DTan|DTime|EOShift|Epsilon|'
1509
+ r'ErF|ErFC|ETime|Exit|Exp|Exponent|Extends_Type_Of|FDate|FGet|'
1510
+ r'FGetC|Float|Floor|Flush|FNum|FPutC|FPut|Fraction|FSeek|FStat|'
1511
+ r'FTell|GError|GetArg|Get_Command|Get_Command_Argument|'
1512
+ r'Get_Environment_Variable|GetCWD|GetEnv|GetGId|GetLog|GetPId|'
1513
+ r'GetUId|GMTime|HostNm|Huge|IAbs|IAChar|IAnd|IArgC|IBClr|IBits|'
1514
+ r'IBSet|IChar|IDate|IDiM|IDInt|IDNInt|IEOr|IErrNo|IFix|Imag|'
1515
+ r'ImagPart|Index|Int|IOr|IRand|IsaTty|IShft|IShftC|ISign|'
1516
+ r'Iso_C_Binding|Is_Iostat_End|Is_Iostat_Eor|ITime|Kill|Kind|'
1517
+ r'LBound|Len|Len_Trim|LGe|LGt|Link|LLe|LLt|LnBlnk|Loc|Log|'
1518
+ r'Logical|Long|LShift|LStat|LTime|MatMul|Max|MaxExponent|MaxLoc|'
1519
+ r'MaxVal|MClock|Merge|Move_Alloc|Min|MinExponent|MinLoc|MinVal|'
1520
+ r'Mod|Modulo|MvBits|Nearest|New_Line|NInt|Not|Or|Pack|PError|'
1521
+ r'Precision|Present|Product|Radix|Rand|Random_Number|Random_Seed|'
1522
+ r'Range|Real|RealPart|Rename|Repeat|Reshape|RRSpacing|RShift|'
1523
+ r'Same_Type_As|Scale|Scan|Second|Selected_Int_Kind|'
1524
+ r'Selected_Real_Kind|Set_Exponent|Shape|Short|Sign|Signal|SinH|'
1525
+ r'Sin|Sleep|Sngl|Spacing|Spread|SqRt|SRand|Stat|Sum|SymLnk|'
1526
+ r'System|System_Clock|Tan|TanH|Time|Tiny|Transfer|Transpose|Trim|'
1527
+ r'TtyNam|UBound|UMask|Unlink|Unpack|Verify|XOr|ZAbs|ZCos|ZExp|'
1528
+ r'ZLog|ZSin|ZSqRt)\s*\b',
1529
+ Name.Builtin),
1530
+
1531
+ # Booleans
1532
+ (r'\.(true|false)\.', Name.Builtin),
1533
+ # Comparing Operators
1534
+ (r'\.(eq|ne|lt|le|gt|ge|not|and|or|eqv|neqv)\.', Operator.Word),
1535
+ ],
1536
+
1537
+ 'strings': [
1538
+ (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
1539
+ (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
1540
+ ],
1541
+
1542
+ 'nums': [
1543
+ (r'\d+(?![.Ee])', Number.Integer),
1544
+ (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
1545
+ (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float),
1546
+ ],
1547
+ }
1548
+
1549
+
1550
+ class GLShaderLexer(RegexLexer):
1551
+ """
1552
+ GLSL (OpenGL Shader) lexer.
1553
+
1554
+ *New in Pygments 1.1.*
1555
+ """
1556
+ name = 'GLSL'
1557
+ aliases = ['glsl']
1558
+ filenames = ['*.vert', '*.frag', '*.geo']
1559
+ mimetypes = ['text/x-glslsrc']
1560
+
1561
+ tokens = {
1562
+ 'root': [
1563
+ (r'^#.*', Comment.Preproc),
1564
+ (r'//.*', Comment.Single),
1565
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
1566
+ (r'\+|-|~|!=?|\*|/|%|<<|>>|<=?|>=?|==?|&&?|\^|\|\|?',
1567
+ Operator),
1568
+ (r'[?:]', Operator), # quick hack for ternary
1569
+ (r'\bdefined\b', Operator),
1570
+ (r'[;{}(),\[\]]', Punctuation),
1571
+ #FIXME when e is present, no decimal point needed
1572
+ (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
1573
+ (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float),
1574
+ (r'0[xX][0-9a-fA-F]*', Number.Hex),
1575
+ (r'0[0-7]*', Number.Oct),
1576
+ (r'[1-9][0-9]*', Number.Integer),
1577
+ (r'\b(attribute|const|uniform|varying|centroid|break|continue|'
1578
+ r'do|for|while|if|else|in|out|inout|float|int|void|bool|true|'
1579
+ r'false|invariant|discard|return|mat[234]|mat[234]x[234]|'
1580
+ r'vec[234]|[ib]vec[234]|sampler[123]D|samplerCube|'
1581
+ r'sampler[12]DShadow|struct)\b', Keyword),
1582
+ (r'\b(asm|class|union|enum|typedef|template|this|packed|goto|'
1583
+ r'switch|default|inline|noinline|volatile|public|static|extern|'
1584
+ r'external|interface|long|short|double|half|fixed|unsigned|'
1585
+ r'lowp|mediump|highp|precision|input|output|hvec[234]|'
1586
+ r'[df]vec[234]|sampler[23]DRect|sampler2DRectShadow|sizeof|'
1587
+ r'cast|namespace|using)\b', Keyword), #future use
1588
+ (r'[a-zA-Z_][a-zA-Z_0-9]*', Name),
1589
+ (r'\.', Punctuation),
1590
+ (r'\s+', Text),
1591
+ ],
1592
+ }
1593
+
1594
+
1595
+ class PrologLexer(RegexLexer):
1596
+ """
1597
+ Lexer for Prolog files.
1598
+ """
1599
+ name = 'Prolog'
1600
+ aliases = ['prolog']
1601
+ filenames = ['*.prolog', '*.pro', '*.pl']
1602
+ mimetypes = ['text/x-prolog']
1603
+
1604
+ flags = re.UNICODE
1605
+
1606
+ tokens = {
1607
+ 'root': [
1608
+ (r'^#.*', Comment.Single),
1609
+ (r'/\*', Comment.Multiline, 'nested-comment'),
1610
+ (r'%.*', Comment.Single),
1611
+ # character literal
1612
+ (r'0\'.', String.Char),
1613
+ (r'0b[01]+', Number.Bin),
1614
+ (r'0o[0-7]+', Number.Oct),
1615
+ (r'0x[0-9a-fA-F]+', Number.Hex),
1616
+ # literal with prepended base
1617
+ (r'\d\d?\'[a-zA-Z0-9]+', Number.Integer),
1618
+ (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
1619
+ (r'\d+', Number.Integer),
1620
+ (r'[\[\](){}|.,;!]', Punctuation),
1621
+ (r':-|-->', Punctuation),
1622
+ (r'"(?:\\x[0-9a-fA-F]+\\|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|'
1623
+ r'\\[0-7]+\\|\\[\w\W]|[^"])*"', String.Double),
1624
+ (r"'(?:''|[^'])*'", String.Atom), # quoted atom
1625
+ # Needs to not be followed by an atom.
1626
+ #(r'=(?=\s|[a-zA-Z\[])', Operator),
1627
+ (r'is\b', Operator),
1628
+ (r'(<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])',
1629
+ Operator),
1630
+ (r'(mod|div|not)\b', Operator),
1631
+ (r'_', Keyword), # The don't-care variable
1632
+ (r'([a-z]+)(:)', bygroups(Name.Namespace, Punctuation)),
1633
+ (u'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
1634
+ u'[a-zA-Z0-9_$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
1635
+ u'(\\s*)(:-|-->)',
1636
+ bygroups(Name.Function, Text, Operator)), # function defn
1637
+ (u'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
1638
+ u'[a-zA-Z0-9_$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
1639
+ u'(\\s*)(\\()',
1640
+ bygroups(Name.Function, Text, Punctuation)),
1641
+ (u'[a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
1642
+ u'[a-zA-Z0-9_$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*',
1643
+ String.Atom), # atom, characters
1644
+ # This one includes !
1645
+ (u'[#&*+\\-./:<=>?@\\\\^~\u00a1-\u00bf\u2010-\u303f]+',
1646
+ String.Atom), # atom, graphics
1647
+ (r'[A-Z_][A-Za-z0-9_]*', Name.Variable),
1648
+ (u'\\s+|[\u2000-\u200f\ufff0-\ufffe\uffef]', Text),
1649
+ ],
1650
+ 'nested-comment': [
1651
+ (r'\*/', Comment.Multiline, '#pop'),
1652
+ (r'/\*', Comment.Multiline, '#push'),
1653
+ (r'[^*/]+', Comment.Multiline),
1654
+ (r'[*/]', Comment.Multiline),
1655
+ ],
1656
+ }
1657
+
1658
+ def analyse_text(text):
1659
+ return ':-' in text
1660
+
1661
+
1662
+ class CythonLexer(RegexLexer):
1663
+ """
1664
+ For Pyrex and `Cython <http://cython.org>`_ source code.
1665
+
1666
+ *New in Pygments 1.1.*
1667
+ """
1668
+
1669
+ name = 'Cython'
1670
+ aliases = ['cython', 'pyx', 'pyrex']
1671
+ filenames = ['*.pyx', '*.pxd', '*.pxi']
1672
+ mimetypes = ['text/x-cython', 'application/x-cython']
1673
+
1674
+ tokens = {
1675
+ 'root': [
1676
+ (r'\n', Text),
1677
+ (r'^(\s*)("""(?:.|\n)*?""")', bygroups(Text, String.Doc)),
1678
+ (r"^(\s*)('''(?:.|\n)*?''')", bygroups(Text, String.Doc)),
1679
+ (r'[^\S\n]+', Text),
1680
+ (r'#.*$', Comment),
1681
+ (r'[]{}:(),;[]', Punctuation),
1682
+ (r'\\\n', Text),
1683
+ (r'\\', Text),
1684
+ (r'(in|is|and|or|not)\b', Operator.Word),
1685
+ (r'(<)([a-zA-Z0-9.?]+)(>)',
1686
+ bygroups(Punctuation, Keyword.Type, Punctuation)),
1687
+ (r'!=|==|<<|>>|[-~+/*%=<>&^|.?]', Operator),
1688
+ (r'(from)(\d+)(<=)(\s+)(<)(\d+)(:)',
1689
+ bygroups(Keyword, Number.Integer, Operator, Name, Operator,
1690
+ Name, Punctuation)),
1691
+ include('keywords'),
1692
+ (r'(def|property)(\s+)', bygroups(Keyword, Text), 'funcname'),
1693
+ (r'(cp?def)(\s+)', bygroups(Keyword, Text), 'cdef'),
1694
+ (r'(class|struct)(\s+)', bygroups(Keyword, Text), 'classname'),
1695
+ (r'(from)(\s+)', bygroups(Keyword, Text), 'fromimport'),
1696
+ (r'(c?import)(\s+)', bygroups(Keyword, Text), 'import'),
1697
+ include('builtins'),
1698
+ include('backtick'),
1699
+ ('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'),
1700
+ ("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'),
1701
+ ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'),
1702
+ ("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'),
1703
+ ('[uU]?"""', String, combined('stringescape', 'tdqs')),
1704
+ ("[uU]?'''", String, combined('stringescape', 'tsqs')),
1705
+ ('[uU]?"', String, combined('stringescape', 'dqs')),
1706
+ ("[uU]?'", String, combined('stringescape', 'sqs')),
1707
+ include('name'),
1708
+ include('numbers'),
1709
+ ],
1710
+ 'keywords': [
1711
+ (r'(assert|break|by|continue|ctypedef|del|elif|else|except\??|exec|'
1712
+ r'finally|for|gil|global|if|include|lambda|nogil|pass|print|raise|'
1713
+ r'return|try|while|yield|as|with)\b', Keyword),
1714
+ (r'(DEF|IF|ELIF|ELSE)\b', Comment.Preproc),
1715
+ ],
1716
+ 'builtins': [
1717
+ (r'(?<!\.)(__import__|abs|all|any|apply|basestring|bin|bool|buffer|'
1718
+ r'bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|'
1719
+ r'complex|delattr|dict|dir|divmod|enumerate|eval|execfile|exit|'
1720
+ r'file|filter|float|frozenset|getattr|globals|hasattr|hash|hex|id|'
1721
+ r'input|int|intern|isinstance|issubclass|iter|len|list|locals|'
1722
+ r'long|map|max|min|next|object|oct|open|ord|pow|property|range|'
1723
+ r'raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|'
1724
+ r'sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|'
1725
+ r'vars|xrange|zip)\b', Name.Builtin),
1726
+ (r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL'
1727
+ r')\b', Name.Builtin.Pseudo),
1728
+ (r'(?<!\.)(ArithmeticError|AssertionError|AttributeError|'
1729
+ r'BaseException|DeprecationWarning|EOFError|EnvironmentError|'
1730
+ r'Exception|FloatingPointError|FutureWarning|GeneratorExit|IOError|'
1731
+ r'ImportError|ImportWarning|IndentationError|IndexError|KeyError|'
1732
+ r'KeyboardInterrupt|LookupError|MemoryError|NameError|'
1733
+ r'NotImplemented|NotImplementedError|OSError|OverflowError|'
1734
+ r'OverflowWarning|PendingDeprecationWarning|ReferenceError|'
1735
+ r'RuntimeError|RuntimeWarning|StandardError|StopIteration|'
1736
+ r'SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|'
1737
+ r'TypeError|UnboundLocalError|UnicodeDecodeError|'
1738
+ r'UnicodeEncodeError|UnicodeError|UnicodeTranslateError|'
1739
+ r'UnicodeWarning|UserWarning|ValueError|Warning|ZeroDivisionError'
1740
+ r')\b', Name.Exception),
1741
+ ],
1742
+ 'numbers': [
1743
+ (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
1744
+ (r'0\d+', Number.Oct),
1745
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
1746
+ (r'\d+L', Number.Integer.Long),
1747
+ (r'\d+', Number.Integer)
1748
+ ],
1749
+ 'backtick': [
1750
+ ('`.*?`', String.Backtick),
1751
+ ],
1752
+ 'name': [
1753
+ (r'@[a-zA-Z0-9_]+', Name.Decorator),
1754
+ ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
1755
+ ],
1756
+ 'funcname': [
1757
+ ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
1758
+ ],
1759
+ 'cdef': [
1760
+ (r'(public|readonly|extern|api|inline)\b', Keyword.Reserved),
1761
+ (r'(struct|enum|union|class)\b', Keyword),
1762
+ (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(?=[(:#=]|$)',
1763
+ bygroups(Name.Function, Text), '#pop'),
1764
+ (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(,)',
1765
+ bygroups(Name.Function, Text, Punctuation)),
1766
+ (r'from\b', Keyword, '#pop'),
1767
+ (r'as\b', Keyword),
1768
+ (r':', Punctuation, '#pop'),
1769
+ (r'(?=["\'])', Text, '#pop'),
1770
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Keyword.Type),
1771
+ (r'.', Text),
1772
+ ],
1773
+ 'classname': [
1774
+ ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
1775
+ ],
1776
+ 'import': [
1777
+ (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)),
1778
+ (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace),
1779
+ (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)),
1780
+ (r'', Text, '#pop') # all else: go back
1781
+ ],
1782
+ 'fromimport': [
1783
+ (r'(\s+)(c?import)\b', bygroups(Text, Keyword), '#pop'),
1784
+ (r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace),
1785
+ # ``cdef foo from "header"``, or ``for foo from 0 < i < 10``
1786
+ (r'', Text, '#pop'),
1787
+ ],
1788
+ 'stringescape': [
1789
+ (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
1790
+ r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
1791
+ ],
1792
+ 'strings': [
1793
+ (r'%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
1794
+ '[hlL]?[diouxXeEfFgGcrs%]', String.Interpol),
1795
+ (r'[^\\\'"%\n]+', String),
1796
+ # quotes, percents and backslashes must be parsed one at a time
1797
+ (r'[\'"\\]', String),
1798
+ # unhandled string formatting sign
1799
+ (r'%', String)
1800
+ # newlines are an error (use "nl" state)
1801
+ ],
1802
+ 'nl': [
1803
+ (r'\n', String)
1804
+ ],
1805
+ 'dqs': [
1806
+ (r'"', String, '#pop'),
1807
+ (r'\\\\|\\"|\\\n', String.Escape), # included here again for raw strings
1808
+ include('strings')
1809
+ ],
1810
+ 'sqs': [
1811
+ (r"'", String, '#pop'),
1812
+ (r"\\\\|\\'|\\\n", String.Escape), # included here again for raw strings
1813
+ include('strings')
1814
+ ],
1815
+ 'tdqs': [
1816
+ (r'"""', String, '#pop'),
1817
+ include('strings'),
1818
+ include('nl')
1819
+ ],
1820
+ 'tsqs': [
1821
+ (r"'''", String, '#pop'),
1822
+ include('strings'),
1823
+ include('nl')
1824
+ ],
1825
+ }
1826
+
1827
+
1828
+ class ValaLexer(RegexLexer):
1829
+ """
1830
+ For Vala source code with preprocessor directives.
1831
+
1832
+ *New in Pygments 1.1.*
1833
+ """
1834
+ name = 'Vala'
1835
+ aliases = ['vala', 'vapi']
1836
+ filenames = ['*.vala', '*.vapi']
1837
+ mimetypes = ['text/x-vala']
1838
+
1839
+ tokens = {
1840
+ 'whitespace': [
1841
+ (r'^\s*#if\s+0', Comment.Preproc, 'if0'),
1842
+ (r'\n', Text),
1843
+ (r'\s+', Text),
1844
+ (r'\\\n', Text), # line continuation
1845
+ (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
1846
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
1847
+ ],
1848
+ 'statements': [
1849
+ (r'L?"', String, 'string'),
1850
+ (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
1851
+ String.Char),
1852
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
1853
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
1854
+ (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
1855
+ (r'0[0-7]+[Ll]?', Number.Oct),
1856
+ (r'\d+[Ll]?', Number.Integer),
1857
+ (r'[~!%^&*+=|?:<>/-]', Operator),
1858
+ (r'(\[)(Compact|Immutable|(?:Boolean|Simple)Type)(\])',
1859
+ bygroups(Punctuation, Name.Decorator, Punctuation)),
1860
+ # TODO: "correctly" parse complex code attributes
1861
+ (r'(\[)(CCode|(?:Integer|Floating)Type)',
1862
+ bygroups(Punctuation, Name.Decorator)),
1863
+ (r'[()\[\],.]', Punctuation),
1864
+ (r'(as|base|break|case|catch|construct|continue|default|delete|do|'
1865
+ r'else|enum|finally|for|foreach|get|if|in|is|lock|new|out|params|'
1866
+ r'return|set|sizeof|switch|this|throw|try|typeof|while|yield)\b',
1867
+ Keyword),
1868
+ (r'(abstract|const|delegate|dynamic|ensures|extern|inline|internal|'
1869
+ r'override|owned|private|protected|public|ref|requires|signal|'
1870
+ r'static|throws|unowned|var|virtual|volatile|weak|yields)\b',
1871
+ Keyword.Declaration),
1872
+ (r'(namespace|using)(\s+)', bygroups(Keyword.Namespace, Text),
1873
+ 'namespace'),
1874
+ (r'(class|errordomain|interface|struct)(\s+)',
1875
+ bygroups(Keyword.Declaration, Text), 'class'),
1876
+ (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)',
1877
+ bygroups(Operator, Name.Attribute)),
1878
+ # void is an actual keyword, others are in glib-2.0.vapi
1879
+ (r'(void|bool|char|double|float|int|int8|int16|int32|int64|long|'
1880
+ r'short|size_t|ssize_t|string|time_t|uchar|uint|uint8|uint16|'
1881
+ r'uint32|uint64|ulong|unichar|ushort)\b', Keyword.Type),
1882
+ (r'(true|false|null)\b', Name.Builtin),
1883
+ ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
1884
+ ],
1885
+ 'root': [
1886
+ include('whitespace'),
1887
+ ('', Text, 'statement'),
1888
+ ],
1889
+ 'statement' : [
1890
+ include('whitespace'),
1891
+ include('statements'),
1892
+ ('[{}]', Punctuation),
1893
+ (';', Punctuation, '#pop'),
1894
+ ],
1895
+ 'string': [
1896
+ (r'"', String, '#pop'),
1897
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
1898
+ (r'[^\\"\n]+', String), # all other characters
1899
+ (r'\\\n', String), # line continuation
1900
+ (r'\\', String), # stray backslash
1901
+ ],
1902
+ 'if0': [
1903
+ (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
1904
+ (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
1905
+ (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
1906
+ (r'.*?\n', Comment),
1907
+ ],
1908
+ 'class': [
1909
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
1910
+ ],
1911
+ 'namespace': [
1912
+ (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace, '#pop')
1913
+ ],
1914
+ }
1915
+
1916
+
1917
+ class OocLexer(RegexLexer):
1918
+ """
1919
+ For `Ooc <http://ooc-lang.org/>`_ source code
1920
+
1921
+ *New in Pygments 1.2.*
1922
+ """
1923
+ name = 'Ooc'
1924
+ aliases = ['ooc']
1925
+ filenames = ['*.ooc']
1926
+ mimetypes = ['text/x-ooc']
1927
+
1928
+ tokens = {
1929
+ 'root': [
1930
+ (r'\b(class|interface|implement|abstract|extends|from|'
1931
+ r'this|super|new|const|final|static|import|use|extern|'
1932
+ r'inline|proto|break|continue|fallthrough|operator|if|else|for|'
1933
+ r'while|do|switch|case|as|in|version|return|true|false|null)\b',
1934
+ Keyword),
1935
+ (r'include\b', Keyword, 'include'),
1936
+ (r'(cover)([ \t]+)(from)([ \t]+)([a-zA-Z0-9_]+[*@]?)',
1937
+ bygroups(Keyword, Text, Keyword, Text, Name.Class)),
1938
+ (r'(func)((?:[ \t]|\\\n)+)(~[a-z_][a-zA-Z0-9_]*)',
1939
+ bygroups(Keyword, Text, Name.Function)),
1940
+ (r'\bfunc\b', Keyword),
1941
+ # Note: %= and ^= not listed on http://ooc-lang.org/syntax
1942
+ (r'//.*', Comment),
1943
+ (r'(?s)/\*.*?\*/', Comment.Multiline),
1944
+ (r'(==?|\+=?|-[=>]?|\*=?|/=?|:=|!=?|%=?|\?|>{1,3}=?|<{1,3}=?|\.\.|'
1945
+ r'&&?|\|\|?|\^=?)', Operator),
1946
+ (r'(\.)([ \t]*)([a-z]\w*)', bygroups(Operator, Text,
1947
+ Name.Function)),
1948
+ (r'[A-Z][A-Z0-9_]+', Name.Constant),
1949
+ (r'[A-Z][a-zA-Z0-9_]*([@*]|\[[ \t]*\])?', Name.Class),
1950
+
1951
+ (r'([a-z][a-zA-Z0-9_]*(?:~[a-z][a-zA-Z0-9_]*)?)((?:[ \t]|\\\n)*)(?=\()',
1952
+ bygroups(Name.Function, Text)),
1953
+ (r'[a-z][a-zA-Z0-9_]*', Name.Variable),
1954
+
1955
+ # : introduces types
1956
+ (r'[:(){}\[\];,]', Punctuation),
1957
+
1958
+ (r'0x[0-9a-fA-F]+', Number.Hex),
1959
+ (r'0c[0-9]+', Number.Oct),
1960
+ (r'0b[01]+', Number.Binary),
1961
+ (r'[0-9_]\.[0-9_]*(?!\.)', Number.Float),
1962
+ (r'[0-9_]+', Number.Decimal),
1963
+
1964
+ (r'"(?:\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\"])*"',
1965
+ String.Double),
1966
+ (r"'(?:\\.|\\[0-9]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
1967
+ String.Char),
1968
+ (r'@', Punctuation), # pointer dereference
1969
+ (r'\.', Punctuation), # imports or chain operator
1970
+
1971
+ (r'\\[ \t\n]', Text),
1972
+ (r'[ \t]+', Text),
1973
+ ],
1974
+ 'include': [
1975
+ (r'[\w/]+', Name),
1976
+ (r',', Punctuation),
1977
+ (r'[ \t]', Text),
1978
+ (r'[;\n]', Text, '#pop'),
1979
+ ],
1980
+ }
1981
+
1982
+
1983
+ class GoLexer(RegexLexer):
1984
+ """
1985
+ For `Go <http://golang.org>`_ source.
1986
+ """
1987
+ name = 'Go'
1988
+ filenames = ['*.go']
1989
+ aliases = ['go']
1990
+ mimetypes = ['text/x-gosrc']
1991
+
1992
+ tokens = {
1993
+ 'root': [
1994
+ (r'\n', Text),
1995
+ (r'\s+', Text),
1996
+ (r'\\\n', Text), # line continuations
1997
+ (r'//(.*?)\n', Comment.Single),
1998
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
1999
+ (r'(import|package)\b', Keyword.Namespace),
2000
+ (r'(var|func|struct|map|chan|type|interface|const)\b', Keyword.Declaration),
2001
+ (r'(break|default|select|case|defer|go'
2002
+ r'|else|goto|switch|fallthrough|if|range'
2003
+ r'|continue|for|return)\b', Keyword),
2004
+ (r'(true|false|iota|nil)\b', Keyword.Constant),
2005
+ # It seems the builtin types aren't actually keywords, but
2006
+ # can be used as functions. So we need two declarations.
2007
+ (r'(uint|uint8|uint16|uint32|uint64'
2008
+ r'|int|int8|int16|int32|int64'
2009
+ r'|float|float32|float64'
2010
+ r'|complex64|complex128|byte|rune'
2011
+ r'|string|bool|error|uintptr'
2012
+ r'|print|println|panic|recover|close|complex|real|imag'
2013
+ r'|len|cap|append|copy|delete|new|make)\b(\()',
2014
+ bygroups(Name.Builtin, Punctuation)),
2015
+ (r'(uint|uint8|uint16|uint32|uint64'
2016
+ r'|int|int8|int16|int32|int64'
2017
+ r'|float|float32|float64'
2018
+ r'|complex64|complex128|byte|rune'
2019
+ r'|string|bool|error|uintptr)\b', Keyword.Type),
2020
+ # imaginary_lit
2021
+ (r'\d+i', Number),
2022
+ (r'\d+\.\d*([Ee][-+]\d+)?i', Number),
2023
+ (r'\.\d+([Ee][-+]\d+)?i', Number),
2024
+ (r'\d+[Ee][-+]\d+i', Number),
2025
+ # float_lit
2026
+ (r'\d+(\.\d+[eE][+\-]?\d+|'
2027
+ r'\.\d*|[eE][+\-]?\d+)', Number.Float),
2028
+ (r'\.\d+([eE][+\-]?\d+)?', Number.Float),
2029
+ # int_lit
2030
+ # -- octal_lit
2031
+ (r'0[0-7]+', Number.Oct),
2032
+ # -- hex_lit
2033
+ (r'0[xX][0-9a-fA-F]+', Number.Hex),
2034
+ # -- decimal_lit
2035
+ (r'(0|[1-9][0-9]*)', Number.Integer),
2036
+ # char_lit
2037
+ (r"""'(\\['"\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
2038
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|[^\\])'""",
2039
+ String.Char
2040
+ ),
2041
+ # StringLiteral
2042
+ # -- raw_string_lit
2043
+ (r'`[^`]*`', String),
2044
+ # -- interpreted_string_lit
2045
+ (r'"(\\\\|\\"|[^"])*"', String),
2046
+ # Tokens
2047
+ (r'(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\|'
2048
+ r'|<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])', Operator),
2049
+ (r'[|^<>=!()\[\]{}.,;:]', Punctuation),
2050
+ # identifier
2051
+ (r'[a-zA-Z_]\w*', Name.Other),
2052
+ ]
2053
+ }
2054
+
2055
+
2056
+ class FelixLexer(RegexLexer):
2057
+ """
2058
+ For `Felix <http://www.felix-lang.org>`_ source code.
2059
+
2060
+ *New in Pygments 1.2.*
2061
+ """
2062
+
2063
+ name = 'Felix'
2064
+ aliases = ['felix', 'flx']
2065
+ filenames = ['*.flx', '*.flxh']
2066
+ mimetypes = ['text/x-felix']
2067
+
2068
+ preproc = [
2069
+ 'elif', 'else', 'endif', 'if', 'ifdef', 'ifndef',
2070
+ ]
2071
+
2072
+ keywords = [
2073
+ '_', '_deref', 'all', 'as',
2074
+ 'assert', 'attempt', 'call', 'callback', 'case', 'caseno', 'cclass',
2075
+ 'code', 'compound', 'ctypes', 'do', 'done', 'downto', 'elif', 'else',
2076
+ 'endattempt', 'endcase', 'endif', 'endmatch', 'enum', 'except',
2077
+ 'exceptions', 'expect', 'finally', 'for', 'forall', 'forget', 'fork',
2078
+ 'functor', 'goto', 'ident', 'if', 'incomplete', 'inherit', 'instance',
2079
+ 'interface', 'jump', 'lambda', 'loop', 'match', 'module', 'namespace',
2080
+ 'new', 'noexpand', 'nonterm', 'obj', 'of', 'open', 'parse', 'raise',
2081
+ 'regexp', 'reglex', 'regmatch', 'rename', 'return', 'the', 'then',
2082
+ 'to', 'type', 'typecase', 'typedef', 'typematch', 'typeof', 'upto',
2083
+ 'when', 'whilst', 'with', 'yield',
2084
+ ]
2085
+
2086
+ keyword_directives = [
2087
+ '_gc_pointer', '_gc_type', 'body', 'comment', 'const', 'export',
2088
+ 'header', 'inline', 'lval', 'macro', 'noinline', 'noreturn',
2089
+ 'package', 'private', 'pod', 'property', 'public', 'publish',
2090
+ 'requires', 'todo', 'virtual', 'use',
2091
+ ]
2092
+
2093
+ keyword_declarations = [
2094
+ 'def', 'let', 'ref', 'val', 'var',
2095
+ ]
2096
+
2097
+ keyword_types = [
2098
+ 'unit', 'void', 'any', 'bool',
2099
+ 'byte', 'offset',
2100
+ 'address', 'caddress', 'cvaddress', 'vaddress',
2101
+ 'tiny', 'short', 'int', 'long', 'vlong',
2102
+ 'utiny', 'ushort', 'vshort', 'uint', 'ulong', 'uvlong',
2103
+ 'int8', 'int16', 'int32', 'int64',
2104
+ 'uint8', 'uint16', 'uint32', 'uint64',
2105
+ 'float', 'double', 'ldouble',
2106
+ 'complex', 'dcomplex', 'lcomplex',
2107
+ 'imaginary', 'dimaginary', 'limaginary',
2108
+ 'char', 'wchar', 'uchar',
2109
+ 'charp', 'charcp', 'ucharp', 'ucharcp',
2110
+ 'string', 'wstring', 'ustring',
2111
+ 'cont',
2112
+ 'array', 'varray', 'list',
2113
+ 'lvalue', 'opt', 'slice',
2114
+ ]
2115
+
2116
+ keyword_constants = [
2117
+ 'false', 'true',
2118
+ ]
2119
+
2120
+ operator_words = [
2121
+ 'and', 'not', 'in', 'is', 'isin', 'or', 'xor',
2122
+ ]
2123
+
2124
+ name_builtins = [
2125
+ '_svc', 'while',
2126
+ ]
2127
+
2128
+ name_pseudo = [
2129
+ 'root', 'self', 'this',
2130
+ ]
2131
+
2132
+ decimal_suffixes = '([tTsSiIlLvV]|ll|LL|([iIuU])(8|16|32|64))?'
2133
+
2134
+ tokens = {
2135
+ 'root': [
2136
+ include('whitespace'),
2137
+
2138
+ # Keywords
2139
+ (r'(axiom|ctor|fun|gen|proc|reduce|union)\b', Keyword,
2140
+ 'funcname'),
2141
+ (r'(class|cclass|cstruct|obj|struct)\b', Keyword, 'classname'),
2142
+ (r'(instance|module|typeclass)\b', Keyword, 'modulename'),
2143
+
2144
+ (r'(%s)\b' % '|'.join(keywords), Keyword),
2145
+ (r'(%s)\b' % '|'.join(keyword_directives), Name.Decorator),
2146
+ (r'(%s)\b' % '|'.join(keyword_declarations), Keyword.Declaration),
2147
+ (r'(%s)\b' % '|'.join(keyword_types), Keyword.Type),
2148
+ (r'(%s)\b' % '|'.join(keyword_constants), Keyword.Constant),
2149
+
2150
+ # Operators
2151
+ include('operators'),
2152
+
2153
+ # Float Literal
2154
+ # -- Hex Float
2155
+ (r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)'
2156
+ r'[pP][+\-]?[0-9_]+[lLfFdD]?', Number.Float),
2157
+ # -- DecimalFloat
2158
+ (r'[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|'
2159
+ r'\.[0-9_]*|[eE][+\-]?[0-9_]+)[lLfFdD]?', Number.Float),
2160
+ (r'\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[lLfFdD]?',
2161
+ Number.Float),
2162
+
2163
+ # IntegerLiteral
2164
+ # -- Binary
2165
+ (r'0[Bb][01_]+%s' % decimal_suffixes, Number),
2166
+ # -- Octal
2167
+ (r'0[0-7_]+%s' % decimal_suffixes, Number.Oct),
2168
+ # -- Hexadecimal
2169
+ (r'0[xX][0-9a-fA-F_]+%s' % decimal_suffixes, Number.Hex),
2170
+ # -- Decimal
2171
+ (r'(0|[1-9][0-9_]*)%s' % decimal_suffixes, Number.Integer),
2172
+
2173
+ # Strings
2174
+ ('([rR][cC]?|[cC][rR])"""', String, 'tdqs'),
2175
+ ("([rR][cC]?|[cC][rR])'''", String, 'tsqs'),
2176
+ ('([rR][cC]?|[cC][rR])"', String, 'dqs'),
2177
+ ("([rR][cC]?|[cC][rR])'", String, 'sqs'),
2178
+ ('[cCfFqQwWuU]?"""', String, combined('stringescape', 'tdqs')),
2179
+ ("[cCfFqQwWuU]?'''", String, combined('stringescape', 'tsqs')),
2180
+ ('[cCfFqQwWuU]?"', String, combined('stringescape', 'dqs')),
2181
+ ("[cCfFqQwWuU]?'", String, combined('stringescape', 'sqs')),
2182
+
2183
+ # Punctuation
2184
+ (r'[\[\]{}:(),;?]', Punctuation),
2185
+
2186
+ # Labels
2187
+ (r'[a-zA-Z_]\w*:>', Name.Label),
2188
+
2189
+ # Identifiers
2190
+ (r'(%s)\b' % '|'.join(name_builtins), Name.Builtin),
2191
+ (r'(%s)\b' % '|'.join(name_pseudo), Name.Builtin.Pseudo),
2192
+ (r'[a-zA-Z_]\w*', Name),
2193
+ ],
2194
+ 'whitespace': [
2195
+ (r'\n', Text),
2196
+ (r'\s+', Text),
2197
+
2198
+ include('comment'),
2199
+
2200
+ # Preprocessor
2201
+ (r'#\s*if\s+0', Comment.Preproc, 'if0'),
2202
+ (r'#', Comment.Preproc, 'macro'),
2203
+ ],
2204
+ 'operators': [
2205
+ (r'(%s)\b' % '|'.join(operator_words), Operator.Word),
2206
+ (r'!=|==|<<|>>|\|\||&&|[-~+/*%=<>&^|.$]', Operator),
2207
+ ],
2208
+ 'comment': [
2209
+ (r'//(.*?)\n', Comment.Single),
2210
+ (r'/[*]', Comment.Multiline, 'comment2'),
2211
+ ],
2212
+ 'comment2': [
2213
+ (r'[^\/*]', Comment.Multiline),
2214
+ (r'/[*]', Comment.Multiline, '#push'),
2215
+ (r'[*]/', Comment.Multiline, '#pop'),
2216
+ (r'[\/*]', Comment.Multiline),
2217
+ ],
2218
+ 'if0': [
2219
+ (r'^\s*#if.*?(?<!\\)\n', Comment, '#push'),
2220
+ (r'^\s*#endif.*?(?<!\\)\n', Comment, '#pop'),
2221
+ (r'.*?\n', Comment),
2222
+ ],
2223
+ 'macro': [
2224
+ include('comment'),
2225
+ (r'(import|include)(\s+)(<[^>]*?>)',
2226
+ bygroups(Comment.Preproc, Text, String), '#pop'),
2227
+ (r'(import|include)(\s+)("[^"]*?")',
2228
+ bygroups(Comment.Preproc, Text, String), '#pop'),
2229
+ (r"(import|include)(\s+)('[^']*?')",
2230
+ bygroups(Comment.Preproc, Text, String), '#pop'),
2231
+ (r'[^/\n]+', Comment.Preproc),
2232
+ ##(r'/[*](.|\n)*?[*]/', Comment),
2233
+ ##(r'//.*?\n', Comment, '#pop'),
2234
+ (r'/', Comment.Preproc),
2235
+ (r'(?<=\\)\n', Comment.Preproc),
2236
+ (r'\n', Comment.Preproc, '#pop'),
2237
+ ],
2238
+ 'funcname': [
2239
+ include('whitespace'),
2240
+ (r'[a-zA-Z_]\w*', Name.Function, '#pop'),
2241
+ # anonymous functions
2242
+ (r'(?=\()', Text, '#pop'),
2243
+ ],
2244
+ 'classname': [
2245
+ include('whitespace'),
2246
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
2247
+ # anonymous classes
2248
+ (r'(?=\{)', Text, '#pop'),
2249
+ ],
2250
+ 'modulename': [
2251
+ include('whitespace'),
2252
+ (r'\[', Punctuation, ('modulename2', 'tvarlist')),
2253
+ (r'', Error, 'modulename2'),
2254
+ ],
2255
+ 'modulename2': [
2256
+ include('whitespace'),
2257
+ (r'([a-zA-Z_]\w*)', Name.Namespace, '#pop:2'),
2258
+ ],
2259
+ 'tvarlist': [
2260
+ include('whitespace'),
2261
+ include('operators'),
2262
+ (r'\[', Punctuation, '#push'),
2263
+ (r'\]', Punctuation, '#pop'),
2264
+ (r',', Punctuation),
2265
+ (r'(with|where)\b', Keyword),
2266
+ (r'[a-zA-Z_]\w*', Name),
2267
+ ],
2268
+ 'stringescape': [
2269
+ (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
2270
+ r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
2271
+ ],
2272
+ 'strings': [
2273
+ (r'%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
2274
+ '[hlL]?[diouxXeEfFgGcrs%]', String.Interpol),
2275
+ (r'[^\\\'"%\n]+', String),
2276
+ # quotes, percents and backslashes must be parsed one at a time
2277
+ (r'[\'"\\]', String),
2278
+ # unhandled string formatting sign
2279
+ (r'%', String)
2280
+ # newlines are an error (use "nl" state)
2281
+ ],
2282
+ 'nl': [
2283
+ (r'\n', String)
2284
+ ],
2285
+ 'dqs': [
2286
+ (r'"', String, '#pop'),
2287
+ # included here again for raw strings
2288
+ (r'\\\\|\\"|\\\n', String.Escape),
2289
+ include('strings')
2290
+ ],
2291
+ 'sqs': [
2292
+ (r"'", String, '#pop'),
2293
+ # included here again for raw strings
2294
+ (r"\\\\|\\'|\\\n", String.Escape),
2295
+ include('strings')
2296
+ ],
2297
+ 'tdqs': [
2298
+ (r'"""', String, '#pop'),
2299
+ include('strings'),
2300
+ include('nl')
2301
+ ],
2302
+ 'tsqs': [
2303
+ (r"'''", String, '#pop'),
2304
+ include('strings'),
2305
+ include('nl')
2306
+ ],
2307
+ }
2308
+
2309
+
2310
+ class AdaLexer(RegexLexer):
2311
+ """
2312
+ For Ada source code.
2313
+
2314
+ *New in Pygments 1.3.*
2315
+ """
2316
+
2317
+ name = 'Ada'
2318
+ aliases = ['ada', 'ada95' 'ada2005']
2319
+ filenames = ['*.adb', '*.ads', '*.ada']
2320
+ mimetypes = ['text/x-ada']
2321
+
2322
+ flags = re.MULTILINE | re.I # Ignore case
2323
+
2324
+ tokens = {
2325
+ 'root': [
2326
+ (r'[^\S\n]+', Text),
2327
+ (r'--.*?\n', Comment.Single),
2328
+ (r'[^\S\n]+', Text),
2329
+ (r'function|procedure|entry', Keyword.Declaration, 'subprogram'),
2330
+ (r'(subtype|type)(\s+)([a-z0-9_]+)',
2331
+ bygroups(Keyword.Declaration, Text, Keyword.Type), 'type_def'),
2332
+ (r'task|protected', Keyword.Declaration),
2333
+ (r'(subtype)(\s+)', bygroups(Keyword.Declaration, Text)),
2334
+ (r'(end)(\s+)', bygroups(Keyword.Reserved, Text), 'end'),
2335
+ (r'(pragma)(\s+)([a-zA-Z0-9_]+)', bygroups(Keyword.Reserved, Text,
2336
+ Comment.Preproc)),
2337
+ (r'(true|false|null)\b', Keyword.Constant),
2338
+ (r'(Address|Byte|Boolean|Character|Controlled|Count|Cursor|'
2339
+ r'Duration|File_Mode|File_Type|Float|Generator|Integer|Long_Float|'
2340
+ r'Long_Integer|Long_Long_Float|Long_Long_Integer|Natural|Positive|'
2341
+ r'Reference_Type|Short_Float|Short_Integer|Short_Short_Float|'
2342
+ r'Short_Short_Integer|String|Wide_Character|Wide_String)\b',
2343
+ Keyword.Type),
2344
+ (r'(and(\s+then)?|in|mod|not|or(\s+else)|rem)\b', Operator.Word),
2345
+ (r'generic|private', Keyword.Declaration),
2346
+ (r'package', Keyword.Declaration, 'package'),
2347
+ (r'array\b', Keyword.Reserved, 'array_def'),
2348
+ (r'(with|use)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
2349
+ (r'([a-z0-9_]+)(\s*)(:)(\s*)(constant)',
2350
+ bygroups(Name.Constant, Text, Punctuation, Text,
2351
+ Keyword.Reserved)),
2352
+ (r'<<[a-z0-9_]+>>', Name.Label),
2353
+ (r'([a-z0-9_]+)(\s*)(:)(\s*)(declare|begin|loop|for|while)',
2354
+ bygroups(Name.Label, Text, Punctuation, Text, Keyword.Reserved)),
2355
+ (r'\b(abort|abs|abstract|accept|access|aliased|all|array|at|begin|'
2356
+ r'body|case|constant|declare|delay|delta|digits|do|else|elsif|end|'
2357
+ r'entry|exception|exit|interface|for|goto|if|is|limited|loop|new|'
2358
+ r'null|of|or|others|out|overriding|pragma|protected|raise|range|'
2359
+ r'record|renames|requeue|return|reverse|select|separate|subtype|'
2360
+ r'synchronized|task|tagged|terminate|then|type|until|when|while|'
2361
+ r'xor)\b',
2362
+ Keyword.Reserved),
2363
+ (r'"[^"]*"', String),
2364
+ include('attribute'),
2365
+ include('numbers'),
2366
+ (r"'[^']'", String.Character),
2367
+ (r'([a-z0-9_]+)(\s*|[(,])', bygroups(Name, using(this))),
2368
+ (r"(<>|=>|:=|[()|:;,.'])", Punctuation),
2369
+ (r'[*<>+=/&-]', Operator),
2370
+ (r'\n+', Text),
2371
+ ],
2372
+ 'numbers' : [
2373
+ (r'[0-9_]+#[0-9a-f]+#', Number.Hex),
2374
+ (r'[0-9_]+\.[0-9_]*', Number.Float),
2375
+ (r'[0-9_]+', Number.Integer),
2376
+ ],
2377
+ 'attribute' : [
2378
+ (r"(')([a-zA-Z0-9_]+)", bygroups(Punctuation, Name.Attribute)),
2379
+ ],
2380
+ 'subprogram' : [
2381
+ (r'\(', Punctuation, ('#pop', 'formal_part')),
2382
+ (r';', Punctuation, '#pop'),
2383
+ (r'is\b', Keyword.Reserved, '#pop'),
2384
+ (r'"[^"]+"|[a-z0-9_]+', Name.Function),
2385
+ include('root'),
2386
+ ],
2387
+ 'end' : [
2388
+ ('(if|case|record|loop|select)', Keyword.Reserved),
2389
+ ('"[^"]+"|[a-zA-Z0-9_.]+', Name.Function),
2390
+ ('\s+', Text),
2391
+ (';', Punctuation, '#pop'),
2392
+ ],
2393
+ 'type_def': [
2394
+ (r';', Punctuation, '#pop'),
2395
+ (r'\(', Punctuation, 'formal_part'),
2396
+ (r'with|and|use', Keyword.Reserved),
2397
+ (r'array\b', Keyword.Reserved, ('#pop', 'array_def')),
2398
+ (r'record\b', Keyword.Reserved, ('record_def')),
2399
+ (r'(null record)(;)', bygroups(Keyword.Reserved, Punctuation), '#pop'),
2400
+ include('root'),
2401
+ ],
2402
+ 'array_def' : [
2403
+ (r';', Punctuation, '#pop'),
2404
+ (r'([a-z0-9_]+)(\s+)(range)', bygroups(Keyword.Type, Text,
2405
+ Keyword.Reserved)),
2406
+ include('root'),
2407
+ ],
2408
+ 'record_def' : [
2409
+ (r'end record', Keyword.Reserved, '#pop'),
2410
+ include('root'),
2411
+ ],
2412
+ 'import': [
2413
+ (r'[a-z0-9_.]+', Name.Namespace, '#pop'),
2414
+ (r'', Text, '#pop'),
2415
+ ],
2416
+ 'formal_part' : [
2417
+ (r'\)', Punctuation, '#pop'),
2418
+ (r'[a-z0-9_]+', Name.Variable),
2419
+ (r',|:[^=]', Punctuation),
2420
+ (r'(in|not|null|out|access)\b', Keyword.Reserved),
2421
+ include('root'),
2422
+ ],
2423
+ 'package': [
2424
+ ('body', Keyword.Declaration),
2425
+ ('is\s+new|renames', Keyword.Reserved),
2426
+ ('is', Keyword.Reserved, '#pop'),
2427
+ (';', Punctuation, '#pop'),
2428
+ ('\(', Punctuation, 'package_instantiation'),
2429
+ ('([a-zA-Z0-9_.]+)', Name.Class),
2430
+ include('root'),
2431
+ ],
2432
+ 'package_instantiation': [
2433
+ (r'("[^"]+"|[a-z0-9_]+)(\s+)(=>)', bygroups(Name.Variable,
2434
+ Text, Punctuation)),
2435
+ (r'[a-z0-9._\'"]', Text),
2436
+ (r'\)', Punctuation, '#pop'),
2437
+ include('root'),
2438
+ ],
2439
+ }
2440
+
2441
+
2442
+ class Modula2Lexer(RegexLexer):
2443
+ """
2444
+ For `Modula-2 <http://www.modula2.org/>`_ source code.
2445
+
2446
+ Additional options that determine which keywords are highlighted:
2447
+
2448
+ `pim`
2449
+ Select PIM Modula-2 dialect (default: True).
2450
+ `iso`
2451
+ Select ISO Modula-2 dialect (default: False).
2452
+ `objm2`
2453
+ Select Objective Modula-2 dialect (default: False).
2454
+ `gm2ext`
2455
+ Also highlight GNU extensions (default: False).
2456
+
2457
+ *New in Pygments 1.3.*
2458
+ """
2459
+ name = 'Modula-2'
2460
+ aliases = ['modula2', 'm2']
2461
+ filenames = ['*.def', '*.mod']
2462
+ mimetypes = ['text/x-modula2']
2463
+
2464
+ flags = re.MULTILINE | re.DOTALL
2465
+
2466
+ tokens = {
2467
+ 'whitespace': [
2468
+ (r'\n+', Text), # blank lines
2469
+ (r'\s+', Text), # whitespace
2470
+ ],
2471
+ 'identifiers': [
2472
+ (r'([a-zA-Z_\$][a-zA-Z0-9_\$]*)', Name),
2473
+ ],
2474
+ 'numliterals': [
2475
+ (r'[01]+B', Number.Binary), # binary number (ObjM2)
2476
+ (r'[0-7]+B', Number.Oct), # octal number (PIM + ISO)
2477
+ (r'[0-7]+C', Number.Oct), # char code (PIM + ISO)
2478
+ (r'[0-9A-F]+C', Number.Hex), # char code (ObjM2)
2479
+ (r'[0-9A-F]+H', Number.Hex), # hexadecimal number
2480
+ (r'[0-9]+\.[0-9]+E[+-][0-9]+', Number.Float), # real number
2481
+ (r'[0-9]+\.[0-9]+', Number.Float), # real number
2482
+ (r'[0-9]+', Number.Integer), # decimal whole number
2483
+ ],
2484
+ 'strings': [
2485
+ (r"'(\\\\|\\'|[^'])*'", String), # single quoted string
2486
+ (r'"(\\\\|\\"|[^"])*"', String), # double quoted string
2487
+ ],
2488
+ 'operators': [
2489
+ (r'[*/+=#~&<>\^-]', Operator),
2490
+ (r':=', Operator), # assignment
2491
+ (r'@', Operator), # pointer deref (ISO)
2492
+ (r'\.\.', Operator), # ellipsis or range
2493
+ (r'`', Operator), # Smalltalk message (ObjM2)
2494
+ (r'::', Operator), # type conversion (ObjM2)
2495
+ ],
2496
+ 'punctuation': [
2497
+ (r'[\(\)\[\]{},.:;|]', Punctuation),
2498
+ ],
2499
+ 'comments': [
2500
+ (r'//.*?\n', Comment.Single), # ObjM2
2501
+ (r'/\*(.*?)\*/', Comment.Multiline), # ObjM2
2502
+ (r'\(\*([^\$].*?)\*\)', Comment.Multiline),
2503
+ # TO DO: nesting of (* ... *) comments
2504
+ ],
2505
+ 'pragmas': [
2506
+ (r'\(\*\$(.*?)\*\)', Comment.Preproc), # PIM
2507
+ (r'<\*(.*?)\*>', Comment.Preproc), # ISO + ObjM2
2508
+ ],
2509
+ 'root': [
2510
+ include('whitespace'),
2511
+ include('comments'),
2512
+ include('pragmas'),
2513
+ include('identifiers'),
2514
+ include('numliterals'),
2515
+ include('strings'),
2516
+ include('operators'),
2517
+ include('punctuation'),
2518
+ ]
2519
+ }
2520
+
2521
+ pim_reserved_words = [
2522
+ # 40 reserved words
2523
+ 'AND', 'ARRAY', 'BEGIN', 'BY', 'CASE', 'CONST', 'DEFINITION',
2524
+ 'DIV', 'DO', 'ELSE', 'ELSIF', 'END', 'EXIT', 'EXPORT', 'FOR',
2525
+ 'FROM', 'IF', 'IMPLEMENTATION', 'IMPORT', 'IN', 'LOOP', 'MOD',
2526
+ 'MODULE', 'NOT', 'OF', 'OR', 'POINTER', 'PROCEDURE', 'QUALIFIED',
2527
+ 'RECORD', 'REPEAT', 'RETURN', 'SET', 'THEN', 'TO', 'TYPE',
2528
+ 'UNTIL', 'VAR', 'WHILE', 'WITH',
2529
+ ]
2530
+
2531
+ pim_pervasives = [
2532
+ # 31 pervasives
2533
+ 'ABS', 'BITSET', 'BOOLEAN', 'CAP', 'CARDINAL', 'CHAR', 'CHR', 'DEC',
2534
+ 'DISPOSE', 'EXCL', 'FALSE', 'FLOAT', 'HALT', 'HIGH', 'INC', 'INCL',
2535
+ 'INTEGER', 'LONGINT', 'LONGREAL', 'MAX', 'MIN', 'NEW', 'NIL', 'ODD',
2536
+ 'ORD', 'PROC', 'REAL', 'SIZE', 'TRUE', 'TRUNC', 'VAL',
2537
+ ]
2538
+
2539
+ iso_reserved_words = [
2540
+ # 46 reserved words
2541
+ 'AND', 'ARRAY', 'BEGIN', 'BY', 'CASE', 'CONST', 'DEFINITION', 'DIV',
2542
+ 'DO', 'ELSE', 'ELSIF', 'END', 'EXCEPT', 'EXIT', 'EXPORT', 'FINALLY',
2543
+ 'FOR', 'FORWARD', 'FROM', 'IF', 'IMPLEMENTATION', 'IMPORT', 'IN',
2544
+ 'LOOP', 'MOD', 'MODULE', 'NOT', 'OF', 'OR', 'PACKEDSET', 'POINTER',
2545
+ 'PROCEDURE', 'QUALIFIED', 'RECORD', 'REPEAT', 'REM', 'RETRY',
2546
+ 'RETURN', 'SET', 'THEN', 'TO', 'TYPE', 'UNTIL', 'VAR', 'WHILE',
2547
+ 'WITH',
2548
+ ]
2549
+
2550
+ iso_pervasives = [
2551
+ # 42 pervasives
2552
+ 'ABS', 'BITSET', 'BOOLEAN', 'CAP', 'CARDINAL', 'CHAR', 'CHR', 'CMPLX',
2553
+ 'COMPLEX', 'DEC', 'DISPOSE', 'EXCL', 'FALSE', 'FLOAT', 'HALT', 'HIGH',
2554
+ 'IM', 'INC', 'INCL', 'INT', 'INTEGER', 'INTERRUPTIBLE', 'LENGTH',
2555
+ 'LFLOAT', 'LONGCOMPLEX', 'LONGINT', 'LONGREAL', 'MAX', 'MIN', 'NEW',
2556
+ 'NIL', 'ODD', 'ORD', 'PROC', 'PROTECTION', 'RE', 'REAL', 'SIZE',
2557
+ 'TRUE', 'TRUNC', 'UNINTERRUBTIBLE', 'VAL',
2558
+ ]
2559
+
2560
+ objm2_reserved_words = [
2561
+ # base language, 42 reserved words
2562
+ 'AND', 'ARRAY', 'BEGIN', 'BY', 'CASE', 'CONST', 'DEFINITION', 'DIV',
2563
+ 'DO', 'ELSE', 'ELSIF', 'END', 'ENUM', 'EXIT', 'FOR', 'FROM', 'IF',
2564
+ 'IMMUTABLE', 'IMPLEMENTATION', 'IMPORT', 'IN', 'IS', 'LOOP', 'MOD',
2565
+ 'MODULE', 'NOT', 'OF', 'OPAQUE', 'OR', 'POINTER', 'PROCEDURE',
2566
+ 'RECORD', 'REPEAT', 'RETURN', 'SET', 'THEN', 'TO', 'TYPE',
2567
+ 'UNTIL', 'VAR', 'VARIADIC', 'WHILE',
2568
+ # OO extensions, 16 reserved words
2569
+ 'BYCOPY', 'BYREF', 'CLASS', 'CONTINUE', 'CRITICAL', 'INOUT', 'METHOD',
2570
+ 'ON', 'OPTIONAL', 'OUT', 'PRIVATE', 'PROTECTED', 'PROTOCOL', 'PUBLIC',
2571
+ 'SUPER', 'TRY',
2572
+ ]
2573
+
2574
+ objm2_pervasives = [
2575
+ # base language, 38 pervasives
2576
+ 'ABS', 'BITSET', 'BOOLEAN', 'CARDINAL', 'CHAR', 'CHR', 'DISPOSE',
2577
+ 'FALSE', 'HALT', 'HIGH', 'INTEGER', 'INRANGE', 'LENGTH', 'LONGCARD',
2578
+ 'LONGINT', 'LONGREAL', 'MAX', 'MIN', 'NEG', 'NEW', 'NEXTV', 'NIL',
2579
+ 'OCTET', 'ODD', 'ORD', 'PRED', 'PROC', 'READ', 'REAL', 'SUCC', 'TMAX',
2580
+ 'TMIN', 'TRUE', 'TSIZE', 'UNICHAR', 'VAL', 'WRITE', 'WRITEF',
2581
+ # OO extensions, 3 pervasives
2582
+ 'OBJECT', 'NO', 'YES',
2583
+ ]
2584
+
2585
+ gnu_reserved_words = [
2586
+ # 10 additional reserved words
2587
+ 'ASM', '__ATTRIBUTE__', '__BUILTIN__', '__COLUMN__', '__DATE__',
2588
+ '__FILE__', '__FUNCTION__', '__LINE__', '__MODULE__', 'VOLATILE',
2589
+ ]
2590
+
2591
+ gnu_pervasives = [
2592
+ # 21 identifiers, actually from pseudo-module SYSTEM
2593
+ # but we will highlight them as if they were pervasives
2594
+ 'BITSET8', 'BITSET16', 'BITSET32', 'CARDINAL8', 'CARDINAL16',
2595
+ 'CARDINAL32', 'CARDINAL64', 'COMPLEX32', 'COMPLEX64', 'COMPLEX96',
2596
+ 'COMPLEX128', 'INTEGER8', 'INTEGER16', 'INTEGER32', 'INTEGER64',
2597
+ 'REAL8', 'REAL16', 'REAL32', 'REAL96', 'REAL128', 'THROW',
2598
+ ]
2599
+
2600
+ def __init__(self, **options):
2601
+ self.reserved_words = set()
2602
+ self.pervasives = set()
2603
+ # ISO Modula-2
2604
+ if get_bool_opt(options, 'iso', False):
2605
+ self.reserved_words.update(self.iso_reserved_words)
2606
+ self.pervasives.update(self.iso_pervasives)
2607
+ # Objective Modula-2
2608
+ elif get_bool_opt(options, 'objm2', False):
2609
+ self.reserved_words.update(self.objm2_reserved_words)
2610
+ self.pervasives.update(self.objm2_pervasives)
2611
+ # PIM Modula-2 (DEFAULT)
2612
+ else:
2613
+ self.reserved_words.update(self.pim_reserved_words)
2614
+ self.pervasives.update(self.pim_pervasives)
2615
+ # GNU extensions
2616
+ if get_bool_opt(options, 'gm2ext', False):
2617
+ self.reserved_words.update(self.gnu_reserved_words)
2618
+ self.pervasives.update(self.gnu_pervasives)
2619
+ # initialise
2620
+ RegexLexer.__init__(self, **options)
2621
+
2622
+ def get_tokens_unprocessed(self, text):
2623
+ for index, token, value in \
2624
+ RegexLexer.get_tokens_unprocessed(self, text):
2625
+ # check for reserved words and pervasives
2626
+ if token is Name:
2627
+ if value in self.reserved_words:
2628
+ token = Keyword.Reserved
2629
+ elif value in self.pervasives:
2630
+ token = Keyword.Pervasive
2631
+ # return result
2632
+ yield index, token, value
2633
+
2634
+
2635
+ class BlitzMaxLexer(RegexLexer):
2636
+ """
2637
+ For `BlitzMax <http://blitzbasic.com>`_ source code.
2638
+
2639
+ *New in Pygments 1.4.*
2640
+ """
2641
+
2642
+ name = 'BlitzMax'
2643
+ aliases = ['blitzmax', 'bmax']
2644
+ filenames = ['*.bmx']
2645
+ mimetypes = ['text/x-bmx']
2646
+
2647
+ bmax_vopwords = r'\b(Shl|Shr|Sar|Mod)\b'
2648
+ bmax_sktypes = r'@{1,2}|[!#$%]'
2649
+ bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b'
2650
+ bmax_name = r'[a-z_][a-z0-9_]*'
2651
+ bmax_var = (r'(%s)(?:(?:([ \t]*)(%s)|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)'
2652
+ r'|([ \t]*)([:])([ \t]*)(?:%s|(%s)))(?:([ \t]*)(Ptr))?)') % \
2653
+ (bmax_name, bmax_sktypes, bmax_lktypes, bmax_name)
2654
+ bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])'
2655
+
2656
+ flags = re.MULTILINE | re.IGNORECASE
2657
+ tokens = {
2658
+ 'root': [
2659
+ # Text
2660
+ (r'[ \t]+', Text),
2661
+ (r'\.\.\n', Text), # Line continuation
2662
+ # Comments
2663
+ (r"'.*?\n", Comment.Single),
2664
+ (r'([ \t]*)\bRem\n(\n|.)*?\s*\bEnd([ \t]*)Rem', Comment.Multiline),
2665
+ # Data types
2666
+ ('"', String.Double, 'string'),
2667
+ # Numbers
2668
+ (r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
2669
+ (r'\.[0-9]*(?!\.)', Number.Float),
2670
+ (r'[0-9]+', Number.Integer),
2671
+ (r'\$[0-9a-f]+', Number.Hex),
2672
+ (r'\%[10]+', Number), # Binary
2673
+ # Other
2674
+ (r'(?:(?:(:)?([ \t]*)(:?%s|([+\-*/&|~]))|Or|And|Not|[=<>^]))' %
2675
+ (bmax_vopwords), Operator),
2676
+ (r'[(),.:\[\]]', Punctuation),
2677
+ (r'(?:#[\w \t]*)', Name.Label),
2678
+ (r'(?:\?[\w \t]*)', Comment.Preproc),
2679
+ # Identifiers
2680
+ (r'\b(New)\b([ \t]?)([(]?)(%s)' % (bmax_name),
2681
+ bygroups(Keyword.Reserved, Text, Punctuation, Name.Class)),
2682
+ (r'\b(Import|Framework|Module)([ \t]+)(%s\.%s)' %
2683
+ (bmax_name, bmax_name),
2684
+ bygroups(Keyword.Reserved, Text, Keyword.Namespace)),
2685
+ (bmax_func, bygroups(Name.Function, Text, Keyword.Type,
2686
+ Operator, Text, Punctuation, Text,
2687
+ Keyword.Type, Name.Class, Text,
2688
+ Keyword.Type, Text, Punctuation)),
2689
+ (bmax_var, bygroups(Name.Variable, Text, Keyword.Type, Operator,
2690
+ Text, Punctuation, Text, Keyword.Type,
2691
+ Name.Class, Text, Keyword.Type)),
2692
+ (r'\b(Type|Extends)([ \t]+)(%s)' % (bmax_name),
2693
+ bygroups(Keyword.Reserved, Text, Name.Class)),
2694
+ # Keywords
2695
+ (r'\b(Ptr)\b', Keyword.Type),
2696
+ (r'\b(Pi|True|False|Null|Self|Super)\b', Keyword.Constant),
2697
+ (r'\b(Local|Global|Const|Field)\b', Keyword.Declaration),
2698
+ (r'\b(TNullMethodException|TNullFunctionException|'
2699
+ r'TNullObjectException|TArrayBoundsException|'
2700
+ r'TRuntimeException)\b', Name.Exception),
2701
+ (r'\b(Strict|SuperStrict|Module|ModuleInfo|'
2702
+ r'End|Return|Continue|Exit|Public|Private|'
2703
+ r'Var|VarPtr|Chr|Len|Asc|SizeOf|Sgn|Abs|Min|Max|'
2704
+ r'New|Release|Delete|'
2705
+ r'Incbin|IncbinPtr|IncbinLen|'
2706
+ r'Framework|Include|Import|Extern|EndExtern|'
2707
+ r'Function|EndFunction|'
2708
+ r'Type|EndType|Extends|'
2709
+ r'Method|EndMethod|'
2710
+ r'Abstract|Final|'
2711
+ r'If|Then|Else|ElseIf|EndIf|'
2712
+ r'For|To|Next|Step|EachIn|'
2713
+ r'While|Wend|EndWhile|'
2714
+ r'Repeat|Until|Forever|'
2715
+ r'Select|Case|Default|EndSelect|'
2716
+ r'Try|Catch|EndTry|Throw|Assert|'
2717
+ r'Goto|DefData|ReadData|RestoreData)\b', Keyword.Reserved),
2718
+ # Final resolve (for variable names and such)
2719
+ (r'(%s)' % (bmax_name), Name.Variable),
2720
+ ],
2721
+ 'string': [
2722
+ (r'""', String.Double),
2723
+ (r'"C?', String.Double, '#pop'),
2724
+ (r'[^"]+', String.Double),
2725
+ ],
2726
+ }
2727
+
2728
+
2729
+ class BlitzBasicLexer(RegexLexer):
2730
+ """
2731
+ For `BlitzBasic <http://blitzbasic.com>`_ source code.
2732
+
2733
+ *New in Pygments 1.7.*
2734
+ """
2735
+
2736
+ name = 'BlitzBasic'
2737
+ aliases = ['blitzbasic', 'b3d', 'bplus']
2738
+ filenames = ['*.bb', '*.decls']
2739
+ mimetypes = ['text/x-bb']
2740
+
2741
+ bb_vopwords = (r'\b(Shl|Shr|Sar|Mod|Or|And|Not|'
2742
+ r'Abs|Sgn|Handle|Int|Float|Str|'
2743
+ r'First|Last|Before|After)\b')
2744
+ bb_sktypes = r'@{1,2}|[#$%]'
2745
+ bb_name = r'[a-z][a-z0-9_]*'
2746
+ bb_var = (r'(%s)(?:([ \t]*)(%s)|([ \t]*)([.])([ \t]*)(?:(%s)))?') % \
2747
+ (bb_name, bb_sktypes, bb_name)
2748
+
2749
+ flags = re.MULTILINE | re.IGNORECASE
2750
+ tokens = {
2751
+ 'root': [
2752
+ # Text
2753
+ (r'[ \t]+', Text),
2754
+ # Comments
2755
+ (r";.*?\n", Comment.Single),
2756
+ # Data types
2757
+ ('"', String.Double, 'string'),
2758
+ # Numbers
2759
+ (r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
2760
+ (r'\.[0-9]+(?!\.)', Number.Float),
2761
+ (r'[0-9]+', Number.Integer),
2762
+ (r'\$[0-9a-f]+', Number.Hex),
2763
+ (r'\%[10]+', Number), # Binary
2764
+ # Other
2765
+ (r'(?:%s|([+\-*/~=<>^]))' % (bb_vopwords), Operator),
2766
+ (r'[(),:\[\]\\]', Punctuation),
2767
+ (r'\.([ \t]*)(%s)' % bb_name, Name.Label),
2768
+ # Identifiers
2769
+ (r'\b(New)\b([ \t]+)(%s)' % (bb_name),
2770
+ bygroups(Keyword.Reserved, Text, Name.Class)),
2771
+ (r'\b(Gosub|Goto)\b([ \t]+)(%s)' % (bb_name),
2772
+ bygroups(Keyword.Reserved, Text, Name.Label)),
2773
+ (r'\b(Object)\b([ \t]*)([.])([ \t]*)(%s)\b' % (bb_name),
2774
+ bygroups(Operator, Text, Punctuation, Text, Name.Class)),
2775
+ (r'\b%s\b([ \t]*)(\()' % bb_var,
2776
+ bygroups(Name.Function, Text, Keyword.Type,Text, Punctuation,
2777
+ Text, Name.Class, Text, Punctuation)),
2778
+ (r'\b(Function)\b([ \t]+)%s' % bb_var,
2779
+ bygroups(Keyword.Reserved, Text, Name.Function, Text, Keyword.Type,
2780
+ Text, Punctuation, Text, Name.Class)),
2781
+ (r'\b(Type)([ \t]+)(%s)' % (bb_name),
2782
+ bygroups(Keyword.Reserved, Text, Name.Class)),
2783
+ # Keywords
2784
+ (r'\b(Pi|True|False|Null)\b', Keyword.Constant),
2785
+ (r'\b(Local|Global|Const|Field|Dim)\b', Keyword.Declaration),
2786
+ (r'\b(End|Return|Exit|'
2787
+ r'Chr|Len|Asc|'
2788
+ r'New|Delete|Insert|'
2789
+ r'Include|'
2790
+ r'Function|'
2791
+ r'Type|'
2792
+ r'If|Then|Else|ElseIf|EndIf|'
2793
+ r'For|To|Next|Step|Each|'
2794
+ r'While|Wend|'
2795
+ r'Repeat|Until|Forever|'
2796
+ r'Select|Case|Default|'
2797
+ r'Goto|Gosub|Data|Read|Restore)\b', Keyword.Reserved),
2798
+ # Final resolve (for variable names and such)
2799
+ # (r'(%s)' % (bb_name), Name.Variable),
2800
+ (bb_var, bygroups(Name.Variable, Text, Keyword.Type,
2801
+ Text, Punctuation, Text, Name.Class)),
2802
+ ],
2803
+ 'string': [
2804
+ (r'""', String.Double),
2805
+ (r'"C?', String.Double, '#pop'),
2806
+ (r'[^"]+', String.Double),
2807
+ ],
2808
+ }
2809
+
2810
+
2811
+ class NimrodLexer(RegexLexer):
2812
+ """
2813
+ For `Nimrod <http://nimrod-code.org/>`_ source code.
2814
+
2815
+ *New in Pygments 1.5.*
2816
+ """
2817
+
2818
+ name = 'Nimrod'
2819
+ aliases = ['nimrod', 'nim']
2820
+ filenames = ['*.nim', '*.nimrod']
2821
+ mimetypes = ['text/x-nimrod']
2822
+
2823
+ flags = re.MULTILINE | re.IGNORECASE | re.UNICODE
2824
+
2825
+ def underscorize(words):
2826
+ newWords = []
2827
+ new = ""
2828
+ for word in words:
2829
+ for ch in word:
2830
+ new += (ch + "_?")
2831
+ newWords.append(new)
2832
+ new = ""
2833
+ return "|".join(newWords)
2834
+
2835
+ keywords = [
2836
+ 'addr', 'and', 'as', 'asm', 'atomic', 'bind', 'block', 'break',
2837
+ 'case', 'cast', 'const', 'continue', 'converter', 'discard',
2838
+ 'distinct', 'div', 'elif', 'else', 'end', 'enum', 'except', 'finally',
2839
+ 'for', 'generic', 'if', 'implies', 'in', 'yield',
2840
+ 'is', 'isnot', 'iterator', 'lambda', 'let', 'macro', 'method',
2841
+ 'mod', 'not', 'notin', 'object', 'of', 'or', 'out', 'proc',
2842
+ 'ptr', 'raise', 'ref', 'return', 'shl', 'shr', 'template', 'try',
2843
+ 'tuple', 'type' , 'when', 'while', 'with', 'without', 'xor'
2844
+ ]
2845
+
2846
+ keywordsPseudo = [
2847
+ 'nil', 'true', 'false'
2848
+ ]
2849
+
2850
+ opWords = [
2851
+ 'and', 'or', 'not', 'xor', 'shl', 'shr', 'div', 'mod', 'in',
2852
+ 'notin', 'is', 'isnot'
2853
+ ]
2854
+
2855
+ types = [
2856
+ 'int', 'int8', 'int16', 'int32', 'int64', 'float', 'float32', 'float64',
2857
+ 'bool', 'char', 'range', 'array', 'seq', 'set', 'string'
2858
+ ]
2859
+
2860
+ tokens = {
2861
+ 'root': [
2862
+ (r'##.*$', String.Doc),
2863
+ (r'#.*$', Comment),
2864
+ (r'\*|=|>|<|\+|-|/|@|\$|~|&|%|\!|\?|\||\\|\[|\]', Operator),
2865
+ (r'\.\.|\.|,|\[\.|\.\]|{\.|\.}|\(\.|\.\)|{|}|\(|\)|:|\^|`|;',
2866
+ Punctuation),
2867
+
2868
+ # Strings
2869
+ (r'(?:[\w]+)"', String, 'rdqs'),
2870
+ (r'"""', String, 'tdqs'),
2871
+ ('"', String, 'dqs'),
2872
+
2873
+ # Char
2874
+ ("'", String.Char, 'chars'),
2875
+
2876
+ # Keywords
2877
+ (r'(%s)\b' % underscorize(opWords), Operator.Word),
2878
+ (r'(p_?r_?o_?c_?\s)(?![\(\[\]])', Keyword, 'funcname'),
2879
+ (r'(%s)\b' % underscorize(keywords), Keyword),
2880
+ (r'(%s)\b' % underscorize(['from', 'import', 'include']),
2881
+ Keyword.Namespace),
2882
+ (r'(v_?a_?r)\b', Keyword.Declaration),
2883
+ (r'(%s)\b' % underscorize(types), Keyword.Type),
2884
+ (r'(%s)\b' % underscorize(keywordsPseudo), Keyword.Pseudo),
2885
+ # Identifiers
2886
+ (r'\b((?![_\d])\w)(((?!_)\w)|(_(?!_)\w))*', Name),
2887
+ # Numbers
2888
+ (r'[0-9][0-9_]*(?=([eE.]|\'[fF](32|64)))',
2889
+ Number.Float, ('float-suffix', 'float-number')),
2890
+ (r'0[xX][a-fA-F0-9][a-fA-F0-9_]*', Number.Hex, 'int-suffix'),
2891
+ (r'0[bB][01][01_]*', Number, 'int-suffix'),
2892
+ (r'0o[0-7][0-7_]*', Number.Oct, 'int-suffix'),
2893
+ (r'[0-9][0-9_]*', Number.Integer, 'int-suffix'),
2894
+ # Whitespace
2895
+ (r'\s+', Text),
2896
+ (r'.+$', Error),
2897
+ ],
2898
+ 'chars': [
2899
+ (r'\\([\\abcefnrtvl"\']|x[a-fA-F0-9]{2}|[0-9]{1,3})', String.Escape),
2900
+ (r"'", String.Char, '#pop'),
2901
+ (r".", String.Char)
2902
+ ],
2903
+ 'strings': [
2904
+ (r'(?<!\$)\$(\d+|#|\w+)+', String.Interpol),
2905
+ (r'[^\\\'"\$\n]+', String),
2906
+ # quotes, dollars and backslashes must be parsed one at a time
2907
+ (r'[\'"\\]', String),
2908
+ # unhandled string formatting sign
2909
+ (r'\$', String)
2910
+ # newlines are an error (use "nl" state)
2911
+ ],
2912
+ 'dqs': [
2913
+ (r'\\([\\abcefnrtvl"\']|\n|x[a-fA-F0-9]{2}|[0-9]{1,3})',
2914
+ String.Escape),
2915
+ (r'"', String, '#pop'),
2916
+ include('strings')
2917
+ ],
2918
+ 'rdqs': [
2919
+ (r'"(?!")', String, '#pop'),
2920
+ (r'""', String.Escape),
2921
+ include('strings')
2922
+ ],
2923
+ 'tdqs': [
2924
+ (r'"""(?!")', String, '#pop'),
2925
+ include('strings'),
2926
+ include('nl')
2927
+ ],
2928
+ 'funcname': [
2929
+ (r'((?![\d_])\w)(((?!_)\w)|(_(?!_)\w))*', Name.Function, '#pop'),
2930
+ (r'`.+`', Name.Function, '#pop')
2931
+ ],
2932
+ 'nl': [
2933
+ (r'\n', String)
2934
+ ],
2935
+ 'float-number': [
2936
+ (r'\.(?!\.)[0-9_]*', Number.Float),
2937
+ (r'[eE][+-]?[0-9][0-9_]*', Number.Float),
2938
+ (r'', Text, '#pop')
2939
+ ],
2940
+ 'float-suffix': [
2941
+ (r'\'[fF](32|64)', Number.Float),
2942
+ (r'', Text, '#pop')
2943
+ ],
2944
+ 'int-suffix': [
2945
+ (r'\'[iI](32|64)', Number.Integer.Long),
2946
+ (r'\'[iI](8|16)', Number.Integer),
2947
+ (r'', Text, '#pop')
2948
+ ],
2949
+ }
2950
+
2951
+
2952
+ class FantomLexer(RegexLexer):
2953
+ """
2954
+ For Fantom source code.
2955
+
2956
+ *New in Pygments 1.5.*
2957
+ """
2958
+ name = 'Fantom'
2959
+ aliases = ['fan']
2960
+ filenames = ['*.fan']
2961
+ mimetypes = ['application/x-fantom']
2962
+
2963
+ # often used regexes
2964
+ def s(str):
2965
+ return Template(str).substitute(
2966
+ dict (
2967
+ pod = r'[\"\w\.]+',
2968
+ eos = r'\n|;',
2969
+ id = r'[a-zA-Z_][a-zA-Z0-9_]*',
2970
+ # all chars which can be part of type definition. Starts with
2971
+ # either letter, or [ (maps), or | (funcs)
2972
+ type = r'(?:\[|[a-zA-Z_]|\|)[:\w\[\]\|\->\?]*?',
2973
+ )
2974
+ )
2975
+
2976
+
2977
+ tokens = {
2978
+ 'comments': [
2979
+ (r'(?s)/\*.*?\*/', Comment.Multiline), #Multiline
2980
+ (r'//.*?\n', Comment.Single), #Single line
2981
+ #todo: highlight references in fandocs
2982
+ (r'\*\*.*?\n', Comment.Special), #Fandoc
2983
+ (r'#.*\n', Comment.Single) #Shell-style
2984
+ ],
2985
+ 'literals': [
2986
+ (r'\b-?[\d_]+(ns|ms|sec|min|hr|day)', Number), #Duration
2987
+ (r'\b-?[\d_]*\.[\d_]+(ns|ms|sec|min|hr|day)', Number),
2988
+ #Duration with dot
2989
+ (r'\b-?(\d+)?\.\d+(f|F|d|D)?', Number.Float), #Float/Decimal
2990
+ (r'\b-?0x[0-9a-fA-F_]+', Number.Hex), #Hex
2991
+ (r'\b-?[\d_]+', Number.Integer), #Int
2992
+ (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), #Char
2993
+ (r'"', Punctuation, 'insideStr'), #Opening quote
2994
+ (r'`', Punctuation, 'insideUri'), #Opening accent
2995
+ (r'\b(true|false|null)\b', Keyword.Constant), #Bool & null
2996
+ (r'(?:(\w+)(::))?(\w+)(<\|)(.*?)(\|>)', #DSL
2997
+ bygroups(Name.Namespace, Punctuation, Name.Class,
2998
+ Punctuation, String, Punctuation)),
2999
+ (r'(?:(\w+)(::))?(\w+)?(#)(\w+)?', #Type/slot literal
3000
+ bygroups(Name.Namespace, Punctuation, Name.Class,
3001
+ Punctuation, Name.Function)),
3002
+ (r'\[,\]', Literal), # Empty list
3003
+ (s(r'($type)(\[,\])'), # Typed empty list
3004
+ bygroups(using(this, state = 'inType'), Literal)),
3005
+ (r'\[:\]', Literal), # Empty Map
3006
+ (s(r'($type)(\[:\])'),
3007
+ bygroups(using(this, state = 'inType'), Literal)),
3008
+ ],
3009
+ 'insideStr': [
3010
+ (r'\\\\', String.Escape), #Escaped backslash
3011
+ (r'\\"', String.Escape), #Escaped "
3012
+ (r'\\`', String.Escape), #Escaped `
3013
+ (r'\$\w+', String.Interpol), #Subst var
3014
+ (r'\${.*?}', String.Interpol), #Subst expr
3015
+ (r'"', Punctuation, '#pop'), #Closing quot
3016
+ (r'.', String) #String content
3017
+ ],
3018
+ 'insideUri': [ #TODO: remove copy/paste str/uri
3019
+ (r'\\\\', String.Escape), #Escaped backslash
3020
+ (r'\\"', String.Escape), #Escaped "
3021
+ (r'\\`', String.Escape), #Escaped `
3022
+ (r'\$\w+', String.Interpol), #Subst var
3023
+ (r'\${.*?}', String.Interpol), #Subst expr
3024
+ (r'`', Punctuation, '#pop'), #Closing tick
3025
+ (r'.', String.Backtick) #URI content
3026
+ ],
3027
+ 'protectionKeywords': [
3028
+ (r'\b(public|protected|private|internal)\b', Keyword),
3029
+ ],
3030
+ 'typeKeywords': [
3031
+ (r'\b(abstract|final|const|native|facet|enum)\b', Keyword),
3032
+ ],
3033
+ 'methodKeywords': [
3034
+ (r'\b(abstract|native|once|override|static|virtual|final)\b',
3035
+ Keyword),
3036
+ ],
3037
+ 'fieldKeywords': [
3038
+ (r'\b(abstract|const|final|native|override|static|virtual|'
3039
+ r'readonly)\b', Keyword)
3040
+ ],
3041
+ 'otherKeywords': [
3042
+ (r'\b(try|catch|throw|finally|for|if|else|while|as|is|isnot|'
3043
+ r'switch|case|default|continue|break|do|return|get|set)\b',
3044
+ Keyword),
3045
+ (r'\b(it|this|super)\b', Name.Builtin.Pseudo),
3046
+ ],
3047
+ 'operators': [
3048
+ (r'\+\+|\-\-|\+|\-|\*|/|\|\||&&|<=>|<=|<|>=|>|=|!|\[|\]', Operator)
3049
+ ],
3050
+ 'inType': [
3051
+ (r'[\[\]\|\->:\?]', Punctuation),
3052
+ (s(r'$id'), Name.Class),
3053
+ (r'', Text, '#pop'),
3054
+
3055
+ ],
3056
+ 'root': [
3057
+ include('comments'),
3058
+ include('protectionKeywords'),
3059
+ include('typeKeywords'),
3060
+ include('methodKeywords'),
3061
+ include('fieldKeywords'),
3062
+ include('literals'),
3063
+ include('otherKeywords'),
3064
+ include('operators'),
3065
+ (r'using\b', Keyword.Namespace, 'using'), # Using stmt
3066
+ (r'@\w+', Name.Decorator, 'facet'), # Symbol
3067
+ (r'(class|mixin)(\s+)(\w+)', bygroups(Keyword, Text, Name.Class),
3068
+ 'inheritance'), # Inheritance list
3069
+
3070
+
3071
+ ### Type var := val
3072
+ (s(r'($type)([ \t]+)($id)(\s*)(:=)'),
3073
+ bygroups(using(this, state = 'inType'), Text,
3074
+ Name.Variable, Text, Operator)),
3075
+
3076
+ ### var := val
3077
+ (s(r'($id)(\s*)(:=)'),
3078
+ bygroups(Name.Variable, Text, Operator)),
3079
+
3080
+ ### .someId( or ->someId( ###
3081
+ (s(r'(\.|(?:\->))($id)(\s*)(\()'),
3082
+ bygroups(Operator, Name.Function, Text, Punctuation),
3083
+ 'insideParen'),
3084
+
3085
+ ### .someId or ->someId
3086
+ (s(r'(\.|(?:\->))($id)'),
3087
+ bygroups(Operator, Name.Function)),
3088
+
3089
+ ### new makeXXX ( ####
3090
+ (r'(new)(\s+)(make\w*)(\s*)(\()',
3091
+ bygroups(Keyword, Text, Name.Function, Text, Punctuation),
3092
+ 'insideMethodDeclArgs'),
3093
+
3094
+ ### Type name ( ####
3095
+ (s(r'($type)([ \t]+)' #Return type and whitespace
3096
+ r'($id)(\s*)(\()'), #method name + open brace
3097
+ bygroups(using(this, state = 'inType'), Text,
3098
+ Name.Function, Text, Punctuation),
3099
+ 'insideMethodDeclArgs'),
3100
+
3101
+ ### ArgType argName, #####
3102
+ (s(r'($type)(\s+)($id)(\s*)(,)'),
3103
+ bygroups(using(this, state='inType'), Text, Name.Variable,
3104
+ Text, Punctuation)),
3105
+
3106
+ #### ArgType argName) ####
3107
+ ## Covered in 'insideParen' state
3108
+
3109
+ ### ArgType argName -> ArgType| ###
3110
+ (s(r'($type)(\s+)($id)(\s*)(\->)(\s*)($type)(\|)'),
3111
+ bygroups(using(this, state='inType'), Text, Name.Variable,
3112
+ Text, Punctuation, Text, using(this, state = 'inType'),
3113
+ Punctuation)),
3114
+
3115
+ ### ArgType argName| ###
3116
+ (s(r'($type)(\s+)($id)(\s*)(\|)'),
3117
+ bygroups(using(this, state='inType'), Text, Name.Variable,
3118
+ Text, Punctuation)),
3119
+
3120
+ ### Type var
3121
+ (s(r'($type)([ \t]+)($id)'),
3122
+ bygroups(using(this, state='inType'), Text,
3123
+ Name.Variable)),
3124
+
3125
+ (r'\(', Punctuation, 'insideParen'),
3126
+ (r'\{', Punctuation, 'insideBrace'),
3127
+ (r'.', Text)
3128
+ ],
3129
+ 'insideParen': [
3130
+ (r'\)', Punctuation, '#pop'),
3131
+ include('root'),
3132
+ ],
3133
+ 'insideMethodDeclArgs': [
3134
+ (r'\)', Punctuation, '#pop'),
3135
+ (s(r'($type)(\s+)($id)(\s*)(\))'),
3136
+ bygroups(using(this, state='inType'), Text, Name.Variable,
3137
+ Text, Punctuation), '#pop'),
3138
+ include('root'),
3139
+ ],
3140
+ 'insideBrace': [
3141
+ (r'\}', Punctuation, '#pop'),
3142
+ include('root'),
3143
+ ],
3144
+ 'inheritance': [
3145
+ (r'\s+', Text), #Whitespace
3146
+ (r':|,', Punctuation),
3147
+ (r'(?:(\w+)(::))?(\w+)',
3148
+ bygroups(Name.Namespace, Punctuation, Name.Class)),
3149
+ (r'{', Punctuation, '#pop')
3150
+ ],
3151
+ 'using': [
3152
+ (r'[ \t]+', Text), # consume whitespaces
3153
+ (r'(\[)(\w+)(\])',
3154
+ bygroups(Punctuation, Comment.Special, Punctuation)), #ffi
3155
+ (r'(\")?([\w\.]+)(\")?',
3156
+ bygroups(Punctuation, Name.Namespace, Punctuation)), #podname
3157
+ (r'::', Punctuation, 'usingClass'),
3158
+ (r'', Text, '#pop')
3159
+ ],
3160
+ 'usingClass': [
3161
+ (r'[ \t]+', Text), # consume whitespaces
3162
+ (r'(as)(\s+)(\w+)',
3163
+ bygroups(Keyword.Declaration, Text, Name.Class), '#pop:2'),
3164
+ (r'[\w\$]+', Name.Class),
3165
+ (r'', Text, '#pop:2') # jump out to root state
3166
+ ],
3167
+ 'facet': [
3168
+ (r'\s+', Text),
3169
+ (r'{', Punctuation, 'facetFields'),
3170
+ (r'', Text, '#pop')
3171
+ ],
3172
+ 'facetFields': [
3173
+ include('comments'),
3174
+ include('literals'),
3175
+ include('operators'),
3176
+ (r'\s+', Text),
3177
+ (r'(\s*)(\w+)(\s*)(=)', bygroups(Text, Name, Text, Operator)),
3178
+ (r'}', Punctuation, '#pop'),
3179
+ (r'.', Text)
3180
+ ],
3181
+ }
3182
+
3183
+
3184
+ class RustLexer(RegexLexer):
3185
+ """
3186
+ Lexer for Mozilla's Rust programming language.
3187
+
3188
+ *New in Pygments 1.6.*
3189
+ """
3190
+ name = 'Rust'
3191
+ filenames = ['*.rs', '*.rc']
3192
+ aliases = ['rust']
3193
+ mimetypes = ['text/x-rustsrc']
3194
+
3195
+ tokens = {
3196
+ 'root': [
3197
+ # Whitespace and Comments
3198
+ (r'\n', Text),
3199
+ (r'\s+', Text),
3200
+ (r'//(.*?)\n', Comment.Single),
3201
+ (r'/[*](.|\n)*?[*]/', Comment.Multiline),
3202
+
3203
+ # Keywords
3204
+ (r'(as|assert|break|const'
3205
+ r'|copy|do|else|enum|extern|fail'
3206
+ r'|false|fn|for|if|impl|let|log'
3207
+ r'|loop|match|mod|move|mut|once|priv|pub|pure'
3208
+ r'|ref|return|static|struct|trait|true|type|unsafe|use|while'
3209
+ r'|u8|u16|u32|u64|i8|i16|i32|i64|uint'
3210
+ r'|int|float|f32|f64|str)\b', Keyword),
3211
+
3212
+ # Character Literal
3213
+ (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
3214
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
3215
+ String.Char),
3216
+ # Binary Literal
3217
+ (r'0[Bb][01_]+', Number, 'number_lit'),
3218
+ # Octal Literal
3219
+ (r'0[0-7_]+', Number.Oct, 'number_lit'),
3220
+ # Hexadecimal Literal
3221
+ (r'0[xX][0-9a-fA-F_]+', Number.Hex, 'number_lit'),
3222
+ # Decimal Literal
3223
+ (r'[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?'
3224
+ r'[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)?', Number, 'number_lit'),
3225
+ # String Literal
3226
+ (r'"', String, 'string'),
3227
+
3228
+ # Operators and Punctuation
3229
+ (r'[{}()\[\],.;]', Punctuation),
3230
+ (r'[+\-*/%&|<>^!~@=:?]', Operator),
3231
+
3232
+ # Identifier
3233
+ (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
3234
+
3235
+ # Attributes
3236
+ (r'#\[', Comment.Preproc, 'attribute['),
3237
+ (r'#\(', Comment.Preproc, 'attribute('),
3238
+ # Macros
3239
+ (r'[A-Za-z_][A-Za-z0-9_]*!\[', Comment.Preproc, 'attribute['),
3240
+ (r'[A-Za-z_][A-Za-z0-9_]*!\(', Comment.Preproc, 'attribute('),
3241
+ ],
3242
+ 'number_lit': [
3243
+ (r'(([ui](8|16|32|64)?)|(f(32|64)?))?', Keyword, '#pop'),
3244
+ ],
3245
+ 'string': [
3246
+ (r'"', String, '#pop'),
3247
+ (r"""\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
3248
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}""", String.Escape),
3249
+ (r'[^\\"]+', String),
3250
+ (r'\\', String),
3251
+ ],
3252
+ 'attribute_common': [
3253
+ (r'"', String, 'string'),
3254
+ (r'\[', Comment.Preproc, 'attribute['),
3255
+ (r'\(', Comment.Preproc, 'attribute('),
3256
+ ],
3257
+ 'attribute[': [
3258
+ include('attribute_common'),
3259
+ (r'\];?', Comment.Preproc, '#pop'),
3260
+ (r'[^"\]]+', Comment.Preproc),
3261
+ ],
3262
+ 'attribute(': [
3263
+ include('attribute_common'),
3264
+ (r'\);?', Comment.Preproc, '#pop'),
3265
+ (r'[^"\)]+', Comment.Preproc),
3266
+ ],
3267
+ }
3268
+
3269
+
3270
+ class CudaLexer(CLexer):
3271
+ """
3272
+ For NVIDIA `CUDA™ <http://developer.nvidia.com/category/zone/cuda-zone>`_
3273
+ source.
3274
+
3275
+ *New in Pygments 1.6.*
3276
+ """
3277
+ name = 'CUDA'
3278
+ filenames = ['*.cu', '*.cuh']
3279
+ aliases = ['cuda', 'cu']
3280
+ mimetypes = ['text/x-cuda']
3281
+
3282
+ function_qualifiers = ['__device__', '__global__', '__host__',
3283
+ '__noinline__', '__forceinline__']
3284
+ variable_qualifiers = ['__device__', '__constant__', '__shared__',
3285
+ '__restrict__']
3286
+ vector_types = ['char1', 'uchar1', 'char2', 'uchar2', 'char3', 'uchar3',
3287
+ 'char4', 'uchar4', 'short1', 'ushort1', 'short2', 'ushort2',
3288
+ 'short3', 'ushort3', 'short4', 'ushort4', 'int1', 'uint1',
3289
+ 'int2', 'uint2', 'int3', 'uint3', 'int4', 'uint4', 'long1',
3290
+ 'ulong1', 'long2', 'ulong2', 'long3', 'ulong3', 'long4',
3291
+ 'ulong4', 'longlong1', 'ulonglong1', 'longlong2',
3292
+ 'ulonglong2', 'float1', 'float2', 'float3', 'float4',
3293
+ 'double1', 'double2', 'dim3']
3294
+ variables = ['gridDim', 'blockIdx', 'blockDim', 'threadIdx', 'warpSize']
3295
+ functions = ['__threadfence_block', '__threadfence', '__threadfence_system',
3296
+ '__syncthreads', '__syncthreads_count', '__syncthreads_and',
3297
+ '__syncthreads_or']
3298
+ execution_confs = ['<<<', '>>>']
3299
+
3300
+ def get_tokens_unprocessed(self, text):
3301
+ for index, token, value in \
3302
+ CLexer.get_tokens_unprocessed(self, text):
3303
+ if token is Name:
3304
+ if value in self.variable_qualifiers:
3305
+ token = Keyword.Type
3306
+ elif value in self.vector_types:
3307
+ token = Keyword.Type
3308
+ elif value in self.variables:
3309
+ token = Name.Builtin
3310
+ elif value in self.execution_confs:
3311
+ token = Keyword.Pseudo
3312
+ elif value in self.function_qualifiers:
3313
+ token = Keyword.Reserved
3314
+ elif value in self.functions:
3315
+ token = Name.Function
3316
+ yield index, token, value
3317
+
3318
+
3319
+ class MonkeyLexer(RegexLexer):
3320
+ """
3321
+ For
3322
+ `Monkey <https://en.wikipedia.org/wiki/Monkey_(programming_language)>`_
3323
+ source code.
3324
+
3325
+ *New in Pygments 1.6.*
3326
+ """
3327
+
3328
+ name = 'Monkey'
3329
+ aliases = ['monkey']
3330
+ filenames = ['*.monkey']
3331
+ mimetypes = ['text/x-monkey']
3332
+
3333
+ name_variable = r'[a-z_][a-zA-Z0-9_]*'
3334
+ name_function = r'[A-Z][a-zA-Z0-9_]*'
3335
+ name_constant = r'[A-Z_][A-Z0-9_]*'
3336
+ name_class = r'[A-Z][a-zA-Z0-9_]*'
3337
+ name_module = r'[a-z0-9_]*'
3338
+
3339
+ keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)'
3340
+ # ? == Bool // % == Int // # == Float // $ == String
3341
+ keyword_type_special = r'[?%#$]'
3342
+
3343
+ flags = re.MULTILINE
3344
+
3345
+ tokens = {
3346
+ 'root': [
3347
+ #Text
3348
+ (r'\s+', Text),
3349
+ # Comments
3350
+ (r"'.*", Comment),
3351
+ (r'(?i)^#rem\b', Comment.Multiline, 'comment'),
3352
+ # preprocessor directives
3353
+ (r'(?i)^(?:#If|#ElseIf|#Else|#EndIf|#End|#Print|#Error)\b', Comment.Preproc),
3354
+ # preprocessor variable (any line starting with '#' that is not a directive)
3355
+ (r'^#', Comment.Preproc, 'variables'),
3356
+ # String
3357
+ ('"', String.Double, 'string'),
3358
+ # Numbers
3359
+ (r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
3360
+ (r'\.[0-9]+(?!\.)', Number.Float),
3361
+ (r'[0-9]+', Number.Integer),
3362
+ (r'\$[0-9a-fA-Z]+', Number.Hex),
3363
+ (r'\%[10]+', Number), # Binary
3364
+ # Native data types
3365
+ (r'\b%s\b' % keyword_type, Keyword.Type),
3366
+ # Exception handling
3367
+ (r'(?i)\b(?:Try|Catch|Throw)\b', Keyword.Reserved),
3368
+ (r'Throwable', Name.Exception),
3369
+ # Builtins
3370
+ (r'(?i)\b(?:Null|True|False)\b', Name.Builtin),
3371
+ (r'(?i)\b(?:Self|Super)\b', Name.Builtin.Pseudo),
3372
+ (r'\b(?:HOST|LANG|TARGET|CONFIG)\b', Name.Constant),
3373
+ # Keywords
3374
+ (r'(?i)^(Import)(\s+)(.*)(\n)',
3375
+ bygroups(Keyword.Namespace, Text, Name.Namespace, Text)),
3376
+ (r'(?i)^Strict\b.*\n', Keyword.Reserved),
3377
+ (r'(?i)(Const|Local|Global|Field)(\s+)',
3378
+ bygroups(Keyword.Declaration, Text), 'variables'),
3379
+ (r'(?i)(New|Class|Interface|Extends|Implements)(\s+)',
3380
+ bygroups(Keyword.Reserved, Text), 'classname'),
3381
+ (r'(?i)(Function|Method)(\s+)',
3382
+ bygroups(Keyword.Reserved, Text), 'funcname'),
3383
+ (r'(?i)(?:End|Return|Public|Private|Extern|Property|'
3384
+ r'Final|Abstract)\b', Keyword.Reserved),
3385
+ # Flow Control stuff
3386
+ (r'(?i)(?:If|Then|Else|ElseIf|EndIf|'
3387
+ r'Select|Case|Default|'
3388
+ r'While|Wend|'
3389
+ r'Repeat|Until|Forever|'
3390
+ r'For|To|Until|Step|EachIn|Next|'
3391
+ r'Exit|Continue)\s+', Keyword.Reserved),
3392
+ # not used yet
3393
+ (r'(?i)\b(?:Module|Inline)\b', Keyword.Reserved),
3394
+ # Array
3395
+ (r'[\[\]]', Punctuation),
3396
+ # Other
3397
+ (r'<=|>=|<>|\*=|/=|\+=|-=|&=|~=|\|=|[-&*/^+=<>|~]', Operator),
3398
+ (r'(?i)(?:Not|Mod|Shl|Shr|And|Or)', Operator.Word),
3399
+ (r'[\(\){}!#,.:]', Punctuation),
3400
+ # catch the rest
3401
+ (r'%s\b' % name_constant, Name.Constant),
3402
+ (r'%s\b' % name_function, Name.Function),
3403
+ (r'%s\b' % name_variable, Name.Variable),
3404
+ ],
3405
+ 'funcname': [
3406
+ (r'(?i)%s\b' % name_function, Name.Function),
3407
+ (r':', Punctuation, 'classname'),
3408
+ (r'\s+', Text),
3409
+ (r'\(', Punctuation, 'variables'),
3410
+ (r'\)', Punctuation, '#pop')
3411
+ ],
3412
+ 'classname': [
3413
+ (r'%s\.' % name_module, Name.Namespace),
3414
+ (r'%s\b' % keyword_type, Keyword.Type),
3415
+ (r'%s\b' % name_class, Name.Class),
3416
+ # array (of given size)
3417
+ (r'(\[)(\s*)(\d*)(\s*)(\])',
3418
+ bygroups(Punctuation, Text, Number.Integer, Text, Punctuation)),
3419
+ # generics
3420
+ (r'\s+(?!<)', Text, '#pop'),
3421
+ (r'<', Punctuation, '#push'),
3422
+ (r'>', Punctuation, '#pop'),
3423
+ (r'\n', Text, '#pop'),
3424
+ (r'', Text, '#pop')
3425
+ ],
3426
+ 'variables': [
3427
+ (r'%s\b' % name_constant, Name.Constant),
3428
+ (r'%s\b' % name_variable, Name.Variable),
3429
+ (r'%s' % keyword_type_special, Keyword.Type),
3430
+ (r'\s+', Text),
3431
+ (r':', Punctuation, 'classname'),
3432
+ (r',', Punctuation, '#push'),
3433
+ (r'', Text, '#pop')
3434
+ ],
3435
+ 'string': [
3436
+ (r'[^"~]+', String.Double),
3437
+ (r'~q|~n|~r|~t|~z|~~', String.Escape),
3438
+ (r'"', String.Double, '#pop'),
3439
+ ],
3440
+ 'comment' : [
3441
+ (r'(?i)^#rem.*?', Comment.Multiline, "#push"),
3442
+ (r'(?i)^#end.*?', Comment.Multiline, "#pop"),
3443
+ (r'\n', Comment.Multiline),
3444
+ (r'.+', Comment.Multiline),
3445
+ ],
3446
+ }
3447
+
3448
+
3449
+ class CobolLexer(RegexLexer):
3450
+ """
3451
+ Lexer for OpenCOBOL code.
3452
+
3453
+ *New in Pygments 1.6.*
3454
+ """
3455
+ name = 'COBOL'
3456
+ aliases = ['cobol']
3457
+ filenames = ['*.cob', '*.COB', '*.cpy', '*.CPY']
3458
+ mimetypes = ['text/x-cobol']
3459
+ flags = re.IGNORECASE | re.MULTILINE
3460
+
3461
+ # Data Types: by PICTURE and USAGE
3462
+ # Operators: **, *, +, -, /, <, >, <=, >=, =, <>
3463
+ # Logical (?): NOT, AND, OR
3464
+
3465
+ # Reserved words:
3466
+ # http://opencobol.add1tocobol.com/#reserved-words
3467
+ # Intrinsics:
3468
+ # http://opencobol.add1tocobol.com/#does-opencobol-implement-any-intrinsic-functions
3469
+
3470
+ tokens = {
3471
+ 'root': [
3472
+ include('comment'),
3473
+ include('strings'),
3474
+ include('core'),
3475
+ include('nums'),
3476
+ (r'[a-z0-9]([_a-z0-9\-]*[a-z0-9]+)?', Name.Variable),
3477
+ # (r'[\s]+', Text),
3478
+ (r'[ \t]+', Text),
3479
+ ],
3480
+ 'comment': [
3481
+ (r'(^.{6}[*/].*\n|^.{6}|\*>.*\n)', Comment),
3482
+ ],
3483
+ 'core': [
3484
+ # Figurative constants
3485
+ (r'(^|(?<=[^0-9a-z_\-]))(ALL\s+)?'
3486
+ r'((ZEROES)|(HIGH-VALUE|LOW-VALUE|QUOTE|SPACE|ZERO)(S)?)'
3487
+ r'\s*($|(?=[^0-9a-z_\-]))',
3488
+ Name.Constant),
3489
+
3490
+ # Reserved words STATEMENTS and other bolds
3491
+ (r'(^|(?<=[^0-9a-z_\-]))'
3492
+ r'(ACCEPT|ADD|ALLOCATE|CALL|CANCEL|CLOSE|COMPUTE|'
3493
+ r'CONFIGURATION|CONTINUE|'
3494
+ r'DATA|DELETE|DISPLAY|DIVIDE|DIVISION|ELSE|END|END-ACCEPT|'
3495
+ r'END-ADD|END-CALL|END-COMPUTE|END-DELETE|END-DISPLAY|'
3496
+ r'END-DIVIDE|END-EVALUATE|END-IF|END-MULTIPLY|END-OF-PAGE|'
3497
+ r'END-PERFORM|END-READ|END-RETURN|END-REWRITE|END-SEARCH|'
3498
+ r'END-START|END-STRING|END-SUBTRACT|END-UNSTRING|END-WRITE|'
3499
+ r'ENVIRONMENT|EVALUATE|EXIT|FD|FILE|FILE-CONTROL|FOREVER|'
3500
+ r'FREE|GENERATE|GO|GOBACK|'
3501
+ r'IDENTIFICATION|IF|INITIALIZE|'
3502
+ r'INITIATE|INPUT-OUTPUT|INSPECT|INVOKE|I-O-CONTROL|LINKAGE|'
3503
+ r'LOCAL-STORAGE|MERGE|MOVE|MULTIPLY|OPEN|'
3504
+ r'PERFORM|PROCEDURE|PROGRAM-ID|RAISE|READ|RELEASE|RESUME|'
3505
+ r'RETURN|REWRITE|SCREEN|'
3506
+ r'SD|SEARCH|SECTION|SET|SORT|START|STOP|STRING|SUBTRACT|'
3507
+ r'SUPPRESS|TERMINATE|THEN|UNLOCK|UNSTRING|USE|VALIDATE|'
3508
+ r'WORKING-STORAGE|WRITE)'
3509
+ r'\s*($|(?=[^0-9a-z_\-]))', Keyword.Reserved),
3510
+
3511
+ # Reserved words
3512
+ (r'(^|(?<=[^0-9a-z_\-]))'
3513
+ r'(ACCESS|ADDRESS|ADVANCING|AFTER|ALL|'
3514
+ r'ALPHABET|ALPHABETIC|ALPHABETIC-LOWER|ALPHABETIC-UPPER|'
3515
+ r'ALPHANUMERIC|ALPHANUMERIC-EDITED|ALSO|ALTER|ALTERNATE'
3516
+ r'ANY|ARE|AREA|AREAS|ARGUMENT-NUMBER|ARGUMENT-VALUE|AS|'
3517
+ r'ASCENDING|ASSIGN|AT|AUTO|AUTO-SKIP|AUTOMATIC|AUTOTERMINATE|'
3518
+ r'BACKGROUND-COLOR|BASED|BEEP|BEFORE|BELL|'
3519
+ r'BLANK|'
3520
+ r'BLINK|BLOCK|BOTTOM|BY|BYTE-LENGTH|CHAINING|'
3521
+ r'CHARACTER|CHARACTERS|CLASS|CODE|CODE-SET|COL|COLLATING|'
3522
+ r'COLS|COLUMN|COLUMNS|COMMA|COMMAND-LINE|COMMIT|COMMON|'
3523
+ r'CONSTANT|CONTAINS|CONTENT|CONTROL|'
3524
+ r'CONTROLS|CONVERTING|COPY|CORR|CORRESPONDING|COUNT|CRT|'
3525
+ r'CURRENCY|CURSOR|CYCLE|DATE|DAY|DAY-OF-WEEK|DE|DEBUGGING|'
3526
+ r'DECIMAL-POINT|DECLARATIVES|DEFAULT|DELIMITED|'
3527
+ r'DELIMITER|DEPENDING|DESCENDING|DETAIL|DISK|'
3528
+ r'DOWN|DUPLICATES|DYNAMIC|EBCDIC|'
3529
+ r'ENTRY|ENVIRONMENT-NAME|ENVIRONMENT-VALUE|EOL|EOP|'
3530
+ r'EOS|ERASE|ERROR|ESCAPE|EXCEPTION|'
3531
+ r'EXCLUSIVE|EXTEND|EXTERNAL|'
3532
+ r'FILE-ID|FILLER|FINAL|FIRST|FIXED|FLOAT-LONG|FLOAT-SHORT|'
3533
+ r'FOOTING|FOR|FOREGROUND-COLOR|FORMAT|FROM|FULL|FUNCTION|'
3534
+ r'FUNCTION-ID|GIVING|GLOBAL|GROUP|'
3535
+ r'HEADING|HIGHLIGHT|I-O|ID|'
3536
+ r'IGNORE|IGNORING|IN|INDEX|INDEXED|INDICATE|'
3537
+ r'INITIAL|INITIALIZED|INPUT|'
3538
+ r'INTO|INTRINSIC|INVALID|IS|JUST|JUSTIFIED|KEY|LABEL|'
3539
+ r'LAST|LEADING|LEFT|LENGTH|LIMIT|LIMITS|LINAGE|'
3540
+ r'LINAGE-COUNTER|LINE|LINES|LOCALE|LOCK|'
3541
+ r'LOWLIGHT|MANUAL|MEMORY|MINUS|MODE|'
3542
+ r'MULTIPLE|NATIONAL|NATIONAL-EDITED|NATIVE|'
3543
+ r'NEGATIVE|NEXT|NO|NULL|NULLS|NUMBER|NUMBERS|NUMERIC|'
3544
+ r'NUMERIC-EDITED|OBJECT-COMPUTER|OCCURS|OF|OFF|OMITTED|ON|ONLY|'
3545
+ r'OPTIONAL|ORDER|ORGANIZATION|OTHER|OUTPUT|OVERFLOW|'
3546
+ r'OVERLINE|PACKED-DECIMAL|PADDING|PAGE|PARAGRAPH|'
3547
+ r'PLUS|POINTER|POSITION|POSITIVE|PRESENT|PREVIOUS|'
3548
+ r'PRINTER|PRINTING|PROCEDURE-POINTER|PROCEDURES|'
3549
+ r'PROCEED|PROGRAM|PROGRAM-POINTER|PROMPT|QUOTE|'
3550
+ r'QUOTES|RANDOM|RD|RECORD|RECORDING|RECORDS|RECURSIVE|'
3551
+ r'REDEFINES|REEL|REFERENCE|RELATIVE|REMAINDER|REMOVAL|'
3552
+ r'RENAMES|REPLACING|REPORT|REPORTING|REPORTS|REPOSITORY|'
3553
+ r'REQUIRED|RESERVE|RETURNING|REVERSE-VIDEO|REWIND|'
3554
+ r'RIGHT|ROLLBACK|ROUNDED|RUN|SAME|SCROLL|'
3555
+ r'SECURE|SEGMENT-LIMIT|SELECT|SENTENCE|SEPARATE|'
3556
+ r'SEQUENCE|SEQUENTIAL|SHARING|SIGN|SIGNED|SIGNED-INT|'
3557
+ r'SIGNED-LONG|SIGNED-SHORT|SIZE|SORT-MERGE|SOURCE|'
3558
+ r'SOURCE-COMPUTER|SPECIAL-NAMES|STANDARD|'
3559
+ r'STANDARD-1|STANDARD-2|STATUS|SUM|'
3560
+ r'SYMBOLIC|SYNC|SYNCHRONIZED|TALLYING|TAPE|'
3561
+ r'TEST|THROUGH|THRU|TIME|TIMES|TO|TOP|TRAILING|'
3562
+ r'TRANSFORM|TYPE|UNDERLINE|UNIT|UNSIGNED|'
3563
+ r'UNSIGNED-INT|UNSIGNED-LONG|UNSIGNED-SHORT|UNTIL|UP|'
3564
+ r'UPDATE|UPON|USAGE|USING|VALUE|VALUES|VARYING|WAIT|WHEN|'
3565
+ r'WITH|WORDS|YYYYDDD|YYYYMMDD)'
3566
+ r'\s*($|(?=[^0-9a-z_\-]))', Keyword.Pseudo),
3567
+
3568
+ # inactive reserved words
3569
+ (r'(^|(?<=[^0-9a-z_\-]))'
3570
+ r'(ACTIVE-CLASS|ALIGNED|ANYCASE|ARITHMETIC|ATTRIBUTE|B-AND|'
3571
+ r'B-NOT|B-OR|B-XOR|BIT|BOOLEAN|CD|CENTER|CF|CH|CHAIN|CLASS-ID|'
3572
+ r'CLASSIFICATION|COMMUNICATION|CONDITION|DATA-POINTER|'
3573
+ r'DESTINATION|DISABLE|EC|EGI|EMI|ENABLE|END-RECEIVE|'
3574
+ r'ENTRY-CONVENTION|EO|ESI|EXCEPTION-OBJECT|EXPANDS|FACTORY|'
3575
+ r'FLOAT-BINARY-16|FLOAT-BINARY-34|FLOAT-BINARY-7|'
3576
+ r'FLOAT-DECIMAL-16|FLOAT-DECIMAL-34|FLOAT-EXTENDED|FORMAT|'
3577
+ r'FUNCTION-POINTER|GET|GROUP-USAGE|IMPLEMENTS|INFINITY|'
3578
+ r'INHERITS|INTERFACE|INTERFACE-ID|INVOKE|LC_ALL|LC_COLLATE|'
3579
+ r'LC_CTYPE|LC_MESSAGES|LC_MONETARY|LC_NUMERIC|LC_TIME|'
3580
+ r'LINE-COUNTER|MESSAGE|METHOD|METHOD-ID|NESTED|NONE|NORMAL|'
3581
+ r'OBJECT|OBJECT-REFERENCE|OPTIONS|OVERRIDE|PAGE-COUNTER|PF|PH|'
3582
+ r'PROPERTY|PROTOTYPE|PURGE|QUEUE|RAISE|RAISING|RECEIVE|'
3583
+ r'RELATION|REPLACE|REPRESENTS-NOT-A-NUMBER|RESET|RESUME|RETRY|'
3584
+ r'RF|RH|SECONDS|SEGMENT|SELF|SEND|SOURCES|STATEMENT|STEP|'
3585
+ r'STRONG|SUB-QUEUE-1|SUB-QUEUE-2|SUB-QUEUE-3|SUPER|SYMBOL|'
3586
+ r'SYSTEM-DEFAULT|TABLE|TERMINAL|TEXT|TYPEDEF|UCS-4|UNIVERSAL|'
3587
+ r'USER-DEFAULT|UTF-16|UTF-8|VAL-STATUS|VALID|VALIDATE|'
3588
+ r'VALIDATE-STATUS)\s*($|(?=[^0-9a-z_\-]))', Error),
3589
+
3590
+ # Data Types
3591
+ (r'(^|(?<=[^0-9a-z_\-]))'
3592
+ r'(PIC\s+.+?(?=(\s|\.\s))|PICTURE\s+.+?(?=(\s|\.\s))|'
3593
+ r'(COMPUTATIONAL)(-[1-5X])?|(COMP)(-[1-5X])?|'
3594
+ r'BINARY-C-LONG|'
3595
+ r'BINARY-CHAR|BINARY-DOUBLE|BINARY-LONG|BINARY-SHORT|'
3596
+ r'BINARY)\s*($|(?=[^0-9a-z_\-]))', Keyword.Type),
3597
+
3598
+ # Operators
3599
+ (r'(\*\*|\*|\+|-|/|<=|>=|<|>|==|/=|=)', Operator),
3600
+
3601
+ # (r'(::)', Keyword.Declaration),
3602
+
3603
+ (r'([(),;:&%.])', Punctuation),
3604
+
3605
+ # Intrinsics
3606
+ (r'(^|(?<=[^0-9a-z_\-]))(ABS|ACOS|ANNUITY|ASIN|ATAN|BYTE-LENGTH|'
3607
+ r'CHAR|COMBINED-DATETIME|CONCATENATE|COS|CURRENT-DATE|'
3608
+ r'DATE-OF-INTEGER|DATE-TO-YYYYMMDD|DAY-OF-INTEGER|DAY-TO-YYYYDDD|'
3609
+ r'EXCEPTION-(?:FILE|LOCATION|STATEMENT|STATUS)|EXP10|EXP|E|'
3610
+ r'FACTORIAL|FRACTION-PART|INTEGER-OF-(?:DATE|DAY|PART)|INTEGER|'
3611
+ r'LENGTH|LOCALE-(?:DATE|TIME(?:-FROM-SECONDS)?)|LOG10|LOG|'
3612
+ r'LOWER-CASE|MAX|MEAN|MEDIAN|MIDRANGE|MIN|MOD|NUMVAL(?:-C)?|'
3613
+ r'ORD(?:-MAX|-MIN)?|PI|PRESENT-VALUE|RANDOM|RANGE|REM|REVERSE|'
3614
+ r'SECONDS-FROM-FORMATTED-TIME|SECONDS-PAST-MIDNIGHT|SIGN|SIN|SQRT|'
3615
+ r'STANDARD-DEVIATION|STORED-CHAR-LENGTH|SUBSTITUTE(?:-CASE)?|'
3616
+ r'SUM|TAN|TEST-DATE-YYYYMMDD|TEST-DAY-YYYYDDD|TRIM|'
3617
+ r'UPPER-CASE|VARIANCE|WHEN-COMPILED|YEAR-TO-YYYY)\s*'
3618
+ r'($|(?=[^0-9a-z_\-]))', Name.Function),
3619
+
3620
+ # Booleans
3621
+ (r'(^|(?<=[^0-9a-z_\-]))(true|false)\s*($|(?=[^0-9a-z_\-]))', Name.Builtin),
3622
+ # Comparing Operators
3623
+ (r'(^|(?<=[^0-9a-z_\-]))(equal|equals|ne|lt|le|gt|ge|'
3624
+ r'greater|less|than|not|and|or)\s*($|(?=[^0-9a-z_\-]))', Operator.Word),
3625
+ ],
3626
+
3627
+ # \"[^\"\n]*\"|\'[^\'\n]*\'
3628
+ 'strings': [
3629
+ # apparently strings can be delimited by EOL if they are continued
3630
+ # in the next line
3631
+ (r'"[^"\n]*("|\n)', String.Double),
3632
+ (r"'[^'\n]*('|\n)", String.Single),
3633
+ ],
3634
+
3635
+ 'nums': [
3636
+ (r'\d+(\s*|\.$|$)', Number.Integer),
3637
+ (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
3638
+ (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float),
3639
+ ],
3640
+ }
3641
+
3642
+
3643
+ class CobolFreeformatLexer(CobolLexer):
3644
+ """
3645
+ Lexer for Free format OpenCOBOL code.
3646
+
3647
+ *New in Pygments 1.6.*
3648
+ """
3649
+ name = 'COBOLFree'
3650
+ aliases = ['cobolfree']
3651
+ filenames = ['*.cbl', '*.CBL']
3652
+ mimetypes = []
3653
+ flags = re.IGNORECASE | re.MULTILINE
3654
+
3655
+ tokens = {
3656
+ 'comment': [
3657
+ (r'(\*>.*\n|^\w*\*.*$)', Comment),
3658
+ ],
3659
+ }
3660
+
3661
+
3662
+ class LogosLexer(ObjectiveCppLexer):
3663
+ """
3664
+ For Logos + Objective-C source code with preprocessor directives.
3665
+
3666
+ *New in Pygments 1.6.*
3667
+ """
3668
+
3669
+ name = 'Logos'
3670
+ aliases = ['logos']
3671
+ filenames = ['*.x', '*.xi', '*.xm', '*.xmi']
3672
+ mimetypes = ['text/x-logos']
3673
+ priority = 0.25
3674
+
3675
+ tokens = {
3676
+ 'statements': [
3677
+ (r'(%orig|%log)\b', Keyword),
3678
+ (r'(%c)\b(\()(\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\))',
3679
+ bygroups(Keyword, Punctuation, Text, Name.Class, Text, Punctuation)),
3680
+ (r'(%init)\b(\()',
3681
+ bygroups(Keyword, Punctuation), 'logos_init_directive'),
3682
+ (r'(%init)(?=\s*;)', bygroups(Keyword)),
3683
+ (r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)',
3684
+ bygroups(Keyword, Text, Name.Class), '#pop'),
3685
+ (r'(%subclass)(\s+)', bygroups(Keyword, Text),
3686
+ ('#pop', 'logos_classname')),
3687
+ inherit,
3688
+ ],
3689
+ 'logos_init_directive' : [
3690
+ ('\s+', Text),
3691
+ (',', Punctuation, ('logos_init_directive', '#pop')),
3692
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(=)(\s*)([^);]*)',
3693
+ bygroups(Name.Class, Text, Punctuation, Text, Text)),
3694
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class),
3695
+ ('\)', Punctuation, '#pop'),
3696
+ ],
3697
+ 'logos_classname' : [
3698
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
3699
+ bygroups(Name.Class, Text, Name.Class), '#pop'),
3700
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
3701
+ ],
3702
+ 'root': [
3703
+ (r'(%subclass)(\s+)', bygroups(Keyword, Text),
3704
+ 'logos_classname'),
3705
+ (r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)',
3706
+ bygroups(Keyword, Text, Name.Class)),
3707
+ (r'(%config)(\s*\(\s*)(\w+)(\s*=\s*)(.*?)(\s*\)\s*)',
3708
+ bygroups(Keyword, Text, Name.Variable, Text, String, Text)),
3709
+ (r'(%ctor)(\s*)({)', bygroups(Keyword, Text, Punctuation),
3710
+ 'function'),
3711
+ (r'(%new)(\s*)(\()(\s*.*?\s*)(\))',
3712
+ bygroups(Keyword, Text, Keyword, String, Keyword)),
3713
+ (r'(\s*)(%end)(\s*)', bygroups(Text, Keyword, Text)),
3714
+ inherit,
3715
+ ],
3716
+ }
3717
+
3718
+ _logos_keywords = re.compile(r'%(?:hook|ctor|init|c\()')
3719
+
3720
+ def analyse_text(text):
3721
+ if LogosLexer._logos_keywords.search(text):
3722
+ return 1.0
3723
+ return 0