pygments.rb 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
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,14 +5,14 @@
5
5
 
6
6
  Lexers for other 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
 
12
12
  import re
13
13
 
14
14
  from pygments.lexer import RegexLexer, include, bygroups, using, \
15
- this, combined, ExtendedRegexLexer
15
+ this, combined, ExtendedRegexLexer, default
16
16
  from pygments.token import Error, Punctuation, Literal, Token, \
17
17
  Text, Comment, Operator, Keyword, Name, String, Number, Generic, \
18
18
  Whitespace
@@ -36,7 +36,91 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer',
36
36
  'ECLLexer', 'UrbiscriptLexer', 'OpenEdgeLexer', 'BroLexer',
37
37
  'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer',
38
38
  'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer',
39
- 'CbmBasicV2Lexer', 'AutoItLexer', 'RexxLexer']
39
+ 'CbmBasicV2Lexer', 'AutoItLexer', 'RexxLexer', 'APLLexer',
40
+ 'LSLLexer', 'AmbientTalkLexer', 'PawnLexer', 'VCTreeStatusLexer',
41
+ 'RslLexer', 'PanLexer', 'RedLexer', 'AlloyLexer']
42
+
43
+
44
+ class LSLLexer(RegexLexer):
45
+ """
46
+ For Second Life's Linden Scripting Language source code.
47
+ """
48
+
49
+ name = 'LSL'
50
+ aliases = ['lsl']
51
+ filenames = ['*.lsl']
52
+ mimetypes = ['text/x-lsl']
53
+
54
+ flags = re.MULTILINE
55
+
56
+ lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b'
57
+ lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b'
58
+ lsl_states = r'\b(?:(?:state)\s+\w+|default)\b'
59
+ lsl_events = r'\b(?:state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b'
60
+ lsl_functions_builtin = r'\b(?:ll(?:ReturnObjectsBy(?:ID|Owner)|Json(?:2List|[GS]etValue|ValueType)|Sin|Cos|Tan|Atan2|Sqrt|Pow|Abs|Fabs|Frand|Floor|Ceil|Round|Vec(?:Mag|Norm|Dist)|Rot(?:Between|2(?:Euler|Fwd|Left|Up))|(?:Euler|Axes)2Rot|Whisper|(?:Region|Owner)?Say|Shout|Listen(?:Control|Remove)?|Sensor(?:Repeat|Remove)?|Detected(?:Name|Key|Owner|Type|Pos|Vel|Grab|Rot|Group|LinkNumber)|Die|Ground|Wind|(?:[GS]et)(?:AnimationOverride|MemoryLimit|PrimMediaParams|ParcelMusicURL|Object(?:Desc|Name)|PhysicsMaterial|Status|Scale|Color|Alpha|Texture|Pos|Rot|Force|Torque)|ResetAnimationOverride|(?:Scale|Offset|Rotate)Texture|(?:Rot)?Target(?:Remove)?|(?:Stop)?MoveToTarget|Apply(?:Rotational)?Impulse|Set(?:KeyframedMotion|ContentType|RegionPos|(?:Angular)?Velocity|Buoyancy|HoverHeight|ForceAndTorque|TimerEvent|ScriptState|Damage|TextureAnim|Sound(?:Queueing|Radius)|Vehicle(?:Type|(?:Float|Vector|Rotation)Param)|(?:Touch|Sit)?Text|Camera(?:Eye|At)Offset|PrimitiveParams|ClickAction|Link(?:Alpha|Color|PrimitiveParams(?:Fast)?|Texture(?:Anim)?|Camera|Media)|RemoteScriptAccessPin|PayPrice|LocalRot)|ScaleByFactor|Get(?:(?:Max|Min)ScaleFactor|ClosestNavPoint|StaticPath|SimStats|Env|PrimitiveParams|Link(?:PrimitiveParams|Number(?:OfSides)?|Key|Name|Media)|HTTPHeader|FreeURLs|Object(?:Details|PermMask|PrimCount)|Parcel(?:MaxPrims|Details|Prim(?:Count|Owners))|Attached|(?:SPMax|Free|Used)Memory|Region(?:Name|TimeDilation|FPS|Corner|AgentCount)|Root(?:Position|Rotation)|UnixTime|(?:Parcel|Region)Flags|(?:Wall|GMT)clock|SimulatorHostname|BoundingBox|GeometricCenter|Creator|NumberOf(?:Prims|NotecardLines|Sides)|Animation(?:List)?|(?:Camera|Local)(?:Pos|Rot)|Vel|Accel|Omega|Time(?:stamp|OfDay)|(?:Object|CenterOf)?Mass|MassMKS|Energy|Owner|(?:Owner)?Key|SunDirection|Texture(?:Offset|Scale|Rot)|Inventory(?:Number|Name|Key|Type|Creator|PermMask)|Permissions(?:Key)?|StartParameter|List(?:Length|EntryType)|Date|Agent(?:Size|Info|Language|List)|LandOwnerAt|NotecardLine|Script(?:Name|State))|(?:Get|Reset|GetAndReset)Time|PlaySound(?:Slave)?|LoopSound(?:Master|Slave)?|(?:Trigger|Stop|Preload)Sound|(?:(?:Get|Delete)Sub|Insert)String|To(?:Upper|Lower)|Give(?:InventoryList|Money)|RezObject|(?:Stop)?LookAt|Sleep|CollisionFilter|(?:Take|Release)Controls|DetachFromAvatar|AttachToAvatar(?:Temp)?|InstantMessage|(?:GetNext)?Email|StopHover|MinEventDelay|RotLookAt|String(?:Length|Trim)|(?:Start|Stop)Animation|TargetOmega|RequestPermissions|(?:Create|Break)Link|BreakAllLinks|(?:Give|Remove)Inventory|Water|PassTouches|Request(?:Agent|Inventory)Data|TeleportAgent(?:Home|GlobalCoords)?|ModifyLand|CollisionSound|ResetScript|MessageLinked|PushObject|PassCollisions|AxisAngle2Rot|Rot2(?:Axis|Angle)|A(?:cos|sin)|AngleBetween|AllowInventoryDrop|SubStringIndex|List2(?:CSV|Integer|Json|Float|String|Key|Vector|Rot|List(?:Strided)?)|DeleteSubList|List(?:Statistics|Sort|Randomize|(?:Insert|Find|Replace)List)|EdgeOfWorld|AdjustSoundVolume|Key2Name|TriggerSoundLimited|EjectFromLand|(?:CSV|ParseString)2List|OverMyLand|SameGroup|UnSit|Ground(?:Slope|Normal|Contour)|GroundRepel|(?:Set|Remove)VehicleFlags|(?:AvatarOn)?(?:Link)?SitTarget|Script(?:Danger|Profiler)|Dialog|VolumeDetect|ResetOtherScript|RemoteLoadScriptPin|(?:Open|Close)RemoteDataChannel|SendRemoteData|RemoteDataReply|(?:Integer|String)ToBase64|XorBase64|Log(?:10)?|Base64To(?:String|Integer)|ParseStringKeepNulls|RezAtRoot|RequestSimulatorData|ForceMouselook|(?:Load|Release|(?:E|Une)scape)URL|ParcelMedia(?:CommandList|Query)|ModPow|MapDestination|(?:RemoveFrom|AddTo|Reset)Land(?:Pass|Ban)List|(?:Set|Clear)CameraParams|HTTP(?:Request|Response)|TextBox|DetectedTouch(?:UV|Face|Pos|(?:N|Bin)ormal|ST)|(?:MD5|SHA1|DumpList2)String|Request(?:Secure)?URL|Clear(?:Prim|Link)Media|(?:Link)?ParticleSystem|(?:Get|Request)(?:Username|DisplayName)|RegionSayTo|CastRay|GenerateKey|TransferLindenDollars|ManageEstateAccess|(?:Create|Delete)Character|ExecCharacterCmd|Evade|FleeFrom|NavigateTo|PatrolPoints|Pursue|UpdateCharacter|WanderWithin))\b'
61
+ lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b'
62
+ lsl_constants_integer = r'\b(?:JSON_APPEND|STATUS_(?:PHYSICS|ROTATE_[XYZ]|PHANTOM|SANDBOX|BLOCK_GRAB(?:_OBJECT)?|(?:DIE|RETURN)_AT_EDGE|CAST_SHADOWS|OK|MALFORMED_PARAMS|TYPE_MISMATCH|BOUNDS_ERROR|NOT_(?:FOUND|SUPPORTED)|INTERNAL_ERROR|WHITELIST_FAILED)|AGENT(?:_(?:BY_(?:LEGACY_|USER)NAME|FLYING|ATTACHMENTS|SCRIPTED|MOUSELOOK|SITTING|ON_OBJECT|AWAY|WALKING|IN_AIR|TYPING|CROUCHING|BUSY|ALWAYS_RUN|AUTOPILOT|LIST_(?:PARCEL(?:_OWNER)?|REGION)))?|CAMERA_(?:PITCH|DISTANCE|BEHINDNESS_(?:ANGLE|LAG)|(?:FOCUS|POSITION)(?:_(?:THRESHOLD|LOCKED|LAG))?|FOCUS_OFFSET|ACTIVE)|ANIM_ON|LOOP|REVERSE|PING_PONG|SMOOTH|ROTATE|SCALE|ALL_SIDES|LINK_(?:ROOT|SET|ALL_(?:OTHERS|CHILDREN)|THIS)|ACTIVE|PASSIVE|SCRIPTED|CONTROL_(?:FWD|BACK|(?:ROT_)?(?:LEFT|RIGHT)|UP|DOWN|(?:ML_)?LBUTTON)|PERMISSION_(?:RETURN_OBJECTS|DEBIT|OVERRIDE_ANIMATIONS|SILENT_ESTATE_MANAGEMENT|TAKE_CONTROLS|TRIGGER_ANIMATION|ATTACH|CHANGE_LINKS|(?:CONTROL|TRACK)_CAMERA|TELEPORT)|INVENTORY_(?:TEXTURE|SOUND|OBJECT|SCRIPT|LANDMARK|CLOTHING|NOTECARD|BODYPART|ANIMATION|GESTURE|ALL|NONE)|CHANGED_(?:INVENTORY|COLOR|SHAPE|SCALE|TEXTURE|LINK|ALLOWED_DROP|OWNER|REGION(?:_START)?|TELEPORT|MEDIA)|OBJECT_(?:(?:PHYSICS|SERVER|STREAMING)_COST|UNKNOWN_DETAIL|CHARACTER_TIME|PHANTOM|PHYSICS|TEMP_ON_REZ|NAME|DESC|POS|PRIM_EQUIVALENCE|RETURN_(?:PARCEL(?:_OWNER)?|REGION)|ROO?T|VELOCITY|OWNER|GROUP|CREATOR|ATTACHED_POINT|RENDER_WEIGHT|PATHFINDING_TYPE|(?:RUNNING|TOTAL)_SCRIPT_COUNT|SCRIPT_(?:MEMORY|TIME))|TYPE_(?:INTEGER|FLOAT|STRING|KEY|VECTOR|ROTATION|INVALID)|(?:DEBUG|PUBLIC)_CHANNEL|ATTACH_(?:AVATAR_CENTER|CHEST|HEAD|BACK|PELVIS|MOUTH|CHIN|NECK|NOSE|BELLY|[LR](?:SHOULDER|HAND|FOOT|EAR|EYE|[UL](?:ARM|LEG)|HIP)|(?:LEFT|RIGHT)_PEC|HUD_(?:CENTER_[12]|TOP_(?:RIGHT|CENTER|LEFT)|BOTTOM(?:_(?:RIGHT|LEFT))?))|LAND_(?:LEVEL|RAISE|LOWER|SMOOTH|NOISE|REVERT)|DATA_(?:ONLINE|NAME|BORN|SIM_(?:POS|STATUS|RATING)|PAYINFO)|PAYMENT_INFO_(?:ON_FILE|USED)|REMOTE_DATA_(?:CHANNEL|REQUEST|REPLY)|PSYS_(?:PART_(?:BF_(?:ZERO|ONE(?:_MINUS_(?:DEST_COLOR|SOURCE_(ALPHA|COLOR)))?|DEST_COLOR|SOURCE_(ALPHA|COLOR))|BLEND_FUNC_(DEST|SOURCE)|FLAGS|(?:START|END)_(?:COLOR|ALPHA|SCALE|GLOW)|MAX_AGE|(?:RIBBON|WIND|INTERP_(?:COLOR|SCALE)|BOUNCE|FOLLOW_(?:SRC|VELOCITY)|TARGET_(?:POS|LINEAR)|EMISSIVE)_MASK)|SRC_(?:MAX_AGE|PATTERN|ANGLE_(?:BEGIN|END)|BURST_(?:RATE|PART_COUNT|RADIUS|SPEED_(?:MIN|MAX))|ACCEL|TEXTURE|TARGET_KEY|OMEGA|PATTERN_(?:DROP|EXPLODE|ANGLE(?:_CONE(?:_EMPTY)?)?)))|VEHICLE_(?:REFERENCE_FRAME|TYPE_(?:NONE|SLED|CAR|BOAT|AIRPLANE|BALLOON)|(?:LINEAR|ANGULAR)_(?:FRICTION_TIMESCALE|MOTOR_DIRECTION)|LINEAR_MOTOR_OFFSET|HOVER_(?:HEIGHT|EFFICIENCY|TIMESCALE)|BUOYANCY|(?:LINEAR|ANGULAR)_(?:DEFLECTION_(?:EFFICIENCY|TIMESCALE)|MOTOR_(?:DECAY_)?TIMESCALE)|VERTICAL_ATTRACTION_(?:EFFICIENCY|TIMESCALE)|BANKING_(?:EFFICIENCY|MIX|TIMESCALE)|FLAG_(?:NO_DEFLECTION_UP|LIMIT_(?:ROLL_ONLY|MOTOR_UP)|HOVER_(?:(?:WATER|TERRAIN|UP)_ONLY|GLOBAL_HEIGHT)|MOUSELOOK_(?:STEER|BANK)|CAMERA_DECOUPLED))|PRIM_(?:TYPE(?:_(?:BOX|CYLINDER|PRISM|SPHERE|TORUS|TUBE|RING|SCULPT))?|HOLE_(?:DEFAULT|CIRCLE|SQUARE|TRIANGLE)|MATERIAL(?:_(?:STONE|METAL|GLASS|WOOD|FLESH|PLASTIC|RUBBER))?|SHINY_(?:NONE|LOW|MEDIUM|HIGH)|BUMP_(?:NONE|BRIGHT|DARK|WOOD|BARK|BRICKS|CHECKER|CONCRETE|TILE|STONE|DISKS|GRAVEL|BLOBS|SIDING|LARGETILE|STUCCO|SUCTION|WEAVE)|TEXGEN_(?:DEFAULT|PLANAR)|SCULPT_(?:TYPE_(?:SPHERE|TORUS|PLANE|CYLINDER|MASK)|FLAG_(?:MIRROR|INVERT))|PHYSICS(?:_(?:SHAPE_(?:CONVEX|NONE|PRIM|TYPE)))?|(?:POS|ROT)_LOCAL|SLICE|TEXT|FLEXIBLE|POINT_LIGHT|TEMP_ON_REZ|PHANTOM|POSITION|SIZE|ROTATION|TEXTURE|NAME|OMEGA|DESC|LINK_TARGET|COLOR|BUMP_SHINY|FULLBRIGHT|TEXGEN|GLOW|MEDIA_(?:ALT_IMAGE_ENABLE|CONTROLS|(?:CURRENT|HOME)_URL|AUTO_(?:LOOP|PLAY|SCALE|ZOOM)|FIRST_CLICK_INTERACT|(?:WIDTH|HEIGHT)_PIXELS|WHITELIST(?:_ENABLE)?|PERMS_(?:INTERACT|CONTROL)|PARAM_MAX|CONTROLS_(?:STANDARD|MINI)|PERM_(?:NONE|OWNER|GROUP|ANYONE)|MAX_(?:URL_LENGTH|WHITELIST_(?:SIZE|COUNT)|(?:WIDTH|HEIGHT)_PIXELS)))|MASK_(?:BASE|OWNER|GROUP|EVERYONE|NEXT)|PERM_(?:TRANSFER|MODIFY|COPY|MOVE|ALL)|PARCEL_(?:MEDIA_COMMAND_(?:STOP|PAUSE|PLAY|LOOP|TEXTURE|URL|TIME|AGENT|UNLOAD|AUTO_ALIGN|TYPE|SIZE|DESC|LOOP_SET)|FLAG_(?:ALLOW_(?:FLY|(?:GROUP_)?SCRIPTS|LANDMARK|TERRAFORM|DAMAGE|CREATE_(?:GROUP_)?OBJECTS)|USE_(?:ACCESS_(?:GROUP|LIST)|BAN_LIST|LAND_PASS_LIST)|LOCAL_SOUND_ONLY|RESTRICT_PUSHOBJECT|ALLOW_(?:GROUP|ALL)_OBJECT_ENTRY)|COUNT_(?:TOTAL|OWNER|GROUP|OTHER|SELECTED|TEMP)|DETAILS_(?:NAME|DESC|OWNER|GROUP|AREA|ID|SEE_AVATARS))|LIST_STAT_(?:MAX|MIN|MEAN|MEDIAN|STD_DEV|SUM(?:_SQUARES)?|NUM_COUNT|GEOMETRIC_MEAN|RANGE)|PAY_(?:HIDE|DEFAULT)|REGION_FLAG_(?:ALLOW_DAMAGE|FIXED_SUN|BLOCK_TERRAFORM|SANDBOX|DISABLE_(?:COLLISIONS|PHYSICS)|BLOCK_FLY|ALLOW_DIRECT_TELEPORT|RESTRICT_PUSHOBJECT)|HTTP_(?:METHOD|MIMETYPE|BODY_(?:MAXLENGTH|TRUNCATED)|CUSTOM_HEADER|PRAGMA_NO_CACHE|VERBOSE_THROTTLE|VERIFY_CERT)|STRING_(?:TRIM(?:_(?:HEAD|TAIL))?)|CLICK_ACTION_(?:NONE|TOUCH|SIT|BUY|PAY|OPEN(?:_MEDIA)?|PLAY|ZOOM)|TOUCH_INVALID_FACE|PROFILE_(?:NONE|SCRIPT_MEMORY)|RC_(?:DATA_FLAGS|DETECT_PHANTOM|GET_(?:LINK_NUM|NORMAL|ROOT_KEY)|MAX_HITS|REJECT_(?:TYPES|AGENTS|(?:NON)?PHYSICAL|LAND))|RCERR_(?:CAST_TIME_EXCEEDED|SIM_PERF_LOW|UNKNOWN)|ESTATE_ACCESS_(?:ALLOWED_(?:AGENT|GROUP)_(?:ADD|REMOVE)|BANNED_AGENT_(?:ADD|REMOVE))|DENSITY|FRICTION|RESTITUTION|GRAVITY_MULTIPLIER|KFM_(?:COMMAND|CMD_(?:PLAY|STOP|PAUSE|SET_MODE)|MODE|FORWARD|LOOP|PING_PONG|REVERSE|DATA|ROTATION|TRANSLATION)|ERR_(?:GENERIC|PARCEL_PERMISSIONS|MALFORMED_PARAMS|RUNTIME_PERMISSIONS|THROTTLED)|CHARACTER_(?:CMD_(?:(?:SMOOTH_)?STOP|JUMP)|DESIRED_(?:TURN_)?SPEED|RADIUS|STAY_WITHIN_PARCEL|LENGTH|ORIENTATION|ACCOUNT_FOR_SKIPPED_FRAMES|AVOIDANCE_MODE|TYPE(?:_(?:[ABCD]|NONE))?|MAX_(?:DECEL|TURN_RADIUS|(?:ACCEL|SPEED)))|PURSUIT_(?:OFFSET|FUZZ_FACTOR|GOAL_TOLERANCE|INTERCEPT)|REQUIRE_LINE_OF_SIGHT|FORCE_DIRECT_PATH|VERTICAL|HORIZONTAL|AVOID_(?:CHARACTERS|DYNAMIC_OBSTACLES|NONE)|PU_(?:EVADE_(?:HIDDEN|SPOTTED)|FAILURE_(?:DYNAMIC_PATHFINDING_DISABLED|INVALID_(?:GOAL|START)|NO_(?:NAVMESH|VALID_DESTINATION)|OTHER|TARGET_GONE|(?:PARCEL_)?UNREACHABLE)|(?:GOAL|SLOWDOWN_DISTANCE)_REACHED)|TRAVERSAL_TYPE(?:_(?:FAST|NONE|SLOW))?|CONTENT_TYPE_(?:ATOM|FORM|HTML|JSON|LLSD|RSS|TEXT|XHTML|XML)|GCNP_(?:RADIUS|STATIC)|(?:PATROL|WANDER)_PAUSE_AT_WAYPOINTS|OPT_(?:AVATAR|CHARACTER|EXCLUSION_VOLUME|LEGACY_LINKSET|MATERIAL_VOLUME|OTHER|STATIC_OBSTACLE|WALKABLE)|SIM_STAT_PCT_CHARS_STEPPED)\b'
63
+ lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b'
64
+ lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b'
65
+ lsl_constants_string = r'\b(?:EOF|JSON_(?:ARRAY|DELETE|FALSE|INVALID|NULL|NUMBER|OBJECT|STRING|TRUE)|NULL_KEY|TEXTURE_(?:BLANK|DEFAULT|MEDIA|PLYWOOD|TRANSPARENT)|URL_REQUEST_(?:GRANTED|DENIED))\b'
66
+ lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b'
67
+ lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b'
68
+ lsl_invalid_deprecated = r'\b(?:ATTACH_[LR]PEC|DATA_RATING|OBJECT_ATTACHMENT_(?:GEOMETRY_BYTES|SURFACE_AREA)|PRIM_(?:CAST_SHADOWS|MATERIAL_LIGHT|TYPE_LEGACY)|PSYS_SRC_(?:INNER|OUTER)ANGLE|VEHICLE_FLAG_NO_FLY_UP|ll(?:Cloud|Make(?:Explosion|Fountain|Smoke|Fire)|RemoteDataSetRegion|Sound(?:Preload)?|XorBase64Strings(?:Correct)?))\b'
69
+ lsl_invalid_illegal = r'\b(?:event)\b'
70
+ lsl_invalid_unimplemented = r'\b(?:CHARACTER_(?:MAX_ANGULAR_(?:ACCEL|SPEED)|TURN_SPEED_MULTIPLIER)|PERMISSION_(?:CHANGE_(?:JOINTS|PERMISSIONS)|RELEASE_OWNERSHIP|REMAP_CONTROLS)|PRIM_PHYSICS_MATERIAL|PSYS_SRC_OBJ_REL_MASK|ll(?:CollisionSprite|(?:Stop)?PointAt|(?:(?:Refresh|Set)Prim)URL|(?:Take|Release)Camera|RemoteLoadScript))\b'
71
+ lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b'
72
+ lsl_reserved_log = r'\b(?:print)\b'
73
+ lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-\/]=?'
74
+
75
+ tokens = {
76
+ 'root':
77
+ [
78
+ (r'//.*?\n', Comment.Single),
79
+ (r'/\*', Comment.Multiline, 'comment'),
80
+ (r'"', String.Double, 'string'),
81
+ (lsl_keywords, Keyword),
82
+ (lsl_types, Keyword.Type),
83
+ (lsl_states, Name.Class),
84
+ (lsl_events, Name.Builtin),
85
+ (lsl_functions_builtin, Name.Function),
86
+ (lsl_constants_float, Keyword.Constant),
87
+ (lsl_constants_integer, Keyword.Constant),
88
+ (lsl_constants_integer_boolean, Keyword.Constant),
89
+ (lsl_constants_rotation, Keyword.Constant),
90
+ (lsl_constants_string, Keyword.Constant),
91
+ (lsl_constants_vector, Keyword.Constant),
92
+ (lsl_invalid_broken, Error),
93
+ (lsl_invalid_deprecated, Error),
94
+ (lsl_invalid_illegal, Error),
95
+ (lsl_invalid_unimplemented, Error),
96
+ (lsl_reserved_godmode, Keyword.Reserved),
97
+ (lsl_reserved_log, Keyword.Reserved),
98
+ (r'\b([a-zA-Z_]\w*)\b', Name.Variable),
99
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),
100
+ (r'(\d+\.\d*|\.\d+)', Number.Float),
101
+ (r'0[xX][0-9a-fA-F]+', Number.Hex),
102
+ (r'\d+', Number.Integer),
103
+ (lsl_operators, Operator),
104
+ (r':=?', Error),
105
+ (r'[,;{}\(\)\[\]]', Punctuation),
106
+ (r'\n+', Whitespace),
107
+ (r'\s+', Whitespace)
108
+ ],
109
+ 'comment':
110
+ [
111
+ (r'[^*/]+', Comment.Multiline),
112
+ (r'/\*', Comment.Multiline, '#push'),
113
+ (r'\*/', Comment.Multiline, '#pop'),
114
+ (r'[*/]', Comment.Multiline)
115
+ ],
116
+ 'string':
117
+ [
118
+ (r'\\([nt"\\])', String.Escape),
119
+ (r'"', String.Double, '#pop'),
120
+ (r'\\.', Error),
121
+ (r'[^"\\]+', String.Double),
122
+ ]
123
+ }
40
124
 
