pygments.rb 0.3.7 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. data/CHANGELOG +9 -0
  2. data/CHANGELOG.md +6 -0
  3. data/LICENSE +1 -1
  4. data/README.md +1 -1
  5. data/lexers +0 -0
  6. data/lib/pygments/version.rb +1 -1
  7. data/test/test_pygments.rb +0 -1
  8. data/vendor/pygments-main/AUTHORS +14 -1
  9. data/vendor/pygments-main/CHANGES +56 -6
  10. data/vendor/pygments-main/LICENSE +1 -1
  11. data/vendor/pygments-main/Makefile +1 -1
  12. data/vendor/pygments-main/REVISION +1 -0
  13. data/vendor/pygments-main/docs/generate.py +1 -1
  14. data/vendor/pygments-main/docs/src/api.txt +1 -1
  15. data/vendor/pygments-main/docs/src/index.txt +1 -1
  16. data/vendor/pygments-main/docs/src/integrate.txt +5 -0
  17. data/vendor/pygments-main/docs/src/java.txt +70 -0
  18. data/vendor/pygments-main/external/autopygmentize +64 -0
  19. data/vendor/pygments-main/external/markdown-processor.py +2 -2
  20. data/vendor/pygments-main/external/moin-parser.py +1 -1
  21. data/vendor/pygments-main/external/rst-directive-old.py +1 -1
  22. data/vendor/pygments-main/external/rst-directive.py +1 -1
  23. data/vendor/pygments-main/pygments/__init__.py +2 -2
  24. data/vendor/pygments-main/pygments/cmdline.py +14 -6
  25. data/vendor/pygments-main/pygments/console.py +1 -1
  26. data/vendor/pygments-main/pygments/filter.py +1 -1
  27. data/vendor/pygments-main/pygments/filters/__init__.py +1 -1
  28. data/vendor/pygments-main/pygments/formatter.py +1 -1
  29. data/vendor/pygments-main/pygments/formatters/__init__.py +1 -1
  30. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -1
  31. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  32. data/vendor/pygments-main/pygments/formatters/html.py +73 -2
  33. data/vendor/pygments-main/pygments/formatters/img.py +1 -1
  34. data/vendor/pygments-main/pygments/formatters/latex.py +1 -1
  35. data/vendor/pygments-main/pygments/formatters/other.py +1 -1
  36. data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
  37. data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
  38. data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
  39. data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
  40. data/vendor/pygments-main/pygments/lexer.py +76 -12
  41. data/vendor/pygments-main/pygments/lexers/__init__.py +2 -2
  42. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  43. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +1 -1
  44. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +4 -1
  45. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +1 -1
  46. data/vendor/pygments-main/pygments/lexers/_mapping.py +26 -10
  47. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +11 -0
  48. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +2 -2
  49. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +4 -2
  50. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +14 -3
  51. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +11 -0
  52. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +2 -2
  53. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +6 -6
  54. data/vendor/pygments-main/pygments/lexers/agile.py +6 -4
  55. data/vendor/pygments-main/pygments/lexers/asm.py +40 -2
  56. data/vendor/pygments-main/pygments/lexers/compiled.py +751 -438
  57. data/vendor/pygments-main/pygments/lexers/dalvik.py +2 -2
  58. data/vendor/pygments-main/pygments/lexers/dotnet.py +1 -1
  59. data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
  60. data/vendor/pygments-main/pygments/lexers/functional.py +6 -5
  61. data/vendor/pygments-main/pygments/lexers/hdl.py +3 -3
  62. data/vendor/pygments-main/pygments/lexers/jvm.py +130 -16
  63. data/vendor/pygments-main/pygments/lexers/math.py +250 -9
  64. data/vendor/pygments-main/pygments/lexers/other.py +518 -13
  65. data/vendor/pygments-main/pygments/lexers/parsers.py +3 -2
  66. data/vendor/pygments-main/pygments/lexers/shell.py +48 -2
  67. data/vendor/pygments-main/pygments/lexers/special.py +1 -1
  68. data/vendor/pygments-main/pygments/lexers/sql.py +1 -1
  69. data/vendor/pygments-main/pygments/lexers/templates.py +7 -6
  70. data/vendor/pygments-main/pygments/lexers/text.py +9 -9
  71. data/vendor/pygments-main/pygments/lexers/web.py +264 -51
  72. data/vendor/pygments-main/pygments/plugin.py +1 -1
  73. data/vendor/pygments-main/pygments/scanner.py +1 -1
  74. data/vendor/pygments-main/pygments/style.py +1 -1
  75. data/vendor/pygments-main/pygments/styles/__init__.py +1 -1
  76. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  77. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  78. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  79. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  80. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  81. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  82. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  83. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  84. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  85. data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
  86. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  87. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  88. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  89. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  90. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  91. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  92. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  93. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  94. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  95. data/vendor/pygments-main/pygments/token.py +1 -1
  96. data/vendor/pygments-main/pygments/unistring.py +1 -1
  97. data/vendor/pygments-main/pygments/util.py +1 -1
  98. data/vendor/pygments-main/scripts/check_sources.py +2 -2
  99. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +2 -0
  100. data/vendor/pygments-main/scripts/find_codetags.py +1 -1
  101. data/vendor/pygments-main/scripts/find_error.py +5 -6
  102. data/vendor/pygments-main/setup.cfg +1 -0
  103. data/vendor/pygments-main/setup.py +6 -4
  104. data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
  105. data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
  106. data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
  107. data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
  108. data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
  109. data/vendor/pygments-main/tests/examplefiles/classes.dylan +89 -4
  110. data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
  111. data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
  112. data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
  113. data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
  114. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +2 -2
  115. data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
  116. data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
  117. data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
  118. data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
  119. data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
  120. data/vendor/pygments-main/tests/examplefiles/rust_example.rs +191 -701
  121. data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
  122. data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
  123. data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
  124. data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
  125. data/vendor/pygments-main/tests/old_run.py +1 -1
  126. data/vendor/pygments-main/tests/run.py +3 -2
  127. data/vendor/pygments-main/tests/support/tags +36 -0
  128. data/vendor/pygments-main/tests/test_basic_api.py +3 -2
  129. data/vendor/pygments-main/tests/test_clexer.py +1 -1
  130. data/vendor/pygments-main/tests/test_cmdline.py +1 -1
  131. data/vendor/pygments-main/tests/test_examplefiles.py +1 -1
  132. data/vendor/pygments-main/tests/test_html_formatter.py +17 -1
  133. data/vendor/pygments-main/tests/test_latex_formatter.py +1 -1
  134. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  135. data/vendor/pygments-main/tests/test_regexlexer.py +1 -1
  136. data/vendor/pygments-main/tests/test_token.py +1 -1
  137. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  138. data/vendor/pygments-main/tests/test_util.py +5 -4
  139. metadata +26 -2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for compiled languages.
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
 
@@ -13,31 +13,30 @@ import re
13
13
  from string import Template
14
14
 
15
15
  from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
16
- this, combined
16
+ this, combined, inherit, do_insertions
17
17
  from pygments.util import get_bool_opt, get_list_opt
18
18
  from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
19
- Number, Punctuation, Error, Literal
19
+ Number, Punctuation, Error, Literal, Generic
20
20
  from pygments.scanner import Scanner
21
21
 
22
22
  # backwards compatibility
23
23
  from pygments.lexers.functional import OcamlLexer
24
24
  from pygments.lexers.jvm import JavaLexer, ScalaLexer
25
25
 
26
- __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer',
27
- 'DylanLexer', 'ObjectiveCLexer', 'FortranLexer', 'GLShaderLexer',
26
+ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer', 'DylanLexer',
27
+ 'ObjectiveCLexer', 'ObjectiveCppLexer', 'FortranLexer', 'GLShaderLexer',
28
28
  'PrologLexer', 'CythonLexer', 'ValaLexer', 'OocLexer', 'GoLexer',
29
29
  'FelixLexer', 'AdaLexer', 'Modula2Lexer', 'BlitzMaxLexer',
30
- 'NimrodLexer', 'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer']
30
+ 'NimrodLexer', 'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer',
31
+ 'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer',
32
+ 'CobolFreeformatLexer', 'LogosLexer']
31
33
 
32
34
 
33
- class CLexer(RegexLexer):
35
+ class CFamilyLexer(RegexLexer):
34
36
  """
35
- For C source code with preprocessor directives.
37
+ For C family source code. This is used as a base class to avoid repetitious
38
+ definitions.
36
39
  """
37
- name = 'C'
38
- aliases = ['c']
39
- filenames = ['*.c', '*.h', '*.idc']
40
- mimetypes = ['text/x-chdr', 'text/x-csrc']
41
40
 
42
41
  #: optional Comment or Whitespace
43
42
  _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
@@ -76,12 +75,17 @@ class CLexer(RegexLexer):
76
75
  (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
77
76
  (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
78
77
  r'for|goto|if|register|restricted|return|sizeof|static|struct|'
79
- r'switch|typedef|union|volatile|virtual|while)\b', Keyword),
80
- (r'(int|long|float|short|double|char|unsigned|signed|void)\b',
78
+ r'switch|typedef|union|volatile|while)\b', Keyword),
79
+ (r'(bool|int|long|float|short|double|char|unsigned|signed|void|'
80
+ r'[a-z_][a-z0-9_]*_t)\b',
81
81
  Keyword.Type),
82
82
  (r'(_{0,2}inline|naked|restrict|thread|typename)\b', Keyword.Reserved),
83
+ # Vector intrinsics
84
+ (r'(__(m128i|m128d|m128|m64))\b', Keyword.Reserved),
85
+ # Microsoft-isms
83
86
  (r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
84
- r'declspec|finally|int64|try|leave)\b', Keyword.Reserved),
87
+ r'declspec|finally|int64|try|leave|wchar_t|w64|unaligned|'
88
+ r'raise|noop|identifier|forceinline|assume)\b', Keyword.Reserved),
85
89
  (r'(true|false|NULL)\b', Name.Builtin),
86
90
  ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
87
91
  ],
@@ -119,7 +123,8 @@ class CLexer(RegexLexer):
119
123
  ],
120
124
  'string': [
121
125
  (r'"', String, '#pop'),
122
- (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
126
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
127
+ r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
123
128
  (r'[^\\"\n]+', String), # all other characters
124
129
  (r'\\\n', String), # line continuation
125
130
  (r'\\', String), # stray backslash
@@ -141,16 +146,17 @@ class CLexer(RegexLexer):
141
146
  }
142
147
 
143
148
  stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
144
- 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
145
- 'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
146
- 'wctrans_t', 'wint_t', 'wctype_t']
149
+ 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
150
+ 'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
151
+ 'wctrans_t', 'wint_t', 'wctype_t']
147
152
  c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
