gitlab-pygments.rb 0.3.2 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +71 -0
- data/Gemfile +1 -1
- data/LICENSE +17 -0
- data/README.md +28 -1
- data/Rakefile +2 -5
- data/lexers +0 -0
- data/lib/pygments/mentos.py +19 -12
- data/lib/pygments/popen.rb +21 -4
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -0
- data/test/test_pygments.rb +13 -2
- data/vendor/custom_lexers/github.py +206 -3
- data/vendor/pygments-main/AUTHORS +41 -3
- data/vendor/pygments-main/CHANGES +132 -5
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/Makefile +1 -1
- data/vendor/pygments-main/REVISION +1 -1
- data/vendor/pygments-main/docs/generate.py +1 -1
- data/vendor/pygments-main/docs/src/api.txt +1 -1
- data/vendor/pygments-main/docs/src/index.txt +1 -1
- data/vendor/pygments-main/docs/src/integrate.txt +5 -0
- data/vendor/pygments-main/docs/src/java.txt +70 -0
- data/vendor/pygments-main/docs/src/lexerdevelopment.txt +52 -0
- data/vendor/pygments-main/external/autopygmentize +64 -0
- data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
- data/vendor/pygments-main/external/markdown-processor.py +2 -2
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive-old.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +1 -1
- data/vendor/pygments-main/pygmentize +1 -1
- data/vendor/pygments-main/pygments/__init__.py +2 -2
- data/vendor/pygments-main/pygments/cmdline.py +14 -6
- data/vendor/pygments-main/pygments/console.py +1 -1
- data/vendor/pygments-main/pygments/filter.py +1 -1
- data/vendor/pygments-main/pygments/filters/__init__.py +3 -4
- data/vendor/pygments-main/pygments/formatter.py +4 -1
- data/vendor/pygments-main/pygments/formatters/__init__.py +1 -1
- data/vendor/pygments-main/pygments/formatters/_mapping.py +3 -3
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +73 -2
- data/vendor/pygments-main/pygments/formatters/img.py +2 -2
- data/vendor/pygments-main/pygments/formatters/latex.py +9 -9
- data/vendor/pygments-main/pygments/formatters/other.py +1 -3
- data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
- data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
- data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
- data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
- data/vendor/pygments-main/pygments/lexer.py +78 -10
- data/vendor/pygments-main/pygments/lexers/__init__.py +13 -2
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_mapping.py +92 -36
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +2 -2
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +4 -3
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +11 -0
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -3
- data/vendor/pygments-main/pygments/lexers/agile.py +525 -38
- data/vendor/pygments-main/pygments/lexers/asm.py +45 -7
- data/vendor/pygments-main/pygments/lexers/compiled.py +1257 -425
- data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +97 -62
- data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +931 -32
- data/vendor/pygments-main/pygments/lexers/github.py +206 -3
- data/vendor/pygments-main/pygments/lexers/hdl.py +3 -3
- data/vendor/pygments-main/pygments/lexers/jvm.py +309 -44
- data/vendor/pygments-main/pygments/lexers/math.py +876 -30
- data/vendor/pygments-main/pygments/lexers/other.py +956 -517
- data/vendor/pygments-main/pygments/lexers/parsers.py +85 -2
- data/vendor/pygments-main/pygments/lexers/shell.py +81 -18
- data/vendor/pygments-main/pygments/lexers/special.py +1 -1
- data/vendor/pygments-main/pygments/lexers/sql.py +2 -2
- data/vendor/pygments-main/pygments/lexers/templates.py +119 -8
- data/vendor/pygments-main/pygments/lexers/text.py +155 -15
- data/vendor/pygments-main/pygments/lexers/web.py +1578 -397
- data/vendor/pygments-main/pygments/modeline.py +40 -0
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +1 -1
- data/vendor/pygments-main/pygments/style.py +1 -1
- data/vendor/pygments-main/pygments/styles/__init__.py +1 -1
- data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
- data/vendor/pygments-main/pygments/styles/borland.py +1 -1
- data/vendor/pygments-main/pygments/styles/bw.py +1 -1
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
- data/vendor/pygments-main/pygments/styles/default.py +1 -1
- data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
- data/vendor/pygments-main/pygments/styles/native.py +1 -1
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/tango.py +1 -1
- data/vendor/pygments-main/pygments/styles/trac.py +1 -1
- data/vendor/pygments-main/pygments/styles/vim.py +1 -1
- data/vendor/pygments-main/pygments/styles/vs.py +1 -1
- data/vendor/pygments-main/pygments/token.py +1 -1
- data/vendor/pygments-main/pygments/unistring.py +36 -26
- data/vendor/pygments-main/pygments/util.py +46 -1
- data/vendor/pygments-main/scripts/check_sources.py +2 -2
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +2 -0
- data/vendor/pygments-main/scripts/find_codetags.py +1 -1
- data/vendor/pygments-main/scripts/find_error.py +5 -6
- data/vendor/pygments-main/setup.cfg +1 -0
- data/vendor/pygments-main/setup.py +6 -4
- data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
- data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
- data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
- data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
- data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
- data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
- data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
- data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
- data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
- data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
- data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
- data/vendor/pygments-main/tests/examplefiles/classes.dylan +89 -4
- data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
- data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
- data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
- data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
- data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
- data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
- data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
- data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
- data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
- data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
- data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
- data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
- data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
- data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
- data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
- data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
- data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
- data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
- data/vendor/pygments-main/tests/examplefiles/http_request_example +2 -1
- data/vendor/pygments-main/tests/examplefiles/http_response_example +4 -2
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
- data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
- data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
- data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_sample +5 -2
- data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
- data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
- data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
- data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +7 -0
- data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
- data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
- data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
- data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
- data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
- data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
- data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +149 -115
- data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
- data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
- data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
- data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
- data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
- data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
- data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
- data/vendor/pygments-main/tests/examplefiles/type.lisp +16 -0
- data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
- data/vendor/pygments-main/tests/old_run.py +1 -1
- data/vendor/pygments-main/tests/run.py +3 -2
- data/vendor/pygments-main/tests/support/tags +36 -0
- data/vendor/pygments-main/tests/test_basic_api.py +4 -3
- data/vendor/pygments-main/tests/test_clexer.py +1 -1
- data/vendor/pygments-main/tests/test_cmdline.py +1 -1
- data/vendor/pygments-main/tests/test_examplefiles.py +3 -1
- data/vendor/pygments-main/tests/test_html_formatter.py +17 -1
- data/vendor/pygments-main/tests/test_latex_formatter.py +1 -1
- data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
- data/vendor/pygments-main/tests/test_perllexer.py +1 -1
- data/vendor/pygments-main/tests/test_regexlexer.py +1 -1
- data/vendor/pygments-main/tests/test_token.py +1 -1
- data/vendor/pygments-main/tests/test_using_api.py +1 -1
- data/vendor/pygments-main/tests/test_util.py +22 -3
- metadata +84 -16
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Lexers for assembly languages.
|
7
7
|
|
8
|
-
:copyright: Copyright 2006-
|
8
|
+
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
|
9
9
|
:license: BSD, see LICENSE for details.
|
10
10
|
"""
|
11
11
|
|
@@ -17,7 +17,7 @@ from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
|
|
17
17
|
Other, Keyword, Operator
|
18
18
|
|
19
19
|
__all__ = ['GasLexer', 'ObjdumpLexer','DObjdumpLexer', 'CppObjdumpLexer',
|
20
|
-
'CObjdumpLexer', 'LlvmLexer', 'NasmLexer']
|
20
|
+
'CObjdumpLexer', 'LlvmLexer', 'NasmLexer', 'Ca65Lexer']
|
21
21
|
|
22
22
|
|
23
23
|
class GasLexer(RegexLexer):
|
@@ -25,7 +25,7 @@ class GasLexer(RegexLexer):
|
|
25
25
|
For Gas (AT&T) assembly code.
|
26
26
|
"""
|
27
27
|
name = 'GAS'
|
28
|
-
aliases = ['gas']
|
28
|
+
aliases = ['gas', 'asm']
|
29
29
|
filenames = ['*.s', '*.S']
|
30
30
|
mimetypes = ['text/x-gas']
|
31
31
|
|
@@ -208,7 +208,7 @@ class LlvmLexer(RegexLexer):
|
|
208
208
|
include('whitespace'),
|
209
209
|
|
210
210
|
# Before keywords, because keywords are valid label names :(...
|
211
|
-
(
|
211
|
+
(identifier + '\s*:', Name.Label),
|
212
212
|
|
213
213
|
include('keyword'),
|
214
214
|
|
@@ -240,11 +240,11 @@ class LlvmLexer(RegexLexer):
|
|
240
240
|
r'|linkonce_odr|weak|weak_odr|appending|dllimport|dllexport'
|
241
241
|
r'|common|default|hidden|protected|extern_weak|external'
|
242
242
|
r'|thread_local|zeroinitializer|undef|null|to|tail|target|triple'
|
243
|
-
r'|
|
244
|
-
r'|addrspace|section|alias|module|asm|sideeffect|gc|dbg'
|
243
|
+
r'|datalayout|volatile|nuw|nsw|nnan|ninf|nsz|arcp|fast|exact|inbounds'
|
244
|
+
r'|align|addrspace|section|alias|module|asm|sideeffect|gc|dbg'
|
245
245
|
|
246
246
|
r'|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc'
|
247
|
-
r'|arm_aapcscc|arm_aapcs_vfpcc'
|
247
|
+
r'|arm_aapcscc|arm_aapcs_vfpcc|ptx_device|ptx_kernel'
|
248
248
|
|
249
249
|
r'|cc|c'
|
250
250
|
|
@@ -358,3 +358,41 @@ class NasmLexer(RegexLexer):
|
|
358
358
|
(type, Keyword.Type)
|
359
359
|
],
|
360
360
|
}
|
361
|
+
|
362
|
+
|
363
|
+
class Ca65Lexer(RegexLexer):
|
364
|
+
"""
|
365
|
+
For ca65 assembler sources.
|
366
|
+
|
367
|
+
*New in Pygments 1.6.*
|
368
|
+
"""
|
369
|
+
name = 'ca65'
|
370
|
+
aliases = ['ca65']
|
371
|
+
filenames = ['*.s']
|
372
|
+
|
373
|
+
flags = re.IGNORECASE
|
374
|
+
|
375
|
+
tokens = {
|
376
|
+
'root': [
|
377
|
+
(r';.*', Comment.Single),
|
378
|
+
(r'\s+', Text),
|
379
|
+
(r'[a-z_.@$][\w.@$]*:', Name.Label),
|
380
|
+
(r'((ld|st)[axy]|(in|de)[cxy]|asl|lsr|ro[lr]|adc|sbc|cmp|cp[xy]'
|
381
|
+
r'|cl[cvdi]|se[cdi]|jmp|jsr|bne|beq|bpl|bmi|bvc|bvs|bcc|bcs'
|
382
|
+
r'|p[lh][ap]|rt[is]|brk|nop|ta[xy]|t[xy]a|txs|tsx|and|ora|eor'
|
383
|
+
r'|bit)\b', Keyword),
|
384
|
+
(r'\.[a-z0-9_]+', Keyword.Pseudo),
|
385
|
+
(r'[-+~*/^&|!<>=]', Operator),
|
386
|
+
(r'"[^"\n]*.', String),
|
387
|
+
(r"'[^'\n]*.", String.Char),
|
388
|
+
(r'\$[0-9a-f]+|[0-9a-f]+h\b', Number.Hex),
|
389
|
+
(r'\d+|%[01]+', Number.Integer),
|
390
|
+
(r'[#,.:()=]', Punctuation),
|
391
|
+
(r'[a-z_.@$][\w.@$]*', Name),
|
392
|
+
]
|
393
|
+
}
|
394
|
+
|
395
|
+
def analyse_text(self, text):
|
396
|
+
# comments in GAS start with "#"
|
397
|
+
if re.match(r'^\s*;', text, re.MULTILINE):
|
398
|
+
return 0.9
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Lexers for compiled languages.
|
7
7
|
|
8
|
-
:copyright: Copyright 2006-
|
8
|
+
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
|
9
9
|
:license: BSD, see LICENSE for details.
|
10
10
|
"""
|
11
11
|
|
@@ -13,10 +13,10 @@ import re
|
|
13
13
|
from string import Template
|
14
14
|
|
15
15
|
from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
|
16
|
-
this, combined
|
16
|
+
this, combined, inherit, do_insertions
|
17
17
|
from pygments.util import get_bool_opt, get_list_opt
|
18
18
|
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
19
|
-
Number, Punctuation, Error, Literal
|
19
|
+
Number, Punctuation, Error, Literal, Generic
|
20
20
|
from pygments.scanner import Scanner
|
21
21
|
|
22
22
|
# backwards compatibility
|
@@ -24,23 +24,25 @@ from pygments.lexers.functional import OcamlLexer
|
|
24
24
|
from pygments.lexers.jvm import JavaLexer, ScalaLexer
|
25
25
|
|
26
26
|
__all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer',
|
27
|
-
'
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
27
|
+
'NesCLexer', 'DylanLexer', 'ObjectiveCLexer', 'ObjectiveCppLexer',
|
28
|
+
'FortranLexer', 'GLShaderLexer', 'PrologLexer', 'CythonLexer',
|
29
|
+
'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer',
|
30
|
+
'Modula2Lexer', 'BlitzMaxLexer', 'BlitzBasicLexer', 'NimrodLexer',
|
31
|
+
'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', 'SwigLexer',
|
32
|
+
'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer',
|
33
|
+
'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer']
|
31
34
|
|
32
35
|
|
33
|
-
class
|
36
|
+
class CFamilyLexer(RegexLexer):
|
34
37
|
"""
|
35
|
-
For C source code
|
38
|
+
For C family source code. This is used as a base class to avoid repetitious
|
39
|
+
definitions.
|
36
40
|
"""
|
37
|
-
name = 'C'
|
38
|
-
aliases = ['c']
|
39
|
-
filenames = ['*.c', '*.h', '*.idc']
|
40
|
-
mimetypes = ['text/x-chdr', 'text/x-csrc']
|
41
41
|
|
42
42
|
#: optional Comment or Whitespace
|
43
43
|
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
|
44
|
+
#: only one /* */ style comment
|
45
|
+
_ws1 = r':\s*/[*].*?[*]/\s*'
|
44
46
|
|
45
47
|
tokens = {
|
46
48
|
'whitespace': [
|
@@ -48,9 +50,9 @@ class CLexer(RegexLexer):
|
|
48
50
|
('^#if\s+0', Comment.Preproc, 'if0'),
|
49
51
|
('^#', Comment.Preproc, 'macro'),
|
50
52
|
# or with whitespace
|
51
|
-
('^(' +
|
53
|
+
('^(' + _ws1 + r')(#if\s+0)',
|
52
54
|
bygroups(using(this), Comment.Preproc), 'if0'),
|
53
|
-
('^(' +
|
55
|
+
('^(' + _ws1 + ')(#)',
|
54
56
|
bygroups(using(this), Comment.Preproc), 'macro'),
|
55
57
|
(r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))',
|
56
58
|
bygroups(Text, Name.Label)),
|
@@ -74,12 +76,17 @@ class CLexer(RegexLexer):
|
|
74
76
|
(r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
|
75
77
|
(r'(auto|break|case|const|continue|default|do|else|enum|extern|'
|
76
78
|
r'for|goto|if|register|restricted|return|sizeof|static|struct|'
|
77
|
-
r'switch|typedef|union|volatile|
|
78
|
-
(r'(int|long|float|short|double|char|unsigned|signed|void
|
79
|
+
r'switch|typedef|union|volatile|while)\b', Keyword),
|
80
|
+
(r'(bool|int|long|float|short|double|char|unsigned|signed|void|'
|
81
|
+
r'[a-z_][a-z0-9_]*_t)\b',
|
79
82
|
Keyword.Type),
|
80
83
|
(r'(_{0,2}inline|naked|restrict|thread|typename)\b', Keyword.Reserved),
|
84
|
+
# Vector intrinsics
|
85
|
+
(r'(__(m128i|m128d|m128|m64))\b', Keyword.Reserved),
|
86
|
+
# Microsoft-isms
|
81
87
|
(r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
|
82
|
-
r'declspec|finally|int64|try|leave
|
88
|
+
r'declspec|finally|int64|try|leave|wchar_t|w64|unaligned|'
|
89
|
+
r'raise|noop|identifier|forceinline|assume)\b', Keyword.Reserved),
|
83
90
|
(r'(true|false|NULL)\b', Name.Builtin),
|
84
91
|
('[a-zA-Z_][a-zA-Z0-9_]*', Name),
|
85
92
|
],
|
@@ -89,7 +96,7 @@ class CLexer(RegexLexer):
|
|
89
96
|
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
|
90
97
|
r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
|
91
98
|
r'(\s*\([^;]*?\))' # signature
|
92
|
-
r'(' + _ws + r')({)',
|
99
|
+
r'(' + _ws + r')?({)',
|
93
100
|
bygroups(using(this), Name.Function, using(this), using(this),
|
94
101
|
Punctuation),
|
95
102
|
'function'),
|
@@ -97,7 +104,7 @@ class CLexer(RegexLexer):
|
|
97
104
|
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
|
98
105
|
r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
|
99
106
|
r'(\s*\([^;]*?\))' # signature
|
100
|
-
r'(' + _ws + r')(;)',
|
107
|
+
r'(' + _ws + r')?(;)',
|
101
108
|
bygroups(using(this), Name.Function, using(this), using(this),
|
102
109
|
Punctuation)),
|
103
110
|
('', Text, 'statement'),
|
@@ -117,7 +124,8 @@ class CLexer(RegexLexer):
|
|
117
124
|
],
|
118
125
|
'string': [
|
119
126
|
(r'"', String, '#pop'),
|
120
|
-
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|
|
127
|
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
|
128
|
+
r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
|
121
129
|
(r'[^\\"\n]+', String), # all other characters
|
122
130
|
(r'\\\n', String), # line continuation
|
123
131
|
(r'\\', String), # stray backslash
|
@@ -139,16 +147,17 @@ class CLexer(RegexLexer):
|
|
139
147
|
}
|
140
148
|
|
141
149
|
stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
|
142
|
-
|
143
|
-
|
144
|
-
|
150
|
+
'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
|
151
|
+
'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
|
152
|
+
'wctrans_t', 'wint_t', 'wctype_t']
|
145
153
|
c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
154
|
+
'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
|
155
|
+
'int_least16_t', 'int_least32_t', 'int_least64_t',
|
156
|
+
'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
|
157
|
+
'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
|
158
|
+
'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
|
159
|
+
'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t',
|
160
|
+
'uintmax_t']
|
152
161
|
|
153
162
|
def __init__(self, **options):
|
154
163
|
self.stdlibhighlighting = get_bool_opt(options,
|
@@ -167,97 +176,120 @@ class CLexer(RegexLexer):
|
|
167
176
|
token = Keyword.Type
|
168
177
|
yield index, token, value
|
169
178
|
|
170
|
-
|
179
|
+
|
180
|
+
class CLexer(CFamilyLexer):
|
181
|
+
"""
|
182
|
+
For C source code with preprocessor directives.
|
183
|
+
"""
|
184
|
+
name = 'C'
|
185
|
+
aliases = ['c']
|
186
|
+
filenames = ['*.c', '*.h', '*.idc']
|
187
|
+
mimetypes = ['text/x-chdr', 'text/x-csrc']
|
188
|
+
priority = 0.1
|
189
|
+
|
190
|
+
def analyse_text(text):
|
191
|
+
return 0.1
|
192
|
+
|
193
|
+
|
194
|
+
class CppLexer(CFamilyLexer):
|
171
195
|
"""
|
172
196
|
For C++ source code with preprocessor directives.
|
173
197
|
"""
|
174
198
|
name = 'C++'
|
175
199
|
aliases = ['cpp', 'c++']
|
176
200
|
filenames = ['*.cpp', '*.hpp', '*.c++', '*.h++',
|
177
|
-
'*.cc', '*.hh', '*.cxx', '*.hxx'
|
201
|
+
'*.cc', '*.hh', '*.cxx', '*.hxx',
|
202
|
+
'*.C', '*.H', '*.cp', '*.CPP']
|
178
203
|
mimetypes = ['text/x-c++hdr', 'text/x-c++src']
|
179
|
-
|
180
|
-
#: optional Comment or Whitespace
|
181
|
-
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
|
204
|
+
priority = 0.1
|
182
205
|
|
183
206
|
tokens = {
|
184
|
-
'
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
bygroups(using(this), Comment.Preproc), 'if0'),
|
191
|
-
('^(' + _ws + ')(#)',
|
192
|
-
bygroups(using(this), Comment.Preproc), 'macro'),
|
193
|
-
(r'\n', Text),
|
194
|
-
(r'\s+', Text),
|
195
|
-
(r'\\\n', Text), # line continuation
|
196
|
-
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
197
|
-
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
198
|
-
(r'[{}]', Punctuation),
|
199
|
-
(r'L?"', String, 'string'),
|
200
|
-
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
201
|
-
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
|
202
|
-
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
203
|
-
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
204
|
-
(r'0[0-7]+[LlUu]*', Number.Oct),
|
205
|
-
(r'\d+[LlUu]*', Number.Integer),
|
206
|
-
(r'\*/', Error),
|
207
|
-
(r'[~!%^&*+=|?:<>/-]', Operator),
|
208
|
-
(r'[()\[\],.;]', Punctuation),
|
209
|
-
(r'(asm|auto|break|case|catch|const|const_cast|continue|'
|
210
|
-
r'default|delete|do|dynamic_cast|else|enum|explicit|export|'
|
211
|
-
r'extern|for|friend|goto|if|mutable|namespace|new|operator|'
|
212
|
-
r'private|protected|public|register|reinterpret_cast|return|'
|
213
|
-
r'restrict|sizeof|static|static_cast|struct|switch|template|'
|
214
|
-
r'this|throw|throws|try|typedef|typeid|typename|union|using|'
|
215
|
-
r'volatile|virtual|while)\b', Keyword),
|
207
|
+
'statements': [
|
208
|
+
(r'(asm|catch|const_cast|delete|dynamic_cast|explicit|'
|
209
|
+
r'export|friend|mutable|namespace|new|operator|'
|
210
|
+
r'private|protected|public|reinterpret_cast|'
|
211
|
+
r'restrict|static_cast|template|this|throw|throws|'
|
212
|
+
r'typeid|typename|using|virtual)\b', Keyword),
|
216
213
|
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
r'multiple_inheritance|
|
224
|
-
r'identifier|forceinline|event|assume)\b', Keyword.Reserved),
|
214
|
+
inherit,
|
215
|
+
],
|
216
|
+
'root': [
|
217
|
+
inherit,
|
218
|
+
# C++ Microsoft-isms
|
219
|
+
(r'__(virtual_inheritance|uuidof|super|single_inheritance|'
|
220
|
+
r'multiple_inheritance|interface|event)\b', Keyword.Reserved),
|
225
221
|
# Offload C++ extensions, http://offload.codeplay.com/
|
226
222
|
(r'(__offload|__blockingoffload|__outer)\b', Keyword.Pseudo),
|
227
|
-
(r'(true|false)\b', Keyword.Constant),
|
228
|
-
(r'NULL\b', Name.Builtin),
|
229
|
-
('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
|
230
|
-
('[a-zA-Z_][a-zA-Z0-9_]*', Name),
|
231
223
|
],
|
232
224
|
'classname': [
|
233
225
|
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
|
234
226
|
# template specification
|
235
227
|
(r'\s*(?=>)', Text, '#pop'),
|
236
228
|
],
|
237
|
-
'string': [
|
238
|
-
(r'"', String, '#pop'),
|
239
|
-
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
240
|
-
(r'[^\\"\n]+', String), # all other characters
|
241
|
-
(r'\\\n', String), # line continuation
|
242
|
-
(r'\\', String), # stray backslash
|
243
|
-
],
|
244
|
-
'macro': [
|
245
|
-
(r'[^/\n]+', Comment.Preproc),
|
246
|
-
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
247
|
-
(r'//.*?\n', Comment.Single, '#pop'),
|
248
|
-
(r'/', Comment.Preproc),
|
249
|
-
(r'(?<=\\)\n', Comment.Preproc),
|
250
|
-
(r'\n', Comment.Preproc, '#pop'),
|
251
|
-
],
|
252
|
-
'if0': [
|
253
|
-
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
254
|
-
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
255
|
-
(r'.*?\n', Comment),
|
256
|
-
]
|
257
229
|
}
|
258
230
|
|
231
|
+
def analyse_text(text):
|
232
|
+
return 0.1
|
233
|
+
|
234
|
+
|
235
|
+
class SwigLexer(CppLexer):
|
236
|
+
"""
|
237
|
+
For `SWIG <http://www.swig.org/>`_ source code.
|
259
238
|
|
260
|
-
|
239
|
+
*New in Pygments 1.7.*
|
240
|
+
"""
|
241
|
+
name = 'SWIG'
|
242
|
+
aliases = ['Swig', 'swig']
|
243
|
+
filenames = ['*.swg', '*.i']
|
244
|
+
mimetypes = ['text/swig']
|
245
|
+
priority = 0.04 # Lower than C/C++ and Objective C/C++
|
246
|
+
|
247
|
+
tokens = {
|
248
|
+
'statements': [
|
249
|
+
(r'(%[a-z_][a-z0-9_]*)', Name.Function), # SWIG directives
|
250
|
+
('\$\**\&?[a-zA-Z0-9_]+', Name), # Special variables
|
251
|
+
(r'##*[a-zA-Z_][a-zA-Z0-9_]*', Comment.Preproc), # Stringification / additional preprocessor directives
|
252
|
+
inherit,
|
253
|
+
],
|
254
|
+
}
|
255
|
+
|
256
|
+
# This is a far from complete set of SWIG directives
|
257
|
+
swig_directives = (
|
258
|
+
# Most common directives
|
259
|
+
'%apply', '%define', '%director', '%enddef', '%exception', '%extend',
|
260
|
+
'%feature', '%fragment', '%ignore', '%immutable', '%import', '%include',
|
261
|
+
'%inline', '%insert', '%module', '%newobject', '%nspace', '%pragma',
|
262
|
+
'%rename', '%shared_ptr', '%template', '%typecheck', '%typemap',
|
263
|
+
# Less common directives
|
264
|
+
'%arg', '%attribute', '%bang', '%begin', '%callback', '%catches', '%clear',
|
265
|
+
'%constant', '%copyctor', '%csconst', '%csconstvalue', '%csenum',
|
266
|
+
'%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor',
|
267
|
+
'%defaultdtor', '%defined', '%delete', '%delobject', '%descriptor',
|
268
|
+
'%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments',
|
269
|
+
'%header', '%ifcplusplus', '%ignorewarn', '%implicit', '%implicitconv',
|
270
|
+
'%init', '%javaconst', '%javaconstvalue', '%javaenum', '%javaexception',
|
271
|
+
'%javamethodmodifiers', '%kwargs', '%luacode', '%mutable', '%naturalvar',
|
272
|
+
'%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend',
|
273
|
+
'%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall',
|
274
|
+
'%pythonnondynamic', '%pythonprepend', '%refobject', '%shadow', '%sizeof',
|
275
|
+
'%trackobjects', '%types', '%unrefobject', '%varargs', '%warn', '%warnfilter')
|
276
|
+
|
277
|
+
def analyse_text(text):
|
278
|
+
rv = 0.1 # Same as C/C++
|
279
|
+
# Search for SWIG directives, which are conventionally at the beginning of
|
280
|
+
# a line. The probability of them being within a line is low, so let another
|
281
|
+
# lexer win in this case.
|
282
|
+
matches = re.findall(r'^\s*(%[a-z_][a-z0-9_]*)', text, re.M)
|
283
|
+
for m in matches:
|
284
|
+
if m in SwigLexer.swig_directives:
|
285
|
+
rv = 0.98
|
286
|
+
break
|
287
|
+
else:
|
288
|
+
rv = 0.91 # Fraction higher than MatlabLexer
|
289
|
+
return rv
|
290
|
+
|
291
|
+
|
292
|
+
class ECLexer(CLexer):
|
261
293
|
"""
|
262
294
|
For eC source code with preprocessor directives.
|
263
295
|
|
@@ -268,144 +300,106 @@ class ECLexer(RegexLexer):
|
|
268
300
|
filenames = ['*.ec', '*.eh']
|
269
301
|
mimetypes = ['text/x-echdr', 'text/x-ecsrc']
|
270
302
|
|
271
|
-
#: optional Comment or Whitespace
|
272
|
-
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
|
273
|
-
|
274
303
|
tokens = {
|
275
|
-
'whitespace': [
|
276
|
-
# preprocessor directives: without whitespace
|
277
|
-
('^#if\s+0', Comment.Preproc, 'if0'),
|
278
|
-
('^#', Comment.Preproc, 'macro'),
|
279
|
-
# or with whitespace
|
280
|
-
('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
|
281
|
-
('^' + _ws + '#', Comment.Preproc, 'macro'),
|
282
|
-
(r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))', bygroups(Text, Name.Label)),
|
283
|
-
(r'\n', Text),
|
284
|
-
(r'\s+', Text),
|
285
|
-
(r'\\\n', Text), # line continuation
|
286
|
-
(r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
287
|
-
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
288
|
-
],
|
289
304
|
'statements': [
|
290
|
-
(r'
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
(r'\*/', Error),
|
298
|
-
(r'[~!%^&*+=|?:<>/-]', Operator),
|
299
|
-
(r'[()\[\],.]', Punctuation),
|
300
|
-
(r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
|
301
|
-
(r'(auto|break|case|const|continue|default|do|else|enum|extern|'
|
302
|
-
r'for|goto|if|register|restricted|return|sizeof|static|struct|'
|
303
|
-
r'switch|typedef|union|volatile|virtual|while|class|private|public|'
|
304
|
-
r'property|import|delete|new|new0|renew|renew0|define|get|set|remote|dllexport|dllimport|stdcall|'
|
305
|
-
r'subclass|__on_register_module|namespace|using|typed_object|any_object|incref|register|watch|'
|
306
|
-
r'stopwatching|firewatchers|watchable|class_designer|class_fixed|class_no_expansion|isset|'
|
307
|
-
r'class_default_property|property_category|class_data|class_property|virtual|thisclass|'
|
305
|
+
(r'(virtual|class|private|public|property|import|delete|new|new0|'
|
306
|
+
r'renew|renew0|define|get|set|remote|dllexport|dllimport|stdcall|'
|
307
|
+
r'subclass|__on_register_module|namespace|using|typed_object|'
|
308
|
+
r'any_object|incref|register|watch|stopwatching|firewatchers|'
|
309
|
+
r'watchable|class_designer|class_fixed|class_no_expansion|isset|'
|
310
|
+
r'class_default_property|property_category|class_data|'
|
311
|
+
r'class_property|virtual|thisclass|'
|
308
312
|
r'dbtable|dbindex|database_open|dbfield)\b', Keyword),
|
309
|
-
(r'(int|long|float|short|double|char|unsigned|signed|void)\b',
|
310
|
-
Keyword.Type),
|
311
313
|
(r'(uint|uint16|uint32|uint64|bool|byte|unichar|int64)\b',
|
312
314
|
Keyword.Type),
|
313
315
|
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
|
314
|
-
(r'(
|
315
|
-
|
316
|
-
r'declspec|finally|int64|try|leave)\b', Keyword.Reserved),
|
317
|
-
(r'(true|false|null|value|this|NULL)\b', Name.Builtin),
|
318
|
-
('[a-zA-Z_][a-zA-Z0-9_]*', Name),
|
319
|
-
],
|
320
|
-
'root': [
|
321
|
-
include('whitespace'),
|
322
|
-
# functions
|
323
|
-
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
|
324
|
-
r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
|
325
|
-
r'(\s*\([^;]*?\))' # signature
|
326
|
-
r'(' + _ws + r')({)',
|
327
|
-
bygroups(using(this), Name.Function, using(this), using(this),
|
328
|
-
Punctuation),
|
329
|
-
'function'),
|
330
|
-
# function declarations
|
331
|
-
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
|
332
|
-
r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
|
333
|
-
r'(\s*\([^;]*?\))' # signature
|
334
|
-
r'(' + _ws + r')(;)',
|
335
|
-
bygroups(using(this), Name.Function, using(this), using(this),
|
336
|
-
Punctuation)),
|
337
|
-
('', Text, 'statement'),
|
316
|
+
(r'(null|value|this)\b', Name.Builtin),
|
317
|
+
inherit,
|
338
318
|
],
|
339
319
|
'classname': [
|
340
320
|
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
|
341
321
|
# template specification
|
342
322
|
(r'\s*(?=>)', Text, '#pop'),
|
343
323
|
],
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
324
|
+
}
|
325
|
+
|
326
|
+
|
327
|
+
class NesCLexer(CLexer):
|
328
|
+
"""
|
329
|
+
For `nesC <https://github.com/tinyos/nesc>`_ source code with preprocessor
|
330
|
+
directives.
|
331
|
+
|
332
|
+
*New in Pygments 1.7.*
|
333
|
+
"""
|
334
|
+
name = 'nesC'
|
335
|
+
aliases = ['nesc']
|
336
|
+
filenames = ['*.nc']
|
337
|
+
mimetypes = ['text/x-nescsrc']
|
338
|
+
|
339
|
+
tokens = {
|
340
|
+
'statements': [
|
341
|
+
(r'(abstract|as|async|atomic|call|command|component|components|'
|
342
|
+
r'configuration|event|extends|generic|implementation|includes|'
|
343
|
+
r'interface|module|new|norace|post|provides|signal|task|uses)\b',
|
344
|
+
Keyword),
|
345
|
+
(r'(nx_struct|nx_union|nx_int8_t|nx_int16_t|nx_int32_t|nx_int64_t|'
|
346
|
+
r'nx_uint8_t|nx_uint16_t|nx_uint32_t|nx_uint64_t)\b',
|
347
|
+
Keyword.Type),
|
348
|
+
inherit,
|
349
349
|
],
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
350
|
+
}
|
351
|
+
|
352
|
+
|
353
|
+
class ClayLexer(RegexLexer):
|
354
|
+
"""
|
355
|
+
For `Clay <http://claylabs.com/clay/>`_ source.
|
356
|
+
|
357
|
+
*New in Pygments 1.7.*
|
358
|
+
"""
|
359
|
+
name = 'Clay'
|
360
|
+
filenames = ['*.clay']
|
361
|
+
aliases = ['clay']
|
362
|
+
mimetypes = ['text/x-clay']
|
363
|
+
tokens = {
|
364
|
+
'root': [
|
365
|
+
(r'\s', Text),
|
366
|
+
(r'//.*?$', Comment.Singleline),
|
367
|
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
368
|
+
(r'\b(public|private|import|as|record|variant|instance'
|
369
|
+
r'|define|overload|default|external|alias'
|
370
|
+
r'|rvalue|ref|forward|inline|noinline|forceinline'
|
371
|
+
r'|enum|var|and|or|not|if|else|goto|return|while'
|
372
|
+
r'|switch|case|break|continue|for|in|true|false|try|catch|throw'
|
373
|
+
r'|finally|onerror|staticassert|eval|when|newtype'
|
374
|
+
r'|__FILE__|__LINE__|__COLUMN__|__ARG__'
|
375
|
+
r')\b', Keyword),
|
376
|
+
(r'[~!%^&*+=|:<>/-]', Operator),
|
377
|
+
(r'[#(){}\[\],;.]', Punctuation),
|
378
|
+
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
379
|
+
(r'\d+[LlUu]*', Number.Integer),
|
380
|
+
(r'\b(true|false)\b', Name.Builtin),
|
381
|
+
(r'(?i)[a-z_?][a-z_?0-9]*', Name),
|
382
|
+
(r'"""', String, 'tdqs'),
|
383
|
+
(r'"', String, 'dqs'),
|
356
384
|
],
|
357
|
-
'
|
385
|
+
'strings': [
|
386
|
+
(r'(?i)\\(x[0-9a-f]{2}|.)', String.Escape),
|
387
|
+
(r'.', String),
|
388
|
+
],
|
389
|
+
'nl': [
|
390
|
+
(r'\n', String),
|
391
|
+
],
|
392
|
+
'dqs': [
|
358
393
|
(r'"', String, '#pop'),
|
359
|
-
(
|
360
|
-
(r'[^\\"\n]+', String), # all other characters
|
361
|
-
(r'\\\n', String), # line continuation
|
362
|
-
(r'\\', String), # stray backslash
|
394
|
+
include('strings'),
|
363
395
|
],
|
364
|
-
'
|
365
|
-
(r'
|
366
|
-
(
|
367
|
-
(
|
368
|
-
(r'/', Comment.Preproc),
|
369
|
-
(r'(?<=\\)\n', Comment.Preproc),
|
370
|
-
(r'\n', Comment.Preproc, '#pop'),
|
396
|
+
'tdqs': [
|
397
|
+
(r'"""', String, '#pop'),
|
398
|
+
include('strings'),
|
399
|
+
include('nl'),
|
371
400
|
],
|
372
|
-
'if0': [
|
373
|
-
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
374
|
-
(r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
|
375
|
-
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
376
|
-
(r'.*?\n', Comment),
|
377
|
-
]
|
378
401
|
}
|
379
402
|
|
380
|
-
stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
|
381
|
-
'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
|
382
|
-
'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
|
383
|
-
'wctrans_t', 'wint_t', 'wctype_t']
|
384
|
-
c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
|
385
|
-
'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
|
386
|
-
'int_least16_t', 'int_least32_t', 'int_least64_t',
|
387
|
-
'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
|
388
|
-
'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
|
389
|
-
'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
|
390
|
-
'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t']
|
391
|
-
|
392
|
-
def __init__(self, **options):
|
393
|
-
self.stdlibhighlighting = get_bool_opt(options,
|
394
|
-
'stdlibhighlighting', True)
|
395
|
-
self.c99highlighting = get_bool_opt(options,
|
396
|
-
'c99highlighting', True)
|
397
|
-
RegexLexer.__init__(self, **options)
|
398
|
-
|
399
|
-
def get_tokens_unprocessed(self, text):
|
400
|
-
for index, token, value in \
|
401
|
-
RegexLexer.get_tokens_unprocessed(self, text):
|
402
|
-
if token is Name:
|
403
|
-
if self.stdlibhighlighting and value in self.stdlib_types:
|
404
|
-
token = Keyword.Type
|
405
|
-
elif self.c99highlighting and value in self.c99_types:
|
406
|
-
token = Keyword.Type
|
407
|
-
yield index, token, value
|
408
|
-
|
409
403
|
|
410
404
|
class DLexer(RegexLexer):
|
411
405
|
"""
|
@@ -1050,174 +1044,178 @@ class DylanLexer(RegexLexer):
|
|
1050
1044
|
|
1051
1045
|
name = 'Dylan'
|
1052
1046
|
aliases = ['dylan']
|
1053
|
-
filenames = ['*.dylan', '*.dyl']
|
1047
|
+
filenames = ['*.dylan', '*.dyl', '*.intr']
|
1054
1048
|
mimetypes = ['text/x-dylan']
|
1055
1049
|
|
1056
|
-
flags = re.
|
1050
|
+
flags = re.IGNORECASE
|
1051
|
+
|
1052
|
+
builtins = set([
|
1053
|
+
'subclass', 'abstract', 'block', 'concrete', 'constant', 'class',
|
1054
|
+
'compiler-open', 'compiler-sideways', 'domain', 'dynamic',
|
1055
|
+
'each-subclass', 'exception', 'exclude', 'function', 'generic',
|
1056
|
+
'handler', 'inherited', 'inline', 'inline-only', 'instance',
|
1057
|
+
'interface', 'import', 'keyword', 'library', 'macro', 'method',
|
1058
|
+
'module', 'open', 'primary', 'required', 'sealed', 'sideways',
|
1059
|
+
'singleton', 'slot', 'thread', 'variable', 'virtual'])
|
1060
|
+
|
1061
|
+
keywords = set([
|
1062
|
+
'above', 'afterwards', 'begin', 'below', 'by', 'case', 'cleanup',
|
1063
|
+
'create', 'define', 'else', 'elseif', 'end', 'export', 'finally',
|
1064
|
+
'for', 'from', 'if', 'in', 'let', 'local', 'otherwise', 'rename',
|
1065
|
+
'select', 'signal', 'then', 'to', 'unless', 'until', 'use', 'when',
|
1066
|
+
'while'])
|
1067
|
+
|
1068
|
+
operators = set([
|
1069
|
+
'~', '+', '-', '*', '|', '^', '=', '==', '~=', '~==', '<', '<=',
|
1070
|
+
'>', '>=', '&', '|'])
|
1071
|
+
|
1072
|
+
functions = set([
|
1073
|
+
'abort', 'abs', 'add', 'add!', 'add-method', 'add-new', 'add-new!',
|
1074
|
+
'all-superclasses', 'always', 'any?', 'applicable-method?', 'apply',
|
1075
|
+
'aref', 'aref-setter', 'as', 'as-lowercase', 'as-lowercase!',
|
1076
|
+
'as-uppercase', 'as-uppercase!', 'ash', 'backward-iteration-protocol',
|
1077
|
+
'break', 'ceiling', 'ceiling/', 'cerror', 'check-type', 'choose',
|
1078
|
+
'choose-by', 'complement', 'compose', 'concatenate', 'concatenate-as',
|
1079
|
+
'condition-format-arguments', 'condition-format-string', 'conjoin',
|
1080
|
+
'copy-sequence', 'curry', 'default-handler', 'dimension', 'dimensions',
|
1081
|
+
'direct-subclasses', 'direct-superclasses', 'disjoin', 'do',
|
1082
|
+
'do-handlers', 'element', 'element-setter', 'empty?', 'error', 'even?',
|
1083
|
+
'every?', 'false-or', 'fill!', 'find-key', 'find-method', 'first',
|
1084
|
+
'first-setter', 'floor', 'floor/', 'forward-iteration-protocol',
|
1085
|
+
'function-arguments', 'function-return-values',
|
1086
|
+
'function-specializers', 'gcd', 'generic-function-mandatory-keywords',
|
1087
|
+
'generic-function-methods', 'head', 'head-setter', 'identity',
|
1088
|
+
'initialize', 'instance?', 'integral?', 'intersection',
|
1089
|
+
'key-sequence', 'key-test', 'last', 'last-setter', 'lcm', 'limited',
|
1090
|
+
'list', 'logand', 'logbit?', 'logior', 'lognot', 'logxor', 'make',
|
1091
|
+
'map', 'map-as', 'map-into', 'max', 'member?', 'merge-hash-codes',
|
1092
|
+
'min', 'modulo', 'negative', 'negative?', 'next-method',
|
1093
|
+
'object-class', 'object-hash', 'odd?', 'one-of', 'pair', 'pop',
|
1094
|
+
'pop-last', 'positive?', 'push', 'push-last', 'range', 'rank',
|
1095
|
+
'rcurry', 'reduce', 'reduce1', 'remainder', 'remove', 'remove!',
|
1096
|
+
'remove-duplicates', 'remove-duplicates!', 'remove-key!',
|
1097
|
+
'remove-method', 'replace-elements!', 'replace-subsequence!',
|
1098
|
+
'restart-query', 'return-allowed?', 'return-description',
|
1099
|
+
'return-query', 'reverse', 'reverse!', 'round', 'round/',
|
1100
|
+
'row-major-index', 'second', 'second-setter', 'shallow-copy',
|
1101
|
+
'signal', 'singleton', 'size', 'size-setter', 'slot-initialized?',
|
1102
|
+
'sort', 'sort!', 'sorted-applicable-methods', 'subsequence-position',
|
1103
|
+
'subtype?', 'table-protocol', 'tail', 'tail-setter', 'third',
|
1104
|
+
'third-setter', 'truncate', 'truncate/', 'type-error-expected-type',
|
1105
|
+
'type-error-value', 'type-for-copy', 'type-union', 'union', 'values',
|
1106
|
+
'vector', 'zero?'])
|
1107
|
+
|
1108
|
+
valid_name = '\\\\?[a-zA-Z0-9' + re.escape('!&*<>|^$%@_-+~?/=') + ']+'
|
1109
|
+
|
1110
|
+
def get_tokens_unprocessed(self, text):
|
1111
|
+
for index, token, value in RegexLexer.get_tokens_unprocessed(self, text):
|
1112
|
+
if token is Name:
|
1113
|
+
lowercase_value = value.lower()
|
1114
|
+
if lowercase_value in self.builtins:
|
1115
|
+
yield index, Name.Builtin, value
|
1116
|
+
continue
|
1117
|
+
if lowercase_value in self.keywords:
|
1118
|
+
yield index, Keyword, value
|
1119
|
+
continue
|
1120
|
+
if lowercase_value in self.functions:
|
1121
|
+
yield index, Name.Builtin, value
|
1122
|
+
continue
|
1123
|
+
if lowercase_value in self.operators:
|
1124
|
+
yield index, Operator, value
|
1125
|
+
continue
|
1126
|
+
yield index, token, value
|
1057
1127
|
|
1058
1128
|
tokens = {
|
1059
1129
|
'root': [
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
r'|v(ariable|irtual))\b', Name.Builtin),
|
1065
|
-
(r'<\w+>', Keyword.Type),
|
1130
|
+
# Whitespace
|
1131
|
+
(r'\s+', Text),
|
1132
|
+
|
1133
|
+
# single line comment
|
1066
1134
|
(r'//.*?\n', Comment.Single),
|
1067
|
-
|
1135
|
+
|
1136
|
+
# lid header
|
1137
|
+
(r'([A-Za-z0-9-]+)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
|
1138
|
+
bygroups(Name.Attribute, Operator, Text, String)),
|
1139
|
+
|
1140
|
+
('', Text, 'code') # no header match, switch to code
|
1141
|
+
],
|
1142
|
+
'code': [
|
1143
|
+
# Whitespace
|
1144
|
+
(r'\s+', Text),
|
1145
|
+
|
1146
|
+
# single line comment
|
1147
|
+
(r'//.*?\n', Comment.Single),
|
1148
|
+
|
1149
|
+
# multi-line comment
|
1150
|
+
(r'/\*', Comment.Multiline, 'comment'),
|
1151
|
+
|
1152
|
+
# strings and characters
|
1068
1153
|
(r'"', String, 'string'),
|
1069
1154
|
(r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
(r'
|
1079
|
-
|
1080
|
-
|
1081
|
-
(r'[
|
1082
|
-
|
1083
|
-
|
1155
|
+
|
1156
|
+
# binary integer
|
1157
|
+
(r'#[bB][01]+', Number),
|
1158
|
+
|
1159
|
+
# octal integer
|
1160
|
+
(r'#[oO][0-7]+', Number.Oct),
|
1161
|
+
|
1162
|
+
# floating point
|
1163
|
+
(r'[-+]?(\d*\.\d+(e[-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)', Number.Float),
|
1164
|
+
|
1165
|
+
# decimal integer
|
1166
|
+
(r'[-+]?\d+', Number.Integer),
|
1167
|
+
|
1168
|
+
# hex integer
|
1169
|
+
(r'#[xX][0-9a-fA-F]+', Number.Hex),
|
1170
|
+
|
1171
|
+
# Macro parameters
|
1172
|
+
(r'(\?' + valid_name + ')(:)'
|
1173
|
+
r'(token|name|variable|expression|body|case-body|\*)',
|
1174
|
+
bygroups(Name.Tag, Operator, Name.Builtin)),
|
1175
|
+
(r'(\?)(:)(token|name|variable|expression|body|case-body|\*)',
|
1176
|
+
bygroups(Name.Tag, Operator, Name.Builtin)),
|
1177
|
+
(r'\?' + valid_name, Name.Tag),
|
1178
|
+
|
1179
|
+
# Punctuation
|
1180
|
+
(r'(=>|::|#\(|#\[|##|\?|\?\?|\?=|[(){}\[\],\.;])', Punctuation),
|
1181
|
+
|
1182
|
+
# Most operators are picked up as names and then re-flagged.
|
1183
|
+
# This one isn't valid in a name though, so we pick it up now.
|
1184
|
+
(r':=', Operator),
|
1185
|
+
|
1186
|
+
# Pick up #t / #f before we match other stuff with #.
|
1187
|
+
(r'#[tf]', Literal),
|
1188
|
+
|
1189
|
+
# #"foo" style keywords
|
1190
|
+
(r'#"', String.Symbol, 'keyword'),
|
1191
|
+
|
1192
|
+
# #rest, #key, #all-keys, etc.
|
1084
1193
|
(r'#[a-zA-Z0-9-]+', Keyword),
|
1085
|
-
(r'#(\(|\[)', Punctuation),
|
1086
|
-
(r'[a-zA-Z0-9-_]+', Name.Variable),
|
1087
|
-
],
|
1088
|
-
'string': [
|
1089
|
-
(r'"', String, '#pop'),
|
1090
|
-
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
1091
|
-
(r'[^\\"\n]+', String), # all other characters
|
1092
|
-
(r'\\\n', String), # line continuation
|
1093
|
-
(r'\\', String), # stray backslash
|
1094
|
-
],
|
1095
|
-
}
|
1096
1194
|
|
1195
|
+
# required-init-keyword: style keywords.
|
1196
|
+
(valid_name + ':', Keyword),
|
1097
1197
|
|
1098
|
-
class
|
1099
|
-
|
1100
|
-
For Objective-C source code with preprocessor directives.
|
1101
|
-
"""
|
1198
|
+
# class names
|
1199
|
+
(r'<' + valid_name + '>', Name.Class),
|
1102
1200
|
|
1103
|
-
|
1104
|
-
|
1105
|
-
#XXX: objc has .h files too :-/
|
1106
|
-
filenames = ['*.m']
|
1107
|
-
mimetypes = ['text/x-objective-c']
|
1201
|
+
# define variable forms.
|
1202
|
+
(r'\*' + valid_name + '\*', Name.Variable.Global),
|
1108
1203
|
|
1109
|
-
|
1110
|
-
|
1204
|
+
# define constant forms.
|
1205
|
+
(r'\$' + valid_name, Name.Constant),
|
1111
1206
|
|
1112
|
-
|
1113
|
-
|
1114
|
-
# preprocessor directives: without whitespace
|
1115
|
-
('^#if\s+0', Comment.Preproc, 'if0'),
|
1116
|
-
('^#', Comment.Preproc, 'macro'),
|
1117
|
-
# or with whitespace
|
1118
|
-
('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
|
1119
|
-
('^' + _ws + '#', Comment.Preproc, 'macro'),
|
1120
|
-
(r'\n', Text),
|
1121
|
-
(r'\s+', Text),
|
1122
|
-
(r'\\\n', Text), # line continuation
|
1123
|
-
(r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
1124
|
-
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
1207
|
+
# everything else. We re-flag some of these in the method above.
|
1208
|
+
(valid_name, Name),
|
1125
1209
|
],
|
1126
|
-
'
|
1127
|
-
(r'
|
1128
|
-
(r
|
1129
|
-
|
1130
|
-
(r'
|
1131
|
-
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
1132
|
-
(r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
|
1133
|
-
(r'0[0-7]+[Ll]?', Number.Oct),
|
1134
|
-
(r'\d+[Ll]?', Number.Integer),
|
1135
|
-
(r'[~!%^&*+=|?:<>/-]', Operator),
|
1136
|
-
(r'[()\[\],.]', Punctuation),
|
1137
|
-
(r'(auto|break|case|const|continue|default|do|else|enum|extern|'
|
1138
|
-
r'for|goto|if|register|restricted|return|sizeof|static|struct|'
|
1139
|
-
r'switch|typedef|union|volatile|virtual|while|in|@selector|'
|
1140
|
-
r'@private|@protected|@public|@encode|'
|
1141
|
-
r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
|
1142
|
-
r'@synthesize|@dynamic)\b', Keyword),
|
1143
|
-
(r'(int|long|float|short|double|char|unsigned|signed|void|'
|
1144
|
-
r'id|BOOL|IBOutlet|IBAction|SEL)\b', Keyword.Type),
|
1145
|
-
(r'(_{0,2}inline|naked|restrict|thread|typename)\b',
|
1146
|
-
Keyword.Reserved),
|
1147
|
-
(r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
|
1148
|
-
r'declspec|finally|int64|try|leave)\b', Keyword.Reserved),
|
1149
|
-
(r'(TRUE|FALSE|nil|NULL)\b', Name.Builtin),
|
1150
|
-
('[a-zA-Z$_][a-zA-Z0-9$_]*:(?!:)', Name.Label),
|
1151
|
-
('[a-zA-Z$_][a-zA-Z0-9$_]*', Name),
|
1152
|
-
],
|
1153
|
-
'root': [
|
1154
|
-
include('whitespace'),
|
1155
|
-
# functions
|
1156
|
-
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
|
1157
|
-
r'([a-zA-Z$_][a-zA-Z0-9$_]*)' # method name
|
1158
|
-
r'(\s*\([^;]*?\))' # signature
|
1159
|
-
r'(' + _ws + r')({)',
|
1160
|
-
bygroups(using(this), Name.Function,
|
1161
|
-
using(this), Text, Punctuation),
|
1162
|
-
'function'),
|
1163
|
-
# methods
|
1164
|
-
(r'^([-+])(\s*)' # method marker
|
1165
|
-
r'(\(.*?\))?(\s*)' # return type
|
1166
|
-
r'([a-zA-Z$_][a-zA-Z0-9$_]*:?)', # begin of method name
|
1167
|
-
bygroups(Keyword, Text, using(this),
|
1168
|
-
Text, Name.Function),
|
1169
|
-
'method'),
|
1170
|
-
# function declarations
|
1171
|
-
(r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
|
1172
|
-
r'([a-zA-Z$_][a-zA-Z0-9$_]*)' # method name
|
1173
|
-
r'(\s*\([^;]*?\))' # signature
|
1174
|
-
r'(' + _ws + r')(;)',
|
1175
|
-
bygroups(using(this), Name.Function,
|
1176
|
-
using(this), Text, Punctuation)),
|
1177
|
-
(r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
|
1178
|
-
'classname'),
|
1179
|
-
(r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
|
1180
|
-
'forward_classname'),
|
1181
|
-
(r'(\s*)(@end)(\s*)', bygroups(Text, Keyword, Text)),
|
1182
|
-
('', Text, 'statement'),
|
1183
|
-
],
|
1184
|
-
'classname' : [
|
1185
|
-
# interface definition that inherits
|
1186
|
-
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
|
1187
|
-
bygroups(Name.Class, Text, Name.Class), '#pop'),
|
1188
|
-
# interface definition for a category
|
1189
|
-
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\([a-zA-Z$_][a-zA-Z0-9$_]*\))',
|
1190
|
-
bygroups(Name.Class, Text, Name.Label), '#pop'),
|
1191
|
-
# simple interface / implementation
|
1192
|
-
('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
|
1193
|
-
],
|
1194
|
-
'forward_classname' : [
|
1195
|
-
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*,\s*)',
|
1196
|
-
bygroups(Name.Class, Text), 'forward_classname'),
|
1197
|
-
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*;?)',
|
1198
|
-
bygroups(Name.Class, Text), '#pop')
|
1199
|
-
],
|
1200
|
-
'statement' : [
|
1201
|
-
include('whitespace'),
|
1202
|
-
include('statements'),
|
1203
|
-
('[{}]', Punctuation),
|
1204
|
-
(';', Punctuation, '#pop'),
|
1205
|
-
],
|
1206
|
-
'function': [
|
1207
|
-
include('whitespace'),
|
1208
|
-
include('statements'),
|
1209
|
-
(';', Punctuation),
|
1210
|
-
('{', Punctuation, '#push'),
|
1211
|
-
('}', Punctuation, '#pop'),
|
1210
|
+
'comment': [
|
1211
|
+
(r'[^*/]', Comment.Multiline),
|
1212
|
+
(r'/\*', Comment.Multiline, '#push'),
|
1213
|
+
(r'\*/', Comment.Multiline, '#pop'),
|
1214
|
+
(r'[*/]', Comment.Multiline)
|
1212
1215
|
],
|
1213
|
-
'
|
1214
|
-
|
1215
|
-
(r'
|
1216
|
-
Name.Variable)),
|
1217
|
-
(r'[a-zA-Z$_][a-zA-Z0-9$_]*:', Name.Function),
|
1218
|
-
(';', Punctuation, '#pop'),
|
1219
|
-
('{', Punctuation, 'function'),
|
1220
|
-
('', Text, '#pop'),
|
1216
|
+
'keyword': [
|
1217
|
+
(r'"', String.Symbol, '#pop'),
|
1218
|
+
(r'[^\\"]+', String.Symbol), # all other characters
|
1221
1219
|
],
|
1222
1220
|
'string': [
|
1223
1221
|
(r'"', String, '#pop'),
|
@@ -1225,31 +1223,213 @@ class ObjectiveCLexer(RegexLexer):
|
|
1225
1223
|
(r'[^\\"\n]+', String), # all other characters
|
1226
1224
|
(r'\\\n', String), # line continuation
|
1227
1225
|
(r'\\', String), # stray backslash
|
1228
|
-
],
|
1229
|
-
'macro': [
|
1230
|
-
(r'[^/\n]+', Comment.Preproc),
|
1231
|
-
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
1232
|
-
(r'//.*?\n', Comment.Single, '#pop'),
|
1233
|
-
(r'/', Comment.Preproc),
|
1234
|
-
(r'(?<=\\)\n', Comment.Preproc),
|
1235
|
-
(r'\n', Comment.Preproc, '#pop'),
|
1236
|
-
],
|
1237
|
-
'if0': [
|
1238
|
-
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
1239
|
-
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
1240
|
-
(r'.*?\n', Comment),
|
1241
1226
|
]
|
1242
1227
|
}
|
1243
1228
|
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1229
|
+
|
1230
|
+
class DylanLidLexer(RegexLexer):
|
1231
|
+
"""
|
1232
|
+
For Dylan LID (Library Interchange Definition) files.
|
1233
|
+
|
1234
|
+
*New in Pygments 1.6.*
|
1235
|
+
"""
|
1236
|
+
|
1237
|
+
name = 'DylanLID'
|
1238
|
+
aliases = ['dylan-lid', 'lid']
|
1239
|
+
filenames = ['*.lid', '*.hdp']
|
1240
|
+
mimetypes = ['text/x-dylan-lid']
|
1241
|
+
|
1242
|
+
flags = re.IGNORECASE
|
1243
|
+
|
1244
|
+
tokens = {
|
1245
|
+
'root': [
|
1246
|
+
# Whitespace
|
1247
|
+
(r'\s+', Text),
|
1248
|
+
|
1249
|
+
# single line comment
|
1250
|
+
(r'//.*?\n', Comment.Single),
|
1251
|
+
|
1252
|
+
# lid header
|
1253
|
+
(r'(.*?)(:)([ \t]*)(.*(?:\n[ \t].+)*)',
|
1254
|
+
bygroups(Name.Attribute, Operator, Text, String)),
|
1255
|
+
]
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
|
1259
|
+
class DylanConsoleLexer(Lexer):
|
1260
|
+
"""
|
1261
|
+
For Dylan interactive console output like:
|
1262
|
+
|
1263
|
+
.. sourcecode:: dylan-console
|
1264
|
+
|
1265
|
+
? let a = 1;
|
1266
|
+
=> 1
|
1267
|
+
? a
|
1268
|
+
=> 1
|
1269
|
+
|
1270
|
+
This is based on a copy of the RubyConsoleLexer.
|
1271
|
+
|
1272
|
+
*New in Pygments 1.6.*
|
1273
|
+
"""
|
1274
|
+
name = 'Dylan session'
|
1275
|
+
aliases = ['dylan-console', 'dylan-repl']
|
1276
|
+
filenames = ['*.dylan-console']
|
1277
|
+
mimetypes = ['text/x-dylan-console']
|
1278
|
+
|
1279
|
+
_line_re = re.compile('.*?\n')
|
1280
|
+
_prompt_re = re.compile('\?| ')
|
1281
|
+
|
1282
|
+
def get_tokens_unprocessed(self, text):
|
1283
|
+
dylexer = DylanLexer(**self.options)
|
1284
|
+
|
1285
|
+
curcode = ''
|
1286
|
+
insertions = []
|
1287
|
+
for match in self._line_re.finditer(text):
|
1288
|
+
line = match.group()
|
1289
|
+
m = self._prompt_re.match(line)
|
1290
|
+
if m is not None:
|
1291
|
+
end = m.end()
|
1292
|
+
insertions.append((len(curcode),
|
1293
|
+
[(0, Generic.Prompt, line[:end])]))
|
1294
|
+
curcode += line[end:]
|
1295
|
+
else:
|
1296
|
+
if curcode:
|
1297
|
+
for item in do_insertions(insertions,
|
1298
|
+
dylexer.get_tokens_unprocessed(curcode)):
|
1299
|
+
yield item
|
1300
|
+
curcode = ''
|
1301
|
+
insertions = []
|
1302
|
+
yield match.start(), Generic.Output, line
|
1303
|
+
if curcode:
|
1304
|
+
for item in do_insertions(insertions,
|
1305
|
+
dylexer.get_tokens_unprocessed(curcode)):
|
1306
|
+
yield item
|
1307
|
+
|
1308
|
+
|
1309
|
+
def objective(baselexer):
|
1310
|
+
"""
|
1311
|
+
Generate a subclass of baselexer that accepts the Objective-C syntax
|
1312
|
+
extensions.
|
1313
|
+
"""
|
1314
|
+
|
1315
|
+
# Have to be careful not to accidentally match JavaDoc/Doxygen syntax here,
|
1316
|
+
# since that's quite common in ordinary C/C++ files. It's OK to match
|
1317
|
+
# JavaDoc/Doxygen keywords that only apply to Objective-C, mind.
|
1318
|
+
#
|
1319
|
+
# The upshot of this is that we CANNOT match @class or @interface
|
1320
|
+
_oc_keywords = re.compile(r'@(?:end|implementation|protocol)')
|
1321
|
+
|
1322
|
+
# Matches [ <ws>? identifier <ws> ( identifier <ws>? ] | identifier? : )
|
1323
|
+
# (note the identifier is *optional* when there is a ':'!)
|
1324
|
+
_oc_message = re.compile(r'\[\s*[a-zA-Z_][a-zA-Z0-9_]*\s+'
|
1325
|
+
r'(?:[a-zA-Z_][a-zA-Z0-9_]*\s*\]|'
|
1326
|
+
r'(?:[a-zA-Z_][a-zA-Z0-9_]*)?:)')
|
1327
|
+
|
1328
|
+
class GeneratedObjectiveCVariant(baselexer):
|
1329
|
+
"""
|
1330
|
+
Implements Objective-C syntax on top of an existing C family lexer.
|
1331
|
+
"""
|
1332
|
+
|
1333
|
+
tokens = {
|
1334
|
+
'statements': [
|
1335
|
+
(r'@"', String, 'string'),
|
1336
|
+
(r"@'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
|
1337
|
+
String.Char),
|
1338
|
+
(r'@(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
|
1339
|
+
(r'@(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
1340
|
+
(r'@0x[0-9a-fA-F]+[Ll]?', Number.Hex),
|
1341
|
+
(r'@0[0-7]+[Ll]?', Number.Oct),
|
1342
|
+
(r'@\d+[Ll]?', Number.Integer),
|
1343
|
+
(r'(in|@selector|@private|@protected|@public|@encode|'
|
1344
|
+
r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
|
1345
|
+
r'@synthesize|@dynamic|@optional)\b', Keyword),
|
1346
|
+
(r'(id|Class|IMP|SEL|BOOL|IBOutlet|IBAction|unichar)\b',
|
1347
|
+
Keyword.Type),
|
1348
|
+
(r'@(true|false|YES|NO)\n', Name.Builtin),
|
1349
|
+
(r'(YES|NO|nil)\b', Name.Builtin),
|
1350
|
+
(r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
|
1351
|
+
('#pop', 'oc_classname')),
|
1352
|
+
(r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
|
1353
|
+
('#pop', 'oc_forward_classname')),
|
1354
|
+
# @ can also prefix other expressions like @{...} or @(...)
|
1355
|
+
(r'@', Punctuation),
|
1356
|
+
inherit,
|
1357
|
+
],
|
1358
|
+
'oc_classname' : [
|
1359
|
+
# interface definition that inherits
|
1360
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
|
1361
|
+
bygroups(Name.Class, Text, Name.Class), '#pop'),
|
1362
|
+
# interface definition for a category
|
1363
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\([a-zA-Z$_][a-zA-Z0-9$_]*\))',
|
1364
|
+
bygroups(Name.Class, Text, Name.Label), '#pop'),
|
1365
|
+
# simple interface / implementation
|
1366
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
|
1367
|
+
],
|
1368
|
+
'oc_forward_classname' : [
|
1369
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*,\s*)',
|
1370
|
+
bygroups(Name.Class, Text), 'oc_forward_classname'),
|
1371
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*;?)',
|
1372
|
+
bygroups(Name.Class, Text), '#pop')
|
1373
|
+
],
|
1374
|
+
'root': [
|
1375
|
+
# methods
|
1376
|
+
(r'^([-+])(\s*)' # method marker
|
1377
|
+
r'(\(.*?\))?(\s*)' # return type
|
1378
|
+
r'([a-zA-Z$_][a-zA-Z0-9$_]*:?)', # begin of method name
|
1379
|
+
bygroups(Keyword, Text, using(this),
|
1380
|
+
Text, Name.Function),
|
1381
|
+
'method'),
|
1382
|
+
inherit,
|
1383
|
+
],
|
1384
|
+
'method': [
|
1385
|
+
include('whitespace'),
|
1386
|
+
# TODO unsure if ellipses are allowed elsewhere, see
|
1387
|
+
# discussion in Issue 789
|
1388
|
+
(r',', Punctuation),
|
1389
|
+
(r'\.\.\.', Punctuation),
|
1390
|
+
(r'(\(.*?\))([a-zA-Z$_][a-zA-Z0-9$_]*)', bygroups(using(this),
|
1391
|
+
Name.Variable)),
|
1392
|
+
(r'[a-zA-Z$_][a-zA-Z0-9$_]*:', Name.Function),
|
1393
|
+
(';', Punctuation, '#pop'),
|
1394
|
+
('{', Punctuation, 'function'),
|
1395
|
+
('', Text, '#pop'),
|
1396
|
+
],
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
def analyse_text(text):
|
1400
|
+
if _oc_keywords.search(text):
|
1401
|
+
return 1.0
|
1402
|
+
elif '@"' in text: # strings
|
1403
|
+
return 0.8
|
1404
|
+
elif _oc_message.search(text):
|
1405
|
+
return 0.8
|
1406
|
+
return 0
|
1407
|
+
|
1408
|
+
return GeneratedObjectiveCVariant
|
1409
|
+
|
1410
|
+
|
1411
|
+
class ObjectiveCLexer(objective(CLexer)):
|
1412
|
+
"""
|
1413
|
+
For Objective-C source code with preprocessor directives.
|
1414
|
+
"""
|
1415
|
+
|
1416
|
+
name = 'Objective-C'
|
1417
|
+
aliases = ['objective-c', 'objectivec', 'obj-c', 'objc']
|
1418
|
+
filenames = ['*.m', '*.h']
|
1419
|
+
mimetypes = ['text/x-objective-c']
|
1420
|
+
priority = 0.05 # Lower than C
|
1421
|
+
|
1422
|
+
|
1423
|
+
class ObjectiveCppLexer(objective(CppLexer)):
|
1424
|
+
"""
|
1425
|
+
For Objective-C++ source code with preprocessor directives.
|
1426
|
+
"""
|
1427
|
+
|
1428
|
+
name = 'Objective-C++'
|
1429
|
+
aliases = ['objective-c++', 'objectivec++', 'obj-c++', 'objc++']
|
1430
|
+
filenames = ['*.mm', '*.hh']
|
1431
|
+
mimetypes = ['text/x-objective-c++']
|
1432
|
+
priority = 0.05 # Lower than C++
|
1253
1433
|
|
1254
1434
|
|
1255
1435
|
class FortranLexer(RegexLexer):
|
@@ -1282,16 +1462,16 @@ class FortranLexer(RegexLexer):
|
|
1282
1462
|
],
|
1283
1463
|
'core': [
|
1284
1464
|
# Statements
|
1285
|
-
(r'\b(ACCEPT|ALLOCATABLE|ALLOCATE|ARRAY|ASSIGN|ASYNCHRONOUS|'
|
1286
|
-
r'BACKSPACE|BIND|BLOCK DATA
|
1465
|
+
(r'\b(ABSTRACT|ACCEPT|ALLOCATABLE|ALLOCATE|ARRAY|ASSIGN|ASYNCHRONOUS|'
|
1466
|
+
r'BACKSPACE|BIND|BLOCK( DATA)?|BYTE|CALL|CASE|CLASS|CLOSE|COMMON|CONTAINS|'
|
1287
1467
|
r'CONTINUE|CYCLE|DATA|DEALLOCATE|DECODE|DEFERRED|DIMENSION|DO|'
|
1288
|
-
r'ELSE|ENCODE|END FILE
|
1468
|
+
r'ELEMENTAL|ELSE|ENCODE|END( FILE)?|ENDIF|ENTRY|ENUMERATOR|EQUIVALENCE|'
|
1289
1469
|
r'EXIT|EXTERNAL|EXTRINSIC|FINAL|FORALL|FORMAT|FUNCTION|GENERIC|'
|
1290
1470
|
r'GOTO|IF|IMPLICIT|IMPORT|INCLUDE|INQUIRE|INTENT|INTERFACE|'
|
1291
1471
|
r'INTRINSIC|MODULE|NAMELIST|NULLIFY|NONE|NON_INTRINSIC|'
|
1292
1472
|
r'NON_OVERRIDABLE|NOPASS|OPEN|OPTIONAL|OPTIONS|PARAMETER|PASS|'
|
1293
1473
|
r'PAUSE|POINTER|PRINT|PRIVATE|PROGRAM|PROTECTED|PUBLIC|PURE|READ|'
|
1294
|
-
r'RECURSIVE|RETURN|REWIND|SAVE|SELECT|SEQUENCE|STOP|SUBROUTINE|'
|
1474
|
+
r'RECURSIVE|RESULT|RETURN|REWIND|SAVE|SELECT|SEQUENCE|STOP|SUBROUTINE|'
|
1295
1475
|
r'TARGET|THEN|TYPE|USE|VALUE|VOLATILE|WHERE|WRITE|WHILE)\s*\b',
|
1296
1476
|
Keyword),
|
1297
1477
|
|
@@ -1428,7 +1608,15 @@ class PrologLexer(RegexLexer):
|
|
1428
1608
|
(r'^#.*', Comment.Single),
|
1429
1609
|
(r'/\*', Comment.Multiline, 'nested-comment'),
|
1430
1610
|
(r'%.*', Comment.Single),
|
1431
|
-
|
1611
|
+
# character literal
|
1612
|
+
(r'0\'.', String.Char),
|
1613
|
+
(r'0b[01]+', Number.Bin),
|
1614
|
+
(r'0o[0-7]+', Number.Oct),
|
1615
|
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
1616
|
+
# literal with prepended base
|
1617
|
+
(r'\d\d?\'[a-zA-Z0-9]+', Number.Integer),
|
1618
|
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
1619
|
+
(r'\d+', Number.Integer),
|
1432
1620
|
(r'[\[\](){}|.,;!]', Punctuation),
|
1433
1621
|
(r':-|-->', Punctuation),
|
1434
1622
|
(r'"(?:\\x[0-9a-fA-F]+\\|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|'
|
@@ -1436,7 +1624,8 @@ class PrologLexer(RegexLexer):
|
|
1436
1624
|
(r"'(?:''|[^'])*'", String.Atom), # quoted atom
|
1437
1625
|
# Needs to not be followed by an atom.
|
1438
1626
|
#(r'=(?=\s|[a-zA-Z\[])', Operator),
|
1439
|
-
(r'
|
1627
|
+
(r'is\b', Operator),
|
1628
|
+
(r'(<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])',
|
1440
1629
|
Operator),
|
1441
1630
|
(r'(mod|div|not)\b', Operator),
|
1442
1631
|
(r'_', Keyword), # The don't-care variable
|
@@ -1478,7 +1667,7 @@ class CythonLexer(RegexLexer):
|
|
1478
1667
|
"""
|
1479
1668
|
|
1480
1669
|
name = 'Cython'
|
1481
|
-
aliases = ['cython', 'pyx']
|
1670
|
+
aliases = ['cython', 'pyx', 'pyrex']
|
1482
1671
|
filenames = ['*.pyx', '*.pxd', '*.pxi']
|
1483
1672
|
mimetypes = ['text/x-cython', 'application/x-cython']
|
1484
1673
|
|
@@ -1807,19 +1996,32 @@ class GoLexer(RegexLexer):
|
|
1807
1996
|
(r'\\\n', Text), # line continuations
|
1808
1997
|
(r'//(.*?)\n', Comment.Single),
|
1809
1998
|
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
1810
|
-
(r'(
|
1811
|
-
|
1812
|
-
|
1813
|
-
r'|
|
1814
|
-
r'|continue|for|
|
1815
|
-
),
|
1816
|
-
# It seems the builtin types aren't actually keywords
|
1817
|
-
|
1818
|
-
|
1819
|
-
r'|
|
1820
|
-
r'|
|
1821
|
-
r'|
|
1822
|
-
|
1999
|
+
(r'(import|package)\b', Keyword.Namespace),
|
2000
|
+
(r'(var|func|struct|map|chan|type|interface|const)\b', Keyword.Declaration),
|
2001
|
+
(r'(break|default|select|case|defer|go'
|
2002
|
+
r'|else|goto|switch|fallthrough|if|range'
|
2003
|
+
r'|continue|for|return)\b', Keyword),
|
2004
|
+
(r'(true|false|iota|nil)\b', Keyword.Constant),
|
2005
|
+
# It seems the builtin types aren't actually keywords, but
|
2006
|
+
# can be used as functions. So we need two declarations.
|
2007
|
+
(r'(uint|uint8|uint16|uint32|uint64'
|
2008
|
+
r'|int|int8|int16|int32|int64'
|
2009
|
+
r'|float|float32|float64'
|
2010
|
+
r'|complex64|complex128|byte|rune'
|
2011
|
+
r'|string|bool|error|uintptr'
|
2012
|
+
r'|print|println|panic|recover|close|complex|real|imag'
|
2013
|
+
r'|len|cap|append|copy|delete|new|make)\b(\()',
|
2014
|
+
bygroups(Name.Builtin, Punctuation)),
|
2015
|
+
(r'(uint|uint8|uint16|uint32|uint64'
|
2016
|
+
r'|int|int8|int16|int32|int64'
|
2017
|
+
r'|float|float32|float64'
|
2018
|
+
r'|complex64|complex128|byte|rune'
|
2019
|
+
r'|string|bool|error|uintptr)\b', Keyword.Type),
|
2020
|
+
# imaginary_lit
|
2021
|
+
(r'\d+i', Number),
|
2022
|
+
(r'\d+\.\d*([Ee][-+]\d+)?i', Number),
|
2023
|
+
(r'\.\d+([Ee][-+]\d+)?i', Number),
|
2024
|
+
(r'\d+[Ee][-+]\d+i', Number),
|
1823
2025
|
# float_lit
|
1824
2026
|
(r'\d+(\.\d+[eE][+\-]?\d+|'
|
1825
2027
|
r'\.\d*|[eE][+\-]?\d+)', Number.Float),
|
@@ -1843,11 +2045,10 @@ class GoLexer(RegexLexer):
|
|
1843
2045
|
(r'"(\\\\|\\"|[^"])*"', String),
|
1844
2046
|
# Tokens
|
1845
2047
|
(r'(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\|'
|
1846
|
-
r'
|
1847
|
-
|
1848
|
-
),
|
2048
|
+
r'|<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])', Operator),
|
2049
|
+
(r'[|^<>=!()\[\]{}.,;:]', Punctuation),
|
1849
2050
|
# identifier
|
1850
|
-
(r'[a-zA-Z_]\w*', Name),
|
2051
|
+
(r'[a-zA-Z_]\w*', Name.Other),
|
1851
2052
|
]
|
1852
2053
|
}
|
1853
2054
|
|
@@ -2120,8 +2321,6 @@ class AdaLexer(RegexLexer):
|
|
2120
2321
|
|
2121
2322
|
flags = re.MULTILINE | re.I # Ignore case
|
2122
2323
|
|
2123
|
-
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
|
2124
|
-
|
2125
2324
|
tokens = {
|
2126
2325
|
'root': [
|
2127
2326
|
(r'[^\S\n]+', Text),
|
@@ -2136,10 +2335,12 @@ class AdaLexer(RegexLexer):
|
|
2136
2335
|
(r'(pragma)(\s+)([a-zA-Z0-9_]+)', bygroups(Keyword.Reserved, Text,
|
2137
2336
|
Comment.Preproc)),
|
2138
2337
|
(r'(true|false|null)\b', Keyword.Constant),
|
2139
|
-
(r'(Byte|Character|
|
2140
|
-
r'
|
2141
|
-
r'
|
2142
|
-
r'
|
2338
|
+
(r'(Address|Byte|Boolean|Character|Controlled|Count|Cursor|'
|
2339
|
+
r'Duration|File_Mode|File_Type|Float|Generator|Integer|Long_Float|'
|
2340
|
+
r'Long_Integer|Long_Long_Float|Long_Long_Integer|Natural|Positive|'
|
2341
|
+
r'Reference_Type|Short_Float|Short_Integer|Short_Short_Float|'
|
2342
|
+
r'Short_Short_Integer|String|Wide_Character|Wide_String)\b',
|
2343
|
+
Keyword.Type),
|
2143
2344
|
(r'(and(\s+then)?|in|mod|not|or(\s+else)|rem)\b', Operator.Word),
|
2144
2345
|
(r'generic|private', Keyword.Declaration),
|
2145
2346
|
(r'package', Keyword.Declaration, 'package'),
|
@@ -2194,7 +2395,8 @@ class AdaLexer(RegexLexer):
|
|
2194
2395
|
(r'\(', Punctuation, 'formal_part'),
|
2195
2396
|
(r'with|and|use', Keyword.Reserved),
|
2196
2397
|
(r'array\b', Keyword.Reserved, ('#pop', 'array_def')),
|
2197
|
-
(r'record\b', Keyword.Reserved, ('
|
2398
|
+
(r'record\b', Keyword.Reserved, ('record_def')),
|
2399
|
+
(r'(null record)(;)', bygroups(Keyword.Reserved, Punctuation), '#pop'),
|
2198
2400
|
include('root'),
|
2199
2401
|
],
|
2200
2402
|
'array_def' : [
|
@@ -2203,6 +2405,10 @@ class AdaLexer(RegexLexer):
|
|
2203
2405
|
Keyword.Reserved)),
|
2204
2406
|
include('root'),
|
2205
2407
|
],
|
2408
|
+
'record_def' : [
|
2409
|
+
(r'end record', Keyword.Reserved, '#pop'),
|
2410
|
+
include('root'),
|
2411
|
+
],
|
2206
2412
|
'import': [
|
2207
2413
|
(r'[a-z0-9_.]+', Name.Namespace, '#pop'),
|
2208
2414
|
(r'', Text, '#pop'),
|
@@ -2442,7 +2648,9 @@ class BlitzMaxLexer(RegexLexer):
|
|
2442
2648
|
bmax_sktypes = r'@{1,2}|[!#$%]'
|
2443
2649
|
bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b'
|
2444
2650
|
bmax_name = r'[a-z_][a-z0-9_]*'
|
2445
|
-
bmax_var = r'(%s)(?:(?:([ \t]*)(%s)|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)
|
2651
|
+
bmax_var = (r'(%s)(?:(?:([ \t]*)(%s)|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)'
|
2652
|
+
r'|([ \t]*)([:])([ \t]*)(?:%s|(%s)))(?:([ \t]*)(Ptr))?)') % \
|
2653
|
+
(bmax_name, bmax_sktypes, bmax_lktypes, bmax_name)
|
2446
2654
|
bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])'
|
2447
2655
|
|
2448
2656
|
flags = re.MULTILINE | re.IGNORECASE
|
@@ -2518,6 +2726,88 @@ class BlitzMaxLexer(RegexLexer):
|
|
2518
2726
|
}
|
2519
2727
|
|
2520
2728
|
|
2729
|
+
class BlitzBasicLexer(RegexLexer):
|
2730
|
+
"""
|
2731
|
+
For `BlitzBasic <http://blitzbasic.com>`_ source code.
|
2732
|
+
|
2733
|
+
*New in Pygments 1.7.*
|
2734
|
+
"""
|
2735
|
+
|
2736
|
+
name = 'BlitzBasic'
|
2737
|
+
aliases = ['blitzbasic', 'b3d', 'bplus']
|
2738
|
+
filenames = ['*.bb', '*.decls']
|
2739
|
+
mimetypes = ['text/x-bb']
|
2740
|
+
|
2741
|
+
bb_vopwords = (r'\b(Shl|Shr|Sar|Mod|Or|And|Not|'
|
2742
|
+
r'Abs|Sgn|Handle|Int|Float|Str|'
|
2743
|
+
r'First|Last|Before|After)\b')
|
2744
|
+
bb_sktypes = r'@{1,2}|[#$%]'
|
2745
|
+
bb_name = r'[a-z][a-z0-9_]*'
|
2746
|
+
bb_var = (r'(%s)(?:([ \t]*)(%s)|([ \t]*)([.])([ \t]*)(?:(%s)))?') % \
|
2747
|
+
(bb_name, bb_sktypes, bb_name)
|
2748
|
+
|
2749
|
+
flags = re.MULTILINE | re.IGNORECASE
|
2750
|
+
tokens = {
|
2751
|
+
'root': [
|
2752
|
+
# Text
|
2753
|
+
(r'[ \t]+', Text),
|
2754
|
+
# Comments
|
2755
|
+
(r";.*?\n", Comment.Single),
|
2756
|
+
# Data types
|
2757
|
+
('"', String.Double, 'string'),
|
2758
|
+
# Numbers
|
2759
|
+
(r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
|
2760
|
+
(r'\.[0-9]+(?!\.)', Number.Float),
|
2761
|
+
(r'[0-9]+', Number.Integer),
|
2762
|
+
(r'\$[0-9a-f]+', Number.Hex),
|
2763
|
+
(r'\%[10]+', Number), # Binary
|
2764
|
+
# Other
|
2765
|
+
(r'(?:%s|([+\-*/~=<>^]))' % (bb_vopwords), Operator),
|
2766
|
+
(r'[(),:\[\]\\]', Punctuation),
|
2767
|
+
(r'\.([ \t]*)(%s)' % bb_name, Name.Label),
|
2768
|
+
# Identifiers
|
2769
|
+
(r'\b(New)\b([ \t]+)(%s)' % (bb_name),
|
2770
|
+
bygroups(Keyword.Reserved, Text, Name.Class)),
|
2771
|
+
(r'\b(Gosub|Goto)\b([ \t]+)(%s)' % (bb_name),
|
2772
|
+
bygroups(Keyword.Reserved, Text, Name.Label)),
|
2773
|
+
(r'\b(Object)\b([ \t]*)([.])([ \t]*)(%s)\b' % (bb_name),
|
2774
|
+
bygroups(Operator, Text, Punctuation, Text, Name.Class)),
|
2775
|
+
(r'\b%s\b([ \t]*)(\()' % bb_var,
|
2776
|
+
bygroups(Name.Function, Text, Keyword.Type,Text, Punctuation,
|
2777
|
+
Text, Name.Class, Text, Punctuation)),
|
2778
|
+
(r'\b(Function)\b([ \t]+)%s' % bb_var,
|
2779
|
+
bygroups(Keyword.Reserved, Text, Name.Function, Text, Keyword.Type,
|
2780
|
+
Text, Punctuation, Text, Name.Class)),
|
2781
|
+
(r'\b(Type)([ \t]+)(%s)' % (bb_name),
|
2782
|
+
bygroups(Keyword.Reserved, Text, Name.Class)),
|
2783
|
+
# Keywords
|
2784
|
+
(r'\b(Pi|True|False|Null)\b', Keyword.Constant),
|
2785
|
+
(r'\b(Local|Global|Const|Field|Dim)\b', Keyword.Declaration),
|
2786
|
+
(r'\b(End|Return|Exit|'
|
2787
|
+
r'Chr|Len|Asc|'
|
2788
|
+
r'New|Delete|Insert|'
|
2789
|
+
r'Include|'
|
2790
|
+
r'Function|'
|
2791
|
+
r'Type|'
|
2792
|
+
r'If|Then|Else|ElseIf|EndIf|'
|
2793
|
+
r'For|To|Next|Step|Each|'
|
2794
|
+
r'While|Wend|'
|
2795
|
+
r'Repeat|Until|Forever|'
|
2796
|
+
r'Select|Case|Default|'
|
2797
|
+
r'Goto|Gosub|Data|Read|Restore)\b', Keyword.Reserved),
|
2798
|
+
# Final resolve (for variable names and such)
|
2799
|
+
# (r'(%s)' % (bb_name), Name.Variable),
|
2800
|
+
(bb_var, bygroups(Name.Variable, Text, Keyword.Type,
|
2801
|
+
Text, Punctuation, Text, Name.Class)),
|
2802
|
+
],
|
2803
|
+
'string': [
|
2804
|
+
(r'""', String.Double),
|
2805
|
+
(r'"C?', String.Double, '#pop'),
|
2806
|
+
(r'[^"]+', String.Double),
|
2807
|
+
],
|
2808
|
+
}
|
2809
|
+
|
2810
|
+
|
2521
2811
|
class NimrodLexer(RegexLexer):
|
2522
2812
|
"""
|
2523
2813
|
For `Nimrod <http://nimrod-code.org/>`_ source code.
|
@@ -2889,3 +3179,545 @@ class FantomLexer(RegexLexer):
|
|
2889
3179
|
(r'.', Text)
|
2890
3180
|
],
|
2891
3181
|
}
|
3182
|
+
|
3183
|
+
|
3184
|
+
class RustLexer(RegexLexer):
|
3185
|
+
"""
|
3186
|
+
Lexer for Mozilla's Rust programming language.
|
3187
|
+
|
3188
|
+
*New in Pygments 1.6.*
|
3189
|
+
"""
|
3190
|
+
name = 'Rust'
|
3191
|
+
filenames = ['*.rs', '*.rc']
|
3192
|
+
aliases = ['rust']
|
3193
|
+
mimetypes = ['text/x-rustsrc']
|
3194
|
+
|
3195
|
+
tokens = {
|
3196
|
+
'root': [
|
3197
|
+
# Whitespace and Comments
|
3198
|
+
(r'\n', Text),
|
3199
|
+
(r'\s+', Text),
|
3200
|
+
(r'//(.*?)\n', Comment.Single),
|
3201
|
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
3202
|
+
|
3203
|
+
# Keywords
|
3204
|
+
(r'(as|assert|break|const'
|
3205
|
+
r'|copy|do|else|enum|extern|fail'
|
3206
|
+
r'|false|fn|for|if|impl|let|log'
|
3207
|
+
r'|loop|match|mod|move|mut|once|priv|pub|pure'
|
3208
|
+
r'|ref|return|static|struct|trait|true|type|unsafe|use|while'
|
3209
|
+
r'|u8|u16|u32|u64|i8|i16|i32|i64|uint'
|
3210
|
+
r'|int|float|f32|f64|str)\b', Keyword),
|
3211
|
+
|
3212
|
+
# Character Literal
|
3213
|
+
(r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
|
3214
|
+
r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
|
3215
|
+
String.Char),
|
3216
|
+
# Binary Literal
|
3217
|
+
(r'0[Bb][01_]+', Number, 'number_lit'),
|
3218
|
+
# Octal Literal
|
3219
|
+
(r'0[0-7_]+', Number.Oct, 'number_lit'),
|
3220
|
+
# Hexadecimal Literal
|
3221
|
+
(r'0[xX][0-9a-fA-F_]+', Number.Hex, 'number_lit'),
|
3222
|
+
# Decimal Literal
|
3223
|
+
(r'[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?'
|
3224
|
+
r'[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)?', Number, 'number_lit'),
|
3225
|
+
# String Literal
|
3226
|
+
(r'"', String, 'string'),
|
3227
|
+
|
3228
|
+
# Operators and Punctuation
|
3229
|
+
(r'[{}()\[\],.;]', Punctuation),
|
3230
|
+
(r'[+\-*/%&|<>^!~@=:?]', Operator),
|
3231
|
+
|
3232
|
+
# Identifier
|
3233
|
+
(r'[a-zA-Z_$][a-zA-Z0-9_]*', Name),
|
3234
|
+
|
3235
|
+
# Attributes
|
3236
|
+
(r'#\[', Comment.Preproc, 'attribute['),
|
3237
|
+
(r'#\(', Comment.Preproc, 'attribute('),
|
3238
|
+
# Macros
|
3239
|
+
(r'[A-Za-z_][A-Za-z0-9_]*!\[', Comment.Preproc, 'attribute['),
|
3240
|
+
(r'[A-Za-z_][A-Za-z0-9_]*!\(', Comment.Preproc, 'attribute('),
|
3241
|
+
],
|
3242
|
+
'number_lit': [
|
3243
|
+
(r'(([ui](8|16|32|64)?)|(f(32|64)?))?', Keyword, '#pop'),
|
3244
|
+
],
|
3245
|
+
'string': [
|
3246
|
+
(r'"', String, '#pop'),
|
3247
|
+
(r"""\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
|
3248
|
+
r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}""", String.Escape),
|
3249
|
+
(r'[^\\"]+', String),
|
3250
|
+
(r'\\', String),
|
3251
|
+
],
|
3252
|
+
'attribute_common': [
|
3253
|
+
(r'"', String, 'string'),
|
3254
|
+
(r'\[', Comment.Preproc, 'attribute['),
|
3255
|
+
(r'\(', Comment.Preproc, 'attribute('),
|
3256
|
+
],
|
3257
|
+
'attribute[': [
|
3258
|
+
include('attribute_common'),
|
3259
|
+
(r'\];?', Comment.Preproc, '#pop'),
|
3260
|
+
(r'[^"\]]+', Comment.Preproc),
|
3261
|
+
],
|
3262
|
+
'attribute(': [
|
3263
|
+
include('attribute_common'),
|
3264
|
+
(r'\);?', Comment.Preproc, '#pop'),
|
3265
|
+
(r'[^"\)]+', Comment.Preproc),
|
3266
|
+
],
|
3267
|
+
}
|
3268
|
+
|
3269
|
+
|
3270
|
+
class CudaLexer(CLexer):
|
3271
|
+
"""
|
3272
|
+
For NVIDIA `CUDA™ <http://developer.nvidia.com/category/zone/cuda-zone>`_
|
3273
|
+
source.
|
3274
|
+
|
3275
|
+
*New in Pygments 1.6.*
|
3276
|
+
"""
|
3277
|
+
name = 'CUDA'
|
3278
|
+
filenames = ['*.cu', '*.cuh']
|
3279
|
+
aliases = ['cuda', 'cu']
|
3280
|
+
mimetypes = ['text/x-cuda']
|
3281
|
+
|
3282
|
+
function_qualifiers = ['__device__', '__global__', '__host__',
|
3283
|
+
'__noinline__', '__forceinline__']
|
3284
|
+
variable_qualifiers = ['__device__', '__constant__', '__shared__',
|
3285
|
+
'__restrict__']
|
3286
|
+
vector_types = ['char1', 'uchar1', 'char2', 'uchar2', 'char3', 'uchar3',
|
3287
|
+
'char4', 'uchar4', 'short1', 'ushort1', 'short2', 'ushort2',
|
3288
|
+
'short3', 'ushort3', 'short4', 'ushort4', 'int1', 'uint1',
|
3289
|
+
'int2', 'uint2', 'int3', 'uint3', 'int4', 'uint4', 'long1',
|
3290
|
+
'ulong1', 'long2', 'ulong2', 'long3', 'ulong3', 'long4',
|
3291
|
+
'ulong4', 'longlong1', 'ulonglong1', 'longlong2',
|
3292
|
+
'ulonglong2', 'float1', 'float2', 'float3', 'float4',
|
3293
|
+
'double1', 'double2', 'dim3']
|
3294
|
+
variables = ['gridDim', 'blockIdx', 'blockDim', 'threadIdx', 'warpSize']
|
3295
|
+
functions = ['__threadfence_block', '__threadfence', '__threadfence_system',
|
3296
|
+
'__syncthreads', '__syncthreads_count', '__syncthreads_and',
|
3297
|
+
'__syncthreads_or']
|
3298
|
+
execution_confs = ['<<<', '>>>']
|
3299
|
+
|
3300
|
+
def get_tokens_unprocessed(self, text):
|
3301
|
+
for index, token, value in \
|
3302
|
+
CLexer.get_tokens_unprocessed(self, text):
|
3303
|
+
if token is Name:
|
3304
|
+
if value in self.variable_qualifiers:
|
3305
|
+
token = Keyword.Type
|
3306
|
+
elif value in self.vector_types:
|
3307
|
+
token = Keyword.Type
|
3308
|
+
elif value in self.variables:
|
3309
|
+
token = Name.Builtin
|
3310
|
+
elif value in self.execution_confs:
|
3311
|
+
token = Keyword.Pseudo
|
3312
|
+
elif value in self.function_qualifiers:
|
3313
|
+
token = Keyword.Reserved
|
3314
|
+
elif value in self.functions:
|
3315
|
+
token = Name.Function
|
3316
|
+
yield index, token, value
|
3317
|
+
|
3318
|
+
|
3319
|
+
class MonkeyLexer(RegexLexer):
|
3320
|
+
"""
|
3321
|
+
For
|
3322
|
+
`Monkey <https://en.wikipedia.org/wiki/Monkey_(programming_language)>`_
|
3323
|
+
source code.
|
3324
|
+
|
3325
|
+
*New in Pygments 1.6.*
|
3326
|
+
"""
|
3327
|
+
|
3328
|
+
name = 'Monkey'
|
3329
|
+
aliases = ['monkey']
|
3330
|
+
filenames = ['*.monkey']
|
3331
|
+
mimetypes = ['text/x-monkey']
|
3332
|
+
|
3333
|
+
name_variable = r'[a-z_][a-zA-Z0-9_]*'
|
3334
|
+
name_function = r'[A-Z][a-zA-Z0-9_]*'
|
3335
|
+
name_constant = r'[A-Z_][A-Z0-9_]*'
|
3336
|
+
name_class = r'[A-Z][a-zA-Z0-9_]*'
|
3337
|
+
name_module = r'[a-z0-9_]*'
|
3338
|
+
|
3339
|
+
keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)'
|
3340
|
+
# ? == Bool // % == Int // # == Float // $ == String
|
3341
|
+
keyword_type_special = r'[?%#$]'
|
3342
|
+
|
3343
|
+
flags = re.MULTILINE
|
3344
|
+
|
3345
|
+
tokens = {
|
3346
|
+
'root': [
|
3347
|
+
#Text
|
3348
|
+
(r'\s+', Text),
|
3349
|
+
# Comments
|
3350
|
+
(r"'.*", Comment),
|
3351
|
+
(r'(?i)^#rem\b', Comment.Multiline, 'comment'),
|
3352
|
+
# preprocessor directives
|
3353
|
+
(r'(?i)^(?:#If|#ElseIf|#Else|#EndIf|#End|#Print|#Error)\b', Comment.Preproc),
|
3354
|
+
# preprocessor variable (any line starting with '#' that is not a directive)
|
3355
|
+
(r'^#', Comment.Preproc, 'variables'),
|
3356
|
+
# String
|
3357
|
+
('"', String.Double, 'string'),
|
3358
|
+
# Numbers
|
3359
|
+
(r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
|
3360
|
+
(r'\.[0-9]+(?!\.)', Number.Float),
|
3361
|
+
(r'[0-9]+', Number.Integer),
|
3362
|
+
(r'\$[0-9a-fA-Z]+', Number.Hex),
|
3363
|
+
(r'\%[10]+', Number), # Binary
|
3364
|
+
# Native data types
|
3365
|
+
(r'\b%s\b' % keyword_type, Keyword.Type),
|
3366
|
+
# Exception handling
|
3367
|
+
(r'(?i)\b(?:Try|Catch|Throw)\b', Keyword.Reserved),
|
3368
|
+
(r'Throwable', Name.Exception),
|
3369
|
+
# Builtins
|
3370
|
+
(r'(?i)\b(?:Null|True|False)\b', Name.Builtin),
|
3371
|
+
(r'(?i)\b(?:Self|Super)\b', Name.Builtin.Pseudo),
|
3372
|
+
(r'\b(?:HOST|LANG|TARGET|CONFIG)\b', Name.Constant),
|
3373
|
+
# Keywords
|
3374
|
+
(r'(?i)^(Import)(\s+)(.*)(\n)',
|
3375
|
+
bygroups(Keyword.Namespace, Text, Name.Namespace, Text)),
|
3376
|
+
(r'(?i)^Strict\b.*\n', Keyword.Reserved),
|
3377
|
+
(r'(?i)(Const|Local|Global|Field)(\s+)',
|
3378
|
+
bygroups(Keyword.Declaration, Text), 'variables'),
|
3379
|
+
(r'(?i)(New|Class|Interface|Extends|Implements)(\s+)',
|
3380
|
+
bygroups(Keyword.Reserved, Text), 'classname'),
|
3381
|
+
(r'(?i)(Function|Method)(\s+)',
|
3382
|
+
bygroups(Keyword.Reserved, Text), 'funcname'),
|
3383
|
+
(r'(?i)(?:End|Return|Public|Private|Extern|Property|'
|
3384
|
+
r'Final|Abstract)\b', Keyword.Reserved),
|
3385
|
+
# Flow Control stuff
|
3386
|
+
(r'(?i)(?:If|Then|Else|ElseIf|EndIf|'
|
3387
|
+
r'Select|Case|Default|'
|
3388
|
+
r'While|Wend|'
|
3389
|
+
r'Repeat|Until|Forever|'
|
3390
|
+
r'For|To|Until|Step|EachIn|Next|'
|
3391
|
+
r'Exit|Continue)\s+', Keyword.Reserved),
|
3392
|
+
# not used yet
|
3393
|
+
(r'(?i)\b(?:Module|Inline)\b', Keyword.Reserved),
|
3394
|
+
# Array
|
3395
|
+
(r'[\[\]]', Punctuation),
|
3396
|
+
# Other
|
3397
|
+
(r'<=|>=|<>|\*=|/=|\+=|-=|&=|~=|\|=|[-&*/^+=<>|~]', Operator),
|
3398
|
+
(r'(?i)(?:Not|Mod|Shl|Shr|And|Or)', Operator.Word),
|
3399
|
+
(r'[\(\){}!#,.:]', Punctuation),
|
3400
|
+
# catch the rest
|
3401
|
+
(r'%s\b' % name_constant, Name.Constant),
|
3402
|
+
(r'%s\b' % name_function, Name.Function),
|
3403
|
+
(r'%s\b' % name_variable, Name.Variable),
|
3404
|
+
],
|
3405
|
+
'funcname': [
|
3406
|
+
(r'(?i)%s\b' % name_function, Name.Function),
|
3407
|
+
(r':', Punctuation, 'classname'),
|
3408
|
+
(r'\s+', Text),
|
3409
|
+
(r'\(', Punctuation, 'variables'),
|
3410
|
+
(r'\)', Punctuation, '#pop')
|
3411
|
+
],
|
3412
|
+
'classname': [
|
3413
|
+
(r'%s\.' % name_module, Name.Namespace),
|
3414
|
+
(r'%s\b' % keyword_type, Keyword.Type),
|
3415
|
+
(r'%s\b' % name_class, Name.Class),
|
3416
|
+
# array (of given size)
|
3417
|
+
(r'(\[)(\s*)(\d*)(\s*)(\])',
|
3418
|
+
bygroups(Punctuation, Text, Number.Integer, Text, Punctuation)),
|
3419
|
+
# generics
|
3420
|
+
(r'\s+(?!<)', Text, '#pop'),
|
3421
|
+
(r'<', Punctuation, '#push'),
|
3422
|
+
(r'>', Punctuation, '#pop'),
|
3423
|
+
(r'\n', Text, '#pop'),
|
3424
|
+
(r'', Text, '#pop')
|
3425
|
+
],
|
3426
|
+
'variables': [
|
3427
|
+
(r'%s\b' % name_constant, Name.Constant),
|
3428
|
+
(r'%s\b' % name_variable, Name.Variable),
|
3429
|
+
(r'%s' % keyword_type_special, Keyword.Type),
|
3430
|
+
(r'\s+', Text),
|
3431
|
+
(r':', Punctuation, 'classname'),
|
3432
|
+
(r',', Punctuation, '#push'),
|
3433
|
+
(r'', Text, '#pop')
|
3434
|
+
],
|
3435
|
+
'string': [
|
3436
|
+
(r'[^"~]+', String.Double),
|
3437
|
+
(r'~q|~n|~r|~t|~z|~~', String.Escape),
|
3438
|
+
(r'"', String.Double, '#pop'),
|
3439
|
+
],
|
3440
|
+
'comment' : [
|
3441
|
+
(r'(?i)^#rem.*?', Comment.Multiline, "#push"),
|
3442
|
+
(r'(?i)^#end.*?', Comment.Multiline, "#pop"),
|
3443
|
+
(r'\n', Comment.Multiline),
|
3444
|
+
(r'.+', Comment.Multiline),
|
3445
|
+
],
|
3446
|
+
}
|
3447
|
+
|
3448
|
+
|
3449
|
+
class CobolLexer(RegexLexer):
|
3450
|
+
"""
|
3451
|
+
Lexer for OpenCOBOL code.
|
3452
|
+
|
3453
|
+
*New in Pygments 1.6.*
|
3454
|
+
"""
|
3455
|
+
name = 'COBOL'
|
3456
|
+
aliases = ['cobol']
|
3457
|
+
filenames = ['*.cob', '*.COB', '*.cpy', '*.CPY']
|
3458
|
+
mimetypes = ['text/x-cobol']
|
3459
|
+
flags = re.IGNORECASE | re.MULTILINE
|
3460
|
+
|
3461
|
+
# Data Types: by PICTURE and USAGE
|
3462
|
+
# Operators: **, *, +, -, /, <, >, <=, >=, =, <>
|
3463
|
+
# Logical (?): NOT, AND, OR
|
3464
|
+
|
3465
|
+
# Reserved words:
|
3466
|
+
# http://opencobol.add1tocobol.com/#reserved-words
|
3467
|
+
# Intrinsics:
|
3468
|
+
# http://opencobol.add1tocobol.com/#does-opencobol-implement-any-intrinsic-functions
|
3469
|
+
|
3470
|
+
tokens = {
|
3471
|
+
'root': [
|
3472
|
+
include('comment'),
|
3473
|
+
include('strings'),
|
3474
|
+
include('core'),
|
3475
|
+
include('nums'),
|
3476
|
+
(r'[a-z0-9]([_a-z0-9\-]*[a-z0-9]+)?', Name.Variable),
|
3477
|
+
# (r'[\s]+', Text),
|
3478
|
+
(r'[ \t]+', Text),
|
3479
|
+
],
|
3480
|
+
'comment': [
|
3481
|
+
(r'(^.{6}[*/].*\n|^.{6}|\*>.*\n)', Comment),
|
3482
|
+
],
|
3483
|
+
'core': [
|
3484
|
+
# Figurative constants
|
3485
|
+
(r'(^|(?<=[^0-9a-z_\-]))(ALL\s+)?'
|
3486
|
+
r'((ZEROES)|(HIGH-VALUE|LOW-VALUE|QUOTE|SPACE|ZERO)(S)?)'
|
3487
|
+
r'\s*($|(?=[^0-9a-z_\-]))',
|
3488
|
+
Name.Constant),
|
3489
|
+
|
3490
|
+
# Reserved words STATEMENTS and other bolds
|
3491
|
+
(r'(^|(?<=[^0-9a-z_\-]))'
|
3492
|
+
r'(ACCEPT|ADD|ALLOCATE|CALL|CANCEL|CLOSE|COMPUTE|'
|
3493
|
+
r'CONFIGURATION|CONTINUE|'
|
3494
|
+
r'DATA|DELETE|DISPLAY|DIVIDE|DIVISION|ELSE|END|END-ACCEPT|'
|
3495
|
+
r'END-ADD|END-CALL|END-COMPUTE|END-DELETE|END-DISPLAY|'
|
3496
|
+
r'END-DIVIDE|END-EVALUATE|END-IF|END-MULTIPLY|END-OF-PAGE|'
|
3497
|
+
r'END-PERFORM|END-READ|END-RETURN|END-REWRITE|END-SEARCH|'
|
3498
|
+
r'END-START|END-STRING|END-SUBTRACT|END-UNSTRING|END-WRITE|'
|
3499
|
+
r'ENVIRONMENT|EVALUATE|EXIT|FD|FILE|FILE-CONTROL|FOREVER|'
|
3500
|
+
r'FREE|GENERATE|GO|GOBACK|'
|
3501
|
+
r'IDENTIFICATION|IF|INITIALIZE|'
|
3502
|
+
r'INITIATE|INPUT-OUTPUT|INSPECT|INVOKE|I-O-CONTROL|LINKAGE|'
|
3503
|
+
r'LOCAL-STORAGE|MERGE|MOVE|MULTIPLY|OPEN|'
|
3504
|
+
r'PERFORM|PROCEDURE|PROGRAM-ID|RAISE|READ|RELEASE|RESUME|'
|
3505
|
+
r'RETURN|REWRITE|SCREEN|'
|
3506
|
+
r'SD|SEARCH|SECTION|SET|SORT|START|STOP|STRING|SUBTRACT|'
|
3507
|
+
r'SUPPRESS|TERMINATE|THEN|UNLOCK|UNSTRING|USE|VALIDATE|'
|
3508
|
+
r'WORKING-STORAGE|WRITE)'
|
3509
|
+
r'\s*($|(?=[^0-9a-z_\-]))', Keyword.Reserved),
|
3510
|
+
|
3511
|
+
# Reserved words
|
3512
|
+
(r'(^|(?<=[^0-9a-z_\-]))'
|
3513
|
+
r'(ACCESS|ADDRESS|ADVANCING|AFTER|ALL|'
|
3514
|
+
r'ALPHABET|ALPHABETIC|ALPHABETIC-LOWER|ALPHABETIC-UPPER|'
|
3515
|
+
r'ALPHANUMERIC|ALPHANUMERIC-EDITED|ALSO|ALTER|ALTERNATE'
|
3516
|
+
r'ANY|ARE|AREA|AREAS|ARGUMENT-NUMBER|ARGUMENT-VALUE|AS|'
|
3517
|
+
r'ASCENDING|ASSIGN|AT|AUTO|AUTO-SKIP|AUTOMATIC|AUTOTERMINATE|'
|
3518
|
+
r'BACKGROUND-COLOR|BASED|BEEP|BEFORE|BELL|'
|
3519
|
+
r'BLANK|'
|
3520
|
+
r'BLINK|BLOCK|BOTTOM|BY|BYTE-LENGTH|CHAINING|'
|
3521
|
+
r'CHARACTER|CHARACTERS|CLASS|CODE|CODE-SET|COL|COLLATING|'
|
3522
|
+
r'COLS|COLUMN|COLUMNS|COMMA|COMMAND-LINE|COMMIT|COMMON|'
|
3523
|
+
r'CONSTANT|CONTAINS|CONTENT|CONTROL|'
|
3524
|
+
r'CONTROLS|CONVERTING|COPY|CORR|CORRESPONDING|COUNT|CRT|'
|
3525
|
+
r'CURRENCY|CURSOR|CYCLE|DATE|DAY|DAY-OF-WEEK|DE|DEBUGGING|'
|
3526
|
+
r'DECIMAL-POINT|DECLARATIVES|DEFAULT|DELIMITED|'
|
3527
|
+
r'DELIMITER|DEPENDING|DESCENDING|DETAIL|DISK|'
|
3528
|
+
r'DOWN|DUPLICATES|DYNAMIC|EBCDIC|'
|
3529
|
+
r'ENTRY|ENVIRONMENT-NAME|ENVIRONMENT-VALUE|EOL|EOP|'
|
3530
|
+
r'EOS|ERASE|ERROR|ESCAPE|EXCEPTION|'
|
3531
|
+
r'EXCLUSIVE|EXTEND|EXTERNAL|'
|
3532
|
+
r'FILE-ID|FILLER|FINAL|FIRST|FIXED|FLOAT-LONG|FLOAT-SHORT|'
|
3533
|
+
r'FOOTING|FOR|FOREGROUND-COLOR|FORMAT|FROM|FULL|FUNCTION|'
|
3534
|
+
r'FUNCTION-ID|GIVING|GLOBAL|GROUP|'
|
3535
|
+
r'HEADING|HIGHLIGHT|I-O|ID|'
|
3536
|
+
r'IGNORE|IGNORING|IN|INDEX|INDEXED|INDICATE|'
|
3537
|
+
r'INITIAL|INITIALIZED|INPUT|'
|
3538
|
+
r'INTO|INTRINSIC|INVALID|IS|JUST|JUSTIFIED|KEY|LABEL|'
|
3539
|
+
r'LAST|LEADING|LEFT|LENGTH|LIMIT|LIMITS|LINAGE|'
|
3540
|
+
r'LINAGE-COUNTER|LINE|LINES|LOCALE|LOCK|'
|
3541
|
+
r'LOWLIGHT|MANUAL|MEMORY|MINUS|MODE|'
|
3542
|
+
r'MULTIPLE|NATIONAL|NATIONAL-EDITED|NATIVE|'
|
3543
|
+
r'NEGATIVE|NEXT|NO|NULL|NULLS|NUMBER|NUMBERS|NUMERIC|'
|
3544
|
+
r'NUMERIC-EDITED|OBJECT-COMPUTER|OCCURS|OF|OFF|OMITTED|ON|ONLY|'
|
3545
|
+
r'OPTIONAL|ORDER|ORGANIZATION|OTHER|OUTPUT|OVERFLOW|'
|
3546
|
+
r'OVERLINE|PACKED-DECIMAL|PADDING|PAGE|PARAGRAPH|'
|
3547
|
+
r'PLUS|POINTER|POSITION|POSITIVE|PRESENT|PREVIOUS|'
|
3548
|
+
r'PRINTER|PRINTING|PROCEDURE-POINTER|PROCEDURES|'
|
3549
|
+
r'PROCEED|PROGRAM|PROGRAM-POINTER|PROMPT|QUOTE|'
|
3550
|
+
r'QUOTES|RANDOM|RD|RECORD|RECORDING|RECORDS|RECURSIVE|'
|
3551
|
+
r'REDEFINES|REEL|REFERENCE|RELATIVE|REMAINDER|REMOVAL|'
|
3552
|
+
r'RENAMES|REPLACING|REPORT|REPORTING|REPORTS|REPOSITORY|'
|
3553
|
+
r'REQUIRED|RESERVE|RETURNING|REVERSE-VIDEO|REWIND|'
|
3554
|
+
r'RIGHT|ROLLBACK|ROUNDED|RUN|SAME|SCROLL|'
|
3555
|
+
r'SECURE|SEGMENT-LIMIT|SELECT|SENTENCE|SEPARATE|'
|
3556
|
+
r'SEQUENCE|SEQUENTIAL|SHARING|SIGN|SIGNED|SIGNED-INT|'
|
3557
|
+
r'SIGNED-LONG|SIGNED-SHORT|SIZE|SORT-MERGE|SOURCE|'
|
3558
|
+
r'SOURCE-COMPUTER|SPECIAL-NAMES|STANDARD|'
|
3559
|
+
r'STANDARD-1|STANDARD-2|STATUS|SUM|'
|
3560
|
+
r'SYMBOLIC|SYNC|SYNCHRONIZED|TALLYING|TAPE|'
|
3561
|
+
r'TEST|THROUGH|THRU|TIME|TIMES|TO|TOP|TRAILING|'
|
3562
|
+
r'TRANSFORM|TYPE|UNDERLINE|UNIT|UNSIGNED|'
|
3563
|
+
r'UNSIGNED-INT|UNSIGNED-LONG|UNSIGNED-SHORT|UNTIL|UP|'
|
3564
|
+
r'UPDATE|UPON|USAGE|USING|VALUE|VALUES|VARYING|WAIT|WHEN|'
|
3565
|
+
r'WITH|WORDS|YYYYDDD|YYYYMMDD)'
|
3566
|
+
r'\s*($|(?=[^0-9a-z_\-]))', Keyword.Pseudo),
|
3567
|
+
|
3568
|
+
# inactive reserved words
|
3569
|
+
(r'(^|(?<=[^0-9a-z_\-]))'
|
3570
|
+
r'(ACTIVE-CLASS|ALIGNED|ANYCASE|ARITHMETIC|ATTRIBUTE|B-AND|'
|
3571
|
+
r'B-NOT|B-OR|B-XOR|BIT|BOOLEAN|CD|CENTER|CF|CH|CHAIN|CLASS-ID|'
|
3572
|
+
r'CLASSIFICATION|COMMUNICATION|CONDITION|DATA-POINTER|'
|
3573
|
+
r'DESTINATION|DISABLE|EC|EGI|EMI|ENABLE|END-RECEIVE|'
|
3574
|
+
r'ENTRY-CONVENTION|EO|ESI|EXCEPTION-OBJECT|EXPANDS|FACTORY|'
|
3575
|
+
r'FLOAT-BINARY-16|FLOAT-BINARY-34|FLOAT-BINARY-7|'
|
3576
|
+
r'FLOAT-DECIMAL-16|FLOAT-DECIMAL-34|FLOAT-EXTENDED|FORMAT|'
|
3577
|
+
r'FUNCTION-POINTER|GET|GROUP-USAGE|IMPLEMENTS|INFINITY|'
|
3578
|
+
r'INHERITS|INTERFACE|INTERFACE-ID|INVOKE|LC_ALL|LC_COLLATE|'
|
3579
|
+
r'LC_CTYPE|LC_MESSAGES|LC_MONETARY|LC_NUMERIC|LC_TIME|'
|
3580
|
+
r'LINE-COUNTER|MESSAGE|METHOD|METHOD-ID|NESTED|NONE|NORMAL|'
|
3581
|
+
r'OBJECT|OBJECT-REFERENCE|OPTIONS|OVERRIDE|PAGE-COUNTER|PF|PH|'
|
3582
|
+
r'PROPERTY|PROTOTYPE|PURGE|QUEUE|RAISE|RAISING|RECEIVE|'
|
3583
|
+
r'RELATION|REPLACE|REPRESENTS-NOT-A-NUMBER|RESET|RESUME|RETRY|'
|
3584
|
+
r'RF|RH|SECONDS|SEGMENT|SELF|SEND|SOURCES|STATEMENT|STEP|'
|
3585
|
+
r'STRONG|SUB-QUEUE-1|SUB-QUEUE-2|SUB-QUEUE-3|SUPER|SYMBOL|'
|
3586
|
+
r'SYSTEM-DEFAULT|TABLE|TERMINAL|TEXT|TYPEDEF|UCS-4|UNIVERSAL|'
|
3587
|
+
r'USER-DEFAULT|UTF-16|UTF-8|VAL-STATUS|VALID|VALIDATE|'
|
3588
|
+
r'VALIDATE-STATUS)\s*($|(?=[^0-9a-z_\-]))', Error),
|
3589
|
+
|
3590
|
+
# Data Types
|
3591
|
+
(r'(^|(?<=[^0-9a-z_\-]))'
|
3592
|
+
r'(PIC\s+.+?(?=(\s|\.\s))|PICTURE\s+.+?(?=(\s|\.\s))|'
|
3593
|
+
r'(COMPUTATIONAL)(-[1-5X])?|(COMP)(-[1-5X])?|'
|
3594
|
+
r'BINARY-C-LONG|'
|
3595
|
+
r'BINARY-CHAR|BINARY-DOUBLE|BINARY-LONG|BINARY-SHORT|'
|
3596
|
+
r'BINARY)\s*($|(?=[^0-9a-z_\-]))', Keyword.Type),
|
3597
|
+
|
3598
|
+
# Operators
|
3599
|
+
(r'(\*\*|\*|\+|-|/|<=|>=|<|>|==|/=|=)', Operator),
|
3600
|
+
|
3601
|
+
# (r'(::)', Keyword.Declaration),
|
3602
|
+
|
3603
|
+
(r'([(),;:&%.])', Punctuation),
|
3604
|
+
|
3605
|
+
# Intrinsics
|
3606
|
+
(r'(^|(?<=[^0-9a-z_\-]))(ABS|ACOS|ANNUITY|ASIN|ATAN|BYTE-LENGTH|'
|
3607
|
+
r'CHAR|COMBINED-DATETIME|CONCATENATE|COS|CURRENT-DATE|'
|
3608
|
+
r'DATE-OF-INTEGER|DATE-TO-YYYYMMDD|DAY-OF-INTEGER|DAY-TO-YYYYDDD|'
|
3609
|
+
r'EXCEPTION-(?:FILE|LOCATION|STATEMENT|STATUS)|EXP10|EXP|E|'
|
3610
|
+
r'FACTORIAL|FRACTION-PART|INTEGER-OF-(?:DATE|DAY|PART)|INTEGER|'
|
3611
|
+
r'LENGTH|LOCALE-(?:DATE|TIME(?:-FROM-SECONDS)?)|LOG10|LOG|'
|
3612
|
+
r'LOWER-CASE|MAX|MEAN|MEDIAN|MIDRANGE|MIN|MOD|NUMVAL(?:-C)?|'
|
3613
|
+
r'ORD(?:-MAX|-MIN)?|PI|PRESENT-VALUE|RANDOM|RANGE|REM|REVERSE|'
|
3614
|
+
r'SECONDS-FROM-FORMATTED-TIME|SECONDS-PAST-MIDNIGHT|SIGN|SIN|SQRT|'
|
3615
|
+
r'STANDARD-DEVIATION|STORED-CHAR-LENGTH|SUBSTITUTE(?:-CASE)?|'
|
3616
|
+
r'SUM|TAN|TEST-DATE-YYYYMMDD|TEST-DAY-YYYYDDD|TRIM|'
|
3617
|
+
r'UPPER-CASE|VARIANCE|WHEN-COMPILED|YEAR-TO-YYYY)\s*'
|
3618
|
+
r'($|(?=[^0-9a-z_\-]))', Name.Function),
|
3619
|
+
|
3620
|
+
# Booleans
|
3621
|
+
(r'(^|(?<=[^0-9a-z_\-]))(true|false)\s*($|(?=[^0-9a-z_\-]))', Name.Builtin),
|
3622
|
+
# Comparing Operators
|
3623
|
+
(r'(^|(?<=[^0-9a-z_\-]))(equal|equals|ne|lt|le|gt|ge|'
|
3624
|
+
r'greater|less|than|not|and|or)\s*($|(?=[^0-9a-z_\-]))', Operator.Word),
|
3625
|
+
],
|
3626
|
+
|
3627
|
+
# \"[^\"\n]*\"|\'[^\'\n]*\'
|
3628
|
+
'strings': [
|
3629
|
+
# apparently strings can be delimited by EOL if they are continued
|
3630
|
+
# in the next line
|
3631
|
+
(r'"[^"\n]*("|\n)', String.Double),
|
3632
|
+
(r"'[^'\n]*('|\n)", String.Single),
|
3633
|
+
],
|
3634
|
+
|
3635
|
+
'nums': [
|
3636
|
+
(r'\d+(\s*|\.$|$)', Number.Integer),
|
3637
|
+
(r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
|
3638
|
+
(r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float),
|
3639
|
+
],
|
3640
|
+
}
|
3641
|
+
|
3642
|
+
|
3643
|
+
class CobolFreeformatLexer(CobolLexer):
|
3644
|
+
"""
|
3645
|
+
Lexer for Free format OpenCOBOL code.
|
3646
|
+
|
3647
|
+
*New in Pygments 1.6.*
|
3648
|
+
"""
|
3649
|
+
name = 'COBOLFree'
|
3650
|
+
aliases = ['cobolfree']
|
3651
|
+
filenames = ['*.cbl', '*.CBL']
|
3652
|
+
mimetypes = []
|
3653
|
+
flags = re.IGNORECASE | re.MULTILINE
|
3654
|
+
|
3655
|
+
tokens = {
|
3656
|
+
'comment': [
|
3657
|
+
(r'(\*>.*\n|^\w*\*.*$)', Comment),
|
3658
|
+
],
|
3659
|
+
}
|
3660
|
+
|
3661
|
+
|
3662
|
+
class LogosLexer(ObjectiveCppLexer):
|
3663
|
+
"""
|
3664
|
+
For Logos + Objective-C source code with preprocessor directives.
|
3665
|
+
|
3666
|
+
*New in Pygments 1.6.*
|
3667
|
+
"""
|
3668
|
+
|
3669
|
+
name = 'Logos'
|
3670
|
+
aliases = ['logos']
|
3671
|
+
filenames = ['*.x', '*.xi', '*.xm', '*.xmi']
|
3672
|
+
mimetypes = ['text/x-logos']
|
3673
|
+
priority = 0.25
|
3674
|
+
|
3675
|
+
tokens = {
|
3676
|
+
'statements': [
|
3677
|
+
(r'(%orig|%log)\b', Keyword),
|
3678
|
+
(r'(%c)\b(\()(\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\))',
|
3679
|
+
bygroups(Keyword, Punctuation, Text, Name.Class, Text, Punctuation)),
|
3680
|
+
(r'(%init)\b(\()',
|
3681
|
+
bygroups(Keyword, Punctuation), 'logos_init_directive'),
|
3682
|
+
(r'(%init)(?=\s*;)', bygroups(Keyword)),
|
3683
|
+
(r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)',
|
3684
|
+
bygroups(Keyword, Text, Name.Class), '#pop'),
|
3685
|
+
(r'(%subclass)(\s+)', bygroups(Keyword, Text),
|
3686
|
+
('#pop', 'logos_classname')),
|
3687
|
+
inherit,
|
3688
|
+
],
|
3689
|
+
'logos_init_directive' : [
|
3690
|
+
('\s+', Text),
|
3691
|
+
(',', Punctuation, ('logos_init_directive', '#pop')),
|
3692
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(=)(\s*)([^);]*)',
|
3693
|
+
bygroups(Name.Class, Text, Punctuation, Text, Text)),
|
3694
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class),
|
3695
|
+
('\)', Punctuation, '#pop'),
|
3696
|
+
],
|
3697
|
+
'logos_classname' : [
|
3698
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
|
3699
|
+
bygroups(Name.Class, Text, Name.Class), '#pop'),
|
3700
|
+
('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
|
3701
|
+
],
|
3702
|
+
'root': [
|
3703
|
+
(r'(%subclass)(\s+)', bygroups(Keyword, Text),
|
3704
|
+
'logos_classname'),
|
3705
|
+
(r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)',
|
3706
|
+
bygroups(Keyword, Text, Name.Class)),
|
3707
|
+
(r'(%config)(\s*\(\s*)(\w+)(\s*=\s*)(.*?)(\s*\)\s*)',
|
3708
|
+
bygroups(Keyword, Text, Name.Variable, Text, String, Text)),
|
3709
|
+
(r'(%ctor)(\s*)({)', bygroups(Keyword, Text, Punctuation),
|
3710
|
+
'function'),
|
3711
|
+
(r'(%new)(\s*)(\()(\s*.*?\s*)(\))',
|
3712
|
+
bygroups(Keyword, Text, Keyword, String, Keyword)),
|
3713
|
+
(r'(\s*)(%end)(\s*)', bygroups(Text, Keyword, Text)),
|
3714
|
+
inherit,
|
3715
|
+
],
|
3716
|
+
}
|
3717
|
+
|
3718
|
+
_logos_keywords = re.compile(r'%(?:hook|ctor|init|c\()')
|
3719
|
+
|
3720
|
+
def analyse_text(text):
|
3721
|
+
if LogosLexer._logos_keywords.search(text):
|
3722
|
+
return 1.0
|
3723
|
+
return 0
|