41
125
 
42
126
  class ECLLexer(RegexLexer):
@@ -45,7 +129,7 @@ class ECLLexer(RegexLexer):
45
129
  <http://hpccsystems.com/community/docs/ecl-language-reference/html>`_
46
130
  language.
47
131
 
48
- *New in Pygments 1.5.*
132
+ .. versionadded:: 1.5
49
133
  """
50
134
 
51
135
  name = 'ECL'
@@ -72,15 +156,15 @@ class ECLLexer(RegexLexer):
72
156
  include('hash'),
73
157
  (r'"', String, 'string'),
74
158
  (r'\'', String, 'string'),
75
- (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
159
+ (r'(\d+\.\d*|\.\d+|\d+)e[+-]?\d+[lu]*', Number.Float),
76
160
  (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
77
- (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
78
- (r'0[0-7]+[LlUu]*', Number.Oct),
161
+ (r'0x[0-9a-f]+[lu]*', Number.Hex),
162
+ (r'0[0-7]+[lu]*', Number.Oct),
79
163
  (r'\d+[LlUu]*', Number.Integer),
80
164
  (r'\*/', Error),
81
165
  (r'[~!%^&*+=|?:<>/-]+', Operator),
82
166
  (r'[{}()\[\],.;]', Punctuation),
83
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
167
+ (r'[a-z_]\w*', Name),
84
168
  ],
85
169
  'hash': [
86
170
  (r'^#.*$', Comment.Preproc),
@@ -176,7 +260,7 @@ class BefungeLexer(RegexLexer):
176
260
  Lexer for the esoteric `Befunge <http://en.wikipedia.org/wiki/Befunge>`_
177
261
  language.
178
262
 
179
- *New in Pygments 0.7.*
263
+ .. versionadded:: 0.7
180
264
  """
181
265
  name = 'Befunge'
182
266
  aliases = ['befunge']
@@ -206,7 +290,7 @@ class RedcodeLexer(RegexLexer):
206
290
  A simple Redcode lexer based on ICWS'94.
207
291
  Contributed by Adam Blinkinsop <blinks@acm.org>.
208
292
 
209
- *New in Pygments 0.8.*
293
+ .. versionadded:: 0.8
210
294
  """
211
295
  name = 'Redcode'
212
296
  aliases = ['redcode']
@@ -242,7 +326,7 @@ class MOOCodeLexer(RegexLexer):
242
326
  For `MOOCode <http://www.moo.mud.org/>`_ (the MOO scripting
243
327
  language).
244
328
 
245
- *New in Pygments 0.9.*
329
+ .. versionadded:: 0.9
246
330
  """
247
331
  name = 'MOOCode'
248
332
  filenames = ['*.moo']
@@ -286,7 +370,7 @@ class SmalltalkLexer(RegexLexer):
286
370
  Contributed by Stefan Matthias Aust.
