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
@@ -353,13 +353,14 @@ class LlvmLexer(RegexLexer):
|
|
353
353
|
#: optional Comment or Whitespace
|
354
354
|
string = r'"[^"]*?"'
|
355
355
|
identifier = r'([-a-zA-Z$._][\w\-$.]*|' + string + ')'
|
356
|
+
block_label = r'(' + identifier + r'|(\d+))'
|
356
357
|
|
357
358
|
tokens = {
|
358
359
|
'root': [
|
359
360
|
include('whitespace'),
|
360
361
|
|
361
362
|
# Before keywords, because keywords are valid label names :(...
|
362
|
-
(
|
363
|
+
(block_label + r'\s*:', Name.Label),
|
363
364
|
|
364
365
|
include('keyword'),
|
365
366
|
|
@@ -384,68 +385,95 @@ class LlvmLexer(RegexLexer):
|
|
384
385
|
'keyword': [
|
385
386
|
# Regular keywords
|
386
387
|
(words((
|
387
|
-
'
|
388
|
-
'
|
389
|
-
'
|
390
|
-
'
|
391
|
-
'
|
392
|
-
'
|
393
|
-
'
|
394
|
-
'
|
395
|
-
'
|
396
|
-
'
|
397
|
-
'
|
398
|
-
'
|
399
|
-
'
|
400
|
-
'
|
401
|
-
'
|
402
|
-
'
|
403
|
-
'
|
404
|
-
'
|
405
|
-
'
|
406
|
-
'
|
407
|
-
'
|
408
|
-
'
|
409
|
-
'
|
410
|
-
'
|
411
|
-
'
|
412
|
-
'
|
413
|
-
'
|
414
|
-
'
|
415
|
-
'
|
416
|
-
'
|
417
|
-
'
|
418
|
-
'
|
419
|
-
'
|
420
|
-
'
|
421
|
-
'
|
422
|
-
'
|
423
|
-
'
|
424
|
-
'
|
425
|
-
'
|
426
|
-
'
|
427
|
-
'
|
428
|
-
'
|
429
|
-
'
|
430
|
-
'
|
431
|
-
'
|
432
|
-
'
|
433
|
-
'
|
434
|
-
'
|
435
|
-
'
|
436
|
-
'
|
437
|
-
'
|
438
|
-
'
|
439
|
-
'
|
388
|
+
'aarch64_sve_vector_pcs', 'aarch64_vector_pcs', 'acq_rel',
|
389
|
+
'acquire', 'add', 'addrspace', 'addrspacecast', 'afn', 'alias',
|
390
|
+
'aliasee', 'align', 'alignLog2', 'alignstack', 'alloca',
|
391
|
+
'allocsize', 'allOnes', 'alwaysinline', 'alwaysInline',
|
392
|
+
'amdgpu_cs', 'amdgpu_es', 'amdgpu_gfx', 'amdgpu_gs',
|
393
|
+
'amdgpu_hs', 'amdgpu_kernel', 'amdgpu_ls', 'amdgpu_ps',
|
394
|
+
'amdgpu_vs', 'and', 'any', 'anyregcc', 'appending', 'arcp',
|
395
|
+
'argmemonly', 'args', 'arm_aapcs_vfpcc', 'arm_aapcscc',
|
396
|
+
'arm_apcscc', 'ashr', 'asm', 'atomic', 'atomicrmw',
|
397
|
+
'attributes', 'available_externally', 'avr_intrcc',
|
398
|
+
'avr_signalcc', 'bit', 'bitcast', 'bitMask', 'blockaddress',
|
399
|
+
'blockcount', 'br', 'branchFunnel', 'builtin', 'byArg',
|
400
|
+
'byref', 'byte', 'byteArray', 'byval', 'c', 'call', 'callbr',
|
401
|
+
'callee', 'caller', 'calls', 'canAutoHide', 'catch',
|
402
|
+
'catchpad', 'catchret', 'catchswitch', 'cc', 'ccc',
|
403
|
+
'cfguard_checkcc', 'cleanup', 'cleanuppad', 'cleanupret',
|
404
|
+
'cmpxchg', 'cold', 'coldcc', 'comdat', 'common', 'constant',
|
405
|
+
'contract', 'convergent', 'critical', 'cxx_fast_tlscc',
|
406
|
+
'datalayout', 'declare', 'default', 'define', 'deplibs',
|
407
|
+
'dereferenceable', 'dereferenceable_or_null', 'distinct',
|
408
|
+
'dllexport', 'dllimport', 'dso_local', 'dso_local_equivalent',
|
409
|
+
'dso_preemptable', 'dsoLocal', 'eq', 'exact', 'exactmatch',
|
410
|
+
'extern_weak', 'external', 'externally_initialized',
|
411
|
+
'extractelement', 'extractvalue', 'fadd', 'false', 'fast',
|
412
|
+
'fastcc', 'fcmp', 'fdiv', 'fence', 'filter', 'flags', 'fmul',
|
413
|
+
'fneg', 'fpext', 'fptosi', 'fptoui', 'fptrunc', 'freeze',
|
414
|
+
'frem', 'from', 'fsub', 'funcFlags', 'function', 'gc',
|
415
|
+
'getelementptr', 'ghccc', 'global', 'guid', 'gv', 'hash',
|
416
|
+
'hhvm_ccc', 'hhvmcc', 'hidden', 'hot', 'hotness', 'icmp',
|
417
|
+
'ifunc', 'inaccessiblemem_or_argmemonly',
|
418
|
+
'inaccessiblememonly', 'inalloca', 'inbounds', 'indir',
|
419
|
+
'indirectbr', 'info', 'initialexec', 'inline', 'inlineBits',
|
420
|
+
'inlinehint', 'inrange', 'inreg', 'insertelement',
|
421
|
+
'insertvalue', 'insts', 'intel_ocl_bicc', 'inteldialect',
|
422
|
+
'internal', 'inttoptr', 'invoke', 'jumptable', 'kind',
|
423
|
+
'landingpad', 'largest', 'linkage', 'linkonce', 'linkonce_odr',
|
424
|
+
'live', 'load', 'local_unnamed_addr', 'localdynamic',
|
425
|
+
'localexec', 'lshr', 'max', 'metadata', 'min', 'minsize',
|
426
|
+
'module', 'monotonic', 'msp430_intrcc', 'mul', 'mustprogress',
|
427
|
+
'musttail', 'naked', 'name', 'nand', 'ne', 'nest', 'ninf',
|
428
|
+
'nnan', 'noalias', 'nobuiltin', 'nocallback', 'nocapture',
|
429
|
+
'nocf_check', 'noduplicate', 'noduplicates', 'nofree',
|
430
|
+
'noimplicitfloat', 'noinline', 'noInline', 'nomerge', 'none',
|
431
|
+
'nonlazybind', 'nonnull', 'noprofile', 'norecurse',
|
432
|
+
'noRecurse', 'noredzone', 'noreturn', 'nosync', 'notail',
|
433
|
+
'notEligibleToImport', 'noundef', 'nounwind', 'nsw',
|
434
|
+
'nsz', 'null', 'null_pointer_is_valid', 'nuw', 'oeq', 'offset',
|
435
|
+
'oge', 'ogt', 'ole', 'olt', 'one', 'opaque', 'optforfuzzing',
|
436
|
+
'optnone', 'optsize', 'or', 'ord', 'param', 'params',
|
437
|
+
'partition', 'path', 'personality', 'phi', 'poison',
|
438
|
+
'preallocated', 'prefix', 'preserve_allcc', 'preserve_mostcc',
|
439
|
+
'private', 'prologue', 'protected', 'ptrtoint', 'ptx_device',
|
440
|
+
'ptx_kernel', 'readnone', 'readNone', 'readonly', 'readOnly',
|
441
|
+
'reassoc', 'refs', 'relbf', 'release', 'resByArg', 'resume',
|
442
|
+
'ret', 'returnDoesNotAlias', 'returned', 'returns_twice',
|
443
|
+
'safestack', 'samesize', 'sanitize_address',
|
444
|
+
'sanitize_hwaddress', 'sanitize_memory', 'sanitize_memtag',
|
445
|
+
'sanitize_thread', 'sdiv', 'section', 'select', 'seq_cst',
|
446
|
+
'sext', 'sge', 'sgt', 'shadowcallstack', 'shl',
|
447
|
+
'shufflevector', 'sideeffect', 'signext', 'single',
|
448
|
+
'singleImpl', 'singleImplName', 'sitofp', 'sizeM1',
|
449
|
+
'sizeM1BitWidth', 'sle', 'slt', 'source_filename',
|
450
|
+
'speculatable', 'speculative_load_hardening', 'spir_func',
|
451
|
+
'spir_kernel', 'srem', 'sret', 'ssp', 'sspreq', 'sspstrong',
|
452
|
+
'store', 'strictfp', 'sub', 'summaries', 'summary', 'swiftcc',
|
453
|
+
'swifterror', 'swiftself', 'switch', 'syncscope', 'tail',
|
454
|
+
'tailcc', 'target', 'thread_local', 'to', 'token', 'triple',
|
455
|
+
'true', 'trunc', 'type', 'typeCheckedLoadConstVCalls',
|
456
|
+
'typeCheckedLoadVCalls', 'typeid', 'typeidCompatibleVTable',
|
457
|
+
'typeIdInfo', 'typeTestAssumeConstVCalls',
|
458
|
+
'typeTestAssumeVCalls', 'typeTestRes', 'typeTests', 'udiv',
|
459
|
+
'ueq', 'uge', 'ugt', 'uitofp', 'ule', 'ult', 'umax', 'umin',
|
460
|
+
'undef', 'une', 'uniformRetVal', 'uniqueRetVal', 'unknown',
|
461
|
+
'unnamed_addr', 'uno', 'unordered', 'unreachable', 'unsat',
|
462
|
+
'unwind', 'urem', 'uselistorder', 'uselistorder_bb', 'uwtable',
|
463
|
+
'va_arg', 'varFlags', 'variable', 'vcall_visibility',
|
464
|
+
'vFuncId', 'virtFunc', 'virtualConstProp', 'void', 'volatile',
|
465
|
+
'vscale', 'vTableFuncs', 'weak', 'weak_odr', 'webkit_jscc',
|
440
466
|
'win64cc', 'within', 'wpdRes', 'wpdResolutions', 'writeonly',
|
441
|
-
'
|
442
|
-
'
|
443
|
-
'
|
467
|
+
'x', 'x86_64_sysvcc', 'x86_fastcallcc', 'x86_intrcc',
|
468
|
+
'x86_mmx', 'x86_regcallcc', 'x86_stdcallcc', 'x86_thiscallcc',
|
469
|
+
'x86_vectorcallcc', 'xchg', 'xor', 'zeroext',
|
470
|
+
'zeroinitializer', 'zext', 'immarg', 'willreturn'),
|
444
471
|
suffix=r'\b'), Keyword),
|
445
472
|
|
446
473
|
# Types
|
447
474
|
(words(('void', 'half', 'bfloat', 'float', 'double', 'fp128',
|
448
|
-
'x86_fp80', 'ppc_fp128', 'label', 'metadata', '
|
475
|
+
'x86_fp80', 'ppc_fp128', 'label', 'metadata', 'x86_mmx',
|
476
|
+
'x86_amx', 'token')),
|
449
477
|
Keyword.Type),
|
450
478
|
|
451
479
|
# Integer types
|
@@ -26,7 +26,7 @@ class BibTeXLexer(ExtendedRegexLexer):
|
|
26
26
|
"""
|
27
27
|
|
28
28
|
name = 'BibTeX'
|
29
|
-
aliases = ['
|
29
|
+
aliases = ['bibtex', 'bib']
|
30
30
|
filenames = ['*.bib']
|
31
31
|
mimetypes = ["text/x-bibtex"]
|
32
32
|
flags = re.IGNORECASE
|
@@ -154,6 +154,6 @@ class BSTLexer(RegexLexer):
|
|
154
154
|
],
|
155
155
|
'whitespace': [
|
156
156
|
(r'\s+', Text),
|
157
|
-
('%.*?$', Comment.
|
157
|
+
('%.*?$', Comment.Single),
|
158
158
|
],
|
159
159
|
}
|
@@ -14,7 +14,7 @@ from pygments.lexer import RegexLexer, include, bygroups, using, \
|
|
14
14
|
this, inherit, default, words
|
15
15
|
from pygments.util import get_bool_opt
|
16
16
|
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
17
|
-
Number, Punctuation
|
17
|
+
Number, Punctuation, Whitespace
|
18
18
|
|
19
19
|
__all__ = ['CLexer', 'CppLexer']
|
20
20
|
|
@@ -43,6 +43,7 @@ class CFamilyLexer(RegexLexer):
|
|
43
43
|
|
44
44
|
# Identifier regex with C and C++ Universal Character Name (UCN) support.
|
45
45
|
_ident = r'(?:[a-zA-Z_$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})(?:[\w$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})*'
|
46
|
+
_namespaced_ident = r'(?:[a-zA-Z_$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})(?:[\w$]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|::)*'
|
46
47
|
|
47
48
|
tokens = {
|
48
49
|
'whitespace': [
|
@@ -54,8 +55,8 @@ class CFamilyLexer(RegexLexer):
|
|
54
55
|
bygroups(using(this), Comment.Preproc), 'if0'),
|
55
56
|
('^(' + _ws1 + ')(#)',
|
56
57
|
bygroups(using(this), Comment.Preproc), 'macro'),
|
57
|
-
(r'\n',
|
58
|
-
(r'\
|
58
|
+
(r'\n', Whitespace),
|
59
|
+
(r'[^\S\n]+', Whitespace),
|
59
60
|
(r'\\\n', Text), # line continuation
|
60
61
|
(r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single),
|
61
62
|
(r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline),
|
@@ -63,6 +64,8 @@ class CFamilyLexer(RegexLexer):
|
|
63
64
|
(r'/(\\\n)?[*][\w\W]*', Comment.Multiline),
|
64
65
|
],
|
65
66
|
'statements': [
|
67
|
+
include('keywords'),
|
68
|
+
include('types'),
|
66
69
|
(r'([LuU]|u8)?(")', bygroups(String.Affix, String), 'string'),
|
67
70
|
(r"([LuU]|u8)?(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')",
|
68
71
|
bygroups(String.Affix, String.Char, String.Char, String.Char)),
|
@@ -78,6 +81,17 @@ class CFamilyLexer(RegexLexer):
|
|
78
81
|
(r'(-)?' + _decpart + _intsuffix, Number.Integer),
|
79
82
|
(r'[~!%^&*+=|?:<>/-]', Operator),
|
80
83
|
(r'[()\[\],.]', Punctuation),
|
84
|
+
(r'(true|false|NULL)\b', Name.Builtin),
|
85
|
+
(r'(' + _ident + r')(\s*)(:)(?!:)', bygroups(Name.Label, Text, Punctuation)),
|
86
|
+
(_ident, Name)
|
87
|
+
],
|
88
|
+
'types': [
|
89
|
+
(words(('int8', 'int16', 'int32', 'int64', 'wchar_t'), prefix=r'__',
|
90
|
+
suffix=r'\b'), Keyword.Reserved),
|
91
|
+
(words(('bool', 'int', 'long', 'float', 'short', 'double', 'char',
|
92
|
+
'unsigned', 'signed', 'void'), suffix=r'\b'), Keyword.Type)
|
93
|
+
],
|
94
|
+
'keywords': [
|
81
95
|
(r'(struct|union)(\s+)', bygroups(Keyword, Text), 'classname'),
|
82
96
|
(words(('asm', 'auto', 'break', 'case', 'const', 'continue',
|
83
97
|
'default', 'do', 'else', 'enum', 'extern', 'for', 'goto',
|
@@ -85,36 +99,32 @@ class CFamilyLexer(RegexLexer):
|
|
85
99
|
'static', 'switch', 'typedef', 'volatile', 'while', 'union',
|
86
100
|
'thread_local', 'alignas', 'alignof', 'static_assert', '_Pragma'),
|
87
101
|
suffix=r'\b'), Keyword),
|
88
|
-
(r'(bool|int|long|float|short|double|char|unsigned|signed|void)\b',
|
89
|
-
Keyword.Type),
|
90
102
|
(words(('inline', '_inline', '__inline', 'naked', 'restrict',
|
91
103
|
'thread'), suffix=r'\b'), Keyword.Reserved),
|
92
104
|
# Vector intrinsics
|
93
105
|
(r'(__m(128i|128d|128|64))\b', Keyword.Reserved),
|
94
106
|
# Microsoft-isms
|
95
107
|
(words((
|
96
|
-
'asm', '
|
97
|
-
'fastcall', '
|
98
|
-
'leave', '
|
108
|
+
'asm', 'based', 'except', 'stdcall', 'cdecl',
|
109
|
+
'fastcall', 'declspec', 'finally', 'try',
|
110
|
+
'leave', 'w64', 'unaligned', 'raise', 'noop',
|
99
111
|
'identifier', 'forceinline', 'assume'),
|
100
|
-
prefix=r'__', suffix=r'\b'), Keyword.Reserved)
|
101
|
-
(r'(true|false|NULL)\b', Name.Builtin),
|
102
|
-
(r'(' + _ident + r')(\s*)(:)(?!:)', bygroups(Name.Label, Text, Punctuation)),
|
103
|
-
(_ident, Name)
|
112
|
+
prefix=r'__', suffix=r'\b'), Keyword.Reserved)
|
104
113
|
],
|
105
114
|
'root': [
|
106
115
|
include('whitespace'),
|
116
|
+
include('keywords'),
|
107
117
|
# functions
|
108
|
-
(r'(
|
109
|
-
r'(' +
|
118
|
+
(r'(' + _namespaced_ident + r'(?:[&*\s])+)' # return arguments
|
119
|
+
r'(' + _namespaced_ident + r')' # method name
|
110
120
|
r'(\s*\([^;]*?\))' # signature
|
111
121
|
r'([^;{]*)(\{)',
|
112
122
|
bygroups(using(this), Name.Function, using(this), using(this),
|
113
123
|
Punctuation),
|
114
124
|
'function'),
|
115
125
|
# function declarations
|
116
|
-
(r'(
|
117
|
-
r'(' +
|
126
|
+
(r'(' + _namespaced_ident + r'(?:[&*\s])+)' # return arguments
|
127
|
+
r'(' + _namespaced_ident + r')' # method name
|
118
128
|
r'(\s*\([^;]*?\))' # signature
|
119
129
|
r'([^;]*)(;)',
|
120
130
|
bygroups(using(this), Name.Function, using(this), using(this),
|
@@ -143,8 +153,10 @@ class CFamilyLexer(RegexLexer):
|
|
143
153
|
(r'\\', String), # stray backslash
|
144
154
|
],
|
145
155
|
'macro': [
|
146
|
-
(r'(include)('+_ws1+r')("[^"]+")([^\n]*)',
|
147
|
-
|
156
|
+
(r'('+_ws1+r')(include)('+_ws1+r')("[^"]+")([^\n]*)',
|
157
|
+
bygroups(using(this), Comment.Preproc, using(this), Comment.PreprocFile, Comment.Single)),
|
158
|
+
(r'('+_ws1+r')(include)('+_ws1+r')(<[^>]+>)([^\n]*)',
|
159
|
+
bygroups(using(this), Comment.Preproc, using(this), Comment.PreprocFile, Comment.Single)),
|
148
160
|
(r'[^/\n]+', Comment.Preproc),
|
149
161
|
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
150
162
|
(r'//.*?\n', Comment.Single, '#pop'),
|
@@ -245,11 +257,14 @@ class CLexer(CFamilyLexer):
|
|
245
257
|
priority = 0.1
|
246
258
|
|
247
259
|
tokens = {
|
248
|
-
'
|
260
|
+
'keywords': [
|
249
261
|
(words((
|
250
262
|
'_Alignas', '_Alignof', '_Noreturn', '_Generic', '_Thread_local',
|
251
263
|
'_Static_assert', '_Imaginary', 'noreturn', 'imaginary', 'complex'),
|
252
264
|
suffix=r'\b'), Keyword),
|
265
|
+
inherit
|
266
|
+
],
|
267
|
+
'types': [
|
253
268
|
(words(('_Bool', '_Complex', '_Atomic'), suffix=r'\b'), Keyword.Type),
|
254
269
|
inherit
|
255
270
|
]
|
@@ -295,20 +310,6 @@ class CppLexer(CFamilyLexer):
|
|
295
310
|
|
296
311
|
tokens = {
|
297
312
|
'statements': [
|
298
|
-
(r'(class|concept|typename)(\s+)', bygroups(Keyword, Text), 'classname'),
|
299
|
-
(words((
|
300
|
-
'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit',
|
301
|
-
'export', 'friend', 'mutable', 'namespace', 'new', 'operator',
|
302
|
-
'private', 'protected', 'public', 'reinterpret_cast', 'class',
|
303
|
-
'restrict', 'static_cast', 'template', 'this', 'throw', 'throws',
|
304
|
-
'try', 'typeid', 'using', 'virtual', 'constexpr', 'nullptr', 'concept',
|
305
|
-
'decltype', 'noexcept', 'override', 'final', 'constinit', 'consteval',
|
306
|
-
'co_await', 'co_return', 'co_yield', 'requires', 'import', 'module',
|
307
|
-
'typename'),
|
308
|
-
suffix=r'\b'), Keyword),
|
309
|
-
(r'char(16_t|32_t|8_t)\b', Keyword.Type),
|
310
|
-
(r'(enum)(\s+)', bygroups(Keyword, Text), 'enumname'),
|
311
|
-
|
312
313
|
# C++11 raw strings
|
313
314
|
(r'((?:[LuU]|u8)?R)(")([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(")',
|
314
315
|
bygroups(String.Affix, String, String.Delimiter, String.Delimiter,
|
@@ -332,6 +333,32 @@ class CppLexer(CFamilyLexer):
|
|
332
333
|
# template specification
|
333
334
|
(r'\s*(?=>)', Text, '#pop'),
|
334
335
|
default('#pop')
|
336
|
+
],
|
337
|
+
'keywords': [
|
338
|
+
(r'(class|concept|typename)(\s+)', bygroups(Keyword, Text), 'classname'),
|
339
|
+
(words((
|
340
|
+
'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit',
|
341
|
+
'export', 'friend', 'mutable', 'new', 'operator',
|
342
|
+
'private', 'protected', 'public', 'reinterpret_cast', 'class',
|
343
|
+
'restrict', 'static_cast', 'template', 'this', 'throw', 'throws',
|
344
|
+
'try', 'typeid', 'using', 'virtual', 'constexpr', 'nullptr', 'concept',
|
345
|
+
'decltype', 'noexcept', 'override', 'final', 'constinit', 'consteval',
|
346
|
+
'co_await', 'co_return', 'co_yield', 'requires', 'import', 'module',
|
347
|
+
'typename'),
|
348
|
+
suffix=r'\b'), Keyword),
|
349
|
+
(r'namespace\b', Keyword, 'namespace'),
|
350
|
+
(r'(enum)(\s+)', bygroups(Keyword, Text), 'enumname'),
|
351
|
+
inherit
|
352
|
+
],
|
353
|
+
'types': [
|
354
|
+
(r'char(16_t|32_t|8_t)\b', Keyword.Type),
|
355
|
+
inherit
|
356
|
+
],
|
357
|
+
'namespace': [
|
358
|
+
(r'[;{]', Punctuation, ('#pop', 'root')),
|
359
|
+
(r'inline\b', Keyword.Reserved),
|
360
|
+
(CFamilyLexer._ident, Name.Namespace),
|
361
|
+
include('statement')
|
335
362
|
]
|
336
363
|
}
|
337
364
|
|
@@ -13,13 +13,14 @@ import re
|
|
13
13
|
from pygments.lexer import RegexLexer, include, bygroups, inherit, words, \
|
14
14
|
default
|
15
15
|
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
16
|
-
Number, Punctuation
|
16
|
+
Number, Punctuation, Whitespace
|
17
17
|
|
18
18
|
from pygments.lexers.c_cpp import CLexer, CppLexer
|
19
19
|
from pygments.lexers import _mql_builtins
|
20
20
|
|
21
21
|
__all__ = ['PikeLexer', 'NesCLexer', 'ClayLexer', 'ECLexer', 'ValaLexer',
|
22
|
-
'CudaLexer', 'SwigLexer', 'MqlLexer', 'ArduinoLexer', 'CharmciLexer'
|
22
|
+
'CudaLexer', 'SwigLexer', 'MqlLexer', 'ArduinoLexer', 'CharmciLexer',
|
23
|
+
'OmgIdlLexer']
|
23
24
|
|
24
25
|
|
25
26
|
class PikeLexer(CppLexer):
|
@@ -334,6 +335,11 @@ class SwigLexer(CppLexer):
|
|
334
335
|
priority = 0.04 # Lower than C/C++ and Objective C/C++
|
335
336
|
|
336
337
|
tokens = {
|
338
|
+
'root': [
|
339
|
+
# Match it here so it won't be matched as a function in the rest of root
|
340
|
+
(r'\$\**\&?\w+', Name),
|
341
|
+
inherit
|
342
|
+
],
|
337
343
|
'statements': [
|
338
344
|
# SWIG directives
|
339
345
|
(r'(%[a-z_][a-z0-9_]*)', Name.Function),
|
@@ -549,7 +555,7 @@ class CharmciLexer(CppLexer):
|
|
549
555
|
mimetypes = []
|
550
556
|
|
551
557
|
tokens = {
|
552
|
-
'
|
558
|
+
'keywords': [
|
553
559
|
(r'(module)(\s+)', bygroups(Keyword, Text), 'classname'),
|
554
560
|
(words(('mainmodule', 'mainchare', 'chare', 'array', 'group',
|
555
561
|
'nodegroup', 'message', 'conditional')), Keyword),
|
@@ -563,3 +569,96 @@ class CharmciLexer(CppLexer):
|
|
563
569
|
inherit,
|
564
570
|
],
|
565
571
|
}
|
572
|
+
|
573
|
+
|
574
|
+
class OmgIdlLexer(CLexer):
|
575
|
+
"""
|
576
|
+
Lexer for `Object Management Group Interface Definition Language <https://www.omg.org/spec/IDL/About-IDL/>`_.
|
577
|
+
|
578
|
+
.. versionadded:: 2.9
|
579
|
+
"""
|
580
|
+
|
581
|
+
name = 'OMG Interface Definition Language'
|
582
|
+
aliases = ['omg-idl']
|
583
|
+
filenames = ['*.idl', '*.pidl']
|
584
|
+
mimetypes = []
|
585
|
+
|
586
|
+
scoped_name = r'((::)?\w+)+'
|
587
|
+
|
588
|
+
tokens = {
|
589
|
+
'values': [
|
590
|
+
(words(('true', 'false'), prefix=r'(?i)', suffix=r'\b'), Number),
|
591
|
+
(r'([Ll]?)(")', bygroups(String.Affix, String.Double), 'string'),
|
592
|
+
(r'([Ll]?)(\')(\\[^\']+)(\')',
|
593
|
+
bygroups(String.Affix, String.Char, String.Escape, String.Char)),
|
594
|
+
(r'([Ll]?)(\')(\\\')(\')',
|
595
|
+
bygroups(String.Affix, String.Char, String.Escape, String.Char)),
|
596
|
+
(r'([Ll]?)(\'.\')', bygroups(String.Affix, String.Char)),
|
597
|
+
(r'[+-]?\d+(\.\d*)?[Ee][+-]?\d+', Number.Float),
|
598
|
+
(r'[+-]?(\d+\.\d*)|(\d*\.\d+)([Ee][+-]?\d+)?', Number.Float),
|
599
|
+
(r'(?i)[+-]?0x[0-9a-f]+', Number.Hex),
|
600
|
+
(r'[+-]?[1-9]\d*', Number.Integer),
|
601
|
+
(r'[+-]?0[0-7]*', Number.Oct),
|
602
|
+
(r'[\+\-\*\/%^&\|~]', Operator),
|
603
|
+
(words(('<<', '>>')), Operator),
|
604
|
+
(scoped_name, Name),
|
605
|
+
(r'[{};:,<>\[\]]', Punctuation),
|
606
|
+
],
|
607
|
+
'annotation_params': [
|
608
|
+
include('whitespace'),
|
609
|
+
(r'\(', Punctuation, '#push'),
|
610
|
+
include('values'),
|
611
|
+
(r'=', Punctuation),
|
612
|
+
(r'\)', Punctuation, '#pop'),
|
613
|
+
],
|
614
|
+
'annotation_params_maybe': [
|
615
|
+
(r'\(', Punctuation, 'annotation_params'),
|
616
|
+
include('whitespace'),
|
617
|
+
default('#pop'),
|
618
|
+
],
|
619
|
+
'annotation_appl': [
|
620
|
+
(r'@' + scoped_name, Name.Decorator, 'annotation_params_maybe'),
|
621
|
+
],
|
622
|
+
'enum': [
|
623
|
+
include('whitespace'),
|
624
|
+
(r'[{,]', Punctuation),
|
625
|
+
(r'\w+', Name.Constant),
|
626
|
+
include('annotation_appl'),
|
627
|
+
(r'\}', Punctuation, '#pop'),
|
628
|
+
],
|
629
|
+
'root': [
|
630
|
+
include('whitespace'),
|
631
|
+
(words((
|
632
|
+
'typedef', 'const',
|
633
|
+
'in', 'out', 'inout', 'local',
|
634
|
+
), prefix=r'(?i)', suffix=r'\b'), Keyword.Declaration),
|
635
|
+
(words((
|
636
|
+
'void', 'any', 'native', 'bitfield',
|
637
|
+
'unsigned', 'boolean', 'char', 'wchar', 'octet', 'short', 'long',
|
638
|
+
'int8', 'uint8', 'int16', 'int32', 'int64', 'uint16', 'uint32', 'uint64',
|
639
|
+
'float', 'double', 'fixed',
|
640
|
+
'sequence', 'string', 'wstring', 'map',
|
641
|
+
), prefix=r'(?i)', suffix=r'\b'), Keyword.Type),
|
642
|
+
(words((
|
643
|
+
'@annotation', 'struct', 'union', 'bitset', 'interface',
|
644
|
+
'exception', 'valuetype', 'eventtype', 'component',
|
645
|
+
), prefix=r'(?i)', suffix=r'(\s+)(\w+)'), bygroups(Keyword, Whitespace, Name.Class)),
|
646
|
+
(words((
|
647
|
+
'abstract', 'alias', 'attribute', 'case', 'connector',
|
648
|
+
'consumes', 'context', 'custom', 'default', 'emits', 'factory',
|
649
|
+
'finder', 'getraises', 'home', 'import', 'manages', 'mirrorport',
|
650
|
+
'multiple', 'Object', 'oneway', 'primarykey', 'private', 'port',
|
651
|
+
'porttype', 'provides', 'public', 'publishes', 'raises',
|
652
|
+
'readonly', 'setraises', 'supports', 'switch', 'truncatable',
|
653
|
+
'typeid', 'typename', 'typeprefix', 'uses', 'ValueBase',
|
654
|
+
), prefix=r'(?i)', suffix=r'\b'), Keyword),
|
655
|
+
(r'(?i)(enum|bitmask)(\s+)(\w+)',
|
656
|
+
bygroups(Keyword, Whitespace, Name.Class), 'enum'),
|
657
|
+
(r'(?i)(module)(\s+)(\w+)',
|
658
|
+
bygroups(Keyword.Namespace, Whitespace, Name.Namespace)),
|
659
|
+
(r'(\w+)(\s*)(=)', bygroups(Name.Constant, Whitespace, Operator)),
|
660
|
+
(r'[\(\)]', Punctuation),
|
661
|
+
include('values'),
|
662
|
+
include('annotation_appl'),
|
663
|
+
],
|
664
|
+
}
|
@@ -119,7 +119,7 @@ class CddlLexer(RegexLexer):
|
|
119
119
|
"root": [
|
120
120
|
include("commentsandwhitespace"),
|
121
121
|
# tag types
|
122
|
-
(r"#(\d\.{uint})?".format(uint=_re_uint), Keyword.Type),
|
122
|
+
(r"#(\d\.{uint})?".format(uint=_re_uint), Keyword.Type), # type or any
|
123
123
|
# occurence
|
124
124
|
(
|
125
125
|
r"({uint})?(\*)({uint})?".format(uint=_re_uint),
|
@@ -164,7 +164,7 @@ class CddlLexer(RegexLexer):
|
|
164
164
|
Number.Float,
|
165
165
|
),
|
166
166
|
# Int
|
167
|
-
(_re_int, Number.
|
167
|
+
(_re_int, Number.Integer),
|
168
168
|
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
169
169
|
],
|
170
170
|
"bstrb64url": [
|