148
- 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
149
- 'int_least16_t', 'int_least32_t', 'int_least64_t',
150
- 'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
151
- 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
152
- 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
153
- 'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t']
153
+ 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
154
+ 'int_least16_t', 'int_least32_t', 'int_least64_t',
155
+ 'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
156
+ 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
157
+ 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
158
+ 'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t',
159
+ 'uintmax_t']
154
160
 
155
161
  def __init__(self, **options):
156
162
  self.stdlibhighlighting = get_bool_opt(options,
@@ -169,7 +175,22 @@ class CLexer(RegexLexer):
169
175
  token = Keyword.Type
170
176
  yield index, token, value
171
177
 
172
- class CppLexer(RegexLexer):
178
+
179
+ class CLexer(CFamilyLexer):
180
+ """
181
+ For C source code with preprocessor directives.
182
+ """
183
+ name = 'C'
184
+ aliases = ['c']
185
+ filenames = ['*.c', '*.h', '*.idc']
186
+ mimetypes = ['text/x-chdr', 'text/x-csrc']
187
+ priority = 0.1
188
+
189
+ def analyse_text(text):
190
+ return 0.1
191
+
192
+
193
+ class CppLexer(CFamilyLexer):
173
194
  """
174
195
  For C++ source code with preprocessor directives.
175
196
  """
@@ -179,90 +200,38 @@ class CppLexer(RegexLexer):
179
200
  '*.cc', '*.hh', '*.cxx', '*.hxx',
180
201
  '*.C', '*.H', '*.cp', '*.CPP']
181
202
  mimetypes = ['text/x-c++hdr', 'text/x-c++src']
182
-
183
- #: optional Comment or Whitespace
184
- _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
185
- #: only one /* */ style comment
186
- _ws1 = r':\s*/[*].*?[*]/\s*'
203
+ priority = 0.1
187
204
 