287
371
  Rewritten by Nils Winter.
288
372
 
289
- *New in Pygments 0.10.*
373
+ .. versionadded:: 0.10
290
374
  """
291
375
  name = 'Smalltalk'
292
376
  filenames = ['*.st']
@@ -319,7 +403,7 @@ class SmalltalkLexer(RegexLexer):
319
403
  (r'(:)(\s*)(\w+)',
320
404
  bygroups(Operator, Text, Name.Variable)),
321
405
  (r'\|', Operator, '#pop'),
322
- (r'', Text, '#pop'), # else pop
406
+ default('#pop'), # else pop
323
407
  ],
324
408
  'literals' : [
325
409
  (r"'(''|[^'])*'", String, 'afterobject'),
@@ -405,7 +489,7 @@ class LogtalkLexer(RegexLexer):
405
489
  """
406
490
  For `Logtalk <http://logtalk.org/>`_ source code.
407
491
 
408
- *New in Pygments 0.10.*
492
+ .. versionadded:: 0.10
409
493
  """
410
494
 
411
495
  name = 'Logtalk'
@@ -425,12 +509,12 @@ class LogtalkLexer(RegexLexer):
425
509
  (r'\s+', Text),
426
510
  # Numbers
427
511
  (r"0'.", Number),
428
- (r'0b[01]+', Number),
429
- (r'0o[0-7]+', Number),
430
- (r'0x[0-9a-fA-F]+', Number),
431
- (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
512
+ (r'0b[01]+', Number.Bin),
513
+ (r'0o[0-7]+', Number.Oct),
514
+ (r'0x[0-9a-fA-F]+', Number.Hex),
515
+ (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number.Float),
432
516
  # Variables
433
- (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
517
+ (r'([A-Z_]\w*)', Name.Variable),
434
518
  # Event handlers
435
519
  (r'(after|before)(?=[(])', Keyword),
436
520
  # Execution-context methods
@@ -546,7 +630,7 @@ class LogtalkLexer(RegexLexer):
546
630
  # Ponctuation
547
631
  (r'[()\[\],.|]', Text),
548
632
  # Atoms
549
- (r"[a-z][a-zA-Z0-9_]*", Text),
633
+ (r"[a-z]\w*", Text),
550
634
  (r"'", String, 'quoted_atom'),
551
635
  ],
552
636
 
@@ -577,8 +661,8 @@ class LogtalkLexer(RegexLexer):
577
661
  (r'op(?=[(])', Keyword, 'root'),
578
662
  (r'(c(alls|oinductive)|reexport|use(s|_module))(?=[(])',
579
663
  Keyword, 'root'),
580
- (r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'),
581
- (r'[a-z][a-zA-Z0-9_]*[.]', Text, 'root'),
664
+ (r'[a-z]\w*(?=[(])', Text, 'root'),
665
+ (r'[a-z]\w*[.]', Text, 'root'),
582
666
  ],
583
667
 
584
668
  'entityrelations': [
@@ -586,14 +670,14 @@ class LogtalkLexer(RegexLexer):
586
670
  r'(?=[(])', Keyword),
587
671
  # Numbers
588
672
  (r"0'.", Number),
589
- (r'0b[01]+', Number),
590
- (r'0o[0-7]+', Number),
591
- (r'0x[0-9a-fA-F]+', Number),
592
- (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
673
+ (r'0b[01]+', Number.Bin),
674
+ (r'0o[0-7]+', Number.Oct),
675
+ (r'0x[0-9a-fA-F]+', Number.Hex),
676
+ (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number.Float),
593
677
  # Variables
594
- (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
678
+ (r'([A-Z_]\w*)', Name.Variable),
595
679
  # Atoms
596
- (r"[a-z][a-zA-Z0-9_]*", Text),
680
+ (r"[a-z]\w*", Text),
597
681
  (r"'", String, 'quoted_atom'),
598
682
  # Strings
599
683
  (r'"(\\\\|\\"|[^"])*"', String),
@@ -633,7 +717,7 @@ class GnuplotLexer(RegexLexer):
633
717
  """
634
718
  For `Gnuplot <http://gnuplot.info/>`_ plotting scripts.
635
719
 
636
- *New in Pygments 0.11.*
720
+ .. versionadded:: 0.11
637
721
  """
638
722
 
639
723
  name = 'Gnuplot'
@@ -663,11 +747,11 @@ class GnuplotLexer(RegexLexer):
663
747
  (_shortened_many('pwd$', 're$read', 'res$et', 'scr$eendump',
664
748
  'she$ll', 'test$'),
665
749
  Keyword, 'noargs'),
666
- ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(=)',
750
+ ('([a-zA-Z_]\w*)(\s*)(=)',
667
751
  bygroups(Name.Variable, Text, Operator), 'genericargs'),
668
- ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*\(.*?\)\s*)(=)',
752
+ ('([a-zA-Z_]\w*)(\s*\(.*?\)\s*)(=)',
669
753
  bygroups(Name.Function, Text, Operator), 'genericargs'),
670
- (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
754
+ (r'@[a-zA-Z_]\w*', Name.Constant), # macros
671
755
  (r';', Keyword),
672
756
  ],
673
757
  'comment': [
@@ -713,10 +797,10 @@ class GnuplotLexer(RegexLexer):
713
797
  ('[,.~!%^&*+=|?:<>/-]', Operator),
714
798
  ('[{}()\[\]]', Punctuation),
715
799
  (r'(eq|ne)\b', Operator.Word),
716
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
800
+ (r'([a-zA-Z_]\w*)(\s*)(\()',
717
801
  bygroups(Name.Function, Text, Punctuation)),
718
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
719
- (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
802
+ (r'[a-zA-Z_]\w*', Name),
803
+ (r'@[a-zA-Z_]\w*', Name.Constant), # macros
720
804
  (r'\\\n', Text),
721
805
  ],
722
806
  'optionarg': [
@@ -792,7 +876,7 @@ class PovrayLexer(RegexLexer):
792
876
  """
793
877
  For `Persistence of Vision Raytracer <http://www.povray.org/>`_ files.
794
878
 
795
- *New in Pygments 0.11.*
879
+ .. versionadded:: 0.11
796
880
  """
797
881
  name = 'POVRay'
798
882
  aliases = ['pov']
@@ -1150,18 +1234,18 @@ class AppleScriptLexer(RegexLexer):
1150
1234
  tokens = {
1151
1235
  'root': [
1152
1236
  (r'\s+', Text),
1153
- (ur'¬\n', String.Escape),
1237
+ (u'¬\\n', String.Escape),
1154
1238
  (r"'s\s+", Text), # This is a possessive, consider moving
1155
1239
  (r'(--|#).*?$', Comment),
1156
1240
  (r'\(\*', Comment.Multiline, 'comment'),
1157
1241
  (r'[\(\){}!,.:]', Punctuation),
1158
- (ur'(«)([^»]+)(»)',
1242
+ (u'(«)([^»]+)(»)',
1159
1243
  bygroups(Text, Name.Builtin, Text)),
1160
1244
  (r'\b((?:considering|ignoring)\s*)'
1161
1245
  r'(application responses|case|diacriticals|hyphens|'
1162
1246
  r'numeric strings|punctuation|white space)',
1163
1247
  bygroups(Keyword, Name.Builtin)),
1164
- (ur'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator),
1248
+ (u'(-|\\*|\\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\\^)', Operator),
1165
1249
  (r"\b(%s)\b" % '|'.join(Operators), Operator.Word),
1166
1250
  (r'^(\s*(?:on|end)\s+)'
1167
1251
  r'(%s)' % '|'.join(StudioEvents[::-1]),
@@ -1198,7 +1282,7 @@ class ModelicaLexer(RegexLexer):
1198
1282
  """
1199
1283
  For `Modelica <http://www.modelica.org/>`_ source code.
1200
1284
 
1201
- *New in Pygments 1.1.*
1285
+ .. versionadded:: 1.1
1202
1286
  """
1203
1287
  name = 'Modelica'
1204
1288
  aliases = ['modelica']
@@ -1221,25 +1305,28 @@ class ModelicaLexer(RegexLexer):
1221
1305
  (r'(\d+\.\d*|\.\d+)', Number.Float),
1222
1306
  (r'\d+[Ll]?', Number.Integer),
1223
1307
  (r'[~!%^&*+=|?:<>/-]', Operator),
1224
- (r'[()\[\]{},.;]', Punctuation),
1225
1308
  (r'(true|false|NULL|Real|Integer|Boolean)\b', Name.Builtin),
1226
- (r"([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*')"
1227
- r"(\.([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*'))+", Name.Class),
1228
- (r"('[\w\+\-\*\/\^]+'|\w+)", Name),
1309
+ (r'([a-z_][\w]*|\'[^\']+\')'
1310
+ r'([\[\d,:\]]*)'
1311
+ r'(\.([a-z_][\w]*|\'[^\']+\'))+'
1312
+ r'([\[\d,:\]]*)', Name.Class),
1313
+ (r'(\'[\w\+\-\*\/\^]+\'|\w+)', Name),
1314
+ (r'[()\[\]{},.;]', Punctuation),
1315
+ (r'\'', Name, 'quoted_ident'),
1229
1316
  ],
1230
1317
  'root': [
1231
1318
  include('whitespace'),
1232
- include('keywords'),
1319
+ include('classes'),
1233
1320
  include('functions'),
1321
+ include('keywords'),
1234
1322
  include('operators'),
1235
- include('classes'),
1236
1323
  (r'("<html>|<html>)', Name.Tag, 'html-content'),
1237
1324
  include('statements'),
1238
1325
  ],
1239
1326
  'keywords': [
1240
1327
  (r'(algorithm|annotation|break|connect|constant|constrainedby|'
1241
- r'discrete|each|else|elseif|elsewhen|encapsulated|enumeration|'
1242
- r'end|equation|exit|expandable|extends|'
1328
+ r'discrete|each|end|else|elseif|elsewhen|encapsulated|enumeration|'
1329
+ r'equation|exit|expandable|extends|'
1243
1330
  r'external|false|final|flow|for|if|import|impure|in|initial\sequation|'
1244
1331
  r'inner|input|loop|nondiscrete|outer|output|parameter|partial|'
1245
1332
  r'protected|public|pure|redeclare|replaceable|stream|time|then|true|'
@@ -1247,31 +1334,39 @@ class ModelicaLexer(RegexLexer):
1247
1334
  ],
1248
1335
  'functions': [
1249
1336
  (r'(abs|acos|acosh|asin|asinh|atan|atan2|atan3|ceil|cos|cosh|'
1250
- r'cross|div|exp|floor|getInstanceName|log|log10|mod|rem|'
1251
- r'semiLinear|sign|sin|sinh|size|spatialDistribution|sqrt|tan|'
1252
- r'tanh|zeros)\b', Name.Function),
1337
+ r'cross|diagonal|div|exp|fill|floor|getInstanceName|identity|'
1338
+ r'linspace|log|log10|matrix|mod|max|min|ndims|ones|outerProduct|'
1339
+ r'product|rem|scalar|semiLinear|skew|sign|sin|sinh|size|'
1340
+ r'spatialDistribution|sum|sqrt|symmetric|tan|tanh|transpose|'
1341
+ r'vector|zeros)\b', Name.Function),
1253
1342
  ],
1254
1343
  'operators': [
1255
- (r'(actualStream|and|assert|cardinality|change|Clock|delay|der|edge|'
1256
- r'hold|homotopy|initial|inStream|noEvent|not|or|pre|previous|reinit|'
1257
- r'return|sample|smooth|spatialDistribution|subSample|terminal|'
1344
+ (r'(actualStream|and|assert|backSample|cardinality|change|Clock|'
1345
+ r'delay|der|edge|hold|homotopy|initial|inStream|noClock|noEvent|'
1346
+ r'not|or|pre|previous|reinit|return|sample|smooth|'
1347
+ r'spatialDistribution|shiftSample|subSample|superSample|terminal|'
1258
1348
  r'terminate)\b', Name.Builtin),
1259
1349
  ],
1260
1350
  'classes': [
1261
- (r'(block|class|connector|function|model|package|'
1262
- r'record|type)(\s+)([A-Za-z_]+)',
1263
- bygroups(Keyword, Text, Name.Class))
1351
+ (r'(operator)?(\s+)?(block|class|connector|end|function|model|'
1352
+ r'operator|package|record|type)(\s+)'
1353
+ r'((?!if|for|when|while)[a-z_]\w*|\'[^\']+\')([;]?)',
1354
+ bygroups(Keyword, Text, Keyword, Text, Name.Class, Text))
1355
+ ],
1356
+ 'quoted_ident': [
1357
+ (r'\'', Name, '#pop'),
1358
+ (r'[^\']+', Name), # all other characters
1264
1359
  ],
1265
1360
  'string': [
1266
1361
  (r'"', String, '#pop'),
1267
- (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})',
1362
+ (r'\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})',
1268
1363
  String.Escape),
1269
1364
  (r'[^\\"\n]+', String), # all other characters
1270
1365
  (r'\\\n', String), # line continuation
1271
1366
  (r'\\', String), # stray backslash
1272
1367
  ],
1273
1368
  'html-content': [
1274
- (r'<\s*/\s*html\s*>', Name.Tag, '#pop'),
1369
+ (r'<\s*/\s*html\s*>"', Name.Tag, '#pop'),
1275
1370
  (r'.+?(?=<\s*/\s*html\s*>)', using(HtmlLexer)),
1276
1371
  ]
1277
1372
  }
@@ -1281,18 +1376,18 @@ class RebolLexer(RegexLexer):
1281
1376
  """
1282
1377
  A `REBOL <http://www.rebol.com/>`_ lexer.
1283
1378
 
