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
@@ -0,0 +1,81 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.graph
4
+ ~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for graph query languages.
7
+
8
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ import re
13
+
14
+ from pygments.lexer import RegexLexer, include, bygroups, using, this
15
+ from pygments.token import Keyword, Punctuation, Text, Comment, Operator, Name,\
16
+ String, Number, Generic, Whitespace
17
+
18
+
19
+ __all__ = ['CypherLexer']
20
+
21
+
22
+ class CypherLexer(RegexLexer):
23
+ """
24
+ For `Cypher Query Language
25
+ <http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html>`_
26
+
27
+ For the Cypher version in Neo4J 2.0
28
+
29
+ .. versionadded:: 2.0
30
+ """
31
+ name = 'Cypher'
32
+ aliases = ['cypher']
33
+ filenames = ['*.cyp','*.cypher']
34
+
35
+ flags = re.MULTILINE | re.IGNORECASE
36
+
37
+ tokens = {
38
+ 'root': [
39
+ include('comment'),
40
+ include('keywords'),
41
+ include('clauses'),
42
+ include('relations'),
43
+ include('strings'),
44
+ include('whitespace'),
45
+ include('barewords'),
46
+ ],
47
+ 'comment': [
48
+ (r'^.*//.*\n', Comment.Single),
49
+ ],
50
+ 'keywords': [
51
+ (r'(create|order|match|limit|set|skip|start|return|with|where|'
52
+ r'delete|foreach|not|by)\b', Keyword),
53
+ ],
54
+ 'clauses': [
55
+ # TODO: many missing ones, see http://docs.neo4j.org/refcard/2.0/
56
+ (r'(all|any|as|asc|create|create\s+unique|delete|'
57
+ r'desc|distinct|foreach|in|is\s+null|limit|match|none|'
58
+ r'order\s+by|return|set|skip|single|start|union|where|with)\b',
59
+ Keyword),
60
+ ],
61
+ 'relations': [
62
+ (r'(-\[)(.*?)(\]->)', bygroups(Operator, using(this), Operator)),
63
+ (r'(<-\[)(.*?)(\]-)', bygroups(Operator, using(this), Operator)),
64
+ (r'-->|<--|\[|\]', Operator),
65
+ (r'<|>|<>|=|<=|=>|\(|\)|\||:|,|;', Punctuation),
66
+ (r'[.*{}]', Punctuation),
67
+ ],
68
+ 'strings': [
69
+ (r'"(?:\\[tbnrf\'\"\\]|[^\\"])*"', String),
70
+ (r'`(?:``|[^`])+`', Name.Variable),
71
+ ],
72
+ 'whitespace': [
73
+ (r'\s+', Whitespace),
74
+ ],
75
+ 'barewords': [
76
+ (r'[a-z]\w*', Name),
77
+ (r'\d+', Number),
78
+ ],
79
+ }
80
+
81
+
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for hardware descriptor 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
 
@@ -22,7 +22,7 @@ class VerilogLexer(RegexLexer):
22
22
  """
23
23
  For verilog source code with preprocessor directives.
24
24
 
25
- *New in Pygments 1.4.*
25
+ .. versionadded:: 1.4
26
26
  """
27
27
  name = 'verilog'
28
28
  aliases = ['verilog', 'v']
