pygments.rb 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/README.md +6 -1
  2. data/lexers +0 -0
  3. data/lib/pygments/version.rb +1 -1
  4. data/vendor/pygments-main/AUTHORS +15 -0
  5. data/vendor/pygments-main/CHANGES +28 -1
  6. data/vendor/pygments-main/LICENSE +1 -1
  7. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +121 -0
  8. data/vendor/pygments-main/pygments/cmdline.py +1 -1
  9. data/vendor/pygments-main/pygments/filters/__init__.py +0 -1
  10. data/vendor/pygments-main/pygments/formatters/_mapping.py +2 -2
  11. data/vendor/pygments-main/pygments/formatters/img.py +1 -1
  12. data/vendor/pygments-main/pygments/formatters/latex.py +8 -8
  13. data/vendor/pygments-main/pygments/formatters/other.py +0 -2
  14. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5413 -0
  15. data/vendor/pygments-main/pygments/lexers/_mapping.py +36 -11
  16. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +551 -0
  17. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +0 -1
  18. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +546 -0
  19. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
  20. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +174 -0
  21. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -3
  22. data/vendor/pygments-main/pygments/lexers/agile.py +145 -33
  23. data/vendor/pygments-main/pygments/lexers/asm.py +2 -2
  24. data/vendor/pygments-main/pygments/lexers/compiled.py +328 -36
  25. data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
  26. data/vendor/pygments-main/pygments/lexers/dotnet.py +8 -14
  27. data/vendor/pygments-main/pygments/lexers/functional.py +773 -8
  28. data/vendor/pygments-main/pygments/lexers/jvm.py +184 -36
  29. data/vendor/pygments-main/pygments/lexers/math.py +349 -23
  30. data/vendor/pygments-main/pygments/lexers/other.py +315 -492
  31. data/vendor/pygments-main/pygments/lexers/parsers.py +83 -1
  32. data/vendor/pygments-main/pygments/lexers/shell.py +4 -1
  33. data/vendor/pygments-main/pygments/lexers/templates.py +112 -2
  34. data/vendor/pygments-main/pygments/lexers/text.py +52 -3
  35. data/vendor/pygments-main/pygments/lexers/web.py +382 -36
  36. data/vendor/pygments-main/pygments/unistring.py +35 -25
  37. data/vendor/pygments-main/pygments/util.py +45 -0
  38. data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
  39. data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
  40. data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
  41. data/vendor/pygments-main/tests/examplefiles/example.ceylon +33 -0
  42. data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
  43. data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
  44. data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
  45. data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
  46. data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
  47. data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
  48. data/vendor/pygments-main/tests/examplefiles/example.stan +97 -0
  49. data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
  50. data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
  51. data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +123 -0
  52. data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
  53. data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
  54. data/vendor/pygments-main/tests/examplefiles/http_request_example +2 -1
  55. data/vendor/pygments-main/tests/examplefiles/http_response_example +4 -2
  56. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
  57. data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
  58. data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
  59. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
  60. data/vendor/pygments-main/tests/examplefiles/matlab_sample +5 -2
  61. data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
  62. data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
  63. data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
  64. data/vendor/pygments-main/tests/examplefiles/rust_example.rs +743 -0
  65. data/vendor/pygments-main/tests/examplefiles/test.R +149 -115
  66. data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
  67. data/vendor/pygments-main/tests/test_basic_api.py +1 -1
  68. data/vendor/pygments-main/tests/test_util.py +18 -0
  69. metadata +34 -3
  70. data/vendor/pygments-main/REVISION +0 -1
@@ -208,7 +208,7 @@ class LlvmLexer(RegexLexer):
208
208
  include('whitespace'),
209
209
 
210
210
  # Before keywords, because keywords are valid label names :(...
211
- (r'^\s*' + identifier + '\s*:', Name.Label),
211
+ (identifier + '\s*:', Name.Label),
212
212
 
213
213
  include('keyword'),
214
214
 