1284
- *New in Pygments 1.1.*
1379
+ .. versionadded:: 1.1
1285
1380
  """
1286
1381
  name = 'REBOL'
1287
1382
  aliases = ['rebol']
1288
- filenames = ['*.r', '*.r3']
1383
+ filenames = ['*.r', '*.r3', '*.reb']
1289
1384
  mimetypes = ['text/x-rebol']
1290
1385
 
1291
1386
  flags = re.IGNORECASE | re.MULTILINE
1292
1387
 
1293
1388
  re.IGNORECASE
1294
1389
 
1295
- escape_re = r'(?:\^\([0-9a-fA-F]{1,4}\)*)'
1390
+ escape_re = r'(?:\^\([0-9a-f]{1,4}\)*)'
1296
1391
 
1297
1392
  def word_callback(lexer, match):
1298
1393
  word = match.group()
@@ -1381,16 +1476,16 @@ class RebolLexer(RegexLexer):
1381
1476
 
1382
1477
  tokens = {
1383
1478
  'root': [
1384
- (r'REBOL', Generic.Strong, 'script'),
1385
- (r'R', Comment),
1386
1479
  (r'[^R]+', Comment),
1480
+ (r'REBOL\s+\[', Generic.Strong, 'script'),
1481
+ (r'R', Comment)
1387
1482
  ],
1388
1483
  'script': [
1389
1484
  (r'\s+', Text),
1390
1485
  (r'#"', String.Char, 'char'),
1391
- (r'#{[0-9a-fA-F]*}', Number.Hex),
1486
+ (r'#{[0-9a-f]*}', Number.Hex),
1392
1487
  (r'2#{', Number.Hex, 'bin2'),
1393
- (r'64#{[0-9a-zA-Z+/=\s]*}', Number.Hex),
1488
+ (r'64#{[0-9a-z+/=\s]*}', Number.Hex),
1394
1489
  (r'"', String, 'string'),
1395
1490
  (r'{', String, 'string2'),
1396
1491
  (r';#+.*\n', Comment.Special),
@@ -1398,23 +1493,26 @@ class RebolLexer(RegexLexer):
1398
1493
  (r';.*\n', Comment),
1399
1494
  (r'%"', Name.Decorator, 'stringFile'),
1400
1495
  (r'%[^(\^{^")\s\[\]]+', Name.Decorator),
1401
- (r'[+-]?([a-zA-Z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
1496
+ (r'[+-]?([a-z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
1402
1497
  (r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
1403
- (r'\d+\-[0-9a-zA-Z]+\-\d+(\/\d+\:\d+(\:\d+)?'
1404
- r'([\.\d+]?([+-]?\d+:\d+)?)?)?', String.Other), # date
1498
+ (r'\d+[\-\/][0-9a-z]+[\-\/]\d+(\/\d+\:\d+((\:\d+)?'
1499
+ r'([\.\d+]?([+-]?\d+:\d+)?)?)?)?', String.Other), # date
1405
1500
  (r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
1406
1501
  (r'\d+[xX]\d+', Keyword.Constant), # pair
1407
1502
  (r'[+-]?\d+(\'\d+)?([\.,]\d*)?[eE][+-]?\d+', Number.Float),
1408
1503
  (r'[+-]?\d+(\'\d+)?[\.,]\d*', Number.Float),
1409
1504
  (r'[+-]?\d+(\'\d+)?', Number),
1410
1505
  (r'[\[\]\(\)]', Generic.Strong),
1411
- (r'[a-zA-Z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
1506
+ (r'[a-z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
1412
1507
  (r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
1413
1508
  (r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email
1414
- (r'comment\s', Comment, 'comment'),
1509
+ (r'comment\s"', Comment, 'commentString1'),
1510
+ (r'comment\s{', Comment, 'commentString2'),
1511
+ (r'comment\s\[', Comment, 'commentBlock'),
1512
+ (r'comment\s[^(\s{\"\[]+', Comment),
1415
1513
  (r'/[^(\^{^")\s/[\]]*', Name.Attribute),
1416
1514
  (r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
1417
- (r'<[a-zA-Z0-9:._-]*>', Name.Tag),
1515
+ (r'<[\w:.-]*>', Name.Tag),
1418
1516
  (r'<[^(<>\s")]+', Name.Tag, 'tag'),
1419
1517
  (r'([^(\^{^")\s]+)', Text),
1420
1518
  ],
@@ -1466,12 +1564,6 @@ class RebolLexer(RegexLexer):
1466
1564
  (r'([0-1]\s*){8}', Number.Hex),
1467
1565
  (r'}', Number.Hex, '#pop'),
1468
1566
  ],
1469
- 'comment': [
1470
- (r'"', Comment, 'commentString1'),
1471
- (r'{', Comment, 'commentString2'),
1472
- (r'\[', Comment, 'commentBlock'),
1473
- (r'[^(\s{\"\[]+', Comment, '#pop'),
1474
- ],
1475
1567
  'commentString1': [
1476
1568
  (r'[^(\^")]+', Comment),
1477
1569
  (escape_re, Comment),
@@ -1490,16 +1582,28 @@ class RebolLexer(RegexLexer):
1490
1582
  'commentBlock': [
1491
1583
  (r'\[', Comment, '#push'),
1492
1584
  (r'\]', Comment, '#pop'),
1493
- (r'[^(\[\])]+', Comment),
1585
+ (r'"', Comment, "commentString1"),
1586
+ (r'{', Comment, "commentString2"),
1587
+ (r'[^(\[\]\"{)]+', Comment),
1494
1588
  ],
1495
1589
  }
1590
+ def analyse_text(text):
1591
+ """
1592
+ Check if code contains REBOL header and so it probably not R code
1593
+ """
1594
+ if re.match(r'^\s*REBOL\s*\[', text, re.IGNORECASE):
1595
+ # The code starts with REBOL header
1596
+ return 1.0
1597
+ elif re.search(r'\s*REBOL\s*[', text, re.IGNORECASE):
1598
+ # The code contains REBOL header but also some text before it
1599
+ return 0.5
1496
1600
 
1497
1601
 
1498
1602
  class ABAPLexer(RegexLexer):
1499
1603
  """
1500
1604
  Lexer for ABAP, SAP's integrated language.
1501
1605
 
1502
- *New in Pygments 1.1.*
1606
+ .. versionadded:: 1.1
1503
1607
  """
1504
1608
  name = 'ABAP'
1505
1609
  aliases = ['abap']
@@ -1515,7 +1619,7 @@ class ABAPLexer(RegexLexer):
1515
1619
  (r'\".*?\n', Comment.Single),
1516
1620
  ],
1517
1621
  'variable-names': [
1518
- (r'<[\S_]+>', Name.Variable),
1622
+ (r'<\S+>', Name.Variable),
1519
1623
  (r'\w[\w~]*(?:(\[\])|->\*)?', Name.Variable),
1520
1624
  ],
1521
1625
  'root': [
@@ -1680,6 +1784,7 @@ class ABAPLexer(RegexLexer):
1680
1784
  # because < and > are part of field symbols.
1681
1785
  (r'[?*<>=\-+]', Operator),
1682
1786
  (r"'(''|[^'])*'", String.Single),
1787
+ (r"`([^`])*`", String.Single),
1683
1788
  (r'[/;:()\[\],\.]', Punctuation)
1684
1789
  ],
1685
1790
  }
@@ -1698,15 +1803,15 @@ class NewspeakLexer(RegexLexer):
1698
1803
  'root' : [
1699
1804
  (r'\b(Newsqueak2)\b',Keyword.Declaration),
1700
1805
  (r"'[^']*'",String),
1701
- (r'\b(class)(\s+)([a-zA-Z0-9_]+)(\s*)',
1806
+ (r'\b(class)(\s+)(\w+)(\s*)',
1702
1807
  bygroups(Keyword.Declaration,Text,Name.Class,Text)),
1703
1808
  (r'\b(mixin|self|super|private|public|protected|nil|true|false)\b',
1704
1809
  Keyword),
1705
- (r'([a-zA-Z0-9_]+\:)(\s*)([a-zA-Z_]\w+)',
1810
+ (r'(\w+\:)(\s*)([a-zA-Z_]\w+)',
1706
1811
  bygroups(Name.Function,Text,Name.Variable)),
1707
- (r'([a-zA-Z0-9_]+)(\s*)(=)',
1812
+ (r'(\w+)(\s*)(=)',
1708
1813
  bygroups(Name.Attribute,Text,Operator)),
1709
- (r'<[a-zA-Z0-9_]+>', Comment.Special),
1814
+ (r'<\w+>', Comment.Special),
1710
1815
  include('expressionstat'),
1711
1816
  include('whitespace')
1712
1817
  ],
@@ -1746,21 +1851,21 @@ class GherkinLexer(RegexLexer):
1746
1851
  """
1747
1852
  For `Gherkin <http://github.com/aslakhellesoy/gherkin/>` syntax.
1748
1853
 
1749
- *New in Pygments 1.2.*
1854
+ .. versionadded:: 1.2
1750
1855
  """
1751
1856
  name = 'Gherkin'
1752
- aliases = ['Cucumber', 'cucumber', 'Gherkin', 'gherkin']
1857
+ aliases = ['cucumber', 'gherkin']
1753
1858
  filenames = ['*.feature']
1754
1859
  mimetypes = ['text/x-gherkin']
1755
1860
 
1756
- feature_keywords = ur'^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Özellik|Właściwość|Tính năng|Trajto|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$'
1757
- feature_element_keywords = ur'^(\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y\'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$'
1758
- examples_keywords = ur'^(\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Приклади|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$'
1759
- step_keywords = ur'^(\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假如|但是|但し|並且|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y\'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y\'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\* )'
1861
+ feature_keywords = u'^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Özellik|Właściwość|Tính năng|Trajto|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$'
1862
+ feature_element_keywords = u'^(\\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y\'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$'
1863
+ examples_keywords = u'^(\\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Приклади|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$'
1864
+ step_keywords = u'^(\\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假如|但是|但し|並且|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y\'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y\'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\* )'
1760
1865
 
1761
1866
  tokens = {
1762
1867
  'comments': [
1763
- (r'#.*$', Comment),
1868
+ (r'^\s*#.*$', Comment),
1764
1869
  ],
1765
1870
  'feature_elements' : [
1766
1871
  (step_keywords, Keyword, "step_content_stack"),
@@ -1780,14 +1885,18 @@ class GherkinLexer(RegexLexer):
1780
1885
  'examples_table_header': [
1781
1886
  (r"\s+\|\s*$", Keyword, "#pop:2"),
1782
1887
  include('comments'),
1888
+ (r"\\\|", Name.Variable),
1783
1889
  (r"\s*\|", Keyword),
1784
1890
  (r"[^\|]", Name.Variable),
1785
1891
  ],
1786
1892
  'scenario_sections_on_stack': [
1787
- (feature_element_keywords, bygroups(Name.Function, Keyword, Keyword, Name.Function), "feature_elements_on_stack"),
1893
+ (feature_element_keywords,
1894
+ bygroups(Name.Function, Keyword, Keyword, Name.Function),
1895
+ "feature_elements_on_stack"),
1788
1896
  ],
1789
1897
  'narrative': [
1790
1898
  include('scenario_sections_on_stack'),
1899
+ include('comments'),
1791
1900
  (r"(\s|.)", Name.Function),
1792
1901
  ],
1793
1902
  'table_vars': [
@@ -1822,6 +1931,7 @@ class GherkinLexer(RegexLexer):
1822
1931
  'table_content': [
1823
1932
  (r"\s+\|\s*$", Keyword, "#pop"),
1824
1933
  include('comments'),
1934
+ (r"\\\|", String),
1825
1935
  (r"\s*\|", Keyword),
1826
1936
  include('string'),
1827
1937
  ],
@@ -1856,7 +1966,7 @@ class AsymptoteLexer(RegexLexer):
1856
1966
  """
1857
1967
  For `Asymptote <http://asymptote.sf.net/>`_ source code.
1858
1968
 
1859
- *New in Pygments 1.2.*
1969
+ .. versionadded:: 1.2
1860
1970
  """
1861
1971
  name = 'Asymptote'
1862
1972
  aliases = ['asy', 'asymptote']
@@ -1912,23 +2022,23 @@ class AsymptoteLexer(RegexLexer):
1912
2022
  r'bounds|coord|frame|guide|horner|int|linefit|marginT|pair|pen|'
1913
2023
  r'picture|position|real|revolution|slice|splitface|ticksgridT|'
1914
2024
  r'tickvalues|tree|triple|vertex|void)\b', Keyword.Type),
1915
- ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
1916
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
2025
+ ('[a-zA-Z_]\w*:(?!:)', Name.Label),
2026
+ ('[a-zA-Z_]\w*', Name),
1917
2027
  ],
1918
2028
  'root': [
1919
2029
  include('whitespace'),
1920
2030
  # functions
1921
- (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|\*))' # return arguments
1922
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
1923
- r'(\s*\([^;]*?\))' # signature
2031
+ (r'((?:[\w*\s])+?(?:\s|\*))' # return arguments
2032
+ r'([a-zA-Z_]\w*)' # method name
2033
+ r'(\s*\([^;]*?\))' # signature
1924
2034
  r'(' + _ws + r')({)',
1925
2035
  bygroups(using(this), Name.Function, using(this), using(this),
1926
2036
  Punctuation),
1927
2037
  'function'),
1928
2038
  # function declarations
1929
- (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|\*))' # return arguments
1930
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
1931
- r'(\s*\([^;]*?\))' # signature
2039
+ (r'((?:[\w*\s])+?(?:\s|\*))' # return arguments
2040
+ r'([a-zA-Z_]\w*)' # method name
2041
+ r'(\s*\([^;]*?\))' # signature
1932
2042
  r'(' + _ws + r')(;)',
1933
2043
  bygroups(using(this), Name.Function, using(this), using(this),
1934
2044
  Punctuation)),
@@ -1977,7 +2087,7 @@ class PostScriptLexer(RegexLexer):
1977
2087
  <http://partners.adobe.com/public/developer/en/ps/PLRM.pdf>
1978
2088
  is the authority for this.
1979
2089
 
1980
- *New in Pygments 1.4.*
2090
+ .. versionadded:: 1.4
1981
2091
  """
1982
2092
  name = 'PostScript'
1983
2093
  aliases = ['postscript', 'postscr']
