/
opt
/
imh-python
/
lib
/
python3.9
/
site-packages
/
pygments
/
lexers
/
/opt/imh-python/lib/python3.9/site-packages/pygments/lexers
mkdir
upload
Name
Size
Mode
Actions
__pycache__/
-
0755
rm
actionscript.py
11727
0644
edit
dl
rm
ada.py
5353
0644
edit
dl
rm
agile.py
896
0644
edit
dl
rm
algebra.py
9952
0644
edit
dl
rm
ambient.py
2605
0644
edit
dl
rm
amdgpu.py
1723
0644
edit
dl
rm
ampl.py
4176
0644
edit
dl
rm
apdlexer.py
30800
0644
edit
dl
rm
apl.py
3404
0644
edit
dl
rm
archetype.py
11538
0644
edit
dl
rm
arrow.py
3564
0644
edit
dl
rm
arturo.py
11414
0644
edit
dl
rm
asc.py
1693
0644
edit
dl
rm
asm.py
41967
0644
edit
dl
rm
asn1.py
4262
0644
edit
dl
rm
automation.py
19831
0644
edit
dl
rm
bare.py
3020
0644
edit
dl
rm
basic.py
27989
0644
edit
dl
rm
bdd.py
1641
0644
edit
dl
rm
berry.py
3209
0644
edit
dl
rm
bibtex.py
4811
0644
edit
dl
rm
blueprint.py
6188
0644
edit
dl
rm
boa.py
3921
0644
edit
dl
rm
bqn.py
3671
0644
edit
dl
rm
business.py
28345
0644
edit
dl
rm
capnproto.py
2174
0644
edit
dl
rm
carbon.py
3211
0644
edit
dl
rm
cddl.py
5076
0644
edit
dl
rm
chapel.py
5156
0644
edit
dl
rm
clean.py
6418
0644
edit
dl
rm
codeql.py
2576
0644
edit
dl
rm
comal.py
3179
0644
edit
dl
rm
compiled.py
1426
0644
edit
dl
rm
configs.py
50913
0644
edit
dl
rm
console.py
4180
0644
edit
dl
rm
cplint.py
1389
0644
edit
dl
rm
crystal.py
15754
0644
edit
dl
rm
csound.py
16998
0644
edit
dl
rm
css.py
25376
0644
edit
dl
rm
c_cpp.py
18059
0644
edit
dl
rm
c_like.py
32021
0644
edit
dl
rm
d.py
9920
0644
edit
dl
rm
dalvik.py
4606
0644
edit
dl
rm
data.py
27026
0644
edit
dl
rm
dax.py
8098
0644
edit
dl
rm
devicetree.py
4019
0644
edit
dl
rm
diff.py
5382
0644
edit
dl
rm
dns.py
3891
0644
edit
dl
rm
dotnet.py
39441
0644
edit
dl
rm
dsls.py
36746
0644
edit
dl
rm
dylan.py
10409
0644
edit
dl
rm
ecl.py
6371
0644
edit
dl
rm
eiffel.py
2690
0644
edit
dl
rm
elm.py
3152
0644
edit
dl
rm
elpi.py
6877
0644
edit
dl
rm
email.py
4804
0644
edit
dl
rm
erlang.py
19147
0644
edit
dl
rm
esoteric.py
10500
0644
edit
dl
rm
ezhil.py
3272
0644
edit
dl
rm
factor.py
19530
0644
edit
dl
rm
fantom.py
10231
0644
edit
dl
rm
felix.py
9655
0644
edit
dl
rm
fift.py
1644
0644
edit
dl
rm
floscript.py
2667
0644
edit
dl
rm
forth.py
7193
0644
edit
dl
rm
fortran.py
10382
0644
edit
dl
rm
foxpro.py
26295
0644
edit
dl
rm
freefem.py
26913
0644
edit
dl
rm
func.py
3700
0644
edit
dl
rm
functional.py
693
0644
edit
dl
rm
futhark.py
3743
0644
edit
dl
rm
gcodelexer.py
874
0644
edit
dl
rm
gdscript.py
7566
0644
edit
dl
rm
gleam.py
2392
0644
edit
dl
rm
go.py
3783
0644
edit
dl
rm
grammar_notation.py
8043
0644
edit
dl
rm
graph.py
4108
0644
edit
dl
rm
graphics.py
39145
0644
edit
dl
rm
graphql.py
5601
0644
edit
dl
rm
graphviz.py
1934
0644
edit
dl
rm
gsql.py
3990
0644
edit
dl
rm
hare.py
2649
0644
edit
dl
rm
haskell.py
33262
0644
edit
dl
rm
haxe.py
30974
0644
edit
dl
rm
hdl.py
22738
0644
edit
dl
rm
hexdump.py
3653
0644
edit
dl
rm
html.py
21977
0644
edit
dl
rm
idl.py
15449
0644
edit
dl
rm
igor.py
31633
0644
edit
dl
rm
inferno.py
3135
0644
edit
dl
rm
installers.py
14435
0644
edit
dl
rm
int_fiction.py
56544
0644
edit
dl
rm
iolang.py
1905
0644
edit
dl
rm
j.py
4853
0644
edit
dl
rm
javascript.py
63243
0644
edit
dl
rm
jmespath.py
2082
0644
edit
dl
rm
jslt.py
3700
0644
edit
dl
rm
json5.py
2502
0644
edit
dl
rm
jsonnet.py
5636
0644
edit
dl
rm
jsx.py
2693
0644
edit
dl
rm
julia.py
11710
0644
edit
dl
rm
jvm.py
72667
0644
edit
dl
rm
kuin.py
11405
0644
edit
dl
rm
kusto.py
3477
0644
edit
dl
rm
ldap.py
6551
0644
edit
dl
rm
lean.py
8570
0644
edit
dl
rm
lilypond.py
9752
0644
edit
dl
rm
lisp.py
157668
0644
edit
dl
rm
macaulay2.py
33366
0644
edit
dl
rm
make.py
7831
0644
edit
dl
rm
maple.py
7960
0644
edit
dl
rm
markup.py
65088
0644
edit
dl
rm
math.py
695
0644
edit
dl
rm
matlab.py
133027
0644
edit
dl
rm
maxima.py
2715
0644
edit
dl
rm
meson.py
4336
0644
edit
dl
rm
mime.py
7582
0644
edit
dl
rm
minecraft.py
13696
0644
edit
dl
rm
mips.py
4656
0644
edit
dl
rm
ml.py
35390
0644
edit
dl
rm
modeling.py
13683
0644
edit
dl
rm
modula2.py
53072
0644
edit
dl
rm
mojo.py
24233
0644
edit
dl
rm
monte.py
6289
0644
edit
dl
rm
mosel.py
9297
0644
edit
dl
rm
ncl.py
63999
0644
edit
dl
rm
nimrod.py
6413
0644
edit
dl
rm
nit.py
2725
0644
edit
dl
rm
nix.py
4421
0644
edit
dl
rm
numbair.py
1758
0644
edit
dl
rm
oberon.py
4210
0644
edit
dl
rm
objective.py
23297
0644
edit
dl
rm
ooc.py
3002
0644
edit
dl
rm
openscad.py
3700
0644
edit
dl
rm
other.py
1763
0644
edit
dl
rm
parasail.py
2719
0644
edit
dl
rm
parsers.py
26596
0644
edit
dl
rm
pascal.py
30989
0644
edit
dl
rm
pawn.py
8253
0644
edit
dl
rm
pddl.py
2989
0644
edit
dl
rm
perl.py
39192
0644
edit
dl
rm
phix.py
23249
0644
edit
dl
rm
php.py
13061
0644
edit
dl
rm
pointless.py
1974
0644
edit
dl
rm
pony.py
3279
0644
edit
dl
rm
praat.py
12676
0644
edit
dl
rm
procfile.py
1155
0644
edit
dl
rm
prolog.py
12866
0644
edit
dl
rm
promql.py
4738
0644
edit
dl
rm
prql.py
8747
0644
edit
dl
rm
ptx.py
4501
0644
edit
dl
rm
python.py
53805
0644
edit
dl
rm
q.py
6936
0644
edit
dl
rm
qlik.py
3693
0644
edit
dl
rm
qvt.py
6103
0644
edit
dl
rm
r.py
6474
0644
edit
dl
rm
rdf.py
16056
0644
edit
dl
rm
rebol.py
18259
0644
edit
dl
rm
rego.py
1748
0644
edit
dl
rm
resource.py
2927
0644
edit
dl
rm
ride.py
5035
0644
edit
dl
rm
rita.py
1127
0644
edit
dl
rm
rnc.py
1972
0644
edit
dl
rm
roboconf.py
2074
0644
edit
dl
rm
robotframework.py
18448
0644
edit
dl
rm
ruby.py
22753
0644
edit
dl
rm
rust.py
8260
0644
edit
dl
rm
sas.py
9456
0644
edit
dl
rm
savi.py
4878
0644
edit
dl
rm
scdoc.py
2524
0644
edit
dl
rm
scripting.py
81724
0644
edit
dl
rm
sgf.py
1985
0644
edit
dl
rm
shell.py
36381
0644
edit
dl
rm
sieve.py
2514
0644
edit
dl
rm
slash.py
8484
0644
edit
dl
rm
smalltalk.py
7204
0644
edit
dl
rm
smithy.py
2659
0644
edit
dl
rm
smv.py
2805
0644
edit
dl
rm
snobol.py
2778
0644
edit
dl
rm
solidity.py
3163
0644
edit
dl
rm
soong.py
2339
0644
edit
dl
rm
sophia.py
3376
0644
edit
dl
rm
special.py
3585
0644
edit
dl
rm
spice.py
2790
0644
edit
dl
rm
sql.py
48919
0644
edit
dl
rm
srcinfo.py
1746
0644
edit
dl
rm
stata.py
6415
0644
edit
dl
rm
supercollider.py
3697
0644
edit
dl
rm
tablegen.py
3987
0644
edit
dl
rm
tact.py
10809
0644
edit
dl
rm
tal.py
2904
0644
edit
dl
rm
tcl.py
5512
0644
edit
dl
rm
teal.py
3522
0644
edit
dl
rm
templates.py
75731
0644
edit
dl
rm
teraterm.py
9718
0644
edit
dl
rm
testing.py
10810
0644
edit
dl
rm
text.py
1068
0644
edit
dl
rm
textedit.py
7760
0644
edit
dl
rm
textfmts.py
15524
0644
edit
dl
rm
theorem.py
17855
0644
edit
dl
rm
thingsdb.py
6017
0644
edit
dl
rm
tlb.py
1450
0644
edit
dl
rm
tls.py
1540
0644
edit
dl
rm
tnt.py
10456
0644
edit
dl
rm
trafficscript.py
1506
0644
edit
dl
rm
typoscript.py
8332
0644
edit
dl
rm
typst.py
7167
0644
edit
dl
rm
ul4.py
10499
0644
edit
dl
rm
unicon.py
18625
0644
edit
dl
rm
urbi.py
6082
0644
edit
dl
rm
usd.py
3304
0644
edit
dl
rm
varnish.py
7473
0644
edit
dl
rm
verification.py
3934
0644
edit
dl
rm
verifpal.py
2661
0644
edit
dl
rm
vip.py
5711
0644
edit
dl
rm
vyper.py
5615
0644
edit
dl
rm
web.py
913
0644
edit
dl
rm
webassembly.py
5698
0644
edit
dl
rm
webidl.py
10516
0644
edit
dl
rm
webmisc.py
40564
0644
edit
dl
rm
wgsl.py
11880
0644
edit
dl
rm
whiley.py
4017
0644
edit
dl
rm
wowtoc.py
4076
0644
edit
dl
rm
wren.py
3229
0644
edit
dl
rm
x10.py
1943
0644
edit
dl
rm
xorg.py
925
0644
edit
dl
rm
yang.py
4499
0644
edit
dl
rm
yara.py
2427
0644
edit
dl
rm
zig.py
3976
0644
edit
dl
rm
_ada_builtins.py
1543
0644
edit
dl
rm
_asy_builtins.py
27287
0644
edit
dl
rm
_cl_builtins.py
13994
0644
edit
dl
rm
_cocoa_builtins.py
105173
0644
edit
dl
rm
_csound_builtins.py
18414
0644
edit
dl
rm
_css_builtins.py
12446
0644
edit
dl
rm
_googlesql_builtins.py
16132
0644
edit
dl
rm
_julia_builtins.py
11883
0644
edit
dl
rm
_lasso_builtins.py
134510
0644
edit
dl
rm
_lilypond_builtins.py
108094
0644
edit
dl
rm
_luau_builtins.py
955
0644
edit
dl
rm
_lua_builtins.py
8108
0644
edit
dl
rm
_mapping.py
70438
0644
edit
dl
rm
_mql_builtins.py
24713
0644
edit
dl
rm
_mysql_builtins.py
25838
0644
edit
dl
rm
_openedge_builtins.py
49398
0644
edit
dl
rm
_php_builtins.py
107922
0644
edit
dl
rm
_postgres_builtins.py
13343
0644
edit
dl
rm
_qlik_builtins.py
12595
0644
edit
dl
rm
_scheme_builtins.py
32564
0644
edit
dl
rm
_scilab_builtins.py
52411
0644
edit
dl
rm
_sourcemod_builtins.py
26777
0644
edit
dl
rm
_stan_builtins.py
13445
0644
edit
dl
rm
_stata_builtins.py
27227
0644
edit
dl
rm
_tsql_builtins.py
15460
0644
edit
dl
rm
_usd_builtins.py
1658
0644
edit
dl
rm
_vbscript_builtins.py
4225
0644
edit
dl
rm
_vim_builtins.py
57066
0644
edit
dl
rm
__init__.py
12067
0644
edit
dl
rm
Edit:
/opt/imh-python/lib/python3.9/site-packages/pygments/lexers/ml.py
(35390B)
""" pygments.lexers.ml ~~~~~~~~~~~~~~~~~~ Lexers for ML family languages. :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import re from pygments.lexer import RegexLexer, include, bygroups, default, words from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Error __all__ = ['SMLLexer', 'OcamlLexer', 'OpaLexer', 'ReasonLexer', 'FStarLexer'] class SMLLexer(RegexLexer): """ For the Standard ML language. """ name = 'Standard ML' aliases = ['sml'] filenames = ['*.sml', '*.sig', '*.fun'] mimetypes = ['text/x-standardml', 'application/x-standardml'] url = 'https://en.wikipedia.org/wiki/Standard_ML' version_added = '1.5' alphanumid_reserved = { # Core 'abstype', 'and', 'andalso', 'as', 'case', 'datatype', 'do', 'else', 'end', 'exception', 'fn', 'fun', 'handle', 'if', 'in', 'infix', 'infixr', 'let', 'local', 'nonfix', 'of', 'op', 'open', 'orelse', 'raise', 'rec', 'then', 'type', 'val', 'with', 'withtype', 'while', # Modules 'eqtype', 'functor', 'include', 'sharing', 'sig', 'signature', 'struct', 'structure', 'where', } symbolicid_reserved = { # Core ':', r'\|', '=', '=>', '->', '#', # Modules ':>', } nonid_reserved = {'(', ')', '[', ']', '{', '}', ',', ';', '...', '_'} alphanumid_re = r"[a-zA-Z][\w']*" symbolicid_re = r"[!%&$#+\-/:<=>?@\\~`^|*]+" # A character constant is a sequence of the form #s, where s is a string # constant denoting a string of size one character. This setup just parses # the entire string as either a String.Double or a String.Char (depending # on the argument), even if the String.Char is an erroneous # multiple-character string. def stringy(whatkind): return [ (r'[^"\\]', whatkind), (r'\\[\\"abtnvfr]', String.Escape), # Control-character notation is used for codes < 32, # where \^@ == \000 (r'\\\^[\x40-\x5e]', String.Escape), # Docs say 'decimal digits' (r'\\[0-9]{3}', String.Escape), (r'\\u[0-9a-fA-F]{4}', String.Escape), (r'\\\s+\\', String.Interpol), (r'"', whatkind, '#pop'), ] # Callbacks for distinguishing tokens and reserved words def long_id_callback(self, match): if match.group(1) in self.alphanumid_reserved: token = Error else: token = Name.Namespace yield match.start(1), token, match.group(1) yield match.start(2), Punctuation, match.group(2) def end_id_callback(self, match): if match.group(1) in self.alphanumid_reserved: token = Error elif match.group(1) in self.symbolicid_reserved: token = Error else: token = Name yield match.start(1), token, match.group(1) def id_callback(self, match): str = match.group(1) if str in self.alphanumid_reserved: token = Keyword.Reserved elif str in self.symbolicid_reserved: token = Punctuation else: token = Name yield match.start(1), token, str tokens = { # Whitespace and comments are (almost) everywhere 'whitespace': [ (r'\s+', Text), (r'\(\*', Comment.Multiline, 'comment'), ], 'delimiters': [ # This lexer treats these delimiters specially: # Delimiters define scopes, and the scope is how the meaning of # the `|' is resolved - is it a case/handle expression, or function # definition by cases? (This is not how the Definition works, but # it's how MLton behaves, see http://mlton.org/SMLNJDeviations) (r'\(|\[|\{', Punctuation, 'main'), (r'\)|\]|\}', Punctuation, '#pop'), (r'\b(let|if|local)\b(?!\')', Keyword.Reserved, ('main', 'main')), (r'\b(struct|sig|while)\b(?!\')', Keyword.Reserved, 'main'), (r'\b(do|else|end|in|then)\b(?!\')', Keyword.Reserved, '#pop'), ], 'core': [ # Punctuation that doesn't overlap symbolic identifiers (r'({})'.format('|'.join(re.escape(z) for z in nonid_reserved)), Punctuation), # Special constants: strings, floats, numbers in decimal and hex (r'#"', String.Char, 'char'), (r'"', String.Double, 'string'), (r'~?0x[0-9a-fA-F]+', Number.Hex), (r'0wx[0-9a-fA-F]+', Number.Hex), (r'0w\d+', Number.Integer), (r'~?\d+\.\d+[eE]~?\d+', Number.Float), (r'~?\d+\.\d+', Number.Float), (r'~?\d+[eE]~?\d+', Number.Float), (r'~?\d+', Number.Integer), # Labels (r'#\s*[1-9][0-9]*', Name.Label), (rf'#\s*({alphanumid_re})', Name.Label), (rf'#\s+({symbolicid_re})', Name.Label), # Some reserved words trigger a special, local lexer state change (r'\b(datatype|abstype)\b(?!\')', Keyword.Reserved, 'dname'), (r'\b(exception)\b(?!\')', Keyword.Reserved, 'ename'), (r'\b(functor|include|open|signature|structure)\b(?!\')', Keyword.Reserved, 'sname'), (r'\b(type|eqtype)\b(?!\')', Keyword.Reserved, 'tname'), # Regular identifiers, long and otherwise (r'\'[\w\']*', Name.Decorator), (rf'({alphanumid_re})(\.)', long_id_callback, "dotted"), (rf'({alphanumid_re})', id_callback), (rf'({symbolicid_re})', id_callback), ], 'dotted': [ (rf'({alphanumid_re})(\.)', long_id_callback), (rf'({alphanumid_re})', end_id_callback, "#pop"), (rf'({symbolicid_re})', end_id_callback, "#pop"), (r'\s+', Error), (r'\S+', Error), ], # Main parser (prevents errors in files that have scoping errors) 'root': [ default('main') ], # In this scope, I expect '|' to not be followed by a function name, # and I expect 'and' to be followed by a binding site 'main': [ include('whitespace'), # Special behavior of val/and/fun (r'\b(val|and)\b(?!\')', Keyword.Reserved, 'vname'), (r'\b(fun)\b(?!\')', Keyword.Reserved, ('#pop', 'main-fun', 'fname')), include('delimiters'), include('core'), (r'\S+', Error), ], # In this scope, I expect '|' and 'and' to be followed by a function 'main-fun': [ include('whitespace'), (r'\s', Text), (r'\(\*', Comment.Multiline, 'comment'), # Special behavior of val/and/fun (r'\b(fun|and)\b(?!\')', Keyword.Reserved, 'fname'), (r'\b(val)\b(?!\')', Keyword.Reserved, ('#pop', 'main', 'vname')), # Special behavior of '|' and '|'-manipulating keywords (r'\|', Punctuation, 'fname'), (r'\b(case|handle)\b(?!\')', Keyword.Reserved, ('#pop', 'main')), include('delimiters'), include('core'), (r'\S+', Error), ], # Character and string parsers 'char': stringy(String.Char), 'string': stringy(String.Double), 'breakout': [ (r'(?=\b({})\b(?!\'))'.format('|'.join(alphanumid_reserved)), Text, '#pop'), ], # Dealing with what comes after module system keywords 'sname': [ include('whitespace'), include('breakout'), (rf'({alphanumid_re})', Name.Namespace), default('#pop'), ], # Dealing with what comes after the 'fun' (or 'and' or '|') keyword 'fname': [ include('whitespace'), (r'\'[\w\']*', Name.Decorator), (r'\(', Punctuation, 'tyvarseq'), (rf'({alphanumid_re})', Name.Function, '#pop'), (rf'({symbolicid_re})', Name.Function, '#pop'), # Ignore interesting function declarations like "fun (x + y) = ..." default('#pop'), ], # Dealing with what comes after the 'val' (or 'and') keyword 'vname': [ include('whitespace'), (r'\'[\w\']*', Name.Decorator), (r'\(', Punctuation, 'tyvarseq'), (rf'({alphanumid_re})(\s*)(=(?!{symbolicid_re}))', bygroups(Name.Variable, Text, Punctuation), '#pop'), (rf'({symbolicid_re})(\s*)(=(?!{symbolicid_re}))', bygroups(Name.Variable, Text, Punctuation), '#pop'), (rf'({alphanumid_re})', Name.Variable, '#pop'), (rf'({symbolicid_re})', Name.Variable, '#pop'), # Ignore interesting patterns like 'val (x, y)' default('#pop'), ], # Dealing with what comes after the 'type' (or 'and') keyword 'tname': [ include('whitespace'), include('breakout'), (r'\'[\w\']*', Name.Decorator), (r'\(', Punctuation, 'tyvarseq'), (rf'=(?!{symbolicid_re})', Punctuation, ('#pop', 'typbind')), (rf'({alphanumid_re})', Keyword.Type), (rf'({symbolicid_re})', Keyword.Type), (r'\S+', Error, '#pop'), ], # A type binding includes most identifiers 'typbind': [ include('whitespace'), (r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')), include('breakout'), include('core'), (r'\S+', Error, '#pop'), ], # Dealing with what comes after the 'datatype' (or 'and') keyword 'dname': [ include('whitespace'), include('breakout'), (r'\'[\w\']*', Name.Decorator), (r'\(', Punctuation, 'tyvarseq'), (r'(=)(\s*)(datatype)', bygroups(Punctuation, Text, Keyword.Reserved), '#pop'), (rf'=(?!{symbolicid_re})', Punctuation, ('#pop', 'datbind', 'datcon')), (rf'({alphanumid_re})', Keyword.Type), (rf'({symbolicid_re})', Keyword.Type), (r'\S+', Error, '#pop'), ], # common case - A | B | C of int 'datbind': [ include('whitespace'), (r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'dname')), (r'\b(withtype)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')), (r'\b(of)\b(?!\')', Keyword.Reserved), (rf'(\|)(\s*)({alphanumid_re})', bygroups(Punctuation, Text, Name.Class)), (rf'(\|)(\s+)({symbolicid_re})', bygroups(Punctuation, Text, Name.Class)), include('breakout'), include('core'), (r'\S+', Error), ], # Dealing with what comes after an exception 'ename': [ include('whitespace'), (rf'(and\b)(\s+)({alphanumid_re})', bygroups(Keyword.Reserved, Text, Name.Class)), (rf'(and\b)(\s*)({symbolicid_re})', bygroups(Keyword.Reserved, Text, Name.Class)), (r'\b(of)\b(?!\')', Keyword.Reserved), (rf'({alphanumid_re})|({symbolicid_re})', Name.Class), default('#pop'), ], 'datcon': [ include('whitespace'), (rf'({alphanumid_re})', Name.Class, '#pop'), (rf'({symbolicid_re})', Name.Class, '#pop'), (r'\S+', Error, '#pop'), ], # Series of type variables 'tyvarseq': [ (r'\s', Text), (r'\(\*', Comment.Multiline, 'comment'), (r'\'[\w\']*', Name.Decorator), (alphanumid_re, Name), (r',', Punctuation), (r'\)', Punctuation, '#pop'), (symbolicid_re, Name), ], 'comment': [ (r'[^(*)]', Comment.Multiline), (r'\(\*', Comment.Multiline, '#push'), (r'\*\)', Comment.Multiline, '#pop'), (r'[(*)]', Comment.Multiline), ], } class OcamlLexer(RegexLexer): """ For the OCaml language. """ name = 'OCaml' url = 'https://ocaml.org/' aliases = ['ocaml'] filenames = ['*.ml', '*.mli', '*.mll', '*.mly'] mimetypes = ['text/x-ocaml'] version_added = '0.7' keywords = ( 'and', 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done', 'downto', 'else', 'end', 'exception', 'external', 'false', 'for', 'fun', 'function', 'functor', 'if', 'in', 'include', 'inherit', 'initializer', 'lazy', 'let', 'match', 'method', 'module', 'mutable', 'new', 'object', 'of', 'open', 'private', 'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try', 'type', 'val', 'virtual', 'when', 'while', 'with', ) keyopts = ( '!=', '#', '&', '&&', r'\(', r'\)', r'\*', r'\+', ',', '-', r'-\.', '->', r'\.', r'\.\.', ':', '::', ':=', ':>', ';', ';;', '<', '<-', '=', '>', '>]', r'>\}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>', r'\[\|', ']', '_', '`', r'\{', r'\{<', r'\|', r'\|]', r'\}', '~' ) operators = r'[!$%&*+\./:<=>?@^|~-]' word_operators = ('asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'or') prefix_syms = r'[!?~]' infix_syms = r'[=<>@^|&+\*/$%-]' primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array') tokens = { 'escape-sequence': [ (r'\\[\\"\'ntbr]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\x[0-9a-fA-F]{2}', String.Escape), ], 'root': [ (r'\s+', Text), (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo), (r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'), (r'\b([A-Z][\w\']*)', Name.Class), (r'\(\*(?![)])', Comment, 'comment'), (r'\b({})\b'.format('|'.join(keywords)), Keyword), (r'({})'.format('|'.join(keyopts[::-1])), Operator), (rf'({infix_syms}|{prefix_syms})?{operators}', Operator), (r'\b({})\b'.format('|'.join(word_operators)), Operator.Word), (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type), (r"[^\W\d][\w']*", Name), (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float), (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex), (r'0[oO][0-7][0-7_]*', Number.Oct), (r'0[bB][01][01_]*', Number.Bin), (r'\d[\d_]*', Number.Integer), (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", String.Char), (r"'.'", String.Char), (r"'", Keyword), # a stray quote is another syntax element (r'"', String.Double, 'string'), (r'[~?][a-z][\w\']*:', Name.Variable), ], 'comment': [ (r'[^(*)]+', Comment), (r'\(\*', Comment, '#push'), (r'\*\)', Comment, '#pop'), (r'[(*)]', Comment), ], 'string': [ (r'[^\\"]+', String.Double), include('escape-sequence'), (r'\\\n', String.Double), (r'"', String.Double, '#pop'), ], 'dotted': [ (r'\s+', Text), (r'\.', Punctuation), (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace), (r'[A-Z][\w\']*', Name.Class, '#pop'), (r'[a-z_][\w\']*', Name, '#pop'), default('#pop'), ], } class OpaLexer(RegexLexer): """ Lexer for the Opa language. """ name = 'Opa' aliases = ['opa'] filenames = ['*.opa'] mimetypes = ['text/x-opa'] url = 'http://opalang.org' version_added = '1.5' # most of these aren't strictly keywords # but if you color only real keywords, you might just # as well not color anything keywords = ( 'and', 'as', 'begin', 'case', 'client', 'css', 'database', 'db', 'do', 'else', 'end', 'external', 'forall', 'function', 'if', 'import', 'match', 'module', 'or', 'package', 'parser', 'rec', 'server', 'then', 'type', 'val', 'with', 'xml_parser', ) # matches both stuff and `stuff` ident_re = r'(([a-zA-Z_]\w*)|(`[^`]*`))' op_re = r'[.=\-<>,@~%/+?*&^!]' punc_re = r'[()\[\],;|]' # '{' and '}' are treated elsewhere # because they are also used for inserts tokens = { # copied from the caml lexer, should be adapted 'escape-sequence': [ (r'\\[\\"\'ntr}]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\x[0-9a-fA-F]{2}', String.Escape), ], # factorizing these rules, because they are inserted many times 'comments': [ (r'/\*', Comment, 'nested-comment'), (r'//.*?$', Comment), ], 'comments-and-spaces': [ include('comments'), (r'\s+', Text), ], 'root': [ include('comments-and-spaces'), # keywords (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), # directives # we could parse the actual set of directives instead of anything # starting with @, but this is troublesome # because it needs to be adjusted all the time # and assuming we parse only sources that compile, it is useless (r'@' + ident_re + r'\b', Name.Builtin.Pseudo), # number literals (r'-?.[\d]+([eE][+\-]?\d+)', Number.Float), (r'-?\d+.\d*([eE][+\-]?\d+)', Number.Float), (r'-?\d+[eE][+\-]?\d+', Number.Float), (r'0[xX][\da-fA-F]+', Number.Hex), (r'0[oO][0-7]+', Number.Oct), (r'0[bB][01]+', Number.Bin), (r'\d+', Number.Integer), # color literals (r'#[\da-fA-F]{3,6}', Number.Integer), # string literals (r'"', String.Double, 'string'), # char literal, should be checked because this is the regexp from # the caml lexer (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2})|.)'", String.Char), # this is meant to deal with embedded exprs in strings # every time we find a '}' we pop a state so that if we were # inside a string, we are back in the string state # as a consequence, we must also push a state every time we find a # '{' or else we will have errors when parsing {} for instance (r'\{', Operator, '#push'), (r'\}', Operator, '#pop'), # html literals # this is a much more strict that the actual parser, # since a<b would not be parsed as html # but then again, the parser is way too lax, and we can't hope # to have something as tolerant (r'<(?=[a-zA-Z>])', String.Single, 'html-open-tag'), # db path # matching the '[_]' in '/a[_]' because it is a part # of the syntax of the db path definition # unfortunately, i don't know how to match the ']' in # /a[1], so this is somewhat inconsistent (r'[@?!]?(/\w+)+(\[_\])?', Name.Variable), # putting the same color on <- as on db path, since # it can be used only to mean Db.write (r'<-(?!'+op_re+r')', Name.Variable), # 'modules' # although modules are not distinguished by their names as in caml # the standard library seems to follow the convention that modules # only area capitalized (r'\b([A-Z]\w*)(?=\.)', Name.Namespace), # operators # = has a special role because this is the only # way to syntactic distinguish binding constructions # unfortunately, this colors the equal in {x=2} too (r'=(?!'+op_re+r')', Keyword), (rf'({op_re})+', Operator), (rf'({punc_re})+', Operator), # coercions (r':', Operator, 'type'), # type variables # we need this rule because we don't parse specially type # definitions so in "type t('a) = ...", "'a" is parsed by 'root' ("'"+ident_re, Keyword.Type), # id literal, #something, or #{expr} (r'#'+ident_re, String.Single), (r'#(?=\{)', String.Single), # identifiers # this avoids to color '2' in 'a2' as an integer (ident_re, Text), # default, not sure if that is needed or not # (r'.', Text), ], # it is quite painful to have to parse types to know where they end # this is the general rule for a type # a type is either: # * -> ty # * type-with-slash # * type-with-slash -> ty # * type-with-slash (, type-with-slash)+ -> ty # # the code is pretty funky in here, but this code would roughly # translate in caml to: # let rec type stream = # match stream with # | [< "->"; stream >] -> type stream # | [< ""; stream >] -> # type_with_slash stream # type_lhs_1 stream; # and type_1 stream = ... 'type': [ include('comments-and-spaces'), (r'->', Keyword.Type), default(('#pop', 'type-lhs-1', 'type-with-slash')), ], # parses all the atomic or closed constructions in the syntax of type # expressions: record types, tuple types, type constructors, basic type # and type variables 'type-1': [ include('comments-and-spaces'), (r'\(', Keyword.Type, ('#pop', 'type-tuple')), (r'~?\{', Keyword.Type, ('#pop', 'type-record')), (ident_re+r'\(', Keyword.Type, ('#pop', 'type-tuple')), (ident_re, Keyword.Type, '#pop'), ("'"+ident_re, Keyword.Type), # this case is not in the syntax but sometimes # we think we are parsing types when in fact we are parsing # some css, so we just pop the states until we get back into # the root state default('#pop'), ], # type-with-slash is either: # * type-1 # * type-1 (/ type-1)+ 'type-with-slash': [ include('comments-and-spaces'), default(('#pop', 'slash-type-1', 'type-1')), ], 'slash-type-1': [ include('comments-and-spaces'), ('/', Keyword.Type, ('#pop', 'type-1')), # same remark as above default('#pop'), ], # we go in this state after having parsed a type-with-slash # while trying to parse a type # and at this point we must determine if we are parsing an arrow # type (in which case we must continue parsing) or not (in which # case we stop) 'type-lhs-1': [ include('comments-and-spaces'), (r'->', Keyword.Type, ('#pop', 'type')), (r'(?=,)', Keyword.Type, ('#pop', 'type-arrow')), default('#pop'), ], 'type-arrow': [ include('comments-and-spaces'), # the look ahead here allows to parse f(x : int, y : float -> truc) # correctly (r',(?=[^:]*?->)', Keyword.Type, 'type-with-slash'), (r'->', Keyword.Type, ('#pop', 'type')), # same remark as above default('#pop'), ], # no need to do precise parsing for tuples and records # because they are closed constructions, so we can simply # find the closing delimiter # note that this function would be not work if the source # contained identifiers like `{)` (although it could be patched # to support it) 'type-tuple': [ include('comments-and-spaces'), (r'[^()/*]+', Keyword.Type), (r'[/*]', Keyword.Type), (r'\(', Keyword.Type, '#push'), (r'\)', Keyword.Type, '#pop'), ], 'type-record': [ include('comments-and-spaces'), (r'[^{}/*]+', Keyword.Type), (r'[/*]', Keyword.Type), (r'\{', Keyword.Type, '#push'), (r'\}', Keyword.Type, '#pop'), ], # 'type-tuple': [ # include('comments-and-spaces'), # (r'\)', Keyword.Type, '#pop'), # default(('#pop', 'type-tuple-1', 'type-1')), # ], # 'type-tuple-1': [ # include('comments-and-spaces'), # (r',?\s*\)', Keyword.Type, '#pop'), # ,) is a valid end of tuple, in (1,) # (r',', Keyword.Type, 'type-1'), # ], # 'type-record':[ # include('comments-and-spaces'), # (r'\}', Keyword.Type, '#pop'), # (r'~?(?:\w+|`[^`]*`)', Keyword.Type, 'type-record-field-expr'), # ], # 'type-record-field-expr': [ # # ], 'nested-comment': [ (r'[^/*]+', Comment), (r'/\*', Comment, '#push'), (r'\*/', Comment, '#pop'), (r'[/*]', Comment), ], # the copy pasting between string and single-string # is kinda sad. Is there a way to avoid that?? 'string': [ (r'[^\\"{]+', String.Double), (r'"', String.Double, '#pop'), (r'\{', Operator, 'root'), include('escape-sequence'), ], 'single-string': [ (r'[^\\\'{]+', String.Double), (r'\'', String.Double, '#pop'), (r'\{', Operator, 'root'), include('escape-sequence'), ], # all the html stuff # can't really reuse some existing html parser # because we must be able to parse embedded expressions # we are in this state after someone parsed the '<' that # started the html literal 'html-open-tag': [ (r'[\w\-:]+', String.Single, ('#pop', 'html-attr')), (r'>', String.Single, ('#pop', 'html-content')), ], # we are in this state after someone parsed the '</' that # started the end of the closing tag 'html-end-tag': [ # this is a star, because </> is allowed (r'[\w\-:]*>', String.Single, '#pop'), ], # we are in this state after having parsed '<ident(:ident)?' # we thus parse a possibly empty list of attributes 'html-attr': [ (r'\s+', Text), (r'[\w\-:]+=', String.Single, 'html-attr-value'), (r'/>', String.Single, '#pop'), (r'>', String.Single, ('#pop', 'html-content')), ], 'html-attr-value': [ (r"'", String.Single, ('#pop', 'single-string')), (r'"', String.Single, ('#pop', 'string')), (r'#'+ident_re, String.Single, '#pop'), (r'#(?=\{)', String.Single, ('#pop', 'root')), (r'[^"\'{`=<>]+', String.Single, '#pop'), (r'\{', Operator, ('#pop', 'root')), # this is a tail call! ], # we should probably deal with '\' escapes here 'html-content': [ (r'<!--', Comment, 'html-comment'), (r'</', String.Single, ('#pop', 'html-end-tag')), (r'<', String.Single, 'html-open-tag'), (r'\{', Operator, 'root'), (r'[^<{]+', String.Single), ], 'html-comment': [ (r'-->', Comment, '#pop'), (r'[^\-]+|-', Comment), ], } class ReasonLexer(RegexLexer): """ For the ReasonML language. """ name = 'ReasonML' url = 'https://reasonml.github.io/' aliases = ['reasonml', 'reason'] filenames = ['*.re', '*.rei'] mimetypes = ['text/x-reasonml'] version_added = '2.6' keywords = ( 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done', 'downto', 'else', 'end', 'exception', 'external', 'false', 'for', 'fun', 'esfun', 'function', 'functor', 'if', 'in', 'include', 'inherit', 'initializer', 'lazy', 'let', 'switch', 'module', 'pub', 'mutable', 'new', 'nonrec', 'object', 'of', 'open', 'pri', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try', 'type', 'val', 'virtual', 'when', 'while', 'with', ) keyopts = ( '!=', '#', '&', '&&', r'\(', r'\)', r'\*', r'\+', ',', '-', r'-\.', '=>', r'\.', r'\.\.', r'\.\.\.', ':', '::', ':=', ':>', ';', ';;', '<', '<-', '=', '>', '>]', r'>\}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>', r'\[\|', ']', '_', '`', r'\{', r'\{<', r'\|', r'\|\|', r'\|]', r'\}', '~' ) operators = r'[!$%&*+\./:<=>?@^|~-]' word_operators = ('and', 'asr', 'land', 'lor', 'lsl', 'lsr', 'lxor', 'mod', 'or') prefix_syms = r'[!?~]' infix_syms = r'[=<>@^|&+\*/$%-]' primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array') tokens = { 'escape-sequence': [ (r'\\[\\"\'ntbr]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\x[0-9a-fA-F]{2}', String.Escape), ], 'root': [ (r'\s+', Text), (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo), (r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'), (r'\b([A-Z][\w\']*)', Name.Class), (r'//.*?\n', Comment.Single), (r'\/\*(?!/)', Comment.Multiline, 'comment'), (r'\b({})\b'.format('|'.join(keywords)), Keyword), (r'({})'.format('|'.join(keyopts[::-1])), Operator.Word), (rf'({infix_syms}|{prefix_syms})?{operators}', Operator), (r'\b({})\b'.format('|'.join(word_operators)), Operator.Word), (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type), (r"[^\W\d][\w']*", Name), (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float), (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex), (r'0[oO][0-7][0-7_]*', Number.Oct), (r'0[bB][01][01_]*', Number.Bin), (r'\d[\d_]*', Number.Integer), (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", String.Char), (r"'.'", String.Char), (r"'", Keyword), (r'"', String.Double, 'string'), (r'[~?][a-z][\w\']*:', Name.Variable), ], 'comment': [ (r'[^/*]+', Comment.Multiline), (r'\/\*', Comment.Multiline, '#push'), (r'\*\/', Comment.Multiline, '#pop'), (r'\*', Comment.Multiline), ], 'string': [ (r'[^\\"]+', String.Double), include('escape-sequence'), (r'\\\n', String.Double), (r'"', String.Double, '#pop'), ], 'dotted': [ (r'\s+', Text), (r'\.', Punctuation), (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace), (r'[A-Z][\w\']*', Name.Class, '#pop'), (r'[a-z_][\w\']*', Name, '#pop'), default('#pop'), ], } class FStarLexer(RegexLexer): """ For the F* language. """ name = 'FStar' url = 'https://www.fstar-lang.org/' aliases = ['fstar'] filenames = ['*.fst', '*.fsti'] mimetypes = ['text/x-fstar'] version_added = '2.7' keywords = ( 'abstract', 'attributes', 'noeq', 'unopteq', 'and' 'begin', 'by', 'default', 'effect', 'else', 'end', 'ensures', 'exception', 'exists', 'false', 'forall', 'fun', 'function', 'if', 'in', 'include', 'inline', 'inline_for_extraction', 'irreducible', 'logic', 'match', 'module', 'mutable', 'new', 'new_effect', 'noextract', 'of', 'open', 'opaque', 'private', 'range_of', 'reifiable', 'reify', 'reflectable', 'requires', 'set_range_of', 'sub_effect', 'synth', 'then', 'total', 'true', 'try', 'type', 'unfold', 'unfoldable', 'val', 'when', 'with', 'not' ) decl_keywords = ('let', 'rec') assume_keywords = ('assume', 'admit', 'assert', 'calc') keyopts = ( r'~', r'-', r'/\\', r'\\/', r'<:', r'<@', r'\(\|', r'\|\)', r'#', r'u#', r'&', r'\(', r'\)', r'\(\)', r',', r'~>', r'->', r'<-', r'<--', r'<==>', r'==>', r'\.', r'\?', r'\?\.', r'\.\[', r'\.\(', r'\.\(\|', r'\.\[\|', r'\{:pattern', r':', r'::', r':=', r';', r';;', r'=', r'%\[', r'!\{', r'\[', r'\[@', r'\[\|', r'\|>', r'\]', r'\|\]', r'\{', r'\|', r'\}', r'\$' ) operators = r'[!$%&*+\./:<=>?@^|~-]' prefix_syms = r'[!?~]' infix_syms = r'[=<>@^|&+\*/$%-]' primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array') tokens = { 'escape-sequence': [ (r'\\[\\"\'ntbr]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\x[0-9a-fA-F]{2}', String.Escape), ], 'root': [ (r'\s+', Text), (r'false|true|False|True|\(\)|\[\]', Name.Builtin.Pseudo), (r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'), (r'\b([A-Z][\w\']*)', Name.Class), (r'\(\*(?![)])', Comment, 'comment'), (r'\/\/.+$', Comment), (r'\b({})\b'.format('|'.join(keywords)), Keyword), (r'\b({})\b'.format('|'.join(assume_keywords)), Name.Exception), (r'\b({})\b'.format('|'.join(decl_keywords)), Keyword.Declaration), (r'({})'.format('|'.join(keyopts[::-1])), Operator), (rf'({infix_syms}|{prefix_syms})?{operators}', Operator), (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type), (r"[^\W\d][\w']*", Name), (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float), (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex), (r'0[oO][0-7][0-7_]*', Number.Oct), (r'0[bB][01][01_]*', Number.Bin), (r'\d[\d_]*', Number.Integer), (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", String.Char), (r"'.'", String.Char), (r"'", Keyword), # a stray quote is another syntax element (r"\`([\w\'.]+)\`", Operator.Word), # for infix applications (r"\`", Keyword), # for quoting (r'"', String.Double, 'string'), (r'[~?][a-z][\w\']*:', Name.Variable), ], 'comment': [ (r'[^(*)]+', Comment), (r'\(\*', Comment, '#push'), (r'\*\)', Comment, '#pop'), (r'[(*)]', Comment), ], 'string': [ (r'[^\\"]+', String.Double), include('escape-sequence'), (r'\\\n', String.Double), (r'"', String.Double, '#pop'), ], 'dotted': [ (r'\s+', Text), (r'\.', Punctuation), (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace), (r'[A-Z][\w\']*', Name.Class, '#pop'), (r'[a-z_][\w\']*', Name, '#pop'), default('#pop'), ], }
Save
cmd:
run