pygments.rb 2.2.0 → 2.3.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 (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +12 -7
  3. data/.github/workflows/release.yml +5 -5
  4. data/CHANGELOG.adoc +9 -0
  5. data/README.adoc +1 -1
  6. data/bench.rb +2 -2
  7. data/lib/pygments/lexer.rb +1 -1
  8. data/lib/pygments/mentos.py +6 -4
  9. data/lib/pygments/popen.rb +20 -11
  10. data/lib/pygments/version.rb +1 -1
  11. data/lib/pygments.rb +8 -2
  12. data/pygments.rb.gemspec +4 -4
  13. data/test/test_pygments.rb +14 -8
  14. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/AUTHORS +8 -1
  15. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/INSTALLER +0 -0
  16. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/LICENSE +0 -0
  17. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/METADATA +1 -1
  18. data/vendor/pygments-main/Pygments-2.10.0.dist-info/RECORD +524 -0
  19. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/REQUESTED +0 -0
  20. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/WHEEL +0 -0
  21. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/entry_points.txt +0 -0
  22. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/top_level.txt +0 -0
  23. data/vendor/pygments-main/bin/pygmentize +1 -1
  24. data/vendor/pygments-main/pygments/__init__.py +1 -1
  25. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -0
  26. data/vendor/pygments-main/pygments/formatters/html.py +20 -7
  27. data/vendor/pygments-main/pygments/formatters/pangomarkup.py +83 -0
  28. data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +55 -14
  29. data/vendor/pygments-main/pygments/lexers/_julia_builtins.py +401 -0
  30. data/vendor/pygments-main/pygments/lexers/_mapping.py +68 -52
  31. data/vendor/pygments-main/pygments/lexers/actionscript.py +2 -2
  32. data/vendor/pygments-main/pygments/lexers/ambient.py +1 -1
  33. data/vendor/pygments-main/pygments/lexers/amdgpu.py +9 -4
  34. data/vendor/pygments-main/pygments/lexers/apdlexer.py +448 -0
  35. data/vendor/pygments-main/pygments/lexers/apl.py +6 -3
  36. data/vendor/pygments-main/pygments/lexers/asc.py +51 -0
  37. data/vendor/pygments-main/pygments/lexers/asm.py +86 -58
  38. data/vendor/pygments-main/pygments/lexers/automation.py +1 -1
  39. data/vendor/pygments-main/pygments/lexers/bibtex.py +2 -2
  40. data/vendor/pygments-main/pygments/lexers/c_cpp.py +60 -33
  41. data/vendor/pygments-main/pygments/lexers/c_like.py +102 -3
  42. data/vendor/pygments-main/pygments/lexers/cddl.py +2 -2
  43. data/vendor/pygments-main/pygments/lexers/chapel.py +53 -29
  44. data/vendor/pygments-main/pygments/lexers/clean.py +6 -6
  45. data/vendor/pygments-main/pygments/lexers/configs.py +133 -43
  46. data/vendor/pygments-main/pygments/lexers/csound.py +2 -2
  47. data/vendor/pygments-main/pygments/lexers/devicetree.py +1 -1
  48. data/vendor/pygments-main/pygments/lexers/dotnet.py +1 -1
  49. data/vendor/pygments-main/pygments/lexers/erlang.py +1 -1
  50. data/vendor/pygments-main/pygments/lexers/floscript.py +1 -1
  51. data/vendor/pygments-main/pygments/lexers/futhark.py +5 -4
  52. data/vendor/pygments-main/pygments/lexers/gcodelexer.py +36 -0
  53. data/vendor/pygments-main/pygments/lexers/go.py +1 -1
  54. data/vendor/pygments-main/pygments/lexers/graphics.py +1 -1
  55. data/vendor/pygments-main/pygments/lexers/graphviz.py +5 -4
  56. data/vendor/pygments-main/pygments/lexers/gsql.py +92 -0
  57. data/vendor/pygments-main/pygments/lexers/haskell.py +4 -4
  58. data/vendor/pygments-main/pygments/lexers/haxe.py +1 -1
  59. data/vendor/pygments-main/pygments/lexers/installers.py +2 -2
  60. data/vendor/pygments-main/pygments/lexers/javascript.py +145 -127
  61. data/vendor/pygments-main/pygments/lexers/jslt.py +94 -0
  62. data/vendor/pygments-main/pygments/lexers/julia.py +135 -183
  63. data/vendor/pygments-main/pygments/lexers/jvm.py +262 -202
  64. data/vendor/pygments-main/pygments/lexers/kuin.py +299 -0
  65. data/vendor/pygments-main/pygments/lexers/lisp.py +18 -15
  66. data/vendor/pygments-main/pygments/lexers/markup.py +3 -3
  67. data/vendor/pygments-main/pygments/lexers/matlab.py +23 -10
  68. data/vendor/pygments-main/pygments/lexers/meson.py +155 -0
  69. data/vendor/pygments-main/pygments/lexers/mime.py +6 -21
  70. data/vendor/pygments-main/pygments/lexers/ml.py +1 -1
  71. data/vendor/pygments-main/pygments/lexers/nimrod.py +1 -1
  72. data/vendor/pygments-main/pygments/lexers/objective.py +3 -3
  73. data/vendor/pygments-main/pygments/lexers/parsers.py +1 -1
  74. data/vendor/pygments-main/pygments/lexers/procfile.py +43 -0
  75. data/vendor/pygments-main/pygments/lexers/promql.py +1 -1
  76. data/vendor/pygments-main/pygments/lexers/python.py +19 -5
  77. data/vendor/pygments-main/pygments/lexers/resource.py +1 -1
  78. data/vendor/pygments-main/pygments/lexers/rnc.py +1 -1
  79. data/vendor/pygments-main/pygments/lexers/ruby.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/rust.py +9 -10
  81. data/vendor/pygments-main/pygments/lexers/scripting.py +7 -7
  82. data/vendor/pygments-main/pygments/lexers/shell.py +11 -8
  83. data/vendor/pygments-main/pygments/lexers/smithy.py +79 -0
  84. data/vendor/pygments-main/pygments/lexers/smv.py +1 -1
  85. data/vendor/pygments-main/pygments/lexers/special.py +15 -2
  86. data/vendor/pygments-main/pygments/lexers/supercollider.py +1 -1
  87. data/vendor/pygments-main/pygments/lexers/tcl.py +3 -3
  88. data/vendor/pygments-main/pygments/lexers/teal.py +88 -0
  89. data/vendor/pygments-main/pygments/lexers/templates.py +19 -19
  90. data/vendor/pygments-main/pygments/lexers/teraterm.py +1 -1
  91. data/vendor/pygments-main/pygments/lexers/testing.py +1 -1
  92. data/vendor/pygments-main/pygments/lexers/theorem.py +4 -2
  93. data/vendor/pygments-main/pygments/lexers/thingsdb.py +118 -0
  94. data/vendor/pygments-main/pygments/lexers/tnt.py +25 -15
  95. data/vendor/pygments-main/pygments/lexers/trafficscript.py +1 -1
  96. data/vendor/pygments-main/pygments/lexers/webassembly.py +120 -0
  97. data/vendor/pygments-main/pygments/regexopt.py +1 -1
  98. data/vendor/pygments-main/pygments/style.py +1 -1
  99. data/vendor/pygments-main/pygments/styles/__init__.py +2 -0
  100. data/vendor/pygments-main/pygments/styles/friendly.py +1 -0
  101. data/vendor/pygments-main/pygments/styles/gruvbox.py +107 -0
  102. data/vendor/pygments-main/pygments/styles/native.py +1 -0
  103. metadata +29 -14
  104. data/vendor/pygments-main/Pygments-2.8.1.dist-info/RECORD +0 -494
@@ -26,6 +26,38 @@ class ChapelLexer(RegexLexer):
26
26
  aliases = ['chapel', 'chpl']
27
27
  # mimetypes = ['text/x-chapel']
28
28
 
29
+ known_types = ('bool', 'bytes', 'complex', 'imag', 'int', 'locale',
30
+ 'nothing', 'opaque', 'range', 'real', 'string', 'uint',
31
+ 'void')
32
+
33
+ type_modifiers_par = ('atomic', 'single', 'sync')
34
+ type_modifiers_mem = ('borrowed', 'owned', 'shared', 'unmanaged')
35
+ type_modifiers = (*type_modifiers_par, *type_modifiers_mem)
36
+
37
+ declarations = ('config', 'const', 'in', 'inout', 'out', 'param', 'ref',
38
+ 'type', 'var')
39
+
40
+ constants = ('false', 'nil', 'none', 'true')
41
+
42
+ other_keywords = ('align', 'as',
43
+ 'begin', 'break', 'by',
44
+ 'catch', 'cobegin', 'coforall', 'continue',
45
+ 'defer', 'delete', 'dmapped', 'do', 'domain',
46
+ 'else', 'enum', 'except', 'export', 'extern',
47
+ 'for', 'forall', 'foreach', 'forwarding',
48
+ 'if', 'implements', 'import', 'index', 'init', 'inline',
49
+ 'label', 'lambda', 'let', 'lifetime', 'local',
50
+ 'new', 'noinit',
51
+ 'on', 'only', 'otherwise', 'override',
52
+ 'pragma', 'primitive', 'private', 'prototype', 'public',
53
+ 'reduce', 'require', 'return',
54
+ 'scan', 'select', 'serial', 'sparse', 'subdomain',
55
+ 'then', 'this', 'throw', 'throws', 'try',
56
+ 'use',
57
+ 'when', 'where', 'while', 'with',
58
+ 'yield',
59
+ 'zip')
60
+
29
61
  tokens = {
30
62
  'root': [
31
63
  (r'\n', Text),
@@ -35,34 +67,15 @@ class ChapelLexer(RegexLexer):
35
67
  (r'//(.*?)\n', Comment.Single),
36
68
  (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
37
69
 
38
- (r'(config|const|in|inout|out|param|ref|type|var)\b',
39
- Keyword.Declaration),
40
- (r'(false|nil|none|true)\b', Keyword.Constant),
41
- (r'(bool|bytes|complex|imag|int|nothing|opaque|range|real|string|uint|void)\b',
42
- Keyword.Type),
43
- (words((
44
- 'align', 'as', 'atomic',
45
- 'begin', 'borrowed', 'break', 'by',
46
- 'catch', 'cobegin', 'coforall', 'continue',
47
- 'defer', 'delete', 'dmapped', 'do', 'domain',
48
- 'else', 'enum', 'except', 'export', 'extern',
49
- 'for', 'forall', 'forwarding',
50
- 'if', 'import', 'index', 'init', 'inline',
51
- 'label', 'lambda', 'let', 'lifetime', 'local', 'locale'
52
- 'new', 'noinit',
53
- 'on', 'only', 'otherwise', 'override', 'owned',
54
- 'pragma', 'private', 'prototype', 'public',
55
- 'reduce', 'require', 'return',
56
- 'scan', 'select', 'serial', 'shared', 'single', 'sparse', 'subdomain', 'sync',
57
- 'then', 'this', 'throw', 'throws', 'try',
58
- 'unmanaged', 'use',
59
- 'when', 'where', 'while', 'with',
60
- 'yield',
61
- 'zip'), suffix=r'\b'),
62
- Keyword),
70
+ (words(declarations, suffix=r'\b'), Keyword.Declaration),
71
+ (words(constants, suffix=r'\b'), Keyword.Constant),
72
+ (words(known_types, suffix=r'\b'), Keyword.Type),
73
+ (words((*type_modifiers, *other_keywords), suffix=r'\b'), Keyword),
74
+
63
75
  (r'(iter)((?:\s)+)', bygroups(Keyword, Text), 'procname'),
64
76
  (r'(proc)((?:\s)+)', bygroups(Keyword, Text), 'procname'),
65
- (r'(class|module|record|union)(\s+)', bygroups(Keyword, Text),
77
+ (r'(operator)((?:\s)+)', bygroups(Keyword, Text), 'procname'),
78
+ (r'(class|interface|module|record|union)(\s+)', bygroups(Keyword, Text),
66
79
  'classname'),
67
80
 
68
81
  # imaginary integers
@@ -87,8 +100,8 @@ class ChapelLexer(RegexLexer):
87
100
  (r'[0-9]+', Number.Integer),
88
101
 
89
102
  # strings
90
- (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
91
- (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
103
+ (r'"(\\\\|\\"|[^"])*"', String),
104
+ (r"'(\\\\|\\'|[^'])*'", String),
92
105
 
93
106
  # tokens
94
107
  (r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|'
@@ -105,7 +118,18 @@ class ChapelLexer(RegexLexer):
105
118
  (r'[a-zA-Z_][\w$]*', Name.Class, '#pop'),
106
119
  ],
107
120
  'procname': [
108
- (r'([a-zA-Z_][.\w$]*|\~[a-zA-Z_][.\w$]*|[+*/!~%<>=&^|\-]{1,2})',
121
+ (r'([a-zA-Z_][.\w$]*|' # regular function name, including secondary
122
+ r'\~[a-zA-Z_][.\w$]*|' # support for legacy destructors
123
+ r'[+*/!~%<>=&^|\-:]{1,2})', # operators
109
124
  Name.Function, '#pop'),
125
+
126
+ # allow `proc (atomic T).foo`
127
+ (r'\(', Punctuation, "receivertype"),
128
+ (r'\)+\.', Punctuation),
129
+ ],
130
+ 'receivertype': [
131
+ (words(type_modifiers, suffix=r'\b'), Keyword),
132
+ (words(known_types, suffix=r'\b'), Keyword.Type),
133
+ (r'[^()]*', Name.Other, '#pop'),
110
134
  ],
111
135
  }
@@ -59,15 +59,15 @@ class CleanLexer(ExtendedRegexLexer):
59
59
  ],
60
60
  'comments': [
61
61
  (r'//.*\n', Comment.Single),
62
- (r'/\*', Comment.Multi, 'comments.in'),
62
+ (r'/\*', Comment.Multiline, 'comments.in'),
63
63
  (r'/\*\*', Comment.Special, 'comments.in'),
64
64
  ],
65
65
  'comments.in': [
66
- (r'\*\/', Comment.Multi, '#pop'),
67
- (r'/\*', Comment.Multi, '#push'),
68
- (r'[^*/]+', Comment.Multi),
69
- (r'\*(?!/)', Comment.Multi),
70
- (r'/', Comment.Multi),
66
+ (r'\*\/', Comment.Multiline, '#pop'),
67
+ (r'/\*', Comment.Multiline, '#push'),
68
+ (r'[^*/]+', Comment.Multiline),
69
+ (r'\*(?!/)', Comment.Multiline),
70
+ (r'/', Comment.Multiline),
71
71
  ],
72
72
  'keywords': [
73
73
  (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword),
@@ -21,7 +21,7 @@ __all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer',
21
21
  'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer',
22
22
  'TerraformLexer', 'TermcapLexer', 'TerminfoLexer',
23
23
  'PkgConfigLexer', 'PacmanConfLexer', 'AugeasLexer', 'TOMLLexer',
24
- 'SingularityLexer']
24
+ 'NestedTextLexer', 'SingularityLexer']
25
25
 
26
26
 
27
27
  class IniLexer(RegexLexer):
@@ -31,7 +31,13 @@ class IniLexer(RegexLexer):
31
31
 
32
32
  name = 'INI'
33
33
  aliases = ['ini', 'cfg', 'dosini']
34
- filenames = ['*.ini', '*.cfg', '*.inf']
34
+ filenames = [
35
+ '*.ini', '*.cfg', '*.inf',
36
+ # systemd unit files
37
+ # https://www.freedesktop.org/software/systemd/man/systemd.unit.html
38
+ '*.service', '*.socket', '*.device', '*.mount', '*.automount',
39
+ '*.swap', '*.target', '*.path', '*.timer', '*.slice', '*.scope',
40
+ ]
35
41
  mimetypes = ['text/x-ini', 'text/inf']
36
42
 
37
43
  tokens = {
@@ -349,7 +355,7 @@ class SquidConfLexer(RegexLexer):
349
355
  "cache_effective_user", "cache_host", "cache_host_acl",
350
356
  "cache_host_domain", "cache_log", "cache_mem", "cache_mem_high",
351
357
  "cache_mem_low", "cache_mgr", "cachemgr_passwd", "cache_peer",
352
- "cache_peer_access", "cahce_replacement_policy", "cache_stoplist",
358
+ "cache_peer_access", "cache_replacement_policy", "cache_stoplist",
353
359
  "cache_stoplist_pattern", "cache_store_log", "cache_swap",
354
360
  "cache_swap_high", "cache_swap_log", "cache_swap_low", "client_db",
355
361
  "client_lifetime", "client_netmask", "connect_timeout", "coredump_dir",
@@ -509,8 +515,8 @@ class LighttpdConfLexer(RegexLexer):
509
515
  .. versionadded:: 0.11
510
516
  """
511
517
  name = 'Lighttpd configuration file'
512
- aliases = ['lighty', 'lighttpd']
513
- filenames = []
518
+ aliases = ['lighttpd', 'lighty']
519
+ filenames = ['lighttpd.conf']
514
520
  mimetypes = ['text/x-lighttpd-conf']
515
521
 
516
522
  tokens = {
@@ -577,56 +583,113 @@ class TerraformLexer(RegexLexer):
577
583
  filenames = ['*.tf']
578
584
  mimetypes = ['application/x-tf', 'application/x-terraform']
579
585
 
580
- embedded_keywords = ('ingress', 'egress', 'listener', 'default',
581
- 'connection', 'alias', 'terraform', 'tags', 'vars',
582
- 'config', 'lifecycle', 'timeouts')
586
+ classes = ('backend', 'data', 'module', 'output', 'provider',
587
+ 'provisioner', 'resource', 'variable')
588
+ classes_re = "({})".format(('|').join(classes))
589
+
590
+ types = ('string', 'number', 'bool', 'list', 'tuple', 'map', 'object', 'null')
591
+
592
+ numeric_functions = ('abs', 'ceil', 'floor', 'log', 'max',
593
+ 'mix', 'parseint', 'pow', 'signum')
594
+
595
+ string_functions = ('chomp', 'format', 'formatlist', 'indent',
596
+ 'join', 'lower', 'regex', 'regexall', 'replace',
597
+ 'split', 'strrev', 'substr', 'title', 'trim',
598
+ 'trimprefix', 'trimsuffix', 'trimspace', 'upper'
599
+ )
600
+
601
+ collection_functions = ('alltrue', 'anytrue', 'chunklist', 'coalesce',
602
+ 'coalescelist', 'compact', 'concat', 'contains',
603
+ 'distinct', 'element', 'flatten', 'index', 'keys',
604
+ 'length', 'list', 'lookup', 'map', 'matchkeys',
605
+ 'merge', 'range', 'reverse', 'setintersection',
606
+ 'setproduct', 'setsubtract', 'setunion', 'slice',
607
+ 'sort', 'sum', 'transpose', 'values', 'zipmap'
608
+ )
609
+
610
+ encoding_functions = ('base64decode', 'base64encode', 'base64gzip',
611
+ 'csvdecode', 'jsondecode', 'jsonencode', 'textdecodebase64',
612
+ 'textencodebase64', 'urlencode', 'yamldecode', 'yamlencode')
613
+
614
+
615
+ filesystem_functions = ('abspath', 'dirname', 'pathexpand', 'basename',
616
+ 'file', 'fileexists', 'fileset', 'filebase64', 'templatefile')
617
+
618
+ date_time_functions = ('formatdate', 'timeadd', 'timestamp')
619
+
620
+ hash_crypto_functions = ('base64sha256', 'base64sha512', 'bcrypt', 'filebase64sha256',
621
+ 'filebase64sha512', 'filemd5', 'filesha1', 'filesha256', 'filesha512',
622
+ 'md5', 'rsadecrypt', 'sha1', 'sha256', 'sha512', 'uuid', 'uuidv5')
623
+
624
+ ip_network_functions = ('cidrhost', 'cidrnetmask', 'cidrsubnet', 'cidrsubnets')
625
+
626
+ type_conversion_functions = ('can', 'defaults', 'tobool', 'tolist', 'tomap',
627
+ 'tonumber', 'toset', 'tostring', 'try')
628
+
629
+ builtins = numeric_functions + string_functions + collection_functions + encoding_functions +\
630
+ filesystem_functions + date_time_functions + hash_crypto_functions + ip_network_functions +\
631
+ type_conversion_functions
632
+ builtins_re = "({})".format(('|').join(builtins))
583
633
 
584
634
  tokens = {
585
635
  'root': [
586
- include('string'),
587
- include('punctuation'),
588
- include('curly'),
589
636
  include('basic'),
590
637
  include('whitespace'),
638
+
639
+ # Strings
640
+ (r'(".*")', bygroups(String.Double)),
641
+
642
+ # Constants
643
+ (words(('true', 'false'), prefix=r'\b', suffix=r'\b'), Name.Constant),
644
+
645
+ # Types
646
+ (words(types, prefix=r'\b', suffix=r'\b'), Keyword.Type),
647
+
648
+ include('identifier'),
649
+ include('punctuation'),
591
650
  (r'[0-9]+', Number),
592
651
  ],
593
652
  'basic': [
594
- (words(('true', 'false'), prefix=r'\b', suffix=r'\b'), Keyword.Type),
595
653
  (r'\s*/\*', Comment.Multiline, 'comment'),
596
654
  (r'\s*#.*\n', Comment.Single),
597
- (r'(.*?)(\s*)(=)', bygroups(Name.Attribute, Text, Operator)),
598
- (words(('variable', 'resource', 'provider', 'provisioner', 'module',
599
- 'backend', 'data', 'output'), prefix=r'\b', suffix=r'\b'),
600
- Keyword.Reserved, 'function'),
601
- (words(embedded_keywords, prefix=r'\b', suffix=r'\b'),
602
- Keyword.Declaration),
603
- (r'\$\{', String.Interpol, 'var_builtin'),
604
- ],
605
- 'function': [
606
- (r'(\s+)(".*")(\s+)', bygroups(Text, String, Text)),
607
- include('punctuation'),
608
- include('curly'),
655
+ include('whitespace'),
656
+
657
+ # e.g. terraform {
658
+ # e.g. egress {
659
+ (r'(\s*)([0-9a-zA-Z-_]+)(\s*)(=?)(\s*)(\{)',
660
+ bygroups(Text, Name.Builtin, Text, Operator, Text, Punctuation)),
661
+
662
+ # Assignment with attributes, e.g. something = ...
663
+ (r'(\s*)([0-9a-zA-Z-_]+)(\s*)(=)(\s*)',
664
+ bygroups(Text, Name.Attribute, Text, Operator, Text)),
665
+
666
+ # Assignment with environment variables and similar, e.g. "something" = ...
667
+ # or key value assignment, e.g. "SlotName" : ...
668
+ (r'(\s*)("\S+")(\s*)([=:])(\s*)',
669
+ bygroups(Text, Literal.String.Double, Text, Operator, Text)),
670
+
671
+ # Functions, e.g. jsonencode(element("value"))
672
+ (builtins_re + r'(\()', bygroups(Name.Function, Punctuation)),
673
+
674
+ # List of attributes, e.g. ignore_changes = [last_modified, filename]
675
+ (r'(\[)([a-z_,\s]+)(\])', bygroups(Punctuation, Name.Builtin, Punctuation)),
676
+
677
+ # e.g. resource "aws_security_group" "allow_tls" {
678
+ # e.g. backend "consul" {
679
+ (classes_re + r'(\s+)', bygroups(Keyword.Reserved, Text), 'blockname'),
609
680
  ],
610
- 'var_builtin': [
611
- (r'\$\{', String.Interpol, '#push'),
612
- (words(('concat', 'file', 'join', 'lookup', 'element'),
613
- prefix=r'\b', suffix=r'\b'), Name.Builtin),
614
- include('string'),
615
- include('punctuation'),
616
- (r'\s+', Text),
617
- (r'\}', String.Interpol, '#pop'),
681
+ 'blockname': [
682
+ # e.g. resource "aws_security_group" "allow_tls" {
683
+ # e.g. backend "consul" {
684
+ (r'(\s*)("[0-9a-zA-Z-_]+")?(\s*)("[0-9a-zA-Z-_]+")(\s+)(\{)',
685
+ bygroups(Text, Name.Class, Text, Name.Variable, Text, Punctuation)),
618
686
  ],
619
- 'string': [
620
- (r'(".*")', bygroups(String.Double)),
687
+ 'identifier': [
688
+ (r'\b(var\.[0-9a-zA-Z-_\.\[\]]+)\b', bygroups(Name.Variable)),
689
+ (r'\b([0-9a-zA-Z-_\[\]]+\.[0-9a-zA-Z-_\.\[\]]+)\b', bygroups(Name.Variable)),
621
690
  ],
622
691
  'punctuation': [
623
- (r'[\[\](),.]', Punctuation),
624
- ],
625
- # Keep this seperate from punctuation - we sometimes want to use different
626
- # Tokens for { }
627
- 'curly': [
628
- (r'\{', Text.Punctuation),
629
- (r'\}', Text.Punctuation),
692
+ (r'[\[\]()\{\},.?:!=]', Punctuation),
630
693
  ],
631
694
  'comment': [
632
695
  (r'[^*/]', Comment.Multiline),
@@ -905,9 +968,12 @@ class TOMLLexer(RegexLexer):
905
968
 
906
969
  tokens = {
907
970
  'root': [
971
+ # Table
972
+ (r'^(\s*)(\[.*?\])$', bygroups(Text, Keyword)),
908
973
 
909
974
  # Basics, comments, strings
910
- (r'\s+', Text),
975
+ (r'[ \t]+', Text),
976
+ (r'\n', Text),
911
977
  (r'#.*?$', Comment.Single),
912
978
  # Basic string
913
979
  (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
@@ -917,7 +983,6 @@ class TOMLLexer(RegexLexer):
917
983
  (r'(true|false)$', Keyword.Constant),
918
984
  (r'[a-zA-Z_][\w\-]*', Name),
919
985
 
920
- (r'\[.*?\]$', Keyword),
921
986
  # Datetime
922
987
  # TODO this needs to be expanded, as TOML is rather flexible:
923
988
  # https://github.com/toml-lang/toml#offset-date-time
@@ -940,6 +1005,31 @@ class TOMLLexer(RegexLexer):
940
1005
  ]
941
1006
  }
942
1007
 
1008
+ class NestedTextLexer(RegexLexer):
1009
+ """
1010
+ Lexer for `NextedText <https://nestedtext.org>`_, a human-friendly data
1011
+ format.
1012
+
1013
+ .. versionadded:: 2.9
1014
+ """
1015
+
1016
+ name = 'NestedText'
1017
+ aliases = ['nestedtext', 'nt']
1018
+ filenames = ['*.nt']
1019
+
1020
+ _quoted_dict_item = r'^(\s*)({0})(.*?)({0}: ?)(.*?)(\s*)$'
1021
+
1022
+ tokens = {
1023
+ 'root': [
1024
+ (r'^(\s*)(#.*?)$', bygroups(Text, Comment)),
1025
+ (r'^(\s*)(> ?)(.*?)(\s*)$', bygroups(Text, Punctuation, String, Whitespace)),
1026
+ (r'^(\s*)(- ?)(.*?)(\s*)$', bygroups(Text, Punctuation, String, Whitespace)),
1027
+ (_quoted_dict_item.format("'"), bygroups(Text, Punctuation, Name, Punctuation, String, Whitespace)),
1028
+ (_quoted_dict_item.format('"'), bygroups(Text, Punctuation, Name, Punctuation, String, Whitespace)),
1029
+ (r'^(\s*)(.*?)(: ?)(.*?)(\s*)$', bygroups(Text, Name, Punctuation, String, Whitespace)),
1030
+ ],
1031
+ }
1032
+
943
1033
 
944
1034
  class SingularityLexer(RegexLexer):
945
1035
  """
@@ -13,7 +13,7 @@ import re
13
13
  from pygments.lexer import RegexLexer, bygroups, default, include, using, words
14
14
  from pygments.token import Comment, Error, Keyword, Name, Number, Operator, Punctuation, \
15
15
  String, Text, Whitespace
16
- from pygments.lexers._csound_builtins import OPCODES, DEPRECATED_OPCODES
16
+ from pygments.lexers._csound_builtins import OPCODES, DEPRECATED_OPCODES, REMOVED_OPCODES
17
17
  from pygments.lexers.html import HtmlLexer
18
18
  from pygments.lexers.python import PythonLexer
19
19
  from pygments.lexers.scripting import LuaLexer
@@ -219,7 +219,7 @@ class CsoundOrchestraLexer(CsoundLexer):
219
219
  type_annotation_token = Keyword.Type
220
220
 
221
221
  name = match.group(1)
222
- if name in OPCODES or name in DEPRECATED_OPCODES:
222
+ if name in OPCODES or name in DEPRECATED_OPCODES or name in REMOVED_OPCODES:
223
223
  yield match.start(), Name.Builtin, name
224
224
  elif name in lexer.user_defined_opcodes:
225
225
  yield match.start(), Name.Function, name
@@ -58,7 +58,7 @@ class DevicetreeLexer(RegexLexer):
58
58
  (r'(L?)(")', bygroups(String.Affix, String), 'string'),
59
59
  (r'0x[0-9a-fA-F]+', Number.Hex),
60
60
  (r'\d+', Number.Integer),
61
- (r'([^\s{}/*]*)(\s*)(:)', bygroups(Name.Label, Text, Punctuation)),
61
+ (r'([^\s{}/*]*)(\s*)(:)', bygroups(Name.Label, Text, Punctuation), '#pop'),
62
62
  (words(('compatible', 'model', 'phandle', 'status', '#address-cells',
63
63
  '#size-cells', 'reg', 'virtual-reg', 'ranges', 'dma-ranges',
64
64
  'device_type', 'name'), suffix=r'\b'), Keyword.Reserved),
@@ -87,7 +87,7 @@ class CSharpLexer(RegexLexer):
87
87
  (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
88
88
  (r'[{}]', Punctuation),
89
89
  (r'@"(""|[^"])*"', String),
90
- (r'"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
90
+ (r'\$?"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
91
91
  (r"'\\.'|'[^\\]'", String.Char),
92
92
  (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?"
93
93
  r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number),
@@ -230,7 +230,7 @@ class ElixirLexer(RegexLexer):
230
230
 
231
231
  name = 'Elixir'
232
232
  aliases = ['elixir', 'ex', 'exs']
233
- filenames = ['*.ex', '*.eex', '*.exs']
233
+ filenames = ['*.ex', '*.eex', '*.exs', '*.leex']
234
234
  mimetypes = ['text/x-elixir']
235
235
 
236
236
  KEYWORD = ('fn', 'do', 'end', 'after', 'else', 'rescue', 'catch')
@@ -59,7 +59,7 @@ class FloScriptLexer(RegexLexer):
59
59
 
60
60
  include('name'),
61
61
  include('numbers'),
62
- (r'#.+$', Comment.Singleline),
62
+ (r'#.+$', Comment.Single),
63
63
  ],
64
64
  'string': [
65
65
  ('[^"]+', String),
@@ -10,9 +10,9 @@
10
10
 
11
11
  import re
12
12
 
13
- from pygments.lexer import RegexLexer, include, bygroups, default, words
13
+ from pygments.lexer import RegexLexer
14
14
  from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
15
- Number, Punctuation, Error
15
+ Number, Punctuation
16
16
  from pygments import unistring as uni
17
17
 
18
18
  __all__ = ['FutharkLexer']
@@ -25,7 +25,7 @@ class FutharkLexer(RegexLexer):
25
25
  """
26
26
  A Futhark lexer
27
27
 
28
- .. versionadded:: 2.8.0
28
+ .. versionadded:: 2.8
29
29
  """
30
30
  name = 'Futhark'
31
31
  aliases = ['futhark']
@@ -70,7 +70,8 @@ class FutharkLexer(RegexLexer):
70
70
  (r'[][(),:;`{}]', Punctuation),
71
71
 
72
72
  # Numbers
73
- (r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*_*[pP][+-]?\d(_*\d)*' + num_postfix, Number.Float),
73
+ (r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*_*[pP][+-]?\d(_*\d)*' + num_postfix,
74
+ Number.Float),
74
75
  (r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*\.[\da-fA-F](_*[\da-fA-F])*'
75
76
  r'(_*[pP][+-]?\d(_*\d)*)?' + num_postfix, Number.Float),
76
77
  (r'\d(_*\d)*_*[eE][+-]?\d(_*\d)*' + num_postfix, Number.Float),
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.gcodelexer
4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for the G Code Language.
7
+
8
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ from pygments.lexer import RegexLexer, bygroups
13
+ from pygments.token import Comment, Name, Text, Keyword, Number
14
+
15
+ __all__ = ['GcodeLexer']
16
+
17
+
18
+ class GcodeLexer(RegexLexer):
19
+ """
20
+ For gcode source code.
21
+
22
+ .. versionadded:: 2.9
23
+ """
24
+ name = 'g-code'
25
+ aliases = ['gcode']
26
+ filenames = ['*.gcode']
27
+
28
+ tokens = {
29
+ 'root': [
30
+ (r';.*\n', Comment),
31
+ (r'^[gmGM]\d{1,4}\s', Name.Builtin), # M or G commands
32
+ (r'([^gGmM])([+-]?\d*[.]?\d+)', bygroups(Keyword, Number)),
33
+ (r'\s', Text.Whitespace),
34
+ (r'.*\n', Text),
35
+ ]
36
+ }
@@ -25,7 +25,7 @@ class GoLexer(RegexLexer):
25
25
  """
26
26
  name = 'Go'
27
27
  filenames = ['*.go']
28
- aliases = ['go']
28
+ aliases = ['go', 'golang']
29
29
  mimetypes = ['text/x-gosrc']
30
30
 
31
31
  flags = re.MULTILINE | re.UNICODE
@@ -407,7 +407,7 @@ class AsymptoteLexer(RegexLexer):
407
407
  .. versionadded:: 1.2
408
408
  """
409
409
  name = 'Asymptote'
410
- aliases = ['asy', 'asymptote']
410
+ aliases = ['asymptote', 'asy']
411
411
  filenames = ['*.asy']
412
412
  mimetypes = ['text/x-asymptote']
413
413
 
@@ -9,7 +9,8 @@
9
9
  """
10
10
 
11
11
  from pygments.lexer import RegexLexer, bygroups
12
- from pygments.token import Comment, Keyword, Operator, Name, String, Number, Punctuation, Whitespace
12
+ from pygments.token import Comment, Keyword, Operator, Name, String, Number, \
13
+ Punctuation, Whitespace
13
14
 
14
15
 
15
16
  __all__ = ['GraphvizLexer']
@@ -37,9 +38,9 @@ class GraphvizLexer(RegexLexer):
37
38
  bygroups(Name.Attribute, Whitespace, Punctuation, Whitespace),
38
39
  'attr_id'),
39
40
  (r'\b(n|ne|e|se|s|sw|w|nw|c|_)\b', Name.Builtin),
40
- (r'\b\D\w*', Name.Tag), # node
41
+ (r'\b\D\w*', Name.Tag), # node
41
42
  (r'[-]?((\.[0-9]+)|([0-9]+(\.[0-9]*)?))', Number),
42
- (r'"(\\"|[^"])*?"', Name.Tag), # quoted node
43
+ (r'"(\\"|[^"])*?"', Name.Tag), # quoted node
43
44
  (r'<', Punctuation, 'xml'),
44
45
  ],
45
46
  'attr_id': [
@@ -54,4 +55,4 @@ class GraphvizLexer(RegexLexer):
54
55
  (r'\s+', Whitespace),
55
56
  (r'[^<>\s]', Name.Tag),
56
57
  ]
57
- }
58
+ }
@@ -0,0 +1,92 @@
1
+ """
2
+ pygments.lexers.gsql
3
+ ~~~~~~~~~~~~~~~~~~~~
4
+
5
+ Lexers for TigerGraph GSQL graph query language
6
+
7
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
8
+ :license: BSD, see LICENSE for details.
9
+ """
10
+
11
+ import re
12
+
13
+ from pygments.lexer import RegexLexer, include, bygroups, using, this, words
14
+ from pygments.token import Keyword, Punctuation, Comment, Operator, Name,\
15
+ String, Number, Whitespace, Token
16
+
17
+
18
+ __all__ = ["GSQLLexer"]
19
+
20
+ class GSQLLexer(RegexLexer):
21
+
22
+ """
23
+ For `GSQL <https://docs.tigergraph.com/dev/gsql-ref>`_ queries (version 3.x).
24
+ .. versionadded:: 2.10
25
+ """
26
+
27
+ name = 'GSQL'
28
+ aliases = ['gsql']
29
+ filenames = ['*.gsql']
30
+
31
+ flags = re.MULTILINE | re.IGNORECASE
32
+
33
+ tokens = {
34
+ 'root': [
35
+ include('comment'),
36
+ include('keywords'),
37
+ include('clauses'),
38
+ include('accums'),
39
+ include('relations'),
40
+ include('strings'),
41
+ include('whitespace'),
42
+ include('barewords'),
43
+ include('operators'),
44
+ ],
45
+ 'comment': [
46
+ (r'.*\#.*\n', Comment.Single),
47
+ (r'.*\/\*\s*.*\s*\*\/', Comment.Multiline),
48
+ ],
49
+ 'keywords': [
50
+ (words((
51
+ 'ACCUM', 'AND', 'ANY', 'API', 'AS', 'ASC', 'AVG', 'BAG', 'BATCH', 'BETWEEN', 'BOOL', 'BOTH',
52
+ 'BREAK', 'BY', 'CASE', 'CATCH', 'COALESCE', 'COMPRESS', 'CONTINUE', 'COUNT',
53
+ 'CREATE', 'DATETIME', 'DATETIME_ADD', 'DATETIME_SUB', 'DELETE', 'DESC', 'DISTRIBUTED', 'DO',
54
+ 'DOUBLE', 'EDGE', 'ELSE', 'END', 'ESCAPE', 'EXCEPTION', 'FALSE', 'FILE', 'FILTER', 'FLOAT', 'FOREACH', 'FOR',
55
+ 'FROM', 'GRAPH', 'GROUP', 'GSQL_INT_MAX', 'GSQL_INT_MIN', 'GSQL_UINT_MAX', 'HAVING', 'IF',
56
+ 'IN', 'INSERT', 'INT', 'INTERPRET', 'INTERSECT', 'INTERVAL', 'INTO', 'IS', 'ISEMPTY', 'JSONARRAY', 'JSONOBJECT', 'LASTHOP',
57
+ 'LEADING', 'LIKE', 'LIMIT', 'LIST', 'LOAD_ACCUM', 'LOG', 'MAP', 'MATCH', 'MAX', 'MIN', 'MINUS', 'NOT',
58
+ 'NOW', 'NULL', 'OFFSET', 'OR', 'ORDER', 'PATH', 'PER', 'PINNED', 'POST_ACCUM', 'POST-ACCUM', 'PRIMARY_ID', 'PRINT',
59
+ 'QUERY', 'RAISE', 'RANGE', 'REPLACE', 'RESET_COLLECTION_ACCUM', 'RETURN', 'RETURNS', 'RUN', 'SAMPLE', 'SELECT', 'SELECT_VERTEX',
60
+ 'SET', 'SRC', 'STATIC', 'STRING', 'SUM', 'SYNTAX', 'TARGET', 'TAGSTGT', 'THEN', 'TO', 'TO_CSV', 'TO_DATETIME', 'TRAILING', 'TRIM', 'TRUE',
61
+ 'TRY', 'TUPLE', 'TYPEDEF', 'UINT', 'UNION', 'UPDATE', 'VALUES', 'VERTEX', 'WHEN', 'WHERE', 'WHILE', 'WITH'), prefix=r'(?<!\.)', suffix=r'\b'), Token.Keyword)
62
+ ],
63
+ 'clauses': [
64
+ (words(('accum', 'having', 'limit', 'order', 'postAccum', 'sample', 'where')), Name.Builtin)
65
+ ],
66
+ 'accums': [
67
+ (words(('andaccum', 'arrayaccum', 'avgaccum', 'bagaccum', 'bitwiseandaccum',
68
+ 'bitwiseoraccum', 'groupbyaccum', 'heapaccum', 'listaccum', 'MapAccum',
69
+ 'maxaccum', 'minaccum', 'oraccum', 'setaccum', 'sumaccum')), Name.Builtin),
70
+ ],
71
+ 'relations': [
72
+ (r'(-\s?)(\(.*\:\w?\))(\s?-)', bygroups(Operator, using(this), Operator)),
73
+ (r'->|<-', Operator),
74
+ (r'[.*{}]', Punctuation),
75
+ ],
76
+ 'strings': [
77
+ (r'"(?:\\[tbnrf\'"\\]|[^\\"])*"', String),
78
+ (r'@{1,2}\w+', Name.Variable),
79
+ (r'(\<\w+)?\<(\w+\>?\,?\s?)+\>+', Name.Constant),
80
+ ],
81
+ 'whitespace': [
82
+ (r'\s+', Whitespace),
83
+ ],
84
+ 'barewords': [
85
+ (r'[a-z]\w*', Name),
86
+ (r'(\d+\.\d+|\d+)', Number),
87
+ ],
88
+ 'operators': [
89
+ (r'[^0-9|\/|\-](\-\=|\+\=|\*\=|\\\=|\=|\=\=|\=\=\=|\+|\-|\*|\\|\+\=|\>|\<)[^\>|\/]', Operator),
90
+ (r'(\(|\)|\,|\;|\=|\-|\+|\*|\/|\>|\<|\:)', Operator),
91
+ ],
92
+ }