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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +12 -7
- data/.github/workflows/release.yml +5 -5
- data/CHANGELOG.adoc +9 -0
- data/README.adoc +1 -1
- data/bench.rb +2 -2
- data/lib/pygments/lexer.rb +1 -1
- data/lib/pygments/mentos.py +6 -4
- data/lib/pygments/popen.rb +20 -11
- data/lib/pygments/version.rb +1 -1
- data/lib/pygments.rb +8 -2
- data/pygments.rb.gemspec +4 -4
- data/test/test_pygments.rb +14 -8
- data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/AUTHORS +8 -1
- data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/INSTALLER +0 -0
- data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/LICENSE +0 -0
- data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/METADATA +1 -1
- data/vendor/pygments-main/Pygments-2.10.0.dist-info/RECORD +524 -0
- data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/REQUESTED +0 -0
- data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/WHEEL +0 -0
- data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/entry_points.txt +0 -0
- data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/top_level.txt +0 -0
- data/vendor/pygments-main/bin/pygmentize +1 -1
- data/vendor/pygments-main/pygments/__init__.py +1 -1
- data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -0
- data/vendor/pygments-main/pygments/formatters/html.py +20 -7
- data/vendor/pygments-main/pygments/formatters/pangomarkup.py +83 -0
- data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +55 -14
- data/vendor/pygments-main/pygments/lexers/_julia_builtins.py +401 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +68 -52
- data/vendor/pygments-main/pygments/lexers/actionscript.py +2 -2
- data/vendor/pygments-main/pygments/lexers/ambient.py +1 -1
- data/vendor/pygments-main/pygments/lexers/amdgpu.py +9 -4
- data/vendor/pygments-main/pygments/lexers/apdlexer.py +448 -0
- data/vendor/pygments-main/pygments/lexers/apl.py +6 -3
- data/vendor/pygments-main/pygments/lexers/asc.py +51 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +86 -58
- data/vendor/pygments-main/pygments/lexers/automation.py +1 -1
- data/vendor/pygments-main/pygments/lexers/bibtex.py +2 -2
- data/vendor/pygments-main/pygments/lexers/c_cpp.py +60 -33
- data/vendor/pygments-main/pygments/lexers/c_like.py +102 -3
- data/vendor/pygments-main/pygments/lexers/cddl.py +2 -2
- data/vendor/pygments-main/pygments/lexers/chapel.py +53 -29
- data/vendor/pygments-main/pygments/lexers/clean.py +6 -6
- data/vendor/pygments-main/pygments/lexers/configs.py +133 -43
- data/vendor/pygments-main/pygments/lexers/csound.py +2 -2
- data/vendor/pygments-main/pygments/lexers/devicetree.py +1 -1
- data/vendor/pygments-main/pygments/lexers/dotnet.py +1 -1
- data/vendor/pygments-main/pygments/lexers/erlang.py +1 -1
- data/vendor/pygments-main/pygments/lexers/floscript.py +1 -1
- data/vendor/pygments-main/pygments/lexers/futhark.py +5 -4
- data/vendor/pygments-main/pygments/lexers/gcodelexer.py +36 -0
- data/vendor/pygments-main/pygments/lexers/go.py +1 -1
- data/vendor/pygments-main/pygments/lexers/graphics.py +1 -1
- data/vendor/pygments-main/pygments/lexers/graphviz.py +5 -4
- data/vendor/pygments-main/pygments/lexers/gsql.py +92 -0
- data/vendor/pygments-main/pygments/lexers/haskell.py +4 -4
- data/vendor/pygments-main/pygments/lexers/haxe.py +1 -1
- data/vendor/pygments-main/pygments/lexers/installers.py +2 -2
- data/vendor/pygments-main/pygments/lexers/javascript.py +145 -127
- data/vendor/pygments-main/pygments/lexers/jslt.py +94 -0
- data/vendor/pygments-main/pygments/lexers/julia.py +135 -183
- data/vendor/pygments-main/pygments/lexers/jvm.py +262 -202
- data/vendor/pygments-main/pygments/lexers/kuin.py +299 -0
- data/vendor/pygments-main/pygments/lexers/lisp.py +18 -15
- data/vendor/pygments-main/pygments/lexers/markup.py +3 -3
- data/vendor/pygments-main/pygments/lexers/matlab.py +23 -10
- data/vendor/pygments-main/pygments/lexers/meson.py +155 -0
- data/vendor/pygments-main/pygments/lexers/mime.py +6 -21
- data/vendor/pygments-main/pygments/lexers/ml.py +1 -1
- data/vendor/pygments-main/pygments/lexers/nimrod.py +1 -1
- data/vendor/pygments-main/pygments/lexers/objective.py +3 -3
- data/vendor/pygments-main/pygments/lexers/parsers.py +1 -1
- data/vendor/pygments-main/pygments/lexers/procfile.py +43 -0
- data/vendor/pygments-main/pygments/lexers/promql.py +1 -1
- data/vendor/pygments-main/pygments/lexers/python.py +19 -5
- data/vendor/pygments-main/pygments/lexers/resource.py +1 -1
- data/vendor/pygments-main/pygments/lexers/rnc.py +1 -1
- data/vendor/pygments-main/pygments/lexers/ruby.py +1 -1
- data/vendor/pygments-main/pygments/lexers/rust.py +9 -10
- data/vendor/pygments-main/pygments/lexers/scripting.py +7 -7
- data/vendor/pygments-main/pygments/lexers/shell.py +11 -8
- data/vendor/pygments-main/pygments/lexers/smithy.py +79 -0
- data/vendor/pygments-main/pygments/lexers/smv.py +1 -1
- data/vendor/pygments-main/pygments/lexers/special.py +15 -2
- data/vendor/pygments-main/pygments/lexers/supercollider.py +1 -1
- data/vendor/pygments-main/pygments/lexers/tcl.py +3 -3
- data/vendor/pygments-main/pygments/lexers/teal.py +88 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +19 -19
- data/vendor/pygments-main/pygments/lexers/teraterm.py +1 -1
- data/vendor/pygments-main/pygments/lexers/testing.py +1 -1
- data/vendor/pygments-main/pygments/lexers/theorem.py +4 -2
- data/vendor/pygments-main/pygments/lexers/thingsdb.py +118 -0
- data/vendor/pygments-main/pygments/lexers/tnt.py +25 -15
- data/vendor/pygments-main/pygments/lexers/trafficscript.py +1 -1
- data/vendor/pygments-main/pygments/lexers/webassembly.py +120 -0
- data/vendor/pygments-main/pygments/regexopt.py +1 -1
- data/vendor/pygments-main/pygments/style.py +1 -1
- data/vendor/pygments-main/pygments/styles/__init__.py +2 -0
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -0
- data/vendor/pygments-main/pygments/styles/gruvbox.py +107 -0
- data/vendor/pygments-main/pygments/styles/native.py +1 -0
- metadata +29 -14
- data/vendor/pygments-main/Pygments-2.8.1.dist-info/RECORD +0 -494
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
pygments.lexers.kuin
|
|
4
|
+
~~~~~~~~~~~~~~~~~~~~
|
|
5
|
+
|
|
6
|
+
Lexers for the Kuin language.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from pygments.lexer import RegexLexer, include, using, inherit, this, bygroups, words
|
|
10
|
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, Number, Punctuation
|
|
11
|
+
|
|
12
|
+
__all__ = ['KuinLexer']
|
|
13
|
+
|
|
14
|
+
class KuinLexer(RegexLexer):
|
|
15
|
+
"""
|
|
16
|
+
For `Kuin <https://github.com/kuina/Kuin>`_ source code
|
|
17
|
+
|
|
18
|
+
.. versionadded:: 2.9
|
|
19
|
+
"""
|
|
20
|
+
name = 'Kuin'
|
|
21
|
+
aliases = ['kuin']
|
|
22
|
+
filenames = ['*.kn']
|
|
23
|
+
|
|
24
|
+
tokens = {
|
|
25
|
+
'root': [
|
|
26
|
+
include('statement'),
|
|
27
|
+
],
|
|
28
|
+
'statement': [
|
|
29
|
+
# Whitespace / Comment
|
|
30
|
+
include('whitespace'),
|
|
31
|
+
|
|
32
|
+
# Block-statement
|
|
33
|
+
(r'(\+?[ \t]*\*?[ \t]*\bfunc)([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*)', bygroups(Keyword, using(this), Name.Function), 'func_'),
|
|
34
|
+
(r'\b(class)([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*)', bygroups(Keyword, using(this), Name.Class), 'class_'),
|
|
35
|
+
(r'\b(enum)([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*)', bygroups(Keyword, using(this), Name.Constant), 'enum_'),
|
|
36
|
+
(r'\b(block)\b(?:([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*))?', bygroups(Keyword, using(this), Name.Other), 'block_'),
|
|
37
|
+
(r'\b(ifdef)\b(?:([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*))?', bygroups(Keyword, using(this), Name.Other), 'ifdef_'),
|
|
38
|
+
(r'\b(if)\b(?:([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*))?', bygroups(Keyword, using(this), Name.Other), 'if_'),
|
|
39
|
+
(r'\b(switch)\b(?:([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*))?', bygroups(Keyword, using(this), Name.Other), 'switch_'),
|
|
40
|
+
(r'\b(while)\b(?:([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*))?', bygroups(Keyword, using(this), Name.Other), 'while_'),
|
|
41
|
+
(r'\b(for)\b(?:([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*))?', bygroups(Keyword, using(this), Name.Other), 'for_'),
|
|
42
|
+
(r'\b(foreach)\b(?:([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*))?', bygroups(Keyword, using(this), Name.Other), 'foreach_'),
|
|
43
|
+
(r'\b(try)\b(?:([ \t]+(?:\n\s*\|)*[ \t]*)([a-zA-Z_][0-9a-zA-Z_]*))?', bygroups(Keyword, using(this), Name.Other), 'try_'),
|
|
44
|
+
|
|
45
|
+
# Line-statement
|
|
46
|
+
(r'\b(do)\b', Keyword, 'do'),
|
|
47
|
+
(r'(\+?[ \t]*\bvar)\b', Keyword, 'var'),
|
|
48
|
+
(r'\b(const)\b', Keyword, 'const'),
|
|
49
|
+
(r'\b(ret)\b', Keyword, 'ret'),
|
|
50
|
+
(r'\b(throw)\b', Keyword, 'throw'),
|
|
51
|
+
(r'\b(alias)\b', Keyword, 'alias'),
|
|
52
|
+
(r'\b(assert)\b', Keyword, 'assert'),
|
|
53
|
+
(r'\|', Text, 'continued_line'),
|
|
54
|
+
(r'[ \t]*\n', Text),
|
|
55
|
+
],
|
|
56
|
+
|
|
57
|
+
# Whitespace / Comment
|
|
58
|
+
'whitespace': [
|
|
59
|
+
(r'^[ \t]*;.*', Comment.Single),
|
|
60
|
+
(r'[ \t]+(?![; \t])', Text),
|
|
61
|
+
(r'\{', Comment.Multiline, 'multiline_comment'),
|
|
62
|
+
],
|
|
63
|
+
'multiline_comment': [
|
|
64
|
+
(r'\{', Comment.Multiline, 'multiline_comment'),
|
|
65
|
+
(r'(?:\s*;.*|[^{}\n]+)', Comment.Multiline),
|
|
66
|
+
(r'\n', Comment.Multiline),
|
|
67
|
+
(r'\}', Comment.Multiline, '#pop'),
|
|
68
|
+
],
|
|
69
|
+
|
|
70
|
+
# Block-statement
|
|
71
|
+
'func_': [
|
|
72
|
+
include('expr'),
|
|
73
|
+
(r'\n', Text, 'func'),
|
|
74
|
+
],
|
|
75
|
+
'func': [
|
|
76
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(func)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
77
|
+
include('statement'),
|
|
78
|
+
],
|
|
79
|
+
'class_': [
|
|
80
|
+
include('expr'),
|
|
81
|
+
(r'\n', Text, 'class'),
|
|
82
|
+
],
|
|
83
|
+
'class': [
|
|
84
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(class)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
85
|
+
include('statement'),
|
|
86
|
+
],
|
|
87
|
+
'enum_': [
|
|
88
|
+
include('expr'),
|
|
89
|
+
(r'\n', Text, 'enum'),
|
|
90
|
+
],
|
|
91
|
+
'enum': [
|
|
92
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(enum)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
93
|
+
include('expr'),
|
|
94
|
+
(r'\n', Text),
|
|
95
|
+
],
|
|
96
|
+
'block_': [
|
|
97
|
+
include('expr'),
|
|
98
|
+
(r'\n', Text, 'block'),
|
|
99
|
+
],
|
|
100
|
+
'block': [
|
|
101
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(block)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
102
|
+
include('statement'),
|
|
103
|
+
include('break'),
|
|
104
|
+
include('skip'),
|
|
105
|
+
],
|
|
106
|
+
'ifdef_': [
|
|
107
|
+
include('expr'),
|
|
108
|
+
(r'\n', Text, 'ifdef'),
|
|
109
|
+
],
|
|
110
|
+
'ifdef': [
|
|
111
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(ifdef)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
112
|
+
(words(('rls', 'dbg'), prefix=r'\b', suffix=r'\b'), Keyword.Constant, 'ifdef_sp'),
|
|
113
|
+
include('statement'),
|
|
114
|
+
include('break'),
|
|
115
|
+
include('skip'),
|
|
116
|
+
],
|
|
117
|
+
'ifdef_sp': [
|
|
118
|
+
include('expr'),
|
|
119
|
+
(r'\n', Text, '#pop'),
|
|
120
|
+
],
|
|
121
|
+
'if_': [
|
|
122
|
+
include('expr'),
|
|
123
|
+
(r'\n', Text, 'if'),
|
|
124
|
+
],
|
|
125
|
+
'if': [
|
|
126
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(if)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
127
|
+
(words(('elif', 'else'), prefix=r'\b', suffix=r'\b'), Keyword, 'if_sp'),
|
|
128
|
+
include('statement'),
|
|
129
|
+
include('break'),
|
|
130
|
+
include('skip'),
|
|
131
|
+
],
|
|
132
|
+
'if_sp': [
|
|
133
|
+
include('expr'),
|
|
134
|
+
(r'\n', Text, '#pop'),
|
|
135
|
+
],
|
|
136
|
+
'switch_': [
|
|
137
|
+
include('expr'),
|
|
138
|
+
(r'\n', Text, 'switch'),
|
|
139
|
+
],
|
|
140
|
+
'switch': [
|
|
141
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(switch)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
142
|
+
(words(('case', 'default', 'to'), prefix=r'\b', suffix=r'\b'), Keyword, 'switch_sp'),
|
|
143
|
+
include('statement'),
|
|
144
|
+
include('break'),
|
|
145
|
+
include('skip'),
|
|
146
|
+
],
|
|
147
|
+
'switch_sp': [
|
|
148
|
+
include('expr'),
|
|
149
|
+
(r'\n', Text, '#pop'),
|
|
150
|
+
],
|
|
151
|
+
'while_': [
|
|
152
|
+
include('expr'),
|
|
153
|
+
(r'\n', Text, 'while'),
|
|
154
|
+
],
|
|
155
|
+
'while': [
|
|
156
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(while)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
157
|
+
include('statement'),
|
|
158
|
+
include('break'),
|
|
159
|
+
include('skip'),
|
|
160
|
+
],
|
|
161
|
+
'for_': [
|
|
162
|
+
include('expr'),
|
|
163
|
+
(r'\n', Text, 'for'),
|
|
164
|
+
],
|
|
165
|
+
'for': [
|
|
166
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(for)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
167
|
+
include('statement'),
|
|
168
|
+
include('break'),
|
|
169
|
+
include('skip'),
|
|
170
|
+
],
|
|
171
|
+
'foreach_': [
|
|
172
|
+
include('expr'),
|
|
173
|
+
(r'\n', Text, 'foreach'),
|
|
174
|
+
],
|
|
175
|
+
'foreach': [
|
|
176
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(foreach)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
177
|
+
include('statement'),
|
|
178
|
+
include('break'),
|
|
179
|
+
include('skip'),
|
|
180
|
+
],
|
|
181
|
+
'try_': [
|
|
182
|
+
include('expr'),
|
|
183
|
+
(r'\n', Text, 'try'),
|
|
184
|
+
],
|
|
185
|
+
'try': [
|
|
186
|
+
(r'\b(end)([ \t]+(?:\n\s*\|)*[ \t]*)(try)\b', bygroups(Keyword, using(this), Keyword), '#pop:2'),
|
|
187
|
+
(words(('catch', 'finally', 'to'), prefix=r'\b', suffix=r'\b'), Keyword, 'try_sp'),
|
|
188
|
+
include('statement'),
|
|
189
|
+
include('break'),
|
|
190
|
+
include('skip'),
|
|
191
|
+
],
|
|
192
|
+
'try_sp': [
|
|
193
|
+
include('expr'),
|
|
194
|
+
(r'\n', Text, '#pop'),
|
|
195
|
+
],
|
|
196
|
+
|
|
197
|
+
# Line-statement
|
|
198
|
+
'break': [
|
|
199
|
+
(r'\b(break)\b([ \t]+)([a-zA-Z_][0-9a-zA-Z_]*)', bygroups(Keyword, using(this), Name.Other)),
|
|
200
|
+
],
|
|
201
|
+
'skip': [
|
|
202
|
+
(r'\b(skip)\b([ \t]+)([a-zA-Z_][0-9a-zA-Z_]*)', bygroups(Keyword, using(this), Name.Other)),
|
|
203
|
+
],
|
|
204
|
+
'alias': [
|
|
205
|
+
include('expr'),
|
|
206
|
+
(r'\n', Text, '#pop'),
|
|
207
|
+
],
|
|
208
|
+
'assert': [
|
|
209
|
+
include('expr'),
|
|
210
|
+
(r'\n', Text, '#pop'),
|
|
211
|
+
],
|
|
212
|
+
'const': [
|
|
213
|
+
include('expr'),
|
|
214
|
+
(r'\n', Text, '#pop'),
|
|
215
|
+
],
|
|
216
|
+
'do': [
|
|
217
|
+
include('expr'),
|
|
218
|
+
(r'\n', Text, '#pop'),
|
|
219
|
+
],
|
|
220
|
+
'ret': [
|
|
221
|
+
include('expr'),
|
|
222
|
+
(r'\n', Text, '#pop'),
|
|
223
|
+
],
|
|
224
|
+
'throw': [
|
|
225
|
+
include('expr'),
|
|
226
|
+
(r'\n', Text, '#pop'),
|
|
227
|
+
],
|
|
228
|
+
'var': [
|
|
229
|
+
include('expr'),
|
|
230
|
+
(r'\n', Text, '#pop'),
|
|
231
|
+
],
|
|
232
|
+
'continued_line': [
|
|
233
|
+
include('expr'),
|
|
234
|
+
(r'\n', Text, '#pop'),
|
|
235
|
+
],
|
|
236
|
+
|
|
237
|
+
'expr': [
|
|
238
|
+
# Whitespace / Comment
|
|
239
|
+
include('whitespace'),
|
|
240
|
+
|
|
241
|
+
# Punctuation
|
|
242
|
+
(r'\(', Punctuation,),
|
|
243
|
+
(r'\)', Punctuation,),
|
|
244
|
+
(r'\[', Punctuation,),
|
|
245
|
+
(r'\]', Punctuation,),
|
|
246
|
+
(r',', Punctuation),
|
|
247
|
+
|
|
248
|
+
# Keyword
|
|
249
|
+
(words((
|
|
250
|
+
'true', 'false', 'null', 'inf'
|
|
251
|
+
), prefix=r'\b', suffix=r'\b'), Keyword.Constant),
|
|
252
|
+
(words((
|
|
253
|
+
'me'
|
|
254
|
+
), prefix=r'\b', suffix=r'\b'), Keyword),
|
|
255
|
+
(words((
|
|
256
|
+
'bit16', 'bit32', 'bit64', 'bit8', 'bool',
|
|
257
|
+
'char', 'class', 'dict', 'enum', 'float', 'func',
|
|
258
|
+
'int', 'list', 'queue', 'stack'
|
|
259
|
+
), prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
|
260
|
+
|
|
261
|
+
# Number
|
|
262
|
+
(r'\b[0-9]\.[0-9]+(?!\.)(:?e[\+-][0-9]+)?\b', Number.Float),
|
|
263
|
+
(r'\b2#[01]+(?:b(?:8|16|32|64))?\b', Number.Bin),
|
|
264
|
+
(r'\b8#[0-7]+(?:b(?:8|16|32|64))?\b', Number.Oct),
|
|
265
|
+
(r'\b16#[0-9A-F]+(?:b(?:8|16|32|64))?\b', Number.Hex),
|
|
266
|
+
(r'\b[0-9]+(?:b(?:8|16|32|64))?\b', Number.Decimal),
|
|
267
|
+
|
|
268
|
+
# String / Char
|
|
269
|
+
(r'"', String.Double, 'string'),
|
|
270
|
+
(r"'(?:\\.|.)+?'", String.Char),
|
|
271
|
+
|
|
272
|
+
# Operator
|
|
273
|
+
(r'(?:\.|\$(?:>|<)?)', Operator),
|
|
274
|
+
(r'(?:\^)', Operator),
|
|
275
|
+
(r'(?:\+|-|!|##?)', Operator),
|
|
276
|
+
(r'(?:\*|/|%)', Operator),
|
|
277
|
+
(r'(?:~)', Operator),
|
|
278
|
+
(r'(?:(?:=|<>)(?:&|\$)?|<=?|>=?)', Operator),
|
|
279
|
+
(r'(?:&)', Operator),
|
|
280
|
+
(r'(?:\|)', Operator),
|
|
281
|
+
(r'(?:\?)', Operator),
|
|
282
|
+
(r'(?::(?::|\+|-|\*|/|%|\^|~)?)', Operator),
|
|
283
|
+
|
|
284
|
+
# Identifier
|
|
285
|
+
(r"\b([a-zA-Z_][0-9a-zA-Z_]*)(?=@)\b", Name),
|
|
286
|
+
(r"(@)?\b([a-zA-Z_][0-9a-zA-Z_]*)\b", bygroups(Name.Other, Name.Variable)),
|
|
287
|
+
],
|
|
288
|
+
|
|
289
|
+
# String
|
|
290
|
+
'string': [
|
|
291
|
+
(r'(?:\\[^{\n]|[^"\\])+', String.Double),
|
|
292
|
+
(r'\\\{', String.Double, 'toStrInString'),
|
|
293
|
+
(r'"', String.Double, '#pop'),
|
|
294
|
+
],
|
|
295
|
+
'toStrInString': [
|
|
296
|
+
include('expr'),
|
|
297
|
+
(r'\}', String.Double, '#pop'),
|
|
298
|
+
],
|
|
299
|
+
}
|
|
@@ -1536,7 +1536,7 @@ class EmacsLispLexer(RegexLexer):
|
|
|
1536
1536
|
.. versionadded:: 2.1
|
|
1537
1537
|
"""
|
|
1538
1538
|
name = 'EmacsLisp'
|
|
1539
|
-
aliases = ['emacs', 'elisp', 'emacs
|
|
1539
|
+
aliases = ['emacs-lisp', 'elisp', 'emacs']
|
|
1540
1540
|
filenames = ['*.el']
|
|
1541
1541
|
mimetypes = ['text/x-elisp', 'application/x-elisp']
|
|
1542
1542
|
|
|
@@ -2631,23 +2631,22 @@ class FennelLexer(RegexLexer):
|
|
|
2631
2631
|
aliases = ['fennel', 'fnl']
|
|
2632
2632
|
filenames = ['*.fnl']
|
|
2633
2633
|
|
|
2634
|
-
#
|
|
2635
|
-
# https://gitlab.com/technomancy/fennel-mode
|
|
2636
|
-
# this list is current as of Fennel version 0.6.0.
|
|
2634
|
+
# this list is current as of Fennel version 0.10.0.
|
|
2637
2635
|
special_forms = (
|
|
2638
|
-
'
|
|
2639
|
-
'
|
|
2640
|
-
'
|
|
2641
|
-
'
|
|
2642
|
-
'
|
|
2643
|
-
'
|
|
2644
|
-
'
|
|
2645
|
-
'
|
|
2646
|
-
|
|
2647
|
-
|
|
2636
|
+
'#', '%', '*', '+', '-', '->', '->>', '-?>', '-?>>', '.', '..',
|
|
2637
|
+
'/', '//', ':', '<', '<=', '=', '>', '>=', '?.', '^', 'accumulate',
|
|
2638
|
+
'and', 'band', 'bnot', 'bor', 'bxor', 'collect', 'comment', 'do', 'doc',
|
|
2639
|
+
'doto', 'each', 'eval-compiler', 'for', 'hashfn', 'icollect', 'if',
|
|
2640
|
+
'import-macros', 'include', 'length', 'let', 'lshift', 'lua',
|
|
2641
|
+
'macrodebug', 'match', 'not', 'not=', 'or', 'partial', 'pick-args',
|
|
2642
|
+
'pick-values', 'quote', 'require-macros', 'rshift', 'set',
|
|
2643
|
+
'set-forcibly!', 'tset', 'values', 'when', 'while', 'with-open', '~='
|
|
2644
|
+
)
|
|
2645
|
+
|
|
2646
|
+
declarations = (
|
|
2647
|
+
'fn', 'global', 'lambda', 'local', 'macro', 'macros', 'var', 'λ'
|
|
2648
2648
|
)
|
|
2649
2649
|
|
|
2650
|
-
# Might be nicer to use the list from _lua_builtins.py but it's unclear how?
|
|
2651
2650
|
builtins = (
|
|
2652
2651
|
'_G', '_VERSION', 'arg', 'assert', 'bit32', 'collectgarbage',
|
|
2653
2652
|
'coroutine', 'debug', 'dofile', 'error', 'getfenv',
|
|
@@ -2673,6 +2672,8 @@ class FennelLexer(RegexLexer):
|
|
|
2673
2672
|
|
|
2674
2673
|
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
|
2675
2674
|
|
|
2675
|
+
(r'(true|false|nil)', Name.Constant),
|
|
2676
|
+
|
|
2676
2677
|
# these are technically strings, but it's worth visually
|
|
2677
2678
|
# distinguishing them because their intent is different
|
|
2678
2679
|
# from regular strings.
|
|
@@ -2680,6 +2681,8 @@ class FennelLexer(RegexLexer):
|
|
|
2680
2681
|
|
|
2681
2682
|
# special forms are keywords
|
|
2682
2683
|
(words(special_forms, suffix=' '), Keyword),
|
|
2684
|
+
# these are ... even more special!
|
|
2685
|
+
(words(declarations, suffix=' '), Keyword.Declaration),
|
|
2683
2686
|
# lua standard library are builtins
|
|
2684
2687
|
(words(builtins, suffix=' '), Name.Builtin),
|
|
2685
2688
|
# special-case the vararg symbol
|
|
@@ -121,7 +121,7 @@ class RstLexer(RegexLexer):
|
|
|
121
121
|
.. versionadded:: 0.8
|
|
122
122
|
"""
|
|
123
123
|
name = 'reStructuredText'
|
|
124
|
-
aliases = ['
|
|
124
|
+
aliases = ['restructuredtext', 'rst', 'rest']
|
|
125
125
|
filenames = ['*.rst', '*.rest']
|
|
126
126
|
mimetypes = ["text/x-rst", "text/prs.fallenstein.rst"]
|
|
127
127
|
flags = re.MULTILINE
|
|
@@ -501,8 +501,8 @@ class MarkdownLexer(RegexLexer):
|
|
|
501
501
|
|
|
502
502
|
.. versionadded:: 2.2
|
|
503
503
|
"""
|
|
504
|
-
name = '
|
|
505
|
-
aliases = ['
|
|
504
|
+
name = 'Markdown'
|
|
505
|
+
aliases = ['markdown', 'md']
|
|
506
506
|
filenames = ['*.md', '*.markdown']
|
|
507
507
|
mimetypes = ["text/x-markdown"]
|
|
508
508
|
flags = re.MULTILINE
|
|
@@ -20,7 +20,6 @@ from pygments.lexers import _scilab_builtins
|
|
|
20
20
|
__all__ = ['MatlabLexer', 'MatlabSessionLexer', 'OctaveLexer', 'ScilabLexer']
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
class MatlabLexer(RegexLexer):
|
|
25
24
|
"""
|
|
26
25
|
For Matlab source code.
|
|
@@ -2783,8 +2782,8 @@ class MatlabSessionLexer(Lexer):
|
|
|
2783
2782
|
# Set leading spaces with the length of the prompt to be a generic prompt
|
|
2784
2783
|
# This keeps code aligned when prompts are removed, say with some Javascript
|
|
2785
2784
|
if line.startswith(' '*line_start):
|
|
2786
|
-
insertions.append(
|
|
2787
|
-
|
|
2785
|
+
insertions.append(
|
|
2786
|
+
(len(curcode), [(0, Generic.Prompt, line[:line_start])]))
|
|
2788
2787
|
curcode += line[line_start:]
|
|
2789
2788
|
else:
|
|
2790
2789
|
curcode += line
|
|
@@ -3146,18 +3145,21 @@ class OctaveLexer(RegexLexer):
|
|
|
3146
3145
|
|
|
3147
3146
|
tokens = {
|
|
3148
3147
|
'root': [
|
|
3149
|
-
|
|
3148
|
+
(r'%\{\s*\n', Comment.Multiline, 'percentblockcomment'),
|
|
3149
|
+
(r'#\{\s*\n', Comment.Multiline, 'hashblockcomment'),
|
|
3150
3150
|
(r'[%#].*$', Comment),
|
|
3151
3151
|
(r'^\s*function\b', Keyword, 'deffunc'),
|
|
3152
3152
|
|
|
3153
3153
|
# from 'iskeyword' on hg changeset 8cc154f45e37
|
|
3154
3154
|
(words((
|
|
3155
|
-
'__FILE__', '__LINE__', 'break', 'case', 'catch', 'classdef',
|
|
3156
|
-
'
|
|
3157
|
-
'
|
|
3158
|
-
'
|
|
3159
|
-
'
|
|
3160
|
-
'
|
|
3155
|
+
'__FILE__', '__LINE__', 'break', 'case', 'catch', 'classdef',
|
|
3156
|
+
'continue', 'do', 'else', 'elseif', 'end', 'end_try_catch',
|
|
3157
|
+
'end_unwind_protect', 'endclassdef', 'endevents', 'endfor',
|
|
3158
|
+
'endfunction', 'endif', 'endmethods', 'endproperties', 'endswitch',
|
|
3159
|
+
'endwhile', 'events', 'for', 'function', 'get', 'global', 'if',
|
|
3160
|
+
'methods', 'otherwise', 'persistent', 'properties', 'return',
|
|
3161
|
+
'set', 'static', 'switch', 'try', 'until', 'unwind_protect',
|
|
3162
|
+
'unwind_protect_cleanup', 'while'), suffix=r'\b'),
|
|
3161
3163
|
Keyword),
|
|
3162
3164
|
|
|
3163
3165
|
(words(builtin_kw + command_kw + function_kw + loadable_kw + mapping_kw,
|
|
@@ -3191,8 +3193,19 @@ class OctaveLexer(RegexLexer):
|
|
|
3191
3193
|
(r'(?<![\w)\].])\'', String, 'string'),
|
|
3192
3194
|
|
|
3193
3195
|
(r'[a-zA-Z_]\w*', Name),
|
|
3196
|
+
(r'\s+', Text),
|
|
3194
3197
|
(r'.', Text),
|
|
3195
3198
|
],
|
|
3199
|
+
'percentblockcomment': [
|
|
3200
|
+
(r'^\s*%\}', Comment.Multiline, '#pop'),
|
|
3201
|
+
(r'^.*\n', Comment.Multiline),
|
|
3202
|
+
(r'.', Comment.Multiline),
|
|
3203
|
+
],
|
|
3204
|
+
'hashblockcomment': [
|
|
3205
|
+
(r'^\s*#\}', Comment.Multiline, '#pop'),
|
|
3206
|
+
(r'^.*\n', Comment.Multiline),
|
|
3207
|
+
(r'.', Comment.Multiline),
|
|
3208
|
+
],
|
|
3196
3209
|
'string': [
|
|
3197
3210
|
(r"[^']*'", String, '#pop'),
|
|
3198
3211
|
],
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pygments.lexers.meson
|
|
3
|
+
~~~~~~~~~~~~~~~~~~~~~
|
|
4
|
+
|
|
5
|
+
Pygments lexer for the Meson build system
|
|
6
|
+
|
|
7
|
+
:copyright: Copyright 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 (
|
|
14
|
+
RegexLexer,
|
|
15
|
+
words,
|
|
16
|
+
include,
|
|
17
|
+
)
|
|
18
|
+
from pygments.token import (
|
|
19
|
+
Comment,
|
|
20
|
+
Name,
|
|
21
|
+
Number,
|
|
22
|
+
Punctuation,
|
|
23
|
+
Operator,
|
|
24
|
+
Keyword,
|
|
25
|
+
String,
|
|
26
|
+
Whitespace,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
__all__ = ['MesonLexer']
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MesonLexer(RegexLexer):
|
|
33
|
+
"""
|
|
34
|
+
`meson <https://mesonbuild.com/>`_ language lexer.
|
|
35
|
+
The grammar definition use to transcribe the syntax was retrieved from
|
|
36
|
+
https://mesonbuild.com/Syntax.html#grammar for version 0.58
|
|
37
|
+
Some of those definitions are improperly transcribed so the Meson++
|
|
38
|
+
implementation was also checked: https://github.com/dcbaker/meson-plus-plus
|
|
39
|
+
|
|
40
|
+
.. versionadded:: 2.10
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
# TODO String interpolation @VARNAME@ inner matches
|
|
44
|
+
# TODO keyword_arg: value inner matches
|
|
45
|
+
|
|
46
|
+
name = 'Meson'
|
|
47
|
+
aliases = ['meson', 'meson.build']
|
|
48
|
+
filenames = ['meson.build', 'meson_options.txt']
|
|
49
|
+
mimetypes = ['text/x-meson']
|
|
50
|
+
|
|
51
|
+
flags = re.MULTILINE | re.UNICODE
|
|
52
|
+
|
|
53
|
+
tokens = {
|
|
54
|
+
'root': [
|
|
55
|
+
(r'#.*?$', Comment),
|
|
56
|
+
(r"'''.*'''", String.Single),
|
|
57
|
+
(r'[1-9][0-9]*', Number.Integer),
|
|
58
|
+
(r'0o[0-7]+', Number.Oct),
|
|
59
|
+
(r'0x[a-fA-F0-9]+', Number.Hex),
|
|
60
|
+
include('string'),
|
|
61
|
+
include('keywords'),
|
|
62
|
+
include('expr'),
|
|
63
|
+
(r'[a-zA-Z_][a-zA-Z_0-9]*', Name),
|
|
64
|
+
(r'\s+', Whitespace),
|
|
65
|
+
],
|
|
66
|
+
'string': [
|
|
67
|
+
(r"[']{3}([']{0,2}([^\\']|\\(.|\n)))*[']{3}", String),
|
|
68
|
+
(r"'.*?(?<!\\)(\\\\)*?'", String),
|
|
69
|
+
],
|
|
70
|
+
'keywords': [
|
|
71
|
+
(words((
|
|
72
|
+
'if',
|
|
73
|
+
'elif',
|
|
74
|
+
'else',
|
|
75
|
+
'endif',
|
|
76
|
+
'foreach',
|
|
77
|
+
'endforeach',
|
|
78
|
+
'break',
|
|
79
|
+
'continue',
|
|
80
|
+
),
|
|
81
|
+
suffix=r'\b'), Keyword),
|
|
82
|
+
],
|
|
83
|
+
'expr': [
|
|
84
|
+
(r'(in|and|or|not)\b', Operator.Word),
|
|
85
|
+
(r'(\*=|/=|%=|\+]=|-=|==|!=|\+|-|=)', Operator),
|
|
86
|
+
(r'[\[\]{}:().,?]', Punctuation),
|
|
87
|
+
(words(('true', 'false'), suffix=r'\b'), Keyword.Constant),
|
|
88
|
+
include('builtins'),
|
|
89
|
+
(words((
|
|
90
|
+
'meson',
|
|
91
|
+
'build_machine',
|
|
92
|
+
'host_machine',
|
|
93
|
+
'target_machine',
|
|
94
|
+
),
|
|
95
|
+
suffix=r'\b'), Name.Variable.Magic),
|
|
96
|
+
],
|
|
97
|
+
'builtins': [
|
|
98
|
+
# This list was extracted from the v0.58 reference manual
|
|
99
|
+
(words((
|
|
100
|
+
'add_global_arguments',
|
|
101
|
+
'add_global_link_arguments',
|
|
102
|
+
'add_languages',
|
|
103
|
+
'add_project_arguments',
|
|
104
|
+
'add_project_link_arguments',
|
|
105
|
+
'add_test_setup',
|
|
106
|
+
'assert',
|
|
107
|
+
'benchmark',
|
|
108
|
+
'both_libraries',
|
|
109
|
+
'build_target',
|
|
110
|
+
'configuration_data',
|
|
111
|
+
'configure_file',
|
|
112
|
+
'custom_target',
|
|
113
|
+
'declare_dependency',
|
|
114
|
+
'dependency',
|
|
115
|
+
'disabler',
|
|
116
|
+
'environment',
|
|
117
|
+
'error',
|
|
118
|
+
'executable',
|
|
119
|
+
'files',
|
|
120
|
+
'find_library',
|
|
121
|
+
'find_program',
|
|
122
|
+
'generator',
|
|
123
|
+
'get_option',
|
|
124
|
+
'get_variable',
|
|
125
|
+
'include_directories',
|
|
126
|
+
'install_data',
|
|
127
|
+
'install_headers',
|
|
128
|
+
'install_man',
|
|
129
|
+
'install_subdir',
|
|
130
|
+
'is_disabler',
|
|
131
|
+
'is_variable',
|
|
132
|
+
'jar',
|
|
133
|
+
'join_paths',
|
|
134
|
+
'library',
|
|
135
|
+
'message',
|
|
136
|
+
'project',
|
|
137
|
+
'range',
|
|
138
|
+
'run_command',
|
|
139
|
+
'set_variable',
|
|
140
|
+
'shared_library',
|
|
141
|
+
'shared_module',
|
|
142
|
+
'static_library',
|
|
143
|
+
'subdir',
|
|
144
|
+
'subdir_done',
|
|
145
|
+
'subproject',
|
|
146
|
+
'summary',
|
|
147
|
+
'test',
|
|
148
|
+
'vcs_tag',
|
|
149
|
+
'warning',
|
|
150
|
+
),
|
|
151
|
+
prefix=r'(?<!\.)',
|
|
152
|
+
suffix=r'\b'), Name.Builtin),
|
|
153
|
+
(r'(?<!\.)import\b', Name.Namespace),
|
|
154
|
+
],
|
|
155
|
+
}
|
|
@@ -21,20 +21,20 @@ __all__ = ["MIMELexer"]
|
|
|
21
21
|
class MIMELexer(RegexLexer):
|
|
22
22
|
"""
|
|
23
23
|
Lexer for Multipurpose Internet Mail Extensions (MIME) data. This lexer is
|
|
24
|
-
designed to process
|
|
24
|
+
designed to process nested multipart data.
|
|
25
25
|
|
|
26
26
|
It assumes that the given data contains both header and body (and is
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
split at an empty line). If no valid header is found, then the entire data
|
|
28
|
+
will be treated as body.
|
|
29
29
|
|
|
30
30
|
Additional options accepted:
|
|
31
31
|
|
|
32
32
|
`MIME-max-level`
|
|
33
|
-
Max
|
|
33
|
+
Max recursion level for nested MIME structure. Any negative number
|
|
34
34
|
would treated as unlimited. (default: -1)
|
|
35
35
|
|
|
36
36
|
`Content-Type`
|
|
37
|
-
Treat the data as specific content type. Useful when header is
|
|
37
|
+
Treat the data as a specific content type. Useful when header is
|
|
38
38
|
missing, or this lexer would try to parse from header. (default:
|
|
39
39
|
`text/plain`)
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ class MIMELexer(RegexLexer):
|
|
|
44
44
|
would try to parse from header by default. (default: None)
|
|
45
45
|
|
|
46
46
|
`Content-Transfer-Encoding`
|
|
47
|
-
Treat the data as specific encoding. Or this lexer would try to parse
|
|
47
|
+
Treat the data as a specific encoding. Or this lexer would try to parse
|
|
48
48
|
from header by default. (default: None)
|
|
49
49
|
|
|
50
50
|
.. versionadded:: 2.5
|
|
@@ -63,21 +63,6 @@ class MIMELexer(RegexLexer):
|
|
|
63
63
|
self.content_type = options.get("Content_Type", "text/plain")
|
|
64
64
|
self.max_nested_level = get_int_opt(options, "MIME-max-level", -1)
|
|
65
65
|
|
|
66
|
-
def analyse_text(text):
|
|
67
|
-
try:
|
|
68
|
-
header, body = text.strip().split("\n\n", 1)
|
|
69
|
-
if not body.strip():
|
|
70
|
-
return 0.1
|
|
71
|
-
|
|
72
|
-
invalid_headers = MIMELexer.tokens["header"].sub("", header)
|
|
73
|
-
if invalid_headers.strip():
|
|
74
|
-
return 0.1
|
|
75
|
-
else:
|
|
76
|
-
return 1
|
|
77
|
-
|
|
78
|
-
except ValueError:
|
|
79
|
-
return 0
|
|
80
|
-
|
|
81
66
|
def get_header_tokens(self, match):
|
|
82
67
|
field = match.group(1)
|
|
83
68
|
|