@@ -240,7 +240,7 @@ class LlvmLexer(RegexLexer):
240
240
  r'|linkonce_odr|weak|weak_odr|appending|dllimport|dllexport'
241
241
  r'|common|default|hidden|protected|extern_weak|external'
242
242
  r'|thread_local|zeroinitializer|undef|null|to|tail|target|triple'
243
- r'|deplibs|datalayout|volatile|nuw|nsw|exact|inbounds|align'
243
+ r'|datalayout|volatile|nuw|nsw|exact|inbounds|align'
244
244
  r'|addrspace|section|alias|module|asm|sideeffect|gc|dbg'
245
245
 
246
246
  r'|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc'
@@ -27,7 +27,7 @@ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer',
27
27
  'DylanLexer', 'ObjectiveCLexer', 'FortranLexer', 'GLShaderLexer',
28
28
  'PrologLexer', 'CythonLexer', 'ValaLexer', 'OocLexer', 'GoLexer',
29
29
  'FelixLexer', 'AdaLexer', 'Modula2Lexer', 'BlitzMaxLexer',
30
- 'NimrodLexer', 'FantomLexer']
30
+ 'NimrodLexer', 'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer']
31
31
 
32
32
 
33
33
  class CLexer(RegexLexer):
@@ -41,6 +41,8 @@ class CLexer(RegexLexer):
41
41
 
42
42
  #: optional Comment or Whitespace
43
43
  _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
44
+ #: only one /* */ style comment
45
+ _ws1 = r':\s*/[*].*?[*]/\s*'
44
46
 