@@ -46,7 +46,7 @@ class VerilogLexer(RegexLexer):
46
46
  (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
47
47
  (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
48
48
  (r'([0-9]+)|(\'h)[0-9a-fA-F]+', Number.Hex),
49
- (r'([0-9]+)|(\'b)[0-1]+', Number.Hex), # should be binary
49
+ (r'([0-9]+)|(\'b)[0-1]+', Number.Bin),
50
50
  (r'([0-9]+)|(\'d)[0-9]+', Number.Integer),
51
51
  (r'([0-9]+)|(\'o)[0-7]+', Number.Oct),
52
52
  (r'\'[01xz]', Number),
@@ -54,7 +54,7 @@ class VerilogLexer(RegexLexer):
54
54
  (r'\*/', Error),
55
55
  (r'[~!%^&*+=|?:<>/-]', Operator),
56
56
  (r'[()\[\],.;\']', Punctuation),
57
- (r'`[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant),
57
+ (r'`[a-zA-Z_]\w*', Name.Constant),
58
58
 
59
59
  (r'^(\s*)(package)(\s+)', bygroups(Text, Keyword.Namespace, Text)),
60
60
  (r'^(\s*)(import)(\s+)', bygroups(Text, Keyword.Namespace, Text),
@@ -96,8 +96,8 @@ class VerilogLexer(RegexLexer):
96
96
  r'bit|logic|reg|'
97
97
  r'supply0|supply1|tri|triand|trior|tri0|tri1|trireg|uwire|wire|wand|wor'
98
98
  r'shortreal|real|realtime)\b', Keyword.Type),
99
- ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
100
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
99
+ ('[a-zA-Z_]\w*:(?!:)', Name.Label),
100
+ ('[a-zA-Z_]\w*', Name),
101
101
  ],
102
102
  'string': [
103
103
  (r'"', String, '#pop'),
@@ -115,7 +115,7 @@ class VerilogLexer(RegexLexer):
115
115
  (r'\n', Comment.Preproc, '#pop'),
116
116
  ],
117
117
  'import': [
118
- (r'[a-zA-Z0-9_:]+\*?', Name.Namespace, '#pop')
118
+ (r'[\w:]+\*?', Name.Namespace, '#pop')
119
119
  ]
120
120
  }
121
121
 
@@ -134,7 +134,7 @@ class SystemVerilogLexer(RegexLexer):
134
134
  Extends verilog lexer to recognise all SystemVerilog keywords from IEEE
135
135
  1800-2009 standard.
136
136
 
137
- *New in Pygments 1.5.*
137
+ .. versionadded:: 1.5
138
138
  """
139
139
  name = 'systemverilog'
140
140
  aliases = ['systemverilog', 'sv']
@@ -161,7 +161,7 @@ class SystemVerilogLexer(RegexLexer):
161
161
  (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
162
162
  (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
163
163
  (r'([0-9]+)|(\'h)[0-9a-fA-F]+', Number.Hex),
164
- (r'([0-9]+)|(\'b)[0-1]+', Number.Hex), # should be binary
164
+ (r'([0-9]+)|(\'b)[0-1]+', Number.Bin),
165
165
  (r'([0-9]+)|(\'d)[0-9]+', Number.Integer),
166
166
  (r'([0-9]+)|(\'o)[0-7]+', Number.Oct),
167
167
  (r'\'[01xz]', Number),
@@ -169,7 +169,7 @@ class SystemVerilogLexer(RegexLexer):
169
169
  (r'\*/', Error),
170
170
  (r'[~!%^&*+=|?:<>/-]', Operator),
171
171
  (r'[()\[\],.;\']', Punctuation),
172
- (r'`[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant),
172
+ (r'`[a-zA-Z_]\w*', Name.Constant),
173
173
 
174
174
  (r'(accept_on|alias|always|always_comb|always_ff|always_latch|'
175
175
  r'and|assert|assign|assume|automatic|before|begin|bind|bins|'
@@ -215,12 +215,12 @@ class SystemVerilogLexer(RegexLexer):
215
215
  r'\$dumpportsall|\$dumpportsflush|\$dumpportslimit|\$dumpportsoff|'
216
216
  r'\$dumpportson|\$dumpvars|\$fclose|\$fdisplay|\$fdisplayb|'
217
217
  r'\$fdisplayh|\$fdisplayo|\$feof|\$ferror|\$fflush|\$fgetc|'
218
- r'\$fgets|\$fmonitor|\$fmonitorb|\$fmonitorh|\$fmonitoro|'
218
+ r'\$fgets|\$finish|\$fmonitor|\$fmonitorb|\$fmonitorh|\$fmonitoro|'
219
219
  r'\$fopen|\$fread|\$fscanf|\$fseek|\$fstrobe|\$fstrobeb|\$fstrobeh|'
220
220
  r'\$fstrobeo|\$ftell|\$fwrite|\$fwriteb|\$fwriteh|\$fwriteo|'
221
221
  r'\$monitor|\$monitorb|\$monitorh|\$monitoro|\$monitoroff|'
222
- r'\$monitoron|\$plusargs|\$readmemb|\$readmemh|\$rewind|\$sformat|'
223
- r'\$sformatf|\$sscanf|\$strobe|\$strobeb|\$strobeh|\$strobeo|'
222
+ r'\$monitoron|\$plusargs|\$random\|$readmemb|\$readmemh|\$rewind|'
223
+ r'\$sformat|\$sformatf|\$sscanf|\$strobe|\$strobeb|\$strobeh|\$strobeo|'
224
224
  r'\$swrite|\$swriteb|\$swriteh|\$swriteo|\$test|\$ungetc|'
225
225
  r'\$value\$plusargs|\$write|\$writeb|\$writeh|\$writememb|'
226
226
  r'\$writememh|\$writeo)\b' , Name.Builtin ),
@@ -230,11 +230,11 @@ class SystemVerilogLexer(RegexLexer):
230
230
  r'bit|logic|reg|'
231
231
  r'supply0|supply1|tri|triand|trior|tri0|tri1|trireg|uwire|wire|wand|wor'
232
232
  r'shortreal|real|realtime)\b', Keyword.Type),
233
- ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
234
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
233
+ ('[a-zA-Z_]\w*:(?!:)', Name.Label),
234
+ ('[a-zA-Z_]\w*', Name),
235
235
  ],
236
236
  'classname': [
237
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
237
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
238
238
  ],
239
239
  'string': [
240
240
  (r'"', String, '#pop'),
@@ -252,7 +252,7 @@ class SystemVerilogLexer(RegexLexer):
252
252
  (r'\n', Comment.Preproc, '#pop'),
253
253
  ],
254
254
  'import': [
255
- (r'[a-zA-Z0-9_:]+\*?', Name.Namespace, '#pop')
255
+ (r'[\w:]+\*?', Name.Namespace, '#pop')
256
256
  ]
257
257
  }
258
258
 
@@ -274,7 +274,7 @@ class VhdlLexer(RegexLexer):
274
274
  """
275
275
  For VHDL source code.
276
276
 
277
- *New in Pygments 1.5.*
277
+ .. versionadded:: 1.5
278
278
  """
279
279
  name = 'vhdl'
280
280
  aliases = ['vhdl']
@@ -290,19 +290,19 @@ class VhdlLexer(RegexLexer):
290
290
  (r'--(?![!#$%&*+./<=>?@\^|_~]).*?$', Comment.Single),
291
291
  (r"'(U|X|0|1|Z|W|L|H|-)'", String.Char),
292
292
  (r'[~!%^&*+=|?:<>/-]', Operator),
293
- (r"'[a-zA-Z_][a-zA-Z0-9_]*", Name.Attribute),
293
+ (r"'[a-z_]\w*", Name.Attribute),
294
294
  (r'[()\[\],.;\']', Punctuation),
295
295
  (r'"[^\n\\]*"', String),
296
296
 
297
- (r'(library)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
297
+ (r'(library)(\s+)([a-z_]\w*)',
298
298
  bygroups(Keyword, Text, Name.Namespace)),
299
299
  (r'(use)(\s+)(entity)', bygroups(Keyword, Text, Keyword)),
300
- (r'(use)(\s+)([a-zA-Z_][\.a-zA-Z0-9_]*)',
300
+ (r'(use)(\s+)([a-z_][\.\w]*)',
301
301
  bygroups(Keyword, Text, Name.Namespace)),
302
- (r'(entity|component)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
302
+ (r'(entity|component)(\s+)([a-z_]\w*)',
303
303
  bygroups(Keyword, Text, Name.Class)),
304
- (r'(architecture|configuration)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)(\s+)'
305
- r'(of)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)(\s+)(is)',
304
+ (r'(architecture|configuration)(\s+)([a-z_]\w*)(\s+)'
305
+ r'(of)(\s+)([a-z_]\w*)(\s+)(is)',
306
306
  bygroups(Keyword, Text, Name.Class, Text, Keyword, Text,
307
307
  Name.Class, Text, Keyword)),
308
308
 
@@ -312,11 +312,11 @@ class VhdlLexer(RegexLexer):
312
312
  include('keywords'),
313
313
  include('numbers'),
314
314
 
315
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
315
+ (r'[a-z_]\w*', Name),
316
316
  ],
317
317
  'endblock': [
318
318
  include('keywords'),
319
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class),
319
+ (r'[a-z_]\w*', Name.Class),
320
320
  (r'(\s+)', Text),
321
321
  (r';', Punctuation, '#pop'),
322
322
  ],
@@ -345,12 +345,11 @@ class VhdlLexer(RegexLexer):
345
345
  r'while|with|xnor|xor)\b', Keyword),
346
346
  ],
347
347
  'numbers': [
348
- (r'\d{1,2}#[0-9a-fA-F_]+#?', Number.Integer),
349
- (r'[0-1_]+(\.[0-1_])', Number.Integer),
348
+ (r'\d{1,2}#[0-9a-f_]+#?', Number.Integer),
350
349
  (r'\d+', Number.Integer),
351
350
  (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
352
- (r'H"[0-9a-fA-F_]+"', Number.Oct),
351
+ (r'X"[0-9a-f_]+"', Number.Hex),
353
352
  (r'O"[0-7_]+"', Number.Oct),
354
- (r'B"[0-1_]+"', Number.Oct),
353
+ (r'B"[0-1_]+"', Number.Bin),
355
354
  ],
356
355
  }
@@ -0,0 +1,96 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.inferno
4
+ ~~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for Inferno os and all the related stuff.
7
+
8
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ import re
13
+
14
+ from pygments.lexer import RegexLexer, include, bygroups
15
+ from pygments.token import Punctuation, Text, Comment, Operator, Keyword, \
16
+ Name, String, Number
17
+
18
+ __all__ = ['LimboLexer']
19
+
20
+
21
+ class LimboLexer(RegexLexer):
22
+ """
23
+ Lexer for `Limbo programming language <http://www.vitanuova.com/inferno/limbo.html>`_
24
+
25
+ TODO:
26
+ - maybe implement better var declaration highlighting
27
+ - some simple syntax error highlighting
28
+
29
+ .. versionadded:: 2.0
30
+ """
31
+ name = 'Limbo'
32
+ aliases = ['limbo']
33
+ filenames = ['*.b']
34
+ mimetypes = ['text/limbo']
35
+
36
+ tokens = {
37
+ 'whitespace': [
38
+ (r'^(\s*)([a-zA-Z_]\w*:(\s*)\n)',
39
+ bygroups(Text, Name.Label)),
40
+ (r'\n', Text),
41
+ (r'\s+', Text),
42
+ (r'#(\n|(.|\n)*?[^\\]\n)', Comment.Single),
43
+ ],
44
+ 'string': [
45
+ (r'"', String, '#pop'),
46
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
47
+ r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
48
+ (r'[^\\"\n]+', String), # all other characters
49
+ (r'\\', String), # stray backslash
50
+ ],
51
+ 'statements': [
52
+ (r'"', String, 'string'),
53
+ (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
54
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
55
+ (r'(\d+\.\d*|\.\d+|\d+[fF])', Number.Float),
56
+ (r'16r[0-9a-fA-F]+', Number.Hex),
57
+ (r'8r[0-7]+', Number.Oct),
58
+ (r'((([1-3]\d)|([2-9]))r)?(\d+)', Number.Integer),
59
+ (r'[()\[\],.]', Punctuation),
60
+ (r'[~!%^&*+=|?:<>/-]|(->)|(<-)|(=>)|(::)', Operator),
61
+ (r'(alt|break|case|continue|cyclic|do|else|exit'
62
+ r'for|hd|if|implement|import|include|len|load|or'
63
+ r'pick|return|spawn|tagof|tl|to|while)\b', Keyword),
64
+ (r'(byte|int|big|real|string|array|chan|list|adt'
65
+ r'|fn|ref|of|module|self|type)\b', Keyword.Type),
66
+ (r'(con|iota|nil)\b', Keyword.Constant),
67
+ ('[a-zA-Z_]\w*', Name),
68
+ ],
69
+ 'statement' : [
70
+ include('whitespace'),
71
+ include('statements'),
72
+ ('[{}]', Punctuation),
73
+ (';', Punctuation, '#pop'),
74
+ ],
75
+ 'root': [
76
+ include('whitespace'),
77
+ ('', Text, 'statement'),
78
+ ],
79
+ }
80
+
81
+ def analyse_text(text):
82
+ # Any limbo module implements something
83
+ if re.search(r'^implement \w+;', text, re.MULTILINE):
84
+ return 0.7
85
+
86
+ # TODO:
87
+ # - Make lexers for:
88
+ # - asm sources
89
+ # - man pages
90
+ # - mkfiles
91
+ # - module definitions
92
+ # - namespace definitions
93
+ # - shell scripts
94
+ # - maybe keyfiles and fonts
95
+ # they all seem to be quite similar to their equivalents
96
+ # from unix world, so there should not be a lot of problems
@@ -5,23 +5,23 @@
5
5
 
6
6
  Pygments lexers for JVM 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 Lexer, RegexLexer, include, bygroups, using, \
15
- this
15
+ this, combined, default
16
16
  from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
17
17
  Number, Punctuation
18
- from pygments.util import get_choice_opt
19
18
  from pygments import unistring as uni
20
19
 
21
20
 
22
21
  __all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer',
23
- 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'KotlinLexer',
24
- 'XtendLexer', 'AspectJLexer', 'CeylonLexer']
22
+ 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'ClojureScriptLexer',
23
+ 'KotlinLexer', 'XtendLexer', 'AspectJLexer', 'CeylonLexer',
24
+ 'PigLexer', 'GoloLexer', 'JasminLexer']
25
25
 
26
26
 
27
27
  class JavaLexer(RegexLexer):
@@ -34,19 +34,19 @@ class JavaLexer(RegexLexer):
34
34
  filenames = ['*.java']
35
35
  mimetypes = ['text/x-java']
36
36
 
37
- flags = re.MULTILINE | re.DOTALL
37
+ flags = re.MULTILINE | re.DOTALL | re.UNICODE
38
38
 
39
39
  tokens = {
40
40
  'root': [
41
- # method names
42
- (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]<>]*\s+)+?)' # return arguments
43
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
44
- r'(\s*)(\()', # signature start
45
- bygroups(using(this), Name.Function, Text, Operator)),
46
41
  (r'[^\S\n]+', Text),
47
42
  (r'//.*?\n', Comment.Single),
48
43
  (r'/\*.*?\*/', Comment.Multiline),
49
- (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
44
+ # method names
45
+ (r'((?:(?:[^\W\d]|\$)[\w\.\[\]\$<>]*\s+)+?)' # return arguments
46
+ r'((?:[^\W\d]|\$)[\w\$]*)' # method name
47
+ r'(\s*)(\()', # signature start
48
+ bygroups(using(this), Name.Function, Text, Operator)),
49
+ (r'@[^\W\d][\w\.]*', Name.Decorator),
50
50
  (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
51
51
  r'if|goto|instanceof|new|return|switch|this|throw|try|while)\b',
52
52
  Keyword),
@@ -61,20 +61,20 @@ class JavaLexer(RegexLexer):
61
61
  (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
62
62
  (r'"(\\\\|\\"|[^"])*"', String),
63
63
  (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
64
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
65
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
66
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
64
+ (r'(\.)((?:[^\W\d]|\$)[\w\$]*)', bygroups(Operator, Name.Attribute)),
65
+ (r'([^\W\d]|\$)[\w\$]*:', Name.Label),
66
+ (r'([^\W\d]|\$)[\w\$]*', Name),
67
67
  (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
68
68
  (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
69
69
  (r'0x[0-9a-fA-F]+', Number.Hex),
70
- (r'[0-9]+L?', Number.Integer),
70
+ (r'[0-9]+(_+[0-9]+)*L?', Number.Integer),
71
71
  (r'\n', Text)
72
72
  ],
73
73
  'class': [
74
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
74
+ (r'([^\W\d]|\$)[\w\$]*', Name.Class, '#pop')
75
75
  ],
76
76
  'import': [
77
- (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
77
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
78
78
  ],
79
79
  }
80
80
 
@@ -83,7 +83,7 @@ class AspectJLexer(JavaLexer):
83
83
  """
84
84
  For `AspectJ <http://www.eclipse.org/aspectj/>`_ source code.
85
85
 
86
- *New in Pygments 1.6.*
86
+ .. versionadded:: 1.6
87
87
  """
88
88
 
89
89
  name = 'AspectJ'
@@ -243,25 +243,25 @@ class ScalaLexer(RegexLexer):
243
243
  u'\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b'
244
244
  u'\ua77d-\ua77e\ua780\ua782\ua784\ua786\ua78b\uff21-\uff3a]')
245
245
 
246
- idrest = ur'%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op)
246
+ idrest = u'%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op)
247
247
 
248
248
  tokens = {
249
249
  'root': [
250
250
  # method names
251
251
  (r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'),
252
- (ur"'%s" % idrest, Text.Symbol),
252
+ (u"'%s" % idrest, Text.Symbol),
253
253
  (r'[^\S\n]+', Text),
254
254
  (r'//.*?\n', Comment.Single),
255
255
  (r'/\*', Comment.Multiline, 'comment'),
256
- (ur'@%s' % idrest, Name.Decorator),
257
- (ur'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|'
258
- ur'f(?:inal(?:ly)?|or(?:Some)?)|i(?:f|mplicit)|'
259
- ur'lazy|match|new|override|pr(?:ivate|otected)'
260
- ur'|re(?:quires|turn)|s(?:ealed|uper)|'
261
- ur't(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\b|'
256
+ (u'@%s' % idrest, Name.Decorator),
257
+ (u'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|'
258
+ u'f(?:inal(?:ly)?|or(?:Some)?)|i(?:f|mplicit)|'
259
+ u'lazy|match|new|override|pr(?:ivate|otected)'
260
+ u'|re(?:quires|turn)|s(?:ealed|uper)|'
261
+ u't(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\\b|'
262
262
  u'(<[%:-]|=>|>:|[#=@_\u21D2\u2190])(\\b|(?=\\s)|$)', Keyword),
263
- (ur':(?!%s)' % op, Keyword, 'type'),
264
- (ur'%s%s\b' % (upper, idrest), Name.Class),
263
+ (u':(?!%s)' % op, Keyword, 'type'),
264
+ (u'%s%s\\b' % (upper, idrest), Name.Class),
265
265
  (r'(true|false|null)\b', Keyword.Constant),
266
266
  (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
267
267
  (r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
@@ -282,34 +282,34 @@ class ScalaLexer(RegexLexer):
282
282
  (r'\n', Text)
283
283
  ],
284
284
  'class': [
285
- (ur'(%s|%s|`[^`]+`)(\s*)(\[)' % (idrest, op),
285
+ (u'(%s|%s|`[^`]+`)(\\s*)(\\[)' % (idrest, op),
286
286
  bygroups(Name.Class, Text, Operator), 'typeparam'),
287
287
  (r'\s+', Text),
288
288
  (r'{', Operator, '#pop'),
289
289
  (r'\(', Operator, '#pop'),
290
290
  (r'//.*?\n', Comment.Single, '#pop'),
291
- (ur'%s|%s|`[^`]+`' % (idrest, op), Name.Class, '#pop'),
291
+ (u'%s|%s|`[^`]+`' % (idrest, op), Name.Class, '#pop'),
292
292
  ],
293
293
  'type': [
294
294
  (r'\s+', Text),
295
295
  (u'<[%:]|>:|[#_\u21D2]|forSome|type', Keyword),
296
296
  (r'([,\);}]|=>|=)(\s*)', bygroups(Operator, Text), '#pop'),
297
297
  (r'[\(\{]', Operator, '#push'),
298
- (ur'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)(\[)' %
298
+ (u'((?:%s|%s|`[^`]+`)(?:\\.(?:%s|%s|`[^`]+`))*)(\\s*)(\\[)' %
299
299
  (idrest, op, idrest, op),
300
300
  bygroups(Keyword.Type, Text, Operator), ('#pop', 'typeparam')),
301
- (ur'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)$' %
301
+ (u'((?:%s|%s|`[^`]+`)(?:\\.(?:%s|%s|`[^`]+`))*)(\\s*)$' %
302
302
  (idrest, op, idrest, op),
303
303
  bygroups(Keyword.Type, Text), '#pop'),
304
304
  (r'//.*?\n', Comment.Single, '#pop'),
305
- (ur'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
305
+ (u'\\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
306
306
  ],
307
307
  'typeparam': [
308
308
  (r'[\s,]+', Text),
309
309
  (u'<[%:]|=>|>:|[#_\u21D2]|forSome|type', Keyword),
310
310
  (r'([\]\)\}])', Operator, '#pop'),
311
311
  (r'[\(\[\{]', Operator, '#push'),
312
- (ur'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
312
+ (u'\\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
313
313
  ],
314
314
  'comment': [
315
315
  (r'[^/\*]+', Comment.Multiline),
@@ -318,7 +318,7 @@ class ScalaLexer(RegexLexer):
318
318
  (r'[*/]', Comment.Multiline)
319
319
  ],
320
320
  'import': [
321
- (ur'(%s|\.)+' % idrest, Name.Namespace, '#pop')
321
+ (u'(%s|\\.)+' % idrest, Name.Namespace, '#pop')
322
322
  ],
323
323
  }
324
324
 
@@ -327,7 +327,7 @@ class GosuLexer(RegexLexer):
327
327
  """
328
328
  For Gosu source code.
329
329
 
330
- *New in Pygments 1.5.*
330
+ .. versionadded:: 1.5
331
331
  """
332
332
 
333
333
  name = 'Gosu'
@@ -340,14 +340,14 @@ class GosuLexer(RegexLexer):
340
340
  tokens = {
341
341
  'root': [
342
342
  # method names
343
- (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # modifiers etc.
344
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
345
- r'(\s*)(\()', # signature start
343
+ (r'^(\s*(?:[a-zA-Z_][\w\.\[\]]*\s+)+?)' # modifiers etc.
344
+ r'([a-zA-Z_]\w*)' # method name
345
+ r'(\s*)(\()', # signature start
346
346
  bygroups(using(this), Name.Function, Text, Operator)),
347
347
  (r'[^\S\n]+', Text),
348
348
  (r'//.*?\n', Comment.Single),
349
349
  (r'/\*.*?\*/', Comment.Multiline),
350
- (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
350
+ (r'@[a-zA-Z_][\w\.]*', Name.Decorator),
351
351
  (r'(in|as|typeof|statictypeof|typeis|typeas|if|else|foreach|for|'
352
352
  r'index|while|do|continue|break|return|try|catch|finally|this|'
353
353
  r'throw|new|switch|case|default|eval|super|outer|classpath|'
@@ -360,16 +360,16 @@ class GosuLexer(RegexLexer):
360
360
  Keyword.Type),
361
361
  (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
362
362
  (r'(true|false|null|NaN|Infinity)\b', Keyword.Constant),
363
- (r'(class|interface|enhancement|enum)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
363
+ (r'(class|interface|enhancement|enum)(\s+)([a-zA-Z_]\w*)',
364
364
  bygroups(Keyword.Declaration, Text, Name.Class)),
365
- (r'(uses)(\s+)([a-zA-Z0-9_.]+\*?)',
365
+ (r'(uses)(\s+)([\w.]+\*?)',
366
366
  bygroups(Keyword.Namespace, Text, Name.Namespace)),
367
367
  (r'"', String, 'string'),
368
- (r'(\??[\.#])([a-zA-Z_][a-zA-Z0-9_]*)',
368
+ (r'(\??[\.#])([a-zA-Z_]\w*)',
369
369
  bygroups(Operator, Name.Attribute)),
370
- (r'(:)([a-zA-Z_][a-zA-Z0-9_]*)',
370
+ (r'(:)([a-zA-Z_]\w*)',
371
371
  bygroups(Operator, Name.Attribute)),
372
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
372
+ (r'[a-zA-Z_\$]\w*', Name),
373
373
  (r'and|or|not|[\\~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
374
374
  (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
375
375
  (r'[0-9]+', Number.Integer),
@@ -406,7 +406,7 @@ class GosuTemplateLexer(Lexer):
406
406
  """
407
407
  For Gosu templates.
408
408
 
409
- *New in Pygments 1.5.*
409
+ .. versionadded:: 1.5
410
410
  """
411
411
 
412
412
  name = 'Gosu Template'
@@ -425,7 +425,7 @@ class GroovyLexer(RegexLexer):
425
425
  """
426
426
  For `Groovy <http://groovy.codehaus.org/>`_ source code.
427
427
 
428
- *New in Pygments 1.5.*
428
+ .. versionadded:: 1.5
429
429
  """
430
430
 
431
431
  name = 'Groovy'
@@ -437,15 +437,20 @@ class GroovyLexer(RegexLexer):
437
437
 
438
438
  tokens = {
439
439
  'root': [
440
+ # Groovy allows a file to start with a shebang
441
+ (r'#!(.*?)$', Comment.Preproc, 'base'),
442
+ default('base'),
443
+ ],
444
+ 'base': [
440
445
  # method names
441
- (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
442
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
443
- r'(\s*)(\()', # signature start
446
+ (r'^(\s*(?:[a-zA-Z_][\w\.\[\]]*\s+)+?)' # return arguments
447
+ r'([a-zA-Z_]\w*)' # method name
448
+ r'(\s*)(\()', # signature start
444
449
  bygroups(using(this), Name.Function, Text, Operator)),
445
450
  (r'[^\S\n]+', Text),
446
451
  (r'//.*?\n', Comment.Single),
447
452
  (r'/\*.*?\*/', Comment.Multiline),
448
- (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
453
+ (r'@[a-zA-Z_][\w\.]*', Name.Decorator),
449
454
  (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
450
455
  r'if|goto|instanceof|new|return|switch|this|throw|try|while|in|as)\b',
451
456
  Keyword),
@@ -464,9 +469,9 @@ class GroovyLexer(RegexLexer):
464
469
  (r'\$/((?!/\$).)*/\$', String),
465
470
  (r'/(\\\\|\\"|[^/])*/', String),
466
471
  (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
467
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
468
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
469
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
472
+ (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
473
+ (r'[a-zA-Z_]\w*:', Name.Label),
474
+ (r'[a-zA-Z_\$]\w*', Name),
470
475
  (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
471
476
  (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
472
477
  (r'0x[0-9a-fA-F]+', Number.Hex),
@@ -474,20 +479,23 @@ class GroovyLexer(RegexLexer):
474
479
  (r'\n', Text)
475
480
  ],
476
481
  'class': [
477
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
482
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
478
483
  ],
479
484
  'import': [
480
- (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
485
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
481
486
  ],
482
487
  }
483
488
 
489
+ def analyse_text(text):
490
+ return shebang_matches(text, r'groovy')
491
+
484
492
 
485
493
  class IokeLexer(RegexLexer):
486
494
  """
487
495
  For `Ioke <http://ioke.org/>`_ (a strongly typed, dynamic,
488
496
  prototype based programming language) source.
489
497
 
490
- *New in Pygments 1.4.*
498
+ .. versionadded:: 1.4
491
499
  """
492
500
  name = 'Ioke'
493
501
  filenames = ['*.ik']
@@ -550,8 +558,8 @@ class IokeLexer(RegexLexer):
550
558
  (r'#r\[', String.Regex, 'squareRegexp'),
551
559
 
552
560
  #Symbols
553
- (r':[a-zA-Z0-9_!:?]+', String.Symbol),
554
- (r'[a-zA-Z0-9_!:?]+:(?![a-zA-Z0-9_!?])', String.Other),
561
+ (r':[\w!:?]+', String.Symbol),
562
+ (r'[\w!:?]+:(?![\w!?])', String.Other),
555
563
  (r':"(\\\\|\\"|[^"])*"', String.Symbol),
556
564
 
557
565
  #Documentation
@@ -564,10 +572,10 @@ class IokeLexer(RegexLexer):
564
572
  (r'#\[', String, 'squareText'),
565
573
 
566
574
  #Mimic
567
- (r'[a-zA-Z0-9_][a-zA-Z0-9!?_:]+(?=\s*=.*mimic\s)', Name.Entity),
575
+ (r'\w[a-zA-Z0-9!?_:]+(?=\s*=.*mimic\s)', Name.Entity),
568
576
 
569
577
  #Assignment
570
- (r'[a-zA-Z_][a-zA-Z0-9_!:?]*(?=[\s]*[+*/-]?=[^=].*($|\.))',
578
+ (r'[a-zA-Z_][\w!:?]*(?=[\s]*[+*/-]?=[^=].*($|\.))',
571
579
  Name.Variable),
572
580
 
573
581
  # keywords
@@ -639,9 +647,9 @@ class IokeLexer(RegexLexer):
639
647
  r'System|Text|Tuple)(?![a-zA-Z0-9!:_?])', Name.Builtin),
640
648
 
641
649
  # functions
642
- (ur'(generateMatchMethod|aliasMethod|\u03bb|\u028E|fnx|fn|method|'
643
- ur'dmacro|dlecro|syntax|macro|dlecrox|lecrox|lecro|syntax)'
644
- ur'(?![a-zA-Z0-9!:_?])', Name.Function),
650
+ (u'(generateMatchMethod|aliasMethod|\u03bb|\u028E|fnx|fn|method|'
651
+ u'dmacro|dlecro|syntax|macro|dlecrox|lecrox|lecro|syntax)'
652
+ u'(?![a-zA-Z0-9!:_?])', Name.Function),
645
653
 
646
654
  # Numbers
647
655
  (r'-?0[xX][0-9a-fA-F]+', Number.Hex),
@@ -651,24 +659,24 @@ class IokeLexer(RegexLexer):
651
659
  (r'#\(', Punctuation),
652
660
 
653
661
  # Operators
654
- (ur'(&&>>|\|\|>>|\*\*>>|:::|::|\.\.\.|===|\*\*>|\*\*=|&&>|&&=|'
655
- ur'\|\|>|\|\|=|\->>|\+>>|!>>|<>>>|<>>|&>>|%>>|#>>|@>>|/>>|\*>>|'
656
- ur'\?>>|\|>>|\^>>|~>>|\$>>|=>>|<<=|>>=|<=>|<\->|=~|!~|=>|\+\+|'
657
- ur'\-\-|<=|>=|==|!=|&&|\.\.|\+=|\-=|\*=|\/=|%=|&=|\^=|\|=|<\-|'
658
- ur'\+>|!>|<>|&>|%>|#>|\@>|\/>|\*>|\?>|\|>|\^>|~>|\$>|<\->|\->|'
659
- ur'<<|>>|\*\*|\?\||\?&|\|\||>|<|\*|\/|%|\+|\-|&|\^|\||=|\$|!|~|'
660
- ur'\?|#|\u2260|\u2218|\u2208|\u2209)', Operator),
661
- (r'(and|nand|or|xor|nor|return|import)(?![a-zA-Z0-9_!?])',
662
+ (r'(&&>>|\|\|>>|\*\*>>|:::|::|\.\.\.|===|\*\*>|\*\*=|&&>|&&=|'
663
+ r'\|\|>|\|\|=|\->>|\+>>|!>>|<>>>|<>>|&>>|%>>|#>>|@>>|/>>|\*>>|'
664
+ r'\?>>|\|>>|\^>>|~>>|\$>>|=>>|<<=|>>=|<=>|<\->|=~|!~|=>|\+\+|'
665
+ r'\-\-|<=|>=|==|!=|&&|\.\.|\+=|\-=|\*=|\/=|%=|&=|\^=|\|=|<\-|'
666
+ r'\+>|!>|<>|&>|%>|#>|\@>|\/>|\*>|\?>|\|>|\^>|~>|\$>|<\->|\->|'
667
+ r'<<|>>|\*\*|\?\||\?&|\|\||>|<|\*|\/|%|\+|\-|&|\^|\||=|\$|!|~|'
668
+ u'\\?|#|\u2260|\u2218|\u2208|\u2209)', Operator),
669
+ (r'(and|nand|or|xor|nor|return|import)(?![\w!?])',
662
670
  Operator),
663
671
 
664
672
  # Punctuation
665
673
  (r'(\`\`|\`|\'\'|\'|\.|\,|@@|@|\[|\]|\(|\)|{|})', Punctuation),
666
674
 
667
675
  #kinds
668
- (r'[A-Z][a-zA-Z0-9_!:?]*', Name.Class),
676
+ (r'[A-Z][\w!:?]*', Name.Class),
669
677
 
670
678
  #default cellnames
671
- (r'[a-z_][a-zA-Z0-9_!:?]*', Name)
679
+ (r'[a-z_][\w!:?]*', Name)
672
680
  ]
673
681
  }
674
682
 
@@ -677,7 +685,7 @@ class ClojureLexer(RegexLexer):
677
685
  """
678
686
  Lexer for `Clojure <http://clojure.org/>`_ source code.
679
687
 
680
- *New in Pygments 0.11.*
688
+ .. versionadded:: 0.11
681
689
  """
682
690
  name = 'Clojure'
683
691
  aliases = ['clojure', 'clj']
@@ -778,7 +786,7 @@ class ClojureLexer(RegexLexer):
778
786
  (r"\\(.|[a-z]+)", String.Char),
779
787
 
780
788
  # keywords
781
- (r'::?' + valid_name, String.Symbol),
789
+ (r'::?#?' + valid_name, String.Symbol),
782
790
 
783
791
  # special operators
784
792
  (r'~@|[`\'#^~&@]', Operator),
@@ -814,12 +822,25 @@ class ClojureLexer(RegexLexer):
814
822
  }
815
823
 
816
824
 
825
+ class ClojureScriptLexer(ClojureLexer):
826
+ """
827
+ Lexer for `ClojureScript <http://clojure.org/clojurescript>`_
828
+ source code.
829
+
830
+ .. versionadded:: 2.0
831
+ """
832
+ name = 'ClojureScript'
833
+ aliases = ['clojurescript', 'cljs']
834
+ filenames = ['*.cljs']
835
+ mimetypes = ['text/x-clojurescript', 'application/x-clojurescript']
836
+
837
+
817
838
  class TeaLangLexer(RegexLexer):
818
839
  """
819
840
  For `Tea <http://teatrove.org/>`_ source code. Only used within a
820
841
  TeaTemplateLexer.
821
842
 
822
- *New in Pygments 1.5.*
843
+ .. versionadded:: 1.5
823
844
  """
824
845
 
825
846
  flags = re.MULTILINE | re.DOTALL
@@ -827,14 +848,14 @@ class TeaLangLexer(RegexLexer):
827
848
  tokens = {
828
849
  'root': [
829
850
  # method names
830
- (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
831
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
832
- r'(\s*)(\()', # signature start
851
+ (r'^(\s*(?:[a-zA-Z_][\w\.\[\]]*\s+)+?)' # return arguments
852
+ r'([a-zA-Z_]\w*)' # method name
853
+ r'(\s*)(\()', # signature start
833
854
  bygroups(using(this), Name.Function, Text, Operator)),
834
855
  (r'[^\S\n]+', Text),
835
856
  (r'//.*?\n', Comment.Single),
836
857
  (r'/\*.*?\*/', Comment.Multiline),
837
- (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
858
+ (r'@[a-zA-Z_][\w\.]*', Name.Decorator),
838
859
  (r'(and|break|else|foreach|if|in|not|or|reverse)\b',
839
860
  Keyword),
840
861
  (r'(as|call|define)\b', Keyword.Declaration),
@@ -843,9 +864,9 @@ class TeaLangLexer(RegexLexer):
843
864
  (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
844
865
  (r'"(\\\\|\\"|[^"])*"', String),
845
866
  (r'\'(\\\\|\\\'|[^\'])*\'', String),
846
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
847
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
848
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
867
+ (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
868
+ (r'[a-zA-Z_]\w*:', Name.Label),
869
+ (r'[a-zA-Z_\$]\w*', Name),
849
870
  (r'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', Operator),
850
871
  (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
851
872
  (r'0x[0-9a-fA-F]+', Number.Hex),
@@ -853,10 +874,10 @@ class TeaLangLexer(RegexLexer):
853
874
  (r'\n', Text)
854
875
  ],
855
876
  'template': [
856
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
877
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
857
878
  ],
858
879
  'import': [
859
- (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
880
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
860
881
  ],
861
882
  }
862
883
 
@@ -865,7 +886,7 @@ class CeylonLexer(RegexLexer):
865
886
  """
866
887
  For `Ceylon <http://ceylon-lang.org/>`_ source code.
867
888
 
868
- *New in Pygments 1.6.*
889
+ .. versionadded:: 1.6
869
890
  """
870
891
 
871
892
  name = 'Ceylon'
@@ -881,13 +902,13 @@ class CeylonLexer(RegexLexer):
881
902
  tokens = {
882
903
  'root': [
883
904
  # method names
884
- (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
885
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
886
- r'(\s*)(\()', # signature start
905
+ (r'^(\s*(?:[a-zA-Z_][\w\.\[\]]*\s+)+?)' # return arguments
906
+ r'([a-zA-Z_]\w*)' # method name
907
+ r'(\s*)(\()', # signature start
887
908
  bygroups(using(this), Name.Function, Text, Operator)),
888
909
  (r'[^\S\n]+', Text),
889
910
  (r'//.*?\n', Comment.Single),
890
- (r'/\*.*?\*/', Comment.Multiline),
911
+ (r'/\*', Comment.Multiline, 'comment'),
891
912
  (r'(variable|shared|abstract|doc|by|formal|actual|late|native)',
892
913
  Name.Decorator),
893
914
  (r'(break|case|catch|continue|default|else|finally|for|in|'
@@ -906,10 +927,10 @@ class CeylonLexer(RegexLexer):
906
927
  (r'"(\\\\|\\"|[^"])*"', String),
907
928
  (r"'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'", String.Char),
908
929
  (r'".*``.*``.*"', String.Interpol),
909
- (r'(\.)([a-z_][a-zA-Z0-9_]*)',
930
+ (r'(\.)([a-z_]\w*)',
910
931
  bygroups(Operator, Name.Attribute)),
911
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
912
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
932
+ (r'[a-zA-Z_]\w*:', Name.Label),
933
+ (r'[a-zA-Z_]\w*', Name),
913
934
  (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
914
935
  (r'\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
915
936
  (r'\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
@@ -919,139 +940,96 @@ class CeylonLexer(RegexLexer):
919
940
  Number.Float),
920
941
  (r'#([0-9a-fA-F]{4})(_[0-9a-fA-F]{4})+', Number.Hex),
921
942
  (r'#[0-9a-fA-F]+', Number.Hex),
922
- (r'\$([01]{4})(_[01]{4})+', Number.Integer),
923
- (r'\$[01]+', Number.Integer),
943
+ (r'\$([01]{4})(_[01]{4})+', Number.Bin),
944
+ (r'\$[01]+', Number.Bin),
924
945
  (r'\d{1,3}(_\d{3})+[kMGTP]?', Number.Integer),
925
946
  (r'[0-9]+[kMGTP]?', Number.Integer),
926
947
  (r'\n', Text)
927
948
  ],
928
949
  'class': [
929
- (r'[A-Za-z_][a-zA-Z0-9_]*', Name.Class, '#pop')
950
+ (r'[A-Za-z_]\w*', Name.Class, '#pop')
930
951
  ],
931
952
  'import': [
932
- (r'[a-z][a-zA-Z0-9_.]*',
953
+ (r'[a-z][\w.]*',
933
954
  Name.Namespace, '#pop')
934
955
  ],
956
+ 'comment': [
957
+ (r'[^*/]', Comment.Multiline),
958
+ (r'/\*', Comment.Multiline, '#push'),
959
+ (r'\*/', Comment.Multiline, '#pop'),
960
+ (r'[*/]', Comment.Multiline)
961
+ ],
935
962
  }
936
963
 
937
964
 
938
965
  class KotlinLexer(RegexLexer):
939
966
  """
940
- For `Kotlin <http://confluence.jetbrains.net/display/Kotlin/>`_
967
+ For `Kotlin <http://kotlin.jetbrains.org/>`_
941
968
  source code.
942
969
 
943
- Additional options accepted:
944
-
945
- `unicodelevel`
946
- Determines which Unicode characters this lexer allows for identifiers.
947
- The possible values are:
948
-
949
- * ``none`` -- only the ASCII letters and numbers are allowed. This
950
- is the fastest selection.
951
- * ``basic`` -- all Unicode characters from the specification except
952
- category ``Lo`` are allowed.
953
- * ``full`` -- all Unicode characters as specified in the C# specs
954
- are allowed. Note that this means a considerable slowdown since the
955
- ``Lo`` category has more than 40,000 characters in it!
956
-
957
- The default value is ``basic``.
958
-
959
- *New in Pygments 1.5.*
970
+ .. versionadded:: 1.5
960
971
  """
961
972
 
962
973
  name = 'Kotlin'
963
974
  aliases = ['kotlin']
964
975
  filenames = ['*.kt']
965
- mimetypes = ['text/x-kotlin'] # inferred
976
+ mimetypes = ['text/x-kotlin']
966
977
 
967
978
  flags = re.MULTILINE | re.DOTALL | re.UNICODE
968
979
 
969
- # for the range of allowed unicode characters in identifiers,
970
- # see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
971
-
972
- levels = {
973
- 'none': '@?[_a-zA-Z][a-zA-Z0-9_]*',
974
- 'basic': ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' +
975
- '[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl +
976
- uni.Nd + uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*'),
977
- 'full': ('@?(?:_|[^' +
978
- uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])'
979
- + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
980
- 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'),
981
- }
982
-
983
- tokens = {}
984
- token_variants = True
985
-
986
- for levelname, cs_ident in levels.items():
987
- tokens[levelname] = {
988
- 'root': [
989
- # method names
990
- (r'^([ \t]*(?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type
991
- r'(' + cs_ident + ')' # method name
992
- r'(\s*)(\()', # signature start
993
- bygroups(using(this), Name.Function, Text, Punctuation)),
994
- (r'^\s*\[.*?\]', Name.Attribute),
995
- (r'[^\S\n]+', Text),
996
- (r'\\\n', Text), # line continuation
997
- (r'//.*?\n', Comment.Single),
998
- (r'/[*](.|\n)*?[*]/', Comment.Multiline),
999
- (r'\n', Text),
1000
- (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
1001
- (r'[{}]', Punctuation),
1002
- (r'@"(""|[^"])*"', String),
1003
- (r'"(\\\\|\\"|[^"\n])*["\n]', String),
1004
- (r"'\\.'|'[^\\]'", String.Char),
1005
- (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?"
1006
- r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number),
1007
- (r'#[ \t]*(if|endif|else|elif|define|undef|'
1008
- r'line|error|warning|region|endregion|pragma)\b.*?\n',
1009
- Comment.Preproc),
1010
- (r'\b(extern)(\s+)(alias)\b', bygroups(Keyword, Text,
1011
- Keyword)),
1012
- (r'(abstract|as|break|catch|'
1013
- r'fun|continue|default|delegate|'
1014
- r'do|else|enum|extern|false|finally|'
1015
- r'fixed|for|goto|if|implicit|in|interface|'
1016
- r'internal|is|lock|null|'
1017
- r'out|override|private|protected|public|readonly|'
1018
- r'ref|return|sealed|sizeof|'
1019
- r'when|this|throw|true|try|typeof|'
1020
- r'unchecked|unsafe|virtual|void|while|'
1021
- r'get|set|new|partial|yield|val|var)\b', Keyword),
1022
- (r'(global)(::)', bygroups(Keyword, Punctuation)),
1023
- (r'(bool|byte|char|decimal|double|dynamic|float|int|long|'
1024
- r'short)\b\??', Keyword.Type),
1025
- (r'(class|struct)(\s+)', bygroups(Keyword, Text), 'class'),
1026
- (r'(package|using)(\s+)', bygroups(Keyword, Text), 'package'),
1027
- (cs_ident, Name),
1028
- ],
1029
- 'class': [
1030
- (cs_ident, Name.Class, '#pop')
1031
- ],
1032
- 'package': [
1033
- (r'(?=\()', Text, '#pop'), # using (resource)
1034
- ('(' + cs_ident + r'|\.)+', Name.Namespace, '#pop')
1035
- ]
1036
- }
980
+ kt_name = ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' +
981
+ '[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + uni.Nd +
982
+ uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*')
983
+ kt_id = '(' + kt_name + '|`' + kt_name + '`)'
1037
984
 
1038
- def __init__(self, **options):
1039
- level = get_choice_opt(options, 'unicodelevel', self.tokens.keys(),
1040
- 'basic')
1041
- if level not in self._all_tokens:
1042
- # compile the regexes now
1043
- self._tokens = self.__class__.process_tokendef(level)
1044
- else:
1045
- self._tokens = self._all_tokens[level]
1046
-
1047
- RegexLexer.__init__(self, **options)
985
+ tokens = {
986
+ 'root': [
987
+ (r'^\s*\[.*?\]', Name.Attribute),
988
+ (r'[^\S\n]+', Text),
989
+ (r'\\\n', Text), # line continuation
990
+ (r'//.*?\n', Comment.Single),
991
+ (r'/[*].*?[*]/', Comment.Multiline),
992
+ (r'\n', Text),
993
+ (r'::|!!|\?[:.]', Operator),
994
+ (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
995
+ (r'[{}]', Punctuation),
996
+ (r'@"(""|[^"])*"', String),
997
+ (r'"(\\\\|\\"|[^"\n])*["\n]', String),
998
+ (r"'\\.'|'[^\\]'", String.Char),
999
+ (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFL]?|"
1000
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
1001
+ (r'(class)(\s+)(object)', bygroups(Keyword, Text, Keyword)),
1002
+ (r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'),
1003
+ (r'(package|import)(\s+)', bygroups(Keyword, Text), 'package'),
1004
+ (r'(val|var)(\s+)', bygroups(Keyword, Text), 'property'),
1005
+ (r'(fun)(\s+)', bygroups(Keyword, Text), 'function'),
1006
+ (r'(abstract|annotation|as|break|by|catch|class|continue|do|else|'
1007
+ r'enum|false|final|finally|for|fun|get|if|import|in|inner|'
1008
+ r'internal|is|null|object|open|out|override|package|private|'
1009
+ r'protected|public|reified|return|set|super|this|throw|trait|'
1010
+ r'true|try|type|val|var|vararg|when|where|while|This)\b', Keyword),
1011
+ (kt_id, Name),
1012
+ ],
1013
+ 'package': [
1014
+ (r'\S+', Name.Namespace, '#pop')
1015
+ ],
1016
+ 'class': [
1017
+ (kt_id, Name.Class, '#pop')
1018
+ ],
1019
+ 'property': [
1020
+ (kt_id, Name.Property, '#pop')
1021
+ ],
1022
+ 'function': [
1023
+ (kt_id, Name.Function, '#pop')
1024
+ ],
1025
+ }
1048
1026
 
1049
1027
 
1050
1028
  class XtendLexer(RegexLexer):
1051
1029
  """
1052
1030
  For `Xtend <http://xtend-lang.org/>`_ source code.
1053
1031
 
1054
- *New in Pygments 1.6.*
1032
+ .. versionadded:: 1.6
1055
1033
  """
1056
1034
 
1057
1035
  name = 'Xtend'
@@ -1064,14 +1042,14 @@ class XtendLexer(RegexLexer):
1064
1042
  tokens = {
1065
1043
  'root': [
1066
1044
  # method names
1067
- (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
1068
- r'([a-zA-Z_$][a-zA-Z0-9_$]*)' # method name
1069
- r'(\s*)(\()', # signature start
1045
+ (r'^(\s*(?:[a-zA-Z_][\w\.\[\]]*\s+)+?)' # return arguments
1046
+ r'([a-zA-Z_$][\w$]*)' # method name
1047
+ r'(\s*)(\()', # signature start
1070
1048
  bygroups(using(this), Name.Function, Text, Operator)),
1071
1049
  (r'[^\S\n]+', Text),
1072
1050
  (r'//.*?\n', Comment.Single),
1073
1051
  (r'/\*.*?\*/', Comment.Multiline),
1074
- (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
1052
+ (r'@[a-zA-Z_][\w\.]*', Name.Decorator),
1075
1053
  (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
1076
1054
  r'if|goto|instanceof|new|return|switch|this|throw|try|while|IF|'
1077
1055
  r'ELSE|ELSEIF|ENDIF|FOR|ENDFOR|SEPARATOR|BEFORE|AFTER)\b',
@@ -1087,11 +1065,11 @@ class XtendLexer(RegexLexer):
1087
1065
  'class'),
1088
1066
  (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
1089
1067
  (r"(''')", String, 'template'),
1090
- (ur"(\u00BB)", String, 'template'),
1068
+ (u'(\u00BB)', String, 'template'),
1091
1069
  (r'"(\\\\|\\"|[^"])*"', String),
1092
1070
  (r"'(\\\\|\\'|[^'])*'", String),
1093
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
1094
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
1071
+ (r'[a-zA-Z_]\w*:', Name.Label),
1072
+ (r'[a-zA-Z_\$]\w*', Name),
1095
1073
  (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
1096
1074
  (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1097
1075
  (r'0x[0-9a-fA-F]+', Number.Hex),
@@ -1099,14 +1077,451 @@ class XtendLexer(RegexLexer):
1099
1077
  (r'\n', Text)
1100
1078
  ],
1101
1079
  'class': [
1102
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
1080
+ (r'[a-zA-Z_]\w*', Name.Class, '#pop')
1103
1081
  ],
1104
1082
  'import': [
1105
- (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
1083
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
1106
1084
  ],
1107
1085
  'template': [
1108
1086
  (r"'''", String, '#pop'),
1109
- (ur"\u00AB", String, '#pop'),
1087
+ (u'\u00AB', String, '#pop'),
1110
1088
  (r'.', String)
1111
1089
  ],
1112
1090
  }
1091
+
1092
+ class PigLexer(RegexLexer):
1093
+ """
1094
+ For `Pig Latin <https://pig.apache.org/>`_ source code.
1095
+
1096
+ .. versionadded:: 2.0
1097
+ """
1098
+
1099
+ name = 'Pig'
1100
+ aliases = ['pig']
1101
+ filenames = ['*.pig']
1102
+ mimetypes = ['text/x-pig']
1103
+
1104
+ flags = re.MULTILINE | re.IGNORECASE
1105
+
1106
+ tokens = {
1107
+ 'root': [
1108
+ (r'\s+', Text),
1109
+ (r'--.*', Comment),
1110
+ (r'/\*[\w\W]*?\*/', Comment.Multiline),
1111
+ (r'\\\n', Text),
1112
+ (r'\\', Text),
1113
+ (r'\'(?:\\[ntbrf\\\']|\\u[0-9a-f]{4}|[^\'\\\n\r])*\'', String),
1114
+ include('keywords'),
1115
+ include('types'),
1116
+ include('builtins'),
1117
+ include('punct'),
1118
+ include('operators'),
1119
+ (r'[0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1120
+ (r'0x[0-9a-f]+', Number.Hex),
1121
+ (r'[0-9]+L?', Number.Integer),
1122
+ (r'\n', Text),
1123
+ (r'([a-z_]\w*)(\s*)(\()',
1124
+ bygroups(Name.Function, Text, Punctuation)),
1125
+ (r'[()#:]', Text),
1126
+ (r'[^(:#\'\")\s]+', Text),
1127
+ (r'\S+\s+', Text) # TODO: make tests pass without \s+
1128
+ ],
1129
+ 'keywords': [
1130
+ (r'(assert|and|any|all|arrange|as|asc|bag|by|cache|CASE|cat|cd|cp|'
1131
+ r'%declare|%default|define|dense|desc|describe|distinct|du|dump|'
1132
+ r'eval|exex|explain|filter|flatten|foreach|full|generate|group|'
1133
+ r'help|if|illustrate|import|inner|input|into|is|join|kill|left|'
1134
+ r'limit|load|ls|map|matches|mkdir|mv|not|null|onschema|or|order|'
1135
+ r'outer|output|parallel|pig|pwd|quit|register|returns|right|rm|'
1136
+ r'rmf|rollup|run|sample|set|ship|split|stderr|stdin|stdout|store|'
1137
+ r'stream|through|union|using|void)\b', Keyword)
1138
+ ],
1139
+ 'builtins': [
1140
+ (r'(AVG|BinStorage|cogroup|CONCAT|copyFromLocal|copyToLocal|COUNT|'
1141
+ r'cross|DIFF|MAX|MIN|PigDump|PigStorage|SIZE|SUM|TextLoader|'
1142
+ r'TOKENIZE)\b', Name.Builtin)
1143
+ ],
1144
+ 'types': [
1145
+ (r'(bytearray|BIGINTEGER|BIGDECIMAL|chararray|datetime|double|float|'
1146
+ r'int|long|tuple)\b', Keyword.Type)
1147
+ ],
1148
+ 'punct': [
1149
+ (r'[;(){}\[\]]', Punctuation),
1150
+ ],
1151
+ 'operators': [
1152
+ (r'[#=,./%+\-?]', Operator),
1153
+ (r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
1154
+ (r'(==|<=|<|>=|>|!=)', Operator),
1155
+ ],
1156
+ }
1157
+
1158
+
1159
+ class GoloLexer(RegexLexer):
1160
+ """
1161
+ For `Golo <http://golo-lang.org/>`_ source code.
1162
+
1163
+ .. versionadded:: 2.0
1164
+ """
1165
+
1166
+ name = 'Golo'
1167
+ filenames = ['*.golo']
1168
+ aliases = ['golo']
1169
+
1170
+ tokens = {
1171
+ 'root': [
1172
+ (r'[^\S\n]+', Text),
1173
+
1174
+ (r'#.*$', Comment),
1175
+
1176
+ (r'(\^|\.\.\.|:|\?:|->|==|!=|=|\+|\*|%|/|<=|<|>=|>|=|\.)',
1177
+ Operator),
1178
+ (r'(?<=[^-])(-)(?=[^-])', Operator),
1179
+
1180
+ (r'(?<=[^`])(is|isnt|and|or|not|oftype|in|orIfNull)\b', Operator.Word),
1181
+ (r'[]{}|(),[]', Punctuation),
1182
+
1183
+ (r'(module|import)(\s+)',
1184
+ bygroups(Keyword.Namespace, Text),
1185
+ 'modname'),
1186
+ (r'\b([a-zA-Z_][\w$.]*)(::)', bygroups(Name.Namespace, Punctuation)),
1187
+ (r'\b([a-zA-Z_][\w$]*(?:\.[a-zA-Z_][\w$]*)+)\b', Name.Namespace),
1188
+
1189
+ (r'(let|var)(\s+)',
1190
+ bygroups(Keyword.Declaration, Text),
1191
+ 'varname'),
1192
+ (r'(struct)(\s+)',
1193
+ bygroups(Keyword.Declaration, Text),
1194
+ 'structname'),
1195
+ (r'(function)(\s+)',
1196
+ bygroups(Keyword.Declaration, Text),
1197
+ 'funcname'),
1198
+
1199
+ (r'(null|true|false)\b', Keyword.Constant),
1200
+ (r'(augment|pimp'
1201
+ r'|if|else|case|match|return'
1202
+ r'|case|when|then|otherwise'
1203
+ r'|while|for|foreach'
1204
+ r'|try|catch|finally|throw'
1205
+ r'|local'
1206
+ r'|continue|break)\b', Keyword),
1207
+
1208
+ (r'(map|array|list|set|vector|tuple)(\[)',
1209
+ bygroups(Name.Builtin, Punctuation)),
1210
+ (r'(print|println|readln|raise|fun'
1211
+ r'|asInterfaceInstance)\b', Name.Builtin),
1212
+ (r'(`?[a-zA-Z_][\w$]*)(\()',
1213
+ bygroups(Name.Function, Punctuation)),
1214
+
1215
+ (r'-?[\d_]*\.[\d_]*([eE][+-]?\d[\d_]*)?F?', Number.Float),
1216
+ (r'0[0-7]+j?', Number.Oct),
1217
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
1218
+ (r'-?\d[\d_]*L', Number.Integer.Long),
1219
+ (r'-?\d[\d_]*', Number.Integer),
1220
+
1221
+ ('`?[a-zA-Z_][\w$]*', Name),
1222
+
1223
+ (r'"""', String, combined('stringescape', 'triplestring')),
1224
+ (r'"', String, combined('stringescape', 'doublestring')),
1225
+ (r"'", String, combined('stringescape', 'singlestring')),
1226
+ (r'----((.|\n)*?)----', String.Doc)
1227
+
1228
+ ],
1229
+
1230
+ 'funcname': [
1231
+ (r'`?[a-zA-Z_][\w$]*', Name.Function, '#pop'),
1232
+ ],
1233
+ 'modname': [
1234
+ (r'[a-zA-Z_][\w$.]*\*?', Name.Namespace, '#pop')
1235
+ ],
1236
+ 'structname': [
1237
+ (r'`?[\w.]+\*?', Name.Class, '#pop')
1238
+ ],
1239
+ 'varname': [
1240
+ (r'`?[a-zA-Z_][\w$]*', Name.Variable, '#pop'),
1241
+ ],
1242
+ 'string': [
1243
+ (r'[^\\\'"\n]+', String),
1244
+ (r'[\'"\\]', String)
1245
+ ],
1246
+ 'stringescape': [
1247
+ (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
1248
+ r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
1249
+ ],
1250
+ 'triplestring': [
1251
+ (r'"""', String, '#pop'),
1252
+ include('string'),
1253
+ (r'\n', String),
1254
+ ],
1255
+ 'doublestring': [
1256
+ (r'"', String.Double, '#pop'),
1257
+ include('string'),
1258
+ ],
1259
+ 'singlestring': [
1260
+ (r"'", String, '#pop'),
1261
+ include('string'),
1262
+ ],
1263
+ 'operators': [
1264
+ (r'[#=,./%+\-?]', Operator),
1265
+ (r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
1266
+ (r'(==|<=|<|>=|>|!=)', Operator),
1267
+ ],
1268
+ }
1269
+
1270
+
1271
+ class JasminLexer(RegexLexer):
1272
+ """
1273
+ For `Jasmin <http://jasmin.sourceforge.net/>`_ assembly code.
1274
+
1275
+ .. versionadded:: 2.0
1276
+ """
1277
+
1278
+ name = 'Jasmin'
1279
+ aliases = ['jasmin', 'jasminxt']
1280
+ filenames = ['*.j']
1281
+
1282
+ _whitespace = r' \n\t\r'
1283
+ _ws = r'(?:[%s]+)' % _whitespace
1284
+ _separator = r'%s:=' % _whitespace
1285
+ _break = r'(?=[%s]|$)' % _separator
1286
+ _name = r'[^%s]+' % _separator
1287
+ _unqualified_name = r'(?:[^%s.;\[/]+)' % _separator
1288
+
1289
+ tokens = {
1290
+ 'default': [
1291
+ (r'\n', Text, '#pop'),
1292
+ (r"'", String.Single, ('#pop', 'quote')),
1293
+ (r'"', String.Double, 'string'),
1294
+ (r'=', Punctuation),
1295
+ (r':', Punctuation, 'label'),
1296
+ (_ws, Text),
1297
+ (r';.*', Comment.Single),
1298
+ (r'(\$[-+])?0x-?[\da-fA-F]+%s' % _break, Number.Hex),
1299
+ (r'(\$[-+]|\+)?-?\d+%s' % _break, Number.Integer),
1300
+ (r'-?(\d+\.\d*|\.\d+)([eE][-+]?\d+)?[fFdD]?'
1301
+ r'[\x00-\x08\x0b\x0c\x0e-\x1f]*%s' % _break, Number.Float),
1302
+ (r'\$%s' % _name, Name.Variable),
1303
+
1304
+ # Directives
1305
+ (r'\.annotation%s' % _break, Keyword.Reserved, 'annotation'),
1306
+ (r'(\.attribute|\.bytecode|\.debug|\.deprecated|\.enclosing|'
1307
+ r'\.interface|\.line|\.signature|\.source|\.stack|\.var|abstract|'
1308
+ r'annotation|bridge|class|default|enum|field|final|fpstrict|'
1309
+ r'interface|native|private|protected|public|signature|static|'
1310
+ r'synchronized|synthetic|transient|varargs|volatile)%s' % _break,
1311
+ Keyword.Reserved),
1312
+ (r'\.catch%s' % _break, Keyword.Reserved, 'caught-exception'),
1313
+ (r'(\.class|\.implements|\.inner|\.super|inner|invisible|'
1314
+ r'invisibleparam|outer|visible|visibleparam)%s' % _break,
1315
+ Keyword.Reserved, 'class/convert-dots'),
1316
+ (r'\.field%s' % _break, Keyword.Reserved,
1317
+ ('descriptor/convert-dots', 'field')),
1318
+ (r'(\.end|\.limit|use)%s' % _break, Keyword.Reserved,
1319
+ 'no-verification'),
1320
+ (r'\.method%s' % _break, Keyword.Reserved, 'method'),
1321
+ (r'\.set%s' % _break, Keyword.Reserved, 'var'),
1322
+ (r'\.throws%s' % _break, Keyword.Reserved, 'exception'),
1323
+ (r'(from|offset|to|using)%s' % _break, Keyword.Reserved, 'label'),
1324
+ (r'is%s' % _break, Keyword.Reserved,
1325
+ ('descriptor/convert-dots', 'var')),
1326
+ (r'(locals|stack)%s' % _break, Keyword.Reserved, 'verification'),
1327
+ (r'method%s' % _break, Keyword.Reserved, 'enclosing-method'),
1328
+
1329
+ # Instructions
1330
+ (r'(aaload|aastore|aconst_null|aload|aload_0|aload_1|aload_2|'
1331
+ r'aload_3|aload_w|areturn|arraylength|astore|astore_0|astore_1|'
1332
+ r'astore_2|astore_3|astore_w|athrow|baload|bastore|bipush|'
1333
+ r'breakpoint|caload|castore|d2f|d2i|d2l|dadd|daload|dastore|'
1334
+ r'dcmpg|dcmpl|dconst_0|dconst_1|ddiv|dload|dload_0|dload_1|'
1335
+ r'dload_2|dload_3|dload_w|dmul|dneg|drem|dreturn|dstore|dstore_0|'
1336
+ r'dstore_1|dstore_2|dstore_3|dstore_w|dsub|dup|dup2|dup2_x1|'
1337
+ r'dup2_x2|dup_x1|dup_x2|f2d|f2i|f2l|fadd|faload|fastore|fcmpg|'
1338
+ r'fcmpl|fconst_0|fconst_1|fconst_2|fdiv|fload|fload_0|fload_1|'
1339
+ r'fload_2|fload_3|fload_w|fmul|fneg|frem|freturn|fstore|fstore_0|'
1340
+ r'fstore_1|fstore_2|fstore_3|fstore_w|fsub|i2b|i2c|i2d|i2f|i2l|'
1341
+ r'i2s|iadd|iaload|iand|iastore|iconst_0|iconst_1|iconst_2|'
1342
+ r'iconst_3|iconst_4|iconst_5|iconst_m1|idiv|iinc|iinc_w|iload|'
1343
+ r'iload_0|iload_1|iload_2|iload_3|iload_w|imul|ineg|int2byte|'
1344
+ r'int2char|int2short|ior|irem|ireturn|ishl|ishr|istore|istore_0|'
1345
+ r'istore_1|istore_2|istore_3|istore_w|isub|iushr|ixor|l2d|l2f|'
1346
+ r'l2i|ladd|laload|land|lastore|lcmp|lconst_0|lconst_1|ldc2_w|'
1347
+ r'ldiv|lload|lload_0|lload_1|lload_2|lload_3|lload_w|lmul|lneg|'
1348
+ r'lookupswitch|lor|lrem|lreturn|lshl|lshr|lstore|lstore_0|'
1349
+ r'lstore_1|lstore_2|lstore_3|lstore_w|lsub|lushr|lxor|'
1350
+ r'monitorenter|monitorexit|nop|pop|pop2|ret|ret_w|return|saload|'
1351
+ r'sastore|sipush|swap)%s' % _break, Keyword.Reserved),
1352
+ (r'(anewarray|checkcast|instanceof|ldc|ldc_w|new)%s' % _break,
1353
+ Keyword.Reserved, 'class/no-dots'),
1354
+ (r'(invokedynamic|invokeinterface|invokenonvirtual|invokespecial|'
1355
+ r'invokestatic|invokevirtual)%s' % _break, Keyword.Reserved,
1356
+ 'invocation'),
1357
+ (r'(getfield|putfield)%s' % _break, Keyword.Reserved,
1358
+ ('descriptor/no-dots', 'field')),
1359
+ (r'(getstatic|putstatic)%s' % _break, Keyword.Reserved,
1360
+ ('descriptor/no-dots', 'static')),
1361
+ (r'(goto|goto_w|if_acmpeq|if_acmpne|if_icmpeq|if_icmpge|if_icmpgt|'
1362
+ r'if_icmple|if_icmplt|if_icmpne|ifeq|ifge|ifgt|ifle|iflt|ifne|'
1363
+ r'ifnonnull|ifnull|jsr|jsr_w)%s' % _break, Keyword.Reserved,
1364
+ 'label'),
1365
+ (r'(multianewarray|newarray)%s' % _break, Keyword.Reserved,
1366
+ 'descriptor/convert-dots'),
1367
+ (r'tableswitch%s' % _break, Keyword.Reserved, 'table')
1368
+ ],
1369
+ 'quote': [
1370
+ (r"'", String.Single, '#pop'),
1371
+ (r'\\u[\da-fA-F]{4}', String.Escape),
1372
+ (r"[^'\\]+", String.Single)
1373
+ ],
1374
+ 'string': [
1375
+ (r'"', String.Double, '#pop'),
1376
+ (r'\\([nrtfb"\'\\]|u[\da-fA-F]{4}|[0-3]?[0-7]{1,2})',
1377
+ String.Escape),
1378
+ (r'[^"\\]+', String.Double)
1379
+ ],
1380
+ 'root': [
1381
+ (r'\n+', Text),
1382
+ (r"'", String.Single, 'quote'),
1383
+ include('default'),
1384
+ (r'(%s)([ \t\r]*)(:)' % _name,
1385
+ bygroups(Name.Label, Text, Punctuation)),
1386
+ (_name, String.Other)
1387
+ ],
1388
+ 'annotation': [
1389
+ (r'\n', Text, ('#pop', 'annotation-body')),
1390
+ (r'default%s' % _break, Keyword.Reserved,
1391
+ ('#pop', 'annotation-default')),
1392
+ include('default')
1393
+ ],
1394
+ 'annotation-body': [
1395
+ (r'\n+', Text),
1396
+ (r'\.end%s' % _break, Keyword.Reserved, '#pop'),
1397
+ include('default'),
1398
+ (_name, String.Other, ('annotation-items', 'descriptor/no-dots'))
1399
+ ],
1400
+ 'annotation-default': [
1401
+ (r'\n+', Text),
1402
+ (r'\.end%s' % _break, Keyword.Reserved, '#pop'),
1403
+ include('default'),
1404
+ default(('annotation-items', 'descriptor/no-dots'))
1405
+ ],
1406
+ 'annotation-items': [
1407
+ (r"'", String.Single, 'quote'),
1408
+ include('default'),
1409
+ (_name, String.Other)
1410
+ ],
1411
+ 'caught-exception': [
1412
+ (r'all%s' % _break, Keyword, '#pop'),
1413
+ include('exception')
1414
+ ],
1415
+ 'class/convert-dots': [
1416
+ include('default'),
1417
+ (r'(L)((?:%s[/.])*)(%s)(;)' % (_unqualified_name, _name),
1418
+ bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
1419
+ '#pop'),
1420
+ (r'((?:%s[/.])*)(%s)' % (_unqualified_name, _name),
1421
+ bygroups(Name.Namespace, Name.Class), '#pop')
1422
+ ],
1423
+ 'class/no-dots': [
1424
+ include('default'),
1425
+ (r'\[+', Punctuation, ('#pop', 'descriptor/no-dots')),
1426
+ (r'(L)((?:%s/)*)(%s)(;)' % (_unqualified_name, _name),
1427
+ bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
1428
+ '#pop'),
1429
+ (r'((?:%s/)*)(%s)' % (_unqualified_name, _name),
1430
+ bygroups(Name.Namespace, Name.Class), '#pop')
1431
+ ],
1432
+ 'descriptor/convert-dots': [
1433
+ include('default'),
1434
+ (r'\[+', Punctuation),
1435
+ (r'(L)((?:%s[/.])*)(%s?)(;)' % (_unqualified_name, _name),
1436
+ bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
1437
+ '#pop'),
1438
+ (r'[^%s\[)L]*' % _separator, Keyword.Type, '#pop')
1439
+ ],
1440
+ 'descriptor/no-dots': [
1441
+ include('default'),
1442
+ (r'\[+', Punctuation),
1443
+ (r'(L)((?:%s/)*)(%s)(;)' % (_unqualified_name, _name),
1444
+ bygroups(Keyword.Type, Name.Namespace, Name.Class, Punctuation),
1445
+ '#pop'),
1446
+ (r'[^%s\[)L]*' % _separator, Keyword.Type, '#pop')
1447
+ ],
1448
+ 'descriptors/convert-dots': [
1449
+ (r'\)', Punctuation, '#pop'),
1450
+ default('descriptor/convert-dots')
1451
+ ],
1452
+ 'enclosing-method': [
1453
+ (_ws, Text),
1454
+ (r'(?=[^%s]*\()' % _separator, Text, ('#pop', 'invocation')),
1455
+ default(('#pop', 'class/convert-dots'))
1456
+ ],
1457
+ 'exception': [
1458
+ include('default'),
1459
+ (r'((?:%s[/.])*)(%s)' % (_unqualified_name, _name),
1460
+ bygroups(Name.Namespace, Name.Exception), '#pop')
1461
+ ],
1462
+ 'field': [
1463
+ (r'static%s' % _break, Keyword.Reserved, ('#pop', 'static')),
1464
+ include('default'),
1465
+ (r'((?:%s[/.](?=[^%s]*[/.]))*)(%s[/.])?(%s)' %
1466
+ (_unqualified_name, _separator, _unqualified_name, _name),
1467
+ bygroups(Name.Namespace, Name.Class, Name.Variable.Instance),
1468
+ '#pop')
1469
+ ],
1470
+ 'invocation': [
1471
+ include('default'),
1472
+ (r'((?:%s[/.](?=[^%s(]*[/.]))*)(%s[/.])?(%s)(\()' %
1473
+ (_unqualified_name, _separator, _unqualified_name, _name),
1474
+ bygroups(Name.Namespace, Name.Class, Name.Function, Punctuation),
1475
+ ('#pop', 'descriptor/convert-dots', 'descriptors/convert-dots',
1476
+ 'descriptor/convert-dots'))
1477
+ ],
1478
+ 'label': [
1479
+ include('default'),
1480
+ (_name, Name.Label, '#pop')
1481
+ ],
1482
+ 'method': [
1483
+ include('default'),
1484
+ (r'(%s)(\()' % _name, bygroups(Name.Function, Punctuation),
1485
+ ('#pop', 'descriptor/convert-dots', 'descriptors/convert-dots',
1486
+ 'descriptor/convert-dots'))
1487
+ ],
1488
+ 'no-verification': [
1489
+ (r'(locals|method|stack)%s' % _break, Keyword.Reserved, '#pop'),
1490
+ include('default')
1491
+ ],
1492
+ 'static': [
1493
+ include('default'),
1494
+ (r'((?:%s[/.](?=[^%s]*[/.]))*)(%s[/.])?(%s)' %
1495
+ (_unqualified_name, _separator, _unqualified_name, _name),
1496
+ bygroups(Name.Namespace, Name.Class, Name.Variable.Class), '#pop')
1497
+ ],
1498
+ 'table': [
1499
+ (r'\n+', Text),
1500
+ (r'default%s' % _break, Keyword.Reserved, '#pop'),
1501
+ include('default'),
1502
+ (_name, Name.Label)
1503
+ ],
1504
+ 'var': [
1505
+ include('default'),
1506
+ (_name, Name.Variable, '#pop')
1507
+ ],
1508
+ 'verification': [
1509
+ include('default'),
1510
+ (r'(Double|Float|Integer|Long|Null|Top|UninitializedThis)%s' %
1511
+ _break, Keyword, '#pop'),
1512
+ (r'Object%s' % _break, Keyword, ('#pop', 'class/no-dots')),
1513
+ (r'Uninitialized%s' % _break, Keyword, ('#pop', 'label'))
1514
+ ]
1515
+ }
1516
+
1517
+ def analyse_text(text):
1518
+ score = 0
1519
+ if re.search(r'^\s*\.class\s', text, re.MULTILINE):
1520
+ score += 0.5
1521
+ if re.search(r'^\s*[a-z]+_[a-z]+\b', text, re.MULTILINE):
1522
+ score += 0.3
1523
+ if re.search(r'^\s*\.(attribute|bytecode|debug|deprecated|enclosing|'
1524
+ r'inner|interface|limit|set|signature|stack)\b', text,
1525
+ re.MULTILINE):
1526
+ score += 0.6
1527
+ return score