pygments.rb 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.adoc +5 -0
- data/bench.rb +2 -2
- data/lib/pygments/lexer.rb +1 -1
- data/lib/pygments/mentos.py +6 -4
- data/lib/pygments/popen.rb +14 -7
- data/lib/pygments/version.rb +1 -1
- data/lib/pygments.rb +8 -2
- data/pygments.rb.gemspec +4 -4
- data/test/test_pygments.rb +13 -7
- 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
@@ -68,7 +68,9 @@ class JavaLexer(RegexLexer):
|
|
68
68
|
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
|
69
69
|
(r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Punctuation,
|
70
70
|
Name.Attribute)),
|
71
|
-
(r'
|
71
|
+
(r'^(\s*)(default)(:)', bygroups(Text, Keyword, Punctuation)),
|
72
|
+
(r'^(\s*)((?:[^\W\d]|\$)[\w$]*)(:)', bygroups(Text, Name.Label,
|
73
|
+
Punctuation)),
|
72
74
|
(r'([^\W\d]|\$)[\w$]*', Name),
|
73
75
|
(r'([0-9][0-9_]*\.([0-9][0-9_]*)?|'
|
74
76
|
r'\.[0-9][0-9_]*)'
|
@@ -156,226 +158,278 @@ class ScalaLexer(RegexLexer):
|
|
156
158
|
|
157
159
|
flags = re.MULTILINE | re.DOTALL
|
158
160
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
'\u13a0-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u16ee-\u1711'
|
192
|
-
'\u1720-\u1731\u1740-\u1751\u1760-\u1770\u1780-\u17b3\u17dc'
|
193
|
-
'\u1820-\u1842\u1844-\u18a8\u18aa-\u191c\u1950-\u19a9\u19c1-\u19c7'
|
194
|
-
'\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae-\u1baf'
|
195
|
-
'\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c77\u1d00-\u1d2b\u1d62-\u1d77'
|
196
|
-
'\u1d79-\u1d9a\u1e00-\u1fbc\u1fbe\u1fc2-\u1fcc\u1fd0-\u1fdb'
|
197
|
-
'\u1fe0-\u1fec\u1ff2-\u1ffc\u2071\u207f\u2102\u2107\u210a-\u2113'
|
198
|
-
'\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139'
|
199
|
-
'\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c7c'
|
200
|
-
'\u2c80-\u2ce4\u2d00-\u2d65\u2d80-\u2dde\u3006-\u3007\u3021-\u3029'
|
201
|
-
'\u3038-\u303a\u303c\u3041-\u3096\u309f\u30a1-\u30fa\u30ff-\u318e'
|
202
|
-
'\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\ua014\ua016-\ua48c'
|
203
|
-
'\ua500-\ua60b\ua610-\ua61f\ua62a-\ua66e\ua680-\ua697\ua722-\ua76f'
|
204
|
-
'\ua771-\ua787\ua78b-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822'
|
205
|
-
'\ua840-\ua873\ua882-\ua8b3\ua90a-\ua925\ua930-\ua946\uaa00-\uaa28'
|
206
|
-
'\uaa40-\uaa42\uaa44-\uaa4b\uac00-\ud7a3\uf900-\ufb1d\ufb1f-\ufb28'
|
207
|
-
'\ufb2a-\ufd3d\ufd50-\ufdfb\ufe70-\ufefc\uff21-\uff3a\uff41-\uff5a'
|
208
|
-
'\uff66-\uff6f\uff71-\uff9d\uffa0-\uffdc]')
|
209
|
-
|
210
|
-
upper = ('[A-Z\\$_\u00c0-\u00d6\u00d8-\u00de\u0100\u0102\u0104\u0106\u0108'
|
211
|
-
'\u010a\u010c\u010e\u0110\u0112\u0114\u0116\u0118\u011a\u011c'
|
212
|
-
'\u011e\u0120\u0122\u0124\u0126\u0128\u012a\u012c\u012e\u0130'
|
213
|
-
'\u0132\u0134\u0136\u0139\u013b\u013d\u013f\u0141\u0143\u0145'
|
214
|
-
'\u0147\u014a\u014c\u014e\u0150\u0152\u0154\u0156\u0158\u015a'
|
215
|
-
'\u015c\u015e\u0160\u0162\u0164\u0166\u0168\u016a\u016c\u016e'
|
216
|
-
'\u0170\u0172\u0174\u0176\u0178-\u0179\u017b\u017d\u0181-\u0182'
|
217
|
-
'\u0184\u0186-\u0187\u0189-\u018b\u018e-\u0191\u0193-\u0194'
|
218
|
-
'\u0196-\u0198\u019c-\u019d\u019f-\u01a0\u01a2\u01a4\u01a6-\u01a7'
|
219
|
-
'\u01a9\u01ac\u01ae-\u01af\u01b1-\u01b3\u01b5\u01b7-\u01b8\u01bc'
|
220
|
-
'\u01c4\u01c7\u01ca\u01cd\u01cf\u01d1\u01d3\u01d5\u01d7\u01d9'
|
221
|
-
'\u01db\u01de\u01e0\u01e2\u01e4\u01e6\u01e8\u01ea\u01ec\u01ee'
|
222
|
-
'\u01f1\u01f4\u01f6-\u01f8\u01fa\u01fc\u01fe\u0200\u0202\u0204'
|
223
|
-
'\u0206\u0208\u020a\u020c\u020e\u0210\u0212\u0214\u0216\u0218'
|
224
|
-
'\u021a\u021c\u021e\u0220\u0222\u0224\u0226\u0228\u022a\u022c'
|
225
|
-
'\u022e\u0230\u0232\u023a-\u023b\u023d-\u023e\u0241\u0243-\u0246'
|
226
|
-
'\u0248\u024a\u024c\u024e\u0370\u0372\u0376\u0386\u0388-\u038f'
|
227
|
-
'\u0391-\u03ab\u03cf\u03d2-\u03d4\u03d8\u03da\u03dc\u03de\u03e0'
|
228
|
-
'\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7'
|
229
|
-
'\u03f9-\u03fa\u03fd-\u042f\u0460\u0462\u0464\u0466\u0468\u046a'
|
230
|
-
'\u046c\u046e\u0470\u0472\u0474\u0476\u0478\u047a\u047c\u047e'
|
231
|
-
'\u0480\u048a\u048c\u048e\u0490\u0492\u0494\u0496\u0498\u049a'
|
232
|
-
'\u049c\u049e\u04a0\u04a2\u04a4\u04a6\u04a8\u04aa\u04ac\u04ae'
|
233
|
-
'\u04b0\u04b2\u04b4\u04b6\u04b8\u04ba\u04bc\u04be\u04c0-\u04c1'
|
234
|
-
'\u04c3\u04c5\u04c7\u04c9\u04cb\u04cd\u04d0\u04d2\u04d4\u04d6'
|
235
|
-
'\u04d8\u04da\u04dc\u04de\u04e0\u04e2\u04e4\u04e6\u04e8\u04ea'
|
236
|
-
'\u04ec\u04ee\u04f0\u04f2\u04f4\u04f6\u04f8\u04fa\u04fc\u04fe'
|
237
|
-
'\u0500\u0502\u0504\u0506\u0508\u050a\u050c\u050e\u0510\u0512'
|
238
|
-
'\u0514\u0516\u0518\u051a\u051c\u051e\u0520\u0522\u0531-\u0556'
|
239
|
-
'\u10a0-\u10c5\u1e00\u1e02\u1e04\u1e06\u1e08\u1e0a\u1e0c\u1e0e'
|
240
|
-
'\u1e10\u1e12\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1e1e\u1e20\u1e22'
|
241
|
-
'\u1e24\u1e26\u1e28\u1e2a\u1e2c\u1e2e\u1e30\u1e32\u1e34\u1e36'
|
242
|
-
'\u1e38\u1e3a\u1e3c\u1e3e\u1e40\u1e42\u1e44\u1e46\u1e48\u1e4a'
|
243
|
-
'\u1e4c\u1e4e\u1e50\u1e52\u1e54\u1e56\u1e58\u1e5a\u1e5c\u1e5e'
|
244
|
-
'\u1e60\u1e62\u1e64\u1e66\u1e68\u1e6a\u1e6c\u1e6e\u1e70\u1e72'
|
245
|
-
'\u1e74\u1e76\u1e78\u1e7a\u1e7c\u1e7e\u1e80\u1e82\u1e84\u1e86'
|
246
|
-
'\u1e88\u1e8a\u1e8c\u1e8e\u1e90\u1e92\u1e94\u1e9e\u1ea0\u1ea2'
|
247
|
-
'\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6'
|
248
|
-
'\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6\u1ec8\u1eca'
|
249
|
-
'\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede'
|
250
|
-
'\u1ee0\u1ee2\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0\u1ef2'
|
251
|
-
'\u1ef4\u1ef6\u1ef8\u1efa\u1efc\u1efe\u1f08-\u1f0f\u1f18-\u1f1d'
|
252
|
-
'\u1f28-\u1f2f\u1f38-\u1f3f\u1f48-\u1f4d\u1f59-\u1f5f'
|
253
|
-
'\u1f68-\u1f6f\u1fb8-\u1fbb\u1fc8-\u1fcb\u1fd8-\u1fdb'
|
254
|
-
'\u1fe8-\u1fec\u1ff8-\u1ffb\u2102\u2107\u210b-\u210d\u2110-\u2112'
|
255
|
-
'\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u2130-\u2133'
|
256
|
-
'\u213e-\u213f\u2145\u2183\u2c00-\u2c2e\u2c60\u2c62-\u2c64\u2c67'
|
257
|
-
'\u2c69\u2c6b\u2c6d-\u2c6f\u2c72\u2c75\u2c80\u2c82\u2c84\u2c86'
|
258
|
-
'\u2c88\u2c8a\u2c8c\u2c8e\u2c90\u2c92\u2c94\u2c96\u2c98\u2c9a'
|
259
|
-
'\u2c9c\u2c9e\u2ca0\u2ca2\u2ca4\u2ca6\u2ca8\u2caa\u2cac\u2cae'
|
260
|
-
'\u2cb0\u2cb2\u2cb4\u2cb6\u2cb8\u2cba\u2cbc\u2cbe\u2cc0\u2cc2'
|
261
|
-
'\u2cc4\u2cc6\u2cc8\u2cca\u2ccc\u2cce\u2cd0\u2cd2\u2cd4\u2cd6'
|
262
|
-
'\u2cd8\u2cda\u2cdc\u2cde\u2ce0\u2ce2\ua640\ua642\ua644\ua646'
|
263
|
-
'\ua648\ua64a\ua64c\ua64e\ua650\ua652\ua654\ua656\ua658\ua65a'
|
264
|
-
'\ua65c\ua65e\ua662\ua664\ua666\ua668\ua66a\ua66c\ua680\ua682'
|
265
|
-
'\ua684\ua686\ua688\ua68a\ua68c\ua68e\ua690\ua692\ua694\ua696'
|
266
|
-
'\ua722\ua724\ua726\ua728\ua72a\ua72c\ua72e\ua732\ua734\ua736'
|
267
|
-
'\ua738\ua73a\ua73c\ua73e\ua740\ua742\ua744\ua746\ua748\ua74a'
|
268
|
-
'\ua74c\ua74e\ua750\ua752\ua754\ua756\ua758\ua75a\ua75c\ua75e'
|
269
|
-
'\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b'
|
270
|
-
'\ua77d-\ua77e\ua780\ua782\ua784\ua786\ua78b\uff21-\uff3a]')
|
271
|
-
|
272
|
-
idrest = '%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op)
|
273
|
-
letter_letter_digit = '%s(?:%s|\\d)*' % (letter, letter)
|
161
|
+
opchar = '[!#%&*\\-\\/:?@^' + uni.combine('Sm', 'So') + ']'
|
162
|
+
letter = '[_\\$' + uni.combine('Ll', 'Lu', 'Lo', 'Nl', 'Lt') + ']'
|
163
|
+
upperLetter = '[' + uni.combine('Lu', 'Lt') + ']'
|
164
|
+
letterOrDigit = '(?:%s|[0-9])' % letter
|
165
|
+
letterOrDigitNoDollarSign = '(?:%s|[0-9])' % letter.replace('\\$', '')
|
166
|
+
alphaId = '%s+' % letter
|
167
|
+
simpleInterpolatedVariable = '%s%s*' % (letter, letterOrDigitNoDollarSign)
|
168
|
+
idrest = '%s%s*(?:(?<=_)%s+)?' % (letter, letterOrDigit, opchar)
|
169
|
+
idUpper = '%s%s*(?:(?<=_)%s+)?' % (upperLetter, letterOrDigit, opchar)
|
170
|
+
plainid = '(?:%s|%s+)' % (idrest, opchar)
|
171
|
+
backQuotedId = r'`[^`]+`'
|
172
|
+
anyId = r'(?:%s|%s)' % (plainid, backQuotedId)
|
173
|
+
notStartOfComment = r'(?!//|/\*)'
|
174
|
+
endOfLineMaybeWithComment = r'(?=\s*(//|$))'
|
175
|
+
|
176
|
+
keywords = (
|
177
|
+
'new', 'return', 'throw', 'classOf', 'isInstanceOf', 'asInstanceOf',
|
178
|
+
'else', 'if', 'then', 'do', 'while', 'for', 'yield', 'match', 'case',
|
179
|
+
'catch', 'finally', 'try'
|
180
|
+
)
|
181
|
+
|
182
|
+
operators = (
|
183
|
+
'<%', '=:=', '<:<', '<%<', '>:', '<:', '=', '==', '!=', '<=', '>=',
|
184
|
+
'<>', '<', '>', '<-', '←', '->', '→', '=>', '⇒', '?', '@', '|', '-',
|
185
|
+
'+', '*', '%', '~', '\\'
|
186
|
+
)
|
187
|
+
|
188
|
+
storage_modifiers = (
|
189
|
+
'private', 'protected', 'synchronized', '@volatile', 'abstract',
|
190
|
+
'final', 'lazy', 'sealed', 'implicit', 'override', '@transient',
|
191
|
+
'@native'
|
192
|
+
)
|
274
193
|
|
275
194
|
tokens = {
|
276
195
|
'root': [
|
277
|
-
|
278
|
-
(r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'),
|
279
|
-
(r'[^\S\n]+', Text),
|
280
|
-
include('comments'),
|
281
|
-
(r'@%s' % idrest, Name.Decorator),
|
282
|
-
(r'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|'
|
283
|
-
r'f(?:inal(?:ly)?|or(?:Some)?)|i(?:f|mplicit)|'
|
284
|
-
r'lazy|match|new|override|pr(?:ivate|otected)'
|
285
|
-
r'|re(?:quires|turn)|s(?:ealed|uper)|'
|
286
|
-
r't(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\b|'
|
287
|
-
r'(<[%:-]|=>|>:|[#=@_\u21D2\u2190])\b', Keyword),
|
288
|
-
(r':(?!%s)' % op, Keyword, 'type'),
|
289
|
-
(r'%s%s\b' % (upper, idrest), Name.Class),
|
290
|
-
(r'(true|false|null)\b', Keyword.Constant),
|
291
|
-
(r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
|
292
|
-
(r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
|
293
|
-
(r'""".*?"""(?!")', String),
|
294
|
-
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
295
|
-
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
|
296
|
-
(r"'%s" % idrest, Text.Symbol),
|
297
|
-
(r'[fs]"""', String, 'interptriplestring'), # interpolated strings
|
298
|
-
(r'[fs]"', String, 'interpstring'), # interpolated strings
|
299
|
-
(r'raw"(\\\\|\\[^\\]|[^"\\])*"', String), # raw strings
|
300
|
-
# (r'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
|
301
|
-
# Name.Attribute)),
|
302
|
-
(idrest, Name),
|
303
|
-
(r'`[^`]+`', Name),
|
304
|
-
(r'\[', Operator, 'typeparam'),
|
305
|
-
(r'[(){};,.#]', Operator),
|
306
|
-
(op, Operator),
|
307
|
-
(r'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?',
|
308
|
-
Number.Float),
|
309
|
-
(r'0x[0-9a-fA-F]+', Number.Hex),
|
310
|
-
(r'[0-9]+L?', Number.Integer),
|
311
|
-
(r'\n', Text)
|
312
|
-
],
|
313
|
-
'class': [
|
314
|
-
(r'(%s|%s|`[^`]+`)(\s*)(\[)' % (idrest, op),
|
315
|
-
bygroups(Name.Class, Text, Operator), ('#pop', 'typeparam')),
|
316
|
-
(r'\s+', Text),
|
196
|
+
include('whitespace'),
|
317
197
|
include('comments'),
|
318
|
-
(
|
319
|
-
(
|
320
|
-
(
|
198
|
+
include('script-header'),
|
199
|
+
include('imports'),
|
200
|
+
include('exports'),
|
201
|
+
include('storage-modifiers'),
|
202
|
+
include('annotations'),
|
203
|
+
include('using'),
|
204
|
+
include('declarations'),
|
205
|
+
include('inheritance'),
|
206
|
+
include('extension'),
|
207
|
+
include('end'),
|
208
|
+
include('constants'),
|
209
|
+
include('strings'),
|
210
|
+
include('symbols'),
|
211
|
+
include('singleton-type'),
|
212
|
+
include('inline'),
|
213
|
+
include('quoted'),
|
214
|
+
include('keywords'),
|
215
|
+
include('operators'),
|
216
|
+
include('punctuation'),
|
217
|
+
include('names'),
|
321
218
|
],
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
(r'<[%:]|>:|[#_]|\bforSome\b|\btype\b', Keyword),
|
326
|
-
(r'([,);}]|=>|=|\u21d2)(\s*)', bygroups(Operator, Text), '#pop'),
|
327
|
-
(r'[({]', Operator, '#push'),
|
328
|
-
(r'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)(\[)' %
|
329
|
-
(idrest, op, idrest, op),
|
330
|
-
bygroups(Keyword.Type, Text, Operator), ('#pop', 'typeparam')),
|
331
|
-
(r'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)$' %
|
332
|
-
(idrest, op, idrest, op),
|
333
|
-
bygroups(Keyword.Type, Text), '#pop'),
|
334
|
-
(r'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
|
335
|
-
],
|
336
|
-
'typeparam': [
|
219
|
+
|
220
|
+
# Includes:
|
221
|
+
'whitespace': [
|
337
222
|
(r'\s+', Text),
|
338
|
-
include('comments'),
|
339
|
-
(r',+', Punctuation),
|
340
|
-
(r'<[%:]|=>|>:|[#_\u21D2]|\bforSome\b|\btype\b', Keyword),
|
341
|
-
(r'([\])}])', Operator, '#pop'),
|
342
|
-
(r'[(\[{]', Operator, '#push'),
|
343
|
-
(r'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
|
344
223
|
],
|
345
224
|
'comments': [
|
346
225
|
(r'//.*?\n', Comment.Single),
|
347
226
|
(r'/\*', Comment.Multiline, 'comment'),
|
348
227
|
],
|
228
|
+
'script-header': [
|
229
|
+
(r'^#!([^\n]*)$', Comment.Hashbang),
|
230
|
+
],
|
231
|
+
'imports': [
|
232
|
+
(r'\b(import)(\s+)', bygroups(Keyword, Text), 'import-path'),
|
233
|
+
],
|
234
|
+
'exports': [
|
235
|
+
(r'\b(export)(\s+)(given)(\s+)',
|
236
|
+
bygroups(Keyword, Text, Keyword, Text), 'export-path'),
|
237
|
+
(r'\b(export)(\s+)', bygroups(Keyword, Text), 'export-path'),
|
238
|
+
],
|
239
|
+
'storage-modifiers': [
|
240
|
+
(words(storage_modifiers, prefix=r'\b', suffix=r'\b'), Keyword),
|
241
|
+
# Only highlight soft modifiers if they are eventually followed by
|
242
|
+
# the correct keyword. Note that soft modifiers can be followed by a
|
243
|
+
# sequence of regular modifiers; [a-z\s]* skips those, and we just
|
244
|
+
# check that the soft modifier is applied to a supported statement.
|
245
|
+
(r'\b(transparent|opaque|infix|open|inline)\b(?=[a-z\s]*\b'
|
246
|
+
r'(def|val|var|given|type|class|trait|object|enum)\b)', Keyword),
|
247
|
+
],
|
248
|
+
'annotations': [
|
249
|
+
(r'@%s' % idrest, Name.Decorator),
|
250
|
+
],
|
251
|
+
'using': [
|
252
|
+
# using is a soft keyword, can only be used in the first position of
|
253
|
+
# a parameter or argument list.
|
254
|
+
(r'(\()(\s*)(using)(\s)', bygroups(Punctuation, Text, Keyword, Text)),
|
255
|
+
],
|
256
|
+
'declarations': [
|
257
|
+
(r'\b(def)\b(\s*)%s(%s)?' % (notStartOfComment, anyId),
|
258
|
+
bygroups(Keyword, Text, Name.Function)),
|
259
|
+
(r'\b(trait)\b(\s*)%s(%s)?' % (notStartOfComment, anyId),
|
260
|
+
bygroups(Keyword, Text, Name.Class)),
|
261
|
+
(r'\b(?:(case)(\s+))?(class|object|enum)\b(\s*)%s(%s)?' %
|
262
|
+
(notStartOfComment, anyId),
|
263
|
+
bygroups(Keyword, Text, Keyword, Text, Name.Class)),
|
264
|
+
(r'(?<!\.)\b(type)\b(\s*)%s(%s)?' % (notStartOfComment, anyId),
|
265
|
+
bygroups(Keyword, Text, Name.Class)),
|
266
|
+
(r'\b(val|var)\b', Keyword.Declaration),
|
267
|
+
(r'\b(package)(\s+)(object)\b(\s*)%s(%s)?' %
|
268
|
+
(notStartOfComment, anyId),
|
269
|
+
bygroups(Keyword, Text, Keyword, Text, Name.Namespace)),
|
270
|
+
(r'\b(package)(\s+)', bygroups(Keyword, Text), 'package'),
|
271
|
+
(r'\b(given)\b(\s*)(%s)' % idUpper,
|
272
|
+
bygroups(Keyword, Text, Name.Class)),
|
273
|
+
(r'\b(given)\b(\s*)(%s)?' % anyId,
|
274
|
+
bygroups(Keyword, Text, Name)),
|
275
|
+
],
|
276
|
+
'inheritance': [
|
277
|
+
(r'\b(extends|with|derives)\b(\s*)'
|
278
|
+
r'(%s|%s|(?=\([^\)]+=>)|(?=%s)|(?="))?' %
|
279
|
+
(idUpper, backQuotedId, plainid),
|
280
|
+
bygroups(Keyword, Text, Name.Class)),
|
281
|
+
],
|
282
|
+
'extension': [
|
283
|
+
(r'\b(extension)(\s+)(?=[\[\(])', bygroups(Keyword, Text)),
|
284
|
+
],
|
285
|
+
'end': [
|
286
|
+
# end is a soft keyword, should only be highlighted in certain cases
|
287
|
+
(r'\b(end)(\s+)(if|while|for|match|new|extension|val|var)\b',
|
288
|
+
bygroups(Keyword, Text, Keyword)),
|
289
|
+
(r'\b(end)(\s+)(%s)%s' % (idUpper, endOfLineMaybeWithComment),
|
290
|
+
bygroups(Keyword, Text, Name.Class)),
|
291
|
+
(r'\b(end)(\s+)(%s|%s)?%s' %
|
292
|
+
(backQuotedId, plainid, endOfLineMaybeWithComment),
|
293
|
+
bygroups(Keyword, Text, Name.Namespace)),
|
294
|
+
],
|
295
|
+
'punctuation': [
|
296
|
+
(r'[{}()\[\];,.]', Punctuation),
|
297
|
+
(r'(?<!:):(?!:)', Punctuation),
|
298
|
+
],
|
299
|
+
'keywords': [
|
300
|
+
(words(keywords, prefix=r'\b', suffix=r'\b'), Keyword),
|
301
|
+
],
|
302
|
+
'operators': [
|
303
|
+
(r'(%s{2,})(\s+)' % opchar, bygroups(Operator, Text)),
|
304
|
+
(r'/(?![/*])', Operator),
|
305
|
+
(words(operators), Operator),
|
306
|
+
(r'(?<!%s)(!|&&|\|\|)(?!%s)' % (opchar, opchar), Operator),
|
307
|
+
],
|
308
|
+
'constants': [
|
309
|
+
(r'\b(this|super)\b', Name.Builtin.Pseudo),
|
310
|
+
(r'(true|false|null)\b', Keyword.Constant),
|
311
|
+
(r'0[xX][0-9a-fA-F_]*', Number.Hex),
|
312
|
+
(r'([0-9][0-9_]*\.[0-9][0-9_]*|\.[0-9][0-9_]*)'
|
313
|
+
r'([eE][+-]?[0-9][0-9_]*)?[fFdD]?', Number.Float),
|
314
|
+
(r'[0-9]+([eE][+-]?[0-9]+)?[fFdD]', Number.Float),
|
315
|
+
(r'[0-9]+([eE][+-]?[0-9]+)[fFdD]?', Number.Float),
|
316
|
+
(r'[0-9]+[lL]', Number.Integer.Long),
|
317
|
+
(r'[0-9]+', Number.Integer),
|
318
|
+
(r'""".*?"""(?!")', String),
|
319
|
+
(r'"(\\\\|\\"|[^"])*"', String),
|
320
|
+
(r"(')(\\.)(')", bygroups(String.Char, String.Escape, String.Char)),
|
321
|
+
(r"'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
|
322
|
+
],
|
323
|
+
"strings": [
|
324
|
+
(r'[fs]"""', String, 'interpolated-string-triple'),
|
325
|
+
(r'[fs]"', String, 'interpolated-string'),
|
326
|
+
(r'raw"(\\\\|\\"|[^"])*"', String),
|
327
|
+
],
|
328
|
+
'symbols': [
|
329
|
+
(r"('%s)(?!')" % plainid, String.Symbol),
|
330
|
+
],
|
331
|
+
'singleton-type': [
|
332
|
+
(r'(\.)(type)\b', bygroups(Punctuation, Keyword)),
|
333
|
+
],
|
334
|
+
'inline': [
|
335
|
+
# inline is a soft modifer, only highlighted if followed by if,
|
336
|
+
# match or parameters.
|
337
|
+
(r'\b(inline)(?=\s+(%s|%s)\s*:)' % (plainid, backQuotedId),
|
338
|
+
Keyword),
|
339
|
+
(r'\b(inline)\b(?=(?:.(?!\b(?:val|def|given)\b))*\b(if|match)\b)',
|
340
|
+
Keyword),
|
341
|
+
],
|
342
|
+
'quoted': [
|
343
|
+
# '{...} or ${...}
|
344
|
+
(r"['$]\{(?!')", Punctuation),
|
345
|
+
# '[...]
|
346
|
+
(r"'\[(?!')", Punctuation),
|
347
|
+
],
|
348
|
+
'names': [
|
349
|
+
(idUpper, Name.Class),
|
350
|
+
(anyId, Name),
|
351
|
+
],
|
352
|
+
|
353
|
+
# States
|
349
354
|
'comment': [
|
350
355
|
(r'[^/*]+', Comment.Multiline),
|
351
356
|
(r'/\*', Comment.Multiline, '#push'),
|
352
357
|
(r'\*/', Comment.Multiline, '#pop'),
|
353
|
-
(r'[*/]', Comment.Multiline)
|
358
|
+
(r'[*/]', Comment.Multiline),
|
354
359
|
],
|
355
|
-
'import': [
|
356
|
-
(r'(
|
360
|
+
'import-path': [
|
361
|
+
(r'(?<=[\n;:])', Text, '#pop'),
|
362
|
+
include('comments'),
|
363
|
+
(r'\b(given)\b', Keyword),
|
364
|
+
include('qualified-name'),
|
365
|
+
(r'\{', Punctuation, 'import-path-curly-brace'),
|
357
366
|
],
|
358
|
-
'
|
359
|
-
(
|
360
|
-
(
|
361
|
-
(r'
|
362
|
-
(r'
|
363
|
-
(r'
|
367
|
+
'import-path-curly-brace': [
|
368
|
+
include('whitespace'),
|
369
|
+
include('comments'),
|
370
|
+
(r'\b(given)\b', Keyword),
|
371
|
+
(r'=>', Operator),
|
372
|
+
(r'\}', Punctuation, '#pop'),
|
373
|
+
(r',', Punctuation),
|
374
|
+
(r'[\[\]]', Punctuation),
|
375
|
+
include('qualified-name'),
|
376
|
+
],
|
377
|
+
'export-path': [
|
378
|
+
(r'(?<=[\n;:])', Text, '#pop'),
|
379
|
+
include('comments'),
|
380
|
+
include('qualified-name'),
|
381
|
+
(r'\{', Punctuation, 'export-path-curly-brace'),
|
364
382
|
],
|
365
|
-
'
|
383
|
+
'export-path-curly-brace': [
|
384
|
+
include('whitespace'),
|
385
|
+
include('comments'),
|
386
|
+
(r'=>', Operator),
|
387
|
+
(r'\}', Punctuation, '#pop'),
|
388
|
+
(r',', Punctuation),
|
389
|
+
include('qualified-name'),
|
390
|
+
],
|
391
|
+
'package': [
|
392
|
+
(r'(?<=[\n;])', Text, '#pop'),
|
393
|
+
(r':', Punctuation, '#pop'),
|
394
|
+
include('comments'),
|
395
|
+
include('qualified-name'),
|
396
|
+
],
|
397
|
+
'interpolated-string-triple': [
|
366
398
|
(r'"""(?!")', String, '#pop'),
|
367
399
|
(r'"', String),
|
368
|
-
include('
|
400
|
+
include('interpolated-string-common'),
|
369
401
|
],
|
370
|
-
'
|
402
|
+
'interpolated-string': [
|
371
403
|
(r'"', String, '#pop'),
|
372
|
-
include('
|
404
|
+
include('interpolated-string-common'),
|
373
405
|
],
|
374
|
-
'
|
406
|
+
'interpolated-string-brace': [
|
375
407
|
(r'\}', String.Interpol, '#pop'),
|
376
|
-
(r'\{',
|
408
|
+
(r'\{', Punctuation, 'interpolated-string-nested-brace'),
|
377
409
|
include('root'),
|
378
410
|
],
|
411
|
+
'interpolated-string-nested-brace': [
|
412
|
+
(r'\{', Punctuation, '#push'),
|
413
|
+
(r'\}', Punctuation, '#pop'),
|
414
|
+
include('root'),
|
415
|
+
],
|
416
|
+
|
417
|
+
# Helpers
|
418
|
+
'qualified-name': [
|
419
|
+
(idUpper, Name.Class),
|
420
|
+
(r'(%s)(\.)' % anyId, bygroups(Name.Namespace, Punctuation)),
|
421
|
+
(r'\.', Punctuation),
|
422
|
+
(anyId, Name),
|
423
|
+
(r'[^\S\n]+', Text),
|
424
|
+
],
|
425
|
+
'interpolated-string-common': [
|
426
|
+
(r'[^"$\\]+', String),
|
427
|
+
(r'\$\$', String.Escape),
|
428
|
+
(r'(\$)(%s)' % simpleInterpolatedVariable,
|
429
|
+
bygroups(String.Interpol, Name)),
|
430
|
+
(r'\$\{', String.Interpol, 'interpolated-string-brace'),
|
431
|
+
(r'\\.', String),
|
432
|
+
],
|
379
433
|
}
|
380
434
|
|
381
435
|
|
@@ -497,18 +551,24 @@ class GroovyLexer(RegexLexer):
|
|
497
551
|
default('base'),
|
498
552
|
],
|
499
553
|
'base': [
|
500
|
-
# method names
|
501
|
-
(r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
|
502
|
-
r'([a-zA-Z_]\w*)' # method name
|
503
|
-
r'(\s*)(\()', # signature start
|
504
|
-
bygroups(using(this), Name.Function, Text, Operator)),
|
505
554
|
(r'[^\S\n]+', Text),
|
506
555
|
(r'//.*?\n', Comment.Single),
|
507
556
|
(r'/\*.*?\*/', Comment.Multiline),
|
508
|
-
|
557
|
+
# keywords: go before method names to avoid lexing "throw new XYZ"
|
558
|
+
# as a method signature
|
509
559
|
(r'(assert|break|case|catch|continue|default|do|else|finally|for|'
|
510
560
|
r'if|goto|instanceof|new|return|switch|this|throw|try|while|in|as)\b',
|
511
561
|
Keyword),
|
562
|
+
# method names
|
563
|
+
(r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
|
564
|
+
r'('
|
565
|
+
r'[a-zA-Z_]\w*' # method name
|
566
|
+
r'|"(?:\\\\|\\[^\\]|[^"\\])*"' # or double-quoted method name
|
567
|
+
r"|'(?:\\\\|\\[^\\]|[^'\\])*'" # or single-quoted method name
|
568
|
+
r')'
|
569
|
+
r'(\s*)(\()', # signature start
|
570
|
+
bygroups(using(this), Name.Function, Text, Operator)),
|
571
|
+
(r'@[a-zA-Z_][\w.]*', Name.Decorator),
|
512
572
|
(r'(abstract|const|enum|extends|final|implements|native|private|'
|
513
573
|
r'protected|public|static|strictfp|super|synchronized|throws|'
|
514
574
|
r'transient|volatile)\b', Keyword.Declaration),
|
@@ -1677,7 +1737,7 @@ class JasminLexer(RegexLexer):
|
|
1677
1737
|
r'inner|interface|limit|set|signature|stack)\b', text,
|
1678
1738
|
re.MULTILINE):
|
1679
1739
|
score += 0.6
|
1680
|
-
return score
|
1740
|
+
return min(score, 1.0)
|
1681
1741
|
|
1682
1742
|
|
1683
1743
|
class SarlLexer(RegexLexer):
|