pygments.rb 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  changelog
2
2
  ===========
3
3
 
4
+ Version 0.5.1 (June 25, 2013)
5
+ -----------------------------
6
+
7
+ * Ensure compatability across distros by detecting if `python2` is available
8
+
4
9
  Version 0.5.0 (Apr 13, 2013)
5
10
  -----------------------------
6
11
 
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
  gemspec
data/lexers CHANGED
Binary file
@@ -141,6 +141,7 @@ module Pygments
141
141
  hash["Augeas"] = {:name=>"Augeas", :aliases=>["augeas"], :filenames=>["*.aug"], :mimetypes=>[]}
142
142
  hash["dasm16"] = {:name=>"dasm16", :aliases=>["DASM16"], :filenames=>["*.dasm16", "*.dasm"], :mimetypes=>['text/x-dasm16']}
143
143
  hash["Puppet"] = {:name=>"Puppet", :aliases=>["puppet"], :filenames=>["*.pp"], :mimetypes=>[]}
144
+ hash["Slash"] = {:name=>"Slash", :aliases=>["slash"], :filenames=>["*.sl"], :mimetypes=>[]}
144
145
  hash
145
146
  end
146
147
  end
@@ -1,3 +1,3 @@
1
1
  module Pygments
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
@@ -10,11 +10,12 @@
10
10
  """
11
11
  import re
12
12
 
13
- from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer
13
+ from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, bygroups, \
14
+ using, DelegatingLexer
14
15
  from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
15
- Other, Keyword, Operator, Literal
16
+ Other, Keyword, Operator, Literal, Whitespace
16
17
 
17
- __all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer', "TOMLLexer"]
18
+ __all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer', "TOMLLexer", "SlashLexer"]
18
19
 
19
20
  class Dasm16Lexer(RegexLexer):
20
21
  """
@@ -398,4 +399,161 @@ class TOMLLexer(RegexLexer):
398
399
  ]
399
400
  }
400
401
 