@@ -2065,7 +2175,7 @@ class AutohotkeyLexer(RegexLexer):
2065
2175
  """
2066
2176
  For `autohotkey <http://www.autohotkey.com/>`_ source code.
2067
2177
 
2068
- *New in Pygments 1.4.*
2178
+ .. versionadded:: 1.4
2069
2179
  """
2070
2180
  name = 'autohotkey'
2071
2181
  aliases = ['ahk', 'autohotkey']
@@ -2081,7 +2191,7 @@ class AutohotkeyLexer(RegexLexer):
2081
2191
  (r'^;.*?$', Comment.Singleline),
2082
2192
  (r'[]{}(),;[]', Punctuation),
2083
2193
  (r'(in|is|and|or|not)\b', Operator.Word),
2084
- (r'\%[a-zA-Z_#@$][a-zA-Z0-9_#@$]*\%', Name.Variable),
2194
+ (r'\%[a-zA-Z_#@$][\w#@$]*\%', Name.Variable),
2085
2195
  (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator),
2086
2196
  include('commands'),
2087
2197
  include('labels'),
@@ -2089,7 +2199,7 @@ class AutohotkeyLexer(RegexLexer):
2089
2199
  include('builtInVariables'),
2090
2200
  (r'"', String, combined('stringescape', 'dqs')),
2091
2201
  include('numbers'),
2092
- (r'[a-zA-Z_#@$][a-zA-Z0-9_#@$]*', Name),
2202
+ (r'[a-zA-Z_#@$][\w#@$]*', Name),
2093
2203
  (r'\\|\'', Text),
2094
2204
  (r'\`([\,\%\`abfnrtv\-\+;])', String.Escape),
2095
2205
  include('garbage'),
@@ -2245,7 +2355,7 @@ class MaqlLexer(RegexLexer):
2245
2355
  <https://secure.gooddata.com/docs/html/advanced.metric.tutorial.html>`_
2246
2356
  scripts.
2247
2357
 
2248
- *New in Pygments 1.4.*
2358
+ .. versionadded:: 1.4
2249
2359
  """
2250
2360
 
2251
2361
  name = 'MAQL'
@@ -2283,7 +2393,7 @@ class MaqlLexer(RegexLexer):
2283
2393
  r'SYNCHRONIZE|TYPE|DEFAULT|ORDER|ASC|DESC|HYPERLINK|'
2284
2394
  r'INCLUDE|TEMPLATE|MODIFY)\b', Keyword),
2285
2395
  # FUNCNAME
2286
- (r'[a-zA-Z]\w*\b', Name.Function),
2396
+ (r'[a-z]\w*\b', Name.Function),
2287
2397
  # Comments
2288
2398
  (r'#.*', Comment.Single),
2289
2399
  # Punctuation
@@ -2304,7 +2414,7 @@ class GoodDataCLLexer(RegexLexer):
2304
2414
  Lexer for `GoodData-CL <http://github.com/gooddata/GoodData-CL/raw/master/cli/src/main/resources/com/gooddata/processor/COMMANDS.txt>`_
2305
2415
  script files.
2306
2416
 
2307
- *New in Pygments 1.4.*
2417
+ .. versionadded:: 1.4
2308
2418
  """
2309
2419
 
2310
2420
  name = 'GoodData-CL'
@@ -2318,7 +2428,7 @@ class GoodDataCLLexer(RegexLexer):
2318
2428
  # Comments
2319
2429
  (r'#.*', Comment.Single),
2320
2430
  # Function call
2321
- (r'[a-zA-Z]\w*', Name.Function),
2431
+ (r'[a-z]\w*', Name.Function),
2322
2432
  # Argument list
2323
2433
  (r'\(', Token.Punctuation, 'args-list'),
2324
2434
  # Punctuation
@@ -2329,7 +2439,7 @@ class GoodDataCLLexer(RegexLexer):
2329
2439
  'args-list': [
2330
2440
  (r'\)', Token.Punctuation, '#pop'),
2331
2441
  (r',', Token.Punctuation),
2332
- (r'[a-zA-Z]\w*', Name.Variable),
2442
+ (r'[a-z]\w*', Name.Variable),
2333
2443
  (r'=', Operator),
2334
2444
  (r'"', Literal.String, 'string-literal'),
2335
2445
  (r'[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]{1,3})?', Literal.Number),
@@ -2349,7 +2459,7 @@ class ProtoBufLexer(RegexLexer):
2349
2459
  Lexer for `Protocol Buffer <http://code.google.com/p/protobuf/>`_
2350
2460
  definition files.
2351
2461
 
2352
- *New in Pygments 1.4.*
2462
+ .. versionadded:: 1.4
2353
2463
  """
2354
2464
 
2355
2465
  name = 'Protocol Buffer'
@@ -2381,18 +2491,18 @@ class ProtoBufLexer(RegexLexer):
2381
2491
  (r'0[0-7]+[LlUu]*', Number.Oct),
2382
2492
  (r'\d+[LlUu]*', Number.Integer),
2383
2493
  (r'[+-=]', Operator),
2384
- (r'([a-zA-Z_][a-zA-Z0-9_\.]*)([ \t]*)(=)',
2494
+ (r'([a-zA-Z_][\w\.]*)([ \t]*)(=)',
2385
2495
  bygroups(Name.Attribute, Text, Operator)),
2386
- ('[a-zA-Z_][a-zA-Z0-9_\.]*', Name),
2496
+ ('[a-zA-Z_][\w\.]*', Name),
2387
2497
  ],
2388
2498
  'package': [
2389
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Namespace, '#pop')
2499
+ (r'[a-zA-Z_]\w*', Name.Namespace, '#pop')
2390
2500
  ],
2391
2501
  'message': [
2392
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
2502
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
2393
2503
  ],
2394
2504
  'type': [
2395
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name, '#pop')
2505
+ (r'[a-zA-Z_]\w*', Name, '#pop')
2396
2506
  ],
2397
2507
  }
2398
2508
 
@@ -2401,7 +2511,7 @@ class HybrisLexer(RegexLexer):
2401
2511
  """
2402
2512
  For `Hybris <http://www.hybris-lang.org>`_ source code.
2403
2513
 
2404
- *New in Pygments 1.4.*
2514
+ .. versionadded:: 1.4
2405
2515
  """
2406
2516
 
2407
2517
  name = 'Hybris'
@@ -2415,12 +2525,12 @@ class HybrisLexer(RegexLexer):
2415
2525
  'root': [
2416
2526
  # method names
2417
2527
  (r'^(\s*(?:function|method|operator\s+)+?)'
2418
- r'([a-zA-Z_][a-zA-Z0-9_]*)'
2528
+ r'([a-zA-Z_]\w*)'
2419
2529
  r'(\s*)(\()', bygroups(Keyword, Name.Function, Text, Operator)),
2420
2530
  (r'[^\S\n]+', Text),
2421
2531
  (r'//.*?\n', Comment.Single),
2422
2532
  (r'/\*.*?\*/', Comment.Multiline),
2423
- (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
2533
+ (r'@[a-zA-Z_][\w\.]*', Name.Decorator),
2424
2534
  (r'(break|case|catch|next|default|do|else|finally|for|foreach|of|'
2425
2535
  r'unless|if|new|return|switch|me|throw|try|while)\b', Keyword),
2426
2536
  (r'(extends|private|protected|public|static|throws|function|method|'
@@ -2456,10 +2566,10 @@ class HybrisLexer(RegexLexer):
2456
2566
  r'Exception)\b', Keyword.Type),
2457
2567
  (r'"(\\\\|\\"|[^"])*"', String),
2458
2568
  (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
2459
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)',
2569
+ (r'(\.)([a-zA-Z_]\w*)',
2460
2570
  bygroups(Operator, Name.Attribute)),
2461
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
2462
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
2571
+ (r'[a-zA-Z_]\w*:', Name.Label),
2572
+ (r'[a-zA-Z_\$]\w*', Name),
2463
2573
  (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?\-@]+', Operator),
2464
2574
  (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
2465
2575
  (r'0x[0-9a-f]+', Number.Hex),
@@ -2467,10 +2577,10 @@ class HybrisLexer(RegexLexer):
2467
2577
  (r'\n', Text),
2468
2578
  ],
2469
2579
  'class': [
2470
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
2580
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
2471
2581
  ],
2472
2582
  'import': [
2473
- (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
2583
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
2474
2584
  ],
2475
2585
  }
2476
2586
 
@@ -2479,7 +2589,7 @@ class AwkLexer(RegexLexer):
2479
2589
  """
2480
2590
  For Awk scripts.
2481
2591
 
2482
- *New in Pygments 1.5.*
2592
+ .. versionadded:: 1.5
2483
2593
  """
2484
2594
 
2485
2595
  name = 'Awk'
@@ -2497,7 +2607,7 @@ class AwkLexer(RegexLexer):
2497
2607
  (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
2498
2608
  r'\B', String.Regex, '#pop'),
2499
2609
  (r'(?=/)', Text, ('#pop', 'badregex')),
2500
- (r'', Text, '#pop')
2610
+ default('#pop')
2501
2611
  ],
2502
2612
  'badregex': [
2503
2613
  (r'\n', Text, '#pop')
@@ -2505,11 +2615,11 @@ class AwkLexer(RegexLexer):
2505
2615
  'root': [
2506
2616
  (r'^(?=\s|/)', Text, 'slashstartsregex'),
2507
2617
  include('commentsandwhitespace'),
2508
- (r'\+\+|--|\|\||&&|in|\$|!?~|'
2618
+ (r'\+\+|--|\|\||&&|in\b|\$|!?~|'
2509
2619
  r'(\*\*|[-<>+*%\^/!=])=?', Operator, 'slashstartsregex'),
2510
2620
  (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
2511
2621
  (r'[})\].]', Punctuation),
2512
- (r'(break|continue|do|while|exit|for|if|'
2622
+ (r'(break|continue|do|while|exit|for|if|else|'
2513
2623
  r'return)\b', Keyword, 'slashstartsregex'),
2514
2624
  (r'function\b', Keyword.Declaration, 'slashstartsregex'),
2515
2625
  (r'(atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|'
@@ -2519,7 +2629,7 @@ class AwkLexer(RegexLexer):
2519
2629
  (r'(ARGC|ARGIND|ARGV|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS|FILENAME|FNR|FS|'
2520
2630
  r'IGNORECASE|NF|NR|OFMT|OFS|ORFS|RLENGTH|RS|RSTART|RT|'
2521
2631
  r'SUBSEP)\b', Name.Builtin),
2522
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
2632
+ (r'[$a-zA-Z_]\w*', Name.Other),
2523
2633
  (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
2524
2634
  (r'0x[0-9a-fA-F]+', Number.Hex),
2525
2635
  (r'[0-9]+', Number.Integer),
@@ -2533,7 +2643,7 @@ class Cfengine3Lexer(RegexLexer):
2533
2643
  """
2534
2644
  Lexer for `CFEngine3 <http://cfengine.org>`_ policy files.
2535
2645
 
2536
- *New in Pygments 1.5.*
2646
+ .. versionadded:: 1.5
2537
2647
  """
2538
2648
 
2539
2649
  name = 'CFEngine3'
@@ -2597,7 +2707,7 @@ class SnobolLexer(RegexLexer):
2597
2707
  Recognizes the common ASCII equivalents of the original SNOBOL4 operators.
2598
2708
  Does not require spaces around binary operators.
2599
2709
 
2600
- *New in Pygments 1.5.*
2710
+ .. versionadded:: 1.5
2601
2711
  """
2602
2712
 
2603
2713
  name = "Snobol"
@@ -2661,7 +2771,7 @@ class UrbiscriptLexer(ExtendedRegexLexer):
2661
2771
  """
2662
2772
  For UrbiScript source code.
2663
2773
 
2664
- *New in Pygments 1.5.*
2774
+ .. versionadded:: 1.5
2665
2775
  """
2666
2776
 
2667
2777
  name = 'UrbiScript'
@@ -2736,7 +2846,7 @@ class UrbiscriptLexer(ExtendedRegexLexer):
2736
2846
  Operator.Word),
2737
2847
  (r'[{}\[\]()]+', Punctuation),
2738
2848
  (r'(?:;|\||,|&|\?|!)+', Punctuation),
2739
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
2849
+ (r'[$a-zA-Z_]\w*', Name.Other),
2740
2850
  (r'0x[0-9a-fA-F]+', Number.Hex),
2741
2851
  # Float, Integer, Angle and Duration
