gitlab-pygments.rb 0.3.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +71 -0
  4. data/Gemfile +1 -1
  5. data/LICENSE +17 -0
  6. data/README.md +28 -1
  7. data/Rakefile +2 -5
  8. data/lexers +0 -0
  9. data/lib/pygments/mentos.py +19 -12
  10. data/lib/pygments/popen.rb +21 -4
  11. data/lib/pygments/version.rb +1 -1
  12. data/pygments.rb.gemspec +2 -0
  13. data/test/test_pygments.rb +13 -2
  14. data/vendor/custom_lexers/github.py +206 -3
  15. data/vendor/pygments-main/AUTHORS +41 -3
  16. data/vendor/pygments-main/CHANGES +132 -5
  17. data/vendor/pygments-main/LICENSE +1 -1
  18. data/vendor/pygments-main/Makefile +1 -1
  19. data/vendor/pygments-main/REVISION +1 -1
  20. data/vendor/pygments-main/docs/generate.py +1 -1
  21. data/vendor/pygments-main/docs/src/api.txt +1 -1
  22. data/vendor/pygments-main/docs/src/index.txt +1 -1
  23. data/vendor/pygments-main/docs/src/integrate.txt +5 -0
  24. data/vendor/pygments-main/docs/src/java.txt +70 -0
  25. data/vendor/pygments-main/docs/src/lexerdevelopment.txt +52 -0
  26. data/vendor/pygments-main/external/autopygmentize +64 -0
  27. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
  28. data/vendor/pygments-main/external/markdown-processor.py +2 -2
  29. data/vendor/pygments-main/external/moin-parser.py +1 -1
  30. data/vendor/pygments-main/external/rst-directive-old.py +1 -1
  31. data/vendor/pygments-main/external/rst-directive.py +1 -1
  32. data/vendor/pygments-main/pygmentize +1 -1
  33. data/vendor/pygments-main/pygments/__init__.py +2 -2
  34. data/vendor/pygments-main/pygments/cmdline.py +14 -6
  35. data/vendor/pygments-main/pygments/console.py +1 -1
  36. data/vendor/pygments-main/pygments/filter.py +1 -1
  37. data/vendor/pygments-main/pygments/filters/__init__.py +3 -4
  38. data/vendor/pygments-main/pygments/formatter.py +4 -1
  39. data/vendor/pygments-main/pygments/formatters/__init__.py +1 -1
  40. data/vendor/pygments-main/pygments/formatters/_mapping.py +3 -3
  41. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  42. data/vendor/pygments-main/pygments/formatters/html.py +73 -2
  43. data/vendor/pygments-main/pygments/formatters/img.py +2 -2
  44. data/vendor/pygments-main/pygments/formatters/latex.py +9 -9
  45. data/vendor/pygments-main/pygments/formatters/other.py +1 -3
  46. data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
  47. data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
  48. data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
  49. data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
  50. data/vendor/pygments-main/pygments/lexer.py +78 -10
  51. data/vendor/pygments-main/pygments/lexers/__init__.py +13 -2
  52. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  53. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +1 -1
  54. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
  55. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +1 -1
  56. data/vendor/pygments-main/pygments/lexers/_mapping.py +92 -36
  57. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
  58. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +2 -2
  59. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +4 -3
  60. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
  61. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +11 -0
  62. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
  63. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
  64. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -3
  65. data/vendor/pygments-main/pygments/lexers/agile.py +525 -38
  66. data/vendor/pygments-main/pygments/lexers/asm.py +45 -7
  67. data/vendor/pygments-main/pygments/lexers/compiled.py +1257 -425
  68. data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
  69. data/vendor/pygments-main/pygments/lexers/dotnet.py +97 -62
  70. data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
  71. data/vendor/pygments-main/pygments/lexers/functional.py +931 -32
  72. data/vendor/pygments-main/pygments/lexers/github.py +206 -3
  73. data/vendor/pygments-main/pygments/lexers/hdl.py +3 -3
  74. data/vendor/pygments-main/pygments/lexers/jvm.py +309 -44
  75. data/vendor/pygments-main/pygments/lexers/math.py +876 -30
  76. data/vendor/pygments-main/pygments/lexers/other.py +956 -517
  77. data/vendor/pygments-main/pygments/lexers/parsers.py +85 -2
  78. data/vendor/pygments-main/pygments/lexers/shell.py +81 -18
  79. data/vendor/pygments-main/pygments/lexers/special.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/sql.py +2 -2
  81. data/vendor/pygments-main/pygments/lexers/templates.py +119 -8
  82. data/vendor/pygments-main/pygments/lexers/text.py +155 -15
  83. data/vendor/pygments-main/pygments/lexers/web.py +1578 -397
  84. data/vendor/pygments-main/pygments/modeline.py +40 -0
  85. data/vendor/pygments-main/pygments/plugin.py +1 -1
  86. data/vendor/pygments-main/pygments/scanner.py +1 -1
  87. data/vendor/pygments-main/pygments/style.py +1 -1
  88. data/vendor/pygments-main/pygments/styles/__init__.py +1 -1
  89. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  90. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  91. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  92. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  93. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  94. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  95. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  96. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  97. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  98. data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
  99. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  100. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  101. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  102. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  103. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  104. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  105. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  106. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  107. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  108. data/vendor/pygments-main/pygments/token.py +1 -1
  109. data/vendor/pygments-main/pygments/unistring.py +36 -26
  110. data/vendor/pygments-main/pygments/util.py +46 -1
  111. data/vendor/pygments-main/scripts/check_sources.py +2 -2
  112. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +2 -0
  113. data/vendor/pygments-main/scripts/find_codetags.py +1 -1
  114. data/vendor/pygments-main/scripts/find_error.py +5 -6
  115. data/vendor/pygments-main/setup.cfg +1 -0
  116. data/vendor/pygments-main/setup.py +6 -4
  117. data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
  118. data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
  119. data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
  120. data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
  121. data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
  122. data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
  123. data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
  124. data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
  125. data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
  126. data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
  127. data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
  128. data/vendor/pygments-main/tests/examplefiles/classes.dylan +89 -4
  129. data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
  130. data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
  131. data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
  132. data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
  133. data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
  134. data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
  135. data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
  136. data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
  137. data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
  138. data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
  139. data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
  140. data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
  141. data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
  142. data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
  143. data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
  144. data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
  145. data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
  146. data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
  147. data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
  148. data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
  149. data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
  150. data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
  151. data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
  152. data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
  153. data/vendor/pygments-main/tests/examplefiles/http_request_example +2 -1
  154. data/vendor/pygments-main/tests/examplefiles/http_response_example +4 -2
  155. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
  156. data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
  157. data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
  158. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
  159. data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
  160. data/vendor/pygments-main/tests/examplefiles/matlab_sample +5 -2
  161. data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
  162. data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
  163. data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
  164. data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
  165. data/vendor/pygments-main/tests/examplefiles/objc_example.m +7 -0
  166. data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
  167. data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
  168. data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
  169. data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
  170. data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
  171. data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
  172. data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
  173. data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
  174. data/vendor/pygments-main/tests/examplefiles/test.R +149 -115
  175. data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
  176. data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
  177. data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
  178. data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
  179. data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
  180. data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
  181. data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
  182. data/vendor/pygments-main/tests/examplefiles/type.lisp +16 -0
  183. data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
  184. data/vendor/pygments-main/tests/old_run.py +1 -1
  185. data/vendor/pygments-main/tests/run.py +3 -2
  186. data/vendor/pygments-main/tests/support/tags +36 -0
  187. data/vendor/pygments-main/tests/test_basic_api.py +4 -3
  188. data/vendor/pygments-main/tests/test_clexer.py +1 -1
  189. data/vendor/pygments-main/tests/test_cmdline.py +1 -1
  190. data/vendor/pygments-main/tests/test_examplefiles.py +3 -1
  191. data/vendor/pygments-main/tests/test_html_formatter.py +17 -1
  192. data/vendor/pygments-main/tests/test_latex_formatter.py +1 -1
  193. data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
  194. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  195. data/vendor/pygments-main/tests/test_regexlexer.py +1 -1
  196. data/vendor/pygments-main/tests/test_token.py +1 -1
  197. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  198. data/vendor/pygments-main/tests/test_util.py +22 -3
  199. metadata +84 -16
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for non-source code file types.
7
7
 
8
- :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -25,7 +25,7 @@ __all__ = ['IniLexer', 'PropertiesLexer', 'SourcesListLexer', 'BaseMakefileLexer
25
25
  'RstLexer', 'VimLexer', 'GettextLexer', 'SquidConfLexer',
26
26
  'DebianControlLexer', 'DarcsPatchLexer', 'YamlLexer',
27
27
  'LighttpdConfLexer', 'NginxConfLexer', 'CMakeLexer', 'HttpLexer',
28
- 'PyPyLogLexer']
28
+ 'PyPyLogLexer', 'RegeditLexer', 'HxmlLexer', 'EbnfLexer']
29
29
 
30
30
 
31
31
  class IniLexer(RegexLexer):
@@ -34,14 +34,14 @@ class IniLexer(RegexLexer):
34
34
  """
35
35
 
36
36
  name = 'INI'
37
- aliases = ['ini', 'cfg']
37
+ aliases = ['ini', 'cfg', 'dosini']
38
38
  filenames = ['*.ini', '*.cfg']
39
39
  mimetypes = ['text/x-ini']
40
40
 
41
41
  tokens = {
42
42
  'root': [
43
43
  (r'\s+', Text),
44
- (r'[;#].*?$', Comment),
44
+ (r'[;#].*', Comment.Single),
45
45
  (r'\[.*?\]$', Keyword),
46
46
  (r'(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)',
47
47
  bygroups(Name.Attribute, Text, Operator, Text, String))
@@ -55,6 +55,49 @@ class IniLexer(RegexLexer):
55
55
  return text[0] == '[' and text[npos-1] == ']'
56
56
 
57
57
 
58
+ class RegeditLexer(RegexLexer):
59
+ """
60
+ Lexer for `Windows Registry
61
+ <http://en.wikipedia.org/wiki/Windows_Registry#.REG_files>`_ files produced
62
+ by regedit.
63
+
64
+ *New in Pygments 1.6.*
65
+ """
66
+
67
+ name = 'reg'
68
+ aliases = ['registry']
69
+ filenames = ['*.reg']
70
+ mimetypes = ['text/x-windows-registry']
71
+
72
+ tokens = {
73
+ 'root': [
74
+ (r'Windows Registry Editor.*', Text),
75
+ (r'\s+', Text),
76
+ (r'[;#].*', Comment.Single),
77
+ (r'(\[)(-?)(HKEY_[A-Z_]+)(.*?\])$',
78
+ bygroups(Keyword, Operator, Name.Builtin, Keyword)),
79
+ # String keys, which obey somewhat normal escaping
80
+ (r'("(?:\\"|\\\\|[^"])+")([ \t]*)(=)([ \t]*)',
81
+ bygroups(Name.Attribute, Text, Operator, Text),
82
+ 'value'),
83
+ # Bare keys (includes @)
84
+ (r'(.*?)([ \t]*)(=)([ \t]*)',
85
+ bygroups(Name.Attribute, Text, Operator, Text),
86
+ 'value'),
87
+ ],
88
+ 'value': [
89
+ (r'-', Operator, '#pop'), # delete value
90
+ (r'(dword|hex(?:\([0-9a-fA-F]\))?)(:)([0-9a-fA-F,]+)',
91
+ bygroups(Name.Variable, Punctuation, Number), '#pop'),
92
+ # As far as I know, .reg files do not support line continuation.
93
+ (r'.*', String, '#pop'),
94
+ ]
95
+ }
96
+
97
+ def analyse_text(text):
98
+ return text.startswith('Windows Registry Editor')
99
+
100
+
58
101
  class PropertiesLexer(RegexLexer):
59
102
  """
60
103
  Lexer for configuration files in Java's properties format.
@@ -63,7 +106,7 @@ class PropertiesLexer(RegexLexer):
63
106
  """
64
107
 
65
108
  name = 'Properties'
66
- aliases = ['properties']
109
+ aliases = ['properties', 'jproperties']
67
110
  filenames = ['*.properties']
68
111
  mimetypes = ['text/x-java-properties']
69
112
 
@@ -85,7 +128,7 @@ class SourcesListLexer(RegexLexer):
85
128
  """
86
129
 
87
130
  name = 'Debian Sourcelist'
88
- aliases = ['sourceslist', 'sources.list']
131
+ aliases = ['sourceslist', 'sources.list', 'debsources']
89
132
  filenames = ['sources.list']
90
133
  mimetype = ['application/x-debian-sourceslist']
91
134
 
@@ -187,7 +230,7 @@ class BaseMakefileLexer(RegexLexer):
187
230
  bygroups(Keyword, Text), 'export'),
188
231
  (r'export\s+', Keyword),
189
232
  # assignment
