pygments.rb 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +3 -0
  4. data/lexers +0 -0
  5. data/lib/pygments/popen.rb +3 -2
  6. data/lib/pygments/version.rb +1 -1
  7. data/pygments.rb.gemspec +2 -1
  8. data/vendor/pygments-main/AUTHORS +20 -1
  9. data/vendor/pygments-main/CHANGES +55 -3
  10. data/vendor/pygments-main/LICENSE +1 -1
  11. data/vendor/pygments-main/MANIFEST.in +1 -1
  12. data/vendor/pygments-main/Makefile +5 -8
  13. data/vendor/pygments-main/REVISION +1 -1
  14. data/vendor/pygments-main/doc/Makefile +153 -0
  15. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  16. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  17. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  18. data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
  19. data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
  20. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
  21. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  22. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  23. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  24. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  25. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  26. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
  27. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
  28. data/vendor/pygments-main/doc/conf.py +249 -0
  29. data/vendor/pygments-main/doc/docs/api.rst +316 -0
  30. data/vendor/pygments-main/doc/docs/authors.rst +4 -0
  31. data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
  32. data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
  33. data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
  34. data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
  35. data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
  36. data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
  37. data/vendor/pygments-main/doc/docs/index.rst +66 -0
  38. data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
  39. data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
  40. data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
  41. data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
  42. data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
  43. data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
  44. data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
  45. data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
  46. data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
  47. data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
  48. data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
  49. data/vendor/pygments-main/doc/download.rst +41 -0
  50. data/vendor/pygments-main/doc/faq.rst +143 -0
  51. data/vendor/pygments-main/doc/index.rst +53 -0
  52. data/vendor/pygments-main/doc/languages.rst +151 -0
  53. data/vendor/pygments-main/doc/make.bat +190 -0
  54. data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
  55. data/vendor/pygments-main/external/autopygmentize +65 -48
  56. data/vendor/pygments-main/external/markdown-processor.py +15 -15
  57. data/vendor/pygments-main/external/moin-parser.py +1 -1
  58. data/vendor/pygments-main/external/rst-directive.py +2 -3
  59. data/vendor/pygments-main/ez_setup.py +340 -234
  60. data/vendor/pygments-main/pygments/__init__.py +4 -4
  61. data/vendor/pygments-main/pygments/cmdline.py +81 -68
  62. data/vendor/pygments-main/pygments/console.py +1 -1
  63. data/vendor/pygments-main/pygments/filter.py +1 -1
  64. data/vendor/pygments-main/pygments/filters/__init__.py +11 -9
  65. data/vendor/pygments-main/pygments/formatter.py +3 -3
  66. data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
  67. data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
  68. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  69. data/vendor/pygments-main/pygments/formatters/html.py +44 -26
  70. data/vendor/pygments-main/pygments/formatters/img.py +21 -14
  71. data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
  72. data/vendor/pygments-main/pygments/formatters/other.py +53 -6
  73. data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
  74. data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
  75. data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
  76. data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
  77. data/vendor/pygments-main/pygments/lexer.py +59 -39
  78. data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
  79. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
  81. data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
  82. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
  83. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
  84. data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
  85. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
  86. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
  87. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
  88. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
  89. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
  90. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
  91. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
  92. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
  93. data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
  94. data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
  95. data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
  96. data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
  97. data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
  98. data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
  99. data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
  100. data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
  101. data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
  102. data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
  103. data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
  104. data/vendor/pygments-main/pygments/lexers/math.py +438 -70
  105. data/vendor/pygments-main/pygments/lexers/other.py +885 -171
  106. data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
  107. data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
  108. data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
  109. data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
  110. data/vendor/pygments-main/pygments/lexers/special.py +7 -8
  111. data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
  112. data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
  113. data/vendor/pygments-main/pygments/lexers/text.py +208 -46
  114. data/vendor/pygments-main/pygments/lexers/web.py +729 -264
  115. data/vendor/pygments-main/pygments/modeline.py +1 -1
  116. data/vendor/pygments-main/pygments/plugin.py +1 -1
  117. data/vendor/pygments-main/pygments/scanner.py +1 -1
  118. data/vendor/pygments-main/pygments/sphinxext.py +153 -0
  119. data/vendor/pygments-main/pygments/style.py +3 -2
  120. data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
  121. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  122. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  123. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  124. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  125. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  126. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  127. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  128. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  129. data/vendor/pygments-main/pygments/styles/igor.py +29 -0
  130. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  131. data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
  132. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  133. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  134. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +125 -0
  135. data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
  136. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  137. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  138. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  139. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  140. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  141. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  142. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  143. data/vendor/pygments-main/pygments/styles/xcode.py +51 -0
  144. data/vendor/pygments-main/pygments/token.py +4 -1
  145. data/vendor/pygments-main/pygments/unistring.py +6 -5
  146. data/vendor/pygments-main/pygments/util.py +35 -21
  147. data/vendor/pygments-main/scripts/check_sources.py +28 -44
  148. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
  149. data/vendor/pygments-main/scripts/find_codetags.py +27 -19
  150. data/vendor/pygments-main/scripts/find_error.py +16 -13
  151. data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
  152. data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
  153. data/vendor/pygments-main/setup.py +19 -19
  154. data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
  155. data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
  156. data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
  157. data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
  158. data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
  159. data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
  160. data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
  161. data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
  162. data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
  163. data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
  164. data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
  165. data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
  166. data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
  167. data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
  168. data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
  169. data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
  170. data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
  171. data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
  172. data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
  173. data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
  174. data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
  175. data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
  176. data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
  177. data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
  178. data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
  179. data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
  180. data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
  181. data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
  182. data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
  183. data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
  184. data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
  185. data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
  186. data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
  187. data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
  188. data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
  189. data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
  190. data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
  191. data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
  192. data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
  193. data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
  194. data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
  195. data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
  196. data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
  197. data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
  198. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
  199. data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
  200. data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
  201. data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
  202. data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
  203. data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
  204. data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
  205. data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
  206. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
  207. data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
  208. data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
  209. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
  210. data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
  211. data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
  212. data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
  213. data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
  214. data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
  215. data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
  216. data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
  217. data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
  218. data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
  219. data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
  220. data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
  221. data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
  222. data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
  223. data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
  224. data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
  225. data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
  226. data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
  227. data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
  228. data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
  229. data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
  230. data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
  231. data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
  232. data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
  233. data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
  234. data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
  235. data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
  236. data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
  237. data/vendor/pygments-main/tests/run.py +14 -19
  238. data/vendor/pygments-main/tests/string_asserts.py +22 -0
  239. data/vendor/pygments-main/tests/test_basic_api.py +28 -14
  240. data/vendor/pygments-main/tests/test_cfm.py +46 -0
  241. data/vendor/pygments-main/tests/test_clexer.py +208 -3
  242. data/vendor/pygments-main/tests/test_cmdline.py +6 -5
  243. data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
  244. data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
  245. data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
  246. data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
  247. data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
  248. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  249. data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
  250. data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
  251. data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
  252. data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
  253. data/vendor/pygments-main/tests/test_token.py +3 -3
  254. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  255. data/vendor/pygments-main/tests/test_util.py +1 -1
  256. metadata +138 -51
  257. data/vendor/pygments-main/docs/generate.py +0 -472
  258. data/vendor/pygments-main/docs/src/api.txt +0 -270
  259. data/vendor/pygments-main/docs/src/authors.txt +0 -5
  260. data/vendor/pygments-main/docs/src/changelog.txt +0 -5
  261. data/vendor/pygments-main/docs/src/index.txt +0 -69
  262. data/vendor/pygments-main/docs/src/installation.txt +0 -71
  263. data/vendor/pygments-main/external/rst-directive-old.py +0 -77
  264. data/vendor/pygments-main/scripts/reindent.py +0 -291
  265. data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
  266. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
  267. data/vendor/pygments-main/tests/old_run.py +0 -138
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for assembly languages.
7
7
 
8
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -17,7 +17,7 @@ from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
17
17
  Other, Keyword, Operator
18
18
 
19
19
  __all__ = ['GasLexer', 'ObjdumpLexer','DObjdumpLexer', 'CppObjdumpLexer',
20
- 'CObjdumpLexer', 'LlvmLexer', 'NasmLexer', 'Ca65Lexer']
20
+ 'CObjdumpLexer', 'LlvmLexer', 'NasmLexer', 'NasmObjdumpLexer', 'Ca65Lexer']
21
21
 
22
22
 
23
23
  class GasLexer(RegexLexer):
@@ -96,18 +96,12 @@ class GasLexer(RegexLexer):
96
96
  return 0.1
97
97
 
98
98
 
99
- class ObjdumpLexer(RegexLexer):
99
+ def _objdump_lexer_tokens(asm_lexer):
100
100
  """
101
- For the output of 'objdump -dr'
101
+ Common objdump lexer tokens to wrap an ASM lexer.
102
102
  """