2742
2852
  (r'(?:[0-9]+(?:(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)?'
@@ -2768,7 +2878,7 @@ class OpenEdgeLexer(RegexLexer):
2768
2878
  Lexer for `OpenEdge ABL (formerly Progress)
2769
2879
  <http://web.progress.com/en/openedge/abl.html>`_ source code.
2770
2880
 
2771
- *New in Pygments 1.5.*
2881
+ .. versionadded:: 1.5
2772
2882
  """
2773
2883
  name = 'OpenEdge ABL'
2774
2884
  aliases = ['openedge', 'abl', 'progress']
@@ -2820,7 +2930,7 @@ class BroLexer(RegexLexer):
2820
2930
  """
2821
2931
  For `Bro <http://bro-ids.org/>`_ scripts.
2822
2932
 
2823
- *New in Pygments 1.5.*
2933
+ .. versionadded:: 1.5
2824
2934
  """
2825
2935
  name = 'Bro'
2826
2936
  aliases = ['bro']
@@ -2898,7 +3008,7 @@ class CbmBasicV2Lexer(RegexLexer):
2898
3008
  """
2899
3009
  For CBM BASIC V2 sources.
2900
3010
 
2901
- *New in Pygments 1.6.*
3011
+ .. versionadded:: 1.6
2902
3012
  """
2903
3013
  name = 'CBM BASIC V2'
2904
3014
  aliases = ['cbmbas']
@@ -2936,13 +3046,13 @@ class MscgenLexer(RegexLexer):
2936
3046
  """
2937
3047
  For `Mscgen <http://www.mcternan.me.uk/mscgen/>`_ files.
2938
3048
 
2939
- *New in Pygments 1.6.*
3049
+ .. versionadded:: 1.6
2940
3050
  """
2941
3051
  name = 'Mscgen'
2942
3052
  aliases = ['mscgen', 'msc']
2943
3053
  filenames = ['*.msc']
2944
3054
 
2945
- _var = r'([a-zA-Z0-9_]+|"(?:\\"|[^"])*")'
3055
+ _var = r'(\w+|"(?:\\"|[^"])*")'
2946
3056
 
2947
3057
  tokens = {
2948
3058
  'root': [
@@ -2997,7 +3107,7 @@ class KconfigLexer(RegexLexer):
2997
3107
  """
2998
3108
  For Linux-style Kconfig files.
2999
3109
 
3000
- *New in Pygments 1.6.*
3110
+ .. versionadded:: 1.6
3001
3111
  """
3002
3112
 
3003
3113
  name = 'Kconfig'
@@ -3019,7 +3129,7 @@ class KconfigLexer(RegexLexer):
3019
3129
  return [
3020
3130
  (_rx_indent(level), String.Doc),
3021
3131
  (r'\s*\n', Text),
3022
- (r'', Generic, '#pop:2')
3132
+ default('#pop:2')
3023
3133
  ]
3024
3134
 
3025
3135
  tokens = {
@@ -3072,7 +3182,7 @@ class VGLLexer(RegexLexer):
3072
3182
  For `SampleManager VGL <http://www.thermoscientific.com/samplemanager>`_
3073
3183
  source code.
3074
3184
 
3075
- *New in Pygments 1.6.*
3185
+ .. versionadded:: 1.6
3076
3186
  """
3077
3187
  name = 'VGL'
3078
3188
  aliases = ['vgl']
@@ -3092,9 +3202,9 @@ class VGLLexer(RegexLexer):
3092
3202
  (r'(true|false|null|empty|error|locked)', Keyword.Constant),
3093
3203
  (r'[~\^\*\#!%&\[\]\(\)<>\|+=:;,./?-]', Operator),
3094
3204
  (r'"[^"]*"', String),
3095
- (r'(\.)([a-z_\$][a-z0-9_\$]*)', bygroups(Operator, Name.Attribute)),
3205
+ (r'(\.)([a-z_\$][\w\$]*)', bygroups(Operator, Name.Attribute)),
3096
3206
  (r'[0-9][0-9]*(\.[0-9]+(e[+\-]?[0-9]+)?)?', Number),
3097
- (r'[a-z_\$][a-z0-9_\$]*', Name),
3207
+ (r'[a-z_\$][\w\$]*', Name),
3098
3208
  (r'[\r\n]+', Text),
3099
3209
  (r'\s+', Text)
3100
3210
  ]
@@ -3105,7 +3215,7 @@ class SourcePawnLexer(RegexLexer):
3105
3215
  """
3106
3216
  For SourcePawn source code with preprocessor directives.
3107
3217
 
3108
- *New in Pygments 1.6.*
3218
+ .. versionadded:: 1.6
3109
3219
  """
3110
3220
  name = 'SourcePawn'
3111
3221
  aliases = ['sp']
@@ -3144,7 +3254,7 @@ class SourcePawnLexer(RegexLexer):
3144
3254
  r'public|return|sizeof|static|decl|struct|switch)\b', Keyword),
3145
3255
  (r'(bool|Float)\b', Keyword.Type),
3146
3256
  (r'(true|false)\b', Keyword.Constant),
3147
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
3257
+ ('[a-zA-Z_]\w*', Name),
3148
3258
  ],
3149
3259
  'string': [
3150
3260
  (r'"', String, '#pop'),
@@ -3168,7 +3278,7 @@ class SourcePawnLexer(RegexLexer):
3168
3278
  ]
3169
3279
  }
3170
3280
 
3171
- SM_TYPES = ['Action', 'bool', 'Float', 'Plugin', 'String', 'any',
3281
+ SM_TYPES = set(['Action', 'bool', 'Float', 'Plugin', 'String', 'any',
3172
3282
  'AdminFlag', 'OverrideType', 'OverrideRule', 'ImmunityType',
3173
3283
  'GroupId', 'AdminId', 'AdmAccessMode', 'AdminCachePart',
3174
3284
  'CookieAccess', 'CookieMenu', 'CookieMenuAction', 'NetFlow',
@@ -3186,16 +3296,16 @@ class SourcePawnLexer(RegexLexer):
3186
3296
  'SortFunc2D', 'APLRes', 'FeatureType', 'FeatureStatus',
3187
3297
  'SMCResult', 'SMCError', 'TFClassType', 'TFTeam', 'TFCond',
3188
3298
  'TFResourceType', 'Timer', 'TopMenuAction', 'TopMenuObjectType',
3189
- 'TopMenuPosition', 'TopMenuObject', 'UserMsg']
3299
+ 'TopMenuPosition', 'TopMenuObject', 'UserMsg'])
3190
3300
 
3191
3301
  def __init__(self, **options):
3192
3302
  self.smhighlighting = get_bool_opt(options,
3193
3303
  'sourcemod', True)
3194
3304
 
3195
- self._functions = []
3305
+ self._functions = set()
3196
3306
  if self.smhighlighting:
3197
3307
  from pygments.lexers._sourcemodbuiltins import FUNCTIONS
3198
- self._functions.extend(FUNCTIONS)
3308
+ self._functions.update(FUNCTIONS)
3199
3309
  RegexLexer.__init__(self, **options)
3200
3310
 
3201
3311
  def get_tokens_unprocessed(self, text):
@@ -3214,7 +3324,7 @@ class PuppetLexer(RegexLexer):
3214
3324
  """
3215
3325
  For `Puppet <http://puppetlabs.com/>`__ configuration DSL.
3216
3326
 
3217
- *New in Pygments 1.6.*
3327
+ .. versionadded:: 1.6
3218
3328
  """
3219
3329
  name = 'Puppet'
3220
3330
  aliases = ['puppet']
@@ -3244,7 +3354,7 @@ class PuppetLexer(RegexLexer):
3244
3354
  ],
3245
3355
 
3246
3356
  'names': [
3247
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Attribute),
3357
+ ('[a-zA-Z_]\w*', Name.Attribute),
3248
3358
  (r'(\$\S+)(\[)(\S+)(\])', bygroups(Name.Variable, Punctuation,
3249
3359
  String, Punctuation)),
3250
3360
  (r'\$\S+', Name.Variable),
@@ -3285,7 +3395,7 @@ class PuppetLexer(RegexLexer):
3285
3395
 
3286
3396
  'strings': [
3287
3397
  (r'"([^"])*"', String),
3288
- (r'\'([^\'])*\'', String),
3398
+ (r"'(\\'|[^'])*'", String),
3289
3399
  ],
3290
3400
 
3291
3401
  }
@@ -3295,7 +3405,7 @@ class NSISLexer(RegexLexer):
3295
3405
  """
3296
3406
  For `NSIS <http://nsis.sourceforge.net/>`_ scripts.
3297
3407
 
3298
- *New in Pygments 1.6.*
3408
+ .. versionadded:: 1.6
3299
3409
  """
3300
3410
  name = 'NSIS'
3301
3411
  aliases = ['nsis', 'nsi', 'nsh']
@@ -3417,9 +3527,9 @@ class NSISLexer(RegexLexer):
3417
3527
 
3418
3528
  class RPMSpecLexer(RegexLexer):
3419
3529
  """
3420
- For RPM *.spec files
3530
+ For RPM ``.spec`` files.
3421
3531
 
3422
- *New in Pygments 1.6.*
3532
+ .. versionadded:: 1.6
3423
3533
  """
3424
3534
 
3425
3535
  name = 'RPMSpec'
@@ -3481,9 +3591,9 @@ class RPMSpecLexer(RegexLexer):
3481
3591
  'interpol': [
3482
3592
  (r'%\{?__[a-z_]+\}?', Name.Function),
3483
3593
  (r'%\{?_([a-z_]+dir|[a-z_]+path|prefix)\}?', Keyword.Pseudo),
3484
- (r'%\{\?[A-Za-z0-9_]+\}', Name.Variable),
3594
+ (r'%\{\?\w+\}', Name.Variable),
3485
3595
  (r'\$\{?RPM_[A-Z0-9_]+\}?', Name.Variable.Global),
3486
- (r'%\{[a-zA-Z][a-zA-Z0-9_]+\}', Keyword.Constant),
3596
+ (r'%\{[a-zA-Z]\w+\}', Keyword.Constant),
3487
3597
  ]
3488
3598
  }
3489
3599
 
@@ -3495,10 +3605,10 @@ class AutoItLexer(RegexLexer):
3495
3605
  AutoIt is a freeware BASIC-like scripting language
3496
3606
  designed for automating the Windows GUI and general scripting
3497
3607
 
3498
- *New in Pygments 1.6.*
3608
+ .. versionadded:: 1.6
3499
3609
  """
3500
3610
  name = 'AutoIt'
3501
- aliases = ['autoit', 'Autoit']
3611
+ aliases = ['autoit']
3502
3612
  filenames = ['*.au3']
3503
3613
  mimetypes = ['text/x-autoit']
3504
3614
 
@@ -3614,7 +3724,7 @@ class AutoItLexer(RegexLexer):
3614
3724
  (r'(#comments-start|#cs).*?(#comments-end|#ce)', Comment.Multiline),
3615
3725
  (r'[\[\]{}(),;]', Punctuation),
3616
3726
  (r'(and|or|not)\b', Operator.Word),
3617
- (r'[\$|@][a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
3727
+ (r'[\$|@][a-zA-Z_]\w*', Name.Variable),
3618
3728
  (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator),
3619
3729
  include('commands'),
3620
3730
  include('labels'),
@@ -3622,7 +3732,7 @@ class AutoItLexer(RegexLexer):
3622
3732
  include('builtInMarcros'),
3623
3733
  (r'"', String, combined('stringescape', 'dqs')),
3624
3734
  include('numbers'),
3625
- (r'[a-zA-Z_#@$][a-zA-Z0-9_#@$]*', Name),
3735
+ (r'[a-zA-Z_#@$][\w#@$]*', Name),
3626
3736
  (r'\\|\'', Text),
3627
3737
  (r'\`([\,\%\`abfnrtv\-\+;])', String.Escape),
3628
3738
  (r'_\n', Text), # Line continuation
@@ -3675,10 +3785,10 @@ class RexxLexer(RegexLexer):
3675
3785
  systems. It is popular for I/O- and data based tasks and can act as glue
3676
3786
  language to bind different applications together.
3677
3787
 
3678
- *New in Pygments 1.7.*
3788
+ .. versionadded:: 2.0
3679
3789
  """
3680
3790
  name = 'Rexx'
3681
- aliases = ['rexx', 'ARexx', 'arexx']
3791
+ aliases = ['rexx', 'arexx']
3682
3792
  filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx']
3683
3793
  mimetypes = ['text/x-rexx']
3684
3794
  flags = re.IGNORECASE
@@ -3690,15 +3800,15 @@ class RexxLexer(RegexLexer):
3690
3800
  (r'"', String, 'string_double'),
3691
3801
  (r"'", String, 'string_single'),
3692
3802
  (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number),