402
+ class SlashLanguageLexer(ExtendedRegexLexer):
403
+ _nkw = r'(?=[^a-zA-Z_0-9])'
404
+
405
+ def move_state(new_state):
406
+ return ("#pop", new_state)
407
+
408
+ def right_angle_bracket(lexer, match, ctx):
409
+ if len(ctx.stack) > 1 and ctx.stack[-2] == "string":
410
+ ctx.stack.pop()
411
+ yield match.start(), Punctuation, "}"
412
+ ctx.pos = match.end()
413
+ pass
414
+
415
+ tokens = {
416
+ "root": [
417
+ (r"<%=", Comment.Preproc, move_state("slash")),
418
+ (r"<%!!", Comment.Preproc, move_state("slash")),
419
+ (r"<%#.*?%>", Comment.Multiline),
420
+ (r"<%", Comment.Preproc, move_state("slash")),
421
+ (r".|\n", Other),
422
+ ],
423
+ "string": [
424
+ (r"\\", String.Escape, move_state("string_e")),
425
+ (r"\"", String, move_state("slash")),
426
+ (r"#\{", Punctuation, "slash"),
427
+ (r'.|\n', String),
428
+ ],
429
+ "string_e": [
430
+ (r'n', String.Escape, move_state("string")),
431
+ (r't', String.Escape, move_state("string")),
432
+ (r'r', String.Escape, move_state("string")),
433
+ (r'e', String.Escape, move_state("string")),
434
+ (r'x[a-fA-F0-9]{2}', String.Escape, move_state("string")),
435
+ (r'.', String.Escape, move_state("string")),
436
+ ],
437
+ "regexp": [
438
+ (r'}[a-z]*', String.Regex, move_state("slash")),
439
+ (r'\\(.|\n)', String.Regex),
440
+ (r'{', String.Regex, "regexp_r"),
441
+ (r'.|\n', String.Regex),
442
+ ],
443
+ "regexp_r": [
444
+ (r'}[a-z]*', String.Regex, "#pop"),
445
+ (r'\\(.|\n)', String.Regex),
446
+ (r'{', String.Regex, "regexp_r"),
447
+ ],
448
+ "slash": [
449
+ (r"%>", Comment.Preproc, move_state("root")),
450
+ (r"\"", String, move_state("string")),
451
+ (r"'[a-zA-Z0-9_]+", String),
452
+ (r'%r{', String.Regex, move_state("regexp")),
453
+ (r'/\*.*?\*/', Comment.Multiline),
454
+ (r"(#|//).*?\n", Comment.Single),
455
+ (r'-?[0-9]+e[+-]?[0-9]+', Number.Float),
456
+ (r'-?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?', Number.Float),
457
+ (r'-?[0-9]+', Number.Integer),
458
+ (r'nil'+_nkw, Name.Builtin),
459
+ (r'true'+_nkw, Name.Builtin),
460
+ (r'false'+_nkw, Name.Builtin),
461
+ (r'self'+_nkw, Name.Builtin),
462
+ (r'class'+_nkw, Keyword),
463
+ (r'extends'+_nkw, Keyword),
464
+ (r'def'+_nkw, Keyword),
465
+ (r'if'+_nkw, Keyword),
466
+ (r'elsif'+_nkw, Keyword),
467
+ (r'else'+_nkw, Keyword),
468
+ (r'unless'+_nkw, Keyword),
469
+ (r'for'+_nkw, Keyword),
470
+ (r'in'+_nkw, Keyword),
471
+ (r'while'+_nkw, Keyword),
472
+ (r'until'+_nkw, Keyword),
473
+ (r'and'+_nkw, Keyword),
474
+ (r'or'+_nkw, Keyword),
475
+ (r'not'+_nkw, Keyword),
476
+ (r'lambda'+_nkw, Keyword),
477
+ (r'try'+_nkw, Keyword),
478
+ (r'catch'+_nkw, Keyword),
479
+ (r'return'+_nkw, Keyword),
480
+ (r'next'+_nkw, Keyword),
481
+ (r'last'+_nkw, Keyword),
482
+ (r'throw'+_nkw, Keyword),
483
+ (r'use'+_nkw, Keyword),
484
+ (r'switch'+_nkw, Keyword),
485
+ (r'\\'+_nkw, Keyword),
486
+ (r'λ'+_nkw, Keyword),
487
+ (r'__FILE__'+_nkw, Name.Builtin.Pseudo),
488
+ (r'__LINE__'+_nkw, Name.Builtin.Pseudo),
489
+ (r'[A-Z][a-zA-Z0-9_]*'+_nkw, Name.Constant),
490
+ (r'[a-z_][a-zA-Z0-9_]*'+_nkw, Name.Variable),
491
+ (r'@[a-z_][a-zA-Z0-9_]*'+_nkw, Name.Variable.Instance),
492
+ (r'@@[a-z_][a-zA-Z0-9_]*'+_nkw, Name.Variable.Class),
493
+ (r'\(', Punctuation),
494
+ (r'\)', Punctuation),
495
+ (r'\[', Punctuation),
496
+ (r'\]', Punctuation),
497
+ (r'\{', Punctuation),
498
+ (r'\}', right_angle_bracket),
499
+ (r';', Punctuation),
500
+ (r',', Punctuation),
501
+ (r'<<=', Operator),
502
+ (r'>>=', Operator),
503
+ (r'<<', Operator),
504
+ (r'>>', Operator),
505
+ (r'==', Operator),
506
+ (r'!=', Operator),
507
+ (r'=>', Operator),
508
+ (r'=', Operator),
509
+ (r'<=>', Operator),
510
+ (r'<=', Operator),
511
+ (r'>=', Operator),
512
+ (r'<', Operator),
513
+ (r'>', Operator),
514
+ (r'\+\+', Operator),
515
+ (r'\+=', Operator),
516
+ (r'-=', Operator),
517
+ (r'\*\*=', Operator),
518
+ (r'\*=', Operator),
519
+ (r'\*\*', Operator),
520
+ (r'\*', Operator),
521
+ (r'/=', Operator),
522
+ (r'\+', Operator),
523
+ (r'-', Operator),
524
+ (r'/', Operator),
525
+ (r'%=', Operator),
526
+ (r'%', Operator),
527
+ (r'^=', Operator),
528
+ (r'&&=', Operator),
529
+ (r'&=', Operator),
530
+ (r'&&', Operator),
531
+ (r'&', Operator),
532
+ (r'\|\|=', Operator),
533
+ (r'\|=', Operator),
534
+ (r'\|\|', Operator),
535
+ (r'\|', Operator),
536
+ (r'!', Operator),
537
+ (r'\.\.\.', Operator),
538
+ (r'\.\.', Operator),
539
+ (r'\.', Operator),
540
+ (r'::', Operator),
541
+ (r':', Operator),
542
+ (r'(\s|\n)+', Whitespace),
543
+ (r'[a-z_][a-zA-Z0-9_]*', Name.Variable),
544
+ ],
545
+ }
546
+
547
+ class SlashLexer(DelegatingLexer):
548
+ """
549
+ Lexer for the Slash programming language.
550
+ """
551
+
552
+ name = 'Slash'
553
+ aliases = ['slash']
554
+ filenames = ['*.sl']
555
+
556
+ def __init__(self, **options):
557
+ from pygments.lexers.web import HtmlLexer
558
+ super(SlashLexer, self).__init__(HtmlLexer, SlashLanguageLexer, **options)
401
559
 