188
205
  tokens = {
189
- 'root': [
190
- # preprocessor directives: without whitespace
191
- ('^#if\s+0', Comment.Preproc, 'if0'),
192
- ('^#', Comment.Preproc, 'macro'),
193
- # or with whitespace
194
- ('^(' + _ws1 + r')(#if\s+0)',
195
- bygroups(using(this), Comment.Preproc), 'if0'),
196
- ('^(' + _ws1 + ')(#)',
197
- bygroups(using(this), Comment.Preproc), 'macro'),
198
- (r'\n', Text),
199
- (r'\s+', Text),
200
- (r'\\\n', Text), # line continuation
201
- (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
202
- (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
203
- (r'[{}]', Punctuation),
204
- (r'L?"', String, 'string'),
205
- (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
206
- (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
207
- (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
208
- (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
209
- (r'0[0-7]+[LlUu]*', Number.Oct),
210
- (r'\d+[LlUu]*', Number.Integer),
211
- (r'\*/', Error),
212
- (r'[~!%^&*+=|?:<>/-]', Operator),
213
- (r'[()\[\],.;]', Punctuation),
214
- (r'(asm|auto|break|case|catch|const|const_cast|continue|'
215
- r'default|delete|do|dynamic_cast|else|enum|explicit|export|'
216
- r'extern|for|friend|goto|if|mutable|namespace|new|operator|'
217
- r'private|protected|public|register|reinterpret_cast|return|'
218
- r'restrict|sizeof|static|static_cast|struct|switch|template|'
219
- r'this|throw|throws|try|typedef|typeid|typename|union|using|'
220
- r'volatile|virtual|while)\b', Keyword),
206
+ 'statements': [
207
+ (r'(asm|catch|const_cast|delete|dynamic_cast|explicit|'
208
+ r'export|friend|mutable|namespace|new|operator|'
209
+ r'private|protected|public|reinterpret_cast|'
210
+ r'restrict|static_cast|template|this|throw|throws|'
211
+ r'typeid|typename|using|virtual)\b', Keyword),
221
212
  (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
222
- (r'(bool|int|long|float|short|double|char|unsigned|signed|'
223
- r'void|wchar_t)\b', Keyword.Type),
224
- (r'(_{0,2}inline|naked|thread)\b', Keyword.Reserved),
225
- (r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
226
- r'declspec|finally|int64|try|leave|wchar_t|w64|virtual_inheritance|'
227
- r'uuidof|unaligned|super|single_inheritance|raise|noop|'
228
- r'multiple_inheritance|m128i|m128d|m128|m64|interface|'
229
- r'identifier|forceinline|event|assume)\b', Keyword.Reserved),
213
+ inherit,
214
+ ],
215
+ 'root': [
216
+ inherit,
217
+ # C++ Microsoft-isms
218
+ (r'__(virtual_inheritance|uuidof|super|single_inheritance|'
219
+ r'multiple_inheritance|interface|event)\b', Keyword.Reserved),
230
220
  # Offload C++ extensions, http://offload.codeplay.com/
231
221
  (r'(__offload|__blockingoffload|__outer)\b', Keyword.Pseudo),
232
- (r'(true|false)\b', Keyword.Constant),
233
- (r'NULL\b', Name.Builtin),
234
- ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
235
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
236
222
  ],
237
223
  'classname': [
238
224
  (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
239
225
  # template specification
240
226
  (r'\s*(?=>)', Text, '#pop'),
241
227
  ],
242
- 'string': [
243
- (r'"', String, '#pop'),
244
- (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
245
- (r'[^\\"\n]+', String), # all other characters
246
- (r'\\\n', String), # line continuation
247
- (r'\\', String), # stray backslash
248
- ],
249
- 'macro': [
250
- (r'[^/\n]+', Comment.Preproc),
251
- (r'/[*](.|\n)*?[*]/', Comment.Multiline),
252
- (r'//.*?\n', Comment.Single, '#pop'),
253
- (r'/', Comment.Preproc),
254
- (r'(?<=\\)\n', Comment.Preproc),
255
- (r'\n', Comment.Preproc, '#pop'),
256
- ],
257
- 'if0': [
258
- (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
259
- (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
260
- (r'.*?\n', Comment),
261
- ]
262
228
  }
263
229
 
230
+ def analyse_text(text):
231
+ return 0.1
232
+
264
233
 
265
- class ECLexer(RegexLexer):
234
+ class ECLexer(CLexer):
266
235
  """
267
236
  For eC source code with preprocessor directives.
268
237
 
@@ -273,146 +242,29 @@ class ECLexer(RegexLexer):
273
242
  filenames = ['*.ec', '*.eh']
274
243
  mimetypes = ['text/x-echdr', 'text/x-ecsrc']
275
244
 
276
- #: optional Comment or Whitespace
277
- _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
278
- #: only one /* */ style comment
279
- _ws1 = r':\s*/[*].*?[*]/\s*'
280
-
281
245
  tokens = {
282
- 'whitespace': [
283
- # preprocessor directives: without whitespace
284
- ('^#if\s+0', Comment.Preproc, 'if0'),
285
- ('^#', Comment.Preproc, 'macro'),
286
- # or with whitespace
287
- ('^' + _ws1 + r'#if\s+0', Comment.Preproc, 'if0'),
288
- ('^' + _ws1 + '#', Comment.Preproc, 'macro'),
289
- (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))', bygroups(Text, Name.Label)),
290
- (r'\n', Text),
291
- (r'\s+', Text),
292
- (r'\\\n', Text), # line continuation
293
- (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
294
- (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
295
- ],
296
246
  'statements': [
297
- (r'L?"', String, 'string'),
298
- (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
299
- (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
300
- (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
301
- (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
302
- (r'0[0-7]+[LlUu]*', Number.Oct),
303
- (r'\d+[LlUu]*', Number.Integer),
304
- (r'\*/', Error),
305
- (r'[~!%^&*+=|?:<>/-]', Operator),
306
- (r'[()\[\],.]', Punctuation),
307
- (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
308
- (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
309
- r'for|goto|if|register|restricted|return|sizeof|static|struct|'
310
- r'switch|typedef|union|volatile|virtual|while|class|private|public|'
311
- r'property|import|delete|new|new0|renew|renew0|define|get|set|remote|dllexport|dllimport|stdcall|'
312
- r'subclass|__on_register_module|namespace|using|typed_object|any_object|incref|register|watch|'
313
- r'stopwatching|firewatchers|watchable|class_designer|class_fixed|class_no_expansion|isset|'
314
- r'class_default_property|property_category|class_data|class_property|virtual|thisclass|'
247
+ (r'(virtual|class|private|public|property|import|delete|new|new0|'
248
+ r'renew|renew0|define|get|set|remote|dllexport|dllimport|stdcall|'
249
+ r'subclass|__on_register_module|namespace|using|typed_object|'
250
+ r'any_object|incref|register|watch|stopwatching|firewatchers|'
251
+ r'watchable|class_designer|class_fixed|class_no_expansion|isset|'
252
+ r'class_default_property|property_category|class_data|'
253
+ r'class_property|virtual|thisclass|'
315
254
  r'dbtable|dbindex|database_open|dbfield)\b', Keyword),
316
- (r'(int|long|float|short|double|char|unsigned|signed|void)\b',
317
- Keyword.Type),
318
255
  (r'(uint|uint16|uint32|uint64|bool|byte|unichar|int64)\b',
319
256
  Keyword.Type),
320
257
  (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
321
- (r'(_{0,2}inline|naked|restrict|thread|typename)\b', Keyword.Reserved),
322
- (r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
323
- r'declspec|finally|int64|try|leave)\b', Keyword.Reserved),
324
- (r'(true|false|null|value|this|NULL)\b', Name.Builtin),
325
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
326
- ],
327
- 'root': [
328
- include('whitespace'),
329
- # functions
330
- (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
331
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
332
- r'(\s*\([^;]*?\))' # signature
333
- r'(' + _ws + r')?({)',
334
- bygroups(using(this), Name.Function, using(this), using(this),
335
- Punctuation),
336
- 'function'),
337
- # function declarations
338
- (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
339
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
340
- r'(\s*\([^;]*?\))' # signature
341
- r'(' + _ws + r')?(;)',
342
- bygroups(using(this), Name.Function, using(this), using(this),
343
- Punctuation)),
344
- ('', Text, 'statement'),
258
+ (r'(null|value|this)\b', Name.Builtin),
259
+ inherit,
345
260
  ],
346
261
  'classname': [
347
262
  (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
348
263
  # template specification
349
264
  (r'\s*(?=>)', Text, '#pop'),
350
265
  ],
351
- 'statement' : [
352
- include('whitespace'),
353
- include('statements'),
354
- ('[{}]', Punctuation),
355
- (';', Punctuation, '#pop'),
356
- ],
357
- 'function': [
358
- include('whitespace'),
359
- include('statements'),
360
- (';', Punctuation),
361
- ('{', Punctuation, '#push'),
362
- ('}', Punctuation, '#pop'),
363
- ],
364
- 'string': [
365
- (r'"', String, '#pop'),
366
- (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
367
- (r'[^\\"\n]+', String), # all other characters
368
- (r'\\\n', String), # line continuation
369
- (r'\\', String), # stray backslash
370
- ],
371
- 'macro': [
372
- (r'[^/\n]+', Comment.Preproc),
373
- (r'/[*](.|\n)*?[*]/', Comment.Multiline),
374
- (r'//.*?\n', Comment.Single, '#pop'),
375
- (r'/', Comment.Preproc),
376
- (r'(?<=\\)\n', Comment.Preproc),
377
- (r'\n', Comment.Preproc, '#pop'),
378
- ],
379
- 'if0': [
380
- (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
381
- (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
382
- (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
383
- (r'.*?\n', Comment),
384
- ]
385
266
  }
386
267
 
387
- stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
388
- 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
389
- 'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
390
- 'wctrans_t', 'wint_t', 'wctype_t']
391
- c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
392
- 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
393
- 'int_least16_t', 'int_least32_t', 'int_least64_t',
394
- 'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
395
- 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
396
- 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
397
- 'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t']
398
-
399
- def __init__(self, **options):
400
- self.stdlibhighlighting = get_bool_opt(options,
401
- 'stdlibhighlighting', True)
402
- self.c99highlighting = get_bool_opt(options,
403
- 'c99highlighting', True)
404
- RegexLexer.__init__(self, **options)
405
-
406
- def get_tokens_unprocessed(self, text):
407
- for index, token, value in \
408
- RegexLexer.get_tokens_unprocessed(self, text):
409
- if token is Name:
410
- if self.stdlibhighlighting and value in self.stdlib_types:
411
- token = Keyword.Type
412
- elif self.c99highlighting and value in self.c99_types:
413
- token = Keyword.Type
414
- yield index, token, value
415
-
416
268
 
417
269
  class DLexer(RegexLexer):
418
270
  """
@@ -1057,40 +909,178 @@ class DylanLexer(RegexLexer):
1057
909
 
1058
910
  name = 'Dylan'
1059
911
  aliases = ['dylan']
1060
- filenames = ['*.dylan', '*.dyl']
912
+ filenames = ['*.dylan', '*.dyl', '*.intr']
1061
913
  mimetypes = ['text/x-dylan']
1062
914
 
1063
- flags = re.DOTALL
915
+ flags = re.IGNORECASE
916
+
917
+ builtins = set([
918
+ 'subclass', 'abstract', 'block', 'concrete', 'constant', 'class',
919
+ 'compiler-open', 'compiler-sideways', 'domain', 'dynamic',
920
+ 'each-subclass', 'exception', 'exclude', 'function', 'generic',
921
+ 'handler', 'inherited', 'inline', 'inline-only', 'instance',
922
+ 'interface', 'import', 'keyword', 'library', 'macro', 'method',
923
+ 'module', 'open', 'primary', 'required', 'sealed', 'sideways',
924
+ 'singleton', 'slot', 'thread', 'variable', 'virtual'])
925
+
926
+ keywords = set([
927
+ 'above', 'afterwards', 'begin', 'below', 'by', 'case', 'cleanup',
928
+ 'create', 'define', 'else', 'elseif', 'end', 'export', 'finally',
929
+ 'for', 'from', 'if', 'in', 'let', 'local', 'otherwise', 'rename',
930
+ 'select', 'signal', 'then', 'to', 'unless', 'until', 'use', 'when',
931
+ 'while'])
932
+
933
+ operators = set([
934
+ '~', '+', '-', '*', '|', '^', '=', '==', '~=', '~==', '<', '<=',
935
+ '>', '>=', '&', '|'])
936
+
937
+ functions = set([
938
+ 'abort', 'abs', 'add', 'add!', 'add-method', 'add-new', 'add-new!',
939
+ 'all-superclasses', 'always', 'any?', 'applicable-method?', 'apply',
940
+ 'aref', 'aref-setter', 'as', 'as-lowercase', 'as-lowercase!',
941
+ 'as-uppercase', 'as-uppercase!', 'ash', 'backward-iteration-protocol',
942
+ 'break', 'ceiling', 'ceiling/', 'cerror', 'check-type', 'choose',
943
+ 'choose-by', 'complement', 'compose', 'concatenate', 'concatenate-as',
944
+ 'condition-format-arguments', 'condition-format-string', 'conjoin',
945
+ 'copy-sequence', 'curry', 'default-handler', 'dimension', 'dimensions',
946
+ 'direct-subclasses', 'direct-superclasses', 'disjoin', 'do',
947
+ 'do-handlers', 'element', 'element-setter', 'empty?', 'error', 'even?',
948
+ 'every?', 'false-or', 'fill!', 'find-key', 'find-method', 'first',
949
+ 'first-setter', 'floor', 'floor/', 'forward-iteration-protocol',
950
+ 'function-arguments', 'function-return-values',
951
+ 'function-specializers', 'gcd', 'generic-function-mandatory-keywords',
952
+ 'generic-function-methods', 'head', 'head-setter', 'identity',
953
+ 'initialize', 'instance?', 'integral?', 'intersection',
954
+ 'key-sequence', 'key-test', 'last', 'last-setter', 'lcm', 'limited',
955
+ 'list', 'logand', 'logbit?', 'logior', 'lognot', 'logxor', 'make',
956
+ 'map', 'map-as', 'map-into', 'max', 'member?', 'merge-hash-codes',
957
+ 'min', 'modulo', 'negative', 'negative?', 'next-method',
958
+ 'object-class', 'object-hash', 'odd?', 'one-of', 'pair', 'pop',
959
+ 'pop-last', 'positive?', 'push', 'push-last', 'range', 'rank',
960
+ 'rcurry', 'reduce', 'reduce1', 'remainder', 'remove', 'remove!',
961
+ 'remove-duplicates', 'remove-duplicates!', 'remove-key!',
962
+ 'remove-method', 'replace-elements!', 'replace-subsequence!',
963
+ 'restart-query', 'return-allowed?', 'return-description',
964
+ 'return-query', 'reverse', 'reverse!', 'round', 'round/',
965
+ 'row-major-index', 'second', 'second-setter', 'shallow-copy',
966
+ 'signal', 'singleton', 'size', 'size-setter', 'slot-initialized?',
967
+ 'sort', 'sort!', 'sorted-applicable-methods', 'subsequence-position',
968
+ 'subtype?', 'table-protocol', 'tail', 'tail-setter', 'third',
969
+ 'third-setter', 'truncate', 'truncate/', 'type-error-expected-type',
970
+ 'type-error-value', 'type-for-copy', 'type-union', 'union', 'values',
971
+ 'vector', 'zero?'])
972
+
973
+ valid_name = '\\\\?[a-zA-Z0-9' + re.escape('!&*<>|^$%@_-+~?/=') + ']+'
974
+
975
+ def get_tokens_unprocessed(self, text):
976
+ for index, token, value in RegexLexer.get_tokens_unprocessed(self, text):
977
+ if token is Name:
978
+ lowercase_value = value.lower()
979
+ if lowercase_value in self.builtins:
980
+ yield index, Name.Builtin, value
981
+ continue
982
+ if lowercase_value in self.keywords:
983
+ yield index, Keyword, value
984
+ continue
985
+ if lowercase_value in self.functions:
986
+ yield index, Name.Builtin, value
987
+ continue
988
+ if lowercase_value in self.operators:
989
+ yield index, Operator, value
990
+ continue
991
+ yield index, token, value
1064
992
 
1065
993
  tokens = {
1066
994
  'root': [
1067
- (r'\b(subclass|abstract|block|c(on(crete|stant)|lass)|domain'
1068
- r'|ex(c(eption|lude)|port)|f(unction(al)?)|generic|handler'
1069
- r'|i(n(herited|line|stance|terface)|mport)|library|m(acro|ethod)'
1070
- r'|open|primary|sealed|si(deways|ngleton)|slot'
1071
- r'|v(ariable|irtual))\b', Name.Builtin),
1072
- (r'<\w+>', Keyword.Type),
995
+ # Whitespace
996
+ (r'\s+', Text),
997
+
998
+ # single line comment
1073
999
  (r'//.*?\n', Comment.Single),
1074
- (r'/\*[\w\W]*?\*/', Comment.Multiline),
1000
+
1001
+ # lid header
1002
+ (r'([A-Za-z0-9-]+)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
1003
+ bygroups(Name.Attribute, Operator, Text, String)),
1004
+
1005
+ ('', Text, 'code') # no header match, switch to code
1006
+ ],
1007
+ 'code': [
1008
+ # Whitespace
1009
+ (r'\s+', Text),
1010
+
1011
+ # single line comment
1012
+ (r'//.*?\n', Comment.Single),
1013
+
1014
+ # multi-line comment
1015
+ (r'/\*', Comment.Multiline, 'comment'),
1016
+
1017
+ # strings and characters
1075
1018
  (r'"', String, 'string'),
1076
1019
  (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
1077
- (r'=>|\b(a(bove|fterwards)|b(e(gin|low)|y)|c(ase|leanup|reate)'
1078
- r'|define|else(if)?|end|f(inally|or|rom)|i[fn]|l(et|ocal)|otherwise'
1079
- r'|rename|s(elect|ignal)|t(hen|o)|u(n(less|til)|se)|wh(en|ile))\b',
1080
- Keyword),
1081
- (r'([ \t])([!\$%&\*\/:<=>\?~_^a-zA-Z0-9.+\-]*:)',
1082
- bygroups(Text, Name.Variable)),
1083
- (r'([ \t]*)(\S+[^:])([ \t]*)(\()([ \t]*)',
1084
- bygroups(Text, Name.Function, Text, Punctuation, Text)),
1085
- (r'-?[0-9.]+', Number),
1086
- (r'[(),;]', Punctuation),
1087
- (r'\$[a-zA-Z0-9-]+', Name.Constant),
1088
- (r'[!$%&*/:<>=?~^.+\[\]{}-]+', Operator),
1089
- (r'\s+', Text),
1090
- (r'#"[a-zA-Z0-9-]+"', Keyword),
1020
+
1021
+ # binary integer
1022
+ (r'#[bB][01]+', Number),
1023
+
1024
+ # octal integer
1025
+ (r'#[oO][0-7]+', Number.Oct),
1026
+
1027
+ # floating point
1028
+ (r'[-+]?(\d*\.\d+(e[-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)', Number.Float),
1029
+
1030
+ # decimal integer
1031
+ (r'[-+]?\d+', Number.Integer),
1032
+
1033
+ # hex integer
1034
+ (r'#[xX][0-9a-fA-F]+', Number.Hex),
1035
+
1036
+ # Macro parameters
1037
+ (r'(\?' + valid_name + ')(:)'
1038
+ r'(token|name|variable|expression|body|case-body|\*)',
1039
+ bygroups(Name.Tag, Operator, Name.Builtin)),
1040
+ (r'(\?)(:)(token|name|variable|expression|body|case-body|\*)',
1041
+ bygroups(Name.Tag, Operator, Name.Builtin)),
1042
+ (r'\?' + valid_name, Name.Tag),
1043
+
1044
+ # Punctuation
1045
+ (r'(=>|::|#\(|#\[|##|\?|\?\?|\?=|[(){}\[\],\.;])', Punctuation),
1046
+
1047
+ # Most operators are picked up as names and then re-flagged.
1048
+ # This one isn't valid in a name though, so we pick it up now.
1049
+ (r':=', Operator),
1050
+
1051
+ # Pick up #t / #f before we match other stuff with #.
1052
+ (r'#[tf]', Literal),
1053
+
1054
+ # #"foo" style keywords
1055
+ (r'#"', String.Symbol, 'keyword'),
1056
+
1057
+ # #rest, #key, #all-keys, etc.
1091
1058
  (r'#[a-zA-Z0-9-]+', Keyword),
1092
- (r'#(\(|\[)', Punctuation),
1093
- (r'[a-zA-Z0-9-_]+', Name.Variable),
1059
+
1060
+ # required-init-keyword: style keywords.
1061
+ (valid_name + ':', Keyword),
1062
+
1063
+ # class names
1064
+ (r'<' + valid_name + '>', Name.Class),
1065
+
1066
+ # define variable forms.
1067
+ (r'\*' + valid_name + '\*', Name.Variable.Global),
1068
+
1069
+ # define constant forms.
1070
+ (r'\$' + valid_name, Name.Constant),
1071
+
1072
+ # everything else. We re-flag some of these in the method above.
1073
+ (valid_name, Name),
1074
+ ],
1075
+ 'comment': [
1076
+ (r'[^*/]', Comment.Multiline),
1077
+ (r'/\*', Comment.Multiline, '#push'),
1078
+ (r'\*/', Comment.Multiline, '#pop'),
1079
+ (r'[*/]', Comment.Multiline)
1080
+ ],
1081
+ 'keyword': [
1082
+ (r'"', String.Symbol, '#pop'),
1083
+ (r'[^\\"]+', String.Symbol), # all other characters
1094
1084
  ],
1095
1085
  'string': [
1096
1086
  (r'"', String, '#pop'),
@@ -1098,177 +1088,211 @@ class DylanLexer(RegexLexer):
1098
1088
  (r'[^\\"\n]+', String), # all other characters
1099
1089
  (r'\\\n', String), # line continuation
1100
1090
  (r'\\', String), # stray backslash
1101
- ],
1091
+ ]
1102
1092
  }
1103
1093
 
1104
1094
 
1105
- class ObjectiveCLexer(RegexLexer):
1095
+ class DylanLidLexer(RegexLexer):
1106
1096
  """
1107
- For Objective-C source code with preprocessor directives.
1097
+ For Dylan LID (Library Interchange Definition) files.
1098
+
1099
+ *New in Pygments 1.6.*
1108
1100
  """
1109
1101
 
1110
- name = 'Objective-C'
1111
- aliases = ['objective-c', 'objectivec', 'obj-c', 'objc']
1112
- # XXX: objc has .h files too :-/
1113
- filenames = ['*.m']
1114
- mimetypes = ['text/x-objective-c']
1102
+ name = 'DylanLID'
1103
+ aliases = ['dylan-lid', 'lid']
1104
+ filenames = ['*.lid', '*.hdp']
1105
+ mimetypes = ['text/x-dylan-lid']
1115
1106
 
1116
- #: optional Comment or Whitespace
1117
- _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
1118
- #: only one /* */ style comment
1119
- _ws1 = r':\s*/[*].*?[*]/\s*'
1107
+ flags = re.IGNORECASE
1120
1108
 
1121
1109
  tokens = {
1122
- 'whitespace': [
1123
- # preprocessor directives: without whitespace
1124
- ('^#if\s+0', Comment.Preproc, 'if0'),
1125
- ('^#', Comment.Preproc, 'macro'),
1126
- # or with whitespace
1127
- ('^(' + _ws1 + r')(#if\s+0)',
1128
- bygroups(using(this), Comment.Preproc), 'if0'),
1129
- ('^(' + _ws1 + ')(#)',
1130
- bygroups(using(this), Comment.Preproc), 'macro'),
1131
- (r'\n', Text),
1132
- (r'\s+', Text),
1133
- (r'\\\n', Text), # line continuation
1134
- (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
1135
- (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
1136
- ],
1137
- 'statements': [
1138
- (r'(L|@)?"', String, 'string'),
1139
- (r"(L|@)?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
1140
- String.Char),
1141
- (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
1142
- (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
1143
- (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
1144
- (r'0[0-7]+[Ll]?', Number.Oct),
1145
- (r'\d+[Ll]?', Number.Integer),
1146
- (r'[~!%^&*+=|?:<>/-]', Operator),
1147
- (r'[()\[\],.]', Punctuation),
1148
- (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
1149
- r'for|goto|if|register|restricted|return|sizeof|static|struct|'
1150
- r'switch|typedef|union|volatile|virtual|while|in|@selector|'
1151
- r'@private|@protected|@public|@encode|'
1152
- r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
1153
- r'@synthesize|@dynamic|@optional)\b', Keyword),
1154
- (r'(int|long|float|short|double|char|unsigned|signed|void|'
1155
- r'id|BOOL|IBOutlet|IBAction|SEL)\b', Keyword.Type),
1156
- (r'(_{0,2}inline|naked|restrict|thread|typename)\b',
1157
- Keyword.Reserved),
1158
- (r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
1159
- r'declspec|finally|int64|try|leave)\b', Keyword.Reserved),
1160
- (r'(TRUE|FALSE|nil|NULL)\b', Name.Builtin),
1161
- ('[a-zA-Z$_][a-zA-Z0-9$_]*:(?!:)', Name.Label),
1162
- ('[a-zA-Z$_][a-zA-Z0-9$_]*', Name),
1163
- (r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
1164
- ('#pop', 'classname')),
1165
- (r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
1166
- ('#pop', 'forward_classname')),
1167
- ],
1168
1110
  'root': [
1169
- include('whitespace'),
1170
- # functions
1171
- (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
1172
- r'([a-zA-Z$_][a-zA-Z0-9$_]*)' # method name
1173
- r'(\s*\([^;]*?\))' # signature
1174
- r'(' + _ws + r')?({)',
1175
- bygroups(using(this), Name.Function,
1176
- using(this), Text, Punctuation),
1177
- 'function'),
1178
- # methods
1179
- (r'^([-+])(\s*)' # method marker
1180
- r'(\(.*?\))?(\s*)' # return type
1181
- r'([a-zA-Z$_][a-zA-Z0-9$_]*:?)', # begin of method name
1182
- bygroups(Keyword, Text, using(this),
1183
- Text, Name.Function),
1184
- 'method'),
1185
- # function declarations
1186
- (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
1187
- r'([a-zA-Z$_][a-zA-Z0-9$_]*)' # method name
1188
- r'(\s*\([^;]*?\))' # signature
1189
- r'(' + _ws + r')?(;)',
1190
- bygroups(using(this), Name.Function,
1191
- using(this), Text, Punctuation)),
1192
- (r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
1193
- 'classname'),
1194
- (r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
1195
- 'forward_classname'),
1196
- (r'(\s*)(@end)(\s*)', bygroups(Text, Keyword, Text)),
1197
- ('', Text, 'statement'),
1198
- ],
1199
- 'classname' : [
1200
- # interface definition that inherits
1201
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
1202
- bygroups(Name.Class, Text, Name.Class), '#pop'),
1203
- # interface definition for a category
1204
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\([a-zA-Z$_][a-zA-Z0-9$_]*\))',
1205
- bygroups(Name.Class, Text, Name.Label), '#pop'),
1206
- # simple interface / implementation
1207
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
1208
- ],
1209
- 'forward_classname' : [
1210
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*,\s*)',
1211
- bygroups(Name.Class, Text), 'forward_classname'),
1212
- ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*;?)',
1213
- bygroups(Name.Class, Text), '#pop')
1214
- ],
1215
- 'statement' : [
1216
- include('whitespace'),
1217
- include('statements'),
1218
- ('[{}]', Punctuation),
1219
- (';', Punctuation, '#pop'),
1220
- ],
1221
- 'function': [
1222
- include('whitespace'),
1223
- include('statements'),
1224
- (';', Punctuation),
1225
- ('{', Punctuation, '#push'),
1226
- ('}', Punctuation, '#pop'),
1227
- ],
1228
- 'method': [
1229
- include('whitespace'),
1230
- # TODO unsure if ellipses are allowed elsewhere, see discussion in
1231
- # Issue 789
1232
- (r',', Punctuation),
1233
- (r'\.\.\.', Punctuation),
1234
- (r'(\(.*?\))([a-zA-Z$_][a-zA-Z0-9$_]*)', bygroups(using(this),
1235
- Name.Variable)),
1236
- (r'[a-zA-Z$_][a-zA-Z0-9$_]*:', Name.Function),
1237
- (';', Punctuation, '#pop'),
1238
- ('{', Punctuation, 'function'),
1239
- ('', Text, '#pop'),
1240
- ],
1241
- 'string': [
1242
- (r'"', String, '#pop'),
1243
- (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
1244
- (r'[^\\"\n]+', String), # all other characters
1245
- (r'\\\n', String), # line continuation
1246
- (r'\\', String), # stray backslash
1247
- ],
1248
- 'macro': [
1249
- (r'[^/\n]+', Comment.Preproc),
1250
- (r'/[*](.|\n)*?[*]/', Comment.Multiline),
1251
- (r'//.*?\n', Comment.Single, '#pop'),
1252
- (r'/', Comment.Preproc),
1253
- (r'(?<=\\)\n', Comment.Preproc),
1254
- (r'\n', Comment.Preproc, '#pop'),
1255
- ],
1256
- 'if0': [
1257
- (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
1258
- (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
1259
- (r'.*?\n', Comment),
1111
+ # Whitespace
1112
+ (r'\s+', Text),
1113
+
1114
+ # single line comment
1115
+ (r'//.*?\n', Comment.Single),
1116
+
1117
+ # lid header
1118
+ (r'(.*?)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
1119
+ bygroups(Name.Attribute, Operator, Text, String)),
1260
1120
  ]
1261
1121
  }
1262
1122
 
1263
- def analyse_text(text):
1264
- if '@import' in text or '@interface' in text or \
1265
- '@implementation' in text:
1266
- return True
1267
- elif '@"' in text: # strings
1268
- return True
1269
- elif re.match(r'\[[a-zA-Z0-9.]:', text): # message
1270
- return True
1271
- return False
1123
+
1124
+ class DylanConsoleLexer(Lexer):
1125
+ """
1126
+ For Dylan interactive console output like:
1127
+
1128
+ .. sourcecode:: dylan-console
1129
+
1130
+ ? let a = 1;
1131
+ => 1
1132
+ ? a
1133
+ => 1
1134
+
1135
+ This is based on a copy of the RubyConsoleLexer.
1136
+
1137
+ *New in Pygments 1.6.*
1138
+ """
1139
+ name = 'Dylan session'
1140
+ aliases = ['dylan-console', 'dylan-repl']
1141
+ filenames = ['*.dylan-console']
1142
+ mimetypes = ['text/x-dylan-console']
1143
+
1144
+ _line_re = re.compile('.*?\n')
1145
+ _prompt_re = re.compile('\?| ')
1146
+
1147
+ def get_tokens_unprocessed(self, text):
1148
+ dylexer = DylanLexer(**self.options)
1149
+
1150
+ curcode = ''
1151
+ insertions = []
1152
+ for match in self._line_re.finditer(text):
1153
+ line = match.group()
1154
+ m = self._prompt_re.match(line)
1155
+ if m is not None:
1156
+ end = m.end()
1157
+ insertions.append((len(curcode),
1158
+ [(0, Generic.Prompt, line[:end])]))
1159
+ curcode += line[end:]
1160
+ else:
1161
+ if curcode:
1162
+ for item in do_insertions(insertions,
1163
+ dylexer.get_tokens_unprocessed(curcode)):
1164
+ yield item
1165
+ curcode = ''
1166
+ insertions = []
1167
+ yield match.start(), Generic.Output, line
1168
+ if curcode:
1169
+ for item in do_insertions(insertions,
1170
+ dylexer.get_tokens_unprocessed(curcode)):
1171
+ yield item
1172
+
1173
+
1174
+ def objective(baselexer):
1175
+ """
1176
+ Generate a subclass of baselexer that accepts the Objective-C syntax
1177
+ extensions.
1178
+ """
1179
+
1180
+ # Have to be careful not to accidentally match JavaDoc/Doxygen syntax here,
1181
+ # since that's quite common in ordinary C/C++ files. It's OK to match
1182
+ # JavaDoc/Doxygen keywords that only apply to Objective-C, mind.
1183
+ #
1184
+ # The upshot of this is that we CANNOT match @class or @interface
1185
+ _oc_keywords = re.compile(r'@(?:end|implementation|protocol)')
1186
+
1187
+ # Matches [ <ws>? identifier <ws> ( identifier <ws>? ] | identifier? : )
1188
+ # (note the identifier is *optional* when there is a ':'!)
1189
+ _oc_message = re.compile(r'\[\s*[a-zA-Z_][a-zA-Z0-9_]*\s+'
1190
+ r'(?:[a-zA-Z_][a-zA-Z0-9_]*\s*\]|'
1191
+ r'(?:[a-zA-Z_][a-zA-Z0-9_]*)?:)')
1192
+
1193
+ class GeneratedObjectiveCVariant(baselexer):
1194
+ """
1195
+ Implements Objective-C syntax on top of an existing C family lexer.
1196
+ """
1197
+
1198
+ tokens = {
1199
+ 'statements': [
1200
+ (r'@"', String, 'string'),
1201
+ (r"@'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
1202
+ String.Char),
1203
+ (r'@(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
1204
+ (r'@(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
1205
+ (r'@0x[0-9a-fA-F]+[Ll]?', Number.Hex),
1206
+ (r'@0[0-7]+[Ll]?', Number.Oct),
1207
+ (r'@\d+[Ll]?', Number.Integer),
1208
+ (r'(in|@selector|@private|@protected|@public|@encode|'
1209
+ r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
1210
+ r'@synthesize|@dynamic|@optional)\b', Keyword),
1211
+ (r'(id|Class|IMP|SEL|BOOL|IBOutlet|IBAction|unichar)\b',
1212
+ Keyword.Type),
1213
+ (r'@(true|false|YES|NO)\n', Name.Builtin),
1214
+ (r'(YES|NO|nil)\b', Name.Builtin),
1215
+ (r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
1216
+ ('#pop', 'oc_classname')),
1217
+ (r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
1218
+ ('#pop', 'oc_forward_classname')),
1219
+ inherit,
1220
+ ],
1221
+ 'oc_classname' : [
1222
+ # interface definition that inherits
1223
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
1224
+ bygroups(Name.Class, Text, Name.Class), '#pop'),
1225
+ # interface definition for a category
1226
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\([a-zA-Z$_][a-zA-Z0-9$_]*\))',
1227
+ bygroups(Name.Class, Text, Name.Label), '#pop'),
1228
+ # simple interface / implementation
1229
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
1230
+ ],
1231
+ 'oc_forward_classname' : [
1232
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*,\s*)',
1233
+ bygroups(Name.Class, Text), 'oc_forward_classname'),
1234
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*;?)',
1235
+ bygroups(Name.Class, Text), '#pop')
1236
+ ],
1237
+ 'root': [
1238
+ # methods
1239
+ (r'^([-+])(\s*)' # method marker
1240
+ r'(\(.*?\))?(\s*)' # return type
1241
+ r'([a-zA-Z$_][a-zA-Z0-9$_]*:?)', # begin of method name
1242
+ bygroups(Keyword, Text, using(this),
1243
+ Text, Name.Function),
1244
+ 'method'),
1245
+ inherit,
1246
+ ],
1247
+ 'method': [
1248
+ include('whitespace'),
1249
+ # TODO unsure if ellipses are allowed elsewhere, see
1250
+ # discussion in Issue 789
1251
+ (r',', Punctuation),
1252
+ (r'\.\.\.', Punctuation),
1253
+ (r'(\(.*?\))([a-zA-Z$_][a-zA-Z0-9$_]*)', bygroups(using(this),
1254
+ Name.Variable)),
1255
+ (r'[a-zA-Z$_][a-zA-Z0-9$_]*:', Name.Function),
1256
+ (';', Punctuation, '#pop'),
1257
+ ('{', Punctuation, 'function'),
1258
+ ('', Text, '#pop'),
1259
+ ],
1260
+ }
1261
+
1262
+ def analyse_text(text):
1263
+ if _oc_keywords.search(text):
1264
+ return 1.0
1265
+ elif '@"' in text: # strings
1266
+ return 0.8
1267
+ elif _oc_message.search(text):
1268
+ return 0.8
1269
+ return 0
1270
+
1271
+ return GeneratedObjectiveCVariant
1272
+
1273
+
1274
+ class ObjectiveCLexer(objective(CLexer)):
1275
+ """
1276
+ For Objective-C source code with preprocessor directives.
1277
+ """
1278
+
1279
+ name = 'Objective-C'
1280
+ aliases = ['objective-c', 'objectivec', 'obj-c', 'objc']
1281
+ filenames = ['*.m', '*.h']
1282
+ mimetypes = ['text/x-objective-c']
1283
+ priority = 0.05 # Lower than C
1284
+
1285
+
1286
+ class ObjectiveCppLexer(objective(CppLexer)):
1287
+ """
1288
+ For Objective-C++ source code with preprocessor directives.
1289
+ """
1290
+
1291
+ name = 'Objective-C++'
1292
+ aliases = ['objective-c++', 'objectivec++', 'obj-c++', 'objc++']
1293
+ filenames = ['*.mm', '*.hh']
1294
+ mimetypes = ['text/x-objective-c++']
1295
+ priority = 0.05 # Lower than C++
1272
1296
 
1273
1297
 
1274
1298
  class FortranLexer(RegexLexer):
@@ -1301,16 +1325,16 @@ class FortranLexer(RegexLexer):
1301
1325
  ],
1302
1326
  'core': [
1303
1327
  # Statements
1304
- (r'\b(ACCEPT|ALLOCATABLE|ALLOCATE|ARRAY|ASSIGN|ASYNCHRONOUS|'
1305
- r'BACKSPACE|BIND|BLOCK DATA|BYTE|CALL|CASE|CLOSE|COMMON|CONTAINS|'
1328
+ (r'\b(ABSTRACT|ACCEPT|ALLOCATABLE|ALLOCATE|ARRAY|ASSIGN|ASYNCHRONOUS|'
1329
+ r'BACKSPACE|BIND|BLOCK( DATA)?|BYTE|CALL|CASE|CLASS|CLOSE|COMMON|CONTAINS|'
1306
1330
  r'CONTINUE|CYCLE|DATA|DEALLOCATE|DECODE|DEFERRED|DIMENSION|DO|'
1307
- r'ELSE|ENCODE|END FILE|ENDIF|END|ENTRY|ENUMERATOR|EQUIVALENCE|'
1331
+ r'ELEMENTAL|ELSE|ENCODE|END( FILE)?|ENDIF|ENTRY|ENUMERATOR|EQUIVALENCE|'
1308
1332
  r'EXIT|EXTERNAL|EXTRINSIC|FINAL|FORALL|FORMAT|FUNCTION|GENERIC|'
1309
1333
  r'GOTO|IF|IMPLICIT|IMPORT|INCLUDE|INQUIRE|INTENT|INTERFACE|'
1310
1334
  r'INTRINSIC|MODULE|NAMELIST|NULLIFY|NONE|NON_INTRINSIC|'
1311
1335
  r'NON_OVERRIDABLE|NOPASS|OPEN|OPTIONAL|OPTIONS|PARAMETER|PASS|'
1312
1336
  r'PAUSE|POINTER|PRINT|PRIVATE|PROGRAM|PROTECTED|PUBLIC|PURE|READ|'
1313
- r'RECURSIVE|RETURN|REWIND|SAVE|SELECT|SEQUENCE|STOP|SUBROUTINE|'
1337
+ r'RECURSIVE|RESULT|RETURN|REWIND|SAVE|SELECT|SEQUENCE|STOP|SUBROUTINE|'
1314
1338
  r'TARGET|THEN|TYPE|USE|VALUE|VOLATILE|WHERE|WRITE|WHILE)\s*\b',
1315
1339
  Keyword),
1316
1340
 
@@ -1831,8 +1855,7 @@ class GoLexer(RegexLexer):
1831
1855
  (r'(var|func|struct|map|chan|type|interface|const)\b', Keyword.Declaration),
1832
1856
  (r'(break|default|select|case|defer|go'
1833
1857
  r'|else|goto|switch|fallthrough|if|range'
1834
- r'|continue|for|return)\b', Keyword
1835
- ),
1858
+ r'|continue|for|return)\b', Keyword),
1836
1859
  (r'(true|false|iota|nil)\b', Keyword.Constant),
1837
1860
  # It seems the builtin types aren't actually keywords, but
1838
1861
  # can be used as functions. So we need two declarations.
@@ -1842,14 +1865,13 @@ class GoLexer(RegexLexer):
1842
1865
  r'|complex64|complex128|byte|rune'
1843
1866
  r'|string|bool|error|uintptr'
1844
1867
  r'|print|println|panic|recover|close|complex|real|imag'
1845
- r'|len|cap|append|copy|delete|new|make)\b(\()', bygroups(Name.Builtin, Punctuation)
1846
- ),
1868
+ r'|len|cap|append|copy|delete|new|make)\b(\()',
1869
+ bygroups(Name.Builtin, Punctuation)),
1847
1870
  (r'(uint|uint8|uint16|uint32|uint64'
1848
1871
  r'|int|int8|int16|int32|int64'
1849
1872
  r'|float|float32|float64'
1850
1873
  r'|complex64|complex128|byte|rune'
1851
- r'|string|bool|error|uintptr)\b', Keyword.Type
1852
- ),
1874
+ r'|string|bool|error|uintptr)\b', Keyword.Type),
1853
1875
  # imaginary_lit
1854
1876
  (r'\d+i', Number),
1855
1877
  (r'\d+\.\d*([Ee][-+]\d+)?i', Number),
@@ -2168,10 +2190,12 @@ class AdaLexer(RegexLexer):
2168
2190
  (r'(pragma)(\s+)([a-zA-Z0-9_]+)', bygroups(Keyword.Reserved, Text,
2169
2191
  Comment.Preproc)),
2170
2192
  (r'(true|false|null)\b', Keyword.Constant),
2171
- (r'(Byte|Character|Float|Integer|Long_Float|Long_Integer|'
2172
- r'Long_Long_Float|Long_Long_Integer|Natural|Positive|Short_Float|'
2173
- r'Short_Integer|Short_Short_Float|Short_Short_Integer|String|'
2174
- r'Wide_String|Duration)\b', Keyword.Type),
2193
+ (r'(Address|Byte|Boolean|Character|Controlled|Count|Cursor|'
2194
+ r'Duration|File_Mode|File_Type|Float|Generator|Integer|Long_Float|'
2195
+ r'Long_Integer|Long_Long_Float|Long_Long_Integer|Natural|Positive|'
2196
+ r'Reference_Type|Short_Float|Short_Integer|Short_Short_Float|'
2197
+ r'Short_Short_Integer|String|Wide_Character|Wide_String)\b',
2198
+ Keyword.Type),
2175
2199
  (r'(and(\s+then)?|in|mod|not|or(\s+else)|rem)\b', Operator.Word),
2176
2200
  (r'generic|private', Keyword.Declaration),
2177
2201
  (r'package', Keyword.Declaration, 'package'),
@@ -2226,7 +2250,8 @@ class AdaLexer(RegexLexer):
2226
2250
  (r'\(', Punctuation, 'formal_part'),
2227
2251
  (r'with|and|use', Keyword.Reserved),
2228
2252
  (r'array\b', Keyword.Reserved, ('#pop', 'array_def')),
2229
- (r'record\b', Keyword.Reserved, ('formal_part')),
2253
+ (r'record\b', Keyword.Reserved, ('record_def')),
2254
+ (r'(null record)(;)', bygroups(Keyword.Reserved, Punctuation), '#pop'),
2230
2255
  include('root'),
2231
2256
  ],
2232
2257
  'array_def' : [
@@ -2235,6 +2260,10 @@ class AdaLexer(RegexLexer):
2235
2260
  Keyword.Reserved)),
2236
2261
  include('root'),
2237
2262
  ],
2263
+ 'record_def' : [
2264
+ (r'end record', Keyword.Reserved, '#pop'),
2265
+ include('root'),
2266
+ ],
2238
2267
  'import': [
2239
2268
  (r'[a-z0-9_.]+', Name.Namespace, '#pop'),
2240
2269
  (r'', Text, '#pop'),
@@ -2474,7 +2503,9 @@ class BlitzMaxLexer(RegexLexer):
2474
2503
  bmax_sktypes = r'@{1,2}|[!#$%]'
2475
2504
  bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b'
2476
2505
  bmax_name = r'[a-z_][a-z0-9_]*'
2477
- bmax_var = r'(%s)(?:(?:([ \t]*)(%s)|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)|([ \t]*)([:])([ \t]*)(?:%s|(%s)))(?:([ \t]*)(Ptr))?)' % (bmax_name, bmax_sktypes, bmax_lktypes, bmax_name)
2506
+ bmax_var = (r'(%s)(?:(?:([ \t]*)(%s)|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)'
2507
+ r'|([ \t]*)([:])([ \t]*)(?:%s|(%s)))(?:([ \t]*)(Ptr))?)') % \
2508
+ (bmax_name, bmax_sktypes, bmax_lktypes, bmax_name)
2478
2509
  bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])'
2479
2510
 
2480
2511
  flags = re.MULTILINE | re.IGNORECASE
@@ -2943,13 +2974,13 @@ class RustLexer(RegexLexer):
2943
2974
  (r'/[*](.|\n)*?[*]/', Comment.Multiline),
2944
2975
 
2945
2976
  # Keywords
2946
- (r'(alt|as|assert|be|break|check|claim|class|const'
2947
- r'|cont|copy|crust|do|else|enum|export|fail'
2948
- r'|false|fn|for|if|iface|impl|import|let|log'
2949
- r'|loop|mod|mut|native|pure|resource|ret|true'
2950
- r'|type|unsafe|use|white|note|bind|prove|unchecked'
2951
- r'|with|syntax|u8|u16|u32|u64|i8|i16|i32|i64|uint'
2952
- r'|int|f32|f64)\b', Keyword),
2977
+ (r'(as|assert|break|const'
2978
+ r'|copy|do|else|enum|extern|fail'
2979
+ r'|false|fn|for|if|impl|let|log'
2980
+ r'|loop|match|mod|move|mut|once|priv|pub|pure'
2981
+ r'|ref|return|static|struct|trait|true|type|unsafe|use|while'
2982
+ r'|u8|u16|u32|u64|i8|i16|i32|i64|uint'
2983
+ r'|int|float|f32|f64|str)\b', Keyword),
2953
2984
 
2954
2985
  # Character Literal
2955
2986
  (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
@@ -2978,8 +3009,8 @@ class RustLexer(RegexLexer):
2978
3009
  (r'#\[', Comment.Preproc, 'attribute['),
2979
3010
  (r'#\(', Comment.Preproc, 'attribute('),
2980
3011
  # Macros
2981
- (r'#[A-Za-z_][A-Za-z0-9_]*\[', Comment.Preproc, 'attribute['),
2982
- (r'#[A-Za-z_][A-Za-z0-9_]*\(', Comment.Preproc, 'attribute('),
3012
+ (r'[A-Za-z_][A-Za-z0-9_]*!\[', Comment.Preproc, 'attribute['),
3013
+ (r'[A-Za-z_][A-Za-z0-9_]*!\(', Comment.Preproc, 'attribute('),
2983
3014
  ],
2984
3015
  'number_lit': [
2985
3016
  (r'(([ui](8|16|32|64)?)|(f(32|64)?))?', Keyword, '#pop'),
@@ -3070,7 +3101,7 @@ class MonkeyLexer(RegexLexer):
3070
3101
  name = 'Monkey'
3071
3102
  aliases = ['monkey']
3072
3103
  filenames = ['*.monkey']
3073
- mimetypes = ['text/x-monkey']
3104
+ mimetypes = ['text/x-monkey']
3074
3105
 
3075
3106
  name_variable = r'[a-z_][a-zA-Z0-9_]*'
3076
3107
  name_function = r'[A-Z][a-zA-Z0-9_]*'
@@ -3113,12 +3144,17 @@ class MonkeyLexer(RegexLexer):
3113
3144
  (r'(?i)\b(?:Self|Super)\b', Name.Builtin.Pseudo),
3114
3145
  (r'\b(?:HOST|LANG|TARGET|CONFIG)\b', Name.Constant),
3115
3146
  # Keywords
3116
- (r'(?i)^(Import)(\s+)(.*)(\n)', bygroups(Keyword.Namespace, Text, Name.Namespace, Text)),
3147
+ (r'(?i)^(Import)(\s+)(.*)(\n)',
3148
+ bygroups(Keyword.Namespace, Text, Name.Namespace, Text)),
3117
3149
  (r'(?i)^Strict\b.*\n', Keyword.Reserved),
3118
- (r'(?i)(Const|Local|Global|Field)(\s+)', bygroups(Keyword.Declaration, Text), 'variables'),
3119
- (r'(?i)(New|Class|Interface|Extends|Implements)(\s+)', bygroups(Keyword.Reserved, Text), 'classname'),
3120
- (r'(?i)(Function|Method)(\s+)', bygroups(Keyword.Reserved, Text), 'funcname'),
3121
- (r'(?i)(?:End|Return|Public|Private|Extern|Property|Final|Abstract)\b', Keyword.Reserved),
3150
+ (r'(?i)(Const|Local|Global|Field)(\s+)',
3151
+ bygroups(Keyword.Declaration, Text), 'variables'),
3152
+ (r'(?i)(New|Class|Interface|Extends|Implements)(\s+)',
3153
+ bygroups(Keyword.Reserved, Text), 'classname'),
3154
+ (r'(?i)(Function|Method)(\s+)',
3155
+ bygroups(Keyword.Reserved, Text), 'funcname'),
3156
+ (r'(?i)(?:End|Return|Public|Private|Extern|Property|'
3157
+ r'Final|Abstract)\b', Keyword.Reserved),
3122
3158
  # Flow Control stuff
3123
3159
  (r'(?i)(?:If|Then|Else|ElseIf|EndIf|'
3124
3160
  r'Select|Case|Default|'
@@ -3144,10 +3180,10 @@ class MonkeyLexer(RegexLexer):
3144
3180
  (r':', Punctuation, 'classname'),
3145
3181
  (r'\s+', Text),
3146
3182
  (r'\(', Punctuation, 'variables'),
3147
- (r'\)', Punctuation, '#pop')
3183
+ (r'\)', Punctuation, '#pop')
3148
3184
  ],
3149
3185
  'classname': [
3150
- (r'%s\.' % name_module, Name.Namespace),
3186
+ (r'%s\.' % name_module, Name.Namespace),
3151
3187
  (r'%s\b' % keyword_type, Keyword.Type),
3152
3188
  (r'%s\b' % name_class, Name.Class),
3153
3189
  # array (of given size)
@@ -3181,3 +3217,280 @@ class MonkeyLexer(RegexLexer):
3181
3217
  (r'.+', Comment.Multiline),
3182
3218
  ],
3183
3219
  }
3220
+
3221
+
3222
+ class CobolLexer(RegexLexer):
3223
+ """
3224
+ Lexer for OpenCOBOL code.
3225
+
3226
+ *New in Pygments 1.6.*
3227
+ """
3228
+ name = 'COBOL'
3229
+ aliases = ['cobol']
3230
+ filenames = ['*.cob', '*.COB', '*.cpy', '*.CPY']
3231
+ mimetypes = ['text/x-cobol']
3232
+ flags = re.IGNORECASE | re.MULTILINE
3233
+
3234
+ # Data Types: by PICTURE and USAGE
3235
+ # Operators: **, *, +, -, /, <, >, <=, >=, =, <>
3236
+ # Logical (?): NOT, AND, OR
3237
+
3238
+ # Reserved words:
3239
+ # http://opencobol.add1tocobol.com/#reserved-words
3240
+ # Intrinsics:
3241
+ # http://opencobol.add1tocobol.com/#does-opencobol-implement-any-intrinsic-functions
3242
+
3243
+ tokens = {
3244
+ 'root': [
3245
+ include('comment'),
3246
+ include('strings'),
3247
+ include('core'),
3248
+ include('nums'),
3249
+ (r'[a-z0-9]([_a-z0-9\-]*[a-z0-9]+)?', Name.Variable),
3250
+ # (r'[\s]+', Text),
3251
+ (r'[ \t]+', Text),
3252
+ ],
3253
+ 'comment': [
3254
+ (r'(^.{6}[*/].*\n|^.{6}|\*>.*\n)', Comment),
3255
+ ],
3256
+ 'core': [
3257
+ # Figurative constants
3258
+ (r'(^|(?<=[^0-9a-z_\-]))(ALL\s+)?'
3259
+ r'((ZEROES)|(HIGH-VALUE|LOW-VALUE|QUOTE|SPACE|ZERO)(S)?)'
3260
+ r'\s*($|(?=[^0-9a-z_\-]))',
3261
+ Name.Constant),
3262
+
3263
+ # Reserved words STATEMENTS and other bolds
3264
+ (r'(^|(?<=[^0-9a-z_\-]))'
3265
+ r'(ACCEPT|ADD|ALLOCATE|CALL|CANCEL|CLOSE|COMPUTE|'
3266
+ r'CONFIGURATION|CONTINUE|'
3267
+ r'DATA|DELETE|DISPLAY|DIVIDE|DIVISION|ELSE|END|END-ACCEPT|'
3268
+ r'END-ADD|END-CALL|END-COMPUTE|END-DELETE|END-DISPLAY|'
3269
+ r'END-DIVIDE|END-EVALUATE|END-IF|END-MULTIPLY|END-OF-PAGE|'
3270
+ r'END-PERFORM|END-READ|END-RETURN|END-REWRITE|END-SEARCH|'
3271
+ r'END-START|END-STRING|END-SUBTRACT|END-UNSTRING|END-WRITE|'
3272
+ r'ENVIRONMENT|EVALUATE|EXIT|FD|FILE|FILE-CONTROL|FOREVER|'
3273
+ r'FREE|GENERATE|GO|GOBACK|'
3274
+ r'IDENTIFICATION|IF|INITIALIZE|'
3275
+ r'INITIATE|INPUT-OUTPUT|INSPECT|INVOKE|I-O-CONTROL|LINKAGE|'
3276
+ r'LOCAL-STORAGE|MERGE|MOVE|MULTIPLY|OPEN|'
3277
+ r'PERFORM|PROCEDURE|PROGRAM-ID|RAISE|READ|RELEASE|RESUME|'
3278
+ r'RETURN|REWRITE|SCREEN|'
3279
+ r'SD|SEARCH|SECTION|SET|SORT|START|STOP|STRING|SUBTRACT|'
3280
+ r'SUPPRESS|TERMINATE|THEN|UNLOCK|UNSTRING|USE|VALIDATE|'
3281
+ r'WORKING-STORAGE|WRITE)'
3282
+ r'\s*($|(?=[^0-9a-z_\-]))', Keyword.Reserved),
3283
+
3284
+ # Reserved words
3285
+ (r'(^|(?<=[^0-9a-z_\-]))'
3286
+ r'(ACCESS|ADDRESS|ADVANCING|AFTER|ALL|'
3287
+ r'ALPHABET|ALPHABETIC|ALPHABETIC-LOWER|ALPHABETIC-UPPER|'
3288
+ r'ALPHANUMERIC|ALPHANUMERIC-EDITED|ALSO|ALTER|ALTERNATE'
3289
+ r'ANY|ARE|AREA|AREAS|ARGUMENT-NUMBER|ARGUMENT-VALUE|AS|'
3290
+ r'ASCENDING|ASSIGN|AT|AUTO|AUTO-SKIP|AUTOMATIC|AUTOTERMINATE|'
3291
+ r'BACKGROUND-COLOR|BASED|BEEP|BEFORE|BELL|'
3292
+ r'BLANK|'
3293
+ r'BLINK|BLOCK|BOTTOM|BY|BYTE-LENGTH|CHAINING|'
3294
+ r'CHARACTER|CHARACTERS|CLASS|CODE|CODE-SET|COL|COLLATING|'
3295
+ r'COLS|COLUMN|COLUMNS|COMMA|COMMAND-LINE|COMMIT|COMMON|'
3296
+ r'CONSTANT|CONTAINS|CONTENT|CONTROL|'
3297
+ r'CONTROLS|CONVERTING|COPY|CORR|CORRESPONDING|COUNT|CRT|'
3298
+ r'CURRENCY|CURSOR|CYCLE|DATE|DAY|DAY-OF-WEEK|DE|DEBUGGING|'
3299
+ r'DECIMAL-POINT|DECLARATIVES|DEFAULT|DELIMITED|'
3300
+ r'DELIMITER|DEPENDING|DESCENDING|DETAIL|DISK|'
3301
+ r'DOWN|DUPLICATES|DYNAMIC|EBCDIC|'
3302
+ r'ENTRY|ENVIRONMENT-NAME|ENVIRONMENT-VALUE|EOL|EOP|'
3303
+ r'EOS|ERASE|ERROR|ESCAPE|EXCEPTION|'
3304
+ r'EXCLUSIVE|EXTEND|EXTERNAL|'
3305
+ r'FILE-ID|FILLER|FINAL|FIRST|FIXED|FLOAT-LONG|FLOAT-SHORT|'
3306
+ r'FOOTING|FOR|FOREGROUND-COLOR|FORMAT|FROM|FULL|FUNCTION|'
3307
+ r'FUNCTION-ID|GIVING|GLOBAL|GROUP|'
3308
+ r'HEADING|HIGHLIGHT|I-O|ID|'
3309
+ r'IGNORE|IGNORING|IN|INDEX|INDEXED|INDICATE|'
3310
+ r'INITIAL|INITIALIZED|INPUT|'
3311
+ r'INTO|INTRINSIC|INVALID|IS|JUST|JUSTIFIED|KEY|LABEL|'
3312
+ r'LAST|LEADING|LEFT|LENGTH|LIMIT|LIMITS|LINAGE|'
3313
+ r'LINAGE-COUNTER|LINE|LINES|LOCALE|LOCK|'
3314
+ r'LOWLIGHT|MANUAL|MEMORY|MINUS|MODE|'
3315
+ r'MULTIPLE|NATIONAL|NATIONAL-EDITED|NATIVE|'
3316
+ r'NEGATIVE|NEXT|NO|NULL|NULLS|NUMBER|NUMBERS|NUMERIC|'
3317
+ r'NUMERIC-EDITED|OBJECT-COMPUTER|OCCURS|OF|OFF|OMITTED|ON|ONLY|'
3318
+ r'OPTIONAL|ORDER|ORGANIZATION|OTHER|OUTPUT|OVERFLOW|'
3319
+ r'OVERLINE|PACKED-DECIMAL|PADDING|PAGE|PARAGRAPH|'
3320
+ r'PLUS|POINTER|POSITION|POSITIVE|PRESENT|PREVIOUS|'
3321
+ r'PRINTER|PRINTING|PROCEDURE-POINTER|PROCEDURES|'
3322
+ r'PROCEED|PROGRAM|PROGRAM-POINTER|PROMPT|QUOTE|'
3323
+ r'QUOTES|RANDOM|RD|RECORD|RECORDING|RECORDS|RECURSIVE|'
3324
+ r'REDEFINES|REEL|REFERENCE|RELATIVE|REMAINDER|REMOVAL|'
3325
+ r'RENAMES|REPLACING|REPORT|REPORTING|REPORTS|REPOSITORY|'
3326
+ r'REQUIRED|RESERVE|RETURNING|REVERSE-VIDEO|REWIND|'
3327
+ r'RIGHT|ROLLBACK|ROUNDED|RUN|SAME|SCROLL|'
3328
+ r'SECURE|SEGMENT-LIMIT|SELECT|SENTENCE|SEPARATE|'
3329
+ r'SEQUENCE|SEQUENTIAL|SHARING|SIGN|SIGNED|SIGNED-INT|'
3330
+ r'SIGNED-LONG|SIGNED-SHORT|SIZE|SORT-MERGE|SOURCE|'
3331
+ r'SOURCE-COMPUTER|SPECIAL-NAMES|STANDARD|'
3332
+ r'STANDARD-1|STANDARD-2|STATUS|SUM|'
3333
+ r'SYMBOLIC|SYNC|SYNCHRONIZED|TALLYING|TAPE|'
3334
+ r'TEST|THROUGH|THRU|TIME|TIMES|TO|TOP|TRAILING|'
3335
+ r'TRANSFORM|TYPE|UNDERLINE|UNIT|UNSIGNED|'
3336
+ r'UNSIGNED-INT|UNSIGNED-LONG|UNSIGNED-SHORT|UNTIL|UP|'
3337
+ r'UPDATE|UPON|USAGE|USING|VALUE|VALUES|VARYING|WAIT|WHEN|'
3338
+ r'WITH|WORDS|YYYYDDD|YYYYMMDD)'
3339
+ r'\s*($|(?=[^0-9a-z_\-]))', Keyword.Pseudo),
3340
+
3341
+ # inactive reserved words
3342
+ (r'(^|(?<=[^0-9a-z_\-]))'
3343
+ r'(ACTIVE-CLASS|ALIGNED|ANYCASE|ARITHMETIC|ATTRIBUTE|B-AND|'
3344
+ r'B-NOT|B-OR|B-XOR|BIT|BOOLEAN|CD|CENTER|CF|CH|CHAIN|CLASS-ID|'
3345
+ r'CLASSIFICATION|COMMUNICATION|CONDITION|DATA-POINTER|'
3346
+ r'DESTINATION|DISABLE|EC|EGI|EMI|ENABLE|END-RECEIVE|'
3347
+ r'ENTRY-CONVENTION|EO|ESI|EXCEPTION-OBJECT|EXPANDS|FACTORY|'
3348
+ r'FLOAT-BINARY-16|FLOAT-BINARY-34|FLOAT-BINARY-7|'
3349
+ r'FLOAT-DECIMAL-16|FLOAT-DECIMAL-34|FLOAT-EXTENDED|FORMAT|'
3350
+ r'FUNCTION-POINTER|GET|GROUP-USAGE|IMPLEMENTS|INFINITY|'
3351
+ r'INHERITS|INTERFACE|INTERFACE-ID|INVOKE|LC_ALL|LC_COLLATE|'
3352
+ r'LC_CTYPE|LC_MESSAGES|LC_MONETARY|LC_NUMERIC|LC_TIME|'
3353
+ r'LINE-COUNTER|MESSAGE|METHOD|METHOD-ID|NESTED|NONE|NORMAL|'
3354
+ r'OBJECT|OBJECT-REFERENCE|OPTIONS|OVERRIDE|PAGE-COUNTER|PF|PH|'
3355
+ r'PROPERTY|PROTOTYPE|PURGE|QUEUE|RAISE|RAISING|RECEIVE|'
3356
+ r'RELATION|REPLACE|REPRESENTS-NOT-A-NUMBER|RESET|RESUME|RETRY|'
3357
+ r'RF|RH|SECONDS|SEGMENT|SELF|SEND|SOURCES|STATEMENT|STEP|'
3358
+ r'STRONG|SUB-QUEUE-1|SUB-QUEUE-2|SUB-QUEUE-3|SUPER|SYMBOL|'
3359
+ r'SYSTEM-DEFAULT|TABLE|TERMINAL|TEXT|TYPEDEF|UCS-4|UNIVERSAL|'
3360
+ r'USER-DEFAULT|UTF-16|UTF-8|VAL-STATUS|VALID|VALIDATE|'
3361
+ r'VALIDATE-STATUS)\s*($|(?=[^0-9a-z_\-]))', Error),
3362
+
3363
+ # Data Types
3364
+ (r'(^|(?<=[^0-9a-z_\-]))'
3365
+ r'(PIC\s+.+?(?=(\s|\.\s))|PICTURE\s+.+?(?=(\s|\.\s))|'
3366
+ r'(COMPUTATIONAL)(-[1-5X])?|(COMP)(-[1-5X])?|'
3367
+ r'BINARY-C-LONG|'
3368
+ r'BINARY-CHAR|BINARY-DOUBLE|BINARY-LONG|BINARY-SHORT|'
3369
+ r'BINARY)\s*($|(?=[^0-9a-z_\-]))', Keyword.Type),
3370
+
3371
+ # Operators
3372
+ (r'(\*\*|\*|\+|-|/|<=|>=|<|>|==|/=|=)', Operator),
3373
+
3374
+ # (r'(::)', Keyword.Declaration),
3375
+
3376
+ (r'([(),;:&%.])', Punctuation),
3377
+
3378
+ # Intrinsics
3379
+ (r'(^|(?<=[^0-9a-z_\-]))(ABS|ACOS|ANNUITY|ASIN|ATAN|BYTE-LENGTH|'
3380
+ r'CHAR|COMBINED-DATETIME|CONCATENATE|COS|CURRENT-DATE|'
3381
+ r'DATE-OF-INTEGER|DATE-TO-YYYYMMDD|DAY-OF-INTEGER|DAY-TO-YYYYDDD|'
3382
+ r'EXCEPTION-(?:FILE|LOCATION|STATEMENT|STATUS)|EXP10|EXP|E|'
3383
+ r'FACTORIAL|FRACTION-PART|INTEGER-OF-(?:DATE|DAY|PART)|INTEGER|'
3384
+ r'LENGTH|LOCALE-(?:DATE|TIME(?:-FROM-SECONDS)?)|LOG10|LOG|'
3385
+ r'LOWER-CASE|MAX|MEAN|MEDIAN|MIDRANGE|MIN|MOD|NUMVAL(?:-C)?|'
3386
+ r'ORD(?:-MAX|-MIN)?|PI|PRESENT-VALUE|RANDOM|RANGE|REM|REVERSE|'
3387
+ r'SECONDS-FROM-FORMATTED-TIME|SECONDS-PAST-MIDNIGHT|SIGN|SIN|SQRT|'
3388
+ r'STANDARD-DEVIATION|STORED-CHAR-LENGTH|SUBSTITUTE(?:-CASE)?|'
3389
+ r'SUM|TAN|TEST-DATE-YYYYMMDD|TEST-DAY-YYYYDDD|TRIM|'
3390
+ r'UPPER-CASE|VARIANCE|WHEN-COMPILED|YEAR-TO-YYYY)\s*'
3391
+ r'($|(?=[^0-9a-z_\-]))', Name.Function),
3392
+
3393
+ # Booleans
3394
+ (r'(^|(?<=[^0-9a-z_\-]))(true|false)\s*($|(?=[^0-9a-z_\-]))', Name.Builtin),
3395
+ # Comparing Operators
3396
+ (r'(^|(?<=[^0-9a-z_\-]))(equal|equals|ne|lt|le|gt|ge|'
3397
+ r'greater|less|than|not|and|or)\s*($|(?=[^0-9a-z_\-]))', Operator.Word),
3398
+ ],
3399
+
3400
+ # \"[^\"\n]*\"|\'[^\'\n]*\'
3401
+ 'strings': [
3402
+ # apparently strings can be delimited by EOL if they are continued
3403
+ # in the next line
3404
+ (r'"[^"\n]*("|\n)', String.Double),
3405
+ (r"'[^'\n]*('|\n)", String.Single),
3406
+ ],
3407
+
3408
+ 'nums': [
3409
+ (r'\d+(\s*|\.$|$)', Number.Integer),
3410
+ (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
3411
+ (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float),
3412
+ ],
3413
+ }
3414
+
3415
+
3416
+ class CobolFreeformatLexer(CobolLexer):
3417
+ """
3418
+ Lexer for Free format OpenCOBOL code.
3419
+
3420
+ *New in Pygments 1.6.*
3421
+ """
3422
+ name = 'COBOLFree'
3423
+ aliases = ['cobolfree']
3424
+ filenames = ['*.cbl', '*.CBL']
3425
+ mimetypes = []
3426
+ flags = re.IGNORECASE | re.MULTILINE
3427
+
3428
+ tokens = {
3429
+ 'comment': [
3430
+ (r'(\*>.*\n|^\w*\*.*$)', Comment),
3431
+ ],
3432
+ }
3433
+
3434
+
3435
+ class LogosLexer(ObjectiveCppLexer):
3436
+ """
3437
+ For Logos + Objective-C source code with preprocessor directives.
3438
+
3439
+ *New in Pygments 1.6.*
3440
+ """
3441
+
3442
+ name = 'Logos'
3443
+ aliases = ['logos']
3444
+ filenames = ['*.x', '*.xi', '*.xm', '*.xmi']
3445
+ mimetypes = ['text/x-logos']
3446
+ priority = 0.25
3447
+
3448
+ tokens = {
3449
+ 'statements': [
3450
+ (r'(%orig|%log)\b', Keyword),
3451
+ (r'(%c)\b(\()(\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\))',
3452
+ bygroups(Keyword, Punctuation, Text, Name.Class, Text, Punctuation)),
3453
+ (r'(%init)\b(\()',
3454
+ bygroups(Keyword, Punctuation), 'logos_init_directive'),
3455
+ (r'(%init)(?=\s*;)', bygroups(Keyword)),
3456
+ (r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)',
3457
+ bygroups(Keyword, Text, Name.Class), '#pop'),
3458
+ (r'(%subclass)(\s+)', bygroups(Keyword, Text),
3459
+ ('#pop', 'logos_classname')),
3460
+ inherit,
3461
+ ],
3462
+ 'logos_init_directive' : [
3463
+ ('\s+', Text),
3464
+ (',', Punctuation, ('logos_init_directive', '#pop')),
3465
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(=)(\s*)([^);]*)',
3466
+ bygroups(Name.Class, Text, Punctuation, Text, Text)),
3467
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class),
3468
+ ('\)', Punctuation, '#pop'),
3469
+ ],
3470
+ 'logos_classname' : [
3471
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
3472
+ bygroups(Name.Class, Text, Name.Class), '#pop'),
3473
+ ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
3474
+ ],
3475
+ 'root': [
3476
+ (r'(%subclass)(\s+)', bygroups(Keyword, Text),
3477
+ 'logos_classname'),
3478
+ (r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)',
3479
+ bygroups(Keyword, Text, Name.Class)),
3480
+ (r'(%config)(\s*\(\s*)(\w+)(\s*=\s*)(.*?)(\s*\)\s*)',
3481
+ bygroups(Keyword, Text, Name.Variable, Text, String, Text)),
3482
+ (r'(%ctor)(\s*)({)', bygroups(Keyword, Text, Punctuation),
3483
+ 'function'),
3484
+ (r'(%new)(\s*)(\()(\s*.*?\s*)(\))',
3485
+ bygroups(Keyword, Text, Keyword, String, Keyword)),
3486
+ (r'(\s*)(%end)(\s*)', bygroups(Text, Keyword, Text)),
3487
+ inherit,
3488
+ ],
3489
+ }
3490
+
3491
+ _logos_keywords = re.compile(r'%(?:hook|ctor|init|c\()')
3492
+
3493
+ def analyse_text(text):
3494
+ if LogosLexer._logos_keywords.search(text):
3495
+ return 1.0
3496
+ return 0