3693
- (r'([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)\b',
3803
+ (r'([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b',
3694
3804
  bygroups(Name.Function, Whitespace, Operator, Whitespace,
3695
3805
  Keyword.Declaration)),
3696
- (r'([a-z_][a-z0-9_]*)(\s*)(:)',
3806
+ (r'([a-z_]\w*)(\s*)(:)',
3697
3807
  bygroups(Name.Label, Whitespace, Operator)),
3698
3808
  include('function'),
3699
3809
  include('keyword'),
3700
3810
  include('operator'),
3701
- (r'[a-z_][a-z0-9_]*', Text),
3811
+ (r'[a-z_]\w*', Text),
3702
3812
  ],
3703
3813
  'function': [
3704
3814
  (r'(abbrev|abs|address|arg|b2x|bitand|bitor|bitxor|c2d|c2x|'
@@ -3718,9 +3828,9 @@ class RexxLexer(RegexLexer):
3718
3828
  r'while)\b', Keyword.Reserved),
3719
3829
  ],
3720
3830
  'operator': [
3721
- (ur'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||'
3722
- ur'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|'
3723
- ur'¬>>|¬>|¬|\.|,)', Operator),
3831
+ (r'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||'
3832
+ r'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|'
3833
+ r'¬>>|¬>|¬|\.|,)', Operator),
3724
3834
  ],
3725
3835
  'string_double': [
3726
3836
  (r'[^"\n]+', String),
@@ -3746,7 +3856,7 @@ class RexxLexer(RegexLexer):
3746
3856
  _ADDRESS_PATTERN = _c(r'^\s*address\s+')
3747
3857
  _DO_WHILE_PATTERN = _c(r'^\s*do\s+while\b')
3748
3858
  _IF_THEN_DO_PATTERN = _c(r'^\s*if\b.+\bthen\s+do\s*$')
3749
- _PROCEDURE_PATTERN = _c(r'^\s*([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)\b')
3859
+ _PROCEDURE_PATTERN = _c(r'^\s*([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b')
3750
3860
  _ELSE_DO_PATTERN = _c(r'\belse\s+do\s*$')
3751
3861
  _PARSE_ARG_PATTERN = _c(r'^\s*parse\s+(upper\s+)?(arg|value)\b')
3752
3862
  PATTERNS_AND_WEIGHTS = (
@@ -3776,3 +3886,607 @@ class RexxLexer(RegexLexer):
3776
3886
  for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS
3777
3887
  if pattern.search(lowerText)) + 0.01
3778
3888
  return min(result, 1.0)
3889
+
3890
+
3891
+ class APLLexer(RegexLexer):
3892
+ """
3893
+ A simple APL lexer.
3894
+
3895
+ .. versionadded:: 2.0
3896
+ """
3897
+ name = 'APL'
3898
+ aliases = ['apl']
3899
+ filenames = ['*.apl']
3900
+
3901
+ tokens = {
3902
+ 'root': [
3903
+ # Whitespace
3904
+ # ==========
3905
+ (r'\s+', Text),
3906
+ #
3907
+ # Comment
3908
+ # =======
3909
+ # '⍝' is traditional; '#' is supported by GNU APL and NGN (but not Dyalog)
3910
+ (u'[⍝#].*$', Comment.Single),
3911
+ #
3912
+ # Strings
3913
+ # =======
3914
+ (r'\'((\'\')|[^\'])*\'', String.Single),
3915
+ (r'"(("")|[^"])*"', String.Double), # supported by NGN APL
3916
+ #
3917
+ # Punctuation
3918
+ # ===========
3919
+ # This token type is used for diamond and parenthesis
3920
+ # but not for bracket and ; (see below)
3921
+ (u'[⋄◇()]', Punctuation),
3922
+ #
3923
+ # Array indexing
3924
+ # ==============
3925
+ # Since this token type is very important in APL, it is not included in
3926
+ # the punctuation token type but rather in the following one
3927
+ (r'[\[\];]', String.Regex),
3928
+ #
3929
+ # Distinguished names
3930
+ # ===================
3931
+ # following IBM APL2 standard
3932
+ (u'⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Function),
3933
+ #
3934
+ # Labels
3935
+ # ======
3936
+ # following IBM APL2 standard
3937
+ # (u'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*:', Name.Label),
3938
+ #
3939
+ # Variables
3940
+ # =========
3941
+ # following IBM APL2 standard
3942
+ (u'[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*', Name.Variable),
3943
+ #
3944
+ # Numbers
3945
+ # =======
3946
+ (u'¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)'
3947
+ u'([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?',
3948
+ Number),
3949
+ #
3950
+ # Operators
3951
+ # ==========
3952
+ (u'[\.\\\/⌿⍀¨⍣⍨⍠⍤∘]', Name.Attribute), # closest token type
3953
+ (u'[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗]',
3954
+ Operator),
3955
+ #
3956
+ # Constant
3957
+ # ========
3958
+ (u'⍬', Name.Constant),
3959
+ #
3960
+ # Quad symbol
3961
+ # ===========
3962
+ (u'[⎕⍞]', Name.Variable.Global),
3963
+ #
3964
+ # Arrows left/right
3965
+ # =================
3966
+ (u'[←→]', Keyword.Declaration),
3967
+ #
3968
+ # D-Fn
3969
+ # ====
3970
+ (u'[⍺⍵⍶⍹∇:]', Name.Builtin.Pseudo),
3971
+ (r'[{}]', Keyword.Type),
3972
+ ],
3973
+ }
3974
+
3975
+ class AmbientTalkLexer(RegexLexer):
3976
+ """
3977
+ Lexer for `AmbientTalk <https://code.google.com/p/ambienttalk>`_ source code.
3978
+
3979
+ .. versionadded:: 2.0
3980
+ """
3981
+ name = 'AmbientTalk'
3982
+ filenames = ['*.at']
3983
+ aliases = ['at', 'ambienttalk', 'ambienttalk/2']
3984
+ mimetypes = ['text/x-ambienttalk']
3985
+
3986
+ flags = re.MULTILINE | re.DOTALL
3987
+
3988
+ builtin = ['if:', 'then:', 'else:', 'when:', 'whenever:', 'discovered:',
3989
+ 'disconnected:', 'reconnected:', 'takenOffline:', 'becomes:',
3990
+ 'export:', 'as:', 'object:', 'actor:', 'mirror:', 'taggedAs:',
3991
+ 'mirroredBy:', 'is:']
3992
+ tokens = {
3993
+ 'root' : [
3994
+ (r'\s+', Text),
3995
+ (r'//.*?\n', Comment.Single),
3996
+ (r'/\*.*?\*/', Comment.Multiline),
3997
+ (r'(def|deftype|import|alias|exclude)\b', Keyword),
3998
+ (r"(%s)" % "|".join(builtin), Name.Builtin),
3999
+ (r'(true|false|nil)\b', Keyword.Constant),
4000
+ (r'(~|lobby|jlobby|/)\.', Keyword.Constant, 'namespace'),
4001
+ (r'"(\\\\|\\"|[^"])*"', String),
4002
+ (r'\|', Punctuation, 'arglist'),
4003
+ (r'<:|[\^\*!%&<>+=,./?-]|:=', Operator),
4004
+ (r"`[a-zA-Z_]\w*", String.Symbol),
4005
+ (r"[a-zA-Z_]\w*:", Name.Function),
4006
+ (r"[\{\}()\[\];`]", Punctuation),
4007
+ (r'(self|super)\b', Name.Variable.Instance),
4008
+ (r"[a-zA-Z_]\w*", Name.Variable),
4009
+ (r"@[a-zA-Z_]\w*", Name.Class),
4010
+ (r"@\[", Name.Class, 'annotations'),
4011
+ include('numbers'),
4012
+ ],
4013
+ 'numbers' : [
4014
+ (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
4015
+ (r'\d+', Number.Integer)
4016
+ ],
4017
+ 'namespace': [
4018
+ (r'[a-zA-Z_]\w*\.', Name.Namespace),
4019
+ (r'[a-zA-Z_]\w*:', Name.Function , '#pop'),
4020
+ (r'[a-zA-Z_]\w*(?!\.)', Name.Function , '#pop')
4021
+ ],
4022
+ 'annotations' : [
4023
+ (r"(.*?)\]", Name.Class, '#pop')
4024
+ ],
4025
+ 'arglist' : [
4026
+ (r'\|', Punctuation, '#pop'),
4027
+ (r'\s*(,)\s*', Punctuation),
4028
+ (r'[a-zA-Z_]\w*', Name.Variable),
4029
+ ],
4030
+ }
4031
+
4032
+
4033
+ class PawnLexer(RegexLexer):
4034
+ """
4035
+ For Pawn source code
4036
+ """
4037
+
4038
+ name = 'Pawn'
4039
+ aliases = ['pawn']
4040
+ filenames = ['*.p', '*.pwn', '*.inc']
4041
+ mimetypes = ['text/x-pawn']
4042
+
4043
+ #: optional Comment or Whitespace
4044
+ _ws = r'(?:\s|//.*?\n|/[*][\w\W]*?[*]/)+'
4045
+
4046
+ tokens = {
4047
+ 'root': [
4048
+ # preprocessor directives: without whitespace
4049
+ ('^#if\s+0', Comment.Preproc, 'if0'),
4050
+ ('^#', Comment.Preproc, 'macro'),
4051
+ # or with whitespace
4052
+ ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
4053
+ ('^' + _ws + '#', Comment.Preproc, 'macro'),
4054
+ (r'\n', Text),
4055
+ (r'\s+', Text),
4056
+ (r'\\\n', Text), # line continuation
4057
+ (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
4058
+ (r'/(\\\n)?\*[\w\W]*?\*(\\\n)?/', Comment.Multiline),
4059
+ (r'[{}]', Punctuation),
4060
+ (r'L?"', String, 'string'),
4061
+ (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
4062
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
4063
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
4064
+ (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
4065
+ (r'0[0-7]+[LlUu]*', Number.Oct),
4066
+ (r'\d+[LlUu]*', Number.Integer),
4067
+ (r'\*/', Error),
4068
+ (r'[~!%^&*+=|?:<>/-]', Operator),
4069
+ (r'[()\[\],.;]', Punctuation),
4070
+ (r'(switch|case|default|const|new|static|char|continue|break|'
4071
+ r'if|else|for|while|do|operator|enum|'
4072
+ r'public|return|sizeof|tagof|state|goto)\b', Keyword),
4073
+ (r'(bool|Float)\b', Keyword.Type),
4074
+ (r'(true|false)\b', Keyword.Constant),
4075
+ ('[a-zA-Z_]\w*', Name),
4076
+ ],
4077
+ 'string': [
4078
+ (r'"', String, '#pop'),
4079
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
4080
+ (r'[^\\"\n]+', String), # all other characters
4081
+ (r'\\\n', String), # line continuation
4082
+ (r'\\', String), # stray backslash
4083
+ ],
4084
+ 'macro': [
4085
+ (r'[^/\n]+', Comment.Preproc),
4086
+ (r'/\*(.|\n)*?\*/', Comment.Multiline),
4087
+ (r'//.*?\n', Comment.Single, '#pop'),
4088
+ (r'/', Comment.Preproc),
4089
+ (r'(?<=\\)\n', Comment.Preproc),
4090
+ (r'\n', Comment.Preproc, '#pop'),
4091
+ ],
4092
+ 'if0': [
4093
+ (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
4094
+ (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
4095
+ (r'.*?\n', Comment),
4096
+ ]
4097
+ }
4098
+
4099
+
4100
+ class VCTreeStatusLexer(RegexLexer):
4101
+ """
4102
+ For colorizing output of version control status commans, like "hg
4103
+ status" or "svn status".
4104
+
4105
+ .. versionadded:: 2.0
4106
+ """
4107
+ name = 'VCTreeStatus'
4108
+ aliases = ['vctreestatus']
4109
+ filenames = []
4110
+ mimetypes = []
4111
+
4112
+ tokens = {
4113
+ 'root' : [
4114
+ (r'^A \+ C\s+', Generic.Error),
4115
+ (r'^A\s+\+?\s+', String),
4116
+ (r'^M\s+', Generic.Inserted),
4117
+ (r'^C\s+', Generic.Error),
4118
+ (r'^D\s+', Generic.Deleted),
4119
+ (r'^[\?!]\s+', Comment.Preproc),
4120
+ (r' >\s+.*\n', Comment.Preproc),
4121
+ (r'.*\n', Text)
4122
+ ]
4123
+ }
4124
+
4125
+
4126
+ class RslLexer(RegexLexer):
4127
+ """
4128
+ `RSL <http://en.wikipedia.org/wiki/RAISE>`_ is the formal specification
4129
+ language used in RAISE (Rigorous Approach to Industrial Software Engineering)
4130
+ method.
4131
+
4132
+ .. versionadded:: 2.0
4133
+ """
4134
+ name = 'RSL'
4135
+ aliases = ['rsl']
4136
+ filenames = ['*.rsl']
4137
+ mimetypes = ['text/rsl']
4138
+
4139
+ flags = re.MULTILINE | re.DOTALL
4140
+
4141
+ tokens = {
4142
+ 'root':[
4143
+ (r'\b(Bool|Char|Int|Nat|Real|Text|Unit|abs|all|always|any|as|'
4144
+ r'axiom|card|case|channel|chaos|class|devt_relation|dom|elems|'
4145
+ r'else|elif|end|exists|extend|false|for|hd|hide|if|in|is|inds|'
4146
+ r'initialise|int|inter|isin|len|let|local|ltl_assertion|object|'
4147
+ r'of|out|post|pre|read|real|rng|scheme|skip|stop|swap|then|'
4148
+ r'thoery|test_case|tl|transition_system|true|type|union|until|'
4149
+ r'use|value|variable|while|with|write|~isin|-inflist|-infset|'
4150
+ r'-list|-set)\b', Keyword),
4151
+ (r'(variable|value)\b', Keyword.Declaration),
4152
+ (r'--.*?\n', Comment),
4153
+ (r'<:.*?:>', Comment),
4154
+ (r'\{!.*?!\}', Comment),
4155
+ (r'/\*.*?\*/', Comment),
4156
+ (r'^[ \t]*([\w]+)[ \t]*:[^:]', Name.Function),
4157
+ (r'(^[ \t]*)([\w]+)([ \t]*\([\w\s,]*\)[ \t]*)(is|as)',
4158
+ bygroups(Text, Name.Function, Text, Keyword)),
4159
+ (r'\b[A-Z]\w*\b',Keyword.Type),
4160
+ (r'(true|false)\b', Keyword.Constant),
4161
+ (r'".*"',String),
4162
+ (r'\'.\'',String.Char),
4163
+ (r'(><|->|-m->|/\\|<=|<<=|<\.|\|\||\|\^\||-~->|-~m->|\\/|>=|>>|'
4164
+ r'\.>|\+\+|-\\|<->|=>|:-|~=|\*\*|<<|>>=|\+>|!!|\|=\||#)',
4165
+ Operator),
4166
+ (r'[0-9]+\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
4167
+ (r'0x[0-9a-f]+', Number.Hex),
4168
+ (r'[0-9]+', Number.Integer),
4169
+ (r'.', Text),
4170
+ ],
4171
+ }
4172
+
4173
+ def analyse_text(text):
4174
+ """
4175
+ Check for the most common text in the beginning of a RSL file.
4176
+ """
4177
+ if re.search(r'scheme\s*.*?=\s*class\s*type', text, re.I) is not None:
4178
+ return 1.0
4179
+ else:
4180
+ return 0.01
4181
+
4182
+
4183
+ class PanLexer(RegexLexer):
4184
+ """
4185
+ Lexer for `pan <http://github.com/quattor/pan/>`_ source files.
4186
+
4187
+ Based on tcsh lexer.
4188
+
4189
+ .. versionadded:: 2.0
4190
+ """
4191
+
4192
+ name = 'Pan'
4193
+ aliases = ['pan']
4194
+ filenames = ['*.pan']
4195
+
4196
+ tokens = {
4197
+ 'root': [
4198
+ include('basic'),
4199
+ (r'\(', Keyword, 'paren'),
4200
+ (r'{', Keyword, 'curly'),
4201
+ include('data'),
4202
+ ],
4203
+ 'basic': [
4204
+ (r'\b(if|for|with|else|type|bind|while|valid|final|prefix|unique|'
4205
+ r'object|foreach|include|template|function|variable|structure|'
4206
+ r'extensible|declaration)\s*\b',
4207
+ Keyword),
4208
+ (r'\b(file_contents|format|index|length|match|matches|replace|'
4209
+ r'splice|split|substr|to_lowercase|to_uppercase|debug|error|'
4210
+ r'traceback|deprecated|base64_decode|base64_encode|digest|escape|'
4211
+ r'unescape|append|create|first|nlist|key|length|list|merge|next|'
4212
+ r'prepend|splice|is_boolean|is_defined|is_double|is_list|is_long|'
4213
+ r'is_nlist|is_null|is_number|is_property|is_resource|is_string|'
4214
+ r'to_boolean|to_double|to_long|to_string|clone|delete|exists|'
4215
+ r'path_exists|if_exists|return|value)\s*\b',
4216
+ Name.Builtin),
4217
+ (r'#.*', Comment),
4218
+ (r'\\[\w\W]', String.Escape),
4219
+ (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
4220
+ (r'[\[\]{}()=]+', Operator),
4221
+ (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
4222
+ (r';', Punctuation),
4223
+ ],
4224
+ 'data': [
4225
+ (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
4226
+ (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
4227
+ (r'\s+', Text),
4228
+ (r'[^=\s\[\]{}()$"\'`\\;#]+', Text),
4229
+ (r'\d+(?= |\Z)', Number),
4230
+ ],
4231
+ 'curly': [
4232
+ (r'}', Keyword, '#pop'),
4233
+ (r':-', Keyword),
4234
+ (r'\w+', Name.Variable),
4235
+ (r'[^}:"\'`$]+', Punctuation),
4236
+ (r':', Punctuation),
4237
+ include('root'),
4238
+ ],
4239
+ 'paren': [
4240
+ (r'\)', Keyword, '#pop'),
4241
+ include('root'),
4242
+ ],
4243
+ }
4244
+
4245
+ class RedLexer(RegexLexer):
4246
+ """
4247
+ A `Red-language <http://www.red-lang.org/>`_ lexer.
4248
+
4249
+ .. versionadded:: 2.0
4250
+ """
4251
+ name = 'Red'
4252
+ aliases = ['red', 'red/system']
4253
+ filenames = ['*.red', '*.reds']
4254
+ mimetypes = ['text/x-red', 'text/x-red-system']
4255
+
4256
+ flags = re.IGNORECASE | re.MULTILINE
4257
+
4258
+ escape_re = r'(?:\^\([0-9a-f]{1,4}\)*)'
4259
+
4260
+ def word_callback(lexer, match):
4261
+ word = match.group()
4262
+
4263
+ if re.match(".*:$", word):
4264
+ yield match.start(), Generic.Subheading, word
4265
+ elif re.match(
4266
+ r'(if|unless|either|any|all|while|until|loop|repeat|'
4267
+ r'foreach|forall|func|function|does|has|switch|'
4268
+ r'case|reduce|compose|get|set|print|prin|equal\?|'
4269
+ r'not-equal\?|strict-equal\?|lesser\?|greater\?|lesser-or-equal\?|'
4270
+ r'greater-or-equal\?|same\?|not|type\?|stats|'
4271
+ r'bind|union|replace|charset|routine)$', word):
4272
+ yield match.start(), Name.Builtin, word
4273
+ elif re.match(
4274
+ r'(make|random|reflect|to|form|mold|absolute|add|divide|multiply|negate|'
4275
+ r'power|remainder|round|subtract|even\?|odd\?|and~|complement|or~|xor~|'
4276
+ r'append|at|back|change|clear|copy|find|head|head\?|index\?|insert|'
4277
+ r'length\?|next|pick|poke|remove|reverse|select|sort|skip|swap|tail|tail\?|'
4278
+ r'take|trim|create|close|delete|modify|open|open\?|query|read|rename|'
4279
+ r'update|write)$', word):
4280
+ yield match.start(), Name.Function, word
4281
+ elif re.match(
4282
+ r'(yes|on|no|off|true|false|tab|cr|lf|newline|escape|slash|sp|space|null|'
4283
+ r'none|crlf|dot|null-byte)$', word):
4284
+ yield match.start(), Name.Builtin.Pseudo, word
4285
+ elif re.match(
4286
+ r'(#system-global|#include|#enum|#define|#either|#if|#import|#export|'
4287
+ r'#switch|#default|#get-definition)$', word):
4288
+ yield match.start(), Keyword.Namespace, word
4289
+ elif re.match(
4290
+ r'(system|halt|quit|quit-return|do|load|q|recycle|call|run|ask|parse|'
4291
+ r'raise-error|return|exit|break|alias|push|pop|probe|\?\?|spec-of|body-of|'
4292
+ r'quote|forever)$', word):
4293
+ yield match.start(), Name.Exception, word
4294
+ elif re.match(
4295
+ r'(action\?|block\?|char\?|datatype\?|file\?|function\?|get-path\?|zero\?|'
4296
+ r'get-word\?|integer\?|issue\?|lit-path\?|lit-word\?|logic\?|native\?|'
4297
+ r'op\?|paren\?|path\?|refinement\?|set-path\?|set-word\?|string\?|unset\?|'
4298
+ r'any-struct\?|none\?|word\?|any-series\?)$', word):
4299
+ yield match.start(), Keyword, word
4300
+ elif re.match(r'(JNICALL|stdcall|cdecl|infix)$', word):
4301
+ yield match.start(), Keyword.Namespace, word
4302
+ elif re.match("to-.*", word):
4303
+ yield match.start(), Keyword, word
4304
+ elif re.match('(\+|-|\*|/|//|\*\*|and|or|xor|=\?|=|==|===|<>|<|>|<=|>=|<<|>>|<<<|>>>|%|-\*\*)$', word):
4305
+ yield match.start(), Operator, word
4306
+ elif re.match(".*\!$", word):
4307
+ yield match.start(), Keyword.Type, word
4308
+ elif re.match("'.*", word):
4309
+ yield match.start(), Name.Variable.Instance, word # lit-word
4310
+ elif re.match("#.*", word):
4311
+ yield match.start(), Name.Label, word # issue
4312
+ elif re.match("%.*", word):
4313
+ yield match.start(), Name.Decorator, word # file
4314
+ elif re.match(":.*", word):
4315
+ yield match.start(), Generic.Subheading, word # get-word
4316
+ else:
4317
+ yield match.start(), Name.Variable, word
4318
+
4319
+ tokens = {
4320
+ 'root': [
4321
+ (r'[^R]+', Comment),
4322
+ (r'Red/System\s+\[', Generic.Strong, 'script'),
4323
+ (r'Red\s+\[', Generic.Strong, 'script'),
4324
+ (r'R', Comment)
4325
+ ],
4326
+ 'script': [
4327
+ (r'\s+', Text),
4328
+ (r'#"', String.Char, 'char'),
4329
+ (r'#{[0-9a-f\s]*}', Number.Hex),
4330
+ (r'2#{', Number.Hex, 'bin2'),
4331
+ (r'64#{[0-9a-z+/=\s]*}', Number.Hex),
4332
+ (r'([0-9a-f]+)(h)((\s)|(?=[\[\]{}""\(\)]))',
4333
+ bygroups(Number.Hex, Name.Variable, Whitespace)),
4334
+ (r'"', String, 'string'),
4335
+ (r'{', String, 'string2'),
4336
+ (r';#+.*\n', Comment.Special),
4337
+ (r';\*+.*\n', Comment.Preproc),
4338
+ (r';.*\n', Comment),
4339
+ (r'%"', Name.Decorator, 'stringFile'),
4340
+ (r'%[^(\^{^")\s\[\]]+', Name.Decorator),
4341
+ (r'[+-]?([a-z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
4342
+ (r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
4343
+ (r'\d+[\-\/][0-9a-z]+[\-\/]\d+(\/\d+\:\d+((\:\d+)?'
4344
+ r'([\.\d+]?([+-]?\d+:\d+)?)?)?)?', String.Other), # date
4345
+ (r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
4346
+ (r'\d+[xX]\d+', Keyword.Constant), # pair
4347
+ (r'[+-]?\d+(\'\d+)?([\.,]\d*)?[eE][+-]?\d+', Number.Float),
4348
+ (r'[+-]?\d+(\'\d+)?[\.,]\d*', Number.Float),
4349
+ (r'[+-]?\d+(\'\d+)?', Number),
4350
+ (r'[\[\]\(\)]', Generic.Strong),
4351
+ (r'[a-z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
4352
+ (r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
4353
+ (r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email
4354
+ (r'comment\s"', Comment, 'commentString1'),
4355
+ (r'comment\s{', Comment, 'commentString2'),
4356
+ (r'comment\s\[', Comment, 'commentBlock'),
4357
+ (r'comment\s[^(\s{\"\[]+', Comment),
4358
+ (r'/[^(\^{^")\s/[\]]*', Name.Attribute),
4359
+ (r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
4360
+ (r'<[\w:.-]*>', Name.Tag),
4361
+ (r'<[^(<>\s")]+', Name.Tag, 'tag'),
4362
+ (r'([^(\^{^")\s]+)', Text),
4363
+ ],
4364
+ 'string': [
4365
+ (r'[^(\^")]+', String),
4366
+ (escape_re, String.Escape),
4367
+ (r'[\(|\)]+', String),
4368
+ (r'\^.', String.Escape),
4369
+ (r'"', String, '#pop'),
4370
+ ],
4371
+ 'string2': [
4372
+ (r'[^(\^{^})]+', String),
4373
+ (escape_re, String.Escape),
4374
+ (r'[\(|\)]+', String),
4375
+ (r'\^.', String.Escape),
4376
+ (r'{', String, '#push'),
4377
+ (r'}', String, '#pop'),
4378
+ ],
4379
+ 'stringFile': [
4380
+ (r'[^(\^")]+', Name.Decorator),
4381
+ (escape_re, Name.Decorator),
4382
+ (r'\^.', Name.Decorator),
4383
+ (r'"', Name.Decorator, '#pop'),
4384
+ ],
4385
+ 'char': [
4386
+ (escape_re + '"', String.Char, '#pop'),
4387
+ (r'\^."', String.Char, '#pop'),
4388
+ (r'."', String.Char, '#pop'),
4389
+ ],
4390
+ 'tag': [
4391
+ (escape_re, Name.Tag),
4392
+ (r'"', Name.Tag, 'tagString'),
4393
+ (r'[^(<>\r\n")]+', Name.Tag),
4394
+ (r'>', Name.Tag, '#pop'),
4395
+ ],
4396
+ 'tagString': [
4397
+ (r'[^(\^")]+', Name.Tag),
4398
+ (escape_re, Name.Tag),
4399
+ (r'[\(|\)]+', Name.Tag),
4400
+ (r'\^.', Name.Tag),
4401
+ (r'"', Name.Tag, '#pop'),
4402
+ ],
4403
+ 'tuple': [
4404
+ (r'(\d+\.)+', Keyword.Constant),
4405
+ (r'\d+', Keyword.Constant, '#pop'),
4406
+ ],
4407
+ 'bin2': [
4408
+ (r'\s+', Number.Hex),
4409
+ (r'([0-1]\s*){8}', Number.Hex),
4410
+ (r'}', Number.Hex, '#pop'),
4411
+ ],
4412
+ 'commentString1': [
4413
+ (r'[^(\^")]+', Comment),
4414
+ (escape_re, Comment),
4415
+ (r'[\(|\)]+', Comment),
4416
+ (r'\^.', Comment),
4417
+ (r'"', Comment, '#pop'),
4418
+ ],
4419
+ 'commentString2': [
4420
+ (r'[^(\^{^})]+', Comment),
4421
+ (escape_re, Comment),
4422
+ (r'[\(|\)]+', Comment),
4423
+ (r'\^.', Comment),
4424
+ (r'{', Comment, '#push'),
4425
+ (r'}', Comment, '#pop'),
4426
+ ],
4427
+ 'commentBlock': [
4428
+ (r'\[', Comment, '#push'),
4429
+ (r'\]', Comment, '#pop'),
4430
+ (r'"', Comment, "commentString1"),
4431
+ (r'{', Comment, "commentString2"),
4432
+ (r'[^(\[\]\"{)]+', Comment),
4433
+ ],
4434
+ }
4435
+
4436
+
4437
+ class AlloyLexer(RegexLexer):
4438
+ """
4439
+ For `Alloy <http://alloy.mit.edu>`_ source code.
4440
+ """
4441
+
4442
+ name = 'Alloy'
4443
+ aliases = ['alloy']
4444
+ filenames = ['*.als']
4445
+ mimetypes = ['text/x-alloy']
4446
+
4447
+ flags = re.MULTILINE | re.DOTALL
4448
+
4449
+ iden_rex = r'[a-zA-Z_][a-zA-Z0-9_\']*'
4450
+ text_tuple = (r'[^\S\n]+', Text)
4451
+
4452
+ tokens = {
4453
+ 'sig': [
4454
+ (r'(extends)\b', Keyword, '#pop'),
4455
+ (iden_rex, Name),
4456
+ text_tuple,
4457
+ (r',', Punctuation),
4458
+ (r'\{', Operator, '#pop'),
4459
+ ],
4460
+ 'module': [
4461
+ text_tuple,
4462
+ (iden_rex, Name, '#pop'),
4463
+ ],
4464
+ 'fun': [
4465
+ text_tuple,
4466
+ (r'\{', Operator, '#pop'),
4467
+ (iden_rex, Name, '#pop'),
4468
+ ],
4469
+ 'root': [
4470
+ (r'--.*?$', Comment.Single),
4471
+ (r'//.*?$', Comment.Single),
4472
+ (r'/\*.*?\*/', Comment.Multiline),
4473
+ text_tuple,
4474
+ (r'(module|open)(\s+)', bygroups(Keyword.Namespace, Text),
4475
+ 'module'),
4476
+ (r'(sig|enum)(\s+)', bygroups(Keyword.Declaration, Text), 'sig'),
4477
+ (r'(iden|univ|none)\b', Keyword.Constant),
4478
+ (r'(int|Int)\b', Keyword.Type),
4479
+ (r'(this|abstract|extends|set|seq|one|lone|let)\b', Keyword),
4480
+ (r'(all|some|no|sum|disj|when|else)\b', Keyword),
4481
+ (r'(run|check|for|but|exactly|expect|as)\b', Keyword),
4482
+ (r'(and|or|implies|iff|in)\b', Operator.Word),
4483
+ (r'(fun|pred|fact|assert)(\s+)', bygroups(Keyword, Text), 'fun'),
4484
+ (r'!|#|&&|\+\+|<<|>>|>=|<=>|<=|\.|->', Operator),
4485
+ (r'[-+/*%=<>&!^|~\{\}\[\]\(\)\.]', Operator),
4486
+ (iden_rex, Name),
4487
+ (r'[:,]', Punctuation),
4488
+ (r'[0-9]+', Number.Integer),
4489
+ (r'"(\\\\|\\"|[^"])*"', String),
4490
+ (r'\n', Text),
4491
+ ]
4492
+ }