@@ -222,7 +222,6 @@ LEXERS = {
222
222
  'PropertiesLexer': ('pygments.lexers.text', 'Properties', ('properties',), ('*.properties',), ('text/x-java-properties',)),
223
223
  'ProtoBufLexer': ('pygments.lexers.other', 'Protocol Buffer', ('protobuf',), ('*.proto',), ()),
224
224
  'PuppetLexer': ('pygments.lexers.github', 'Puppet', ('puppet',), ('*.pp',), ()),
225
- 'PuppetLexer': ('pygments.lexers.other', 'Puppet', ('puppet',), ('*.pp',), ()),
226
225
  'PyPyLogLexer': ('pygments.lexers.text', 'PyPy Log', ('pypylog', 'pypy'), ('*.pypylog',), ('application/x-pypylog',)),
227
226
  'Python3Lexer': ('pygments.lexers.agile', 'Python 3', ('python3', 'py3'), (), ('text/x-python3', 'application/x-python3')),
228
227
  'Python3TracebackLexer': ('pygments.lexers.agile', 'Python 3.0 Traceback', ('py3tb',), ('*.py3tb',), ('text/x-python3-traceback',)),
@@ -261,6 +260,7 @@ LEXERS = {
261
260
  'ScilabLexer': ('pygments.lexers.math', 'Scilab', ('scilab',), ('*.sci', '*.sce', '*.tst'), ('text/scilab',)),
262
261
  'ScssLexer': ('pygments.lexers.web', 'SCSS', ('scss',), ('*.scss',), ('text/x-scss',)),
263
262
  'ShellSessionLexer': ('pygments.lexers.shell', 'Shell Session', ('shell-session',), ('*.shell-session',), ('application/x-sh-session',)),
263
+ 'SlashLexer': ('pygments.lexers.github', 'Slash', ('slash',), ('*.sl',), ()),
264
264
  'SmaliLexer': ('pygments.lexers.dalvik', 'Smali', ('smali',), ('*.smali',), ('text/smali',)),
265
265
  'SmalltalkLexer': ('pygments.lexers.other', 'Smalltalk', ('smalltalk', 'squeak'), ('*.st',), ('text/x-smalltalk',)),
266
266
  'SmartyLexer': ('pygments.lexers.templates', 'Smarty', ('smarty',), ('*.tpl',), ('application/x-smarty',)),
@@ -10,11 +10,12 @@
10
10
  """
11
11
  import re
12
12
 
13
- from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer
13
+ from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, bygroups, \
14
+ using, DelegatingLexer
14
15
  from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
15
- Other, Keyword, Operator, Literal
16
+ Other, Keyword, Operator, Literal, Whitespace
16
17
 
17
- __all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer', "TOMLLexer"]
18
+ __all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer', "TOMLLexer", "SlashLexer"]
18
19
 
19
20
  class Dasm16Lexer(RegexLexer):
20
21
  """
@@ -398,4 +399,161 @@ class TOMLLexer(RegexLexer):
398
399
  ]
399
400
  }