190
- (r'([a-zA-Z0-9_${}.-]+)(\s*)([!?:+]?=)([ \t]*)((?:.*\\\n|.*\n)+)',
233
+ (r'([a-zA-Z0-9_${}.-]+)(\s*)([!?:+]?=)([ \t]*)((?:.*\\\n)+|.*\n)',
191
234
  bygroups(Name.Variable, Text, Operator, Text, using(BashLexer))),
192
235
  # strings
193
236
  (r'(?s)"(\\\\|\\.|[^"\\])*"', String.Double),
@@ -573,7 +616,7 @@ class MoinWikiLexer(RegexLexer):
573
616
  (r'(\'\'\'?|\|\||`|__|~~|\^|,,|::)', Comment), # Formatting
574
617
  # Lists
575
618
  (r'^( +)([.*-])( )', bygroups(Text, Name.Builtin, Text)),
576
- (r'^( +)([a-zivx]{1,5}\.)( )', bygroups(Text, Name.Builtin, Text)),
619
+ (r'^( +)([a-z]{1,5}\.)( )', bygroups(Text, Name.Builtin, Text)),
577
620
  # Other Formatting
578
621
  (r'\[\[\w+.*?\]\]', Keyword), # Macro
579
622
  (r'(\[[^\s\]]+)(\s+[^\]]+?)?(\])',
@@ -1010,7 +1053,7 @@ class DebianControlLexer(RegexLexer):
1010
1053
  *New in Pygments 0.9.*
1011
1054
  """
1012
1055
  name = 'Debian Control file'
1013
- aliases = ['control']
1056
+ aliases = ['control', 'debcontrol']
1014
1057
  filenames = ['control']
1015
1058
 
1016
1059
  tokens = {
@@ -1588,7 +1631,7 @@ class CMakeLexer(RegexLexer):
1588
1631
  # r'VTK_MAKE_INSTANTIATOR|VTK_WRAP_JAVA|VTK_WRAP_PYTHON|'
1589
1632
  # r'VTK_WRAP_TCL|WHILE|WRITE_FILE|'
1590
1633
  # r'COUNTARGS)\b', Name.Builtin, 'args'),
1591
- (r'\b([A-Za-z_]+)([ \t]*)(\()', bygroups(Name.Builtin, Text,
1634
+ (r'\b(\w+)([ \t]*)(\()', bygroups(Name.Builtin, Text,
1592
1635
  Punctuation), 'args'),
1593
1636
  include('keywords'),
1594
1637
  include('ws')
@@ -1643,6 +1686,11 @@ class HttpLexer(RegexLexer):
1643
1686
  yield match.start(5), Literal, match.group(5)
1644
1687
  yield match.start(6), Text, match.group(6)
1645
1688
 
1689
+ def continuous_header_callback(self, match):
1690
+ yield match.start(1), Text, match.group(1)
1691
+ yield match.start(2), Literal, match.group(2)
1692
+ yield match.start(3), Text, match.group(3)
1693
+
1646
1694
  def content_callback(self, match):
1647
1695
  content_type = getattr(self, 'content_type', None)
1648
1696
  content = match.group()
@@ -1661,18 +1709,19 @@ class HttpLexer(RegexLexer):
1661
1709
 
1662
1710
  tokens = {
1663
1711
  'root': [
1664
- (r'(GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE)( +)([^ ]+)( +)'
1665
- r'(HTTPS?)(/)(1\.[01])(\r?\n|$)',
1712
+ (r'(GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE|PATCH)( +)([^ ]+)( +)'
1713
+ r'(HTTP)(/)(1\.[01])(\r?\n|$)',
1666
1714
  bygroups(Name.Function, Text, Name.Namespace, Text,
1667
1715
  Keyword.Reserved, Operator, Number, Text),
1668
1716
  'headers'),
1669
- (r'(HTTPS?)(/)(1\.[01])( +)(\d{3})( +)([^\r\n]+)(\r?\n|$)',
1717
+ (r'(HTTP)(/)(1\.[01])( +)(\d{3})( +)([^\r\n]+)(\r?\n|$)',
1670
1718
  bygroups(Keyword.Reserved, Operator, Number, Text, Number,
1671
1719
  Text, Name.Exception, Text),
1672
1720
  'headers'),
1673
1721
  ],
1674
1722
  'headers': [
1675
1723
  (r'([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)', header_callback),
1724
+ (r'([\t ]+)([^\r\n]+)(\r?\n|$)', continuous_header_callback),
1676
1725
  (r'\r?\n', Text, 'content')
1677
1726
  ],
1678
1727
  'content': [
@@ -1700,8 +1749,8 @@ class PyPyLogLexer(RegexLexer):
1700
1749
  ],
1701
1750
  "jit-log": [
1702
1751
  (r"\[\w+\] jit-log-.*?}$", Keyword, "#pop"),
1703
-
1704
1752
  (r"^\+\d+: ", Comment),
1753
+ (r"--end of the loop--", Comment),
1705
1754
  (r"[ifp]\d+", Name),
1706
1755
  (r"ptr\d+", Name),
1707
1756
  (r"(\()(\w+(?:\.\w+)?)(\))",
@@ -1711,7 +1760,7 @@ class PyPyLogLexer(RegexLexer):
1711
1760
  (r"-?\d+", Number.Integer),
1712
1761
  (r"'.*'", String),
1713
1762
  (r"(None|descr|ConstClass|ConstPtr|TargetToken)", Name),
1714
- (r"<.*?>", Name.Builtin),
1763
+ (r"<.*?>+", Name.Builtin),
1715
1764
  (r"(label|debug_merge_point|jump|finish)", Name.Class),
1716
1765
  (r"(int_add_ovf|int_add|int_sub_ovf|int_sub|int_mul_ovf|int_mul|"
1717
1766
  r"int_floordiv|int_mod|int_lshift|int_rshift|int_and|int_or|"
@@ -1751,3 +1800,94 @@ class PyPyLogLexer(RegexLexer):
1751
1800
  (r"#.*?$", Comment),
1752
1801
  ],
1753
1802
  }
1803
+
1804
+
1805
+ class HxmlLexer(RegexLexer):
1806
+ """
1807
+ Lexer for `haXe build <http://haxe.org/doc/compiler>`_ files.
1808
+
1809
+ *New in Pygments 1.6.*
1810
+ """
1811
+ name = 'Hxml'
1812
+ aliases = ['haxeml', 'hxml']
1813
+ filenames = ['*.hxml']
1814
+
1815
+ tokens = {
1816
+ 'root': [
1817
+ # Seperator
1818
+ (r'(--)(next)', bygroups(Punctuation, Generic.Heading)),
1819
+ # Compiler switches with one dash
1820
+ (r'(-)(prompt|debug|v)', bygroups(Punctuation, Keyword.Keyword)),
1821
+ # Compilerswitches with two dashes
1822
+ (r'(--)(neko-source|flash-strict|flash-use-stage|no-opt|no-traces|'
1823
+ r'no-inline|times|no-output)', bygroups(Punctuation, Keyword)),
1824
+ # Targets and other options that take an argument
1825
+ (r'(-)(cpp|js|neko|x|as3|swf9?|swf-lib|php|xml|main|lib|D|resource|'
1826
+ r'cp|cmd)( +)(.+)',
1827
+ bygroups(Punctuation, Keyword, Whitespace, String)),
1828
+ # Options that take only numerical arguments
1829
+ (r'(-)(swf-version)( +)(\d+)',
1830
+ bygroups(Punctuation, Keyword, Number.Integer)),
1831
+ # An Option that defines the size, the fps and the background
1832
+ # color of an flash movie
1833
+ (r'(-)(swf-header)( +)(\d+)(:)(\d+)(:)(\d+)(:)([A-Fa-f0-9]{6})',
1834
+ bygroups(Punctuation, Keyword, Whitespace, Number.Integer,
1835
+ Punctuation, Number.Integer, Punctuation, Number.Integer,
1836
+ Punctuation, Number.Hex)),
1837
+ # options with two dashes that takes arguments
1838
+ (r'(--)(js-namespace|php-front|php-lib|remap|gen-hx-classes)( +)'
1839
+ r'(.+)', bygroups(Punctuation, Keyword, Whitespace, String)),
1840
+ # Single line comment, multiline ones are not allowed.
1841
+ (r'#.*', Comment.Single)
1842
+ ]
1843
+ }
1844
+
1845
+
1846
+ class EbnfLexer(RegexLexer):
1847
+ """
1848
+ Lexer for `ISO/IEC 14977 EBNF
1849
+ <http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form>`_
1850
+ grammars.
1851
+
1852
+ *New in Pygments 1.7.*
1853
+ """
1854
+
1855
+ name = 'EBNF'
1856
+ aliases = ['ebnf']
1857
+ filenames = ['*.ebnf']
1858
+ mimetypes = ['text/x-ebnf']
1859
+
1860
+ tokens = {
1861
+ 'root': [
1862
+ include('whitespace'),
1863
+ include('comment_start'),
1864
+ include('identifier'),
1865
+ (r'=', Operator, 'production'),
1866
+ ],
1867
+ 'production': [
1868
+ include('whitespace'),
1869
+ include('comment_start'),
1870
+ include('identifier'),
1871
+ (r'"[^"]*"', String.Double),
1872
+ (r"'[^']*'", String.Single),
1873
+ (r'(\?[^?]*\?)', Name.Entity),
1874
+ (r'[\[\]{}(),|]', Punctuation),
1875
+ (r'-', Operator),
1876
+ (r';', Punctuation, '#pop'),
1877
+ ],
1878
+ 'whitespace': [
1879
+ (r'\s+', Text),
1880
+ ],
1881
+ 'comment_start': [
1882
+ (r'\(\*', Comment.Multiline, 'comment'),
1883
+ ],
1884
+ 'comment': [
1885
+ (r'[^*)]', Comment.Multiline),
1886
+ include('comment_start'),
1887
+ (r'\*\)', Comment.Multiline, '#pop'),
1888
+ (r'[*)]', Comment.Multiline),
1889
+ ],
1890
+ 'identifier': [
1891
+ (r'([a-zA-Z][a-zA-Z0-9 \-]*)', Keyword),
1892
+ ],
1893
+ }
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for web-related languages and markup.
7
7
 
8
- :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -17,16 +17,17 @@ from pygments.lexer import RegexLexer, ExtendedRegexLexer, bygroups, using, \
17
17
  from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
18
18
  Number, Other, Punctuation, Literal
19
19
  from pygments.util import get_bool_opt, get_list_opt, looks_like_xml, \
20
- html_doctype_matches
20
+ html_doctype_matches, unirange
21
21
  from pygments.lexers.agile import RubyLexer
22
22
  from pygments.lexers.compiled import ScalaLexer
23
23
 
24
24
 
25
- __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'JSONLexer', 'CssLexer',
25
+ __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'JsonLexer', 'CssLexer',
26
26
  'PhpLexer', 'ActionScriptLexer', 'XsltLexer', 'ActionScript3Lexer',
27
27
  'MxmlLexer', 'HaxeLexer', 'HamlLexer', 'SassLexer', 'ScssLexer',
28
- 'ObjectiveJLexer', 'CoffeeScriptLexer', 'DuelLexer', 'ScamlLexer',
29
- 'JadeLexer', 'XQueryLexer', 'DtdLexer', 'DartLexer']
28
+ 'ObjectiveJLexer', 'CoffeeScriptLexer', 'LiveScriptLexer',
29
+ 'DuelLexer', 'ScamlLexer', 'JadeLexer', 'XQueryLexer',
30
+ 'DtdLexer', 'DartLexer', 'LassoLexer', 'QmlLexer', 'TypeScriptLexer']
30
31
 
31
32
 
32
33
  class JavascriptLexer(RegexLexer):
@@ -66,7 +67,7 @@ class JavascriptLexer(RegexLexer):
66
67
  (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
67
68
  (r'[})\].]', Punctuation),
68
69
  (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
69
- r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
70
+ r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|'
70
71
  r'this)\b', Keyword, 'slashstartsregex'),
71
72
  (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
72
73
  (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
@@ -89,7 +90,7 @@ class JavascriptLexer(RegexLexer):
89
90
  }
90
91
 
91
92
 
92
- class JSONLexer(RegexLexer):
93
+ class JsonLexer(RegexLexer):
93
94
  """
94
95
  For JSON data structures.
95
96
 
@@ -103,10 +104,10 @@ class JSONLexer(RegexLexer):
103
104
 
104
105
  # integer part of a number
105
106
  int_part = r'-?(0|[1-9]\d*)'
106
-
107
+
107
108
  # fractional part of a number
108
109
  frac_part = r'\.\d+'
109
-
110
+
110
111
  # exponential part of a number
111
112
  exp_part = r'[eE](\+|-)?\d+'
112
113
 
@@ -169,6 +170,8 @@ class JSONLexer(RegexLexer):
169
170
 
170
171
  }
171
172
 
173
+ JSONLexer = JsonLexer # for backwards compatibility with Pygments 1.5
174
+
172
175
 
173
176
  class ActionScriptLexer(RegexLexer):
174
177
  """
@@ -719,8 +722,10 @@ class HtmlLexer(RegexLexer):
719
722
  ('<![^>]*>', Comment.Preproc),
720
723
  (r'<\s*script\s*', Name.Tag, ('script-content', 'tag')),
721
724
  (r'<\s*style\s*', Name.Tag, ('style-content', 'tag')),
722
- (r'<\s*[a-zA-Z0-9:]+', Name.Tag, 'tag'),
723
- (r'<\s*/\s*[a-zA-Z0-9:]+\s*>', Name.Tag),
725
+ # note: this allows tag names not used in HTML like <x:with-dash>,
726
+ # this is to support yet-unknown template engines and the like
727
+ (r'<\s*[\w:.-]+', Name.Tag, 'tag'),
728
+ (r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
724
729
  ],
725
730
  'comment': [
726
731
  ('[^-]+', Comment),
@@ -788,7 +793,7 @@ class PhpLexer(RegexLexer):
788
793
 
789
794
  name = 'PHP'
790
795
  aliases = ['php', 'php3', 'php4', 'php5']
791
- filenames = ['*.php', '*.php[345]']
796
+ filenames = ['*.php', '*.php[345]', '*.inc']
792
797
  mimetypes = ['text/x-php']
793
798
 
794
799
  flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
@@ -828,7 +833,7 @@ class PhpLexer(RegexLexer):
828
833
  r'endif|list|__LINE__|endswitch|new|__sleep|endwhile|not|'
829
834
  r'array|__wakeup|E_ALL|NULL|final|php_user_filter|interface|'
830
835
  r'implements|public|private|protected|abstract|clone|try|'
831
- r'catch|throw|this|use|namespace)\b', Keyword),
836
+ r'catch|throw|this|use|namespace|trait)\b', Keyword),
832
837
  (r'(true|false|null)\b', Keyword.Constant),
833
838
  (r'\$\{\$+[a-zA-Z_][a-zA-Z0-9_]*\}', Name.Variable),
834
839
  (r'\$+[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
@@ -966,7 +971,8 @@ class DtdLexer(RegexLexer):
966
971
 
967
972
  'attlist': [
968
973
  include('common'),
969
- (r'CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION', Keyword.Constant),
974
+ (r'CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION',
975
+ Keyword.Constant),
970
976
  (r'#REQUIRED|#IMPLIED|#FIXED', Keyword.Constant),
971
977
  (r'xml:space|xml:lang', Keyword.Reserved),
972
978
  (r'[^>\s\|()?+*,]+', Name.Attribute),
@@ -998,11 +1004,12 @@ class XmlLexer(RegexLexer):
998
1004
  Generic lexer for XML (eXtensible Markup Language).
999
1005
  """
1000
1006
 
1001
- flags = re.MULTILINE | re.DOTALL
1007
+ flags = re.MULTILINE | re.DOTALL | re.UNICODE
1002
1008
 
1003
1009
  name = 'XML'
1004
1010
  aliases = ['xml']
1005
- filenames = ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl']
1011
+ filenames = ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd',
1012
+ '*.wsdl', '*.wsf']
1006
1013
  mimetypes = ['text/xml', 'application/xml', 'image/svg+xml',
1007
1014
  'application/rss+xml', 'application/atom+xml']
1008
1015
 
@@ -1014,8 +1021,8 @@ class XmlLexer(RegexLexer):
1014
1021
  ('<!--', Comment, 'comment'),
1015
1022
  (r'<\?.*?\?>', Comment.Preproc),
1016
1023
  ('<![^>]*>', Comment.Preproc),
1017
- (r'<\s*[a-zA-Z0-9:._-]+', Name.Tag, 'tag'),
1018
- (r'<\s*/\s*[a-zA-Z0-9:._-]+\s*>', Name.Tag),
1024
+ (r'<\s*[\w:.-]+', Name.Tag, 'tag'),
1025
+ (r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
1019
1026
  ],
1020
1027
  'comment': [
1021
1028
  ('[^-]+', Comment),
@@ -1024,7 +1031,7 @@ class XmlLexer(RegexLexer):
1024
1031
  ],
1025
1032
  'tag': [
1026
1033
  (r'\s+', Text),
1027
- (r'[a-zA-Z0-9_.:-]+\s*=', Name.Attribute, 'attr'),
1034
+ (r'[\w.:-]+\s*=', Name.Attribute, 'attr'),
1028
1035
  (r'/?\s*>', Name.Tag, '#pop'),
1029
1036
  ],