45
47
  tokens = {
46
48
  'whitespace': [
@@ -48,9 +50,9 @@ class CLexer(RegexLexer):
48
50
  ('^#if\s+0', Comment.Preproc, 'if0'),
49
51
  ('^#', Comment.Preproc, 'macro'),
50
52
  # or with whitespace
51
- ('^(' + _ws + r')(#if\s+0)',
53
+ ('^(' + _ws1 + r')(#if\s+0)',
52
54
  bygroups(using(this), Comment.Preproc), 'if0'),
53
- ('^(' + _ws + ')(#)',
55
+ ('^(' + _ws1 + ')(#)',
54
56
  bygroups(using(this), Comment.Preproc), 'macro'),
55
57
  (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))',
56
58
  bygroups(Text, Name.Label)),
@@ -89,7 +91,7 @@ class CLexer(RegexLexer):
89
91
  (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
90
92
  r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
91
93
  r'(\s*\([^;]*?\))' # signature
92
- r'(' + _ws + r')({)',
94
+ r'(' + _ws + r')?({)',
93
95
  bygroups(using(this), Name.Function, using(this), using(this),
94
96
  Punctuation),
95
97
  'function'),
@@ -97,7 +99,7 @@ class CLexer(RegexLexer):
97
99
  (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
98
100
  r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
99
101
  r'(\s*\([^;]*?\))' # signature
100
- r'(' + _ws + r')(;)',
102
+ r'(' + _ws + r')?(;)',
101
103
  bygroups(using(this), Name.Function, using(this), using(this),
102
104
  Punctuation)),
103
105
  ('', Text, 'statement'),
@@ -174,11 +176,14 @@ class CppLexer(RegexLexer):
174
176
  name = 'C++'
175
177
  aliases = ['cpp', 'c++']
176
178
  filenames = ['*.cpp', '*.hpp', '*.c++', '*.h++',
177
- '*.cc', '*.hh', '*.cxx', '*.hxx']
179
+ '*.cc', '*.hh', '*.cxx', '*.hxx',
180
+ '*.C', '*.H', '*.cp', '*.CPP']
178
181
  mimetypes = ['text/x-c++hdr', 'text/x-c++src']
179
182
 
180
183
  #: optional Comment or Whitespace
181
184
  _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
185
+ #: only one /* */ style comment
186
+ _ws1 = r':\s*/[*].*?[*]/\s*'
182
187
 
183
188
  tokens = {
184
189
  'root': [
@@ -186,9 +191,9 @@ class CppLexer(RegexLexer):
186
191
  ('^#if\s+0', Comment.Preproc, 'if0'),
187
192
  ('^#', Comment.Preproc, 'macro'),
188
193
  # or with whitespace
189
- ('^(' + _ws + r')(#if\s+0)',
194
+ ('^(' + _ws1 + r')(#if\s+0)',
190
195
  bygroups(using(this), Comment.Preproc), 'if0'),
191
- ('^(' + _ws + ')(#)',
196
+ ('^(' + _ws1 + ')(#)',
192
197
  bygroups(using(this), Comment.Preproc), 'macro'),
193
198
  (r'\n', Text),
194
199
  (r'\s+', Text),
@@ -270,6 +275,8 @@ class ECLexer(RegexLexer):
270
275
 
271
276
  #: optional Comment or Whitespace
272
277
  _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
278
+ #: only one /* */ style comment
279
+ _ws1 = r':\s*/[*].*?[*]/\s*'
273
280
 
274
281
  tokens = {
275
282
  'whitespace': [
@@ -277,8 +284,8 @@ class ECLexer(RegexLexer):
277
284
  ('^#if\s+0', Comment.Preproc, 'if0'),
278
285
  ('^#', Comment.Preproc, 'macro'),
279
286
  # or with whitespace
280
- ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
281
- ('^' + _ws + '#', Comment.Preproc, 'macro'),
287
+ ('^' + _ws1 + r'#if\s+0', Comment.Preproc, 'if0'),
288
+ ('^' + _ws1 + '#', Comment.Preproc, 'macro'),
282
289
  (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))', bygroups(Text, Name.Label)),
283
290
  (r'\n', Text),
284
291
  (r'\s+', Text),
@@ -323,7 +330,7 @@ class ECLexer(RegexLexer):
323
330
  (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
324
331
  r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
325
332
  r'(\s*\([^;]*?\))' # signature
326
- r'(' + _ws + r')({)',
333
+ r'(' + _ws + r')?({)',
327
334
  bygroups(using(this), Name.Function, using(this), using(this),
328
335
  Punctuation),
329
336
  'function'),
@@ -331,7 +338,7 @@ class ECLexer(RegexLexer):
331
338
  (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
332
339
  r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
333
340
  r'(\s*\([^;]*?\))' # signature
334
- r'(' + _ws + r')(;)',
341
+ r'(' + _ws + r')?(;)',
335
342
  bygroups(using(this), Name.Function, using(this), using(this),
336
343
  Punctuation)),
337
344
  ('', Text, 'statement'),
@@ -1102,12 +1109,14 @@ class ObjectiveCLexer(RegexLexer):
1102
1109
 
1103
1110
  name = 'Objective-C'
1104
1111
  aliases = ['objective-c', 'objectivec', 'obj-c', 'objc']
1105
- #XXX: objc has .h files too :-/
1112
+ # XXX: objc has .h files too :-/
1106
1113
  filenames = ['*.m']
1107
1114
  mimetypes = ['text/x-objective-c']
1108
1115
 
1109
1116
  #: optional Comment or Whitespace
1110
1117
  _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
1118
+ #: only one /* */ style comment
1119
+ _ws1 = r':\s*/[*].*?[*]/\s*'
1111
1120
 
1112
1121
  tokens = {
1113
1122
  'whitespace': [
@@ -1115,8 +1124,10 @@ class ObjectiveCLexer(RegexLexer):
1115
1124
  ('^#if\s+0', Comment.Preproc, 'if0'),
1116
1125
  ('^#', Comment.Preproc, 'macro'),
1117
1126
  # or with whitespace
1118
- ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
1119
- ('^' + _ws + '#', Comment.Preproc, 'macro'),
1127
+ ('^(' + _ws1 + r')(#if\s+0)',
1128
+ bygroups(using(this), Comment.Preproc), 'if0'),
1129
+ ('^(' + _ws1 + ')(#)',
1130
+ bygroups(using(this), Comment.Preproc), 'macro'),
1120
1131
  (r'\n', Text),
1121
1132
  (r'\s+', Text),
1122
1133
  (r'\\\n', Text), # line continuation
@@ -1139,7 +1150,7 @@ class ObjectiveCLexer(RegexLexer):
1139
1150
  r'switch|typedef|union|volatile|virtual|while|in|@selector|'
1140
1151
  r'@private|@protected|@public|@encode|'
1141
1152
  r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
1142
- r'@synthesize|@dynamic)\b', Keyword),
1153
+ r'@synthesize|@dynamic|@optional)\b', Keyword),
1143
1154
  (r'(int|long|float|short|double|char|unsigned|signed|void|'
1144
1155
  r'id|BOOL|IBOutlet|IBAction|SEL)\b', Keyword.Type),
1145
1156
  (r'(_{0,2}inline|naked|restrict|thread|typename)\b',
@@ -1149,6 +1160,10 @@ class ObjectiveCLexer(RegexLexer):
1149
1160
  (r'(TRUE|FALSE|nil|NULL)\b', Name.Builtin),
1150
1161
  ('[a-zA-Z$_][a-zA-Z0-9$_]*:(?!:)', Name.Label),
1151
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')),
1152
1167
  ],
1153
1168
  'root': [
1154
1169
  include('whitespace'),
@@ -1156,7 +1171,7 @@ class ObjectiveCLexer(RegexLexer):
1156
1171
  (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
1157
1172
  r'([a-zA-Z$_][a-zA-Z0-9$_]*)' # method name
1158
1173
  r'(\s*\([^;]*?\))' # signature
1159
- r'(' + _ws + r')({)',
1174
+ r'(' + _ws + r')?({)',
1160
1175
  bygroups(using(this), Name.Function,
1161
1176
  using(this), Text, Punctuation),
1162
1177
  'function'),
@@ -1171,7 +1186,7 @@ class ObjectiveCLexer(RegexLexer):
1171
1186
  (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
1172
1187
  r'([a-zA-Z$_][a-zA-Z0-9$_]*)' # method name
1173
1188
  r'(\s*\([^;]*?\))' # signature
1174
- r'(' + _ws + r')(;)',
1189
+ r'(' + _ws + r')?(;)',
1175
1190
  bygroups(using(this), Name.Function,
1176
1191
  using(this), Text, Punctuation)),
1177
1192
  (r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
@@ -1212,6 +1227,10 @@ class ObjectiveCLexer(RegexLexer):
1212
1227
  ],
1213
1228
  'method': [
1214
1229
  include('whitespace'),
1230
+ # TODO unsure if ellipses are allowed elsewhere, see discussion in
1231
+ # Issue 789
1232
+ (r',', Punctuation),
1233
+ (r'\.\.\.', Punctuation),
1215
1234
  (r'(\(.*?\))([a-zA-Z$_][a-zA-Z0-9$_]*)', bygroups(using(this),
1216
1235
  Name.Variable)),
1217
1236
  (r'[a-zA-Z$_][a-zA-Z0-9$_]*:', Name.Function),
@@ -1436,7 +1455,8 @@ class PrologLexer(RegexLexer):
1436
1455
  (r"'(?:''|[^'])*'", String.Atom), # quoted atom
1437
1456
  # Needs to not be followed by an atom.
1438
1457
  #(r'=(?=\s|[a-zA-Z\[])', Operator),
1439
- (r'(is|<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])',
1458
+ (r'is\b', Operator),
1459
+ (r'(<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])',
1440
1460
  Operator),
1441
1461
  (r'(mod|div|not)\b', Operator),
1442
1462
  (r'_', Keyword), # The don't-care variable
@@ -1807,19 +1827,34 @@ class GoLexer(RegexLexer):
1807
1827
  (r'\\\n', Text), # line continuations
1808
1828
  (r'//(.*?)\n', Comment.Single),
1809
1829
  (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
1810
- (r'(break|default|func|interface|select'
1811
- r'|case|defer|go|map|struct'
1812
- r'|chan|else|goto|package|switch'
1813
- r'|const|fallthrough|if|range|type'
1814
- r'|continue|for|import|return|var)\b', Keyword
1830
+ (r'(import|package)\b', Keyword.Namespace),
1831
+ (r'(var|func|struct|map|chan|type|interface|const)\b', Keyword.Declaration),
1832
+ (r'(break|default|select|case|defer|go'
1833
+ r'|else|goto|switch|fallthrough|if|range'
1834
+ r'|continue|for|return)\b', Keyword
1835
+ ),
1836
+ (r'(true|false|iota|nil)\b', Keyword.Constant),
1837
+ # It seems the builtin types aren't actually keywords, but
1838
+ # can be used as functions. So we need two declarations.
1839
+ (r'(uint|uint8|uint16|uint32|uint64'
1840
+ r'|int|int8|int16|int32|int64'
1841
+ r'|float|float32|float64'
1842
+ r'|complex64|complex128|byte|rune'
1843
+ r'|string|bool|error|uintptr'
1844
+ r'|print|println|panic|recover|close|complex|real|imag'
1845
+ r'|len|cap|append|copy|delete|new|make)\b(\()', bygroups(Name.Builtin, Punctuation)
1815
1846
  ),
1816
- # It seems the builtin types aren't actually keywords.
1817
- (r'(uint8|uint16|uint32|uint64'
1818
- r'|int8|int16|int32|int64'
1819
- r'|float32|float64|byte'
1820
- r'|uint|int|float|uintptr'
1821
- r'|string|close|closed|len|cap|new|make)\b', Name.Builtin
1847
+ (r'(uint|uint8|uint16|uint32|uint64'
1848
+ r'|int|int8|int16|int32|int64'
1849
+ r'|float|float32|float64'
1850
+ r'|complex64|complex128|byte|rune'
1851
+ r'|string|bool|error|uintptr)\b', Keyword.Type
1822
1852
  ),
1853
+ # imaginary_lit
1854
+ (r'\d+i', Number),
1855
+ (r'\d+\.\d*([Ee][-+]\d+)?i', Number),
1856
+ (r'\.\d+([Ee][-+]\d+)?i', Number),
1857
+ (r'\d+[Ee][-+]\d+i', Number),
1823
1858
  # float_lit
1824
1859
  (r'\d+(\.\d+[eE][+\-]?\d+|'
1825
1860
  r'\.\d*|[eE][+\-]?\d+)', Number.Float),
@@ -1843,11 +1878,10 @@ class GoLexer(RegexLexer):
1843
1878
  (r'"(\\\\|\\"|[^"])*"', String),
1844
1879
  # Tokens
1845
1880
  (r'(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\|'
1846
- r'|<-|\+\+|--|==|!=|:=|\.\.\.)|[+\-*/%&|^<>=!()\[\]{}.,;:]',
1847
- Punctuation
1848
- ),
1881
+ r'|<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])', Operator),
1882
+ (r'[|^<>=!()\[\]{}.,;:]', Punctuation),
1849
1883
  # identifier
1850
- (r'[a-zA-Z_]\w*', Name),
1884
+ (r'[a-zA-Z_]\w*', Name.Other),
1851
1885
  ]
1852
1886
  }
1853
1887
 
@@ -2120,8 +2154,6 @@ class AdaLexer(RegexLexer):
2120
2154
 
2121
2155
  flags = re.MULTILINE | re.I # Ignore case
2122
2156
 
2123
- _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
2124
-
2125
2157
  tokens = {
2126
2158
  'root': [
2127
2159
  (r'[^\S\n]+', Text),
@@ -2889,3 +2921,263 @@ class FantomLexer(RegexLexer):
2889
2921
  (r'.', Text)
2890
2922
  ],
2891
2923
  }
2924
+
2925
+
2926
+ class RustLexer(RegexLexer):
2927
+ """
2928
+ Lexer for Mozilla's Rust programming language.
2929
+
2930
+ *New in Pygments 1.6.*
2931
+ """
2932
+ name = 'Rust'
2933
+ filenames = ['*.rs', '*.rc']
2934
+ aliases = ['rust']
2935
+ mimetypes = ['text/x-rustsrc']
2936
+
2937
+ tokens = {
2938
+ 'root': [
2939
+ # Whitespace and Comments
2940
+ (r'\n', Text),
2941
+ (r'\s+', Text),
2942
+ (r'//(.*?)\n', Comment.Single),
2943
+ (r'/[*](.|\n)*?[*]/', Comment.Multiline),
2944
+
2945
+ # 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),
2953
+
2954
+ # Character Literal
2955
+ (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
2956
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
2957
+ String.Char),
2958
+ # Binary Literal
2959
+ (r'0[Bb][01_]+', Number, 'number_lit'),
2960
+ # Octal Literal
2961
+ (r'0[0-7_]+', Number.Oct, 'number_lit'),
2962
+ # Hexadecimal Literal
2963
+ (r'0[xX][0-9a-fA-F_]+', Number.Hex, 'number_lit'),
2964
+ # Decimal Literal
2965
+ (r'[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?'
2966
+ r'[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)?', Number, 'number_lit'),
2967
+ # String Literal
2968
+ (r'"', String, 'string'),
2969
+
2970
+ # Operators and Punctuation
2971
+ (r'[{}()\[\],.;]', Punctuation),
2972
+ (r'[+\-*/%&|<>^!~@=:?]', Operator),
2973
+
2974
+ # Identifier
2975
+ (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
2976
+
2977
+ # Attributes
2978
+ (r'#\[', Comment.Preproc, 'attribute['),
2979
+ (r'#\(', Comment.Preproc, 'attribute('),
2980
+ # 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('),
2983
+ ],
2984
+ 'number_lit': [
2985
+ (r'(([ui](8|16|32|64)?)|(f(32|64)?))?', Keyword, '#pop'),
2986
+ ],
2987
+ 'string': [
2988
+ (r'"', String, '#pop'),
2989
+ (r"""\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
2990
+ r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}""", String.Escape),
2991
+ (r'[^\\"]+', String),
2992
+ (r'\\', String),
2993
+ ],
2994
+ 'attribute_common': [
2995
+ (r'"', String, 'string'),
2996
+ (r'\[', Comment.Preproc, 'attribute['),
2997
+ (r'\(', Comment.Preproc, 'attribute('),
2998
+ ],
2999
+ 'attribute[': [
3000
+ include('attribute_common'),
3001
+ (r'\];?', Comment.Preproc, '#pop'),
3002
+ (r'[^"\]]+', Comment.Preproc),
3003
+ ],
3004
+ 'attribute(': [
3005
+ include('attribute_common'),
3006
+ (r'\);?', Comment.Preproc, '#pop'),
3007
+ (r'[^"\)]+', Comment.Preproc),
3008
+ ],
3009
+ }
3010
+
3011
+
3012
+ class CudaLexer(CLexer):
3013
+ """
3014
+ For NVIDIA `CUDA™ <http://developer.nvidia.com/category/zone/cuda-zone>`_
3015
+ source.
3016
+
3017
+ *New in Pygments 1.6.*
3018
+ """
3019
+ name = 'CUDA'
3020
+ filenames = ['*.cu', '*.cuh']
3021
+ aliases = ['cuda', 'cu']
3022
+ mimetypes = ['text/x-cuda']
3023
+
3024
+ function_qualifiers = ['__device__', '__global__', '__host__',
3025
+ '__noinline__', '__forceinline__']
3026
+ variable_qualifiers = ['__device__', '__constant__', '__shared__',
3027
+ '__restrict__']
3028
+ vector_types = ['char1', 'uchar1', 'char2', 'uchar2', 'char3', 'uchar3',
3029
+ 'char4', 'uchar4', 'short1', 'ushort1', 'short2', 'ushort2',
3030
+ 'short3', 'ushort3', 'short4', 'ushort4', 'int1', 'uint1',
3031
+ 'int2', 'uint2', 'int3', 'uint3', 'int4', 'uint4', 'long1',
3032
+ 'ulong1', 'long2', 'ulong2', 'long3', 'ulong3', 'long4',
3033
+ 'ulong4', 'longlong1', 'ulonglong1', 'longlong2',
3034
+ 'ulonglong2', 'float1', 'float2', 'float3', 'float4',
3035
+ 'double1', 'double2', 'dim3']
3036
+ variables = ['gridDim', 'blockIdx', 'blockDim', 'threadIdx', 'warpSize']
3037
+ functions = ['__threadfence_block', '__threadfence', '__threadfence_system',
3038
+ '__syncthreads', '__syncthreads_count', '__syncthreads_and',
3039
+ '__syncthreads_or']
3040
+ execution_confs = ['<<<', '>>>']
3041
+
3042
+ def get_tokens_unprocessed(self, text):
3043
+ for index, token, value in \
3044
+ CLexer.get_tokens_unprocessed(self, text):
3045
+ if token is Name:
3046
+ if value in self.variable_qualifiers:
3047
+ token = Keyword.Type
3048
+ elif value in self.vector_types:
3049
+ token = Keyword.Type
3050
+ elif value in self.variables:
3051
+ token = Name.Builtin
3052
+ elif value in self.execution_confs:
3053
+ token = Keyword.Pseudo
3054
+ elif value in self.function_qualifiers:
3055
+ token = Keyword.Reserved
3056
+ elif value in self.functions:
3057
+ token = Name.Function
3058
+ yield index, token, value
3059
+
3060
+
3061
+ class MonkeyLexer(RegexLexer):
3062
+ """
3063
+ For
3064
+ `Monkey <https://en.wikipedia.org/wiki/Monkey_(programming_language)>`_
3065
+ source code.
3066
+
3067
+ *New in Pygments 1.6.*
3068
+ """
3069
+
3070
+ name = 'Monkey'
3071
+ aliases = ['monkey']
3072
+ filenames = ['*.monkey']
3073
+ mimetypes = ['text/x-monkey']
3074
+
3075
+ name_variable = r'[a-z_][a-zA-Z0-9_]*'
3076
+ name_function = r'[A-Z][a-zA-Z0-9_]*'
3077
+ name_constant = r'[A-Z_][A-Z0-9_]*'
3078
+ name_class = r'[A-Z][a-zA-Z0-9_]*'
3079
+ name_module = r'[a-z0-9_]*'
3080
+
3081
+ keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)'
3082
+ # ? == Bool // % == Int // # == Float // $ == String
3083
+ keyword_type_special = r'[?%#$]'
3084
+
3085
+ flags = re.MULTILINE
3086
+
3087
+ tokens = {
3088
+ 'root': [
3089
+ #Text
3090
+ (r'\s+', Text),
3091
+ # Comments
3092
+ (r"'.*", Comment),
3093
+ (r'(?i)^#rem\b', Comment.Multiline, 'comment'),
3094
+ # preprocessor directives
3095
+ (r'(?i)^(?:#If|#ElseIf|#Else|#EndIf|#End|#Print|#Error)\b', Comment.Preproc),
3096
+ # preprocessor variable (any line starting with '#' that is not a directive)
3097
+ (r'^#', Comment.Preproc, 'variables'),
3098
+ # String
3099
+ ('"', String.Double, 'string'),
3100
+ # Numbers
3101
+ (r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
3102
+ (r'\.[0-9]+(?!\.)', Number.Float),
3103
+ (r'[0-9]+', Number.Integer),
3104
+ (r'\$[0-9a-fA-Z]+', Number.Hex),
3105
+ (r'\%[10]+', Number), # Binary
3106
+ # Native data types
3107
+ (r'\b%s\b' % keyword_type, Keyword.Type),
3108
+ # Exception handling
3109
+ (r'(?i)\b(?:Try|Catch|Throw)\b', Keyword.Reserved),
3110
+ (r'Throwable', Name.Exception),
3111
+ # Builtins
3112
+ (r'(?i)\b(?:Null|True|False)\b', Name.Builtin),
3113
+ (r'(?i)\b(?:Self|Super)\b', Name.Builtin.Pseudo),
3114
+ (r'\b(?:HOST|LANG|TARGET|CONFIG)\b', Name.Constant),
3115
+ # Keywords
3116
+ (r'(?i)^(Import)(\s+)(.*)(\n)', bygroups(Keyword.Namespace, Text, Name.Namespace, Text)),
3117
+ (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),
3122
+ # Flow Control stuff
3123
+ (r'(?i)(?:If|Then|Else|ElseIf|EndIf|'
3124
+ r'Select|Case|Default|'
3125
+ r'While|Wend|'
3126
+ r'Repeat|Until|Forever|'
3127
+ r'For|To|Until|Step|EachIn|Next|'
3128
+ r'Exit|Continue)\s+', Keyword.Reserved),
3129
+ # not used yet
3130
+ (r'(?i)\b(?:Module|Inline)\b', Keyword.Reserved),
3131
+ # Array
3132
+ (r'[\[\]]', Punctuation),
3133
+ # Other
3134
+ (r'<=|>=|<>|\*=|/=|\+=|-=|&=|~=|\|=|[-&*/^+=<>|~]', Operator),
3135
+ (r'(?i)(?:Not|Mod|Shl|Shr|And|Or)', Operator.Word),
3136
+ (r'[\(\){}!#,.:]', Punctuation),
3137
+ # catch the rest
3138
+ (r'%s\b' % name_constant, Name.Constant),
3139
+ (r'%s\b' % name_function, Name.Function),
3140
+ (r'%s\b' % name_variable, Name.Variable),
3141
+ ],
3142
+ 'funcname': [
3143
+ (r'(?i)%s\b' % name_function, Name.Function),
3144
+ (r':', Punctuation, 'classname'),
3145
+ (r'\s+', Text),
3146
+ (r'\(', Punctuation, 'variables'),
3147
+ (r'\)', Punctuation, '#pop')
3148
+ ],
3149
+ 'classname': [
3150
+ (r'%s\.' % name_module, Name.Namespace),
3151
+ (r'%s\b' % keyword_type, Keyword.Type),
3152
+ (r'%s\b' % name_class, Name.Class),
3153
+ # array (of given size)
3154
+ (r'(\[)(\s*)(\d*)(\s*)(\])',
3155
+ bygroups(Punctuation, Text, Number.Integer, Text, Punctuation)),
3156
+ # generics
3157
+ (r'\s+(?!<)', Text, '#pop'),
3158
+ (r'<', Punctuation, '#push'),
3159
+ (r'>', Punctuation, '#pop'),
3160
+ (r'\n', Text, '#pop'),
3161
+ (r'', Text, '#pop')
3162
+ ],
3163
+ 'variables': [
3164
+ (r'%s\b' % name_constant, Name.Constant),
3165
+ (r'%s\b' % name_variable, Name.Variable),
3166
+ (r'%s' % keyword_type_special, Keyword.Type),
3167
+ (r'\s+', Text),
3168
+ (r':', Punctuation, 'classname'),
3169
+ (r',', Punctuation, '#push'),
3170
+ (r'', Text, '#pop')
3171
+ ],
3172
+ 'string': [
3173
+ (r'[^"~]+', String.Double),
3174
+ (r'~q|~n|~r|~t|~z|~~', String.Escape),
3175
+ (r'"', String.Double, '#pop'),
3176
+ ],
3177
+ 'comment' : [
3178
+ (r'(?i)^#rem.*?', Comment.Multiline, "#push"),
3179
+ (r'(?i)^#end.*?', Comment.Multiline, "#pop"),
3180
+ (r'\n', Comment.Multiline),
3181
+ (r'.+', Comment.Multiline),
3182
+ ],
3183
+ }