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
@@ -0,0 +1,41 @@
1
+ a = -> [1 to 50]
2
+ const b = --> [2 til 5]
3
+ var c = ~~> 10_000_000km * 500ms - 16~ff / 32~lol
4
+ e = (a) -> (b) ~> (c) --> (d, e) ~~> <[list of words]>
5
+ dashes-identifiers = ->
6
+ a - a b -- c 1-1 1- -1 a- a a -a
7
+ underscores_i$d = ->
8
+ /regexp1/
9
+ //regexp2//g
10
+ 'strings' and "strings" and \strings
11
+
12
+ [2 til 10]
13
+ |> map (* 2)
14
+ |> filter (> 5)
15
+ |> fold (+)
16
+
17
+ obj =
18
+ prop1: 1
19
+ prop2: 2
20
+
21
+ class Class extends Anc-est-or
22
+ (args) ->
23
+ <- # Comment
24
+ <~ /* Comment */
25
+ void undefined yes no on off
26
+ a.void b.undefined c.off d.if f.no g.not
27
+ avoid bundefined coff dif fno gnot
28
+ "inter #{2 + 2} #variable"
29
+ '''HELLO 'world' '''
30
+
31
+ copy = (from, to, callback) -->
32
+ error, data <- read file
33
+ return callback error if error?
34
+ error <~ write file, data
35
+ return callback error if error?
36
+ callback()
37
+
38
+ take(n, [x, ...xs]:list) =
39
+ | n <= 0 => []
40
+ | empty list => []
41
+ | otherwise => [x] +++ take n - 1, xs
@@ -13,7 +13,8 @@ end
13
13
  a = rand(30);
14
14
  b = rand(30);
15
15
 
16
- c = a .* b ./ a \ (b .* a + b - a);
16
+ c = a .* b ./ a \ ... comment at end of line and continuation
17
+ (b .* a + b - a);
17
18
 
18
19
  c = a' * b'; % note: these ticks are for transpose, not quotes.
19
20
 
@@ -24,4 +25,6 @@ disp('a comment symbol, %, in a string');
24
25
  function y=myfunc(x)
25
26
  y = exp(x);
26
27
 