400
401
 
402
+ class SlashLanguageLexer(ExtendedRegexLexer):
403
+ _nkw = r'(?=[^a-zA-Z_0-9])'
404
+
405
+ def move_state(new_state):
406
+ return ("#pop", new_state)
407
+
408
+ def right_angle_bracket(lexer, match, ctx):
409
+ if len(ctx.stack) > 1 and ctx.stack[-2] == "string":
410
+ ctx.stack.pop()
411
+ yield match.start(), Punctuation, "}"
412
+ ctx.pos = match.end()
413
+ pass
414
+
415
+ tokens = {
416
+ "root": [
417
+ (r"<%=", Comment.Preproc, move_state("slash")),
418
+ (r"<%!!", Comment.Preproc, move_state("slash")),
419
+ (r"<%#.*?%>", Comment.Multiline),
420
+ (r"<%", Comment.Preproc, move_state("slash")),
421
+ (r".|\n", Other),
422
+ ],
423
+ "string": [
424
+ (r"\\", String.Escape, move_state("string_e")),
425
+ (r"\"", String, move_state("slash")),
426
+ (r"#\{", Punctuation, "slash"),
427
+ (r'.|\n', String),
428
+ ],
429
+ "string_e": [
430
+ (r'n', String.Escape, move_state("string")),
431
+ (r't', String.Escape, move_state("string")),
432
+ (r'r', String.Escape, move_state("string")),
433
+ (r'e', String.Escape, move_state("string")),
434
+ (r'x[a-fA-F0-9]{2}', String.Escape, move_state("string")),
435
+ (r'.', String.Escape, move_state("string")),
436
+ ],
437
+ "regexp": [
438
+ (r'}[a-z]*', String.Regex, move_state("slash")),
439
+ (r'\\(.|\n)', String.Regex),
440
+ (r'{', String.Regex, "regexp_r"),
441
+ (r'.|\n', String.Regex),
442
+ ],
443
+ "regexp_r": [
444
+ (r'}[a-z]*', String.Regex, "#pop"),
445
+ (r'\\(.|\n)', String.Regex),
446
+ (r'{', String.Regex, "regexp_r"),
447
+ ],
448
+ "slash": [
449
+ (r"%>", Comment.Preproc, move_state("root")),
450
+ (r"\"", String, move_state("string")),
451
+ (r"'[a-zA-Z0-9_]+", String),
452
+ (r'%r{', String.Regex, move_state("regexp")),
453
+ (r'/\*.*?\*/', Comment.Multiline),
454
+ (r"(#|//).*?\n", Comment.Single),
455
+ (r'-?[0-9]+e[+-]?[0-9]+', Number.Float),
456
+ (r'-?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?', Number.Float),
457
+ (r'-?[0-9]+', Number.Integer),
458
+ (r'nil'+_nkw, Name.Builtin),
459
+ (r'true'+_nkw, Name.Builtin),
460
+ (r'false'+_nkw, Name.Builtin),
461
+ (r'self'+_nkw, Name.Builtin),
462
+ (r'class'+_nkw, Keyword),
463
+ (r'extends'+_nkw, Keyword),
464
+ (r'def'+_nkw, Keyword),
465
+ (r'if'+_nkw, Keyword),
466
+ (r'elsif'+_nkw, Keyword),
467
+ (r'else'+_nkw, Keyword),
468
+ (r'unless'+_nkw, Keyword),
469
+ (r'for'+_nkw, Keyword),
470
+ (r'in'+_nkw, Keyword),
471
+ (r'while'+_nkw, Keyword),
472
+ (r'until'+_nkw, Keyword),
473
+ (r'and'+_nkw, Keyword),
474
+ (r'or'+_nkw, Keyword),
475
+ (r'not'+_nkw, Keyword),
476
+ (r'lambda'+_nkw, Keyword),
477
+ (r'try'+_nkw, Keyword),
478
+ (r'catch'+_nkw, Keyword),
479
+ (r'return'+_nkw, Keyword),
480
+ (r'next'+_nkw, Keyword),
481
+ (r'last'+_nkw, Keyword),
482
+ (r'throw'+_nkw, Keyword),
483
+ (r'use'+_nkw, Keyword),
484
+ (r'switch'+_nkw, Keyword),
485
+ (r'\\'+_nkw, Keyword),
486
+ (r'λ'+_nkw, Keyword),
487
+ (r'__FILE__'+_nkw, Name.Builtin.Pseudo),
488
+ (r'__LINE__'+_nkw, Name.Builtin.Pseudo),
489
+ (r'[A-Z][a-zA-Z0-9_]*'+_nkw, Name.Constant),
490
+ (r'[a-z_][a-zA-Z0-9_]*'+_nkw, Name.Variable),
491
+ (r'@[a-z_][a-zA-Z0-9_]*'+_nkw, Name.Variable.Instance),
492
+ (r'@@[a-z_][a-zA-Z0-9_]*'+_nkw, Name.Variable.Class),
493
+ (r'\(', Punctuation),
494
+ (r'\)', Punctuation),
495
+ (r'\[', Punctuation),
496
+ (r'\]', Punctuation),
497
+ (r'\{', Punctuation),
498
+ (r'\}', right_angle_bracket),
499
+ (r';', Punctuation),
500
+ (r',', Punctuation),
501
+ (r'<<=', Operator),
502
+ (r'>>=', Operator),
503
+ (r'<<', Operator),
504
+ (r'>>', Operator),
505
+ (r'==', Operator),
506
+ (r'!=', Operator),
507
+ (r'=>', Operator),
508
+ (r'=', Operator),
509
+ (r'<=>', Operator),
510
+ (r'<=', Operator),
511
+ (r'>=', Operator),
512
+ (r'<', Operator),
513
+ (r'>', Operator),
514
+ (r'\+\+', Operator),
515
+ (r'\+=', Operator),
516
+ (r'-=', Operator),
517
+ (r'\*\*=', Operator),
518
+ (r'\*=', Operator),
519
+ (r'\*\*', Operator),
520
+ (r'\*', Operator),
521
+ (r'/=', Operator),
522
+ (r'\+', Operator),
523
+ (r'-', Operator),
524
+ (r'/', Operator),
525
+ (r'%=', Operator),
526
+ (r'%', Operator),
527
+ (r'^=', Operator),
528
+ (r'&&=', Operator),
529
+ (r'&=', Operator),
530
+ (r'&&', Operator),
531
+ (r'&', Operator),
532
+ (r'\|\|=', Operator),
533
+ (r'\|=', Operator),
534
+ (r'\|\|', Operator),
535
+ (r'\|', Operator),
536
+ (r'!', Operator),
537
+ (r'\.\.\.', Operator),
538
+ (r'\.\.', Operator),
539
+ (r'\.', Operator),
540
+ (r'::', Operator),
541
+ (r':', Operator),
542
+ (r'(\s|\n)+', Whitespace),
543
+ (r'[a-z_][a-zA-Z0-9_]*', Name.Variable),
544
+ ],
545
+ }
546
+
547
+ class SlashLexer(DelegatingLexer):
548
+ """
549
+ Lexer for the Slash programming language.
550
+ """
551
+
552
+ name = 'Slash'
553
+ aliases = ['slash']
554
+ filenames = ['*.sl']
555
+
556
+ def __init__(self, **options):
557
+ from pygments.lexers.web import HtmlLexer
558
+ super(SlashLexer, self).__init__(HtmlLexer, SlashLanguageLexer, **options)
401
559
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pygments.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-25 00:00:00.000000000 Z
13
+ date: 2013-07-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yajl-ruby