103
- name = 'objdump'
104
- aliases = ['objdump']
105
- filenames = ['*.objdump']
106
- mimetypes = ['text/x-objdump']
107
-
108
- hex = r'[0-9A-Za-z]'
109
-
110
- tokens = {
103
+ hex_re = r'[0-9A-Za-z]'
104
+ return {
111
105
  'root': [
112
106
  # File name & format:
113
107
  ('(.*?)(:)( +file format )(.*?)$',
@@ -117,33 +111,33 @@ class ObjdumpLexer(RegexLexer):
117
111
  bygroups(Text, Name.Label, Punctuation)),
118
112
  # Function labels
119
113
  # (With offset)
120
- ('('+hex+'+)( )(<)(.*?)([-+])(0[xX][A-Za-z0-9]+)(>:)$',
114
+ ('('+hex_re+'+)( )(<)(.*?)([-+])(0[xX][A-Za-z0-9]+)(>:)$',
121
115
  bygroups(Number.Hex, Text, Punctuation, Name.Function,
122
116
  Punctuation, Number.Hex, Punctuation)),
123
117
  # (Without offset)
124
- ('('+hex+'+)( )(<)(.*?)(>:)$',
118
+ ('('+hex_re+'+)( )(<)(.*?)(>:)$',
125
119
  bygroups(Number.Hex, Text, Punctuation, Name.Function,
126
120
  Punctuation)),
127
121
  # Code line with disassembled instructions
128
- ('( *)('+hex+r'+:)(\t)((?:'+hex+hex+' )+)( *\t)([a-zA-Z].*?)$',
122
+ ('( *)('+hex_re+r'+:)(\t)((?:'+hex_re+hex_re+' )+)( *\t)([a-zA-Z].*?)$',
129
123
  bygroups(Text, Name.Label, Text, Number.Hex, Text,
130
- using(GasLexer))),
124
+ using(asm_lexer))),
131
125
  # Code line with ascii
132
- ('( *)('+hex+r'+:)(\t)((?:'+hex+hex+' )+)( *)(.*?)$',
126
+ ('( *)('+hex_re+r'+:)(\t)((?:'+hex_re+hex_re+' )+)( *)(.*?)$',
133
127
  bygroups(Text, Name.Label, Text, Number.Hex, Text, String)),
134
128
  # Continued code line, only raw opcodes without disassembled
135
129
  # instruction
136
- ('( *)('+hex+r'+:)(\t)((?:'+hex+hex+' )+)$',
130
+ ('( *)('+hex_re+r'+:)(\t)((?:'+hex_re+hex_re+' )+)$',
137
131
  bygroups(Text, Name.Label, Text, Number.Hex)),
138
132
  # Skipped a few bytes
139
133
  (r'\t\.\.\.$', Text),
140
134
  # Relocation line
141
135
  # (With offset)
142
- (r'(\t\t\t)('+hex+r'+:)( )([^\t]+)(\t)(.*?)([-+])(0x' + hex + '+)$',
136
+ (r'(\t\t\t)('+hex_re+r'+:)( )([^\t]+)(\t)(.*?)([-+])(0x'+hex_re+'+)$',
143
137
  bygroups(Text, Name.Label, Text, Name.Property, Text,
144
138
  Name.Constant, Punctuation, Number.Hex)),
145
139
  # (Without offset)
146
- (r'(\t\t\t)('+hex+r'+:)( )([^\t]+)(\t)(.*?)$',
140
+ (r'(\t\t\t)('+hex_re+r'+:)( )([^\t]+)(\t)(.*?)$',
147
141
  bygroups(Text, Name.Label, Text, Name.Property, Text,
148
142
  Name.Constant)),
149
143
  (r'[^\n]+\n', Other)
@@ -151,6 +145,20 @@ class ObjdumpLexer(RegexLexer):
151
145
  }
152
146
 
153
147
 
148
+ class ObjdumpLexer(RegexLexer):
149
+ """
150
+ For the output of 'objdump -dr'
151
+ """
152
+ name = 'objdump'
153
+ aliases = ['objdump']
154
+ filenames = ['*.objdump']
155
+ mimetypes = ['text/x-objdump']
156
+
157
+
158
+ tokens = _objdump_lexer_tokens(GasLexer)
159
+
160
+
161
+
154
162
  class DObjdumpLexer(DelegatingLexer):
155
163
  """
156
164
  For the output of 'objdump -Sr on compiled D files'
@@ -216,6 +224,7 @@ class LlvmLexer(RegexLexer):
216
224
  (r'@' + identifier, Name.Variable.Global),#Name.Identifier.Global),
217
225
  (r'%\d+', Name.Variable.Anonymous),#Name.Identifier.Anonymous),
218
226
  (r'@\d+', Name.Variable.Global),#Name.Identifier.Anonymous),
227
+ (r'#\d+', Name.Variable.Global),#Name.Identifier.Global),
219
228
  (r'!' + identifier, Name.Variable),
220
229
  (r'!\d+', Name.Variable.Anonymous),
221
230
  (r'c?' + string, String),
@@ -242,17 +251,24 @@ class LlvmLexer(RegexLexer):
242
251
  r'|thread_local|zeroinitializer|undef|null|to|tail|target|triple'
243
252
  r'|datalayout|volatile|nuw|nsw|nnan|ninf|nsz|arcp|fast|exact|inbounds'
244
253
  r'|align|addrspace|section|alias|module|asm|sideeffect|gc|dbg'
254
+ r'|linker_private_weak'
255
+ r'|attributes|blockaddress|initialexec|localdynamic|localexec'
256
+ r'|prefix|unnamed_addr'
245
257
 
246
258
  r'|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc'
247
259
  r'|arm_aapcscc|arm_aapcs_vfpcc|ptx_device|ptx_kernel'
260
+ r'|intel_ocl_bicc|msp430_intrcc|spir_func|spir_kernel'
261
+ r'|x86_64_sysvcc|x86_64_win64cc|x86_thiscallcc'
248
262
 
249
263
  r'|cc|c'
250
264
 
251
265
  r'|signext|zeroext|inreg|sret|nounwind|noreturn|noalias|nocapture'
252
266
  r'|byval|nest|readnone|readonly'
253
-
254
267
  r'|inlinehint|noinline|alwaysinline|optsize|ssp|sspreq|noredzone'
255
268
  r'|noimplicitfloat|naked'
269
+ r'|builtin|cold|nobuiltin|noduplicate|nonlazybind|optnone'
270
+ r'|returns_twice|sanitize_address|sanitize_memory|sanitize_thread'
271
+ r'|sspstrong|uwtable|returned'
256
272
 
257
273
  r'|type|opaque'
258
274
 
@@ -261,24 +277,30 @@ class LlvmLexer(RegexLexer):
261
277
  r'|oeq|one|olt|ogt|ole'
262
278
  r'|oge|ord|uno|ueq|une'
263
279
  r'|x'
280
+ r'|acq_rel|acquire|alignstack|atomic|catch|cleanup|filter'
281
+ r'|inteldialect|max|min|monotonic|nand|personality|release'
282
+ r'|seq_cst|singlethread|umax|umin|unordered|xchg'
264
283
 
265
284
  # instructions
266
285
  r'|add|fadd|sub|fsub|mul|fmul|udiv|sdiv|fdiv|urem|srem|frem|shl'
267
286
  r'|lshr|ashr|and|or|xor|icmp|fcmp'
268
287
 
269
288
  r'|phi|call|trunc|zext|sext|fptrunc|fpext|uitofp|sitofp|fptoui'
270
- r'fptosi|inttoptr|ptrtoint|bitcast|select|va_arg|ret|br|switch'
289
+ r'|fptosi|inttoptr|ptrtoint|bitcast|select|va_arg|ret|br|switch'
271
290
  r'|invoke|unwind|unreachable'
291
+ r'|indirectbr|landingpad|resume'
272
292
 
273
293
  r'|malloc|alloca|free|load|store|getelementptr'
274
294
 
275
295
  r'|extractelement|insertelement|shufflevector|getresult'
276
296
  r'|extractvalue|insertvalue'
277
297
 
298
+ r'|atomicrmw|cmpxchg|fence'
299
+
278
300
  r')\b', Keyword),
279
301
 
280
302
  # Types
281
- (r'void|float|double|x86_fp80|fp128|ppc_fp128|label|metadata',
303
+ (r'void|half|float|double|x86_fp80|fp128|ppc_fp128|label|metadata',
282
304
  Keyword.Type),
283
305
 
284
306
  # Integer types
@@ -296,8 +318,8 @@ class NasmLexer(RegexLexer):
296
318
  filenames = ['*.asm', '*.ASM']
297
319
  mimetypes = ['text/x-nasm']
298
320
 
299
- identifier = r'[a-zA-Z$._?][a-zA-Z0-9$._?#@~]*'
300
- hexn = r'(?:0[xX][0-9a-fA-F]+|$0[0-9a-fA-F]*|[0-9]+[0-9a-fA-F]*h)'
321
+ identifier = r'[a-z$._?][\w$.?#@~]*'
322
+ hexn = r'(?:0[xX][0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)'
301
323
  octn = r'[0-7]+q'
302
324
  binn = r'[01]+b'
303
325
  decn = r'[0-9]+'
@@ -331,7 +353,7 @@ class NasmLexer(RegexLexer):
331
353
  (string, String),
332
354
  (hexn, Number.Hex),
333
355
  (octn, Number.Oct),
334
- (binn, Number),
356
+ (binn, Number.Bin),
335
357
  (floatn, Number.Float),
336
358
  (decn, Number.Integer),
337
359
  include('punctuation'),
@@ -360,11 +382,25 @@ class NasmLexer(RegexLexer):
360
382
  }
361
383
 
362
384
 
385
+ class NasmObjdumpLexer(ObjdumpLexer):
386
+ """
387
+ For the output of 'objdump -d -M intel'.
388
+
389
+ .. versionadded:: 2.0
390
+ """
391
+ name = 'objdump-nasm'
392
+ aliases = ['objdump-nasm']
393
+ filenames = ['*.objdump-intel']
394
+ mimetypes = ['text/x-nasm-objdump']
395
+
396
+ tokens = _objdump_lexer_tokens(NasmLexer)
397
+
398
+
363
399
  class Ca65Lexer(RegexLexer):
364
400
  """
365
401
  For ca65 assembler sources.
366
402
 
367
- *New in Pygments 1.6.*
403
+ .. versionadded:: 1.6
368
404
  """
369
405
  name = 'ca65'
370
406
  aliases = ['ca65']
@@ -381,12 +417,13 @@ class Ca65Lexer(RegexLexer):
381
417
  r'|cl[cvdi]|se[cdi]|jmp|jsr|bne|beq|bpl|bmi|bvc|bvs|bcc|bcs'
382
418
  r'|p[lh][ap]|rt[is]|brk|nop|ta[xy]|t[xy]a|txs|tsx|and|ora|eor'
383
419
  r'|bit)\b', Keyword),
384
- (r'\.[a-z0-9_]+', Keyword.Pseudo),
420
+ (r'\.\w+', Keyword.Pseudo),
385
421
  (r'[-+~*/^&|!<>=]', Operator),
386
422
  (r'"[^"\n]*.', String),
387
423
  (r"'[^'\n]*.", String.Char),
388
424
  (r'\$[0-9a-f]+|[0-9a-f]+h\b', Number.Hex),
389
- (r'\d+|%[01]+', Number.Integer),
425
+ (r'\d+', Number.Integer),
426
+ (r'%[01]+', Number.Bin),
390
427
  (r'[#,.:()=]', Punctuation),
391
428
  (r'[a-z_.@$][\w.@$]*', Name),
392
429
  ]
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for compiled languages.
7
7
 
8
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -13,7 +13,7 @@ import re
13
13
  from string import Template
14
14
 
15
15
  from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
16
- this, combined, inherit, do_insertions
16
+ this, combined, inherit, do_insertions, default
17
17
  from pygments.util import get_bool_opt, get_list_opt
18
18
  from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
19
19
  Number, Punctuation, Error, Literal, Generic
@@ -30,7 +30,9 @@ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer',
30
30
  'Modula2Lexer', 'BlitzMaxLexer', 'BlitzBasicLexer', 'NimrodLexer',
31
31
  'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', 'SwigLexer',
32
32
  'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer',
33
- 'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer']
33
+ 'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer', 'PikeLexer',
34
+ 'ChapelLexer', 'EiffelLexer', 'Inform6Lexer', 'Inform7Lexer',
35
+ 'Inform6TemplateLexer', 'MqlLexer', 'SwiftLexer']
34
36
 
35
37
 
36
38
  class CFamilyLexer(RegexLexer):
@@ -42,7 +44,7 @@ class CFamilyLexer(RegexLexer):
42
44
  #: optional Comment or Whitespace
43
45
  _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
44
46
  #: only one /* */ style comment
45
- _ws1 = r':\s*/[*].*?[*]/\s*'
47
+ _ws1 = r'\s*(?:/[*].*?[*]/\s*)*'
46
48
 
47
49
  tokens = {
48
50
  'whitespace': [
@@ -54,8 +56,6 @@ class CFamilyLexer(RegexLexer):
54
56
  bygroups(using(this), Comment.Preproc), 'if0'),
55
57
  ('^(' + _ws1 + ')(#)',
56
58
  bygroups(using(this), Comment.Preproc), 'macro'),
57
- (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))',
58
- bygroups(Text, Name.Label)),
59
59
  (r'\n', Text),
60
60
  (r'\s+', Text),
61
61
  (r'\\\n', Text), # line continuation
@@ -73,7 +73,6 @@ class CFamilyLexer(RegexLexer):
73
73
  (r'\*/', Error),
74
74
  (r'[~!%^&*+=|?:<>/-]', Operator),
75
75
  (r'[()\[\],.]', Punctuation),
76
- (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
77
76
  (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
78
77
  r'for|goto|if|register|restricted|return|sizeof|static|struct|'
79
78
  r'switch|typedef|union|volatile|while)\b', Keyword),
@@ -88,26 +87,27 @@ class CFamilyLexer(RegexLexer):
88
87
  r'declspec|finally|int64|try|leave|wchar_t|w64|unaligned|'
89
88
  r'raise|noop|identifier|forceinline|assume)\b', Keyword.Reserved),
90
89
  (r'(true|false|NULL)\b', Name.Builtin),
91
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
90
+ (r'([a-zA-Z_]\w*)(\s*)(:)(?!:)', bygroups(Name.Label, Text, Punctuation)),
91
+ ('[a-zA-Z_]\w*', Name),
92
92
  ],
93
93
  'root': [
94
94
  include('whitespace'),
95
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
96
+ (r'((?:[\w*\s])+?(?:\s|[*]))' # return arguments
97
+ r'([a-zA-Z_]\w*)' # method name
98
+ r'(\s*\([^;]*?\))' # signature
99
99
  r'(' + _ws + r')?({)',
100
100
  bygroups(using(this), Name.Function, using(this), using(this),
101
101
  Punctuation),
102
102
  'function'),
103
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
104
+ (r'((?:[\w*\s])+?(?:\s|[*]))' # return arguments
105
+ r'([a-zA-Z_]\w*)' # method name
106
+ r'(\s*\([^;]*?\))' # signature
107
107
  r'(' + _ws + r')?(;)',
108
108
  bygroups(using(this), Name.Function, using(this), using(this),
109
109
  Punctuation)),
110
- ('', Text, 'statement'),
110
+ default('statement'),
111
111
  ],
112
112
  'statement' : [
113
113
  include('whitespace'),
@@ -188,7 +188,8 @@ class CLexer(CFamilyLexer):
188
188
  priority = 0.1
189
189
 
190
190
  def analyse_text(text):
191
- return 0.1
191
+ if re.search('#include [<"]', text):
192
+ return 0.1
192
193
 
193
194
 
194
195
  class CppLexer(CFamilyLexer):
@@ -209,7 +210,10 @@ class CppLexer(CFamilyLexer):
209
210
  r'export|friend|mutable|namespace|new|operator|'
210
211
  r'private|protected|public|reinterpret_cast|'
211
212
  r'restrict|static_cast|template|this|throw|throws|'
212
- r'typeid|typename|using|virtual)\b', Keyword),
213
+ r'typeid|typename|using|virtual|'
214
+ r'constexpr|nullptr|decltype|thread_local|'
215
+ r'alignas|alignof|static_assert|noexcept|override|final)\b', Keyword),
216
+ (r'(char16_t|char32_t)\b', Keyword.Type),
213
217
  (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
214
218
  inherit,
215
219
  ],
@@ -222,33 +226,78 @@ class CppLexer(CFamilyLexer):
222
226
  (r'(__offload|__blockingoffload|__outer)\b', Keyword.Pseudo),
223
227
  ],
224
228
  'classname': [
225
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
229
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
226
230
  # template specification
227
231
  (r'\s*(?=>)', Text, '#pop'),
228
232
  ],
229
233
  }
230
234
 
231
235
  def analyse_text(text):
232
- return 0.1
236
+ if re.search('#include <[a-z]+>', text):
237
+ return 0.2
238
+ if re.search('using namespace ', text):
239
+ return 0.4
240
+
241
+
242
+ class PikeLexer(CppLexer):
243
+ """
244
+ For `Pike <http://pike.lysator.liu.se/>`_ source code.
245
+
246
+ .. versionadded:: 2.0
247
+ """
248
+ name = 'Pike'
249
+ aliases = ['pike']
250
+ filenames = ['*.pike', '*.pmod']
251
+ mimetypes = ['text/x-pike']
252
+
253
+ tokens = {
254
+ 'statements': [
255
+ (r'(catch|new|private|protected|public|gauge|'
256
+ r'throw|throws|class|interface|implement|abstract|extends|from|'
257
+ r'this|super|new|constant|final|static|import|use|extern|'
258
+ r'inline|proto|break|continue|if|else|for|'
259
+ r'while|do|switch|case|as|in|version|return|true|false|null|'
260
+ r'__VERSION__|__MAJOR__|__MINOR__|__BUILD__|__REAL_VERSION__|'
261
+ r'__REAL_MAJOR__|__REAL_MINOR__|__REAL_BUILD__|__DATE__|__TIME__|'
262
+ r'__FILE__|__DIR__|__LINE__|__AUTO_BIGNUM__|__NT__|__PIKE__|'
263
+ r'__amigaos__|_Pragma|static_assert|defined|sscanf)\b',
264
+ Keyword),
265
+ (r'(bool|int|long|float|short|double|char|string|object|void|mapping|'
266
+ r'array|multiset|program|function|lambda|mixed|'
267
+ r'[a-z_][a-z0-9_]*_t)\b',
268
+ Keyword.Type),
269
+ (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
270
+ (r'[~!%^&*+=|?:<>/-@]', Operator),
271
+ inherit,
272
+ ],
273
+ 'classname': [
274
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
275
+ # template specification
276
+ (r'\s*(?=>)', Text, '#pop'),
277
+ ],
278
+ }
233
279
 
234
280
 
235
281
  class SwigLexer(CppLexer):
236
282
  """
237
283
  For `SWIG <http://www.swig.org/>`_ source code.
238
284
 
239
- *New in Pygments 1.7.*
285
+ .. versionadded:: 2.0
240
286
  """
241
287
  name = 'SWIG'
242
- aliases = ['Swig', 'swig']
288
+ aliases = ['swig']
243
289
  filenames = ['*.swg', '*.i']
244
290
  mimetypes = ['text/swig']
245
291
  priority = 0.04 # Lower than C/C++ and Objective C/C++
246
292
 
247
293
  tokens = {
248
294
  '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
295
+ # SWIG directives
296
+ (r'(%[a-z_][a-z0-9_]*)', Name.Function),
297
+ # Special variables
298
+ ('\$\**\&?\w+', Name),
299
+ # Stringification / additional preprocessor directives
300
+ (r'##*[a-zA-Z_]\w*', Comment.Preproc),
252
301
  inherit,
253
302
  ],
254
303
  }
@@ -275,7 +324,7 @@ class SwigLexer(CppLexer):
275
324
  '%trackobjects', '%types', '%unrefobject', '%varargs', '%warn', '%warnfilter')
276
325
 
277
326
  def analyse_text(text):
278
- rv = 0.1 # Same as C/C++
327
+ rv = 0
279
328
  # Search for SWIG directives, which are conventionally at the beginning of
280
329
  # a line. The probability of them being within a line is low, so let another
281
330
  # lexer win in this case.
@@ -293,7 +342,7 @@ class ECLexer(CLexer):
293
342
  """
294
343
  For eC source code with preprocessor directives.
295
344
 
296
- *New in Pygments 1.5.*
345
+ .. versionadded:: 1.5
297
346
  """
298
347
  name = 'eC'
299
348
  aliases = ['ec']
@@ -317,7 +366,7 @@ class ECLexer(CLexer):
317
366
  inherit,
318
367
  ],
319
368
  'classname': [
320
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
369
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
321
370
  # template specification
322
371
  (r'\s*(?=>)', Text, '#pop'),
323
372
  ],
@@ -329,7 +378,7 @@ class NesCLexer(CLexer):
329
378
  For `nesC <https://github.com/tinyos/nesc>`_ source code with preprocessor
330
379
  directives.
331
380
 
332
- *New in Pygments 1.7.*
381
+ .. versionadded:: 2.0
333
382
  """
334
383
  name = 'nesC'
335
384
  aliases = ['nesc']
@@ -354,7 +403,7 @@ class ClayLexer(RegexLexer):
354
403
  """
355
404
  For `Clay <http://claylabs.com/clay/>`_ source.
356
405
 
357
- *New in Pygments 1.7.*
406
+ .. versionadded:: 2.0
358
407
  """
359
408
  name = 'Clay'
360
409
  filenames = ['*.clay']
@@ -405,7 +454,7 @@ class DLexer(RegexLexer):
405
454
  """
406
455
  For D source.
407
456
 
408
- *New in Pygments 1.2.*
457
+ .. versionadded:: 1.2
409
458
  """
410
459
  name = 'D'
411
460
  filenames = ['*.d', '*.di']
@@ -425,20 +474,23 @@ class DLexer(RegexLexer):
425
474
  (r'(abstract|alias|align|asm|assert|auto|body|break|case|cast'
426
475
  r'|catch|class|const|continue|debug|default|delegate|delete'
427
476
  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'
477
+ r'|foreach_reverse|foreach|for|function|goto|if|immutable|import'
478
+ r'|interface|invariant|inout|in|is|lazy|mixin|module|new|nothrow|out'
430
479
  r'|override|package|pragma|private|protected|public|pure|ref|return'
431
- r'|scope|static|struct|super|switch|synchronized|template|this'
480
+ r'|scope|shared|static|struct|super|switch|synchronized|template|this'
432
481
  r'|throw|try|typedef|typeid|typeof|union|unittest|version|volatile'
433
- r'|while|with|__traits)\b', Keyword
482
+ r'|while|with|__gshared|__traits|__vector|__parameters)\b', Keyword
434
483
  ),
435
484
  (r'(bool|byte|cdouble|cent|cfloat|char|creal|dchar|double|float'
436
485
  r'|idouble|ifloat|int|ireal|long|real|short|ubyte|ucent|uint|ulong'
437
486
  r'|ushort|void|wchar)\b', Keyword.Type
438
487
  ),
439
488
  (r'(false|true|null)\b', Keyword.Constant),
489
+ (r'(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__'
490
+ r'|__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\b',
491
+ Keyword.Pseudo),
440
492
  (r'macro\b', Keyword.Reserved),
441
- (r'(string|wstring|dstring)\b', Name.Builtin),
493
+ (r'(string|wstring|dstring|size_t|ptrdiff_t)\b', Name.Builtin),
442
494
  # FloatLiteral
443
495
  # -- HexFloat
444
496
  (r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)'
@@ -449,7 +501,7 @@ class DLexer(RegexLexer):
449
501
  (r'\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?', Number.Float),
450
502
  # IntegerLiteral
451
503
  # -- Binary
452
- (r'0[Bb][01_]+', Number),
504
+ (r'0[Bb][01_]+', Number.Bin),
453
505
  # -- Octal
454
506
  (r'0[0-7_]+', Number.Oct),
455
507
  # -- Hexadecimal
@@ -484,6 +536,8 @@ class DLexer(RegexLexer):
484
536
  (r'q"(.).*?\1"', String),
485
537
  # -- TokenString
486
538
  (r'q{', String, 'token_string'),
539
+ # Attributes
540
+ (r'@([a-zA-Z_]\w*)?', Name.Decorator),
487
541
  # Tokens
488
542
  (r'(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>='
489
543
  r'|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)'
@@ -491,6 +545,8 @@ class DLexer(RegexLexer):
491
545
  ),
492
546
  # Identifier
493
547
  (r'[a-zA-Z_]\w*', Name),
548
+ # Line
549
+ (r'#line\s.*\n', Comment.Special),
494
550
  ],
495
551
  'nested_comment': [
496
552
  (r'[^+/]+', Comment.Multiline),
@@ -835,7 +891,7 @@ class DelphiLexer(Lexer):
835
891
  if get_bool_opt(options, 'freepascal', True):
836
892
  self.keywords.update(self.FREE_PASCAL_KEYWORDS)
837
893
  self.builtins = set()
838
- for unit in get_list_opt(options, 'units', self.BUILTIN_UNITS.keys()):
894
+ for unit in get_list_opt(options, 'units', list(self.BUILTIN_UNITS)):
839
895
  self.builtins.update(self.BUILTIN_UNITS[unit])
840
896
 
841
897
  def get_tokens_unprocessed(self, text):
@@ -1039,7 +1095,7 @@ class DylanLexer(RegexLexer):
1039
1095
  """
1040
1096
  For the `Dylan <http://www.opendylan.org/>`_ language.
1041
1097
 
1042
- *New in Pygments 0.7.*
1098
+ .. versionadded:: 0.7
1043
1099
  """
1044
1100
 
1045
1101
  name = 'Dylan'
@@ -1105,7 +1161,7 @@ class DylanLexer(RegexLexer):
1105
1161
  'type-error-value', 'type-for-copy', 'type-union', 'union', 'values',
1106
1162
  'vector', 'zero?'])
1107
1163
 
1108
- valid_name = '\\\\?[a-zA-Z0-9' + re.escape('!&*<>|^$%@_-+~?/=') + ']+'
1164
+ valid_name = '\\\\?[a-z0-9' + re.escape('!&*<>|^$%@_-+~?/=') + ']+'
1109
1165
 
1110
1166
  def get_tokens_unprocessed(self, text):
1111
1167
  for index, token, value in RegexLexer.get_tokens_unprocessed(self, text):
@@ -1134,7 +1190,7 @@ class DylanLexer(RegexLexer):
1134
1190
  (r'//.*?\n', Comment.Single),
1135
1191
 
1136
1192
  # lid header
1137
- (r'([A-Za-z0-9-]+)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
1193
+ (r'([a-z0-9-]+)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
1138
1194
  bygroups(Name.Attribute, Operator, Text, String)),
1139
1195
 
1140
1196
  ('', Text, 'code') # no header match, switch to code
@@ -1151,10 +1207,10 @@ class DylanLexer(RegexLexer):
1151
1207
 
1152
1208
  # strings and characters
1153
1209
  (r'"', String, 'string'),
1154
- (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
1210
+ (r"'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\\'\n])'", String.Char),
1155
1211
 
1156
1212
  # binary integer
1157
- (r'#[bB][01]+', Number),
1213
+ (r'#[bB][01]+', Number.Bin),
1158
1214
 
1159
1215
  # octal integer
1160
1216
  (r'#[oO][0-7]+', Number.Oct),
@@ -1166,7 +1222,7 @@ class DylanLexer(RegexLexer):
1166
1222
  (r'[-+]?\d+', Number.Integer),
1167
1223
 
1168
1224
  # hex integer
1169
- (r'#[xX][0-9a-fA-F]+', Number.Hex),
1225
+ (r'#[xX][0-9a-f]+', Number.Hex),
1170
1226
 
1171
1227
  # Macro parameters
1172
1228
  (r'(\?' + valid_name + ')(:)'
@@ -1190,7 +1246,7 @@ class DylanLexer(RegexLexer):
1190
1246
  (r'#"', String.Symbol, 'keyword'),
1191
1247
 
1192
1248
  # #rest, #key, #all-keys, etc.
1193
- (r'#[a-zA-Z0-9-]+', Keyword),
1249
+ (r'#[a-z0-9-]+', Keyword),
1194
1250
 
1195
1251
  # required-init-keyword: style keywords.
1196
1252
  (valid_name + ':', Keyword),
@@ -1219,7 +1275,7 @@ class DylanLexer(RegexLexer):
1219
1275
  ],
1220
1276
  'string': [
1221
1277
  (r'"', String, '#pop'),
1222
- (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
1278
+ (r'\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})', String.Escape),
1223
1279
  (r'[^\\"\n]+', String), # all other characters
1224
1280
  (r'\\\n', String), # line continuation
1225
1281
  (r'\\', String), # stray backslash
@@ -1231,7 +1287,7 @@ class DylanLidLexer(RegexLexer):
1231
1287
  """
1232
1288
  For Dylan LID (Library Interchange Definition) files.
1233
1289
 
1234
- *New in Pygments 1.6.*
1290
+ .. versionadded:: 1.6
1235
1291
  """
1236
1292
 
1237
1293
  name = 'DylanLID'
@@ -1269,7 +1325,7 @@ class DylanConsoleLexer(Lexer):
1269
1325
 
1270
1326
  This is based on a copy of the RubyConsoleLexer.
1271
1327
 
1272
- *New in Pygments 1.6.*
1328
+ .. versionadded:: 1.6
1273
1329
  """
1274
1330
  name = 'Dylan session'
1275
1331
  aliases = ['dylan-console', 'dylan-repl']
@@ -1321,9 +1377,9 @@ def objective(baselexer):
1321
1377
 
1322
1378
  # Matches [ <ws>? identifier <ws> ( identifier <ws>? ] | identifier? : )
1323
1379
  # (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_]*)?:)')
1380
+ _oc_message = re.compile(r'\[\s*[a-zA-Z_]\w*\s+'
1381
+ r'(?:[a-zA-Z_]\w*\s*\]|'
1382
+ r'(?:[a-zA-Z_]\w*)?:)')
1327
1383
 
1328
1384
  class GeneratedObjectiveCVariant(baselexer):
1329
1385
  """
@@ -1333,20 +1389,30 @@ def objective(baselexer):
1333
1389
  tokens = {
1334
1390
  'statements': [
1335
1391
  (r'@"', String, 'string'),
1336
- (r"@'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
1337
- String.Char),
1392
+ (r'@(YES|NO)', Number),
1393
+ (r"@'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
1338
1394
  (r'@(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
1339
1395
  (r'@(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
1340
1396
  (r'@0x[0-9a-fA-F]+[Ll]?', Number.Hex),
1341
1397
  (r'@0[0-7]+[Ll]?', Number.Oct),
1342
1398
  (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',
1399
+ (r'@\(', Literal, 'literal_number'),
1400
+ (r'@\[', Literal, 'literal_array'),
1401
+ (r'@\{', Literal, 'literal_dictionary'),
1402
+ (r'(@selector|@private|@protected|@public|@encode|'
1403
+ r'@synchronized|@try|@throw|@catch|@finally|@end|@property|@synthesize|'
1404
+ r'__bridge|__bridge_transfer|__autoreleasing|__block|__weak|__strong|'
1405
+ r'weak|strong|copy|retain|assign|unsafe_unretained|atomic|nonatomic|'
1406
+ r'readonly|readwrite|setter|getter|typeof|in|out|inout|release|class|'
1407
+ r'@dynamic|@optional|@required|@autoreleasepool)\b', Keyword),
1408
+ (r'(id|instancetype|Class|IMP|SEL|BOOL|IBOutlet|IBAction|unichar)\b',
1347
1409
  Keyword.Type),
1348
1410
  (r'@(true|false|YES|NO)\n', Name.Builtin),
1349
- (r'(YES|NO|nil)\b', Name.Builtin),
1411
+ (r'(YES|NO|nil|self|super)\b', Name.Builtin),
1412
+ # Carbon types
1413
+ (r'(Boolean|UInt8|SInt8|UInt16|SInt16|UInt32|SInt32)\b', Keyword.Type),
1414
+ # Carbon built-ins
1415
+ (r'(TRUE|FALSE)\b', Name.Builtin),
1350
1416
  (r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
1351
1417
  ('#pop', 'oc_classname')),
1352
1418
  (r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
@@ -1357,26 +1423,41 @@ def objective(baselexer):
1357
1423
  ],
1358
1424
  'oc_classname' : [
1359
1425
  # interface definition that inherits
1360
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
1426
+ ('([a-zA-Z$_][\w$]*)(\s*:\s*)([a-zA-Z$_][\w$]*)?(\s*)({)',
1427
+ bygroups(Name.Class, Text, Name.Class, Text, Punctuation),
1428
+ ('#pop', 'oc_ivars')),
1429
+ ('([a-zA-Z$_][\w$]*)(\s*:\s*)([a-zA-Z$_][\w$]*)?',
1361
1430
  bygroups(Name.Class, Text, Name.Class), '#pop'),
1362
1431
  # interface definition for a category
1363
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\([a-zA-Z$_][a-zA-Z0-9$_]*\))',
1432
+ ('([a-zA-Z$_][\w$]*)(\s*)(\([a-zA-Z$_][\w$]*\))(\s*)({)',
1433
+ bygroups(Name.Class, Text, Name.Label, Text, Punctuation),
1434
+ ('#pop', 'oc_ivars')),
1435
+ ('([a-zA-Z$_][\w$]*)(\s*)(\([a-zA-Z$_][\w$]*\))',
1364
1436
  bygroups(Name.Class, Text, Name.Label), '#pop'),
1365
1437
  # simple interface / implementation
1366
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
1438
+ ('([a-zA-Z$_][\w$]*)(\s*)({)',
1439
+ bygroups(Name.Class, Text, Punctuation), ('#pop', 'oc_ivars')),
1440
+ ('([a-zA-Z$_][\w$]*)', Name.Class, '#pop')
1367
1441
  ],
1368
1442
  'oc_forward_classname' : [
1369
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*,\s*)',
1443
+ ('([a-zA-Z$_][\w$]*)(\s*,\s*)',
1370
1444
  bygroups(Name.Class, Text), 'oc_forward_classname'),
1371
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*;?)',
1445
+ ('([a-zA-Z$_][\w$]*)(\s*;?)',
1372
1446
  bygroups(Name.Class, Text), '#pop')
1373
1447
  ],
1448
+ 'oc_ivars' : [
1449
+ include('whitespace'),
1450
+ include('statements'),
1451
+ (';', Punctuation),
1452
+ ('{', Punctuation, '#push'),
1453
+ ('}', Punctuation, '#pop'),
1454
+ ],
1374
1455
  'root': [
1375
1456
  # methods
1376
1457
  (r'^([-+])(\s*)' # method marker
1377
1458
  r'(\(.*?\))?(\s*)' # return type
1378
- r'([a-zA-Z$_][a-zA-Z0-9$_]*:?)', # begin of method name
1379
- bygroups(Keyword, Text, using(this),
1459
+ r'([a-zA-Z$_][\w$]*:?)', # begin of method name
1460
+ bygroups(Punctuation, Text, using(this),
1380
1461
  Text, Name.Function),
1381
1462
  'method'),
1382
1463
  inherit,
@@ -1387,13 +1468,37 @@ def objective(baselexer):
1387
1468
  # discussion in Issue 789
1388
1469
  (r',', Punctuation),
1389
1470
  (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),
1471
+ (r'(\(.*?\))(\s*)([a-zA-Z$_][\w$]*)',
1472
+ bygroups(using(this), Text, Name.Variable)),
1473
+ (r'[a-zA-Z$_][\w$]*:', Name.Function),
1393
1474
  (';', Punctuation, '#pop'),
1394
1475
  ('{', Punctuation, 'function'),
1395
1476
  ('', Text, '#pop'),
1396
1477
  ],
1478
+ 'literal_number': [
1479
+ (r'\(', Punctuation, 'literal_number_inner'),
1480
+ (r'\)', Literal, '#pop'),
1481
+ include('statement'),
1482
+ ],
1483
+ 'literal_number_inner': [
1484
+ (r'\(', Punctuation, '#push'),
1485
+ (r'\)', Punctuation, '#pop'),
1486
+ include('statement'),
1487
+ ],
1488
+ 'literal_array': [
1489
+ (r'\[', Punctuation, 'literal_array_inner'),
1490
+ (r'\]', Literal, '#pop'),
1491
+ include('statement'),
1492
+ ],
1493
+ 'literal_array_inner': [
1494
+ (r'\[', Punctuation, '#push'),
1495
+ (r'\]', Punctuation, '#pop'),
1496
+ include('statement'),
1497
+ ],
1498
+ 'literal_dictionary': [
1499
+ (r'\}', Literal, '#pop'),
1500
+ include('statement'),
1501
+ ],
1397
1502
  }
1398
1503
 
1399
1504
  def analyse_text(text):
@@ -1401,10 +1506,25 @@ def objective(baselexer):
1401
1506
  return 1.0
1402
1507
  elif '@"' in text: # strings
1403
1508
  return 0.8
1509
+ elif re.search('@[0-9]+', text):
1510
+ return 0.7
1404
1511
  elif _oc_message.search(text):
1405
1512
  return 0.8
1406
1513
  return 0
1407
1514
 
1515
+ def get_tokens_unprocessed(self, text):
1516
+ from pygments.lexers._cocoabuiltins import COCOA_INTERFACES, \
1517
+ COCOA_PROTOCOLS, COCOA_PRIMITIVES
1518
+
1519
+ for index, token, value in \
1520
+ baselexer.get_tokens_unprocessed(self, text):
1521
+ if token is Name or token is Name.Class:
1522
+ if value in COCOA_INTERFACES or value in COCOA_PROTOCOLS \
1523
+ or value in COCOA_PRIMITIVES:
1524
+ token = Name.Builtin.Pseudo
1525
+
1526
+ yield index, token, value
1527
+
1408
1528
  return GeneratedObjectiveCVariant
1409
1529
 
1410
1530
 
@@ -1436,7 +1556,7 @@ class FortranLexer(RegexLexer):
1436
1556
  """
1437
1557
  Lexer for FORTRAN 90 code.
1438
1558
 
1439
- *New in Pygments 0.10.*
1559
+ .. versionadded:: 0.10
1440
1560
  """
1441
1561
  name = 'Fortran'
1442
1562
  aliases = ['fortran']
@@ -1456,7 +1576,7 @@ class FortranLexer(RegexLexer):
1456
1576
  (r'!.*\n', Comment),
1457
1577
  include('strings'),
1458
1578
  include('core'),
1459
- (r'[a-z][a-z0-9_]*', Name.Variable),
1579
+ (r'[a-z]\w*', Name.Variable),
1460
1580
  include('nums'),
1461
1581
  (r'[\s]+', Text),
1462
1582
  ],
@@ -1491,7 +1611,7 @@ class FortranLexer(RegexLexer):
1491
1611
 
1492
1612
  (r'(::)', Keyword.Declaration),
1493
1613
 
1494
- (r'[(),:&%;]', Punctuation),
1614
+ (r'[()\[\],:&%;]', Punctuation),
1495
1615
 
1496
1616
  # Intrinsics
1497
1617
  (r'\b(Abort|Abs|Access|AChar|ACos|AdjustL|AdjustR|AImag|AInt|Alarm|'
@@ -1540,9 +1660,9 @@ class FortranLexer(RegexLexer):
1540
1660
  ],
1541
1661
 
1542
1662
  'nums': [
1543
- (r'\d+(?![.Ee])', Number.Integer),
1544
- (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
1545
- (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float),
1663
+ (r'\d+(?![.e])(_[a-z]\w+)?', Number.Integer),
1664
+ (r'[+-]?\d*\.\d+(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float),
1665
+ (r'[+-]?\d+\.\d*(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float),
1546
1666
  ],
1547
1667
  }
1548
1668
 
@@ -1551,7 +1671,7 @@ class GLShaderLexer(RegexLexer):
1551
1671
  """
1552
1672
  GLSL (OpenGL Shader) lexer.
1553
1673
 
1554
- *New in Pygments 1.1.*
1674
+ .. versionadded:: 1.1
1555
1675
  """
1556
1676
  name = 'GLSL'
1557
1677
  aliases = ['glsl']
@@ -1620,7 +1740,7 @@ class PrologLexer(RegexLexer):
1620
1740
  (r'[\[\](){}|.,;!]', Punctuation),
1621
1741
  (r':-|-->', Punctuation),
1622
1742
  (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),
1743
+ r'\\[0-7]+\\|\\["\nabcefnrstv]|[^\\"])*"', String.Double),
1624
1744
  (r"'(?:''|[^'])*'", String.Atom), # quoted atom
1625
1745
  # Needs to not be followed by an atom.
1626
1746
  #(r'=(?=\s|[a-zA-Z\[])', Operator),
@@ -1631,20 +1751,20 @@ class PrologLexer(RegexLexer):
1631
1751
  (r'_', Keyword), # The don't-care variable
1632
1752
  (r'([a-z]+)(:)', bygroups(Name.Namespace, Punctuation)),
1633
1753
  (u'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
1634
- u'[a-zA-Z0-9_$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
1754
+ u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
1635
1755
  u'(\\s*)(:-|-->)',
1636
1756
  bygroups(Name.Function, Text, Operator)), # function defn
1637
1757
  (u'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
1638
- u'[a-zA-Z0-9_$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
1758
+ u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
1639
1759
  u'(\\s*)(\\()',
1640
1760
  bygroups(Name.Function, Text, Punctuation)),
1641
1761
  (u'[a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
1642
- u'[a-zA-Z0-9_$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*',
1762
+ u'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*',
1643
1763
  String.Atom), # atom, characters
1644
1764
  # This one includes !
1645
1765
  (u'[#&*+\\-./:<=>?@\\\\^~\u00a1-\u00bf\u2010-\u303f]+',
1646
1766
  String.Atom), # atom, graphics
1647
- (r'[A-Z_][A-Za-z0-9_]*', Name.Variable),
1767
+ (r'[A-Z_]\w*', Name.Variable),
1648
1768
  (u'\\s+|[\u2000-\u200f\ufff0-\ufffe\uffef]', Text),
1649
1769
  ],
1650
1770
  'nested-comment': [
@@ -1663,7 +1783,7 @@ class CythonLexer(RegexLexer):
1663
1783
  """
1664
1784
  For Pyrex and `Cython <http://cython.org>`_ source code.
1665
1785
 
1666
- *New in Pygments 1.1.*
1786
+ .. versionadded:: 1.1
1667
1787
  """
1668
1788
 
1669
1789
  name = 'Cython'
@@ -1750,40 +1870,40 @@ class CythonLexer(RegexLexer):
1750
1870
  ('`.*?`', String.Backtick),
1751
1871
  ],
1752
1872
  'name': [
1753
- (r'@[a-zA-Z0-9_]+', Name.Decorator),
1754
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
1873
+ (r'@\w+', Name.Decorator),
1874
+ ('[a-zA-Z_]\w*', Name),
1755
1875
  ],
1756
1876
  'funcname': [
1757
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
1877
+ ('[a-zA-Z_]\w*', Name.Function, '#pop')
1758
1878
  ],
1759
1879
  'cdef': [
1760
1880
  (r'(public|readonly|extern|api|inline)\b', Keyword.Reserved),
1761
1881
  (r'(struct|enum|union|class)\b', Keyword),
1762
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(?=[(:#=]|$)',
1882
+ (r'([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)',
1763
1883
  bygroups(Name.Function, Text), '#pop'),
1764
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(,)',
1884
+ (r'([a-zA-Z_]\w*)(\s*)(,)',
1765
1885
  bygroups(Name.Function, Text, Punctuation)),
1766
1886
  (r'from\b', Keyword, '#pop'),
1767
1887
  (r'as\b', Keyword),
1768
1888
  (r':', Punctuation, '#pop'),
1769
1889
  (r'(?=["\'])', Text, '#pop'),
1770
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Keyword.Type),
1890
+ (r'[a-zA-Z_]\w*', Keyword.Type),
1771
1891
  (r'.', Text),
1772
1892
  ],
1773
1893
  'classname': [
1774
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
1894
+ ('[a-zA-Z_]\w*', Name.Class, '#pop')
1775
1895
  ],
1776
1896
  'import': [
1777
1897
  (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)),
1778
- (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace),
1898
+ (r'[a-zA-Z_][\w.]*', Name.Namespace),
1779
1899
  (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)),
1780
- (r'', Text, '#pop') # all else: go back
1900
+ default('#pop') # all else: go back
1781
1901
  ],
1782
1902
  'fromimport': [
1783
1903
  (r'(\s+)(c?import)\b', bygroups(Text, Keyword), '#pop'),
1784
- (r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace),
1904
+ (r'[a-zA-Z_.][\w.]*', Name.Namespace),
1785
1905
  # ``cdef foo from "header"``, or ``for foo from 0 < i < 10``
1786
- (r'', Text, '#pop'),
1906
+ default('#pop'),
1787
1907
  ],
1788
1908
  'stringescape': [
1789
1909
  (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
@@ -1829,7 +1949,7 @@ class ValaLexer(RegexLexer):
1829
1949
  """
1830
1950
  For Vala source code with preprocessor directives.
1831
1951
 
1832
- *New in Pygments 1.1.*
1952
+ .. versionadded:: 1.1
1833
1953
  """
1834
1954
  name = 'Vala'
1835
1955
  aliases = ['vala', 'vapi']
@@ -1873,14 +1993,14 @@ class ValaLexer(RegexLexer):
1873
1993
  'namespace'),
1874
1994
  (r'(class|errordomain|interface|struct)(\s+)',
1875
1995
  bygroups(Keyword.Declaration, Text), 'class'),
1876
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)',
1996
+ (r'(\.)([a-zA-Z_]\w*)',
1877
1997
  bygroups(Operator, Name.Attribute)),
1878
1998
  # void is an actual keyword, others are in glib-2.0.vapi
1879
1999
  (r'(void|bool|char|double|float|int|int8|int16|int32|int64|long|'
1880
2000
  r'short|size_t|ssize_t|string|time_t|uchar|uint|uint8|uint16|'
1881
2001
  r'uint32|uint64|ulong|unichar|ushort)\b', Keyword.Type),
1882
2002
  (r'(true|false|null)\b', Name.Builtin),
1883
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
2003
+ ('[a-zA-Z_]\w*', Name),
1884
2004
  ],
1885
2005
  'root': [
1886
2006
  include('whitespace'),
@@ -1906,10 +2026,10 @@ class ValaLexer(RegexLexer):
1906
2026
  (r'.*?\n', Comment),
1907
2027
  ],
1908
2028
  'class': [
1909
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
2029
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
1910
2030
  ],
1911
2031
  'namespace': [
1912
- (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace, '#pop')
2032
+ (r'[a-zA-Z_][\w.]*', Name.Namespace, '#pop')
1913
2033
  ],
1914
2034
  }
1915
2035
 
@@ -1918,7 +2038,7 @@ class OocLexer(RegexLexer):
1918
2038
  """
1919
2039
  For `Ooc <http://ooc-lang.org/>`_ source code
1920
2040
 
1921
- *New in Pygments 1.2.*
2041
+ .. versionadded:: 1.2
1922
2042
  """
1923
2043
  name = 'Ooc'
1924
2044
  aliases = ['ooc']
@@ -1933,9 +2053,9 @@ class OocLexer(RegexLexer):
1933
2053
  r'while|do|switch|case|as|in|version|return|true|false|null)\b',
1934
2054
  Keyword),
1935
2055
  (r'include\b', Keyword, 'include'),
1936
- (r'(cover)([ \t]+)(from)([ \t]+)([a-zA-Z0-9_]+[*@]?)',
2056
+ (r'(cover)([ \t]+)(from)([ \t]+)(\w+[*@]?)',
1937
2057
  bygroups(Keyword, Text, Keyword, Text, Name.Class)),
1938
- (r'(func)((?:[ \t]|\\\n)+)(~[a-z_][a-zA-Z0-9_]*)',
2058
+ (r'(func)((?:[ \t]|\\\n)+)(~[a-z_]\w*)',
1939
2059
  bygroups(Keyword, Text, Name.Function)),
1940
2060
  (r'\bfunc\b', Keyword),
1941
2061
  # Note: %= and ^= not listed on http://ooc-lang.org/syntax
@@ -1946,18 +2066,18 @@ class OocLexer(RegexLexer):
1946
2066
  (r'(\.)([ \t]*)([a-z]\w*)', bygroups(Operator, Text,
1947
2067
  Name.Function)),
1948
2068
  (r'[A-Z][A-Z0-9_]+', Name.Constant),
1949
- (r'[A-Z][a-zA-Z0-9_]*([@*]|\[[ \t]*\])?', Name.Class),
2069
+ (r'[A-Z]\w*([@*]|\[[ \t]*\])?', Name.Class),
1950
2070
 
1951
- (r'([a-z][a-zA-Z0-9_]*(?:~[a-z][a-zA-Z0-9_]*)?)((?:[ \t]|\\\n)*)(?=\()',
2071
+ (r'([a-z]\w*(?:~[a-z]\w*)?)((?:[ \t]|\\\n)*)(?=\()',
1952
2072
  bygroups(Name.Function, Text)),
1953
- (r'[a-z][a-zA-Z0-9_]*', Name.Variable),
2073
+ (r'[a-z]\w*', Name.Variable),
1954
2074
 
1955
2075
  # : introduces types
1956
2076
  (r'[:(){}\[\];,]', Punctuation),
1957
2077
 
1958
2078
  (r'0x[0-9a-fA-F]+', Number.Hex),
1959
2079
  (r'0c[0-9]+', Number.Oct),
1960
- (r'0b[01]+', Number.Binary),
2080
+ (r'0b[01]+', Number.Bin),
1961
2081
  (r'[0-9_]\.[0-9_]*(?!\.)', Number.Float),
1962
2082
  (r'[0-9_]+', Number.Decimal),
1963
2083
 
@@ -1989,6 +2109,8 @@ class GoLexer(RegexLexer):
1989
2109
  aliases = ['go']
1990
2110
  mimetypes = ['text/x-gosrc']
1991
2111
 
2112
+ flags = re.MULTILINE | re.UNICODE
2113
+
1992
2114
  tokens = {
1993
2115
  'root': [
1994
2116
  (r'\n', Text),
@@ -2048,7 +2170,7 @@ class GoLexer(RegexLexer):
2048
2170
  r'|<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])', Operator),
2049
2171
  (r'[|^<>=!()\[\]{}.,;:]', Punctuation),
2050
2172
  # identifier
2051
- (r'[a-zA-Z_]\w*', Name.Other),
2173
+ (r'[^\W\d]\w*', Name.Other),
2052
2174
  ]
2053
2175
  }
2054
2176
 
@@ -2057,7 +2179,7 @@ class FelixLexer(RegexLexer):
2057
2179
  """
2058
2180
  For `Felix <http://www.felix-lang.org>`_ source code.
2059
2181
 
2060
- *New in Pygments 1.2.*
2182
+ .. versionadded:: 1.2
2061
2183
  """
2062
2184
 
2063
2185
  name = 'Felix'
@@ -2162,7 +2284,7 @@ class FelixLexer(RegexLexer):
2162
2284
 
2163
2285
  # IntegerLiteral
2164
2286
  # -- Binary
2165
- (r'0[Bb][01_]+%s' % decimal_suffixes, Number),
2287
+ (r'0[Bb][01_]+%s' % decimal_suffixes, Number.Bin),
2166
2288
  # -- Octal
2167
2289
  (r'0[0-7_]+%s' % decimal_suffixes, Number.Oct),
2168
2290
  # -- Hexadecimal
@@ -2250,7 +2372,7 @@ class FelixLexer(RegexLexer):
2250
2372
  'modulename': [
2251
2373
  include('whitespace'),
2252
2374
  (r'\[', Punctuation, ('modulename2', 'tvarlist')),
2253
- (r'', Error, 'modulename2'),
2375
+ default('modulename2'),
2254
2376
  ],
2255
2377
  'modulename2': [
2256
2378
  include('whitespace'),
@@ -2311,7 +2433,7 @@ class AdaLexer(RegexLexer):
2311
2433
  """
2312
2434
  For Ada source code.
2313
2435
 
2314
- *New in Pygments 1.3.*
2436
+ .. versionadded:: 1.3
2315
2437
  """
2316
2438
 
2317
2439
  name = 'Ada'
@@ -2332,7 +2454,7 @@ class AdaLexer(RegexLexer):
2332
2454
  (r'task|protected', Keyword.Declaration),
2333
2455
  (r'(subtype)(\s+)', bygroups(Keyword.Declaration, Text)),
2334
2456
  (r'(end)(\s+)', bygroups(Keyword.Reserved, Text), 'end'),
2335
- (r'(pragma)(\s+)([a-zA-Z0-9_]+)', bygroups(Keyword.Reserved, Text,
2457
+ (r'(pragma)(\s+)(\w+)', bygroups(Keyword.Reserved, Text,
2336
2458
  Comment.Preproc)),
2337
2459
  (r'(true|false|null)\b', Keyword.Constant),
2338
2460
  (r'(Address|Byte|Boolean|Character|Controlled|Count|Cursor|'
@@ -2375,7 +2497,7 @@ class AdaLexer(RegexLexer):
2375
2497
  (r'[0-9_]+', Number.Integer),
2376
2498
  ],
2377
2499
  'attribute' : [
2378
- (r"(')([a-zA-Z0-9_]+)", bygroups(Punctuation, Name.Attribute)),
2500
+ (r"(')(\w+)", bygroups(Punctuation, Name.Attribute)),
2379
2501
  ],
2380
2502
  'subprogram' : [
2381
2503
  (r'\(', Punctuation, ('#pop', 'formal_part')),
@@ -2386,7 +2508,7 @@ class AdaLexer(RegexLexer):
2386
2508
  ],
2387
2509
  'end' : [
2388
2510
  ('(if|case|record|loop|select)', Keyword.Reserved),
2389
- ('"[^"]+"|[a-zA-Z0-9_.]+', Name.Function),
2511
+ ('"[^"]+"|[\w.]+', Name.Function),
2390
2512
  ('\s+', Text),
2391
2513
  (';', Punctuation, '#pop'),
2392
2514
  ],
@@ -2411,7 +2533,7 @@ class AdaLexer(RegexLexer):
2411
2533
  ],
2412
2534
  'import': [
2413
2535
  (r'[a-z0-9_.]+', Name.Namespace, '#pop'),
2414
- (r'', Text, '#pop'),
2536
+ default('#pop'),
2415
2537
  ],
2416
2538
  'formal_part' : [
2417
2539
  (r'\)', Punctuation, '#pop'),
@@ -2426,7 +2548,7 @@ class AdaLexer(RegexLexer):
2426
2548
  ('is', Keyword.Reserved, '#pop'),
2427
2549
  (';', Punctuation, '#pop'),
2428
2550
  ('\(', Punctuation, 'package_instantiation'),
2429
- ('([a-zA-Z0-9_.]+)', Name.Class),
2551
+ ('([\w.]+)', Name.Class),
2430
2552
  include('root'),
2431
2553
  ],
2432
2554
  'package_instantiation': [
@@ -2454,7 +2576,7 @@ class Modula2Lexer(RegexLexer):
2454
2576
  `gm2ext`
2455
2577
  Also highlight GNU extensions (default: False).
2456
2578
 
2457
- *New in Pygments 1.3.*
2579
+ .. versionadded:: 1.3
2458
2580
  """
2459
2581
  name = 'Modula-2'
2460
2582
  aliases = ['modula2', 'm2']
@@ -2469,10 +2591,10 @@ class Modula2Lexer(RegexLexer):
2469
2591
  (r'\s+', Text), # whitespace
2470
2592
  ],
2471
2593
  'identifiers': [
2472
- (r'([a-zA-Z_\$][a-zA-Z0-9_\$]*)', Name),
2594
+ (r'([a-zA-Z_\$][\w\$]*)', Name),
2473
2595
  ],
2474
2596
  'numliterals': [
2475
- (r'[01]+B', Number.Binary), # binary number (ObjM2)
2597
+ (r'[01]+B', Number.Bin), # binary number (ObjM2)
2476
2598
  (r'[0-7]+B', Number.Oct), # octal number (PIM + ISO)
2477
2599
  (r'[0-7]+C', Number.Oct), # char code (PIM + ISO)
2478
2600
  (r'[0-9A-F]+C', Number.Hex), # char code (ObjM2)
@@ -2636,7 +2758,7 @@ class BlitzMaxLexer(RegexLexer):
2636
2758
  """
2637
2759
  For `BlitzMax <http://blitzbasic.com>`_ source code.
2638
2760
 
2639
- *New in Pygments 1.4.*
2761
+ .. versionadded:: 1.4
2640
2762
  """
2641
2763
 
2642
2764
  name = 'BlitzMax'
@@ -2647,9 +2769,9 @@ class BlitzMaxLexer(RegexLexer):
2647
2769
  bmax_vopwords = r'\b(Shl|Shr|Sar|Mod)\b'
2648
2770
  bmax_sktypes = r'@{1,2}|[!#$%]'
2649
2771
  bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b'
2650
- bmax_name = r'[a-z_][a-z0-9_]*'
2772
+ bmax_name = r'[a-z_]\w*'
2651
2773
  bmax_var = (r'(%s)(?:(?:([ \t]*)(%s)|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)'
2652
- r'|([ \t]*)([:])([ \t]*)(?:%s|(%s)))(?:([ \t]*)(Ptr))?)') % \
2774
+ r'|([ \t]*)(:)([ \t]*)(?:%s|(%s)))(?:([ \t]*)(Ptr))?)') % \
2653
2775
  (bmax_name, bmax_sktypes, bmax_lktypes, bmax_name)
2654
2776
  bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])'
2655
2777
 
@@ -2669,7 +2791,7 @@ class BlitzMaxLexer(RegexLexer):
2669
2791
  (r'\.[0-9]*(?!\.)', Number.Float),
2670
2792
  (r'[0-9]+', Number.Integer),
2671
2793
  (r'\$[0-9a-f]+', Number.Hex),
2672
- (r'\%[10]+', Number), # Binary
2794
+ (r'\%[10]+', Number.Bin),
2673
2795
  # Other
2674
2796
  (r'(?:(?:(:)?([ \t]*)(:?%s|([+\-*/&|~]))|Or|And|Not|[=<>^]))' %
2675
2797
  (bmax_vopwords), Operator),
@@ -2730,7 +2852,7 @@ class BlitzBasicLexer(RegexLexer):
2730
2852
  """
2731
2853
  For `BlitzBasic <http://blitzbasic.com>`_ source code.
2732
2854
 
2733
- *New in Pygments 1.7.*
2855
+ .. versionadded:: 2.0
2734
2856
  """
2735
2857
 
2736
2858
  name = 'BlitzBasic'
@@ -2742,7 +2864,7 @@ class BlitzBasicLexer(RegexLexer):
2742
2864
  r'Abs|Sgn|Handle|Int|Float|Str|'
2743
2865
  r'First|Last|Before|After)\b')
2744
2866
  bb_sktypes = r'@{1,2}|[#$%]'
2745
- bb_name = r'[a-z][a-z0-9_]*'
2867
+ bb_name = r'[a-z]\w*'
2746
2868
  bb_var = (r'(%s)(?:([ \t]*)(%s)|([ \t]*)([.])([ \t]*)(?:(%s)))?') % \
2747
2869
  (bb_name, bb_sktypes, bb_name)
2748
2870
 
@@ -2760,7 +2882,7 @@ class BlitzBasicLexer(RegexLexer):
2760
2882
  (r'\.[0-9]+(?!\.)', Number.Float),
2761
2883
  (r'[0-9]+', Number.Integer),
2762
2884
  (r'\$[0-9a-f]+', Number.Hex),
2763
- (r'\%[10]+', Number), # Binary
2885
+ (r'\%[10]+', Number.Bin),
2764
2886
  # Other
2765
2887
  (r'(?:%s|([+\-*/~=<>^]))' % (bb_vopwords), Operator),
2766
2888
  (r'[(),:\[\]\\]', Punctuation),
@@ -2812,7 +2934,7 @@ class NimrodLexer(RegexLexer):
2812
2934
  """
2813
2935
  For `Nimrod <http://nimrod-code.org/>`_ source code.
2814
2936
 
2815
- *New in Pygments 1.5.*
2937
+ .. versionadded:: 1.5
2816
2938
  """
2817
2939
 
2818
2940
  name = 'Nimrod'
@@ -2887,8 +3009,8 @@ class NimrodLexer(RegexLexer):
2887
3009
  # Numbers
2888
3010
  (r'[0-9][0-9_]*(?=([eE.]|\'[fF](32|64)))',
2889
3011
  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'),
3012
+ (r'0[xX][a-f0-9][a-f0-9_]*', Number.Hex, 'int-suffix'),
3013
+ (r'0[bB][01][01_]*', Number.Bin, 'int-suffix'),
2892
3014
  (r'0o[0-7][0-7_]*', Number.Oct, 'int-suffix'),
2893
3015
  (r'[0-9][0-9_]*', Number.Integer, 'int-suffix'),
2894
3016
  # Whitespace
@@ -2896,7 +3018,7 @@ class NimrodLexer(RegexLexer):
2896
3018
  (r'.+$', Error),
2897
3019
  ],
2898
3020
  'chars': [
2899
- (r'\\([\\abcefnrtvl"\']|x[a-fA-F0-9]{2}|[0-9]{1,3})', String.Escape),
3021
+ (r'\\([\\abcefnrtvl"\']|x[a-f0-9]{2}|[0-9]{1,3})', String.Escape),
2900
3022
  (r"'", String.Char, '#pop'),
2901
3023
  (r".", String.Char)
2902
3024
  ],
@@ -2910,7 +3032,7 @@ class NimrodLexer(RegexLexer):
2910
3032
  # newlines are an error (use "nl" state)
2911
3033
  ],
2912
3034
  'dqs': [
2913
- (r'\\([\\abcefnrtvl"\']|\n|x[a-fA-F0-9]{2}|[0-9]{1,3})',
3035
+ (r'\\([\\abcefnrtvl"\']|\n|x[a-f0-9]{2}|[0-9]{1,3})',
2914
3036
  String.Escape),
2915
3037
  (r'"', String, '#pop'),
2916
3038
  include('strings')
@@ -2935,16 +3057,16 @@ class NimrodLexer(RegexLexer):
2935
3057
  'float-number': [
2936
3058
  (r'\.(?!\.)[0-9_]*', Number.Float),
2937
3059
  (r'[eE][+-]?[0-9][0-9_]*', Number.Float),
2938
- (r'', Text, '#pop')
3060
+ default('#pop')
2939
3061
  ],
2940
3062
  'float-suffix': [
2941
3063
  (r'\'[fF](32|64)', Number.Float),
2942
- (r'', Text, '#pop')
3064
+ default('#pop')
2943
3065
  ],
2944
3066
  'int-suffix': [
2945
3067
  (r'\'[iI](32|64)', Number.Integer.Long),
2946
3068
  (r'\'[iI](8|16)', Number.Integer),
2947
- (r'', Text, '#pop')
3069
+ default('#pop')
2948
3070
  ],
2949
3071
  }
2950
3072
 
@@ -2953,7 +3075,7 @@ class FantomLexer(RegexLexer):
2953
3075
  """
2954
3076
  For Fantom source code.
2955
3077
 
2956
- *New in Pygments 1.5.*
3078
+ .. versionadded:: 1.5
2957
3079
  """
2958
3080
  name = 'Fantom'
2959
3081
  aliases = ['fan']
@@ -2966,7 +3088,7 @@ class FantomLexer(RegexLexer):
2966
3088
  dict (
2967
3089
  pod = r'[\"\w\.]+',
2968
3090
  eos = r'\n|;',
2969
- id = r'[a-zA-Z_][a-zA-Z0-9_]*',
3091
+ id = r'[a-zA-Z_]\w*',
2970
3092
  # all chars which can be part of type definition. Starts with
2971
3093
  # either letter, or [ (maps), or | (funcs)
2972
3094
  type = r'(?:\[|[a-zA-Z_]|\|)[:\w\[\]\|\->\?]*?',
@@ -3050,7 +3172,7 @@ class FantomLexer(RegexLexer):
3050
3172
  'inType': [
3051
3173
  (r'[\[\]\|\->:\?]', Punctuation),
3052
3174
  (s(r'$id'), Name.Class),
3053
- (r'', Text, '#pop'),
3175
+ default('#pop'),
3054
3176
 
3055
3177
  ],
3056
3178
  'root': [
@@ -3155,19 +3277,19 @@ class FantomLexer(RegexLexer):
3155
3277
  (r'(\")?([\w\.]+)(\")?',
3156
3278
  bygroups(Punctuation, Name.Namespace, Punctuation)), #podname
3157
3279
  (r'::', Punctuation, 'usingClass'),
3158
- (r'', Text, '#pop')
3280
+ default('#pop')
3159
3281
  ],
3160
3282
  'usingClass': [
3161
3283
  (r'[ \t]+', Text), # consume whitespaces
3162
3284
  (r'(as)(\s+)(\w+)',
3163
3285
  bygroups(Keyword.Declaration, Text, Name.Class), '#pop:2'),
3164
3286
  (r'[\w\$]+', Name.Class),
3165
- (r'', Text, '#pop:2') # jump out to root state
3287
+ default('#pop:2') # jump out to root state
3166
3288
  ],
3167
3289
  'facet': [
3168
3290
  (r'\s+', Text),
3169
3291
  (r'{', Punctuation, 'facetFields'),
3170
- (r'', Text, '#pop')
3292
+ default('#pop')
3171
3293
  ],
3172
3294
  'facetFields': [
3173
3295
  include('comments'),
@@ -3183,12 +3305,12 @@ class FantomLexer(RegexLexer):
3183
3305
 
3184
3306
  class RustLexer(RegexLexer):
3185
3307
  """
3186
- Lexer for Mozilla's Rust programming language.
3308
+ Lexer for the Rust programming language (version 0.9).
3187
3309
 
3188
- *New in Pygments 1.6.*
3310
+ .. versionadded:: 1.6
3189
3311
  """
3190
3312
  name = 'Rust'
3191
- filenames = ['*.rs', '*.rc']
3313
+ filenames = ['*.rs']
3192
3314
  aliases = ['rust']
3193
3315
  mimetypes = ['text/x-rustsrc']
3194
3316
 
@@ -3197,47 +3319,89 @@ class RustLexer(RegexLexer):
3197
3319
  # Whitespace and Comments
3198
3320
  (r'\n', Text),
3199
3321
  (r'\s+', Text),
3322
+ (r'//[/!](.*?)\n', Comment.Doc),
3200
3323
  (r'//(.*?)\n', Comment.Single),
3201
3324
  (r'/[*](.|\n)*?[*]/', Comment.Multiline),
3202
3325
 
3203
3326
  # 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
-
3327
+ (r'(as|box|break|continue'
3328
+ r'|do|else|enum|extern'
3329
+ r'|fn|for|if|impl|in'
3330
+ r'|loop|match|mut|priv|proc|pub'
3331
+ r'|ref|return|static|\'static|struct|trait|true|type'
3332
+ r'|unsafe|while)\b',
3333
+ Keyword),
3334
+ (r'(alignof|be|const|offsetof|pure|sizeof|typeof|once|unsized'
3335
+ r'|yield)\b', Keyword.Reserved),
3336
+ (r'(mod|use)\b', Keyword.Namespace),
3337
+ (r'(true|false)\b', Keyword.Constant),
3338
+ (r'let\b', Keyword.Declaration),
3339
+ (r'(u8|u16|u32|u64|i8|i16|i32|i64|uint|int|f32|f64'
3340
+ r'|str|bool)\b', Keyword.Type),
3341
+ (r'self\b', Name.Builtin.Pseudo),
3342
+ # Prelude
3343
+ (r'(Freeze|Pod|Send|Sized|Add|Sub|Mul|Div|Rem|Neg|Not|BitAnd'
3344
+ r'|BitOr|BitXor|Drop|Shl|Shr|Index|Option|Some|None|Result'
3345
+ r'|Ok|Err|from_str|range|print|println|Any|AnyOwnExt|AnyRefExt'
3346
+ r'|AnyMutRefExt|Ascii|AsciiCast|OnwedAsciiCast|AsciiStr'
3347
+ r'|IntoBytes|Bool|ToCStr|Char|Clone|DeepClone|Eq|ApproxEq'
3348
+ r'|Ord|TotalEq|Ordering|Less|Equal|Greater|Equiv|Container'
3349
+ r'|Mutable|Map|MutableMap|Set|MutableSet|Default|FromStr'
3350
+ r'|Hash|FromIterator|Extendable|Iterator|DoubleEndedIterator'
3351
+ r'|RandomAccessIterator|CloneableIterator|OrdIterator'
3352
+ r'|MutableDoubleEndedIterator|ExactSize|Times|Algebraic'
3353
+ r'|Trigonometric|Exponential|Hyperbolic|Bitwise|BitCount'
3354
+ r'|Bounded|Integer|Fractional|Real|RealExt|Num|NumCast'
3355
+ r'|CheckedAdd|CheckedSub|CheckedMul|Orderable|Signed'
3356
+ r'|Unsigned|Round|Primitive|Int|Float|ToStrRadix'
3357
+ r'|ToPrimitive|FromPrimitive|GenericPath|Path|PosixPath'
3358
+ r'|WindowsPath|RawPtr|Buffer|Writer|Reader|Seek'
3359
+ r'|SendStr|SendStrOwned|SendStrStatic|IntoSendStr|Str'
3360
+ r'|StrVector|StrSlice|OwnedStr|IterBytes|ToStr|IntoStr'
3361
+ r'|CopyableTuple|ImmutableTuple|ImmutableTuple\d+'
3362
+ r'|Tuple\d+|ImmutableEqVector|ImmutableTotalOrdVector'
3363
+ r'|ImmutableCopyableVector|OwnedVector|OwnedCopyableVector'
3364
+ r'|OwnedEqVector|MutableVector|MutableTotalOrdVector'
3365
+ r'|Vector|VectorVector|CopyableVector|ImmutableVector'
3366
+ r'|Port|Chan|SharedChan|spawn|drop)\b', Name.Builtin),
3367
+ # Borrowed pointer
3368
+ (r'(&)(\'[A-Za-z_]\w*)?', bygroups(Operator, Name)),
3369
+ # Labels
3370
+ (r'\'[A-Za-z_]\w*:', Name.Label),
3212
3371
  # Character Literal
3213
3372
  (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
3214
3373
  r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
3215
3374
  String.Char),
3375
+ # Lifetime
3376
+ (r"""'[a-zA-Z_]\w*""", Name.Label),
3216
3377
  # Binary Literal
3217
- (r'0[Bb][01_]+', Number, 'number_lit'),
3378
+ (r'0b[01_]+', Number.Bin, 'number_lit'),
3218
3379
  # Octal Literal
3219
- (r'0[0-7_]+', Number.Oct, 'number_lit'),
3380
+ (r'0o[0-7_]+', Number.Oct, 'number_lit'),
3220
3381
  # Hexadecimal Literal
3221
3382
  (r'0[xX][0-9a-fA-F_]+', Number.Hex, 'number_lit'),
3222
3383
  # Decimal Literal
3223
- (r'[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?'
3224
- r'[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)?', Number, 'number_lit'),
3384
+ (r'[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?[0-9_]+|'
3385
+ r'\.[0-9_]*|[eE][+\-]?[0-9_]+)', Number.Float, 'number_lit'),
3386
+ (r'[0-9][0-9_]*', Number.Integer, 'number_lit'),
3225
3387
  # String Literal
3226
3388
  (r'"', String, 'string'),
3389
+ (r'r(#*)".*?"\1', String.Raw),
3227
3390
 
3228
3391
  # Operators and Punctuation
3229
3392
  (r'[{}()\[\],.;]', Punctuation),
3230
3393
  (r'[+\-*/%&|<>^!~@=:?]', Operator),
3231
3394
 
3232
3395
  # Identifier
3233
- (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
3396
+ (r'[a-zA-Z_]\w*', Name),
3234
3397
 
3235
3398
  # Attributes
3236
3399
  (r'#\[', Comment.Preproc, 'attribute['),
3237
- (r'#\(', Comment.Preproc, 'attribute('),
3238
3400
  # 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('),
3401
+ (r'([A-Za-z_]\w*)!\s*([A-Za-z_]\w*)?\s*\{',
3402
+ bygroups(Comment.Preproc, Name), 'macro{'),
3403
+ (r'([A-Za-z_]\w*)!\s*([A-Za-z_]\w*)?\(',
3404
+ bygroups(Comment.Preproc, Name), 'macro('),
3241
3405
  ],
3242
3406
  'number_lit': [
3243
3407
  (r'(([ui](8|16|32|64)?)|(f(32|64)?))?', Keyword, '#pop'),
@@ -3249,6 +3413,14 @@ class RustLexer(RegexLexer):
3249
3413
  (r'[^\\"]+', String),
3250
3414
  (r'\\', String),
3251
3415
  ],
3416
+ 'macro{': [
3417
+ (r'\{', Operator, '#push'),
3418
+ (r'\}', Operator, '#pop'),
3419
+ ],
3420
+ 'macro(': [
3421
+ (r'\(', Operator, '#push'),
3422
+ (r'\)', Operator, '#pop'),
3423
+ ],
3252
3424
  'attribute_common': [
3253
3425
  (r'"', String, 'string'),
3254
3426
  (r'\[', Comment.Preproc, 'attribute['),
@@ -3272,7 +3444,7 @@ class CudaLexer(CLexer):
3272
3444
  For NVIDIA `CUDA™ <http://developer.nvidia.com/category/zone/cuda-zone>`_
3273
3445
  source.
3274
3446
 
3275
- *New in Pygments 1.6.*
3447
+ .. versionadded:: 1.6
3276
3448
  """
3277
3449
  name = 'CUDA'
3278
3450
  filenames = ['*.cu', '*.cuh']
@@ -3322,7 +3494,7 @@ class MonkeyLexer(RegexLexer):
3322
3494
  `Monkey <https://en.wikipedia.org/wiki/Monkey_(programming_language)>`_
3323
3495
  source code.
3324
3496
 
3325
- *New in Pygments 1.6.*
3497
+ .. versionadded:: 1.6
3326
3498
  """
3327
3499
 
3328
3500
  name = 'Monkey'
@@ -3330,10 +3502,10 @@ class MonkeyLexer(RegexLexer):
3330
3502
  filenames = ['*.monkey']
3331
3503
  mimetypes = ['text/x-monkey']
3332
3504
 
3333
- name_variable = r'[a-z_][a-zA-Z0-9_]*'
3334
- name_function = r'[A-Z][a-zA-Z0-9_]*'
3505
+ name_variable = r'[a-z_]\w*'
3506
+ name_function = r'[A-Z]\w*'
3335
3507
  name_constant = r'[A-Z_][A-Z0-9_]*'
3336
- name_class = r'[A-Z][a-zA-Z0-9_]*'
3508
+ name_class = r'[A-Z]\w*'
3337
3509
  name_module = r'[a-z0-9_]*'
3338
3510
 
3339
3511
  keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)'
@@ -3360,7 +3532,7 @@ class MonkeyLexer(RegexLexer):
3360
3532
  (r'\.[0-9]+(?!\.)', Number.Float),
3361
3533
  (r'[0-9]+', Number.Integer),
3362
3534
  (r'\$[0-9a-fA-Z]+', Number.Hex),
3363
- (r'\%[10]+', Number), # Binary
3535
+ (r'\%[10]+', Number.Bin),
3364
3536
  # Native data types
3365
3537
  (r'\b%s\b' % keyword_type, Keyword.Type),
3366
3538
  # Exception handling
@@ -3421,7 +3593,7 @@ class MonkeyLexer(RegexLexer):
3421
3593
  (r'<', Punctuation, '#push'),
3422
3594
  (r'>', Punctuation, '#pop'),
3423
3595
  (r'\n', Text, '#pop'),
3424
- (r'', Text, '#pop')
3596
+ default('#pop')
3425
3597
  ],
3426
3598
  'variables': [
3427
3599
  (r'%s\b' % name_constant, Name.Constant),
@@ -3430,7 +3602,7 @@ class MonkeyLexer(RegexLexer):
3430
3602
  (r'\s+', Text),
3431
3603
  (r':', Punctuation, 'classname'),
3432
3604
  (r',', Punctuation, '#push'),
3433
- (r'', Text, '#pop')
3605
+ default('#pop')
3434
3606
  ],
3435
3607
  'string': [
3436
3608
  (r'[^"~]+', String.Double),
@@ -3450,7 +3622,7 @@ class CobolLexer(RegexLexer):
3450
3622
  """
3451
3623
  Lexer for OpenCOBOL code.
3452
3624
 
3453
- *New in Pygments 1.6.*
3625
+ .. versionadded:: 1.6
3454
3626
  """
3455
3627
  name = 'COBOL'
3456
3628
  aliases = ['cobol']
@@ -3644,7 +3816,7 @@ class CobolFreeformatLexer(CobolLexer):
3644
3816
  """
3645
3817
  Lexer for Free format OpenCOBOL code.
3646
3818
 
3647
- *New in Pygments 1.6.*
3819
+ .. versionadded:: 1.6
3648
3820
  """
3649
3821
  name = 'COBOLFree'
3650
3822
  aliases = ['cobolfree']
@@ -3663,7 +3835,7 @@ class LogosLexer(ObjectiveCppLexer):
3663
3835
  """
3664
3836
  For Logos + Objective-C source code with preprocessor directives.
3665
3837
 
3666
- *New in Pygments 1.6.*
3838
+ .. versionadded:: 1.6
3667
3839
  """
3668
3840
 
3669
3841
  name = 'Logos'
@@ -3675,12 +3847,12 @@ class LogosLexer(ObjectiveCppLexer):
3675
3847
  tokens = {
3676
3848
  'statements': [
3677
3849
  (r'(%orig|%log)\b', Keyword),
3678
- (r'(%c)\b(\()(\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\))',
3850
+ (r'(%c)\b(\()(\s*)([a-zA-Z$_][\w$]*)(\s*)(\))',
3679
3851
  bygroups(Keyword, Punctuation, Text, Name.Class, Text, Punctuation)),
3680
3852
  (r'(%init)\b(\()',
3681
3853
  bygroups(Keyword, Punctuation), 'logos_init_directive'),
3682
3854
  (r'(%init)(?=\s*;)', bygroups(Keyword)),
3683
- (r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)',
3855
+ (r'(%hook|%group)(\s+)([a-zA-Z$_][\w$]+)',
3684
3856
  bygroups(Keyword, Text, Name.Class), '#pop'),
3685
3857
  (r'(%subclass)(\s+)', bygroups(Keyword, Text),
3686
3858
  ('#pop', 'logos_classname')),
@@ -3689,20 +3861,20 @@ class LogosLexer(ObjectiveCppLexer):
3689
3861
  'logos_init_directive' : [
3690
3862
  ('\s+', Text),
3691
3863
  (',', Punctuation, ('logos_init_directive', '#pop')),
3692
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(=)(\s*)([^);]*)',
3864
+ ('([a-zA-Z$_][\w$]*)(\s*)(=)(\s*)([^);]*)',
3693
3865
  bygroups(Name.Class, Text, Punctuation, Text, Text)),
3694
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class),
3866
+ ('([a-zA-Z$_][\w$]*)', Name.Class),
3695
3867
  ('\)', Punctuation, '#pop'),
3696
3868
  ],
3697
3869
  'logos_classname' : [
3698
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
3870
+ ('([a-zA-Z$_][\w$]*)(\s*:\s*)([a-zA-Z$_][\w$]*)?',
3699
3871
  bygroups(Name.Class, Text, Name.Class), '#pop'),
3700
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
3872
+ ('([a-zA-Z$_][\w$]*)', Name.Class, '#pop')
3701
3873
  ],
3702
3874
  'root': [
3703
3875
  (r'(%subclass)(\s+)', bygroups(Keyword, Text),
3704
3876
  'logos_classname'),
3705
- (r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)',
3877
+ (r'(%hook|%group)(\s+)([a-zA-Z$_][\w$]+)',
3706
3878
  bygroups(Keyword, Text, Name.Class)),
3707
3879
  (r'(%config)(\s*\(\s*)(\w+)(\s*=\s*)(.*?)(\s*\)\s*)',
3708
3880
  bygroups(Keyword, Text, Name.Variable, Text, String, Text)),
@@ -3721,3 +3893,1300 @@ class LogosLexer(ObjectiveCppLexer):
3721
3893
  if LogosLexer._logos_keywords.search(text):
3722
3894
  return 1.0
3723
3895
  return 0
3896
+
3897
+
3898
+ class ChapelLexer(RegexLexer):
3899
+ """
3900
+ For `Chapel <http://chapel.cray.com/>`_ source.
3901
+
3902
+ .. versionadded:: 2.0
3903
+ """
3904
+ name = 'Chapel'
3905
+ filenames = ['*.chpl']
3906
+ aliases = ['chapel', 'chpl']
3907
+ # mimetypes = ['text/x-chapel']
3908
+
3909
+ tokens = {
3910
+ 'root': [
3911
+ (r'\n', Text),
3912
+ (r'\s+', Text),
3913
+ (r'\\\n', Text),
3914
+
3915
+ (r'//(.*?)\n', Comment.Single),
3916
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
3917
+
3918
+ (r'(config|const|in|inout|out|param|ref|type|var)\b',
3919
+ Keyword.Declaration),
3920
+ (r'(false|nil|true)\b', Keyword.Constant),
3921
+ (r'(bool|complex|imag|int|opaque|range|real|string|uint)\b',
3922
+ Keyword.Type),
3923
+ (r'(atomic|begin|break|by|cobegin|coforall|continue|iter|'
3924
+ r'delete|dmapped|do|domain|else|enum|export|extern|for|forall|'
3925
+ r'if|index|inline|label|lambda|let|local|new|on|otherwise|'
3926
+ r'reduce|return|scan|select|serial|single|sparse|'
3927
+ r'subdomain|sync|then|use|when|where|while|yield|zip)\b',
3928
+ Keyword),
3929
+ (r'(proc)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'procname'),
3930
+ (r'(class|module|record|union)(\s+)', bygroups(Keyword, Text),
3931
+ 'classname'),
3932
+
3933
+ # imaginary integers
3934
+ (r'\d+i', Number),
3935
+ (r'\d+\.\d*([Ee][-+]\d+)?i', Number),
3936
+ (r'\.\d+([Ee][-+]\d+)?i', Number),
3937
+ (r'\d+[Ee][-+]\d+i', Number),
3938
+
3939
+ # reals cannot end with a period due to lexical ambiguity with
3940
+ # .. operator. See reference for rationale.
3941
+ (r'(\d*\.\d+)([eE][+-]?[0-9]+)?i?', Number.Float),
3942
+ (r'\d+[eE][+-]?[0-9]+i?', Number.Float),
3943
+
3944
+ # integer literals
3945
+ # -- binary
3946
+ (r'0[bB][0-1]+', Number.Bin),
3947
+ # -- hex
3948
+ (r'0[xX][0-9a-fA-F]+', Number.Hex),
3949
+ # -- decimal
3950
+ (r'(0|[1-9][0-9]*)', Number.Integer),
3951
+
3952
+ # strings
3953
+ (r'["\'](\\\\|\\"|[^"\'])*["\']', String),
3954
+
3955
+ # tokens
3956
+ (r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|'
3957
+ r'<=>|\.\.|by|#|\.\.\.|'
3958
+ r'&&|\|\||!|&|\||\^|~|<<|>>|'
3959
+ r'==|!=|<=|>=|<|>|'
3960
+ r'[+\-*/%]|\*\*)', Operator),
3961
+ (r'[:;,.?()\[\]{}]', Punctuation),
3962
+
3963
+ # identifiers
3964
+ (r'[a-zA-Z_][\w$]*', Name.Other),
3965
+ ],
3966
+ 'classname': [
3967
+ (r'[a-zA-Z_][\w$]*', Name.Class, '#pop'),
3968
+ ],
3969
+ 'procname': [
3970
+ (r'[a-zA-Z_][\w$]*', Name.Function, '#pop'),
3971
+ ],
3972
+ }
3973
+
3974
+
3975
+ class EiffelLexer(RegexLexer):
3976
+ """
3977
+ For `Eiffel <http://www.eiffel.com>`_ source code.
3978
+
3979
+ .. versionadded:: 2.0
3980
+ """
3981
+ name = 'Eiffel'
3982
+ aliases = ['eiffel']
3983
+ filenames = ['*.e']
3984
+ mimetypes = ['text/x-eiffel']
3985
+
3986
+ tokens = {
3987
+ 'root': [
3988
+ (r'[^\S\n]+', Text),
3989
+ (r'--.*?\n', Comment.Single),
3990
+ (r'[^\S\n]+', Text),
3991
+ # Please note that keyword and operator are case insensitive.
3992
+ (r'(?i)(true|false|void|current|result|precursor)\b', Keyword.Constant),
3993
+ (r'(?i)(and(\s+then)?|not|xor|implies|or(\s+else)?)\b', Operator.Word),
3994
+ (r'(?i)\b(across|agent|alias|all|as|assign|attached|attribute|check|'
3995
+ r'class|convert|create|debug|deferred|detachable|do|else|elseif|'
3996
+ r'end|ensure|expanded|export|external|feature|from|frozen|if|'
3997
+ r'inherit|inspect|invariant|like|local|loop|none|note|obsolete|'
3998
+ r'old|once|only|redefine|rename|require|rescue|retry|select|'
3999
+ r'separate|then|undefine|until|variant|when)\b',Keyword.Reserved),
4000
+ (r'"\[(([^\]%]|\n)|%(.|\n)|\][^"])*?\]"', String),
4001
+ (r'"([^"%\n]|%.)*?"', String),
4002
+ include('numbers'),
4003
+ (r"'([^'%]|%'|%%)'", String.Char),
4004
+ (r"(//|\\\\|>=|<=|:=|/=|~|/~|[\\\?!#%&@|+/\-=\>\*$<|^\[\]])", Operator),
4005
+ (r"([{}():;,.])", Punctuation),
4006
+ (r'([a-z]\w*)|([A-Z][A-Z0-9_]*[a-z]\w*)', Name),
4007
+ (r'([A-Z][A-Z0-9_]*)', Name.Class),
4008
+ (r'\n+', Text),
4009
+ ],
4010
+ 'numbers': [
4011
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
4012
+ (r'0[bB][0-1]+', Number.Bin),
4013
+ (r'0[cC][0-7]+', Number.Oct),
4014
+ (r'([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)', Number.Float),
4015
+ (r'[0-9]+', Number.Integer),
4016
+ ],
4017
+ }
4018
+
4019
+
4020
+ class Inform6Lexer(RegexLexer):
4021
+ """
4022
+ For `Inform 6 <http://inform-fiction.org/>`_ source code.
4023
+
4024
+ .. versionadded:: 2.0
4025
+ """
4026
+
4027
+ name = 'Inform 6'
4028
+ aliases = ['inform6', 'i6']
4029
+ filenames = ['*.inf']
4030
+
4031
+ flags = re.MULTILINE | re.DOTALL | re.UNICODE
4032
+
4033
+ _name = r'[a-zA-Z_][a-zA-Z_0-9]*'
4034
+
4035
+ # Inform 7 maps these four character classes to their ASCII
4036
+ # equivalents. To support Inform 6 inclusions within Inform 7,
4037
+ # Inform6Lexer maps them too.
4038
+ _dash = u'\\-\u2010-\u2014'
4039
+ _dquote = u'"\u201c\u201d'
4040
+ _squote = u"'\u2018\u2019"
4041
+ _newline = u'\\n\u0085\u2028\u2029'
4042
+
4043
+ tokens = {
4044
+ 'root': [
4045
+ (r'(\A(!%%[^%s]*[%s])+)?' % (_newline, _newline), Comment.Preproc,
4046
+ 'directive')
4047
+ ],
4048
+ '_whitespace': [
4049
+ (r'\s+', Text),
4050
+ (r'![^%s]*' % _newline, Comment.Single)
4051
+ ],
4052
+ 'default': [
4053
+ include('_whitespace'),
4054
+ (r'\[', Punctuation, 'many-values'), # Array initialization
4055
+ (r':|(?=;)', Punctuation, '#pop'),
4056
+ (r'<', Punctuation), # Second angle bracket in an action statement
4057
+ default(('expression', '_expression'))
4058
+ ],
4059
+
4060
+ # Expressions
4061
+ '_expression': [
4062
+ include('_whitespace'),
4063
+ (r'(?=sp\b)', Text, '#pop'),
4064
+ (r'(?=[%s%s$0-9#a-zA-Z_])' % (_dquote, _squote), Text,
4065
+ ('#pop', 'value')),
4066
+ (r'\+\+|[%s]{1,2}(?!>)|~~?' % _dash, Operator),
4067
+ (r'(?=[()\[%s,?@{:;])' % _dash, Text, '#pop')
4068
+ ],
4069
+ 'expression': [
4070
+ include('_whitespace'),
4071
+ (r'\(', Punctuation, ('expression', '_expression')),
4072
+ (r'\)', Punctuation, '#pop'),
4073
+ (r'\[', Punctuation, ('#pop', 'statements', 'locals')),
4074
+ (r'>(?=(\s+|(![^%s]*))*[>;])' % _newline, Punctuation),
4075
+ (r'\+\+|[%s]{2}(?!>)' % _dash, Operator),
4076
+ (r',', Punctuation, '_expression'),
4077
+ (r'&&?|\|\|?|[=~><]?=|[%s]{1,2}>?|\.\.?[&#]?|::|[<>+*/%%]' % _dash,
4078
+ Operator, '_expression'),
4079
+ (r'(has|hasnt|in|notin|ofclass|or|provides)\b', Operator.Word,
4080
+ '_expression'),
4081
+ (r'sp\b', Name),
4082
+ (r'\?~?', Name.Label, 'label?'),
4083
+ (r'[@{]', Error),
4084
+ default('#pop')
4085
+ ],
4086
+ '_assembly-expression': [
4087
+ (r'\(', Punctuation, ('#push', '_expression')),
4088
+ (r'[\[\]]', Punctuation),
4089
+ (r'[%s]>' % _dash, Punctuation, '_expression'),
4090
+ (r'sp\b', Keyword.Pseudo),
4091
+ (r';', Punctuation, '#pop:3'),
4092
+ include('expression')
4093
+ ],
4094
+ '_for-expression': [
4095
+ (r'\)', Punctuation, '#pop:2'),
4096
+ (r':', Punctuation, '#pop'),
4097
+ include('expression')
4098
+ ],
4099
+ '_keyword-expression': [
4100
+ (r'(from|near|to)\b', Keyword, '_expression'),
4101
+ include('expression')
4102
+ ],
4103
+ '_list-expression': [
4104
+ (r',', Punctuation, '#pop'),
4105
+ include('expression')
4106
+ ],
4107
+ '_object-expression': [
4108
+ (r'has\b', Keyword.Declaration, '#pop'),
4109
+ include('_list-expression')
4110
+ ],
4111
+
4112
+ # Values
4113
+ 'value': [
4114
+ include('_whitespace'),
4115
+ # Strings
4116
+ (r'[%s][^@][%s]' % (_squote, _squote), String.Char, '#pop'),
4117
+ (r'([%s])(@{[0-9a-fA-F]{1,4}})([%s])' % (_squote, _squote),
4118
+ bygroups(String.Char, String.Escape, String.Char), '#pop'),
4119
+ (r'([%s])(@..)([%s])' % (_squote, _squote),
4120
+ bygroups(String.Char, String.Escape, String.Char), '#pop'),
4121
+ (r'[%s]' % _squote, String.Single, ('#pop', 'dictionary-word')),
4122
+ (r'[%s]' % _dquote, String.Double, ('#pop', 'string')),
4123
+ # Numbers
4124
+ (r'\$[+%s][0-9]*\.?[0-9]*([eE][+%s]?[0-9]+)?' % (_dash, _dash),
4125
+ Number.Float, '#pop'),
4126
+ (r'\$[0-9a-fA-F]+', Number.Hex, '#pop'),
4127
+ (r'\$\$[01]+', Number.Bin, '#pop'),
4128
+ (r'[0-9]+', Number.Integer, '#pop'),
4129
+ # Values prefixed by hashes
4130
+ (r'(##|#a\$)(%s)' % _name, bygroups(Operator, Name), '#pop'),
4131
+ (r'(#g\$)(%s)' % _name,
4132
+ bygroups(Operator, Name.Variable.Global), '#pop'),
4133
+ (r'#[nw]\$', Operator, ('#pop', 'obsolete-dictionary-word')),
4134
+ (r'(#r\$)(%s)' % _name, bygroups(Operator, Name.Function), '#pop'),
4135
+ (r'#', Name.Builtin, ('#pop', 'system-constant')),
4136
+ # System functions
4137
+ (r'(child|children|elder|eldest|glk|indirect|metaclass|parent|'
4138
+ r'random|sibling|younger|youngest)\b', Name.Builtin, '#pop'),
4139
+ # Metaclasses
4140
+ (r'(?i)(Class|Object|Routine|String)\b', Name.Builtin, '#pop'),
4141
+ # Veneer routines
4142
+ (r'(?i)(Box__Routine|CA__Pr|CDefArt|CInDefArt|Cl__Ms|'
4143
+ r'Copy__Primitive|CP__Tab|DA__Pr|DB__Pr|DefArt|Dynam__String|'
4144
+ r'EnglishNumber|Glk__Wrap|IA__Pr|IB__Pr|InDefArt|Main__|'
4145
+ r'Meta__class|OB__Move|OB__Remove|OC__Cl|OP__Pr|Print__Addr|'
4146
+ r'Print__PName|PrintShortName|RA__Pr|RA__Sc|RL__Pr|R_Process|'
4147
+ r'RT__ChG|RT__ChGt|RT__ChLDB|RT__ChLDW|RT__ChPR|RT__ChPrintA|'
4148
+ r'RT__ChPrintC|RT__ChPrintO|RT__ChPrintS|RT__ChPS|RT__ChR|'
4149
+ r'RT__ChSTB|RT__ChSTW|RT__ChT|RT__Err|RT__TrPS|RV__Pr|'
4150
+ r'Symb__Tab|Unsigned__Compare|WV__Pr|Z__Region)\b', Name.Builtin,
4151
+ '#pop'),
4152
+ # Other built-in symbols
4153
+ (r'(?i)(call|copy|create|DEBUG|destroy|DICT_CHAR_SIZE|'
4154
+ r'DICT_ENTRY_BYTES|DICT_IS_UNICODE|DICT_WORD_SIZE|false|'
4155
+ r'FLOAT_INFINITY|FLOAT_NAN|FLOAT_NINFINITY|GOBJFIELD_CHAIN|'
4156
+ r'GOBJFIELD_CHILD|GOBJFIELD_NAME|GOBJFIELD_PARENT|'
4157
+ r'GOBJFIELD_PROPTAB|GOBJFIELD_SIBLING|GOBJ_EXT_START|'
4158
+ r'GOBJ_TOTAL_LENGTH|Grammar__Version|INDIV_PROP_START|INFIX|'
4159
+ r'infix__watching|MODULE_MODE|name|nothing|NUM_ATTR_BYTES|print|'
4160
+ r'print_to_array|recreate|remaining|self|sender|STRICT_MODE|'
4161
+ r'sw__var|sys__glob0|sys__glob1|sys__glob2|sys_statusline_flag|'
4162
+ r'TARGET_GLULX|TARGET_ZCODE|temp__global2|temp__global3|'
4163
+ r'temp__global4|temp_global|true|USE_MODULES|WORDSIZE)\b',
4164
+ Name.Builtin, '#pop'),
4165
+ # Other values
4166
+ (_name, Name, '#pop')
4167
+ ],
4168
+ # Strings
4169
+ 'dictionary-word': [
4170
+ (r'[~^]+', String.Escape),
4171
+ (r'[^~^\\@({%s]+' % _squote, String.Single),
4172
+ (r'[({]', String.Single),
4173
+ (r'@{[0-9a-fA-F]{,4}}', String.Escape),
4174
+ (r'@..', String.Escape),
4175
+ (r'[%s]' % _squote, String.Single, '#pop')
4176
+ ],
4177
+ 'string': [
4178
+ (r'[~^]+', String.Escape),
4179
+ (r'[^~^\\@({%s]+' % _dquote, String.Double),
4180
+ (r'[({]', String.Double),
4181
+ (r'\\', String.Escape),
4182
+ (r'@(\\\s*[%s]\s*)*@((\\\s*[%s]\s*)*[0-9])*' %
4183
+ (_newline, _newline), String.Escape),
4184
+ (r'@(\\\s*[%s]\s*)*{((\\\s*[%s]\s*)*[0-9a-fA-F]){,4}'
4185
+ r'(\\\s*[%s]\s*)*}' % (_newline, _newline, _newline),
4186
+ String.Escape),
4187
+ (r'@(\\\s*[%s]\s*)*.(\\\s*[%s]\s*)*.' % (_newline, _newline),
4188
+ String.Escape),
4189
+ (r'[%s]' % _dquote, String.Double, '#pop')
4190
+ ],
4191
+ 'plain-string': [
4192
+ (r'[^~^\\({\[\]%s]+' % _dquote, String.Double),
4193
+ (r'[~^({\[\]]', String.Double),
4194
+ (r'\\', String.Escape),
4195
+ (r'[%s]' % _dquote, String.Double, '#pop')
4196
+ ],
4197
+ # Names
4198
+ '_constant': [
4199
+ include('_whitespace'),
4200
+ (_name, Name.Constant, '#pop'),
4201
+ include('value')
4202
+ ],
4203
+ '_global': [
4204
+ include('_whitespace'),
4205
+ (_name, Name.Variable.Global, '#pop'),
4206
+ include('value')
4207
+ ],
4208
+ 'label?': [
4209
+ include('_whitespace'),
4210
+ (r'(%s)?' % _name, Name.Label, '#pop')
4211
+ ],
4212
+ 'variable?': [
4213
+ include('_whitespace'),
4214
+ (r'(%s)?' % _name, Name.Variable, '#pop')
4215
+ ],
4216
+ # Values after hashes
4217
+ 'obsolete-dictionary-word': [
4218
+ (r'\S[a-zA-Z_0-9]*', String.Other, '#pop')
4219
+ ],
4220
+ 'system-constant': [
4221
+ include('_whitespace'),
4222
+ (_name, Name.Builtin, '#pop')
4223
+ ],
4224
+
4225
+ # Directives
4226
+ 'directive': [
4227
+ include('_whitespace'),
4228
+ (r'#', Punctuation),
4229
+ (r';', Punctuation, '#pop'),
4230
+ (r'\[', Punctuation,
4231
+ ('default', 'statements', 'locals', 'routine-name?')),
4232
+ (r'(?i)(abbreviate|endif|dictionary|ifdef|iffalse|ifndef|ifnot|'
4233
+ r'iftrue|ifv3|ifv5|release|serial|switches|system_file|version)'
4234
+ r'\b', Keyword, 'default'),
4235
+ (r'(?i)(array|global)\b', Keyword,
4236
+ ('default', 'directive-keyword?', '_global')),
4237
+ (r'(?i)attribute\b', Keyword, ('default', 'alias?', '_constant')),
4238
+ (r'(?i)class\b', Keyword,
4239
+ ('object-body', 'duplicates', 'class-name')),
4240
+ (r'(?i)(constant|default)\b', Keyword,
4241
+ ('default', 'expression', '_constant')),
4242
+ (r'(?i)(end\b)(.*)', bygroups(Keyword, Text)),
4243
+ (r'(?i)(extend|verb)\b', Keyword, 'grammar'),
4244
+ (r'(?i)fake_action\b', Keyword, ('default', '_constant')),
4245
+ (r'(?i)import\b', Keyword, 'manifest'),
4246
+ (r'(?i)(include|link)\b', Keyword,
4247
+ ('default', 'before-plain-string')),
4248
+ (r'(?i)(lowstring|undef)\b', Keyword, ('default', '_constant')),
4249
+ (r'(?i)message\b', Keyword, ('default', 'diagnostic')),
4250
+ (r'(?i)(nearby|object)\b', Keyword,
4251
+ ('object-body', '_object-head')),
4252
+ (r'(?i)property\b', Keyword,
4253
+ ('default', 'alias?', '_constant', 'property-keyword*')),
4254
+ (r'(?i)replace\b', Keyword,
4255
+ ('default', 'routine-name?', 'routine-name?')),
4256
+ (r'(?i)statusline\b', Keyword, ('default', 'directive-keyword?')),
4257
+ (r'(?i)stub\b', Keyword, ('default', 'routine-name?')),
4258
+ (r'(?i)trace\b', Keyword,
4259
+ ('default', 'trace-keyword?', 'trace-keyword?')),
4260
+ (r'(?i)zcharacter\b', Keyword,
4261
+ ('default', 'directive-keyword?', 'directive-keyword?')),
4262
+ (_name, Name.Class, ('object-body', '_object-head'))
4263
+ ],
4264
+ # [, Replace, Stub
4265
+ 'routine-name?': [
4266
+ include('_whitespace'),
4267
+ (r'(%s)?' % _name, Name.Function, '#pop')
4268
+ ],
4269
+ 'locals': [
4270
+ include('_whitespace'),
4271
+ (r';', Punctuation, '#pop'),
4272
+ (r'\*', Punctuation),
4273
+ (_name, Name.Variable)
4274
+ ],
4275
+ # Array
4276
+ 'many-values': [
4277
+ include('_whitespace'),
4278
+ (r';', Punctuation),
4279
+ (r'\]', Punctuation, '#pop'),
4280
+ (r':', Error),
4281
+ default(('expression', '_expression'))
4282
+ ],
4283
+ # Attribute, Property
4284
+ 'alias?': [
4285
+ include('_whitespace'),
4286
+ (r'alias\b', Keyword, ('#pop', '_constant')),
4287
+ default('#pop')
4288
+ ],
4289
+ # Class, Object, Nearby
4290
+ 'class-name': [
4291
+ include('_whitespace'),
4292
+ (r'(?=[,;]|(class|has|private|with)\b)', Text, '#pop'),
4293
+ (_name, Name.Class, '#pop')
4294
+ ],
4295
+ 'duplicates': [
4296
+ include('_whitespace'),
4297
+ (r'\(', Punctuation, ('#pop', 'expression', '_expression')),
4298
+ default('#pop')
4299
+ ],
4300
+ '_object-head': [
4301
+ (r'[%s]>' % _dash, Punctuation),
4302
+ (r'(class|has|private|with)\b', Keyword.Declaration, '#pop'),
4303
+ include('_global')
4304
+ ],
4305
+ 'object-body': [
4306
+ include('_whitespace'),
4307
+ (r';', Punctuation, '#pop:2'),
4308
+ (r',', Punctuation),
4309
+ (r'class\b', Keyword.Declaration, 'class-segment'),
4310
+ (r'(has|private|with)\b', Keyword.Declaration),
4311
+ (r':', Error),
4312
+ default(('_object-expression', '_expression'))
4313
+ ],
4314
+ 'class-segment': [
4315
+ include('_whitespace'),
4316
+ (r'(?=[,;]|(class|has|private|with)\b)', Text, '#pop'),
4317
+ (_name, Name.Class),
4318
+ default('value')
4319
+ ],
4320
+ # Extend, Verb
4321
+ 'grammar': [
4322
+ include('_whitespace'),
4323
+ (r'=', Punctuation, ('#pop', 'default')),
4324
+ (r'\*', Punctuation, ('#pop', 'grammar-line')),
4325
+ default('_directive-keyword')
4326
+ ],
4327
+ 'grammar-line': [
4328
+ include('_whitespace'),
4329
+ (r';', Punctuation, '#pop'),
4330
+ (r'[/*]', Punctuation),
4331
+ (r'[%s]>' % _dash, Punctuation, 'value'),
4332
+ (r'(noun|scope)\b', Keyword, '=routine'),
4333
+ default('_directive-keyword')
4334
+ ],
4335
+ '=routine': [
4336
+ include('_whitespace'),
4337
+ (r'=', Punctuation, 'routine-name?'),
4338
+ default('#pop')
4339
+ ],
4340
+ # Import
4341
+ 'manifest': [
4342
+ include('_whitespace'),
4343
+ (r';', Punctuation, '#pop'),
4344
+ (r',', Punctuation),
4345
+ (r'(?i)(global\b)?', Keyword, '_global')
4346
+ ],
4347
+ # Include, Link, Message
4348
+ 'diagnostic': [
4349
+ include('_whitespace'),
4350
+ (r'[%s]' % _dquote, String.Double, ('#pop', 'message-string')),
4351
+ default(('#pop', 'before-plain-string', 'directive-keyword?'))
4352
+ ],
4353
+ 'before-plain-string': [
4354
+ include('_whitespace'),
4355
+ (r'[%s]' % _dquote, String.Double, ('#pop', 'plain-string'))
4356
+ ],
4357
+ 'message-string': [
4358
+ (r'[~^]+', String.Escape),
4359
+ include('plain-string')
4360
+ ],
4361
+
4362
+ # Keywords used in directives
4363
+ '_directive-keyword!': [
4364
+ include('_whitespace'),
4365
+ (r'(additive|alias|buffer|class|creature|data|error|fatalerror|'
4366
+ r'first|has|held|initial|initstr|last|long|meta|multi|'
4367
+ r'multiexcept|multiheld|multiinside|noun|number|only|private|'
4368
+ r'replace|reverse|scope|score|special|string|table|terminating|'
4369
+ r'time|topic|warning|with)\b', Keyword, '#pop'),
4370
+ (r'[%s]{1,2}>|[+=]' % _dash, Punctuation, '#pop')
4371
+ ],
4372
+ '_directive-keyword': [
4373
+ include('_directive-keyword!'),
4374
+ include('value')
4375
+ ],
4376
+ 'directive-keyword?': [
4377
+ include('_directive-keyword!'),
4378
+ default('#pop')
4379
+ ],
4380
+ 'property-keyword*': [
4381
+ include('_whitespace'),
4382
+ (r'(additive|long)\b', Keyword),
4383
+ default('#pop')
4384
+ ],
4385
+ 'trace-keyword?': [
4386
+ include('_whitespace'),
4387
+ (r'(assembly|dictionary|expressions|lines|linker|objects|off|on|'
4388
+ r'symbols|tokens|verbs)\b', Keyword, '#pop'),
4389
+ default('#pop')
4390
+ ],
4391
+
4392
+ # Statements
4393
+ 'statements': [
4394
+ include('_whitespace'),
4395
+ (r'\]', Punctuation, '#pop'),
4396
+ (r'[;{}]', Punctuation),
4397
+ (r'(box|break|continue|default|give|inversion|new_line|quit|read|'
4398
+ r'remove|return|rfalse|rtrue|spaces|string|until)\b', Keyword,
4399
+ 'default'),
4400
+ (r'(do|else)\b', Keyword),
4401
+ (r'(font|style)\b', Keyword,
4402
+ ('default', 'miscellaneous-keyword?')),
4403
+ (r'for\b', Keyword, ('for', '(?')),
4404
+ (r'(if|switch|while)', Keyword,
4405
+ ('expression', '_expression', '(?')),
4406
+ (r'(jump|save|restore)\b', Keyword, ('default', 'label?')),
4407
+ (r'objectloop\b', Keyword,
4408
+ ('_keyword-expression', 'variable?', '(?')),
4409
+ (r'print(_ret)?\b|(?=[%s])' % _dquote, Keyword, 'print-list'),
4410
+ (r'\.', Name.Label, 'label?'),
4411
+ (r'@', Keyword, 'opcode'),
4412
+ (r'#(?![agrnw]\$|#)', Punctuation, 'directive'),
4413
+ (r'<', Punctuation, 'default'),
4414
+ (r'(move\b)?', Keyword,
4415
+ ('default', '_keyword-expression', '_expression'))
4416
+ ],
4417
+ 'miscellaneous-keyword?': [
4418
+ include('_whitespace'),
4419
+ (r'(bold|fixed|from|near|off|on|reverse|roman|to|underline)\b',
4420
+ Keyword, '#pop'),
4421
+ (r'(a|A|an|address|char|name|number|object|property|string|the|'
4422
+ r'The)\b(?=(\s+|(![^%s]*))*\))' % _newline, Keyword.Pseudo,
4423
+ '#pop'),
4424
+ (r'%s(?=(\s+|(![^%s]*))*\))' % (_name, _newline), Name.Function,
4425
+ '#pop'),
4426
+ default('#pop')
4427
+ ],
4428
+ '(?': [
4429
+ include('_whitespace'),
4430
+ (r'\(?', Punctuation, '#pop')
4431
+ ],
4432
+ 'for': [
4433
+ include('_whitespace'),
4434
+ (r';?', Punctuation, ('_for-expression', '_expression'))
4435
+ ],
4436
+ 'print-list': [
4437
+ include('_whitespace'),
4438
+ (r';', Punctuation, '#pop'),
4439
+ (r':', Error),
4440
+ default(('_list-expression', '_expression', '_list-expression', 'form'))
4441
+ ],
4442
+ 'form': [
4443
+ include('_whitespace'),
4444
+ (r'\(', Punctuation, ('#pop', 'miscellaneous-keyword?')),
4445
+ default('#pop')
4446
+ ],
4447
+
4448
+ # Assembly
4449
+ 'opcode': [
4450
+ include('_whitespace'),
4451
+ (r'[%s]' % _dquote, String.Double, ('operands', 'plain-string')),
4452
+ (_name, Keyword, 'operands')
4453
+ ],
4454
+ 'operands': [
4455
+ (r':', Error),
4456
+ default(('_assembly-expression', '_expression'))
4457
+ ]
4458
+ }
4459
+
4460
+ def get_tokens_unprocessed(self, text):
4461
+ # 'in' is either a keyword or an operator.
4462
+ # If the token two tokens after 'in' is ')', 'in' is a keyword:
4463
+ # objectloop(a in b)
4464
+ # Otherwise, it is an operator:
4465
+ # objectloop(a in b && true)
4466
+ objectloop_queue = []
4467
+ objectloop_token_count = -1
4468
+ previous_token = None
4469
+ for index, token, value in RegexLexer.get_tokens_unprocessed(self,
4470
+ text):
4471
+ if previous_token is Name.Variable and value == 'in':
4472
+ objectloop_queue = [[index, token, value]]
4473
+ objectloop_token_count = 2
4474
+ elif objectloop_token_count > 0:
4475
+ if token not in Comment and token not in Text:
4476
+ objectloop_token_count -= 1
4477
+ objectloop_queue.append((index, token, value))
4478
+ else:
4479
+ if objectloop_token_count == 0:
4480
+ if objectloop_queue[-1][2] == ')':
4481
+ objectloop_queue[0][1] = Keyword
4482
+ while objectloop_queue:
4483
+ yield objectloop_queue.pop(0)
4484
+ objectloop_token_count = -1
4485
+ yield index, token, value
4486
+ if token not in Comment and token not in Text:
4487
+ previous_token = token
4488
+ while objectloop_queue:
4489
+ yield objectloop_queue.pop(0)
4490
+
4491
+
4492
+ class Inform7Lexer(RegexLexer):
4493
+ """
4494
+ For `Inform 7 <http://inform7.com/>`_ source code.
4495
+
4496
+ .. versionadded:: 2.0
4497
+ """
4498
+
4499
+ name = 'Inform 7'
4500
+ aliases = ['inform7', 'i7']
4501
+ filenames = ['*.ni', '*.i7x']
4502
+
4503
+ flags = re.MULTILINE | re.DOTALL | re.UNICODE
4504
+
4505
+ _dash = Inform6Lexer._dash
4506
+ _dquote = Inform6Lexer._dquote
4507
+ _newline = Inform6Lexer._newline
4508
+ _start = r'\A|(?<=[%s])' % _newline
4509
+
4510
+ # There are three variants of Inform 7, differing in how to
4511
+ # interpret at signs and braces in I6T. In top-level inclusions, at
4512
+ # signs in the first column are inweb syntax. In phrase definitions
4513
+ # and use options, tokens in braces are treated as I7. Use options
4514
+ # also interpret "{N}".
4515
+ tokens = {}
4516
+ token_variants = ['+i6t-not-inline', '+i6t-inline', '+i6t-use-option']
4517
+
4518
+ for level in token_variants:
4519
+ tokens[level] = {
4520
+ '+i6-root': list(Inform6Lexer.tokens['root']),
4521
+ '+i6t-root': [ # For Inform6TemplateLexer
4522
+ (r'[^%s]*' % Inform6Lexer._newline, Comment.Preproc,
4523
+ ('directive', '+p'))
4524
+ ],
4525
+ 'root': [
4526
+ (r'(\|?\s)+', Text),
4527
+ (r'\[', Comment.Multiline, '+comment'),
4528
+ (r'[%s]' % _dquote, Generic.Heading,
4529
+ ('+main', '+titling', '+titling-string')),
4530
+ default(('+main', '+heading?'))
4531
+ ],
4532
+ '+titling-string': [
4533
+ (r'[^%s]+' % _dquote, Generic.Heading),
4534
+ (r'[%s]' % _dquote, Generic.Heading, '#pop')
4535
+ ],
4536
+ '+titling': [
4537
+ (r'\[', Comment.Multiline, '+comment'),
4538
+ (r'[^%s.;:|%s]+' % (_dquote, _newline), Generic.Heading),
4539
+ (r'[%s]' % _dquote, Generic.Heading, '+titling-string'),
4540
+ (r'[%s]{2}|(?<=[\s%s])\|[\s%s]' % (_newline, _dquote, _dquote),
4541
+ Text, ('#pop', '+heading?')),
4542
+ (r'[.;:]|(?<=[\s%s])\|' % _dquote, Text, '#pop'),
4543
+ (r'[|%s]' % _newline, Generic.Heading)
4544
+ ],
4545
+ '+main': [
4546
+ (r'(?i)[^%s:a\[(|%s]+' % (_dquote, _newline), Text),
4547
+ (r'[%s]' % _dquote, String.Double, '+text'),
4548
+ (r':', Text, '+phrase-definition'),
4549
+ (r'(?i)\bas\b', Text, '+use-option'),
4550
+ (r'\[', Comment.Multiline, '+comment'),
4551
+ (r'(\([%s])(.*?)([%s]\))' % (_dash, _dash),
4552
+ bygroups(Punctuation,
4553
+ using(this, state=('+i6-root', 'directive'),
4554
+ i6t='+i6t-not-inline'), Punctuation)),
4555
+ (r'(%s|(?<=[\s;:.%s]))\|\s|[%s]{2,}' %
4556
+ (_start, _dquote, _newline), Text, '+heading?'),
4557
+ (r'(?i)[a(|%s]' % _newline, Text)
4558
+ ],
4559
+ '+phrase-definition': [
4560
+ (r'\s+', Text),
4561
+ (r'\[', Comment.Multiline, '+comment'),
4562
+ (r'(\([%s])(.*?)([%s]\))' % (_dash, _dash),
4563
+ bygroups(Punctuation,
4564
+ using(this, state=('+i6-root', 'directive',
4565
+ 'default', 'statements'),
4566
+ i6t='+i6t-inline'), Punctuation), '#pop'),
4567
+ default('#pop')
4568
+ ],
4569
+ '+use-option': [
4570
+ (r'\s+', Text),
4571
+ (r'\[', Comment.Multiline, '+comment'),
4572
+ (r'(\([%s])(.*?)([%s]\))' % (_dash, _dash),
4573
+ bygroups(Punctuation,
4574
+ using(this, state=('+i6-root', 'directive'),
4575
+ i6t='+i6t-use-option'), Punctuation), '#pop'),
4576
+ default('#pop')
4577
+ ],
4578
+ '+comment': [
4579
+ (r'[^\[\]]+', Comment.Multiline),
4580
+ (r'\[', Comment.Multiline, '#push'),
4581
+ (r'\]', Comment.Multiline, '#pop')
4582
+ ],
4583
+ '+text': [
4584
+ (r'[^\[%s]+' % _dquote, String.Double),
4585
+ (r'\[.*?\]', String.Interpol),
4586
+ (r'[%s]' % _dquote, String.Double, '#pop')
4587
+ ],
4588
+ '+heading?': [
4589
+ (r'(\|?\s)+', Text),
4590
+ (r'\[', Comment.Multiline, '+comment'),
4591
+ (r'[%s]{4}\s+' % _dash, Text, '+documentation-heading'),
4592
+ (r'[%s]{1,3}' % _dash, Text),
4593
+ (r'(?i)(volume|book|part|chapter|section)\b[^%s]*' % _newline,
4594
+ Generic.Heading, '#pop'),
4595
+ default('#pop')
4596
+ ],
4597
+ '+documentation-heading': [
4598
+ (r'\s+', Text),
4599
+ (r'\[', Comment.Multiline, '+comment'),
4600
+ (r'(?i)documentation\s+', Text, '+documentation-heading2'),
4601
+ default('#pop')
4602
+ ],
4603
+ '+documentation-heading2': [
4604
+ (r'\s+', Text),
4605
+ (r'\[', Comment.Multiline, '+comment'),
4606
+ (r'[%s]{4}\s' % _dash, Text, '+documentation'),
4607
+ default('#pop:2')
4608
+ ],
4609
+ '+documentation': [
4610
+ (r'(?i)(%s)\s*(chapter|example)\s*:[^%s]*' %
4611
+ (_start, _newline), Generic.Heading),
4612
+ (r'(?i)(%s)\s*section\s*:[^%s]*' % (_start, _newline),
4613
+ Generic.Subheading),
4614
+ (r'((%s)\t.*?[%s])+' % (_start, _newline),
4615
+ using(this, state='+main')),
4616
+ (r'[^%s\[]+|[%s\[]' % (_newline, _newline), Text),
4617
+ (r'\[', Comment.Multiline, '+comment'),
4618
+ ],
4619
+ '+i6t-not-inline': [
4620
+ (r'(%s)@c( .*?)?([%s]|\Z)' % (_start, _newline),
4621
+ Comment.Preproc),
4622
+ (r'(%s)@([%s]+|Purpose:)[^%s]*' % (_start, _dash, _newline),
4623
+ Comment.Preproc),
4624
+ (r'(%s)@p( .*?)?([%s]|\Z)' % (_start, _newline),
4625
+ Generic.Heading, '+p')
4626
+ ],
4627
+ '+i6t-use-option': [
4628
+ include('+i6t-not-inline'),
4629
+ (r'({)(N)(})', bygroups(Punctuation, Text, Punctuation))
4630
+ ],
4631
+ '+i6t-inline': [
4632
+ (r'({)(\S[^}]*)?(})',
4633
+ bygroups(Punctuation, using(this, state='+main'),
4634
+ Punctuation))
4635
+ ],
4636
+ '+i6t': [
4637
+ (r'({[%s])(![^}]*)(}?)' % _dash,
4638
+ bygroups(Punctuation, Comment.Single, Punctuation)),
4639
+ (r'({[%s])(lines)(:)([^}]*)(}?)' % _dash,
4640
+ bygroups(Punctuation, Keyword, Punctuation, Text,
4641
+ Punctuation), '+lines'),
4642
+ (r'({[%s])([^:}]*)(:?)([^}]*)(}?)' % _dash,
4643
+ bygroups(Punctuation, Keyword, Punctuation, Text,
4644
+ Punctuation)),
4645
+ (r'(\(\+)(.*?)(\+\)|\Z)',
4646
+ bygroups(Punctuation, using(this, state='+main'),
4647
+ Punctuation))
4648
+ ],
4649
+ '+p': [
4650
+ (r'[^@]+', Comment.Preproc),
4651
+ (r'(%s)@c( .*?)?([%s]|\Z)' % (_start, _newline),
4652
+ Comment.Preproc, '#pop'),
4653
+ (r'(%s)@([%s]|Purpose:)' % (_start, _dash), Comment.Preproc),
4654
+ (r'(%s)@p( .*?)?([%s]|\Z)' % (_start, _newline),
4655
+ Generic.Heading),
4656
+ (r'@', Comment.Preproc)
4657
+ ],
4658
+ '+lines': [
4659
+ (r'(%s)@c( .*?)?([%s]|\Z)' % (_start, _newline),
4660
+ Comment.Preproc),
4661
+ (r'(%s)@([%s]|Purpose:)[^%s]*' % (_start, _dash, _newline),
4662
+ Comment.Preproc),
4663
+ (r'(%s)@p( .*?)?([%s]|\Z)' % (_start, _newline),
4664
+ Generic.Heading, '+p'),
4665
+ (r'(%s)@[a-zA-Z_0-9]*[ %s]' % (_start, _newline), Keyword),
4666
+ (r'![^%s]*' % _newline, Comment.Single),
4667
+ (r'({)([%s]endlines)(})' % _dash,
4668
+ bygroups(Punctuation, Keyword, Punctuation), '#pop'),
4669
+ (r'[^@!{]+?([%s]|\Z)|.' % _newline, Text)
4670
+ ]
4671
+ }
4672
+ # Inform 7 can include snippets of Inform 6 template language,
4673
+ # so all of Inform6Lexer's states are copied here, with
4674
+ # modifications to account for template syntax. Inform7Lexer's
4675
+ # own states begin with '+' to avoid name conflicts. Some of
4676
+ # Inform6Lexer's states begin with '_': these are not modified.
4677
+ # They deal with template syntax either by including modified
4678
+ # states, or by matching r'' then pushing to modified states.
4679
+ for token in Inform6Lexer.tokens:
4680
+ if token == 'root':
4681
+ continue
4682
+ tokens[level][token] = list(Inform6Lexer.tokens[token])
4683
+ if not token.startswith('_'):
4684
+ tokens[level][token][:0] = [include('+i6t'), include(level)]
4685
+
4686
+ def __init__(self, **options):
4687
+ level = options.get('i6t', '+i6t-not-inline')
4688
+ if level not in self._all_tokens:
4689
+ self._tokens = self.__class__.process_tokendef(level)
4690
+ else:
4691
+ self._tokens = self._all_tokens[level]
4692
+ RegexLexer.__init__(self, **options)
4693
+
4694
+
4695
+ class Inform6TemplateLexer(Inform7Lexer):
4696
+ """
4697
+ For `Inform 6 template
4698
+ <http://inform7.com/sources/src/i6template/Woven/index.html>`_ code.
4699
+
4700
+ .. versionadded:: 2.0
4701
+ """
4702
+
4703
+ name = 'Inform 6 template'
4704
+ aliases = ['i6t']
4705
+ filenames = ['*.i6t']
4706
+
4707
+ def get_tokens_unprocessed(self, text, stack=('+i6t-root',)):
4708
+ return Inform7Lexer.get_tokens_unprocessed(self, text, stack)
4709
+
4710
+
4711
+ class MqlLexer(CppLexer):
4712
+ """
4713
+ For `MQL4 <http://docs.mql4.com/>`_ and
4714
+ `MQL5 <http://www.mql5.com/en/docs>`_ source code.
4715
+
4716
+ .. versionadded:: 2.0
4717
+ """
4718
+ name = 'MQL'
4719
+ aliases = ['mql', 'mq4', 'mq5', 'mql4', 'mql5']
4720
+ filenames = ['*.mq4', '*.mq5', '*.mqh']
4721
+ mimetypes = ['text/x-mql']
4722
+
4723
+ tokens = {
4724
+ 'statements': [
4725
+ (r'(input|_Digits|_Point|_LastError|_Period|_RandomSeed|'
4726
+ r'_StopFlag|_Symbol|_UninitReason|'
4727
+ r'Ask|Bars|Bid|Close|Digits|High|Low|Open|Point|Time|Volume)\b',
4728
+ Keyword),
4729
+ (r'(void|char|uchar|bool|short|ushort|int|uint|color|long|ulong|datetime|'
4730
+ r'float|double|string)\b',
4731
+ Keyword.Type),
4732
+ (r'(Alert|CheckPointer|Comment|DebugBreak|ExpertRemove|'
4733
+ r'GetPointer|GetTickCount|MessageBox|PeriodSeconds|PlaySound|'
4734
+ r'Print|PrintFormat|ResetLastError|ResourceCreate|ResourceFree|'
4735
+ r'ResourceReadImage|ResourceSave|SendFTP|SendMail|SendNotification|'
4736
+ r'Sleep|TerminalClose|TesterStatistics|ZeroMemory|'
4737
+ r'ArrayBsearch|ArrayCopy|ArrayCompare|ArrayFree|ArrayGetAsSeries|'
4738
+ r'ArrayInitialize|ArrayFill|ArrayIsSeries|ArrayIsDynamic|'
4739
+ r'ArrayMaximum|ArrayMinimum|ArrayRange|ArrayResize|'
4740
+ r'ArraySetAsSeries|ArraySize|ArraySort|ArrayCopyRates|'
4741
+ r'ArrayCopySeries|ArrayDimension|'
4742
+ r'CharToString|DoubleToString|EnumToString|NormalizeDouble|'
4743
+ r'StringToDouble|StringToInteger|StringToTime|TimeToString|'
4744
+ r'IntegerToString|ShortToString|ShortArrayToString|'
4745
+ r'StringToShortArray|CharArrayToString|StringToCharArray|'
4746
+ r'ColorToARGB|ColorToString|StringToColor|StringFormat|'
4747
+ r'CharToStr|DoubleToStr|StrToDouble|StrToInteger|StrToTime|TimeToStr|'
4748
+ r'MathAbs|MathArccos|MathArcsin|MathArctan|MathCeil|MathCos|MathExp|'
4749
+ r'MathFloor|MathLog|MathMax|MathMin|MathMod|MathPow|MathRand|'
4750
+ r'MathRound|MathSin|MathSqrt|MathSrand|MathTan|MathIsValidNumber|'
4751
+ r'StringAdd|StringBufferLen|StringCompare|StringConcatenate|StringFill|'
4752
+ r'StringFind|StringGetCharacter|StringInit|StringLen|StringReplace|'
4753
+ r'StringSetCharacter|StringSplit|StringSubstr|StringToLower|StringToUpper|'
4754
+ r'StringTrimLeft|StringTrimRight|StringGetChar|StringSetChar|'
4755
+ r'TimeCurrent|TimeTradeServer|TimeLocal|TimeGMT|TimeDaylightSavings|'
4756
+ r'TimeGMTOffset|TimeToStruct|StructToTime|Day|DayOfWeek|DayOfYear|'
4757
+ r'Hour|Minute|Month|Seconds|TimeDay|TimeDayOfWeek|TimeDayOfYear|TimeHour|'
4758
+ r'TimeMinute|TimeMonth|TimeSeconds|TimeYear|Year|'
4759
+ r'AccountInfoDouble|AccountInfoInteger|AccountInfoString|AccountBalance|'
4760
+ r'AccountCredit|AccountCompany|AccountCurrency|AccountEquity|'
4761
+ r'AccountFreeMargin|AccountFreeMarginCheck|AccountFreeMarginMode|'
4762
+ r'AccountLeverage|AccountMargin|AccountName|AccountNumber|AccountProfit|'
4763
+ r'AccountServer|AccountStopoutLevel|AccountStopoutMode|'
4764
+ r'GetLastError|IsStopped|UninitializeReason|MQLInfoInteger|MQLInfoString|'
4765
+ r'Symbol|Period|Digits|Point|IsConnected|IsDemo|IsDllsAllowed|'
4766
+ r'IsExpertEnabled|IsLibrariesAllowed|IsOptimization|IsTesting|'
4767
+ r'IsTradeAllowed|'
4768
+ r'IsTradeContextBusy|IsVisualMode|TerminalCompany|TerminalName|'
4769
+ r'TerminalPath|'
4770
+ r'SymbolsTotal|SymbolName|SymbolSelect|SymbolIsSynchronized|'
4771
+ r'SymbolInfoDouble|'
4772
+ r'SymbolInfoInteger|SymbolInfoString|SymbolInfoTick|'
4773
+ r'SymbolInfoSessionQuote|'
4774
+ r'SymbolInfoSessionTrade|MarketInfo|'
4775
+ r'SeriesInfoInteger|CopyRates|CopyTime|CopyOpen|'
4776
+ r'CopyHigh|CopyLow|CopyClose|'
4777
+ r'CopyTickVolume|CopyRealVolume|CopySpread|iBars|iBarShift|iClose|'
4778
+ r'iHigh|iHighest|iLow|iLowest|iOpen|iTime|iVolume|'
4779
+ r'HideTestIndicators|Period|RefreshRates|Symbol|WindowBarsPerChart|'
4780
+ r'WindowExpertName|WindowFind|WindowFirstVisibleBar|WindowHandle|'
4781
+ r'WindowIsVisible|WindowOnDropped|WindowPriceMax|WindowPriceMin|'
4782
+ r'WindowPriceOnDropped|WindowRedraw|WindowScreenShot|'
4783
+ r'WindowTimeOnDropped|WindowsTotal|WindowXOnDropped|WindowYOnDropped|'
4784
+ r'OrderClose|OrderCloseBy|OrderClosePrice|OrderCloseTime|OrderComment|'
4785
+ r'OrderCommission|OrderDelete|OrderExpiration|OrderLots|OrderMagicNumber|'
4786
+ r'OrderModify|OrderOpenPrice|OrderOpenTime|OrderPrint|OrderProfit|'
4787
+ r'OrderSelect|OrderSend|OrdersHistoryTotal|OrderStopLoss|OrdersTotal|'
4788
+ r'OrderSwap|OrderSymbol|OrderTakeProfit|OrderTicket|OrderType|'
4789
+ r'GlobalVariableCheck|GlobalVariableTime|'
4790
+ r'GlobalVariableDel|GlobalVariableGet|GlobalVariableName|'
4791
+ r'GlobalVariableSet|GlobalVariablesFlush|GlobalVariableTemp|'
4792
+ r'GlobalVariableSetOnCondition|GlobalVariablesDeleteAll|'
4793
+ r'GlobalVariablesTotal|GlobalVariableCheck|GlobalVariableTime|'
4794
+ r'GlobalVariableDel|GlobalVariableGet|'
4795
+ r'GlobalVariableName|GlobalVariableSet|GlobalVariablesFlush|'
4796
+ r'GlobalVariableTemp|GlobalVariableSetOnCondition|'
4797
+ r'GlobalVariablesDeleteAll|GlobalVariablesTotal|'
4798
+ r'GlobalVariableCheck|GlobalVariableTime|GlobalVariableDel|'
4799
+ r'GlobalVariableGet|GlobalVariableName|GlobalVariableSet|'
4800
+ r'GlobalVariablesFlush|GlobalVariableTemp|'
4801
+ r'GlobalVariableSetOnCondition|GlobalVariablesDeleteAll|'
4802
+ r'GlobalVariablesTotal|'
4803
+ r'FileFindFirst|FileFindNext|FileFindClose|FileOpen|FileDelete|'
4804
+ r'FileFlush|FileGetInteger|FileIsEnding|FileIsLineEnding|'
4805
+ r'FileClose|FileIsExist|FileCopy|FileMove|FileReadArray|'
4806
+ r'FileReadBool|FileReadDatetime|FileReadDouble|FileReadFloat|'
4807
+ r'FileReadInteger|FileReadLong|FileReadNumber|FileReadString|'
4808
+ r'FileReadStruct|FileSeek|FileSize|FileTell|FileWrite|'
4809
+ r'FileWriteArray|FileWriteDouble|FileWriteFloat|FileWriteInteger|'
4810
+ r'FileWriteLong|FileWriteString|FileWriteStruct|FolderCreate|'
4811
+ r'FolderDelete|FolderClean|FileOpenHistory|'
4812
+ r'IndicatorSetDouble|IndicatorSetInteger|IndicatorSetString|'
4813
+ r'SetIndexBuffer|IndicatorBuffers|IndicatorCounted|IndicatorDigits|'
4814
+ r'IndicatorShortName|SetIndexArrow|SetIndexDrawBegin|'
4815
+ r'SetIndexEmptyValue|SetIndexLabel|SetIndexShift|'
4816
+ r'SetIndexStyle|SetLevelStyle|SetLevelValue|'
4817
+ r'ObjectCreate|ObjectName|ObjectDelete|ObjectsDeleteAll|'
4818
+ r'ObjectFind|ObjectGetTimeByValue|ObjectGetValueByTime|'
4819
+ r'ObjectMove|ObjectsTotal|ObjectGetDouble|ObjectGetInteger|'
4820
+ r'ObjectGetString|ObjectSetDouble|ObjectSetInteger|'
4821
+ r'ObjectSetString|TextSetFont|TextOut|TextGetSize|'
4822
+ r'ObjectDescription|ObjectGet|ObjectGetFiboDescription|'
4823
+ r'ObjectGetShiftByValue|ObjectGetValueByShift|ObjectSet|'
4824
+ r'ObjectSetFiboDescription|ObjectSetText|ObjectType|'
4825
+ r'iAC|iAD|iADX|iAlligator|iAO|iATR|iBearsPower|'
4826
+ r'iBands|iBandsOnArray|iBullsPower|iCCI|iCCIOnArray|'
4827
+ r'iCustom|iDeMarker|iEnvelopes|iEnvelopesOnArray|'
4828
+ r'iForce|iFractals|iGator|iIchimoku|iBWMFI|iMomentum|'
4829
+ r'iMomentumOnArray|iMFI|iMA|iMAOnArray|iOsMA|iMACD|'
4830
+ r'iOBV|iSAR|iRSI|iRSIOnArray|iRVI|iStdDev|iStdDevOnArray|'
4831
+ r'iStochastic|iWPR|'
4832
+ r'EventSetMillisecondTimer|EventSetTimer|'
4833
+ r'EventKillTimer|EventChartCustom)\b', Name.Function),
4834
+ (r'(CHARTEVENT_KEYDOWN|CHARTEVENT_MOUSE_MOVE|'
4835
+ r'CHARTEVENT_OBJECT_CREATE|'
4836
+ r'CHARTEVENT_OBJECT_CHANGE|CHARTEVENT_OBJECT_DELETE|'
4837
+ r'CHARTEVENT_CLICK|'
4838
+ r'CHARTEVENT_OBJECT_CLICK|CHARTEVENT_OBJECT_DRAG|'
4839
+ r'CHARTEVENT_OBJECT_ENDEDIT|'
4840
+ r'CHARTEVENT_CHART_CHANGE|CHARTEVENT_CUSTOM|'
4841
+ r'CHARTEVENT_CUSTOM_LAST|'
4842
+ r'PERIOD_CURRENT|PERIOD_M1|PERIOD_M2|PERIOD_M3|'
4843
+ r'PERIOD_M4|PERIOD_M5|'
4844
+ r'PERIOD_M6|PERIOD_M10|PERIOD_M12|PERIOD_M15|'
4845
+ r'PERIOD_M20|PERIOD_M30|'
4846
+ r'PERIOD_H1|PERIOD_H2|PERIOD_H3|PERIOD_H4|'
4847
+ r'PERIOD_H6|PERIOD_H8|'
4848
+ r'PERIOD_H12|PERIOD_D1|PERIOD_W1|PERIOD_MN1|'
4849
+ r'CHART_IS_OBJECT|CHART_BRING_TO_TOP|'
4850
+ r'CHART_MOUSE_SCROLL|CHART_EVENT_MOUSE_MOVE|'
4851
+ r'CHART_EVENT_OBJECT_CREATE|'
4852
+ r'CHART_EVENT_OBJECT_DELETE|CHART_MODE|CHART_FOREGROUND|'
4853
+ r'CHART_SHIFT|'
4854
+ r'CHART_AUTOSCROLL|CHART_SCALE|CHART_SCALEFIX|'
4855
+ r'CHART_SCALEFIX_11|'
4856
+ r'CHART_SCALE_PT_PER_BAR|CHART_SHOW_OHLC|'
4857
+ r'CHART_SHOW_BID_LINE|'
4858
+ r'CHART_SHOW_ASK_LINE|CHART_SHOW_LAST_LINE|'
4859
+ r'CHART_SHOW_PERIOD_SEP|'
4860
+ r'CHART_SHOW_GRID|CHART_SHOW_VOLUMES|'
4861
+ r'CHART_SHOW_OBJECT_DESCR|'
4862
+ r'CHART_VISIBLE_BARS|CHART_WINDOWS_TOTAL|'
4863
+ r'CHART_WINDOW_IS_VISIBLE|'
4864
+ r'CHART_WINDOW_HANDLE|CHART_WINDOW_YDISTANCE|'
4865
+ r'CHART_FIRST_VISIBLE_BAR|'
4866
+ r'CHART_WIDTH_IN_BARS|CHART_WIDTH_IN_PIXELS|'
4867
+ r'CHART_HEIGHT_IN_PIXELS|'
4868
+ r'CHART_COLOR_BACKGROUND|CHART_COLOR_FOREGROUND|'
4869
+ r'CHART_COLOR_GRID|'
4870
+ r'CHART_COLOR_VOLUME|CHART_COLOR_CHART_UP|'
4871
+ r'CHART_COLOR_CHART_DOWN|'
4872
+ r'CHART_COLOR_CHART_LINE|CHART_COLOR_CANDLE_BULL|'
4873
+ r'CHART_COLOR_CANDLE_BEAR|'
4874
+ r'CHART_COLOR_BID|CHART_COLOR_ASK|CHART_COLOR_LAST|'
4875
+ r'CHART_COLOR_STOP_LEVEL|'
4876
+ r'CHART_SHOW_TRADE_LEVELS|CHART_DRAG_TRADE_LEVELS|'
4877
+ r'CHART_SHOW_DATE_SCALE|'
4878
+ r'CHART_SHOW_PRICE_SCALE|CHART_SHIFT_SIZE|'
4879
+ r'CHART_FIXED_POSITION|'
4880
+ r'CHART_FIXED_MAX|CHART_FIXED_MIN|CHART_POINTS_PER_BAR|'
4881
+ r'CHART_PRICE_MIN|'
4882
+ r'CHART_PRICE_MAX|CHART_COMMENT|CHART_BEGIN|'
4883
+ r'CHART_CURRENT_POS|CHART_END|'
4884
+ r'CHART_BARS|CHART_CANDLES|CHART_LINE|CHART_VOLUME_HIDE|'
4885
+ r'CHART_VOLUME_TICK|CHART_VOLUME_REAL|'
4886
+ r'OBJ_VLINE|OBJ_HLINE|OBJ_TREND|OBJ_TRENDBYANGLE|OBJ_CYCLES|'
4887
+ r'OBJ_CHANNEL|OBJ_STDDEVCHANNEL|OBJ_REGRESSION|OBJ_PITCHFORK|'
4888
+ r'OBJ_GANNLINE|OBJ_GANNFAN|OBJ_GANNGRID|OBJ_FIBO|'
4889
+ r'OBJ_FIBOTIMES|OBJ_FIBOFAN|OBJ_FIBOARC|OBJ_FIBOCHANNEL|'
4890
+ r'OBJ_EXPANSION|OBJ_RECTANGLE|OBJ_TRIANGLE|OBJ_ELLIPSE|'
4891
+ r'OBJ_ARROW_THUMB_UP|OBJ_ARROW_THUMB_DOWN|'
4892
+ r'OBJ_ARROW_UP|OBJ_ARROW_DOWN|'
4893
+ r'OBJ_ARROW_STOP|OBJ_ARROW_CHECK|OBJ_ARROW_LEFT_PRICE|'
4894
+ r'OBJ_ARROW_RIGHT_PRICE|OBJ_ARROW_BUY|OBJ_ARROW_SELL|'
4895
+ r'OBJ_ARROW|'
4896
+ r'OBJ_TEXT|OBJ_LABEL|OBJ_BUTTON|OBJ_BITMAP|'
4897
+ r'OBJ_BITMAP_LABEL|'
4898
+ r'OBJ_EDIT|OBJ_EVENT|OBJ_RECTANGLE_LABEL|'
4899
+ r'OBJPROP_TIME1|OBJPROP_PRICE1|OBJPROP_TIME2|'
4900
+ r'OBJPROP_PRICE2|OBJPROP_TIME3|'
4901
+ r'OBJPROP_PRICE3|OBJPROP_COLOR|OBJPROP_STYLE|'
4902
+ r'OBJPROP_WIDTH|'
4903
+ r'OBJPROP_BACK|OBJPROP_RAY|OBJPROP_ELLIPSE|'
4904
+ r'OBJPROP_SCALE|'
4905
+ r'OBJPROP_ANGLE|OBJPROP_ARROWCODE|OBJPROP_TIMEFRAMES|'
4906
+ r'OBJPROP_DEVIATION|OBJPROP_FONTSIZE|OBJPROP_CORNER|'
4907
+ r'OBJPROP_XDISTANCE|OBJPROP_YDISTANCE|OBJPROP_FIBOLEVELS|'
4908
+ r'OBJPROP_LEVELCOLOR|OBJPROP_LEVELSTYLE|OBJPROP_LEVELWIDTH|'
4909
+ r'OBJPROP_FIRSTLEVEL|OBJPROP_COLOR|OBJPROP_STYLE|OBJPROP_WIDTH|'
4910
+ r'OBJPROP_BACK|OBJPROP_ZORDER|OBJPROP_FILL|OBJPROP_HIDDEN|'
4911
+ r'OBJPROP_SELECTED|OBJPROP_READONLY|OBJPROP_TYPE|OBJPROP_TIME|'
4912
+ r'OBJPROP_SELECTABLE|OBJPROP_CREATETIME|OBJPROP_LEVELS|'
4913
+ r'OBJPROP_LEVELCOLOR|OBJPROP_LEVELSTYLE|OBJPROP_LEVELWIDTH|'
4914
+ r'OBJPROP_ALIGN|OBJPROP_FONTSIZE|OBJPROP_RAY_RIGHT|OBJPROP_RAY|'
4915
+ r'OBJPROP_ELLIPSE|OBJPROP_ARROWCODE|OBJPROP_TIMEFRAMES|OBJPROP_ANCHOR|'
4916
+ r'OBJPROP_XDISTANCE|OBJPROP_YDISTANCE|OBJPROP_DRAWLINES|OBJPROP_STATE|'
4917
+ r'OBJPROP_CHART_ID|OBJPROP_XSIZE|OBJPROP_YSIZE|OBJPROP_XOFFSET|'
4918
+ r'OBJPROP_YOFFSET|OBJPROP_PERIOD|OBJPROP_DATE_SCALE|OBJPROP_PRICE_SCALE|'
4919
+ r'OBJPROP_CHART_SCALE|OBJPROP_BGCOLOR|OBJPROP_CORNER|OBJPROP_BORDER_TYPE|'
4920
+ r'OBJPROP_BORDER_COLOR|OBJPROP_PRICE|OBJPROP_LEVELVALUE|OBJPROP_SCALE|'
4921
+ r'OBJPROP_ANGLE|OBJPROP_DEVIATION|'
4922
+ r'OBJPROP_NAME|OBJPROP_TEXT|OBJPROP_TOOLTIP|OBJPROP_LEVELTEXT|'
4923
+ r'OBJPROP_FONT|OBJPROP_BMPFILE|OBJPROP_SYMBOL|'
4924
+ r'BORDER_FLAT|BORDER_RAISED|BORDER_SUNKEN|ALIGN_LEFT|ALIGN_CENTER|'
4925
+ r'ALIGN_RIGHT|ANCHOR_LEFT_UPPER|ANCHOR_LEFT|ANCHOR_LEFT_LOWER|'
4926
+ r'ANCHOR_LOWER|ANCHOR_RIGHT_LOWER|ANCHOR_RIGHT|ANCHOR_RIGHT_UPPER|'
4927
+ r'ANCHOR_UPPER|ANCHOR_CENTER|ANCHOR_TOP|ANCHOR_BOTTOM|'
4928
+ r'CORNER_LEFT_UPPER|CORNER_LEFT_LOWER|CORNER_RIGHT_LOWER|'
4929
+ r'CORNER_RIGHT_UPPER|'
4930
+ r'OBJ_NO_PERIODS|EMPTY|OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|'
4931
+ r'OBJ_PERIOD_M30|OBJ_PERIOD_H1|OBJ_PERIOD_H4|OBJ_PERIOD_D1|'
4932
+ r'OBJ_PERIOD_W1|OBJ_PERIOD_MN1|OBJ_ALL_PERIODS|'
4933
+ r'GANN_UP_TREND|GANN_DOWN_TREND|'
4934
+ r'((clr)?(Black|DarkGreen|DarkSlateGray|Olive|'
4935
+ r'Green|Teal|Navy|Purple|'
4936
+ r'Maroon|Indigo|MidnightBlue|DarkBlue|'
4937
+ r'DarkOliveGreen|SaddleBrown|'
4938
+ r'ForestGreen|OliveDrab|SeaGreen|'
4939
+ r'DarkGoldenrod|DarkSlateBlue|'
4940
+ r'Sienna|MediumBlue|Brown|DarkTurquoise|'
4941
+ r'DimGray|LightSeaGreen|'
4942
+ r'DarkViolet|FireBrick|MediumVioletRed|'
4943
+ r'MediumSeaGreen|Chocolate|'
4944
+ r'Crimson|SteelBlue|Goldenrod|MediumSpringGreen|'
4945
+ r'LawnGreen|CadetBlue|'
4946
+ r'DarkOrchid|YellowGreen|LimeGreen|OrangeRed|'
4947
+ r'DarkOrange|Orange|'
4948
+ r'Gold|Yellow|Chartreuse|Lime|SpringGreen|'
4949
+ r'Aqua|DeepSkyBlue|Blue|'
4950
+ r'Magenta|Red|Gray|SlateGray|Peru|BlueViolet|'
4951
+ r'LightSlateGray|DeepPink|'
4952
+ r'MediumTurquoise|DodgerBlue|Turquoise|RoyalBlue|'
4953
+ r'SlateBlue|DarkKhaki|'
4954
+ r'IndianRed|MediumOrchid|GreenYellow|'
4955
+ r'MediumAquamarine|DarkSeaGreen|'
4956
+ r'Tomato|RosyBrown|Orchid|MediumPurple|'
4957
+ r'PaleVioletRed|Coral|CornflowerBlue|'
4958
+ r'DarkGray|SandyBrown|MediumSlateBlue|'
4959
+ r'Tan|DarkSalmon|BurlyWood|'
4960
+ r'HotPink|Salmon|Violet|LightCoral|SkyBlue|'
4961
+ r'LightSalmon|Plum|'
4962
+ r'Khaki|LightGreen|Aquamarine|Silver|'
4963
+ r'LightSkyBlue|LightSteelBlue|'
4964
+ r'LightBlue|PaleGreen|Thistle|PowderBlue|'
4965
+ r'PaleGoldenrod|PaleTurquoise|'
4966
+ r'LightGray|Wheat|NavajoWhite|Moccasin|'
4967
+ r'LightPink|Gainsboro|PeachPuff|'
4968
+ r'Pink|Bisque|LightGoldenrod|BlanchedAlmond|'
4969
+ r'LemonChiffon|Beige|'
4970
+ r'AntiqueWhite|PapayaWhip|Cornsilk|'
4971
+ r'LightYellow|LightCyan|Linen|'
4972
+ r'Lavender|MistyRose|OldLace|WhiteSmoke|'
4973
+ r'Seashell|Ivory|Honeydew|'
4974
+ r'AliceBlue|LavenderBlush|MintCream|Snow|White))|'
4975
+ r'SYMBOL_THUMBSUP|SYMBOL_THUMBSDOWN|'
4976
+ r'SYMBOL_ARROWUP|SYMBOL_ARROWDOWN|'
4977
+ r'SYMBOL_STOPSIGN|SYMBOL_CHECKSIGN|'
4978
+ r'SYMBOL_LEFTPRICE|SYMBOL_RIGHTPRICE|'
4979
+ r'PRICE_CLOSE|PRICE_OPEN|PRICE_HIGH|PRICE_LOW|'
4980
+ r'PRICE_MEDIAN|PRICE_TYPICAL|PRICE_WEIGHTED|'
4981
+ r'VOLUME_TICK|VOLUME_REAL|'
4982
+ r'STO_LOWHIGH|STO_CLOSECLOSE|'
4983
+ r'MODE_OPEN|MODE_LOW|MODE_HIGH|MODE_CLOSE|MODE_VOLUME|MODE_TIME|'
4984
+ r'MODE_SMA|MODE_EMA|MODE_SMMA|MODE_LWMA|'
4985
+ r'MODE_MAIN|MODE_SIGNAL|MODE_MAIN|'
4986
+ r'MODE_PLUSDI|MODE_MINUSDI|MODE_UPPER|'
4987
+ r'MODE_LOWER|MODE_GATORJAW|MODE_GATORTEETH|'
4988
+ r'MODE_GATORLIPS|MODE_TENKANSEN|'
4989
+ r'MODE_KIJUNSEN|MODE_SENKOUSPANA|'
4990
+ r'MODE_SENKOUSPANB|MODE_CHINKOUSPAN|'
4991
+ r'DRAW_LINE|DRAW_SECTION|DRAW_HISTOGRAM|'
4992
+ r'DRAW_ARROW|DRAW_ZIGZAG|DRAW_NONE|'
4993
+ r'STYLE_SOLID|STYLE_DASH|STYLE_DOT|'
4994
+ r'STYLE_DASHDOT|STYLE_DASHDOTDOT|'
4995
+ r'DRAW_NONE|DRAW_LINE|DRAW_SECTION|DRAW_HISTOGRAM|'
4996
+ r'DRAW_ARROW|DRAW_ZIGZAG|DRAW_FILLING|'
4997
+ r'INDICATOR_DATA|INDICATOR_COLOR_INDEX|'
4998
+ r'INDICATOR_CALCULATIONS|INDICATOR_DIGITS|'
4999
+ r'INDICATOR_HEIGHT|INDICATOR_LEVELS|'
5000
+ r'INDICATOR_LEVELCOLOR|INDICATOR_LEVELSTYLE|'
5001
+ r'INDICATOR_LEVELWIDTH|INDICATOR_MINIMUM|'
5002
+ r'INDICATOR_MAXIMUM|INDICATOR_LEVELVALUE|'
5003
+ r'INDICATOR_SHORTNAME|INDICATOR_LEVELTEXT|'
5004
+ r'TERMINAL_BUILD|TERMINAL_CONNECTED|'
5005
+ r'TERMINAL_DLLS_ALLOWED|TERMINAL_TRADE_ALLOWED|'
5006
+ r'TERMINAL_EMAIL_ENABLED|'
5007
+ r'TERMINAL_FTP_ENABLED|TERMINAL_MAXBARS|'
5008
+ r'TERMINAL_CODEPAGE|TERMINAL_CPU_CORES|'
5009
+ r'TERMINAL_DISK_SPACE|TERMINAL_MEMORY_PHYSICAL|'
5010
+ r'TERMINAL_MEMORY_TOTAL|'
5011
+ r'TERMINAL_MEMORY_AVAILABLE|TERMINAL_MEMORY_USED|'
5012
+ r'TERMINAL_X64|'
5013
+ r'TERMINAL_OPENCL_SUPPORT|TERMINAL_LANGUAGE|'
5014
+ r'TERMINAL_COMPANY|TERMINAL_NAME|'
5015
+ r'TERMINAL_PATH|TERMINAL_DATA_PATH|'
5016
+ r'TERMINAL_COMMONDATA_PATH|'
5017
+ r'MQL_PROGRAM_TYPE|MQL_DLLS_ALLOWED|'
5018
+ r'MQL_TRADE_ALLOWED|MQL_DEBUG|'
5019
+ r'MQL_PROFILER|MQL_TESTER|MQL_OPTIMIZATION|'
5020
+ r'MQL_VISUAL_MODE|'
5021
+ r'MQL_FRAME_MODE|MQL_LICENSE_TYPE|MQL_PROGRAM_NAME|'
5022
+ r'MQL_PROGRAM_PATH|'
5023
+ r'PROGRAM_SCRIPT|PROGRAM_EXPERT|'
5024
+ r'PROGRAM_INDICATOR|LICENSE_FREE|'
5025
+ r'LICENSE_DEMO|LICENSE_FULL|LICENSE_TIME|'
5026
+ r'MODE_LOW|MODE_HIGH|MODE_TIME|MODE_BID|'
5027
+ r'MODE_ASK|MODE_POINT|'
5028
+ r'MODE_DIGITS|MODE_SPREAD|MODE_STOPLEVEL|'
5029
+ r'MODE_LOTSIZE|MODE_TICKVALUE|'
5030
+ r'MODE_TICKSIZE|MODE_SWAPLONG|'
5031
+ r'MODE_SWAPSHORT|MODE_STARTING|'
5032
+ r'MODE_EXPIRATION|MODE_TRADEALLOWED|'
5033
+ r'MODE_MINLOT|MODE_LOTSTEP|MODE_MAXLOT|'
5034
+ r'MODE_SWAPTYPE|MODE_PROFITCALCMODE|'
5035
+ r'MODE_MARGINCALCMODE|MODE_MARGININIT|'
5036
+ r'MODE_MARGINMAINTENANCE|MODE_MARGINHEDGED|'
5037
+ r'MODE_MARGINREQUIRED|MODE_FREEZELEVEL|'
5038
+ r'SUNDAY|MONDAY|TUESDAY|WEDNESDAY|THURSDAY|'
5039
+ r'FRIDAY|SATURDAY|'
5040
+ r'ACCOUNT_LOGIN|ACCOUNT_TRADE_MODE|'
5041
+ r'ACCOUNT_LEVERAGE|'
5042
+ r'ACCOUNT_LIMIT_ORDERS|ACCOUNT_MARGIN_SO_MODE|'
5043
+ r'ACCOUNT_TRADE_ALLOWED|ACCOUNT_TRADE_EXPERT|'
5044
+ r'ACCOUNT_BALANCE|'
5045
+ r'ACCOUNT_CREDIT|ACCOUNT_PROFIT|ACCOUNT_EQUITY|'
5046
+ r'ACCOUNT_MARGIN|'
5047
+ r'ACCOUNT_FREEMARGIN|ACCOUNT_MARGIN_LEVEL|'
5048
+ r'ACCOUNT_MARGIN_SO_CALL|'
5049
+ r'ACCOUNT_MARGIN_SO_SO|ACCOUNT_NAME|'
5050
+ r'ACCOUNT_SERVER|ACCOUNT_CURRENCY|'
5051
+ r'ACCOUNT_COMPANY|ACCOUNT_TRADE_MODE_DEMO|'
5052
+ r'ACCOUNT_TRADE_MODE_CONTEST|'
5053
+ r'ACCOUNT_TRADE_MODE_REAL|ACCOUNT_STOPOUT_MODE_PERCENT|'
5054
+ r'ACCOUNT_STOPOUT_MODE_MONEY|'
5055
+ r'STAT_INITIAL_DEPOSIT|STAT_WITHDRAWAL|STAT_PROFIT|'
5056
+ r'STAT_GROSS_PROFIT|'
5057
+ r'STAT_GROSS_LOSS|STAT_MAX_PROFITTRADE|'
5058
+ r'STAT_MAX_LOSSTRADE|STAT_CONPROFITMAX|'
5059
+ r'STAT_CONPROFITMAX_TRADES|STAT_MAX_CONWINS|'
5060
+ r'STAT_MAX_CONPROFIT_TRADES|'
5061
+ r'STAT_CONLOSSMAX|STAT_CONLOSSMAX_TRADES|'
5062
+ r'STAT_MAX_CONLOSSES|'
5063
+ r'STAT_MAX_CONLOSS_TRADES|STAT_BALANCEMIN|'
5064
+ r'STAT_BALANCE_DD|'
5065
+ r'STAT_BALANCEDD_PERCENT|STAT_BALANCE_DDREL_PERCENT|'
5066
+ r'STAT_BALANCE_DD_RELATIVE|STAT_EQUITYMIN|'
5067
+ r'STAT_EQUITY_DD|'
5068
+ r'STAT_EQUITYDD_PERCENT|STAT_EQUITY_DDREL_PERCENT|'
5069
+ r'STAT_EQUITY_DD_RELATIVE|STAT_EXPECTED_PAYOFF|'
5070
+ r'STAT_PROFIT_FACTOR|'
5071
+ r'STAT_RECOVERY_FACTOR|STAT_SHARPE_RATIO|'
5072
+ r'STAT_MIN_MARGINLEVEL|'
5073
+ r'STAT_CUSTOM_ONTESTER|STAT_DEALS|STAT_TRADES|'
5074
+ r'STAT_PROFIT_TRADES|'
5075
+ r'STAT_LOSS_TRADES|STAT_SHORT_TRADES|STAT_LONG_TRADES|'
5076
+ r'STAT_PROFIT_SHORTTRADES|STAT_PROFIT_LONGTRADES|'
5077
+ r'STAT_PROFITTRADES_AVGCON|STAT_LOSSTRADES_AVGCON|'
5078
+ r'SERIES_BARS_COUNT|SERIES_FIRSTDATE|SERIES_LASTBAR_DATE|'
5079
+ r'SERIES_SERVER_FIRSTDATE|SERIES_TERMINAL_FIRSTDATE|'
5080
+ r'SERIES_SYNCHRONIZED|'
5081
+ r'OP_BUY|OP_SELL|OP_BUYLIMIT|OP_SELLLIMIT|'
5082
+ r'OP_BUYSTOP|OP_SELLSTOP|'
5083
+ r'TRADE_ACTION_DEAL|TRADE_ACTION_PENDING|'
5084
+ r'TRADE_ACTION_SLTP|'
5085
+ r'TRADE_ACTION_MODIFY|TRADE_ACTION_REMOVE|'
5086
+ r'__DATE__|__DATETIME__|__LINE__|__FILE__|'
5087
+ r'__PATH__|__FUNCTION__|'
5088
+ r'__FUNCSIG__|__MQLBUILD__|__MQL4BUILD__|'
5089
+ r'M_E|M_LOG2E|M_LOG10E|M_LN2|M_LN10|'
5090
+ r'M_PI|M_PI_2|M_PI_4|M_1_PI|'
5091
+ r'M_2_PI|M_2_SQRTPI|M_SQRT2|M_SQRT1_2|'
5092
+ r'CHAR_MIN|CHAR_MAX|UCHAR_MAX|'
5093
+ r'SHORT_MIN|SHORT_MAX|USHORT_MAX|'
5094
+ r'INT_MIN|INT_MAX|UINT_MAX|'
5095
+ r'LONG_MIN|LONG_MAX|ULONG_MAX|'
5096
+ r'DBL_MIN|DBL_MAX|DBL_EPSILON|DBL_DIG|DBL_MANT_DIG|'
5097
+ r'DBL_MAX_10_EXP|DBL_MAX_EXP|DBL_MIN_10_EXP|DBL_MIN_EXP|'
5098
+ r'FLT_MIN|FLT_MAX|FLT_EPSILON|'
5099
+ r'FLT_DIG|FLT_MANT_DIG|FLT_MAX_10_EXP|'
5100
+ r'FLT_MAX_EXP|FLT_MIN_10_EXP|FLT_MIN_EXP|REASON_PROGRAM'
5101
+ r'REASON_REMOVE|REASON_RECOMPILE|'
5102
+ r'REASON_CHARTCHANGE|REASON_CHARTCLOSE|'
5103
+ r'REASON_PARAMETERS|REASON_ACCOUNT|'
5104
+ r'REASON_TEMPLATE|REASON_INITFAILED|'
5105
+ r'REASON_CLOSE|POINTER_INVALID'
5106
+ r'POINTER_DYNAMIC|POINTER_AUTOMATIC|'
5107
+ r'NULL|EMPTY|EMPTY_VALUE|CLR_NONE|WHOLE_ARRAY|'
5108
+ r'CHARTS_MAX|clrNONE|EMPTY_VALUE|INVALID_HANDLE|'
5109
+ r'IS_DEBUG_MODE|IS_PROFILE_MODE|NULL|WHOLE_ARRAY|WRONG_VALUE|'
5110
+ r'ERR_NO_ERROR|ERR_NO_RESULT|ERR_COMMON_ERROR|'
5111
+ r'ERR_INVALID_TRADE_PARAMETERS|'
5112
+ r'ERR_SERVER_BUSY|ERR_OLD_VERSION|ERR_NO_CONNECTION|'
5113
+ r'ERR_NOT_ENOUGH_RIGHTS|'
5114
+ r'ERR_TOO_FREQUENT_REQUESTS|ERR_MALFUNCTIONAL_TRADE|'
5115
+ r'ERR_ACCOUNT_DISABLED|'
5116
+ r'ERR_INVALID_ACCOUNT|ERR_TRADE_TIMEOUT|'
5117
+ r'ERR_INVALID_PRICE|ERR_INVALID_STOPS|'
5118
+ r'ERR_INVALID_TRADE_VOLUME|ERR_MARKET_CLOSED|'
5119
+ r'ERR_TRADE_DISABLED|'
5120
+ r'ERR_NOT_ENOUGH_MONEY|ERR_PRICE_CHANGED|'
5121
+ r'ERR_OFF_QUOTES|ERR_BROKER_BUSY|'
5122
+ r'ERR_REQUOTE|ERR_ORDER_LOCKED|'
5123
+ r'ERR_LONG_POSITIONS_ONLY_ALLOWED|ERR_TOO_MANY_REQUESTS|'
5124
+ r'ERR_TRADE_MODIFY_DENIED|ERR_TRADE_CONTEXT_BUSY|'
5125
+ r'ERR_TRADE_EXPIRATION_DENIED|'
5126
+ r'ERR_TRADE_TOO_MANY_ORDERS|ERR_TRADE_HEDGE_PROHIBITED|'
5127
+ r'ERR_TRADE_PROHIBITED_BY_FIFO|'
5128
+ r'FILE_READ|FILE_WRITE|FILE_BIN|FILE_CSV|FILE_TXT|'
5129
+ r'FILE_ANSI|FILE_UNICODE|'
5130
+ r'FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_REWRITE|'
5131
+ r'FILE_COMMON|FILE_EXISTS|'
5132
+ r'FILE_CREATE_DATE|FILE_MODIFY_DATE|'
5133
+ r'FILE_ACCESS_DATE|FILE_SIZE|FILE_POSITION|'
5134
+ r'FILE_END|FILE_LINE_END|FILE_IS_COMMON|'
5135
+ r'FILE_IS_TEXT|FILE_IS_BINARY|'
5136
+ r'FILE_IS_CSV|FILE_IS_ANSI|FILE_IS_READABLE|FILE_IS_WRITABLE|'
5137
+ r'SEEK_SET|SEEK_CUR|SEEK_END|CP_ACP|'
5138
+ r'CP_OEMCP|CP_MACCP|CP_THREAD_ACP|'
5139
+ r'CP_SYMBOL|CP_UTF7|CP_UTF8|IDOK|IDCANCEL|IDABORT|'
5140
+ r'IDRETRY|IDIGNORE|IDYES|IDNO|IDTRYAGAIN|IDCONTINUE|'
5141
+ r'MB_OK|MB_OKCANCEL|MB_ABORTRETRYIGNORE|MB_YESNOCANCEL|'
5142
+ r'MB_YESNO|MB_RETRYCANCEL|'
5143
+ r'MB_CANCELTRYCONTINUE|MB_ICONSTOP|MB_ICONERROR|'
5144
+ r'MB_ICONHAND|MB_ICONQUESTION|'
5145
+ r'MB_ICONEXCLAMATION|MB_ICONWARNING|'
5146
+ r'MB_ICONINFORMATION|MB_ICONASTERISK|'
5147
+ r'MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4)\b',
5148
+ Name.Constant),
5149
+ inherit,
5150
+ ],
5151
+ }
5152
+
5153
+ class SwiftLexer(ObjectiveCLexer):
5154
+ """
5155
+ For `Swift <https://developer.apple.com/swift/>`_ source.
5156
+ """
5157
+ name = 'Swift'
5158
+ filenames = ['*.swift']
5159
+ aliases = ['swift']
5160
+ mimetypes = ['text/x-swift']
5161
+
5162
+ keywords_decl = ['class', 'deinit', 'enum', 'extension', 'func', 'import',
5163
+ 'init', 'let', 'protocol', 'static', 'struct', 'subscript',
5164
+ 'typealias', 'var']
5165
+ keywords_stmt = ['break', 'case', 'continue', 'default', 'do', 'else',
5166
+ 'fallthrough', 'if', 'in', 'for', 'return', 'switch',
5167
+ 'where', 'while']
5168
+ keywords_type = ['as', 'dynamicType', 'is', 'new', 'super', 'self', 'Self',
5169
+ 'Type', '__COLUMN__', '__FILE__', '__FUNCTION__',
5170
+ '__LINE__']
5171
+ keywords_resrv = ['associativity', 'didSet', 'get', 'infix', 'inout', 'left',
5172
+ 'mutating', 'none', 'nonmutating', 'operator', 'override',
5173
+ 'postfix', 'precedence', 'prefix', 'right', 'set',
5174
+ 'unowned', 'unowned(safe)', 'unowned(unsafe)', 'weak',
5175
+ 'willSet']
5176
+ operators = ['->']
5177
+
5178
+ def get_tokens_unprocessed(self, text):
5179
+ for index, token, value in \
5180
+ ObjectiveCLexer.get_tokens_unprocessed(self, text):
5181
+ if token is Name:
5182
+ if value in self.keywords_decl:
5183
+ token = Keyword
5184
+ elif value in self.keywords_stmt:
5185
+ token = Keyword
5186
+ elif value in self.keywords_type:
5187
+ token = Keyword.Type
5188
+ elif value in self.keywords_resrv:
5189
+ token = Keyword.Reserved
5190
+ elif value in self.operators:
5191
+ token = Operator
5192
+ yield index, token, value