27
-
28
+ {%
29
+ a block comment
30
+ %}
@@ -0,0 +1,455 @@
1
+ module Treetop
2
+ module Compiler
3
+ grammar Metagrammar
4
+ rule treetop_file
5
+ requires:(space? require_statement)* prefix:space? module_or_grammar suffix:space? {
6
+ def compile
7
+ requires.text_value + prefix.text_value + module_or_grammar.compile + suffix.text_value
8
+ end
9
+ }
10
+ end
11
+
12
+ rule require_statement
13
+ prefix:space? "require" [ \t]+ [^\n\r]+ [\n\r]
14
+ end
15
+
16
+ rule module_or_grammar
17
+ module_declaration / grammar
18
+ end
19
+
20
+ rule module_declaration
21
+ prefix:('module' space name:([A-Z] alphanumeric_char* ('::' [A-Z] alphanumeric_char*)*) space) module_contents:(module_declaration / grammar) suffix:(space 'end') {
22
+ def compile
23
+ prefix.text_value + module_contents.compile + suffix.text_value
24
+ end
25
+
26
+ def parser_name
27
+ prefix.name.text_value+'::'+module_contents.parser_name
28
+ end
29
+ }
30
+ end
31
+
32
+ rule grammar
33
+ 'grammar' space grammar_name space ('do' space)? declaration_sequence space? 'end' <Grammar>
34
+ end
35
+
36
+ rule grammar_name
37
+ ([A-Z] alphanumeric_char*)
38
+ end
39
+
40
+ rule declaration_sequence
41
+ head:declaration tail:(space declaration)* <DeclarationSequence> {
42
+ def declarations
43
+ [head] + tail
44
+ end
45
+
46
+ def tail
47
+ super.elements.map { |elt| elt.declaration }
48
+ end
49
+ }
50
+ /
51
+ '' {
52
+ def compile(builder)
53
+ end
54
+ }
55
+ end
56
+
57
+ rule declaration
58
+ parsing_rule / include_declaration
59
+ end
60
+
61
+ rule include_declaration
62
+ 'include' space [A-Z] (alphanumeric_char / '::')* {
63
+ def compile(builder)
64
+ builder << text_value
65
+ end
66
+ }
67
+ end
68
+
69
+ rule parsing_rule
70
+ 'rule' space nonterminal space ('do' space)? parsing_expression space 'end' <ParsingRule>
71
+ end
72
+
73
+ rule parsing_expression
74
+ choice / sequence / primary
75
+ end
76
+
77
+ rule choice
78
+ head:alternative tail:(space? '/' space? alternative)+ <Choice> {
79
+ def alternatives
80
+ [head] + tail
81
+ end
82
+
83
+ def tail
84
+ super.elements.map {|elt| elt.alternative}
85
+ end
86
+
87
+ def inline_modules
88
+ (alternatives.map {|alt| alt.inline_modules }).flatten
89
+ end
90
+ }
91
+ end
92
+
93
+ rule sequence
94
+ head:labeled_sequence_primary tail:(space labeled_sequence_primary)+ node_class_declarations <Sequence> {
95
+ def sequence_elements
96
+ [head] + tail
97
+ end
98
+
99
+ def tail
100
+ super.elements.map {|elt| elt.labeled_sequence_primary }
101
+ end
102
+
103
+ def inline_modules
104
+ (sequence_elements.map {|elt| elt.inline_modules}).flatten +
105
+ [sequence_element_accessor_module] +
106
+ node_class_declarations.inline_modules
107
+ end
108
+
109
+ def inline_module_name
110
+ node_class_declarations.inline_module_name
111
+ end
112
+ }
113
+ end
114
+
115
+ rule alternative
116
+ sequence / primary
117
+ end
118
+
119
+ rule primary
120
+ prefix atomic {
121
+ def compile(address, builder, parent_expression=nil)
122
+ prefix.compile(address, builder, self)
123
+ end
124
+
125
+ def prefixed_expression
126
+ atomic
127
+ end
128
+
129
+ def inline_modules
130
+ atomic.inline_modules
131
+ end
132
+
133
+ def inline_module_name
134
+ nil
135
+ end
136
+ }
137
+ /
138
+ prefix space? predicate_block {
139
+ def compile(address, builder, parent_expression=nil)
140
+ prefix.compile(address, builder, self)
141
+ end
142
+ def prefixed_expression
143
+ predicate_block
144
+ end
145
+ def inline_modules
146
+ []
147
+ end
148
+ }
149
+ /
150
+ atomic suffix node_class_declarations {
151
+ def compile(address, builder, parent_expression=nil)
152
+ suffix.compile(address, builder, self)
153
+ end
154
+
155
+ def optional_expression
156
+ atomic
157
+ end
158
+
159
+ def node_class_name
160
+ node_class_declarations.node_class_name
161
+ end
162
+
163
+ def inline_modules
164
+ atomic.inline_modules + node_class_declarations.inline_modules
165
+ end
166
+
167
+ def inline_module_name
168
+ node_class_declarations.inline_module_name
169
+ end
170
+ }
171
+ /
172
+ atomic node_class_declarations {
173
+ def compile(address, builder, parent_expression=nil)
174
+ atomic.compile(address, builder, self)
175
+ end
176
+
177
+ def node_class_name
178
+ node_class_declarations.node_class_name
179
+ end
180
+
181
+ def inline_modules
182
+ atomic.inline_modules + node_class_declarations.inline_modules
183
+ end
184
+
185
+ def inline_module_name
186
+ node_class_declarations.inline_module_name
187
+ end
188
+ }
189
+ end
190
+
191
+ rule labeled_sequence_primary
192
+ label sequence_primary {
193
+ def compile(lexical_address, builder)
194
+ sequence_primary.compile(lexical_address, builder)
195
+ end
196
+
197
+ def inline_modules
198
+ sequence_primary.inline_modules
199
+ end
200
+
201
+ def label_name
202
+ if label.name
203
+ label.name
204
+ elsif sequence_primary.instance_of?(Nonterminal)
205
+ sequence_primary.text_value
206
+ else
207
+ nil
208
+ end
209
+ end
210
+ }
211
+ end
212
+
213
+ rule label
214
+ (alpha_char alphanumeric_char*) ':' {
215
+ def name
216
+ elements[0].text_value
217
+ end
218
+ }
219
+ /
220
+ '' {
221
+ def name
222
+ nil
223
+ end
224
+ }
225
+ end
226
+
227
+ rule sequence_primary
228
+ prefix atomic {
229
+ def compile(lexical_address, builder)
230
+ prefix.compile(lexical_address, builder, self)
231
+ end
232
+
233
+ def prefixed_expression
234
+ elements[1]
235
+ end
236
+
237
+ def inline_modules
238
+ atomic.inline_modules
239
+ end
240
+
241
+ def inline_module_name
242
+ nil
243
+ end
244
+ }
245
+ /
246
+ prefix space? predicate_block {
247
+ def compile(address, builder, parent_expression=nil)
248
+ prefix.compile(address, builder, self)
249
+ end
250
+ def prefixed_expression
251
+ predicate_block
252
+ end
253
+ def inline_modules
254
+ []
255
+ end
256
+ }
257
+ /
258
+ atomic suffix {
259
+ def compile(lexical_address, builder)
260
+ suffix.compile(lexical_address, builder, self)
261
+ end
262
+
263
+ def node_class_name
264
+ nil
265
+ end
266
+
267
+ def inline_modules
268
+ atomic.inline_modules
269
+ end
270
+
271
+ def inline_module_name
272
+ nil
273
+ end
274
+ }
275
+ /
276
+ atomic
277
+ end
278
+
279
+ rule suffix
280
+ repetition_suffix / optional_suffix
281
+ end
282
+
283
+ rule optional_suffix
284
+ '?' <Optional>
285
+ end
286
+
287
+ rule node_class_declarations
288
+ node_class_expression trailing_inline_module {
289
+ def node_class_name
290
+ node_class_expression.node_class_name
291
+ end
292
+
293
+ def inline_modules
294
+ trailing_inline_module.inline_modules
295
+ end
296
+
297
+ def inline_module
298
+ trailing_inline_module.inline_module
299
+ end
300
+
301
+ def inline_module_name
302
+ inline_module.module_name if inline_module
303
+ end
304
+ }
305
+ end
306
+
307
+ rule repetition_suffix
308
+ '+' <OneOrMore> / '*' <ZeroOrMore> / occurrence_range
309
+ end
310
+
311
+ rule occurrence_range
312
+ space? min:([0-9])* '..' max:([0-9])* <OccurrenceRange>
313
+ end
314
+
315
+ rule prefix
316
+ '&' <AndPredicate> / '!' <NotPredicate> / '~' <TransientPrefix>
317
+ end
318
+
319
+ rule atomic
320
+ terminal
321
+ /
322
+ nonterminal
323
+ /
324
+ parenthesized_expression
325
+ end
326
+
327
+ rule parenthesized_expression
328
+ '(' space? parsing_expression space? ')' <ParenthesizedExpression> {
329
+ def inline_modules
330
+ parsing_expression.inline_modules
331
+ end
332
+ }
333
+ end
334
+
335
+ rule nonterminal
336
+ !keyword_inside_grammar (alpha_char alphanumeric_char*) <Nonterminal>
337
+ end
338
+
339
+ rule terminal
340
+ quoted_string / character_class / anything_symbol
341
+ end
342
+
343
+ rule quoted_string
344
+ (single_quoted_string / double_quoted_string) {
345
+ def string
346
+ super.text_value
347
+ end
348
+ }
349
+ end
350
+
351
+ rule double_quoted_string
352
+ '"' string:(!'"' ("\\\\" / '\"' / .))* '"' <Terminal>
353
+ end
354
+
355
+ rule single_quoted_string
356
+ "'" string:(!"'" ("\\\\" / "\\'" / .))* "'" <Terminal>
357
+ end
358
+
359
+ rule character_class
360
+ '[' characters:(!']' ('\\' . / bracket_expression / !'\\' .))+ ']' <CharacterClass> {
361
+ def characters
362
+ super.text_value
363
+ end
364
+ }
365
+ end
366
+
367
+ rule bracket_expression
368
+ '[:' '^'? (
369
+ 'alnum' / 'alpha' / 'blank' / 'cntrl' / 'digit' / 'graph' / 'lower' /
370
+ 'print' / 'punct' / 'space' / 'upper' / 'xdigit' / 'word'
371
+ ) ':]'
372
+ end
373
+
374
+ rule anything_symbol
375
+ '.' <AnythingSymbol>
376
+ end
377
+
378
+ rule node_class_expression
379
+ space '<' (!'>' .)+ '>' {
380
+ def node_class_name
381
+ elements[2].text_value
382
+ end
383
+ }
384
+ /
385
+ '' {
386
+ def node_class_name
387
+ nil
388
+ end
389
+ }
390
+ end
391
+
392
+ rule trailing_inline_module
393
+ space inline_module {
394
+ def inline_modules
395
+ [inline_module]
396
+ end
397
+
398
+ def inline_module_name
399
+ inline_module.module_name
400
+ end
401
+ }
402
+ /
403
+ '' {
404
+ def inline_modules
405
+ []
406
+ end
407
+
408
+ def inline_module
409
+ nil
410
+ end
411
+
412
+ def inline_module_name
413
+ nil
414
+ end
415
+ }
416
+ end
417
+
418
+ rule predicate_block
419
+ '' inline_module <PredicateBlock>
420
+ end
421
+
422
+ rule inline_module
423
+ '{' (inline_module / ![{}] .)* '}' <InlineModule>
424
+ end
425
+
426
+ rule keyword_inside_grammar
427
+ ('rule' / 'end') !non_space_char
428
+ end
429
+
430
+ rule non_space_char
431
+ !space .
432
+ end
433
+
434
+ rule alpha_char
435
+ [A-Za-z_]
436
+ end
437
+
438
+ rule alphanumeric_char
439
+ alpha_char / [0-9]
440
+ end
441
+
442
+ rule space
443
+ (white / comment_to_eol)+
444
+ end
445
+
446
+ rule comment_to_eol
447
+ '#' (!"\n" .)*
448
+ end
449
+
450
+ rule white
451
+ [ \t\n\r]
452
+ end
453
+ end
454
+ end
455
+ end