1030
1037
  'attr': [
@@ -1049,7 +1056,7 @@ class XsltLexer(XmlLexer):
1049
1056
 
1050
1057
  name = 'XSLT'
1051
1058
  aliases = ['xslt']
1052
- filenames = ['*.xsl', '*.xslt']
1059
+ filenames = ['*.xsl', '*.xslt', '*.xpl'] # xpl is XProc
1053
1060
  mimetypes = ['application/xsl+xml', 'application/xslt+xml']
1054
1061
 
1055
1062
  EXTRA_KEYWORDS = set([
@@ -1081,6 +1088,8 @@ class MxmlLexer(RegexLexer):
1081
1088
  """
1082
1089
  For MXML markup.
1083
1090
  Nested AS3 in <script> tags is highlighted by the appropriate lexer.
1091
+
1092
+ *New in Pygments 1.1.*
1084
1093
  """
1085
1094
  flags = re.MULTILINE | re.DOTALL
1086
1095
  name = 'MXML'
@@ -1119,393 +1128,1008 @@ class MxmlLexer(RegexLexer):
1119
1128
  }
1120
1129
 
1121
1130
 
1122
- class HaxeLexer(RegexLexer):
1131
+ class HaxeLexer(ExtendedRegexLexer):
1123
1132
  """
1124
- For haXe source code (http://haxe.org/).
1133
+ For Haxe source code (http://haxe.org/).
1134
+
1135
+ *New in Pygments 1.3.*
1125
1136
  """
1126
1137
 
1127
- name = 'haXe'
1128
- aliases = ['hx', 'haXe']
1129
- filenames = ['*.hx']
1130
- mimetypes = ['text/haxe']
1138
+ name = 'Haxe'
1139
+ aliases = ['hx', 'Haxe', 'haxe', 'haXe', 'hxsl']
1140
+ filenames = ['*.hx', '*.hxsl']
1141
+ mimetypes = ['text/haxe', 'text/x-haxe', 'text/x-hx']
1142
+
1143
+ # keywords extracted from lexer.mll in the haxe compiler source
1144
+ keyword = (r'(?:function|class|static|var|if|else|while|do|for|'
1145
+ r'break|return|continue|extends|implements|import|'
1146
+ r'switch|case|default|public|private|try|untyped|'
1147
+ r'catch|new|this|throw|extern|enum|in|interface|'
1148
+ r'cast|override|dynamic|typedef|package|'
1149
+ r'inline|using|null|true|false|abstract)\b')
1150
+
1151
+ # idtype in lexer.mll
1152
+ typeid = r'_*[A-Z][_a-zA-Z0-9]*'
1153
+
1154
+ # combined ident and dollar and idtype
1155
+ ident = r'(?:_*[a-z][_a-zA-Z0-9]*|_+[0-9][_a-zA-Z0-9]*|' + typeid + \
1156
+ '|_+|\$[_a-zA-Z0-9]+)'
1131
1157
 
1132
- ident = r'(?:[a-zA-Z_][a-zA-Z0-9_]*)'
1133
- typeid = r'(?:(?:[a-z0-9_\.])*[A-Z_][A-Za-z0-9_]*)'
1134
- key_prop = r'(?:default|null|never)'
1135
- key_decl_mod = r'(?:public|private|override|static|inline|extern|dynamic)'
1158
+ binop = (r'(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>\s*>\s*=|>\s*>\s*>\s*=|==|'
1159
+ r'!=|<=|>\s*=|&&|\|\||<<|>>>|>\s*>|\.\.\.|<|>|%|&|\||\^|\+|\*|'
1160
+ r'/|\-|=>|=)')
1161
+
1162
+ # ident except keywords
1163
+ ident_no_keyword = r'(?!' + keyword + ')' + ident
1136
1164
 
1137
1165
  flags = re.DOTALL | re.MULTILINE
1138
1166
 
1167
+ preproc_stack = []
1168
+
1169
+ def preproc_callback(self, match, ctx):
1170
+ proc = match.group(2)
1171
+
1172
+ if proc == 'if':
1173
+ # store the current stack
1174
+ self.preproc_stack.append(ctx.stack[:])
1175
+ elif proc in ['else', 'elseif']:
1176
+ # restore the stack back to right before #if
1177
+ if self.preproc_stack: ctx.stack = self.preproc_stack[-1][:]
1178
+ elif proc == 'end':
1179
+ # remove the saved stack of previous #if
1180
+ if self.preproc_stack: self.preproc_stack.pop()
1181
+
1182
+ # #if and #elseif should follow by an expr
1183
+ if proc in ['if', 'elseif']:
1184
+ ctx.stack.append('preproc-expr')
1185
+
1186
+ # #error can be optionally follow by the error msg
1187
+ if proc in ['error']:
1188
+ ctx.stack.append('preproc-error')
1189
+
1190
+ yield match.start(), Comment.Preproc, '#' + proc
1191
+ ctx.pos = match.end()
1192
+
1193
+
1139
1194
  tokens = {
1140
1195
  'root': [
1141
- include('whitespace'),
1142
- include('comments'),
1143
- (key_decl_mod, Keyword.Declaration),
1144
- include('enumdef'),
1145
- include('typedef'),
1146
- include('classdef'),
1147
- include('imports'),
1196
+ include('spaces'),
1197
+ include('meta'),
1198
+ (r'(?:package)\b', Keyword.Namespace, ('semicolon', 'package')),
1199
+ (r'(?:import)\b', Keyword.Namespace, ('semicolon', 'import')),
1200
+ (r'(?:using)\b', Keyword.Namespace, ('semicolon', 'using')),
1201
+ (r'(?:extern|private)\b', Keyword.Declaration),
1202
+ (r'(?:abstract)\b', Keyword.Declaration, 'abstract'),
1203
+ (r'(?:class|interface)\b', Keyword.Declaration, 'class'),
1204
+ (r'(?:enum)\b', Keyword.Declaration, 'enum'),
1205
+ (r'(?:typedef)\b', Keyword.Declaration, 'typedef'),
1206
+
1207
+ # top-level expression
1208
+ # although it is not supported in haxe, but it is common to write
1209
+ # expression in web pages the positive lookahead here is to prevent
1210
+ # an infinite loop at the EOF
1211
+ (r'(?=.)', Text, 'expr-statement'),
1212
+ ],
1213
+
1214
+ # space/tab/comment/preproc
1215
+ 'spaces': [
1216
+ (r'\s+', Text),
1217
+ (r'//[^\n\r]*', Comment.Single),
1218
+ (r'/\*.*?\*/', Comment.Multiline),
1219
+ (r'(#)(if|elseif|else|end|error)\b', preproc_callback),
1148
1220
  ],
1149
1221
 
1150
- # General constructs
1151
- 'comments': [
1152
- (r'//.*?\n', Comment.Single),
1153
- (r'/\*.*?\*/', Comment.Multiline),
1154
- (r'#[^\n]*', Comment.Preproc),
1222
+ 'string-single-interpol': [
1223
+ (r'\$\{', String.Interpol, ('string-interpol-close', 'expr')),
1224
+ (r'\$\$', String.Escape),
1225
+ (r'\$(?=' + ident + ')', String.Interpol, 'ident'),
1226
+ include('string-single'),
1155
1227
  ],
1156
- 'whitespace': [
1157
- include('comments'),
1158
- (r'\s+', Text),
1228
+
1229
+ 'string-single': [
1230
+ (r"'", String.Single, '#pop'),
1231
+ (r'\\.', String.Escape),
1232
+ (r'.', String.Single),
1159
1233
  ],
1160
- 'codekeywords': [
1161
- (r'\b(if|else|while|do|for|in|break|continue|'
1162
- r'return|switch|case|try|catch|throw|null|trace|'
1163
- r'new|this|super|untyped|cast|callback|here)\b',
1164
- Keyword.Reserved),
1234
+
1235
+ 'string-double': [
1236
+ (r'"', String.Double, '#pop'),
1237
+ (r'\\.', String.Escape),
1238
+ (r'.', String.Double),
1165
1239
  ],
1166
- 'literals': [
1167
- (r'0[xX][0-9a-fA-F]+', Number.Hex),
1168
- (r'[0-9]+', Number.Integer),
1169
- (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1170
- (r"'(\\\\|\\'|[^'])*'", String.Single),
1171
- (r'"(\\\\|\\"|[^"])*"', String.Double),
1172
- (r'~/([^\n])*?/[gisx]*', String.Regex),
1173
- (r'\b(true|false|null)\b', Keyword.Constant),
1174
- ],
1175
- 'codeblock': [
1176
- include('whitespace'),
1177
- include('new'),
1178
- include('case'),
1179
- include('anonfundef'),
1180
- include('literals'),
1181
- include('vardef'),
1182
- include('codekeywords'),
1183
- (r'[();,\[\]]', Punctuation),
1184
- (r'(?:=|\+=|-=|\*=|/=|%=|&=|\|=|\^=|<<=|>>=|>>>=|\|\||&&|'
1185
- r'\.\.\.|==|!=|>|<|>=|<=|\||&|\^|<<|>>>|>>|\+|\-|\*|/|%|'
1186
- r'!|\+\+|\-\-|~|\.|\?|\:)',
1187
- Operator),
1188
- (ident, Name),
1189
-
1190
- (r'}', Punctuation,'#pop'),
1191
- (r'{', Punctuation,'#push'),
1192
- ],
1193
-
1194
- # Instance/Block level constructs
1195
- 'propertydef': [
1196
- (r'(\()(' + key_prop + ')(,)(' + key_prop + ')(\))',
1197
- bygroups(Punctuation, Keyword.Reserved, Punctuation,
1198
- Keyword.Reserved, Punctuation)),
1240
+
1241
+ 'string-interpol-close': [
1242
+ (r'\$'+ident, String.Interpol),
1243
+ (r'\}', String.Interpol, '#pop'),
1199
1244
  ],
1200
- 'new': [
1201
- (r'\bnew\b', Keyword, 'typedecl'),
1245
+
1246
+ 'package': [
1247
+ include('spaces'),
1248
+ (ident, Name.Namespace),
1249
+ (r'\.', Punctuation, 'import-ident'),
1250
+ (r'', Text, '#pop'),
1202
1251
  ],
1203
- 'case': [
1204
- (r'\b(case)(\s+)(' + ident + ')(\s*)(\()',
1205
- bygroups(Keyword.Reserved, Text, Name, Text, Punctuation),
1206
- 'funargdecl'),
1252
+
1253
+ 'import': [
1254
+ include('spaces'),
1255
+ (ident, Name.Namespace),
1256
+ (r'\*', Keyword), # wildcard import
1257
+ (r'\.', Punctuation, 'import-ident'),
1258
+ (r'in', Keyword.Namespace, 'ident'),
1259
+ (r'', Text, '#pop'),
1207
1260
  ],
1208
- 'vardef': [
1209
- (r'\b(var)(\s+)(' + ident + ')',
1210
- bygroups(Keyword.Declaration, Text, Name.Variable), 'vardecl'),
1261
+
1262
+ 'import-ident': [
1263
+ include('spaces'),
1264
+ (r'\*', Keyword, '#pop'), # wildcard import
1265
+ (ident, Name.Namespace, '#pop'),
1211
1266
  ],
1212
- 'vardecl': [
1213
- include('whitespace'),
1214
- include('typelabel'),
1215
- (r'=', Operator,'#pop'),
1216
- (r';', Punctuation,'#pop'),
1267
+
1268
+ 'using': [
1269
+ include('spaces'),
1270
+ (ident, Name.Namespace),
1271
+ (r'\.', Punctuation, 'import-ident'),
1272
+ (r'', Text, '#pop'),
1217
1273
  ],
1218
- 'instancevardef': [
1219
- (key_decl_mod,Keyword.Declaration),
1220
- (r'\b(var)(\s+)(' + ident + ')',
1221
- bygroups(Keyword.Declaration, Text, Name.Variable.Instance),
1222
- 'instancevardecl'),
1274
+
1275
+ 'preproc-error': [
1276
+ (r'\s+', Comment.Preproc),
1277
+ (r"'", String.Single, ('#pop', 'string-single')),
1278
+ (r'"', String.Double, ('#pop', 'string-double')),
1279
+ (r'', Text, '#pop'),
1223
1280
  ],
1224
- 'instancevardecl': [
1225
- include('vardecl'),
1226
- include('propertydef'),
1281
+
1282
+ 'preproc-expr': [
1283
+ (r'\s+', Comment.Preproc),
1284
+ (r'\!', Comment.Preproc),
1285
+ (r'\(', Comment.Preproc, ('#pop', 'preproc-parenthesis')),
1286
+
1287
+ (ident, Comment.Preproc, '#pop'),
1288
+ (r"'", String.Single, ('#pop', 'string-single')),
1289
+ (r'"', String.Double, ('#pop', 'string-double')),
1227
1290
  ],
1228
1291
 
1229
- 'anonfundef': [
1230
- (r'\bfunction\b', Keyword.Declaration, 'fundecl'),
1292
+ 'preproc-parenthesis': [
1293
+ (r'\s+', Comment.Preproc),
1294
+ (r'\)', Comment.Preproc, '#pop'),
1295
+ ('', Text, 'preproc-expr-in-parenthesis'),
1231
1296
  ],
1232
- 'instancefundef': [
1233
- (key_decl_mod, Keyword.Declaration),
1234
- (r'\b(function)(\s+)(' + ident + ')',
1235
- bygroups(Keyword.Declaration, Text, Name.Function), 'fundecl'),
1297
+
1298
+ 'preproc-expr-chain': [
1299
+ (r'\s+', Comment.Preproc),
1300
+ (binop, Comment.Preproc, ('#pop', 'preproc-expr-in-parenthesis')),
1301
+ (r'', Text, '#pop'),
1236
1302
  ],
1237
- 'fundecl': [
1238
- include('whitespace'),
1239
- include('typelabel'),
1240
- include('generictypedecl'),
1241
- (r'\(',Punctuation,'funargdecl'),
1242
- (r'(?=[a-zA-Z0-9_])',Text,'#pop'),
1243
- (r'{',Punctuation,('#pop','codeblock')),
1244
- (r';',Punctuation,'#pop'),
1245
- ],
1246
- 'funargdecl': [
1247
- include('whitespace'),
1248
- (ident, Name.Variable),
1249
- include('typelabel'),
1250
- include('literals'),
1251
- (r'=', Operator),
1252
- (r',', Punctuation),
1253
- (r'\?', Punctuation),
1254
- (r'\)', Punctuation, '#pop'),
1303
+
1304
+ # same as 'preproc-expr' but able to chain 'preproc-expr-chain'
1305
+ 'preproc-expr-in-parenthesis': [
1306
+ (r'\s+', Comment.Preproc),
1307
+ (r'\!', Comment.Preproc),
1308
+ (r'\(', Comment.Preproc,
1309
+ ('#pop', 'preproc-expr-chain', 'preproc-parenthesis')),
1310
+
1311
+ (ident, Comment.Preproc, ('#pop', 'preproc-expr-chain')),
1312
+ (r"'", String.Single,
1313
+ ('#pop', 'preproc-expr-chain', 'string-single')),
1314
+ (r'"', String.Double,
1315
+ ('#pop', 'preproc-expr-chain', 'string-double')),
1255
1316
  ],
1256
1317
 
1257
- 'typelabel': [
1258
- (r':', Punctuation, 'type'),
1318
+ 'abstract' : [
1319
+ include('spaces'),
1320
+ (r'', Text, ('#pop', 'abstract-body', 'abstract-relation',
1321
+ 'abstract-opaque', 'type-param-constraint', 'type-name')),
1259
1322
  ],
1260
- 'typedecl': [
1261
- include('whitespace'),
1262
- (typeid, Name.Class),
1263
- (r'<', Punctuation, 'generictypedecl'),
1264
- (r'(?=[{}()=,a-z])', Text,'#pop'),
1323
+
1324
+ 'abstract-body' : [
1325
+ include('spaces'),
1326
+ (r'\{', Punctuation, ('#pop', 'class-body')),
1265
1327
  ],
1266
- 'type': [
1267
- include('whitespace'),
1268
- (typeid, Name.Class),
1269
- (r'<', Punctuation, 'generictypedecl'),
1270
- (r'->', Keyword.Type),
1271
- (r'(?=[{}(),;=])', Text, '#pop'),
1328
+
1329
+ 'abstract-opaque' : [
1330
+ include('spaces'),
1331
+ (r'\(', Punctuation, ('#pop', 'parenthesis-close', 'type')),
1332
+ (r'', Text, '#pop'),
1272
1333
  ],
1273
- 'generictypedecl': [
1274
- include('whitespace'),
1275
- (typeid, Name.Class),
1276
- (r'<', Punctuation, '#push'),
1277
- (r'>', Punctuation, '#pop'),
1334
+
1335
+ 'abstract-relation': [
1336
+ include('spaces'),
1337
+ (r'(?:to|from)', Keyword.Declaration, 'type'),
1278
1338
  (r',', Punctuation),
1339
+ (r'', Text, '#pop'),
1340
+ ],
1341
+
1342
+ 'meta': [
1343
+ include('spaces'),
1344
+ (r'@', Name.Decorator, ('meta-body', 'meta-ident', 'meta-colon')),
1345
+ ],
1346
+
1347
+ # optional colon
1348
+ 'meta-colon': [
1349
+ include('spaces'),
1350
+ (r':', Name.Decorator, '#pop'),
1351
+ (r'', Text, '#pop'),
1352
+ ],
1353
+
1354
+ # same as 'ident' but set token as Name.Decorator instead of Name
1355
+ 'meta-ident': [
1356
+ include('spaces'),
1357
+ (ident, Name.Decorator, '#pop'),
1279
1358
  ],
1280
1359
 
1281
- # Top level constructs
1282
- 'imports': [
1283
- (r'(package|import|using)(\s+)([^;]+)(;)',
1284
- bygroups(Keyword.Namespace, Text, Name.Namespace,Punctuation)),
1360
+ 'meta-body': [
1361
+ include('spaces'),
1362
+ (r'\(', Name.Decorator, ('#pop', 'meta-call')),
1363
+ (r'', Text, '#pop'),
1364
+ ],
1365
+
1366
+ 'meta-call': [
1367
+ include('spaces'),
1368
+ (r'\)', Name.Decorator, '#pop'),
1369
+ (r'', Text, ('#pop', 'meta-call-sep', 'expr')),
1370
+ ],
1371
+
1372
+ 'meta-call-sep': [
1373
+ include('spaces'),
1374
+ (r'\)', Name.Decorator, '#pop'),
1375
+ (r',', Punctuation, ('#pop', 'meta-call')),
1285
1376
  ],
1377
+
1286
1378
  'typedef': [
1287
- (r'typedef', Keyword.Declaration, ('typedefprebody', 'typedecl')),
1379
+ include('spaces'),
1380
+ (r'', Text, ('#pop', 'typedef-body', 'type-param-constraint',
1381
+ 'type-name')),
1288
1382
  ],
1289
- 'typedefprebody': [
1290
- include('whitespace'),
1291
- (r'(=)(\s*)({)', bygroups(Punctuation, Text, Punctuation),
1292
- ('#pop', 'typedefbody')),
1383
+
1384
+ 'typedef-body': [
1385
+ include('spaces'),
1386
+ (r'=', Operator, ('#pop', 'optional-semicolon', 'type')),
1293
1387
  ],
1294
- 'enumdef': [
1295
- (r'enum', Keyword.Declaration, ('enumdefprebody', 'typedecl')),
1388
+
1389
+ 'enum': [
1390
+ include('spaces'),
1391
+ (r'', Text, ('#pop', 'enum-body', 'bracket-open',
1392
+ 'type-param-constraint', 'type-name')),
1296
1393
  ],
1297
- 'enumdefprebody': [
1298
- include('whitespace'),
1299
- (r'{', Punctuation, ('#pop','enumdefbody')),
1394
+
1395
+ 'enum-body': [
1396
+ include('spaces'),
1397
+ include('meta'),
1398
+ (r'\}', Punctuation, '#pop'),
1399
+ (ident_no_keyword, Name, ('enum-member', 'type-param-constraint')),
1300
1400
  ],
1301
- 'classdef': [
1302
- (r'class', Keyword.Declaration, ('classdefprebody', 'typedecl')),
1401
+
1402
+ 'enum-member': [
1403
+ include('spaces'),
1404
+ (r'\(', Punctuation,
1405
+ ('#pop', 'semicolon', 'flag', 'function-param')),
1406
+ (r'', Punctuation, ('#pop', 'semicolon', 'flag')),
1303
1407
  ],
1304
- 'classdefprebody': [
1305
- include('whitespace'),
1306
- (r'(extends|implements)', Keyword.Declaration,'typedecl'),
1307
- (r'{', Punctuation, ('#pop', 'classdefbody')),
1408
+
1409
+ 'class': [
1410
+ include('spaces'),
1411
+ (r'', Text, ('#pop', 'class-body', 'bracket-open', 'extends',
1412
+ 'type-param-constraint', 'type-name')),
1308
1413
  ],
1309
- 'interfacedef': [
1310
- (r'interface', Keyword.Declaration,
1311
- ('interfacedefprebody', 'typedecl')),
1414
+
1415
+ 'extends': [
1416
+ include('spaces'),
1417
+ (r'(?:extends|implements)\b', Keyword.Declaration, 'type'),
1418
+ (r',', Punctuation), # the comma is made optional here, since haxe2
1419
+ # requires the comma but haxe3 does not allow it
1420
+ (r'', Text, '#pop'),
1312
1421
  ],
1313
- 'interfacedefprebody': [
1314
- include('whitespace'),
1315
- (r'(extends)', Keyword.Declaration, 'typedecl'),
1316
- (r'{', Punctuation, ('#pop', 'classdefbody')),
1317
- ],
1318
-
1319
- 'typedefbody': [
1320
- include('whitespace'),
1321
- include('instancevardef'),
1322
- include('instancefundef'),
1323
- (r'>', Punctuation, 'typedecl'),
1324
- (r',', Punctuation),
1325
- (r'}', Punctuation, '#pop'),
1326
- ],
1327
- 'enumdefbody': [
1328
- include('whitespace'),
1329
- (ident, Name.Variable.Instance),
1330
- (r'\(', Punctuation, 'funargdecl'),
1331
- (r';', Punctuation),
1332
- (r'}', Punctuation, '#pop'),
1333
- ],
1334
- 'classdefbody': [
1335
- include('whitespace'),
1336
- include('instancevardef'),
1337
- include('instancefundef'),
1338
- (r'}', Punctuation, '#pop'),
1339
- include('codeblock'),
1422
+
1423
+ 'bracket-open': [
1424
+ include('spaces'),
1425
+ (r'\{', Punctuation, '#pop'),
1340
1426
  ],
1341
- }
1342
1427
 
1343
- def analyse_text(text):
1344
- if re.match(r'\w+\s*:\s*\w', text): return 0.3
1428
+ 'bracket-close': [
1429
+ include('spaces'),
1430
+ (r'\}', Punctuation, '#pop'),
1431
+ ],
1345
1432
 
1433
+ 'class-body': [
1434
+ include('spaces'),
1435
+ include('meta'),
1436
+ (r'\}', Punctuation, '#pop'),
1437
+ (r'(?:static|public|private|override|dynamic|inline|macro)\b',
1438
+ Keyword.Declaration),
1439
+ (r'', Text, 'class-member'),
1440
+ ],
1346
1441
 
1347
- def _indentation(lexer, match, ctx):
1348
- indentation = match.group(0)
1349
- yield match.start(), Text, indentation
1350
- ctx.last_indentation = indentation
1351
- ctx.pos = match.end()
1442
+ 'class-member': [
1443
+ include('spaces'),
1444
+ (r'(var)\b', Keyword.Declaration,
1445
+ ('#pop', 'optional-semicolon', 'prop')),
1446
+ (r'(function)\b', Keyword.Declaration,
1447
+ ('#pop', 'optional-semicolon', 'class-method')),
1448
+ ],
1352
1449
 
1353
- if hasattr(ctx, 'block_state') and ctx.block_state and \
1354
- indentation.startswith(ctx.block_indentation) and \
1355
- indentation != ctx.block_indentation:
1356
- ctx.stack.append(ctx.block_state)
1357
- else:
1358
- ctx.block_state = None
1359
- ctx.block_indentation = None
1360
- ctx.stack.append('content')
1450
+ # local function, anonymous or not
1451
+ 'function-local': [
1452
+ include('spaces'),
1453
+ (r'(' + ident_no_keyword + ')?', Name.Function,
1454
+ ('#pop', 'expr', 'flag', 'function-param',
1455
+ 'parenthesis-open', 'type-param-constraint')),
1456
+ ],
1361
1457
 
1362
- def _starts_block(token, state):
1363
- def callback(lexer, match, ctx):
1364
- yield match.start(), token, match.group(0)
1458
+ 'optional-expr': [
1459
+ include('spaces'),
1460
+ include('expr'),
1461
+ (r'', Text, '#pop'),
1462
+ ],
1365
1463
 
1366
- if hasattr(ctx, 'last_indentation'):
1367
- ctx.block_indentation = ctx.last_indentation
1368
- else:
1369
- ctx.block_indentation = ''
1464
+ 'class-method': [
1465
+ include('spaces'),
1466
+ (ident, Name.Function, ('#pop', 'optional-expr', 'flag',
1467
+ 'function-param', 'parenthesis-open',
1468
+ 'type-param-constraint')),
1469
+ ],
1370
1470
 
1371
- ctx.block_state = state
1372
- ctx.pos = match.end()
1471
+ # function arguments
1472
+ 'function-param': [
1473
+ include('spaces'),
1474
+ (r'\)', Punctuation, '#pop'),
1475
+ (r'\?', Punctuation),
1476
+ (ident_no_keyword, Name,
1477
+ ('#pop', 'function-param-sep', 'assign', 'flag')),
1478
+ ],
1373
1479
 
1374
- return callback
1480
+ 'function-param-sep': [
1481
+ include('spaces'),
1482
+ (r'\)', Punctuation, '#pop'),
1483
+ (r',', Punctuation, ('#pop', 'function-param')),
1484
+ ],
1375
1485
 
1486
+ # class property
1487
+ # eg. var prop(default, null):String;
1488
+ 'prop': [
1489
+ include('spaces'),
1490
+ (ident_no_keyword, Name, ('#pop', 'assign', 'flag', 'prop-get-set')),
1491
+ ],
1376
1492
 
1377
- class HamlLexer(ExtendedRegexLexer):
1378
- """
1379
- For Haml markup.
1493
+ 'prop-get-set': [
1494
+ include('spaces'),
1495
+ (r'\(', Punctuation, ('#pop', 'parenthesis-close',
1496
+ 'prop-get-set-opt', 'comma', 'prop-get-set-opt')),
1497
+ (r'', Text, '#pop'),
1498
+ ],
1380
1499
 
1381
- *New in Pygments 1.3.*
1382
- """
1500
+ 'prop-get-set-opt': [
1501
+ include('spaces'),
1502
+ (r'(?:default|null|never|dynamic|get|set)\b', Keyword, '#pop'),
1503
+ (ident_no_keyword, Text, '#pop'), #custom getter/setter
1504
+ ],
1505
+
1506
+ 'expr-statement': [
1507
+ include('spaces'),
1508
+ # makes semicolon optional here, just to avoid checking the last
1509
+ # one is bracket or not.
1510
+ (r'', Text, ('#pop', 'optional-semicolon', 'expr')),
1511
+ ],
1512
+
1513
+ 'expr': [
1514
+ include('spaces'),
1515
+ (r'@', Name.Decorator, ('#pop', 'optional-expr', 'meta-body',
1516
+ 'meta-ident', 'meta-colon')),
1517
+ (r'(?:\+\+|\-\-|~(?!/)|!|\-)', Operator),
1518
+ (r'\(', Punctuation, ('#pop', 'expr-chain', 'parenthesis')),
1519
+ (r'(?:inline)\b', Keyword.Declaration),
1520
+ (r'(?:function)\b', Keyword.Declaration, ('#pop', 'expr-chain',
1521
+ 'function-local')),
1522
+ (r'\{', Punctuation, ('#pop', 'expr-chain', 'bracket')),
1523
+ (r'(?:true|false|null)\b', Keyword.Constant, ('#pop', 'expr-chain')),
1524
+ (r'(?:this)\b', Keyword, ('#pop', 'expr-chain')),
1525
+ (r'(?:cast)\b', Keyword, ('#pop', 'expr-chain', 'cast')),
1526
+ (r'(?:try)\b', Keyword, ('#pop', 'catch', 'expr')),
1527
+ (r'(?:var)\b', Keyword.Declaration, ('#pop', 'var')),
1528
+ (r'(?:new)\b', Keyword, ('#pop', 'expr-chain', 'new')),
1529
+ (r'(?:switch)\b', Keyword, ('#pop', 'switch')),
1530
+ (r'(?:if)\b', Keyword, ('#pop', 'if')),
1531
+ (r'(?:do)\b', Keyword, ('#pop', 'do')),
1532
+ (r'(?:while)\b', Keyword, ('#pop', 'while')),
1533
+ (r'(?:for)\b', Keyword, ('#pop', 'for')),
1534
+ (r'(?:untyped|throw)\b', Keyword),
1535
+ (r'(?:return)\b', Keyword, ('#pop', 'optional-expr')),
1536
+ (r'(?:macro)\b', Keyword, ('#pop', 'macro')),
1537
+ (r'(?:continue|break)\b', Keyword, '#pop'),
1538
+ (r'(?:\$\s*[a-z]\b|\$(?!'+ident+'))', Name, ('#pop', 'dollar')),
1539
+ (ident_no_keyword, Name, ('#pop', 'expr-chain')),
1540
+
1541
+ # Float
1542
+ (r'\.[0-9]+', Number.Float, ('#pop', 'expr-chain')),
1543
+ (r'[0-9]+[eE][\+\-]?[0-9]+', Number.Float, ('#pop', 'expr-chain')),
1544
+ (r'[0-9]+\.[0-9]*[eE][\+\-]?[0-9]+', Number.Float, ('#pop', 'expr-chain')),
1545
+ (r'[0-9]+\.[0-9]+', Number.Float, ('#pop', 'expr-chain')),
1546
+ (r'[0-9]+\.(?!' + ident + '|\.\.)', Number.Float, ('#pop', 'expr-chain')),
1547
+
1548
+ # Int
1549
+ (r'0x[0-9a-fA-F]+', Number.Hex, ('#pop', 'expr-chain')),
1550
+ (r'[0-9]+', Number.Integer, ('#pop', 'expr-chain')),
1551
+
1552
+ # String
1553
+ (r"'", String.Single, ('#pop', 'expr-chain', 'string-single-interpol')),
1554
+ (r'"', String.Double, ('#pop', 'expr-chain', 'string-double')),
1555
+
1556
+ # EReg
1557
+ (r'~/(\\\\|\\/|[^/\n])*/[gimsu]*', String.Regex, ('#pop', 'expr-chain')),
1558
+
1559
+ # Array
1560
+ (r'\[', Punctuation, ('#pop', 'expr-chain', 'array-decl')),
1561
+ ],
1562
+
1563
+ 'expr-chain': [
1564
+ include('spaces'),
1565
+ (r'(?:\+\+|\-\-)', Operator),
1566
+ (binop, Operator, ('#pop', 'expr')),
1567
+ (r'(?:in)\b', Keyword, ('#pop', 'expr')),
1568
+ (r'\?', Operator, ('#pop', 'expr', 'ternary', 'expr')),
1569
+ (r'(\.)(' + ident_no_keyword + ')', bygroups(Punctuation, Name)),
1570
+ (r'\[', Punctuation, 'array-access'),
1571
+ (r'\(', Punctuation, 'call'),
1572
+ (r'', Text, '#pop'),
1573
+ ],
1383
1574
 
1384
- name = 'Haml'
1385
- aliases = ['haml', 'HAML']
1386
- filenames = ['*.haml']
1387
- mimetypes = ['text/x-haml']
1575
+ # macro reification
1576
+ 'macro': [
1577
+ include('spaces'),
1578
+ (r':', Punctuation, ('#pop', 'type')),
1579
+ (r'', Text, ('#pop', 'expr')),
1580
+ ],
1388
1581
 
1389
- flags = re.IGNORECASE
1390
- # Haml can include " |\n" anywhere,
1391
- # which is ignored and used to wrap long lines.
1392
- # To accomodate this, use this custom faux dot instead.
1393
- _dot = r'(?: \|\n(?=.* \|)|.)'
1582
+ # cast can be written as "cast expr" or "cast(expr, type)"
1583
+ 'cast': [
1584
+ include('spaces'),
1585
+ (r'\(', Punctuation, ('#pop', 'parenthesis-close',
1586
+ 'cast-type', 'expr')),
1587
+ (r'', Text, ('#pop', 'expr')),
1588
+ ],
1394
1589
 
1395
- # In certain places, a comma at the end of the line
1396
- # allows line wrapping as well.
1397
- _comma_dot = r'(?:,\s*\n|' + _dot + ')'
1398
- tokens = {
1399
- 'root': [
1400
- (r'[ \t]*\n', Text),
1401
- (r'[ \t]*', _indentation),
1590
+ # optionally give a type as the 2nd argument of cast()
1591
+ 'cast-type': [
1592
+ include('spaces'),
1593
+ (r',', Punctuation, ('#pop', 'type')),
1594
+ (r'', Text, '#pop'),
1402
1595
  ],
1403
1596
 
1404
- 'css': [
1405
- (r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
1406
- (r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
1597
+ 'catch': [
1598
+ include('spaces'),
1599
+ (r'(?:catch)\b', Keyword, ('expr', 'function-param',
1600
+ 'parenthesis-open')),
1601
+ (r'', Text, '#pop'),
1407
1602
  ],
1408
1603
 
1409
- 'eval-or-plain': [
1410
- (r'[&!]?==', Punctuation, 'plain'),
1411
- (r'([&!]?[=~])(' + _comma_dot + r'*\n)',
1412
- bygroups(Punctuation, using(RubyLexer)),
1413
- 'root'),
1414
- (r'', Text, 'plain'),
1604
+ # do-while loop
1605
+ 'do': [
1606
+ include('spaces'),
1607
+ (r'', Punctuation, ('#pop', 'do-while', 'expr')),
1415
1608
  ],
1416
1609
 
1417
- 'content': [
1418
- include('css'),
1419
- (r'%[a-z0-9_:-]+', Name.Tag, 'tag'),
1420
- (r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
1421
- (r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
1422
- bygroups(Comment, Comment.Special, Comment),
1423
- '#pop'),
1424
- (r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
1425
- '#pop'),
1426
- (r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
1427
- 'haml-comment-block'), '#pop'),
1428
- (r'(-)(' + _comma_dot + r'*\n)',
1429
- bygroups(Punctuation, using(RubyLexer)),
1430
- '#pop'),
1431
- (r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
1432
- '#pop'),
1433
- include('eval-or-plain'),
1610
+ # the while after do
1611
+ 'do-while': [
1612
+ include('spaces'),
1613
+ (r'(?:while)\b', Keyword, ('#pop', 'parenthesis',
1614
+ 'parenthesis-open')),
1434
1615
  ],
1435
1616
 
1436
- 'tag': [
1437
- include('css'),
1438
- (r'\{(,\n|' + _dot + ')*?\}', using(RubyLexer)),
1439
- (r'\[' + _dot + '*?\]', using(RubyLexer)),
1440
- (r'\(', Text, 'html-attributes'),
1441
- (r'/[ \t]*\n', Punctuation, '#pop:2'),
1442
- (r'[<>]{1,2}(?=[ \t=])', Punctuation),
1443
- include('eval-or-plain'),
1617
+ 'while': [
1618
+ include('spaces'),
1619
+ (r'\(', Punctuation, ('#pop', 'expr', 'parenthesis')),
1444
1620
  ],
1445
1621
 
1446
- 'plain': [
1447
- (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
1448
- (r'(#\{)(' + _dot + '*?)(\})',
1449
- bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
1450
- (r'\n', Text, 'root'),
1622
+ 'for': [
1623
+ include('spaces'),
1624
+ (r'\(', Punctuation, ('#pop', 'expr', 'parenthesis')),
1451
1625
  ],
1452
1626
 
1453
- 'html-attributes': [
1454
- (r'\s+', Text),
1455
- (r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
1456
- (r'[a-z0-9_:-]+', Name.Attribute),
1457
- (r'\)', Text, '#pop'),
1627
+ 'if': [
1628
+ include('spaces'),
1629
+ (r'\(', Punctuation, ('#pop', 'else', 'optional-semicolon', 'expr',
1630
+ 'parenthesis')),
1458
1631
  ],
1459
1632
 
1460
- 'html-attribute-value': [
1461
- (r'[ \t]+', Text),
1462
- (r'[a-z0-9_]+', Name.Variable, '#pop'),
1463
- (r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
1464
- (r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
1465
- (r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
1466
- (r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
1633
+ 'else': [
1634
+ include('spaces'),
1635
+ (r'(?:else)\b', Keyword, ('#pop', 'expr')),
1636
+ (r'', Text, '#pop'),
1467
1637
  ],
1468
1638
 
1469
- 'html-comment-block': [
1470
- (_dot + '+', Comment),
1471
- (r'\n', Text, 'root'),
1639
+ 'switch': [
1640
+ include('spaces'),
1641
+ (r'', Text, ('#pop', 'switch-body', 'bracket-open', 'expr')),
1472
1642
  ],
1473
1643
 
1474
- 'haml-comment-block': [
1475
- (_dot + '+', Comment.Preproc),
1476
- (r'\n', Text, 'root'),
1644
+ 'switch-body': [
1645
+ include('spaces'),
1646
+ (r'(?:case|default)\b', Keyword, ('case-block', 'case')),
1647
+ (r'\}', Punctuation, '#pop'),
1477
1648
  ],
1478
1649
 
1479
- 'filter-block': [
1480
- (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
1481
- (r'(#\{)(' + _dot + '*?)(\})',
1482
- bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
1483
- (r'\n', Text, 'root'),
1650
+ 'case': [
1651
+ include('spaces'),
1652
+ (r':', Punctuation, '#pop'),
1653
+ (r'', Text, ('#pop', 'case-sep', 'case-guard', 'expr')),
1484
1654
  ],
1485
- }
1486
1655
 
1656
+ 'case-sep': [
1657
+ include('spaces'),
1658
+ (r':', Punctuation, '#pop'),
1659
+ (r',', Punctuation, ('#pop', 'case')),
1660
+ ],
1487
1661
 
1488
- common_sass_tokens = {
1489
- 'value': [
1490
- (r'[ \t]+', Text),
1491
- (r'[!$][\w-]+', Name.Variable),
1492
- (r'url\(', String.Other, 'string-url'),
1493
- (r'[a-z_-][\w-]*(?=\()', Name.Function),
1494
- (r'(azimuth|background-attachment|background-color|'
1495
- r'background-image|background-position|background-repeat|'
1496
- r'background|border-bottom-color|border-bottom-style|'
1497
- r'border-bottom-width|border-left-color|border-left-style|'
1498
- r'border-left-width|border-right|border-right-color|'
1499
- r'border-right-style|border-right-width|border-top-color|'
1500
- r'border-top-style|border-top-width|border-bottom|'
1501
- r'border-collapse|border-left|border-width|border-color|'
1502
- r'border-spacing|border-style|border-top|border|caption-side|'
1503
- r'clear|clip|color|content|counter-increment|counter-reset|'
1504
- r'cue-after|cue-before|cue|cursor|direction|display|'
1505
- r'elevation|empty-cells|float|font-family|font-size|'
1506
- r'font-size-adjust|font-stretch|font-style|font-variant|'
1507
- r'font-weight|font|height|letter-spacing|line-height|'
1508
- r'list-style-type|list-style-image|list-style-position|'
1662
+ 'case-guard': [
1663
+ include('spaces'),
1664
+ (r'(?:if)\b', Keyword, ('#pop', 'parenthesis', 'parenthesis-open')),
1665
+ (r'', Text, '#pop'),
1666
+ ],
1667
+
1668
+ # optional multiple expr under a case
1669
+ 'case-block': [
1670
+ include('spaces'),
1671
+ (r'(?!(?:case|default)\b|\})', Keyword, 'expr-statement'),
1672
+ (r'', Text, '#pop'),
1673
+ ],
1674
+
1675
+ 'new': [
1676
+ include('spaces'),
1677
+ (r'', Text, ('#pop', 'call', 'parenthesis-open', 'type')),
1678
+ ],
1679
+
1680
+ 'array-decl': [
1681
+ include('spaces'),
1682
+ (r'\]', Punctuation, '#pop'),
1683
+ (r'', Text, ('#pop', 'array-decl-sep', 'expr')),
1684
+ ],
1685
+
1686
+ 'array-decl-sep': [
1687
+ include('spaces'),
1688
+ (r'\]', Punctuation, '#pop'),
1689
+ (r',', Punctuation, ('#pop', 'array-decl')),
1690
+ ],
1691
+
1692
+ 'array-access': [
1693
+ include('spaces'),
1694
+ (r'', Text, ('#pop', 'array-access-close', 'expr')),
1695
+ ],
1696
+
1697
+ 'array-access-close': [
1698
+ include('spaces'),
1699
+ (r'\]', Punctuation, '#pop'),
1700
+ ],
1701
+
1702
+ 'comma': [
1703
+ include('spaces'),
1704
+ (r',', Punctuation, '#pop'),
1705
+ ],
1706
+
1707
+ 'colon': [
1708
+ include('spaces'),
1709
+ (r':', Punctuation, '#pop'),
1710
+ ],
1711
+
1712
+ 'semicolon': [
1713
+ include('spaces'),
1714
+ (r';', Punctuation, '#pop'),
1715
+ ],
1716
+
1717
+ 'optional-semicolon': [
1718
+ include('spaces'),
1719
+ (r';', Punctuation, '#pop'),
1720
+ (r'', Text, '#pop'),
1721
+ ],
1722
+
1723
+ # identity that CAN be a Haxe keyword
1724
+ 'ident': [
1725
+ include('spaces'),
1726
+ (ident, Name, '#pop'),
1727
+ ],
1728
+
1729
+ 'dollar': [
1730
+ include('spaces'),
1731
+ (r'\{', Keyword, ('#pop', 'bracket-close', 'expr')),
1732
+ (r'', Text, ('#pop', 'expr-chain')),
1733
+ ],
1734
+
1735
+ 'type-name': [
1736
+ include('spaces'),
1737
+ (typeid, Name, '#pop'),
1738
+ ],
1739
+
1740
+ 'type-full-name': [
1741
+ include('spaces'),
1742
+ (r'\.', Punctuation, 'ident'),
1743
+ (r'', Text, '#pop'),
1744
+ ],
1745
+
1746
+ 'type': [
1747
+ include('spaces'),
1748
+ (r'\?', Punctuation),
1749
+ (ident, Name, ('#pop', 'type-check', 'type-full-name')),
1750
+ (r'\{', Punctuation, ('#pop', 'type-check', 'type-struct')),
1751
+ (r'\(', Punctuation, ('#pop', 'type-check', 'type-parenthesis')),
1752
+ ],
1753
+
1754
+ 'type-parenthesis': [
1755
+ include('spaces'),
1756
+ (r'', Text, ('#pop', 'parenthesis-close', 'type')),
1757
+ ],
1758
+
1759
+ 'type-check': [
1760
+ include('spaces'),
1761
+ (r'->', Punctuation, ('#pop', 'type')),
1762
+ (r'<(?!=)', Punctuation, 'type-param'),
1763
+ (r'', Text, '#pop'),
1764
+ ],
1765
+
1766
+ 'type-struct': [
1767
+ include('spaces'),
1768
+ (r'\}', Punctuation, '#pop'),
1769
+ (r'\?', Punctuation),
1770
+ (r'>', Punctuation, ('comma', 'type')),
1771
+ (ident_no_keyword, Name, ('#pop', 'type-struct-sep', 'type', 'colon')),
1772
+ include('class-body'),
1773
+ ],
1774
+
1775
+ 'type-struct-sep': [
1776
+ include('spaces'),
1777
+ (r'\}', Punctuation, '#pop'),
1778
+ (r',', Punctuation, ('#pop', 'type-struct')),
1779
+ ],
1780
+
1781
+ # type-param can be a normal type or a constant literal...
1782
+ 'type-param-type': [
1783
+ # Float
1784
+ (r'\.[0-9]+', Number.Float, '#pop'),
1785
+ (r'[0-9]+[eE][\+\-]?[0-9]+', Number.Float, '#pop'),
1786
+ (r'[0-9]+\.[0-9]*[eE][\+\-]?[0-9]+', Number.Float, '#pop'),
1787
+ (r'[0-9]+\.[0-9]+', Number.Float, '#pop'),
1788
+ (r'[0-9]+\.(?!' + ident + '|\.\.)', Number.Float, '#pop'),
1789
+
1790
+ # Int
1791
+ (r'0x[0-9a-fA-F]+', Number.Hex, '#pop'),
1792
+ (r'[0-9]+', Number.Integer, '#pop'),
1793
+
1794
+ # String
1795
+ (r"'", String.Single, ('#pop', 'string-single')),
1796
+ (r'"', String.Double, ('#pop', 'string-double')),
1797
+
1798
+ # EReg
1799
+ (r'~/(\\\\|\\/|[^/\n])*/[gim]*', String.Regex, '#pop'),
1800
+
1801
+ # Array
1802
+ (r'\[', Operator, ('#pop', 'array-decl')),
1803
+
1804
+ include('type'),
1805
+ ],
1806
+
1807
+ # type-param part of a type
1808
+ # ie. the <A,B> path in Map<A,B>
1809
+ 'type-param': [
1810
+ include('spaces'),
1811
+ (r'', Text, ('#pop', 'type-param-sep', 'type-param-type')),
1812
+ ],
1813
+
1814
+ 'type-param-sep': [
1815
+ include('spaces'),
1816
+ (r'>', Punctuation, '#pop'),
1817
+ (r',', Punctuation, ('#pop', 'type-param')),
1818
+ ],
1819
+
1820
+ # optional type-param that may include constraint
1821
+ # ie. <T:Constraint, T2:(ConstraintA,ConstraintB)>
1822
+ 'type-param-constraint': [
1823
+ include('spaces'),
1824
+ (r'<(?!=)', Punctuation, ('#pop', 'type-param-constraint-sep',
1825
+ 'type-param-constraint-flag', 'type-name')),
1826
+ (r'', Text, '#pop'),
1827
+ ],
1828
+
1829
+ 'type-param-constraint-sep': [
1830
+ include('spaces'),
1831
+ (r'>', Punctuation, '#pop'),
1832
+ (r',', Punctuation, ('#pop', 'type-param-constraint-sep',
1833
+ 'type-param-constraint-flag', 'type-name')),
1834
+ ],
1835
+
1836
+ # the optional constraint inside type-param
1837
+ 'type-param-constraint-flag': [
1838
+ include('spaces'),
1839
+ (r':', Punctuation, ('#pop', 'type-param-constraint-flag-type')),
1840
+ (r'', Text, '#pop'),
1841
+ ],
1842
+
1843
+ 'type-param-constraint-flag-type': [
1844
+ include('spaces'),
1845
+ (r'\(', Punctuation, ('#pop', 'type-param-constraint-flag-type-sep',
1846
+ 'type')),
1847
+ (r'', Text, ('#pop', 'type')),
1848
+ ],
1849
+
1850
+ 'type-param-constraint-flag-type-sep': [
1851
+ include('spaces'),
1852
+ (r'\)', Punctuation, '#pop'),
1853
+ (r',', Punctuation, 'type'),
1854
+ ],
1855
+
1856
+ # a parenthesis expr that contain exactly one expr
1857
+ 'parenthesis': [
1858
+ include('spaces'),
1859
+ (r'', Text, ('#pop', 'parenthesis-close', 'expr')),
1860
+ ],
1861
+
1862
+ 'parenthesis-open': [
1863
+ include('spaces'),
1864
+ (r'\(', Punctuation, '#pop'),
1865
+ ],
1866
+
1867
+ 'parenthesis-close': [
1868
+ include('spaces'),
1869
+ (r'\)', Punctuation, '#pop'),
1870
+ ],
1871
+
1872
+ 'var': [
1873
+ include('spaces'),
1874
+ (ident_no_keyword, Text, ('#pop', 'var-sep', 'assign', 'flag')),
1875
+ ],
1876
+
1877
+ # optional more var decl.
1878
+ 'var-sep': [
1879
+ include('spaces'),
1880
+ (r',', Punctuation, ('#pop', 'var')),
1881
+ (r'', Text, '#pop'),
1882
+ ],
1883
+
1884
+ # optional assignment
1885
+ 'assign': [
1886
+ include('spaces'),
1887
+ (r'=', Operator, ('#pop', 'expr')),
1888
+ (r'', Text, '#pop'),
1889
+ ],
1890
+
1891
+ # optional type flag
1892
+ 'flag': [
1893
+ include('spaces'),
1894
+ (r':', Punctuation, ('#pop', 'type')),
1895
+ (r'', Text, '#pop'),
1896
+ ],
1897
+
1898
+ # colon as part of a ternary operator (?:)
1899
+ 'ternary': [
1900
+ include('spaces'),
1901
+ (r':', Operator, '#pop'),
1902
+ ],
1903
+
1904
+ # function call
1905
+ 'call': [
1906
+ include('spaces'),
1907
+ (r'\)', Punctuation, '#pop'),
1908
+ (r'', Text, ('#pop', 'call-sep', 'expr')),
1909
+ ],
1910
+
1911
+ # after a call param
1912
+ 'call-sep': [
1913
+ include('spaces'),
1914
+ (r'\)', Punctuation, '#pop'),
1915
+ (r',', Punctuation, ('#pop', 'call')),
1916
+ ],
1917
+
1918
+ # bracket can be block or object
1919
+ 'bracket': [
1920
+ include('spaces'),
1921
+ (r'(?!(?:\$\s*[a-z]\b|\$(?!'+ident+')))' + ident_no_keyword, Name,
1922
+ ('#pop', 'bracket-check')),
1923
+ (r"'", String.Single, ('#pop', 'bracket-check', 'string-single')),
1924
+ (r'"', String.Double, ('#pop', 'bracket-check', 'string-double')),
1925
+ (r'', Text, ('#pop', 'block')),
1926
+ ],
1927
+
1928
+ 'bracket-check': [
1929
+ include('spaces'),
1930
+ (r':', Punctuation, ('#pop', 'object-sep', 'expr')), #is object
1931
+ (r'', Text, ('#pop', 'block', 'optional-semicolon', 'expr-chain')), #is block
1932
+ ],
1933
+
1934
+ # code block
1935
+ 'block': [
1936
+ include('spaces'),
1937
+ (r'\}', Punctuation, '#pop'),
1938
+ (r'', Text, 'expr-statement'),
1939
+ ],
1940
+
1941
+ # object in key-value pairs
1942
+ 'object': [
1943
+ include('spaces'),
1944
+ (r'\}', Punctuation, '#pop'),
1945
+ (r'', Text, ('#pop', 'object-sep', 'expr', 'colon', 'ident-or-string'))
1946
+ ],
1947
+
1948
+ # a key of an object
1949
+ 'ident-or-string': [
1950
+ include('spaces'),
1951
+ (ident_no_keyword, Name, '#pop'),
1952
+ (r"'", String.Single, ('#pop', 'string-single')),
1953
+ (r'"', String.Double, ('#pop', 'string-double')),
1954
+ ],
1955
+
1956
+ # after a key-value pair in object
1957
+ 'object-sep': [
1958
+ include('spaces'),
1959
+ (r'\}', Punctuation, '#pop'),
1960
+ (r',', Punctuation, ('#pop', 'object')),
1961
+ ],
1962
+
1963
+
1964
+
1965
+ }
1966
+
1967
+ def analyse_text(text):
1968
+ if re.match(r'\w+\s*:\s*\w', text): return 0.3
1969
+
1970
+
1971
+ def _indentation(lexer, match, ctx):
1972
+ indentation = match.group(0)
1973
+ yield match.start(), Text, indentation
1974
+ ctx.last_indentation = indentation
1975
+ ctx.pos = match.end()
1976
+
1977
+ if hasattr(ctx, 'block_state') and ctx.block_state and \
1978
+ indentation.startswith(ctx.block_indentation) and \
1979
+ indentation != ctx.block_indentation:
1980
+ ctx.stack.append(ctx.block_state)
1981
+ else:
1982
+ ctx.block_state = None
1983
+ ctx.block_indentation = None
1984
+ ctx.stack.append('content')
1985
+
1986
+ def _starts_block(token, state):
1987
+ def callback(lexer, match, ctx):
1988
+ yield match.start(), token, match.group(0)
1989
+
1990
+ if hasattr(ctx, 'last_indentation'):
1991
+ ctx.block_indentation = ctx.last_indentation
1992
+ else:
1993
+ ctx.block_indentation = ''
1994
+
1995
+ ctx.block_state = state
1996
+ ctx.pos = match.end()
1997
+
1998
+ return callback
1999
+
2000
+
2001
+ class HamlLexer(ExtendedRegexLexer):
2002
+ """
2003
+ For Haml markup.
2004
+
2005
+ *New in Pygments 1.3.*
2006
+ """
2007
+
2008
+ name = 'Haml'
2009
+ aliases = ['haml', 'HAML']
2010
+ filenames = ['*.haml']
2011
+ mimetypes = ['text/x-haml']
2012
+
2013
+ flags = re.IGNORECASE
2014
+ # Haml can include " |\n" anywhere,
2015
+ # which is ignored and used to wrap long lines.
2016
+ # To accomodate this, use this custom faux dot instead.
2017
+ _dot = r'(?: \|\n(?=.* \|)|.)'
2018
+
2019
+ # In certain places, a comma at the end of the line
2020
+ # allows line wrapping as well.
2021
+ _comma_dot = r'(?:,\s*\n|' + _dot + ')'
2022
+ tokens = {
2023
+ 'root': [
2024
+ (r'[ \t]*\n', Text),
2025
+ (r'[ \t]*', _indentation),
2026
+ ],
2027
+
2028
+ 'css': [
2029
+ (r'\.[a-z0-9_:-]+', Name.Class, 'tag'),
2030
+ (r'\#[a-z0-9_:-]+', Name.Function, 'tag'),
2031
+ ],
2032
+
2033
+ 'eval-or-plain': [
2034
+ (r'[&!]?==', Punctuation, 'plain'),
2035
+ (r'([&!]?[=~])(' + _comma_dot + r'*\n)',
2036
+ bygroups(Punctuation, using(RubyLexer)),
2037
+ 'root'),
2038
+ (r'', Text, 'plain'),
2039
+ ],
2040
+
2041
+ 'content': [
2042
+ include('css'),
2043
+ (r'%[a-z0-9_:-]+', Name.Tag, 'tag'),
2044
+ (r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
2045
+ (r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)',
2046
+ bygroups(Comment, Comment.Special, Comment),
2047
+ '#pop'),
2048
+ (r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
2049
+ '#pop'),
2050
+ (r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
2051
+ 'haml-comment-block'), '#pop'),
2052
+ (r'(-)(' + _comma_dot + r'*\n)',
2053
+ bygroups(Punctuation, using(RubyLexer)),
2054
+ '#pop'),
2055
+ (r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
2056
+ '#pop'),
2057
+ include('eval-or-plain'),
2058
+ ],
2059
+
2060
+ 'tag': [
2061
+ include('css'),
2062
+ (r'\{(,\n|' + _dot + ')*?\}', using(RubyLexer)),
2063
+ (r'\[' + _dot + '*?\]', using(RubyLexer)),
2064
+ (r'\(', Text, 'html-attributes'),
2065
+ (r'/[ \t]*\n', Punctuation, '#pop:2'),
2066
+ (r'[<>]{1,2}(?=[ \t=])', Punctuation),
2067
+ include('eval-or-plain'),
2068
+ ],
2069
+
2070
+ 'plain': [
2071
+ (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
2072
+ (r'(#\{)(' + _dot + '*?)(\})',
2073
+ bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
2074
+ (r'\n', Text, 'root'),
2075
+ ],
2076
+
2077
+ 'html-attributes': [
2078
+ (r'\s+', Text),
2079
+ (r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
2080
+ (r'[a-z0-9_:-]+', Name.Attribute),
2081
+ (r'\)', Text, '#pop'),
2082
+ ],
2083
+
2084
+ 'html-attribute-value': [
2085
+ (r'[ \t]+', Text),
2086
+ (r'[a-z0-9_]+', Name.Variable, '#pop'),
2087
+ (r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
2088
+ (r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
2089
+ (r"'(\\\\|\\'|[^'\n])*'", String, '#pop'),
2090
+ (r'"(\\\\|\\"|[^"\n])*"', String, '#pop'),
2091
+ ],
2092
+
2093
+ 'html-comment-block': [
2094
+ (_dot + '+', Comment),
2095
+ (r'\n', Text, 'root'),
2096
+ ],
2097
+
2098
+ 'haml-comment-block': [
2099
+ (_dot + '+', Comment.Preproc),
2100
+ (r'\n', Text, 'root'),
2101
+ ],
2102
+
2103
+ 'filter-block': [
2104
+ (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
2105
+ (r'(#\{)(' + _dot + '*?)(\})',
2106
+ bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
2107
+ (r'\n', Text, 'root'),
2108
+ ],
2109
+ }
2110
+
2111
+
2112
+ common_sass_tokens = {
2113
+ 'value': [
2114
+ (r'[ \t]+', Text),
2115
+ (r'[!$][\w-]+', Name.Variable),
2116
+ (r'url\(', String.Other, 'string-url'),
2117
+ (r'[a-z_-][\w-]*(?=\()', Name.Function),
2118
+ (r'(azimuth|background-attachment|background-color|'
2119
+ r'background-image|background-position|background-repeat|'
2120
+ r'background|border-bottom-color|border-bottom-style|'
2121
+ r'border-bottom-width|border-left-color|border-left-style|'
2122
+ r'border-left-width|border-right|border-right-color|'
2123
+ r'border-right-style|border-right-width|border-top-color|'
2124
+ r'border-top-style|border-top-width|border-bottom|'
2125
+ r'border-collapse|border-left|border-width|border-color|'
2126
+ r'border-spacing|border-style|border-top|border|caption-side|'
2127
+ r'clear|clip|color|content|counter-increment|counter-reset|'
2128
+ r'cue-after|cue-before|cue|cursor|direction|display|'
2129
+ r'elevation|empty-cells|float|font-family|font-size|'
2130
+ r'font-size-adjust|font-stretch|font-style|font-variant|'
2131
+ r'font-weight|font|height|letter-spacing|line-height|'
2132
+ r'list-style-type|list-style-image|list-style-position|'
1509
2133
  r'list-style|margin-bottom|margin-left|margin-right|'
1510
2134
  r'margin-top|margin|marker-offset|marks|max-height|max-width|'
1511
2135
  r'min-height|min-width|opacity|orphans|outline|outline-color|'
@@ -1755,60 +2379,166 @@ class ScssLexer(RegexLexer):
1755
2379
  (r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'),
1756
2380
  (r'@extend', Keyword, 'selector'),
1757
2381
  (r'@[a-z0-9_-]+', Keyword, 'selector'),
1758
- (r'(\$[\w-]\w*)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'),
2382
+ (r'(\$[\w-]*\w)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'),
1759
2383
  (r'(?=[^;{}][;}])', Name.Attribute, 'attr'),
1760
2384
  (r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'),
1761
2385
  (r'', Text, 'selector'),
1762
2386
  ],
1763
-
1764
- 'attr': [
1765
- (r'[^\s:="\[]+', Name.Attribute),
1766
- (r'#{', String.Interpol, 'interpolation'),
1767
- (r'[ \t]*:', Operator, 'value'),
2387
+
2388
+ 'attr': [
2389
+ (r'[^\s:="\[]+', Name.Attribute),
2390
+ (r'#{', String.Interpol, 'interpolation'),
2391
+ (r'[ \t]*:', Operator, 'value'),
2392
+ ],
2393
+
2394
+ 'inline-comment': [
2395
+ (r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline),
2396
+ (r'#\{', String.Interpol, 'interpolation'),
2397
+ (r"\*/", Comment, '#pop'),
2398
+ ],
2399
+ }
2400
+ for group, common in common_sass_tokens.iteritems():
2401
+ tokens[group] = copy.copy(common)
2402
+ tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
2403
+ tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
2404
+
2405
+
2406
+ class CoffeeScriptLexer(RegexLexer):
2407
+ """
2408
+ For `CoffeeScript`_ source code.
2409
+
2410
+ .. _CoffeeScript: http://coffeescript.org
2411
+
2412
+ *New in Pygments 1.3.*
2413
+ """
2414
+
2415
+ name = 'CoffeeScript'
2416
+ aliases = ['coffee-script', 'coffeescript', 'coffee']
2417
+ filenames = ['*.coffee']
2418
+ mimetypes = ['text/coffeescript']
2419
+
2420
+ flags = re.DOTALL
2421
+ tokens = {
2422
+ 'commentsandwhitespace': [
2423
+ (r'\s+', Text),
2424
+ (r'###[^#].*?###', Comment.Multiline),
2425
+ (r'#(?!##[^#]).*?\n', Comment.Single),
2426
+ ],
2427
+ 'multilineregex': [
2428
+ (r'[^/#]+', String.Regex),
2429
+ (r'///([gim]+\b|\B)', String.Regex, '#pop'),
2430
+ (r'#{', String.Interpol, 'interpoling_string'),
2431
+ (r'[/#]', String.Regex),
2432
+ ],
2433
+ 'slashstartsregex': [
2434
+ include('commentsandwhitespace'),
2435
+ (r'///', String.Regex, ('#pop', 'multilineregex')),
2436
+ (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
2437
+ r'([gim]+\b|\B)', String.Regex, '#pop'),
2438
+ (r'', Text, '#pop'),
2439
+ ],
2440
+ 'root': [
2441
+ # this next expr leads to infinite loops root -> slashstartsregex
2442
+ #(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
2443
+ include('commentsandwhitespace'),
2444
+ (r'\+\+|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|'
2445
+ r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|'
2446
+ r'=(?!>)|-(?!>)|[<>+*`%&\|\^/])=?',
2447
+ Operator, 'slashstartsregex'),
2448
+ (r'(?:\([^()]+\))?\s*[=-]>', Name.Function),
2449
+ (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
2450
+ (r'[})\].]', Punctuation),
2451
+ (r'(?<![\.\$])(for|own|in|of|while|until|'
2452
+ r'loop|break|return|continue|'
2453
+ r'switch|when|then|if|unless|else|'
2454
+ r'throw|try|catch|finally|new|delete|typeof|instanceof|super|'
2455
+ r'extends|this|class|by)\b', Keyword, 'slashstartsregex'),
2456
+ (r'(?<![\.\$])(true|false|yes|no|on|off|null|'
2457
+ r'NaN|Infinity|undefined)\b',
2458
+ Keyword.Constant),
2459
+ (r'(Array|Boolean|Date|Error|Function|Math|netscape|'
2460
+ r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
2461
+ r'decodeURIComponent|encodeURI|encodeURIComponent|'
2462
+ r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b',
2463
+ Name.Builtin),
2464
+ (r'[$a-zA-Z_][a-zA-Z0-9_\.:\$]*\s*[:=]\s', Name.Variable,
2465
+ 'slashstartsregex'),
2466
+ (r'@[$a-zA-Z_][a-zA-Z0-9_\.:\$]*\s*[:=]\s', Name.Variable.Instance,
2467
+ 'slashstartsregex'),
2468
+ (r'@', Name.Other, 'slashstartsregex'),
2469
+ (r'@?[$a-zA-Z_][a-zA-Z0-9_\$]*', Name.Other, 'slashstartsregex'),
2470
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
2471
+ (r'0x[0-9a-fA-F]+', Number.Hex),
2472
+ (r'[0-9]+', Number.Integer),
2473
+ ('"""', String, 'tdqs'),
2474
+ ("'''", String, 'tsqs'),
2475
+ ('"', String, 'dqs'),
2476
+ ("'", String, 'sqs'),
2477
+ ],
2478
+ 'strings': [
2479
+ (r'[^#\\\'"]+', String),
2480
+ # note that all coffee script strings are multi-line.
2481
+ # hashmarks, quotes and backslashes must be parsed one at a time
1768
2482
  ],
1769
-
1770
- 'inline-comment': [
1771
- (r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline),
1772
- (r'#\{', String.Interpol, 'interpolation'),
1773
- (r"\*/", Comment, '#pop'),
2483
+ 'interpoling_string' : [
2484
+ (r'}', String.Interpol, "#pop"),
2485
+ include('root')
2486
+ ],
2487
+ 'dqs': [
2488
+ (r'"', String, '#pop'),
2489
+ (r'\\.|\'', String), # double-quoted string don't need ' escapes
2490
+ (r'#{', String.Interpol, "interpoling_string"),
2491
+ include('strings')
2492
+ ],
2493
+ 'sqs': [
2494
+ (r"'", String, '#pop'),
2495
+ (r'#|\\.|"', String), # single quoted strings don't need " escapses
2496
+ include('strings')
2497
+ ],
2498
+ 'tdqs': [
2499
+ (r'"""', String, '#pop'),
2500
+ (r'\\.|\'|"', String), # no need to escape quotes in triple-string
2501
+ (r'#{', String.Interpol, "interpoling_string"),
2502
+ include('strings'),
2503
+ ],
2504
+ 'tsqs': [
2505
+ (r"'''", String, '#pop'),
2506
+ (r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
2507
+ include('strings')
1774
2508
  ],
1775
2509
  }
1776
- for group, common in common_sass_tokens.iteritems():
1777
- tokens[group] = copy.copy(common)
1778
- tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
1779
- tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')])
1780
2510
 
1781
2511
 
1782
- class CoffeeScriptLexer(RegexLexer):
2512
+ class LiveScriptLexer(RegexLexer):
1783
2513
  """
1784
- For `CoffeeScript`_ source code.
2514
+ For `LiveScript`_ source code.
1785
2515
 
1786
- .. _CoffeeScript: http://coffeescript.org
2516
+ .. _LiveScript: http://gkz.github.com/LiveScript/
1787
2517
 
1788
- *New in Pygments 1.3.*
2518
+ New in Pygments 1.6.
1789
2519
  """
1790
2520
 
1791
- name = 'CoffeeScript'
1792
- aliases = ['coffee-script', 'coffeescript']
1793
- filenames = ['*.coffee']
1794
- mimetypes = ['text/coffeescript']
2521
+ name = 'LiveScript'
2522
+ aliases = ['live-script', 'livescript']
2523
+ filenames = ['*.ls']
2524
+ mimetypes = ['text/livescript']
1795
2525
 
1796
2526
  flags = re.DOTALL
1797
2527
  tokens = {
1798
2528
  'commentsandwhitespace': [
1799
2529
  (r'\s+', Text),
1800
- (r'###.*?###', Comment.Multiline),
2530
+ (r'/\*.*?\*/', Comment.Multiline),
1801
2531
  (r'#.*?\n', Comment.Single),
1802
2532
  ],
1803
2533
  'multilineregex': [
1804
2534
  include('commentsandwhitespace'),
1805
- (r'///([gim]+\b|\B)', String.Regex, '#pop'),
2535
+ (r'//([gim]+\b|\B)', String.Regex, '#pop'),
1806
2536
  (r'/', String.Regex),
1807
2537
  (r'[^/#]+', String.Regex)
1808
2538
  ],
1809
2539
  'slashstartsregex': [
1810
2540
  include('commentsandwhitespace'),
1811
- (r'///', String.Regex, ('#pop', 'multilineregex')),
2541
+ (r'//', String.Regex, ('#pop', 'multilineregex')),
1812
2542
  (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
1813
2543
  r'([gim]+\b|\B)', String.Regex, '#pop'),
1814
2544
  (r'', Text, '#pop'),
@@ -1817,35 +2547,42 @@ class CoffeeScriptLexer(RegexLexer):
1817
2547
  # this next expr leads to infinite loops root -> slashstartsregex
1818
2548
  #(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
1819
2549
  include('commentsandwhitespace'),
1820
- (r'\+\+|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|=|'
1821
- r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&\|\^/])=?',
2550
+ (r'(?:\([^()]+\))?[ ]*[~-]{1,2}>|'
2551
+ r'(?:\(?[^()\n]+\)?)?[ ]*<[~-]{1,2}', Name.Function),
2552
+ (r'\+\+|&&|(?<![\.\$])\b(?:and|x?or|is|isnt|not)\b|\?|:|=|'
2553
+ r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|'
2554
+ r'~(?!\~?>)|-(?!\-?>)|<(?!\[)|(?<!\])>|'
2555
+ r'[+*`%&\|\^/])=?',
1822
2556
  Operator, 'slashstartsregex'),
1823
- (r'\([^()]*\)\s*->', Name.Function),
1824
2557
  (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
1825
2558
  (r'[})\].]', Punctuation),
1826
- (r'(for|in|of|while|break|return|continue|switch|when|then|if|else|'
2559
+ (r'(?<![\.\$])(for|own|in|of|while|until|loop|break|'
2560
+ r'return|continue|switch|when|then|if|unless|else|'
1827
2561
  r'throw|try|catch|finally|new|delete|typeof|instanceof|super|'
1828
- r'extends|this|class|by)\b', Keyword, 'slashstartsregex'),
1829
- (r'(true|false|yes|no|on|off|null|NaN|Infinity|undefined)\b',
1830
- Keyword.Constant),
2562
+ r'extends|this|class|by|const|var|to|til)\b', Keyword,
2563
+ 'slashstartsregex'),
2564
+ (r'(?<![\.\$])(true|false|yes|no|on|off|'
2565
+ r'null|NaN|Infinity|undefined|void)\b',
2566
+ Keyword.Constant),
1831
2567
  (r'(Array|Boolean|Date|Error|Function|Math|netscape|'
1832
2568
  r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
1833
2569
  r'decodeURIComponent|encodeURI|encodeURIComponent|'
1834
2570
  r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b',
1835
- Name.Builtin),
1836
- (r'[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable,
2571
+ Name.Builtin),
2572
+ (r'[$a-zA-Z_][a-zA-Z0-9_\.\-:\$]*\s*[:=]\s', Name.Variable,
1837
2573
  'slashstartsregex'),
1838
- (r'@[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable.Instance,
2574
+ (r'@[$a-zA-Z_][a-zA-Z0-9_\.\-:\$]*\s*[:=]\s', Name.Variable.Instance,
1839
2575
  'slashstartsregex'),
1840
2576
  (r'@', Name.Other, 'slashstartsregex'),
1841
- (r'@?[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other, 'slashstartsregex'),
1842
- (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1843
- (r'0x[0-9a-fA-F]+', Number.Hex),
1844
- (r'[0-9]+', Number.Integer),
2577
+ (r'@?[$a-zA-Z_][a-zA-Z0-9_\-]*', Name.Other, 'slashstartsregex'),
2578
+ (r'[0-9]+\.[0-9]+([eE][0-9]+)?[fd]?(?:[a-zA-Z_]+)?', Number.Float),
2579
+ (r'[0-9]+(~[0-9a-z]+)?(?:[a-zA-Z_]+)?', Number.Integer),
1845
2580
  ('"""', String, 'tdqs'),
1846
2581
  ("'''", String, 'tsqs'),
1847
2582
  ('"', String, 'dqs'),
1848
2583
  ("'", String, 'sqs'),
2584
+ (r'\\[\w$-]+', String),
2585
+ (r'<\[.*\]>', String),
1849
2586
  ],
1850
2587
  'strings': [
1851
2588
  (r'[^#\\\'"]+', String),
@@ -1860,6 +2597,7 @@ class CoffeeScriptLexer(RegexLexer):
1860
2597
  (r'"', String, '#pop'),
1861
2598
  (r'\\.|\'', String), # double-quoted string don't need ' escapes
1862
2599
  (r'#{', String.Interpol, "interpoling_string"),
2600
+ (r'#', String),
1863
2601
  include('strings')
1864
2602
  ],
1865
2603
  'sqs': [
@@ -1871,6 +2609,7 @@ class CoffeeScriptLexer(RegexLexer):
1871
2609
  (r'"""', String, '#pop'),
1872
2610
  (r'\\.|\'|"', String), # no need to escape quotes in triple-string
1873
2611
  (r'#{', String.Interpol, "interpoling_string"),
2612
+ (r'#', String),
1874
2613
  include('strings'),
1875
2614
  ],
1876
2615
  'tsqs': [
@@ -1880,6 +2619,7 @@ class CoffeeScriptLexer(RegexLexer):
1880
2619
  ],
1881
2620
  }
1882
2621
 
2622
+
1883
2623
  class DuelLexer(RegexLexer):
1884
2624
  """
1885
2625
  Lexer for Duel Views Engine (formerly JBST) markup with JavaScript code blocks.
@@ -2142,8 +2882,8 @@ class XQueryLexer(ExtendedRegexLexer):
2142
2882
  *New in Pygments 1.4.*
2143
2883
  """
2144
2884
  name = 'XQuery'
2145
- aliases = ['xquery', 'xqy']
2146
- filenames = ['*.xqy', '*.xquery']
2885
+ aliases = ['xquery', 'xqy', 'xq', 'xql', 'xqm']
2886
+ filenames = ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm']
2147
2887
  mimetypes = ['text/xquery', 'application/xquery']
2148
2888
 
2149
2889
  xquery_parse_state = []
@@ -2544,8 +3284,8 @@ class XQueryLexer(ExtendedRegexLexer):
2544
3284
  'xml_comment': [
2545
3285
  (r'(-->)', popstate_xmlcomment_callback),
2546
3286
  (r'[^-]{1,2}', Literal),
2547
- (ur'\t|\r|\n|[\u0020-\U0000D7FF]|[\U0000E000-\U0000FFFD]|'
2548
- ur'[\U00010000-\U0010FFFF]', Literal),
3287
+ (ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
3288
+ unirange(0x10000, 0x10ffff), Literal),
2549
3289
  ],
2550
3290
  'processing_instruction': [
2551
3291
  (r'\s+', Text, 'processing_instruction_content'),
@@ -2554,13 +3294,13 @@ class XQueryLexer(ExtendedRegexLexer):
2554
3294
  ],
2555
3295
  'processing_instruction_content': [
2556
3296
  (r'\?>', String.Doc, '#pop'),
2557
- (ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|'
2558
- ur'[\U00010000-\U0010FFFF]', Literal),
3297
+ (ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
3298
+ unirange(0x10000, 0x10ffff), Literal),
2559
3299
  ],
2560
3300
  'cdata_section': [
2561
3301
  (r']]>', String.Doc, '#pop'),
2562
- (ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|'
2563
- ur'[\U00010000-\U0010FFFF]', Literal),
3302
+ (ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
3303
+ unirange(0x10000, 0x10ffff), Literal),
2564
3304
  ],
2565
3305
  'start_tag': [
2566
3306
  include('whitespace'),
@@ -2628,8 +3368,8 @@ class XQueryLexer(ExtendedRegexLexer):
2628
3368
  ],
2629
3369
  'pragmacontents': [
2630
3370
  (r'#\)', Punctuation, 'operator'),
2631
- (ur'\t|\r|\n|[\u0020-\U0000D7FF]|[\U0000E000-\U0000FFFD]|'
2632
- ur'[\U00010000-\U0010FFFF]', Literal),
3371
+ (ur'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
3372
+ unirange(0x10000, 0x10ffff), Literal),
2633
3373
  (r'(\s+)', Text),
2634
3374
  ],
2635
3375
  'occurrenceindicator': [
@@ -2813,27 +3553,25 @@ class DartLexer(RegexLexer):
2813
3553
 
2814
3554
  tokens = {
2815
3555
  'root': [
3556
+ include('string_literal'),
2816
3557
  (r'#!(.*?)$', Comment.Preproc),
2817
- (r'(#)(import|library|source)', bygroups(Text, Keyword)),
3558
+ (r'\b(import|export)\b', Keyword, 'import_decl'),
3559
+ (r'\b(library|source|part of|part)\b', Keyword),
2818
3560
  (r'[^\S\n]+', Text),
2819
3561
  (r'//.*?\n', Comment.Single),
2820
3562
  (r'/\*.*?\*/', Comment.Multiline),
2821
- (r'(class|interface)(\s+)',
3563
+ (r'\b(class)\b(\s+)',
2822
3564
  bygroups(Keyword.Declaration, Text), 'class'),
2823
- (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
3565
+ (r'\b(assert|break|case|catch|continue|default|do|else|finally|for|'
2824
3566
  r'if|in|is|new|return|super|switch|this|throw|try|while)\b',
2825
3567
  Keyword),
2826
- (r'(abstract|const|extends|factory|final|get|implements|'
3568
+ (r'\b(abstract|const|extends|factory|final|get|implements|'
2827
3569
  r'native|operator|set|static|typedef|var)\b', Keyword.Declaration),
2828
- (r'(bool|double|Dynamic|int|num|Object|String|void)', Keyword.Type),
2829
- (r'(false|null|true)', Keyword.Constant),
2830
- (r'@"(\\\\|\\"|[^"])*"', String.Double), # raw string
2831
- (r"@'(\\\\|\\'|[^'])*'", String.Single), # raw string
2832
- (r'"', String.Double, 'string_double'),
2833
- (r"'", String.Single, 'string_single'),
3570
+ (r'\b(bool|double|Dynamic|int|num|Object|String|void)\b', Keyword.Type),
3571
+ (r'\b(false|null|true)\b', Keyword.Constant),
3572
+ (r'[~!%^&*+=|?:<>/-]|as', Operator),
2834
3573
  (r'[a-zA-Z_$][a-zA-Z0-9_]*:', Name.Label),
2835
3574
  (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
2836
- (r'[~!%^&*+=|?:<>/-]', Operator),
2837
3575
  (r'[(){}\[\],.;]', Punctuation),
2838
3576
  (r'0[xX][0-9a-fA-F]+', Number.Hex),
2839
3577
  # DIGIT+ (‘.’ DIGIT*)? EXPONENT?
@@ -2845,20 +3583,463 @@ class DartLexer(RegexLexer):
2845
3583
  'class': [
2846
3584
  (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name.Class, '#pop')
2847
3585
  ],
2848
- 'string_double': [
2849
- (r'"', String.Double, '#pop'),
2850
- (r'[^"$]+', String.Double),
3586
+ 'import_decl': [
3587
+ include('string_literal'),
3588
+ (r'\s+', Text),
3589
+ (r'\b(as|show|hide)\b', Keyword),
3590
+ (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
3591
+ (r'\,', Punctuation),
3592
+ (r'\;', Punctuation, '#pop')
3593
+ ],
3594
+ 'string_literal': [
3595
+ # Raw strings.
3596
+ (r'r"""([\s|\S]*?)"""', String.Double),
3597
+ (r"r'''([\s|\S]*?)'''", String.Single),
3598
+ (r'r"(.*?)"', String.Double),
3599
+ (r"r'(.*?)'", String.Single),
3600
+ # Normal Strings.
3601
+ (r'"""', String.Double, 'string_double_multiline'),
3602
+ (r"'''", String.Single, 'string_single_multiline'),
3603
+ (r'"', String.Double, 'string_double'),
3604
+ (r"'", String.Single, 'string_single')
3605
+ ],
3606
+ 'string_common': [
3607
+ (r"\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z\'\"$\\])",
3608
+ String.Escape),
2851
3609
  (r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)),
2852
3610
  (r'(\$\{)(.*?)(\})',
2853
- bygroups(String.Interpol, using(this), String.Interpol)),
3611
+ bygroups(String.Interpol, using(this), String.Interpol))
3612
+ ],
3613
+ 'string_double': [
3614
+ (r'"', String.Double, '#pop'),
3615
+ (r'[^\"$\\\n]+', String.Double),
3616
+ include('string_common'),
2854
3617
  (r'\$+', String.Double)
2855
3618
  ],
3619
+ 'string_double_multiline': [
3620
+ (r'"""', String.Double, '#pop'),
3621
+ (r'[^\"$\\]+', String.Double),
3622
+ include('string_common'),
3623
+ (r'(\$|\")+', String.Double)
3624
+ ],
2856
3625
  'string_single': [
2857
3626
  (r"'", String.Single, '#pop'),
2858
- (r"[^'$]+", String.Single),
2859
- (r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)),
2860
- (r'(\$\{)(.*?)(\})',
2861
- bygroups(String.Interpol, using(this), String.Interpol)),
3627
+ (r"[^\'$\\\n]+", String.Single),
3628
+ include('string_common'),
2862
3629
  (r'\$+', String.Single)
3630
+ ],
3631
+ 'string_single_multiline': [
3632
+ (r"'''", String.Single, '#pop'),
3633
+ (r'[^\'$\\]+', String.Single),
3634
+ include('string_common'),
3635
+ (r'(\$|\')+', String.Single)
3636
+ ]
3637
+ }
3638
+
3639
+
3640
+ class TypeScriptLexer(RegexLexer):
3641
+ """
3642
+ For `TypeScript <http://www.python.org>`_ source code.
3643
+
3644
+ *New in Pygments 1.6.*
3645
+ """
3646
+
3647
+ name = 'TypeScript'
3648
+ aliases = ['ts']
3649
+ filenames = ['*.ts']
3650
+ mimetypes = ['text/x-typescript']
3651
+
3652
+ flags = re.DOTALL
3653
+ tokens = {
3654
+ 'commentsandwhitespace': [
3655
+ (r'\s+', Text),
3656
+ (r'<!--', Comment),
3657
+ (r'//.*?\n', Comment.Single),
3658
+ (r'/\*.*?\*/', Comment.Multiline)
3659
+ ],
3660
+ 'slashstartsregex': [
3661
+ include('commentsandwhitespace'),
3662
+ (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
3663
+ r'([gim]+\b|\B)', String.Regex, '#pop'),
3664
+ (r'(?=/)', Text, ('#pop', 'badregex')),
3665
+ (r'', Text, '#pop')
3666
+ ],
3667
+ 'badregex': [
3668
+ (r'\n', Text, '#pop')
3669
+ ],
3670
+ 'root': [
3671
+ (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
3672
+ include('commentsandwhitespace'),
3673
+ (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
3674
+ r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
3675
+ (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
3676
+ (r'[})\].]', Punctuation),
3677
+ (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
3678
+ r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
3679
+ r'this)\b', Keyword, 'slashstartsregex'),
3680
+ (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
3681
+ (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
3682
+ r'extends|final|float|goto|implements|import|int|interface|long|native|'
3683
+ r'package|private|protected|public|short|static|super|synchronized|throws|'
3684
+ r'transient|volatile)\b', Keyword.Reserved),
3685
+ (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
3686
+ (r'(Array|Boolean|Date|Error|Function|Math|netscape|'
3687
+ r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
3688
+ r'decodeURIComponent|encodeURI|encodeURIComponent|'
3689
+ r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
3690
+ r'window)\b', Name.Builtin),
3691
+ # Match stuff like: module name {...}
3692
+ (r'\b(module)(\s*)(\s*[a-zA-Z0-9_?.$][\w?.$]*)(\s*)',
3693
+ bygroups(Keyword.Reserved, Text, Name.Other, Text), 'slashstartsregex'),
3694
+ # Match variable type keywords
3695
+ (r'\b(string|bool|number)\b', Keyword.Type),
3696
+ # Match stuff like: constructor
3697
+ (r'\b(constructor|declare|interface|as|AS)\b', Keyword.Reserved),
3698
+ # Match stuff like: super(argument, list)
3699
+ (r'(super)(\s*)(\([a-zA-Z0-9,_?.$\s]+\s*\))',
3700
+ bygroups(Keyword.Reserved, Text), 'slashstartsregex'),
3701
+ # Match stuff like: function() {...}
3702
+ (r'([a-zA-Z_?.$][\w?.$]*)\(\) \{', Name.Other, 'slashstartsregex'),
3703
+ # Match stuff like: (function: return type)
3704
+ (r'([a-zA-Z0-9_?.$][\w?.$]*)(\s*:\s*)([a-zA-Z0-9_?.$][\w?.$]*)',
3705
+ bygroups(Name.Other, Text, Keyword.Type)),
3706
+ (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
3707
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
3708
+ (r'0x[0-9a-fA-F]+', Number.Hex),
3709
+ (r'[0-9]+', Number.Integer),
3710
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
3711
+ (r"'(\\\\|\\'|[^'])*'", String.Single),
3712
+ ]
3713
+ }
3714
+
3715
+
3716
+ class LassoLexer(RegexLexer):
3717
+ """
3718
+ For `Lasso <http://www.lassosoft.com/>`_ source code, covering both Lasso 9
3719
+ syntax and LassoScript for Lasso 8.6 and earlier. For Lasso embedded in
3720
+ HTML, use the `LassoHtmlLexer`.
3721
+
3722
+ Additional options accepted:
3723
+
3724
+ `builtinshighlighting`
3725
+ If given and ``True``, highlight builtin types, traits, methods, and
3726
+ members (default: ``True``).
3727
+ `requiredelimiters`
3728
+ If given and ``True``, only highlight code between delimiters as Lasso
3729
+ (default: ``False``).
3730
+
3731
+ *New in Pygments 1.6.*
3732
+ """
3733
+
3734
+ name = 'Lasso'
3735
+ aliases = ['lasso', 'lassoscript']
3736
+ filenames = ['*.lasso', '*.lasso[89]']
3737
+ alias_filenames = ['*.incl', '*.inc', '*.las']
3738
+ mimetypes = ['text/x-lasso']
3739
+ flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
3740
+
3741
+ tokens = {
3742
+ 'root': [
3743
+ (r'^#!.+lasso9\b', Comment.Preproc, 'lasso'),
3744
+ (r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'),
3745
+ (r'\[noprocess\]', Comment.Preproc, ('delimiters', 'noprocess')),
3746
+ (r'\[', Comment.Preproc, ('delimiters', 'squarebrackets')),
3747
+ (r'<\?(LassoScript|lasso|=)', Comment.Preproc,
3748
+ ('delimiters', 'anglebrackets')),
3749
+ (r'<', Other, 'delimiters'),
3750
+ (r'\s+', Other),
3751
+ (r'', Other, ('delimiters', 'lassofile')),
3752
+ ],
3753
+ 'delimiters': [
3754
+ (r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'),
3755
+ (r'\[noprocess\]', Comment.Preproc, 'noprocess'),
3756
+ (r'\[', Comment.Preproc, 'squarebrackets'),
3757
+ (r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'),
3758
+ (r'<', Other),
3759
+ (r'[^[<]+', Other),
3760
+ ],
3761
+ 'nosquarebrackets': [
3762
+ (r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'),
3763
+ (r'<', Other),
3764
+ (r'[^<]+', Other),
3765
+ ],
3766
+ 'noprocess': [
3767
+ (r'\[/noprocess\]', Comment.Preproc, '#pop'),
3768
+ (r'\[', Other),
3769
+ (r'[^[]', Other),
3770
+ ],
3771
+ 'squarebrackets': [
3772
+ (r'\]', Comment.Preproc, '#pop'),
3773
+ include('lasso'),
3774
+ ],
3775
+ 'anglebrackets': [
3776
+ (r'\?>', Comment.Preproc, '#pop'),
3777
+ include('lasso'),
3778
+ ],
3779
+ 'lassofile': [
3780
+ (r'\]', Comment.Preproc, '#pop'),
3781
+ (r'\?>', Comment.Preproc, '#pop'),
3782
+ include('lasso'),
3783
+ ],
3784
+ 'whitespacecomments': [
3785
+ (r'\s+', Text),
3786
+ (r'//.*?\n', Comment.Single),
3787
+ (r'/\*\*!.*?\*/', String.Doc),
3788
+ (r'/\*.*?\*/', Comment.Multiline),
3789
+ ],
3790
+ 'lasso': [
3791
+ # whitespace/comments
3792
+ include('whitespacecomments'),
3793
+
3794
+ # literals
3795
+ (r'\d*\.\d+(e[+-]?\d+)?', Number.Float),
3796
+ (r'0x[\da-f]+', Number.Hex),
3797
+ (r'\d+', Number.Integer),
3798
+ (r'([+-]?)(infinity|NaN)\b', bygroups(Operator, Number)),
3799
+ (r"'", String.Single, 'singlestring'),
3800
+ (r'"', String.Double, 'doublestring'),
3801
+ (r'`[^`]*`', String.Backtick),
3802
+
3803
+ # names
3804
+ (r'\$[a-z_][\w.]*', Name.Variable),
3805
+ (r'#([a-z_][\w.]*|\d+)', Name.Variable.Instance),
3806
+ (r"(\.)('[a-z_][\w.]*')",
3807
+ bygroups(Name.Builtin.Pseudo, Name.Variable.Class)),
3808
+ (r"(self)(\s*->\s*)('[a-z_][\w.]*')",
3809
+ bygroups(Name.Builtin.Pseudo, Operator, Name.Variable.Class)),
3810
+ (r'(\.\.?)([a-z_][\w.]*)',
3811
+ bygroups(Name.Builtin.Pseudo, Name.Other.Member)),
3812
+ (r'(->\\?\s*|&\s*)([a-z_][\w.]*)',
3813
+ bygroups(Operator, Name.Other.Member)),
3814
+ (r'(self|inherited|global|void)\b', Name.Builtin.Pseudo),
3815
+ (r'-[a-z_][\w.]*', Name.Attribute),
3816
+ (r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
3817
+ (r'(error_(code|msg)_\w+|Error_AddError|Error_ColumnRestriction|'
3818
+ r'Error_DatabaseConnectionUnavailable|Error_DatabaseTimeout|'
3819
+ r'Error_DeleteError|Error_FieldRestriction|Error_FileNotFound|'
3820
+ r'Error_InvalidDatabase|Error_InvalidPassword|'
3821
+ r'Error_InvalidUsername|Error_ModuleNotFound|'
3822
+ r'Error_NoError|Error_NoPermission|Error_OutOfMemory|'
3823
+ r'Error_ReqColumnMissing|Error_ReqFieldMissing|'
3824
+ r'Error_RequiredColumnMissing|Error_RequiredFieldMissing|'
3825
+ r'Error_UpdateError)\b', Name.Exception),
3826
+
3827
+ # definitions
3828
+ (r'(define)(\s+)([a-z_][\w.]*)(\s*=>\s*)(type|trait|thread)\b',
3829
+ bygroups(Keyword.Declaration, Text, Name.Class, Operator, Keyword)),
3830
+ (r'(define)(\s+)([a-z_][\w.]*)(\s*->\s*)([a-z_][\w.]*=?|[-+*/%<>]|==)',
3831
+ bygroups(Keyword.Declaration, Text, Name.Class, Operator,
3832
+ Name.Function), 'signature'),
3833
+ (r'(define)(\s+)([a-z_][\w.]*)',
3834
+ bygroups(Keyword.Declaration, Text, Name.Function), 'signature'),
3835
+ (r'(public|protected|private|provide)(\s+)(([a-z_][\w.]*=?|'
3836
+ r'[-+*/%<>]|==)(?=\s*\())', bygroups(Keyword, Text, Name.Function),
3837
+ 'signature'),
3838
+ (r'(public|protected|private)(\s+)([a-z_][\w.]*)',
3839
+ bygroups(Keyword, Text, Name.Function)),
3840
+
3841
+ # keywords
3842
+ (r'(true|false|none|minimal|full|all)\b', Keyword.Constant),
3843
+ (r'(local|var|variable|data(?=\s))\b', Keyword.Declaration),
3844
+ (r'(array|date|decimal|duration|integer|map|pair|string|tag|xml|'
3845
+ r'null|list|queue|set|stack|staticarray)\b', Keyword.Type),
3846
+ (r'([a-z_][\w.]*)(\s+)(in)\b', bygroups(Name, Text, Keyword)),
3847
+ (r'(let|into)(\s+)([a-z_][\w.]*)', bygroups(Keyword, Text, Name)),
3848
+ (r'require\b', Keyword, 'requiresection'),
3849
+ (r'(/?)(Namespace_Using)\b', bygroups(Punctuation, Keyword.Namespace)),
3850
+ (r'(/?)(Cache|Database_Names|Database_SchemaNames|'
3851
+ r'Database_TableNames|Define_Tag|Define_Type|Email_Batch|'
3852
+ r'Encode_Set|HTML_Comment|Handle|Handle_Error|Header|If|Inline|'
3853
+ r'Iterate|LJAX_Target|Link|Link_CurrentAction|Link_CurrentGroup|'
3854
+ r'Link_CurrentRecord|Link_Detail|Link_FirstGroup|'
3855
+ r'Link_FirstRecord|Link_LastGroup|Link_LastRecord|Link_NextGroup|'
3856
+ r'Link_NextRecord|Link_PrevGroup|Link_PrevRecord|Log|Loop|'
3857
+ r'NoProcess|Output_None|Portal|Private|Protect|Records|Referer|'
3858
+ r'Referrer|Repeating|ResultSet|Rows|Search_Args|Search_Arguments|'
3859
+ r'Select|Sort_Args|Sort_Arguments|Thread_Atomic|Value_List|While|'
3860
+ r'Abort|Case|Else|If_Empty|If_False|If_Null|If_True|Loop_Abort|'
3861
+ r'Loop_Continue|Loop_Count|Params|Params_Up|Return|Return_Value|'
3862
+ r'Run_Children|SOAP_DefineTag|SOAP_LastRequest|SOAP_LastResponse|'
3863
+ r'Tag_Name|ascending|average|by|define|descending|do|equals|'
3864
+ r'frozen|group|handle_failure|import|in|into|join|let|match|max|'
3865
+ r'min|on|order|parent|protected|provide|public|require|skip|'
3866
+ r'split_thread|sum|take|thread|to|trait|type|where|with|yield)\b',
3867
+ bygroups(Punctuation, Keyword)),
3868
+
3869
+ # other
3870
+ (r',', Punctuation, 'commamember'),
3871
+ (r'(and|or|not)\b', Operator.Word),
3872
+ (r'([a-z_][\w.]*)(\s*::\s*)?([a-z_][\w.]*)?(\s*=(?!=))',
3873
+ bygroups(Name, Punctuation, Name.Label, Operator)),
3874
+ (r'(/?)([\w.]+)', bygroups(Punctuation, Name.Other)),
3875
+ (r'(=)(bw|ew|cn|lte?|gte?|n?eq|ft|n?rx)\b',
3876
+ bygroups(Operator, Operator.Word)),
3877
+ (r':=|[-+*/%=<>&|!?\\]+', Operator),
3878
+ (r'[{}():;,@^]', Punctuation),
3879
+ ],
3880
+ 'singlestring': [
3881
+ (r"'", String.Single, '#pop'),
3882
+ (r"[^'\\]+", String.Single),
3883
+ include('escape'),
3884
+ (r"\\+", String.Single),
3885
+ ],
3886
+ 'doublestring': [
3887
+ (r'"', String.Double, '#pop'),
3888
+ (r'[^"\\]+', String.Double),
3889
+ include('escape'),
3890
+ (r'\\+', String.Double),
3891
+ ],
3892
+ 'escape': [
3893
+ (r'\\(U[\da-f]{8}|u[\da-f]{4}|x[\da-f]{1,2}|[0-7]{1,3}|:[^:]+:|'
3894
+ r'[abefnrtv?\"\'\\]|$)', String.Escape),
3895
+ ],
3896
+ 'signature': [
3897
+ (r'=>', Operator, '#pop'),
3898
+ (r'\)', Punctuation, '#pop'),
3899
+ (r'[(,]', Punctuation, 'parameter'),
3900
+ include('lasso'),
3901
+ ],
3902
+ 'parameter': [
3903
+ (r'\)', Punctuation, '#pop'),
3904
+ (r'-?[a-z_][\w.]*', Name.Attribute, '#pop'),
3905
+ (r'\.\.\.', Name.Builtin.Pseudo),
3906
+ include('lasso'),
3907
+ ],
3908
+ 'requiresection': [
3909
+ (r'(([a-z_][\w.]*=?|[-+*/%<>]|==)(?=\s*\())', Name, 'requiresignature'),
3910
+ (r'(([a-z_][\w.]*=?|[-+*/%<>]|==)(?=(\s*::\s*[\w.]+)?\s*,))', Name),
3911
+ (r'[a-z_][\w.]*=?|[-+*/%<>]|==', Name, '#pop'),
3912
+ (r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
3913
+ (r',', Punctuation),
3914
+ include('whitespacecomments'),
3915
+ ],
3916
+ 'requiresignature': [
3917
+ (r'(\)(?=(\s*::\s*[\w.]+)?\s*,))', Punctuation, '#pop'),
3918
+ (r'\)', Punctuation, '#pop:2'),
3919
+ (r'-?[a-z_][\w.]*', Name.Attribute),
3920
+ (r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
3921
+ (r'\.\.\.', Name.Builtin.Pseudo),
3922
+ (r'[(,]', Punctuation),
3923
+ include('whitespacecomments'),
3924
+ ],
3925
+ 'commamember': [
3926
+ (r'(([a-z_][\w.]*=?|[-+*/%<>]|==)'
3927
+ r'(?=\s*(\(([^()]*\([^()]*\))*[^)]*\)\s*)?(::[\w.\s]+)?=>))',
3928
+ Name.Function, 'signature'),
3929
+ include('whitespacecomments'),
3930
+ (r'', Text, '#pop'),
3931
+ ],
3932
+ }
3933
+
3934
+ def __init__(self, **options):
3935
+ self.builtinshighlighting = get_bool_opt(
3936
+ options, 'builtinshighlighting', True)
3937
+ self.requiredelimiters = get_bool_opt(
3938
+ options, 'requiredelimiters', False)
3939
+
3940
+ self._builtins = set()
3941
+ self._members = set()
3942
+ if self.builtinshighlighting:
3943
+ from pygments.lexers._lassobuiltins import BUILTINS, MEMBERS
3944
+ for key, value in BUILTINS.iteritems():
3945
+ self._builtins.update(value)
3946
+ for key, value in MEMBERS.iteritems():
3947
+ self._members.update(value)
3948
+ RegexLexer.__init__(self, **options)
3949
+
3950
+ def get_tokens_unprocessed(self, text):
3951
+ stack = ['root']
3952
+ if self.requiredelimiters:
3953
+ stack.append('delimiters')
3954
+ for index, token, value in \
3955
+ RegexLexer.get_tokens_unprocessed(self, text, stack):
3956
+ if (token is Name.Other and value.lower() in self._builtins or
3957
+ token is Name.Other.Member and value.lower() in self._members):
3958
+ yield index, Name.Builtin, value
3959
+ continue
3960
+ yield index, token, value
3961
+
3962
+ def analyse_text(text):
3963
+ rv = 0.0
3964
+ if 'bin/lasso9' in text:
3965
+ rv += 0.8
3966
+ if re.search(r'<\?(=|lasso)|\A\[', text, re.I):
3967
+ rv += 0.4
3968
+ if re.search(r'local\(', text, re.I):
3969
+ rv += 0.4
3970
+ if '?>' in text:
3971
+ rv += 0.1
3972
+ return rv
3973
+
3974
+
3975
+ class QmlLexer(RegexLexer):
3976
+ """
3977
+ For QML files. See http://doc.qt.digia.com/4.7/qdeclarativeintroduction.html.
3978
+
3979
+ *New in Pygments 1.6.*
3980
+ """
3981
+
3982
+ # QML is based on javascript, so much of this is taken from the
3983
+ # JavascriptLexer above.
3984
+
3985
+ name = 'QML'
3986
+ aliases = ['qml', 'Qt Meta Language', 'Qt modeling Language']
3987
+ filenames = ['*.qml',]
3988
+ mimetypes = [ 'application/x-qml',]
3989
+
3990
+
3991
+ # pasted from JavascriptLexer, with some additions
3992
+ flags = re.DOTALL
3993
+ tokens = {
3994
+ 'commentsandwhitespace': [
3995
+ (r'\s+', Text),
3996
+ (r'<!--', Comment),
3997
+ (r'//.*?\n', Comment.Single),
3998
+ (r'/\*.*?\*/', Comment.Multiline)
3999
+ ],
4000
+ 'slashstartsregex': [
4001
+ include('commentsandwhitespace'),
4002
+ (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
4003
+ r'([gim]+\b|\B)', String.Regex, '#pop'),
4004
+ (r'(?=/)', Text, ('#pop', 'badregex')),
4005
+ (r'', Text, '#pop')
4006
+ ],
4007
+ 'badregex': [
4008
+ (r'\n', Text, '#pop')
4009
+ ],
4010
+ 'root' : [
4011
+ (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
4012
+ include('commentsandwhitespace'),
4013
+ (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
4014
+ r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
4015
+ (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
4016
+ (r'[})\].]', Punctuation),
4017
+
4018
+ # QML insertions
4019
+ (r'\bid\s*:\s*[A-Za-z][_A-Za-z.0-9]*',Keyword.Declaration,
4020
+ 'slashstartsregex'),
4021
+ (r'\b[A-Za-z][_A-Za-z.0-9]*\s*:',Keyword, 'slashstartsregex'),
4022
+
4023
+ # the rest from JavascriptLexer
4024
+ (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
4025
+ r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
4026
+ r'this)\b', Keyword, 'slashstartsregex'),
4027
+ (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
4028
+ (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
4029
+ r'extends|final|float|goto|implements|import|int|interface|long|native|'
4030
+ r'package|private|protected|public|short|static|super|synchronized|throws|'
4031
+ r'transient|volatile)\b', Keyword.Reserved),
4032
+ (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
4033
+ (r'(Array|Boolean|Date|Error|Function|Math|netscape|'
4034
+ r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
4035
+ r'decodeURIComponent|encodeURI|encodeURIComponent|'
4036
+ r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
4037
+ r'window)\b', Name.Builtin),
4038
+ (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
4039
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
4040
+ (r'0x[0-9a-fA-F]+', Number.Hex),
4041
+ (r'[0-9]+', Number.Integer),
4042
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
4043
+ (r"'(\\\\|\\'|[^'])*'", String.Single),
2863
4044
  ]
2864
4045
  }