Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .cache/pip/http-v2/a/c/f/4/f/acf4fd6c256913acd9e5a7a7ef0969968b134507671c12bde829b8ec.body +3 -0
- .cache/pip/http-v2/f/d/b/4/7/fdb47d08c657290594ceebdd2e8ef27031a2b817d1dd870863649975.body +3 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/make.py +212 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/markup.py +1659 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/maxima.py +84 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/minecraft.py +392 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/mips.py +130 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/ml.py +958 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/modeling.py +368 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/mojo.py +707 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/monte.py +203 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/mosel.py +447 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/ncl.py +894 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/nit.py +63 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/nix.py +144 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/numbair.py +63 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/oberon.py +120 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/objective.py +513 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/ooc.py +84 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/openscad.py +96 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/other.py +41 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/parasail.py +78 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/parsers.py +798 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pascal.py +644 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pawn.py +202 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pddl.py +82 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/perl.py +733 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/phix.py +363 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/php.py +335 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pointless.py +70 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pony.py +93 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/praat.py +303 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/procfile.py +41 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/prolog.py +318 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/promql.py +176 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/prql.py +251 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/ptx.py +119 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/python.py +1204 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/q.py +187 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/qlik.py +117 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/qvt.py +153 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/r.py +196 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rdf.py +468 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rebol.py +419 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rego.py +57 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rell.py +68 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/resource.py +83 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/ride.py +138 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rita.py +42 -0
- .cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rnc.py +66 -0
.cache/pip/http-v2/a/c/f/4/f/acf4fd6c256913acd9e5a7a7ef0969968b134507671c12bde829b8ec.body
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:63a77fb8892bf28ebc3178683445222aa500e48ebad5ec77b0ad80f8726b1f50
|
| 3 |
+
size 226459
|
.cache/pip/http-v2/f/d/b/4/7/fdb47d08c657290594ceebdd2e8ef27031a2b817d1dd870863649975.body
ADDED
|
@@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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.make
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Makefiles and similar.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import Lexer, RegexLexer, include, bygroups, \
|
| 14 |
+
do_insertions, using
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Punctuation, Whitespace
|
| 17 |
+
from pygments.lexers.shell import BashLexer
|
| 18 |
+
|
| 19 |
+
__all__ = ['MakefileLexer', 'BaseMakefileLexer', 'CMakeLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class MakefileLexer(Lexer):
|
| 23 |
+
"""
|
| 24 |
+
Lexer for BSD and GNU make extensions (lenient enough to handle both in
|
| 25 |
+
the same file even).
|
| 26 |
+
|
| 27 |
+
*Rewritten in Pygments 0.10.*
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
name = 'Makefile'
|
| 31 |
+
aliases = ['make', 'makefile', 'mf', 'bsdmake']
|
| 32 |
+
filenames = ['*.mak', '*.mk', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile']
|
| 33 |
+
mimetypes = ['text/x-makefile']
|
| 34 |
+
url = 'https://en.wikipedia.org/wiki/Make_(software)'
|
| 35 |
+
version_added = ''
|
| 36 |
+
|
| 37 |
+
r_special = re.compile(
|
| 38 |
+
r'^(?:'
|
| 39 |
+
# BSD Make
|
| 40 |
+
r'\.\s*(include|undef|error|warning|if|else|elif|endif|for|endfor)|'
|
| 41 |
+
# GNU Make
|
| 42 |
+
r'\s*(ifeq|ifneq|ifdef|ifndef|else|endif|-?include|define|endef|:|vpath)|'
|
| 43 |
+
# GNU Automake
|
| 44 |
+
r'\s*(if|else|endif))(?=\s)')
|
| 45 |
+
r_comment = re.compile(r'^\s*@?#')
|
| 46 |
+
|
| 47 |
+
def get_tokens_unprocessed(self, text):
|
| 48 |
+
ins = []
|
| 49 |
+
lines = text.splitlines(keepends=True)
|
| 50 |
+
done = ''
|
| 51 |
+
lex = BaseMakefileLexer(**self.options)
|
| 52 |
+
backslashflag = False
|
| 53 |
+
for line in lines:
|
| 54 |
+
if self.r_special.match(line) or backslashflag:
|
| 55 |
+
ins.append((len(done), [(0, Comment.Preproc, line)]))
|
| 56 |
+
backslashflag = line.strip().endswith('\\')
|
| 57 |
+
elif self.r_comment.match(line):
|
| 58 |
+
ins.append((len(done), [(0, Comment, line)]))
|
| 59 |
+
else:
|
| 60 |
+
done += line
|
| 61 |
+
yield from do_insertions(ins, lex.get_tokens_unprocessed(done))
|
| 62 |
+
|
| 63 |
+
def analyse_text(text):
|
| 64 |
+
# Many makefiles have $(BIG_CAPS) style variables
|
| 65 |
+
if re.search(r'\$\([A-Z_]+\)', text):
|
| 66 |
+
return 0.1
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
class BaseMakefileLexer(RegexLexer):
|
| 70 |
+
"""
|
| 71 |
+
Lexer for simple Makefiles (no preprocessing).
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
name = 'Base Makefile'
|
| 75 |
+
aliases = ['basemake']
|
| 76 |
+
filenames = []
|
| 77 |
+
mimetypes = []
|
| 78 |
+
url = 'https://en.wikipedia.org/wiki/Make_(software)'
|
| 79 |
+
version_added = '0.10'
|
| 80 |
+
|
| 81 |
+
tokens = {
|
| 82 |
+
'root': [
|
| 83 |
+
# recipes (need to allow spaces because of expandtabs)
|
| 84 |
+
(r'^(?:[\t ]+.*\n|\n)+', using(BashLexer)),
|
| 85 |
+
# special variables
|
| 86 |
+
(r'\$[<@$+%?|*]', Keyword),
|
| 87 |
+
(r'\s+', Whitespace),
|
| 88 |
+
(r'#.*?\n', Comment),
|
| 89 |
+
(r'((?:un)?export)(\s+)(?=[\w${}\t -]+\n)',
|
| 90 |
+
bygroups(Keyword, Whitespace), 'export'),
|
| 91 |
+
(r'(?:un)?export\s+', Keyword),
|
| 92 |
+
# assignment
|
| 93 |
+
(r'([\w${}().-]+)(\s*)([!?:+]?=)([ \t]*)((?:.*\\\n)+|.*\n)',
|
| 94 |
+
bygroups(
|
| 95 |
+
Name.Variable, Whitespace, Operator, Whitespace,
|
| 96 |
+
using(BashLexer))),
|
| 97 |
+
# strings
|
| 98 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 99 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 100 |
+
# targets
|
| 101 |
+
(r'([^\n:]+)(:+)([ \t]*)', bygroups(
|
| 102 |
+
Name.Function, Operator, Whitespace),
|
| 103 |
+
'block-header'),
|
| 104 |
+
# expansions
|
| 105 |
+
(r'\$\(', Keyword, 'expansion'),
|
| 106 |
+
],
|
| 107 |
+
'expansion': [
|
| 108 |
+
(r'[^\w$().-]+', Text),
|
| 109 |
+
(r'[\w.-]+', Name.Variable),
|
| 110 |
+
(r'\$', Keyword),
|
| 111 |
+
(r'\(', Keyword, '#push'),
|
| 112 |
+
(r'\)', Keyword, '#pop'),
|
| 113 |
+
],
|
| 114 |
+
'export': [
|
| 115 |
+
(r'[\w${}-]+', Name.Variable),
|
| 116 |
+
(r'\n', Text, '#pop'),
|
| 117 |
+
(r'\s+', Whitespace),
|
| 118 |
+
],
|
| 119 |
+
'block-header': [
|
| 120 |
+
(r'[,|]', Punctuation),
|
| 121 |
+
(r'#.*?\n', Comment, '#pop'),
|
| 122 |
+
(r'\\\n', Text), # line continuation
|
| 123 |
+
(r'\$\(', Keyword, 'expansion'),
|
| 124 |
+
(r'[a-zA-Z_]+', Name),
|
| 125 |
+
(r'\n', Whitespace, '#pop'),
|
| 126 |
+
(r'.', Text),
|
| 127 |
+
],
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
class CMakeLexer(RegexLexer):
|
| 132 |
+
"""
|
| 133 |
+
Lexer for CMake files.
|
| 134 |
+
"""
|
| 135 |
+
name = 'CMake'
|
| 136 |
+
url = 'https://cmake.org/documentation/'
|
| 137 |
+
aliases = ['cmake']
|
| 138 |
+
filenames = ['*.cmake', 'CMakeLists.txt']
|
| 139 |
+
mimetypes = ['text/x-cmake']
|
| 140 |
+
version_added = '1.2'
|
| 141 |
+
|
| 142 |
+
tokens = {
|
| 143 |
+
'root': [
|
| 144 |
+
# (r'(ADD_CUSTOM_COMMAND|ADD_CUSTOM_TARGET|ADD_DEFINITIONS|'
|
| 145 |
+
# r'ADD_DEPENDENCIES|ADD_EXECUTABLE|ADD_LIBRARY|ADD_SUBDIRECTORY|'
|
| 146 |
+
# r'ADD_TEST|AUX_SOURCE_DIRECTORY|BUILD_COMMAND|BUILD_NAME|'
|
| 147 |
+
# r'CMAKE_MINIMUM_REQUIRED|CONFIGURE_FILE|CREATE_TEST_SOURCELIST|'
|
| 148 |
+
# r'ELSE|ELSEIF|ENABLE_LANGUAGE|ENABLE_TESTING|ENDFOREACH|'
|
| 149 |
+
# r'ENDFUNCTION|ENDIF|ENDMACRO|ENDWHILE|EXEC_PROGRAM|'
|
| 150 |
+
# r'EXECUTE_PROCESS|EXPORT_LIBRARY_DEPENDENCIES|FILE|FIND_FILE|'
|
| 151 |
+
# r'FIND_LIBRARY|FIND_PACKAGE|FIND_PATH|FIND_PROGRAM|FLTK_WRAP_UI|'
|
| 152 |
+
# r'FOREACH|FUNCTION|GET_CMAKE_PROPERTY|GET_DIRECTORY_PROPERTY|'
|
| 153 |
+
# r'GET_FILENAME_COMPONENT|GET_SOURCE_FILE_PROPERTY|'
|
| 154 |
+
# r'GET_TARGET_PROPERTY|GET_TEST_PROPERTY|IF|INCLUDE|'
|
| 155 |
+
# r'INCLUDE_DIRECTORIES|INCLUDE_EXTERNAL_MSPROJECT|'
|
| 156 |
+
# r'INCLUDE_REGULAR_EXPRESSION|INSTALL|INSTALL_FILES|'
|
| 157 |
+
# r'INSTALL_PROGRAMS|INSTALL_TARGETS|LINK_DIRECTORIES|'
|
| 158 |
+
# r'LINK_LIBRARIES|LIST|LOAD_CACHE|LOAD_COMMAND|MACRO|'
|
| 159 |
+
# r'MAKE_DIRECTORY|MARK_AS_ADVANCED|MATH|MESSAGE|OPTION|'
|
| 160 |
+
# r'OUTPUT_REQUIRED_FILES|PROJECT|QT_WRAP_CPP|QT_WRAP_UI|REMOVE|'
|
| 161 |
+
# r'REMOVE_DEFINITIONS|SEPARATE_ARGUMENTS|SET|'
|
| 162 |
+
# r'SET_DIRECTORY_PROPERTIES|SET_SOURCE_FILES_PROPERTIES|'
|
| 163 |
+
# r'SET_TARGET_PROPERTIES|SET_TESTS_PROPERTIES|SITE_NAME|'
|
| 164 |
+
# r'SOURCE_GROUP|STRING|SUBDIR_DEPENDS|SUBDIRS|'
|
| 165 |
+
# r'TARGET_LINK_LIBRARIES|TRY_COMPILE|TRY_RUN|UNSET|'
|
| 166 |
+
# r'USE_MANGLED_MESA|UTILITY_SOURCE|VARIABLE_REQUIRES|'
|
| 167 |
+
# r'VTK_MAKE_INSTANTIATOR|VTK_WRAP_JAVA|VTK_WRAP_PYTHON|'
|
| 168 |
+
# r'VTK_WRAP_TCL|WHILE|WRITE_FILE|'
|
| 169 |
+
# r'COUNTARGS)\b', Name.Builtin, 'args'),
|
| 170 |
+
(r'\b(\w+)([ \t]*)(\()', bygroups(Name.Builtin, Whitespace,
|
| 171 |
+
Punctuation), 'args'),
|
| 172 |
+
include('keywords'),
|
| 173 |
+
include('ws')
|
| 174 |
+
],
|
| 175 |
+
'args': [
|
| 176 |
+
(r'\(', Punctuation, '#push'),
|
| 177 |
+
(r'\)', Punctuation, '#pop'),
|
| 178 |
+
(r'(\$\{)(.+?)(\})', bygroups(Operator, Name.Variable, Operator)),
|
| 179 |
+
(r'(\$ENV\{)(.+?)(\})', bygroups(Operator, Name.Variable, Operator)),
|
| 180 |
+
(r'(\$<)(.+?)(>)', bygroups(Operator, Name.Variable, Operator)),
|
| 181 |
+
(r'(?s)".*?"', String.Double),
|
| 182 |
+
(r'\\\S+', String),
|
| 183 |
+
(r'\[(?P<level>=*)\[[\w\W]*?\](?P=level)\]', String.Multiline),
|
| 184 |
+
(r'[^)$"# \t\n]+', String),
|
| 185 |
+
(r'\n', Whitespace), # explicitly legal
|
| 186 |
+
include('keywords'),
|
| 187 |
+
include('ws')
|
| 188 |
+
],
|
| 189 |
+
'string': [
|
| 190 |
+
|
| 191 |
+
],
|
| 192 |
+
'keywords': [
|
| 193 |
+
(r'\b(WIN32|UNIX|APPLE|CYGWIN|BORLAND|MINGW|MSVC|MSVC_IDE|MSVC60|'
|
| 194 |
+
r'MSVC70|MSVC71|MSVC80|MSVC90)\b', Keyword),
|
| 195 |
+
],
|
| 196 |
+
'ws': [
|
| 197 |
+
(r'[ \t]+', Whitespace),
|
| 198 |
+
(r'#\[(?P<level>=*)\[[\w\W]*?\](?P=level)\]', Comment),
|
| 199 |
+
(r'#.*\n', Comment),
|
| 200 |
+
]
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
def analyse_text(text):
|
| 204 |
+
exp = (
|
| 205 |
+
r'^[ \t]*CMAKE_MINIMUM_REQUIRED[ \t]*'
|
| 206 |
+
r'\([ \t]*VERSION[ \t]*\d+(\.\d+)*[ \t]*'
|
| 207 |
+
r'([ \t]FATAL_ERROR)?[ \t]*\)[ \t]*'
|
| 208 |
+
r'(#[^\n]*)?$'
|
| 209 |
+
)
|
| 210 |
+
if re.search(exp, text, flags=re.MULTILINE | re.IGNORECASE):
|
| 211 |
+
return 0.8
|
| 212 |
+
return 0.0
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/markup.py
ADDED
|
@@ -0,0 +1,1659 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.markup
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for non-HTML markup languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexers.html import XmlLexer
|
| 14 |
+
from pygments.lexers.javascript import JavascriptLexer
|
| 15 |
+
from pygments.lexers.css import CssLexer
|
| 16 |
+
from pygments.lexers.lilypond import LilyPondLexer
|
| 17 |
+
from pygments.lexers.data import JsonLexer
|
| 18 |
+
|
| 19 |
+
from pygments.lexer import RegexLexer, DelegatingLexer, include, bygroups, \
|
| 20 |
+
using, this, do_insertions, default, words
|
| 21 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 22 |
+
Number, Punctuation, Generic, Other, Whitespace, Literal
|
| 23 |
+
from pygments.util import get_bool_opt, ClassNotFound
|
| 24 |
+
|
| 25 |
+
__all__ = ['BBCodeLexer', 'MoinWikiLexer', 'RstLexer', 'TexLexer', 'GroffLexer',
|
| 26 |
+
'MozPreprocHashLexer', 'MozPreprocPercentLexer',
|
| 27 |
+
'MozPreprocXulLexer', 'MozPreprocJavascriptLexer',
|
| 28 |
+
'MozPreprocCssLexer', 'MarkdownLexer', 'OrgLexer', 'TiddlyWiki5Lexer',
|
| 29 |
+
'WikitextLexer']
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class BBCodeLexer(RegexLexer):
|
| 33 |
+
"""
|
| 34 |
+
A lexer that highlights BBCode(-like) syntax.
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
name = 'BBCode'
|
| 38 |
+
aliases = ['bbcode']
|
| 39 |
+
mimetypes = ['text/x-bbcode']
|
| 40 |
+
url = 'https://www.bbcode.org/'
|
| 41 |
+
version_added = '0.6'
|
| 42 |
+
|
| 43 |
+
tokens = {
|
| 44 |
+
'root': [
|
| 45 |
+
(r'[^[]+', Text),
|
| 46 |
+
# tag/end tag begin
|
| 47 |
+
(r'\[/?\w+', Keyword, 'tag'),
|
| 48 |
+
# stray bracket
|
| 49 |
+
(r'\[', Text),
|
| 50 |
+
],
|
| 51 |
+
'tag': [
|
| 52 |
+
(r'\s+', Text),
|
| 53 |
+
# attribute with value
|
| 54 |
+
(r'(\w+)(=)("?[^\s"\]]+"?)',
|
| 55 |
+
bygroups(Name.Attribute, Operator, String)),
|
| 56 |
+
# tag argument (a la [color=green])
|
| 57 |
+
(r'(=)("?[^\s"\]]+"?)',
|
| 58 |
+
bygroups(Operator, String)),
|
| 59 |
+
# tag end
|
| 60 |
+
(r'\]', Keyword, '#pop'),
|
| 61 |
+
],
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class MoinWikiLexer(RegexLexer):
|
| 66 |
+
"""
|
| 67 |
+
For MoinMoin (and Trac) Wiki markup.
|
| 68 |
+
"""
|
| 69 |
+
|
| 70 |
+
name = 'MoinMoin/Trac Wiki markup'
|
| 71 |
+
aliases = ['trac-wiki', 'moin']
|
| 72 |
+
filenames = []
|
| 73 |
+
mimetypes = ['text/x-trac-wiki']
|
| 74 |
+
url = 'https://moinmo.in'
|
| 75 |
+
version_added = '0.7'
|
| 76 |
+
|
| 77 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 78 |
+
|
| 79 |
+
tokens = {
|
| 80 |
+
'root': [
|
| 81 |
+
(r'^#.*$', Comment),
|
| 82 |
+
(r'(!)(\S+)', bygroups(Keyword, Text)), # Ignore-next
|
| 83 |
+
# Titles
|
| 84 |
+
(r'^(=+)([^=]+)(=+)(\s*#.+)?$',
|
| 85 |
+
bygroups(Generic.Heading, using(this), Generic.Heading, String)),
|
| 86 |
+
# Literal code blocks, with optional shebang
|
| 87 |
+
(r'(\{\{\{)(\n#!.+)?', bygroups(Name.Builtin, Name.Namespace), 'codeblock'),
|
| 88 |
+
(r'(\'\'\'?|\|\||`|__|~~|\^|,,|::)', Comment), # Formatting
|
| 89 |
+
# Lists
|
| 90 |
+
(r'^( +)([.*-])( )', bygroups(Text, Name.Builtin, Text)),
|
| 91 |
+
(r'^( +)([a-z]{1,5}\.)( )', bygroups(Text, Name.Builtin, Text)),
|
| 92 |
+
# Other Formatting
|
| 93 |
+
(r'\[\[\w+.*?\]\]', Keyword), # Macro
|
| 94 |
+
(r'(\[[^\s\]]+)(\s+[^\]]+?)?(\])',
|
| 95 |
+
bygroups(Keyword, String, Keyword)), # Link
|
| 96 |
+
(r'^----+$', Keyword), # Horizontal rules
|
| 97 |
+
(r'[^\n\'\[{!_~^,|]+', Text),
|
| 98 |
+
(r'\n', Text),
|
| 99 |
+
(r'.', Text),
|
| 100 |
+
],
|
| 101 |
+
'codeblock': [
|
| 102 |
+
(r'\}\}\}', Name.Builtin, '#pop'),
|
| 103 |
+
# these blocks are allowed to be nested in Trac, but not MoinMoin
|
| 104 |
+
(r'\{\{\{', Text, '#push'),
|
| 105 |
+
(r'[^{}]+', Comment.Preproc), # slurp boring text
|
| 106 |
+
(r'.', Comment.Preproc), # allow loose { or }
|
| 107 |
+
],
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
class RstLexer(RegexLexer):
|
| 112 |
+
"""
|
| 113 |
+
For reStructuredText markup.
|
| 114 |
+
|
| 115 |
+
Additional options accepted:
|
| 116 |
+
|
| 117 |
+
`handlecodeblocks`
|
| 118 |
+
Highlight the contents of ``.. sourcecode:: language``,
|
| 119 |
+
``.. code:: language`` and ``.. code-block:: language``
|
| 120 |
+
directives with a lexer for the given language (default:
|
| 121 |
+
``True``).
|
| 122 |
+
|
| 123 |
+
.. versionadded:: 0.8
|
| 124 |
+
"""
|
| 125 |
+
name = 'reStructuredText'
|
| 126 |
+
url = 'https://docutils.sourceforge.io/rst.html'
|
| 127 |
+
aliases = ['restructuredtext', 'rst', 'rest']
|
| 128 |
+
filenames = ['*.rst', '*.rest']
|
| 129 |
+
mimetypes = ["text/x-rst", "text/prs.fallenstein.rst"]
|
| 130 |
+
version_added = '0.7'
|
| 131 |
+
flags = re.MULTILINE
|
| 132 |
+
|
| 133 |
+
def _handle_sourcecode(self, match):
|
| 134 |
+
from pygments.lexers import get_lexer_by_name
|
| 135 |
+
|
| 136 |
+
# section header
|
| 137 |
+
yield match.start(1), Punctuation, match.group(1)
|
| 138 |
+
yield match.start(2), Text, match.group(2)
|
| 139 |
+
yield match.start(3), Operator.Word, match.group(3)
|
| 140 |
+
yield match.start(4), Punctuation, match.group(4)
|
| 141 |
+
yield match.start(5), Text, match.group(5)
|
| 142 |
+
yield match.start(6), Keyword, match.group(6)
|
| 143 |
+
yield match.start(7), Text, match.group(7)
|
| 144 |
+
|
| 145 |
+
# lookup lexer if wanted and existing
|
| 146 |
+
lexer = None
|
| 147 |
+
if self.handlecodeblocks:
|
| 148 |
+
try:
|
| 149 |
+
lexer = get_lexer_by_name(match.group(6).strip())
|
| 150 |
+
except ClassNotFound:
|
| 151 |
+
pass
|
| 152 |
+
indention = match.group(8)
|
| 153 |
+
indention_size = len(indention)
|
| 154 |
+
code = (indention + match.group(9) + match.group(10) + match.group(11))
|
| 155 |
+
|
| 156 |
+
# no lexer for this language. handle it like it was a code block
|
| 157 |
+
if lexer is None:
|
| 158 |
+
yield match.start(8), String, code
|
| 159 |
+
return
|
| 160 |
+
|
| 161 |
+
# highlight the lines with the lexer.
|
| 162 |
+
ins = []
|
| 163 |
+
codelines = code.splitlines(True)
|
| 164 |
+
code = ''
|
| 165 |
+
for line in codelines:
|
| 166 |
+
if len(line) > indention_size:
|
| 167 |
+
ins.append((len(code), [(0, Text, line[:indention_size])]))
|
| 168 |
+
code += line[indention_size:]
|
| 169 |
+
else:
|
| 170 |
+
code += line
|
| 171 |
+
yield from do_insertions(ins, lexer.get_tokens_unprocessed(code))
|
| 172 |
+
|
| 173 |
+
# from docutils.parsers.rst.states
|
| 174 |
+
closers = '\'")]}>\u2019\u201d\xbb!?'
|
| 175 |
+
unicode_delimiters = '\u2010\u2011\u2012\u2013\u2014\u00a0'
|
| 176 |
+
end_string_suffix = (rf'((?=$)|(?=[-/:.,; \n\x00{re.escape(unicode_delimiters)}{re.escape(closers)}]))')
|
| 177 |
+
|
| 178 |
+
tokens = {
|
| 179 |
+
'root': [
|
| 180 |
+
# Heading with overline
|
| 181 |
+
(r'^(=+|-+|`+|:+|\.+|\'+|"+|~+|\^+|_+|\*+|\++|#+)([ \t]*\n)'
|
| 182 |
+
r'(.+)(\n)(\1)(\n)',
|
| 183 |
+
bygroups(Generic.Heading, Text, Generic.Heading,
|
| 184 |
+
Text, Generic.Heading, Text)),
|
| 185 |
+
# Plain heading
|
| 186 |
+
(r'^(\S.*)(\n)(={3,}|-{3,}|`{3,}|:{3,}|\.{3,}|\'{3,}|"{3,}|'
|
| 187 |
+
r'~{3,}|\^{3,}|_{3,}|\*{3,}|\+{3,}|#{3,})(\n)',
|
| 188 |
+
bygroups(Generic.Heading, Text, Generic.Heading, Text)),
|
| 189 |
+
# Bulleted lists
|
| 190 |
+
(r'^(\s*)([-*+])( .+\n(?:\1 .+\n)*)',
|
| 191 |
+
bygroups(Text, Number, using(this, state='inline'))),
|
| 192 |
+
# Numbered lists
|
| 193 |
+
(r'^(\s*)([0-9#ivxlcmIVXLCM]+\.)( .+\n(?:\1 .+\n)*)',
|
| 194 |
+
bygroups(Text, Number, using(this, state='inline'))),
|
| 195 |
+
(r'^(\s*)(\(?[0-9#ivxlcmIVXLCM]+\))( .+\n(?:\1 .+\n)*)',
|
| 196 |
+
bygroups(Text, Number, using(this, state='inline'))),
|
| 197 |
+
# Numbered, but keep words at BOL from becoming lists
|
| 198 |
+
(r'^(\s*)([A-Z]+\.)( .+\n(?:\1 .+\n)+)',
|
| 199 |
+
bygroups(Text, Number, using(this, state='inline'))),
|
| 200 |
+
(r'^(\s*)(\(?[A-Za-z]+\))( .+\n(?:\1 .+\n)+)',
|
| 201 |
+
bygroups(Text, Number, using(this, state='inline'))),
|
| 202 |
+
# Line blocks
|
| 203 |
+
(r'^(\s*)(\|)( .+\n(?:\| .+\n)*)',
|
| 204 |
+
bygroups(Text, Operator, using(this, state='inline'))),
|
| 205 |
+
# Sourcecode directives
|
| 206 |
+
(r'^( *\.\.)(\s*)((?:source)?code(?:-block)?)(::)([ \t]*)([^\n]+)'
|
| 207 |
+
r'(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\8.*)?\n)+)',
|
| 208 |
+
_handle_sourcecode),
|
| 209 |
+
# A directive
|
| 210 |
+
(r'^( *\.\.)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))',
|
| 211 |
+
bygroups(Punctuation, Text, Operator.Word, Punctuation, Text,
|
| 212 |
+
using(this, state='inline'))),
|
| 213 |
+
# A reference target
|
| 214 |
+
(r'^( *\.\.)(\s*)(_(?:[^:\\]|\\.)+:)(.*?)$',
|
| 215 |
+
bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))),
|
| 216 |
+
# A footnote/citation target
|
| 217 |
+
(r'^( *\.\.)(\s*)(\[.+\])(.*?)$',
|
| 218 |
+
bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))),
|
| 219 |
+
# A substitution def
|
| 220 |
+
(r'^( *\.\.)(\s*)(\|.+\|)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))',
|
| 221 |
+
bygroups(Punctuation, Text, Name.Tag, Text, Operator.Word,
|
| 222 |
+
Punctuation, Text, using(this, state='inline'))),
|
| 223 |
+
# Comments
|
| 224 |
+
(r'^ *\.\..*(\n( +.*\n|\n)+)?', Comment),
|
| 225 |
+
# Field list marker
|
| 226 |
+
(r'^( *)(:(?:\\\\|\\:|[^:\n])+:(?=\s))([ \t]*)',
|
| 227 |
+
bygroups(Text, Name.Class, Text)),
|
| 228 |
+
# Definition list
|
| 229 |
+
(r'^(\S.*(?<!::)\n)((?:(?: +.*)\n)+)',
|
| 230 |
+
bygroups(using(this, state='inline'), using(this, state='inline'))),
|
| 231 |
+
# Code blocks
|
| 232 |
+
(r'(::)(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\3.*)?\n)+)',
|
| 233 |
+
bygroups(String.Escape, Text, String, String, Text, String)),
|
| 234 |
+
include('inline'),
|
| 235 |
+
],
|
| 236 |
+
'inline': [
|
| 237 |
+
(r'\\.', Text), # escape
|
| 238 |
+
(r'``', String, 'literal'), # code
|
| 239 |
+
(r'(`.+?)(<.+?>)(`__?)', # reference with inline target
|
| 240 |
+
bygroups(String, String.Interpol, String)),
|
| 241 |
+
(r'`.+?`__?', String), # reference
|
| 242 |
+
(r'(`.+?`)(:[a-zA-Z0-9:-]+?:)?',
|
| 243 |
+
bygroups(Name.Variable, Name.Attribute)), # role
|
| 244 |
+
(r'(:[a-zA-Z0-9:-]+?:)(`.+?`)',
|
| 245 |
+
bygroups(Name.Attribute, Name.Variable)), # role (content first)
|
| 246 |
+
(r'\*\*.+?\*\*', Generic.Strong), # Strong emphasis
|
| 247 |
+
(r'\*.+?\*', Generic.Emph), # Emphasis
|
| 248 |
+
(r'\[.*?\]_', String), # Footnote or citation
|
| 249 |
+
(r'<.+?>', Name.Tag), # Hyperlink
|
| 250 |
+
(r'[^\\\n\[*`:]+', Text),
|
| 251 |
+
(r'.', Text),
|
| 252 |
+
],
|
| 253 |
+
'literal': [
|
| 254 |
+
(r'[^`]+', String),
|
| 255 |
+
(r'``' + end_string_suffix, String, '#pop'),
|
| 256 |
+
(r'`', String),
|
| 257 |
+
]
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
def __init__(self, **options):
|
| 261 |
+
self.handlecodeblocks = get_bool_opt(options, 'handlecodeblocks', True)
|
| 262 |
+
RegexLexer.__init__(self, **options)
|
| 263 |
+
|
| 264 |
+
def analyse_text(text):
|
| 265 |
+
if text[:2] == '..' and text[2:3] != '.':
|
| 266 |
+
return 0.3
|
| 267 |
+
p1 = text.find("\n")
|
| 268 |
+
p2 = text.find("\n", p1 + 1)
|
| 269 |
+
if (p2 > -1 and # has two lines
|
| 270 |
+
p1 * 2 + 1 == p2 and # they are the same length
|
| 271 |
+
text[p1+1] in '-=' and # the next line both starts and ends with
|
| 272 |
+
text[p1+1] == text[p2-1]): # ...a sufficiently high header
|
| 273 |
+
return 0.5
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
class TexLexer(RegexLexer):
|
| 277 |
+
"""
|
| 278 |
+
Lexer for the TeX and LaTeX typesetting languages.
|
| 279 |
+
"""
|
| 280 |
+
|
| 281 |
+
name = 'TeX'
|
| 282 |
+
aliases = ['tex', 'latex']
|
| 283 |
+
filenames = ['*.tex', '*.aux', '*.toc']
|
| 284 |
+
mimetypes = ['text/x-tex', 'text/x-latex']
|
| 285 |
+
url = 'https://tug.org'
|
| 286 |
+
version_added = ''
|
| 287 |
+
|
| 288 |
+
tokens = {
|
| 289 |
+
'general': [
|
| 290 |
+
(r'%.*?\n', Comment),
|
| 291 |
+
(r'[{}]', Name.Builtin),
|
| 292 |
+
(r'[&_^]', Name.Builtin),
|
| 293 |
+
],
|
| 294 |
+
'root': [
|
| 295 |
+
(r'\\\[', String.Backtick, 'displaymath'),
|
| 296 |
+
(r'\\\(', String, 'inlinemath'),
|
| 297 |
+
(r'\$\$', String.Backtick, 'displaymath'),
|
| 298 |
+
(r'\$', String, 'inlinemath'),
|
| 299 |
+
(r'\\([a-zA-Z@_:]+|\S?)', Keyword, 'command'),
|
| 300 |
+
(r'\\$', Keyword),
|
| 301 |
+
include('general'),
|
| 302 |
+
(r'[^\\$%&_^{}]+', Text),
|
| 303 |
+
],
|
| 304 |
+
'math': [
|
| 305 |
+
(r'\\([a-zA-Z]+|\S?)', Name.Variable),
|
| 306 |
+
include('general'),
|
| 307 |
+
(r'[0-9]+', Number),
|
| 308 |
+
(r'[-=!+*/()\[\]]', Operator),
|
| 309 |
+
(r'[^=!+*/()\[\]\\$%&_^{}0-9-]+', Name.Builtin),
|
| 310 |
+
],
|
| 311 |
+
'inlinemath': [
|
| 312 |
+
(r'\\\)', String, '#pop'),
|
| 313 |
+
(r'\$', String, '#pop'),
|
| 314 |
+
include('math'),
|
| 315 |
+
],
|
| 316 |
+
'displaymath': [
|
| 317 |
+
(r'\\\]', String, '#pop'),
|
| 318 |
+
(r'\$\$', String, '#pop'),
|
| 319 |
+
(r'\$', Name.Builtin),
|
| 320 |
+
include('math'),
|
| 321 |
+
],
|
| 322 |
+
'command': [
|
| 323 |
+
(r'\[.*?\]', Name.Attribute),
|
| 324 |
+
(r'\*', Keyword),
|
| 325 |
+
default('#pop'),
|
| 326 |
+
],
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
def analyse_text(text):
|
| 330 |
+
for start in ("\\documentclass", "\\input", "\\documentstyle",
|
| 331 |
+
"\\relax"):
|
| 332 |
+
if text[:len(start)] == start:
|
| 333 |
+
return True
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
class GroffLexer(RegexLexer):
|
| 337 |
+
"""
|
| 338 |
+
Lexer for the (g)roff typesetting language, supporting groff
|
| 339 |
+
extensions. Mainly useful for highlighting manpage sources.
|
| 340 |
+
"""
|
| 341 |
+
|
| 342 |
+
name = 'Groff'
|
| 343 |
+
aliases = ['groff', 'nroff', 'man']
|
| 344 |
+
filenames = ['*.[1-9]', '*.man', '*.1p', '*.3pm']
|
| 345 |
+
mimetypes = ['application/x-troff', 'text/troff']
|
| 346 |
+
url = 'https://www.gnu.org/software/groff'
|
| 347 |
+
version_added = '0.6'
|
| 348 |
+
|
| 349 |
+
tokens = {
|
| 350 |
+
'root': [
|
| 351 |
+
(r'(\.)(\w+)', bygroups(Text, Keyword), 'request'),
|
| 352 |
+
(r'\.', Punctuation, 'request'),
|
| 353 |
+
# Regular characters, slurp till we find a backslash or newline
|
| 354 |
+
(r'[^\\\n]+', Text, 'textline'),
|
| 355 |
+
default('textline'),
|
| 356 |
+
],
|
| 357 |
+
'textline': [
|
| 358 |
+
include('escapes'),
|
| 359 |
+
(r'[^\\\n]+', Text),
|
| 360 |
+
(r'\n', Text, '#pop'),
|
| 361 |
+
],
|
| 362 |
+
'escapes': [
|
| 363 |
+
# groff has many ways to write escapes.
|
| 364 |
+
(r'\\"[^\n]*', Comment),
|
| 365 |
+
(r'\\[fn]\w', String.Escape),
|
| 366 |
+
(r'\\\(.{2}', String.Escape),
|
| 367 |
+
(r'\\.\[.*\]', String.Escape),
|
| 368 |
+
(r'\\.', String.Escape),
|
| 369 |
+
(r'\\\n', Text, 'request'),
|
| 370 |
+
],
|
| 371 |
+
'request': [
|
| 372 |
+
(r'\n', Text, '#pop'),
|
| 373 |
+
include('escapes'),
|
| 374 |
+
(r'"[^\n"]+"', String.Double),
|
| 375 |
+
(r'\d+', Number),
|
| 376 |
+
(r'\S+', String),
|
| 377 |
+
(r'\s+', Text),
|
| 378 |
+
],
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
def analyse_text(text):
|
| 382 |
+
if text[:1] != '.':
|
| 383 |
+
return False
|
| 384 |
+
if text[:3] == '.\\"':
|
| 385 |
+
return True
|
| 386 |
+
if text[:4] == '.TH ':
|
| 387 |
+
return True
|
| 388 |
+
if text[1:3].isalnum() and text[3].isspace():
|
| 389 |
+
return 0.9
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
class MozPreprocHashLexer(RegexLexer):
|
| 393 |
+
"""
|
| 394 |
+
Lexer for Mozilla Preprocessor files (with '#' as the marker).
|
| 395 |
+
|
| 396 |
+
Other data is left untouched.
|
| 397 |
+
"""
|
| 398 |
+
name = 'mozhashpreproc'
|
| 399 |
+
aliases = [name]
|
| 400 |
+
filenames = []
|
| 401 |
+
mimetypes = []
|
| 402 |
+
url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html'
|
| 403 |
+
version_added = '2.0'
|
| 404 |
+
|
| 405 |
+
tokens = {
|
| 406 |
+
'root': [
|
| 407 |
+
(r'^#', Comment.Preproc, ('expr', 'exprstart')),
|
| 408 |
+
(r'.+', Other),
|
| 409 |
+
],
|
| 410 |
+
'exprstart': [
|
| 411 |
+
(r'(literal)(.*)', bygroups(Comment.Preproc, Text), '#pop:2'),
|
| 412 |
+
(words((
|
| 413 |
+
'define', 'undef', 'if', 'ifdef', 'ifndef', 'else', 'elif',
|
| 414 |
+
'elifdef', 'elifndef', 'endif', 'expand', 'filter', 'unfilter',
|
| 415 |
+
'include', 'includesubst', 'error')),
|
| 416 |
+
Comment.Preproc, '#pop'),
|
| 417 |
+
],
|
| 418 |
+
'expr': [
|
| 419 |
+
(words(('!', '!=', '==', '&&', '||')), Operator),
|
| 420 |
+
(r'(defined)(\()', bygroups(Keyword, Punctuation)),
|
| 421 |
+
(r'\)', Punctuation),
|
| 422 |
+
(r'[0-9]+', Number.Decimal),
|
| 423 |
+
(r'__\w+?__', Name.Variable),
|
| 424 |
+
(r'@\w+?@', Name.Class),
|
| 425 |
+
(r'\w+', Name),
|
| 426 |
+
(r'\n', Text, '#pop'),
|
| 427 |
+
(r'\s+', Text),
|
| 428 |
+
(r'\S', Punctuation),
|
| 429 |
+
],
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
class MozPreprocPercentLexer(MozPreprocHashLexer):
|
| 434 |
+
"""
|
| 435 |
+
Lexer for Mozilla Preprocessor files (with '%' as the marker).
|
| 436 |
+
|
| 437 |
+
Other data is left untouched.
|
| 438 |
+
"""
|
| 439 |
+
name = 'mozpercentpreproc'
|
| 440 |
+
aliases = [name]
|
| 441 |
+
filenames = []
|
| 442 |
+
mimetypes = []
|
| 443 |
+
url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html'
|
| 444 |
+
version_added = '2.0'
|
| 445 |
+
|
| 446 |
+
tokens = {
|
| 447 |
+
'root': [
|
| 448 |
+
(r'^%', Comment.Preproc, ('expr', 'exprstart')),
|
| 449 |
+
(r'.+', Other),
|
| 450 |
+
],
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
class MozPreprocXulLexer(DelegatingLexer):
|
| 455 |
+
"""
|
| 456 |
+
Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the
|
| 457 |
+
`XmlLexer`.
|
| 458 |
+
"""
|
| 459 |
+
name = "XUL+mozpreproc"
|
| 460 |
+
aliases = ['xul+mozpreproc']
|
| 461 |
+
filenames = ['*.xul.in']
|
| 462 |
+
mimetypes = []
|
| 463 |
+
url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html'
|
| 464 |
+
version_added = '2.0'
|
| 465 |
+
|
| 466 |
+
def __init__(self, **options):
|
| 467 |
+
super().__init__(XmlLexer, MozPreprocHashLexer, **options)
|
| 468 |
+
|
| 469 |
+
|
| 470 |
+
class MozPreprocJavascriptLexer(DelegatingLexer):
|
| 471 |
+
"""
|
| 472 |
+
Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the
|
| 473 |
+
`JavascriptLexer`.
|
| 474 |
+
"""
|
| 475 |
+
name = "Javascript+mozpreproc"
|
| 476 |
+
aliases = ['javascript+mozpreproc']
|
| 477 |
+
filenames = ['*.js.in']
|
| 478 |
+
mimetypes = []
|
| 479 |
+
url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html'
|
| 480 |
+
version_added = '2.0'
|
| 481 |
+
|
| 482 |
+
def __init__(self, **options):
|
| 483 |
+
super().__init__(JavascriptLexer, MozPreprocHashLexer, **options)
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+
class MozPreprocCssLexer(DelegatingLexer):
|
| 487 |
+
"""
|
| 488 |
+
Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the
|
| 489 |
+
`CssLexer`.
|
| 490 |
+
"""
|
| 491 |
+
name = "CSS+mozpreproc"
|
| 492 |
+
aliases = ['css+mozpreproc']
|
| 493 |
+
filenames = ['*.css.in']
|
| 494 |
+
mimetypes = []
|
| 495 |
+
url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html'
|
| 496 |
+
version_added = '2.0'
|
| 497 |
+
|
| 498 |
+
def __init__(self, **options):
|
| 499 |
+
super().__init__(CssLexer, MozPreprocPercentLexer, **options)
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
class MarkdownLexer(RegexLexer):
|
| 503 |
+
"""
|
| 504 |
+
For Markdown markup.
|
| 505 |
+
"""
|
| 506 |
+
name = 'Markdown'
|
| 507 |
+
url = 'https://daringfireball.net/projects/markdown/'
|
| 508 |
+
aliases = ['markdown', 'md']
|
| 509 |
+
filenames = ['*.md', '*.markdown']
|
| 510 |
+
mimetypes = ["text/x-markdown"]
|
| 511 |
+
version_added = '2.2'
|
| 512 |
+
flags = re.MULTILINE
|
| 513 |
+
|
| 514 |
+
def _handle_codeblock(self, match):
|
| 515 |
+
from pygments.lexers import get_lexer_by_name
|
| 516 |
+
|
| 517 |
+
yield match.start('initial'), String.Backtick, match.group('initial')
|
| 518 |
+
yield match.start('lang'), String.Backtick, match.group('lang')
|
| 519 |
+
if match.group('afterlang') is not None:
|
| 520 |
+
yield match.start('whitespace'), Whitespace, match.group('whitespace')
|
| 521 |
+
yield match.start('extra'), Text, match.group('extra')
|
| 522 |
+
yield match.start('newline'), Whitespace, match.group('newline')
|
| 523 |
+
|
| 524 |
+
# lookup lexer if wanted and existing
|
| 525 |
+
lexer = None
|
| 526 |
+
if self.handlecodeblocks:
|
| 527 |
+
try:
|
| 528 |
+
lexer = get_lexer_by_name(match.group('lang').strip())
|
| 529 |
+
except ClassNotFound:
|
| 530 |
+
pass
|
| 531 |
+
code = match.group('code')
|
| 532 |
+
# no lexer for this language. handle it like it was a code block
|
| 533 |
+
if lexer is None:
|
| 534 |
+
yield match.start('code'), String, code
|
| 535 |
+
else:
|
| 536 |
+
# FIXME: aren't the offsets wrong?
|
| 537 |
+
yield from do_insertions([], lexer.get_tokens_unprocessed(code))
|
| 538 |
+
|
| 539 |
+
yield match.start('terminator'), String.Backtick, match.group('terminator')
|
| 540 |
+
|
| 541 |
+
tokens = {
|
| 542 |
+
'root': [
|
| 543 |
+
# heading with '#' prefix (atx-style)
|
| 544 |
+
(r'(^#[^#].+)(\n)', bygroups(Generic.Heading, Text)),
|
| 545 |
+
# subheading with '#' prefix (atx-style)
|
| 546 |
+
(r'(^#{2,6}[^#].+)(\n)', bygroups(Generic.Subheading, Text)),
|
| 547 |
+
# heading with '=' underlines (Setext-style)
|
| 548 |
+
(r'^(.+)(\n)(=+)(\n)', bygroups(Generic.Heading, Text, Generic.Heading, Text)),
|
| 549 |
+
# subheading with '-' underlines (Setext-style)
|
| 550 |
+
(r'^(.+)(\n)(-+)(\n)', bygroups(Generic.Subheading, Text, Generic.Subheading, Text)),
|
| 551 |
+
# task list
|
| 552 |
+
(r'^(\s*)([*-] )(\[[ xX]\])( .+\n)',
|
| 553 |
+
bygroups(Whitespace, Keyword, Keyword, using(this, state='inline'))),
|
| 554 |
+
# bulleted list
|
| 555 |
+
(r'^(\s*)([*-])(\s)(.+\n)',
|
| 556 |
+
bygroups(Whitespace, Keyword, Whitespace, using(this, state='inline'))),
|
| 557 |
+
# numbered list
|
| 558 |
+
(r'^(\s*)([0-9]+\.)( .+\n)',
|
| 559 |
+
bygroups(Whitespace, Keyword, using(this, state='inline'))),
|
| 560 |
+
# quote
|
| 561 |
+
(r'^(\s*>\s)(.+\n)', bygroups(Keyword, Generic.Emph)),
|
| 562 |
+
# code block fenced by 3 backticks
|
| 563 |
+
(r'^(\s*```\n[\w\W]*?^\s*```$\n)', String.Backtick),
|
| 564 |
+
# code block with language
|
| 565 |
+
# Some tools include extra stuff after the language name, just
|
| 566 |
+
# highlight that as text. For example: https://docs.enola.dev/use/execmd
|
| 567 |
+
(r'''(?x)
|
| 568 |
+
^(?P<initial>\s*```)
|
| 569 |
+
(?P<lang>[\w\-]+)
|
| 570 |
+
(?P<afterlang>
|
| 571 |
+
(?P<whitespace>[^\S\n]+)
|
| 572 |
+
(?P<extra>.*))?
|
| 573 |
+
(?P<newline>\n)
|
| 574 |
+
(?P<code>(.|\n)*?)
|
| 575 |
+
(?P<terminator>^\s*```$\n)
|
| 576 |
+
''',
|
| 577 |
+
_handle_codeblock),
|
| 578 |
+
|
| 579 |
+
include('inline'),
|
| 580 |
+
],
|
| 581 |
+
'inline': [
|
| 582 |
+
# escape
|
| 583 |
+
(r'\\.', Text),
|
| 584 |
+
# inline code
|
| 585 |
+
(r'([^`]?)(`[^`\n]+`)', bygroups(Text, String.Backtick)),
|
| 586 |
+
# warning: the following rules eat outer tags.
|
| 587 |
+
# eg. **foo _bar_ baz** => foo and baz are not recognized as bold
|
| 588 |
+
# bold fenced by '**'
|
| 589 |
+
(r'([^\*]?)(\*\*[^* \n][^*\n]*\*\*)', bygroups(Text, Generic.Strong)),
|
| 590 |
+
# bold fenced by '__'
|
| 591 |
+
(r'([^_]?)(__[^_ \n][^_\n]*__)', bygroups(Text, Generic.Strong)),
|
| 592 |
+
# italics fenced by '*'
|
| 593 |
+
(r'([^\*]?)(\*[^* \n][^*\n]*\*)', bygroups(Text, Generic.Emph)),
|
| 594 |
+
# italics fenced by '_'
|
| 595 |
+
(r'([^_]?)(_[^_ \n][^_\n]*_)', bygroups(Text, Generic.Emph)),
|
| 596 |
+
# strikethrough
|
| 597 |
+
(r'([^~]?)(~~[^~ \n][^~\n]*~~)', bygroups(Text, Generic.Deleted)),
|
| 598 |
+
# mentions and topics (twitter and github stuff)
|
| 599 |
+
(r'[@#][\w/:]+', Name.Entity),
|
| 600 |
+
# (image?) links eg: 
|
| 601 |
+
(r'(!?\[)([^]]+)(\])(\()([^)]+)(\))',
|
| 602 |
+
bygroups(Text, Name.Tag, Text, Text, Name.Attribute, Text)),
|
| 603 |
+
# reference-style links, e.g.:
|
| 604 |
+
# [an example][id]
|
| 605 |
+
# [id]: http://example.com/
|
| 606 |
+
(r'(\[)([^]]+)(\])(\[)([^]]*)(\])',
|
| 607 |
+
bygroups(Text, Name.Tag, Text, Text, Name.Label, Text)),
|
| 608 |
+
(r'^(\s*\[)([^]]*)(\]:\s*)(.+)',
|
| 609 |
+
bygroups(Text, Name.Label, Text, Name.Attribute)),
|
| 610 |
+
|
| 611 |
+
# general text, must come last!
|
| 612 |
+
(r'[^\\\s]+', Text),
|
| 613 |
+
(r'.', Text),
|
| 614 |
+
],
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
def __init__(self, **options):
|
| 618 |
+
self.handlecodeblocks = get_bool_opt(options, 'handlecodeblocks', True)
|
| 619 |
+
RegexLexer.__init__(self, **options)
|
| 620 |
+
|
| 621 |
+
class OrgLexer(RegexLexer):
|
| 622 |
+
"""
|
| 623 |
+
For Org Mode markup.
|
| 624 |
+
"""
|
| 625 |
+
name = 'Org Mode'
|
| 626 |
+
url = 'https://orgmode.org'
|
| 627 |
+
aliases = ['org', 'orgmode', 'org-mode']
|
| 628 |
+
filenames = ['*.org']
|
| 629 |
+
mimetypes = ["text/org"]
|
| 630 |
+
version_added = '2.18'
|
| 631 |
+
|
| 632 |
+
def _inline(start, end):
|
| 633 |
+
return rf'(?<!\w){start}(.|\n(?!\n))+?{end}(?!\w)'
|
| 634 |
+
|
| 635 |
+
tokens = {
|
| 636 |
+
'root': [
|
| 637 |
+
(r'^# .*', Comment.Single),
|
| 638 |
+
|
| 639 |
+
# Headings
|
| 640 |
+
(r'^(\* )(COMMENT)( .*)',
|
| 641 |
+
bygroups(Generic.Heading, Comment.Preproc, Generic.Heading)),
|
| 642 |
+
(r'^(\*\*+ )(COMMENT)( .*)',
|
| 643 |
+
bygroups(Generic.Subheading, Comment.Preproc, Generic.Subheading)),
|
| 644 |
+
(r'^(\* )(DONE)( .*)',
|
| 645 |
+
bygroups(Generic.Heading, Generic.Deleted, Generic.Heading)),
|
| 646 |
+
(r'^(\*\*+ )(DONE)( .*)',
|
| 647 |
+
bygroups(Generic.Subheading, Generic.Deleted, Generic.Subheading)),
|
| 648 |
+
(r'^(\* )(TODO)( .*)',
|
| 649 |
+
bygroups(Generic.Heading, Generic.Error, Generic.Heading)),
|
| 650 |
+
(r'^(\*\*+ )(TODO)( .*)',
|
| 651 |
+
bygroups(Generic.Subheading, Generic.Error, Generic.Subheading)),
|
| 652 |
+
|
| 653 |
+
(r'^(\* .+?)( :[a-zA-Z0-9_@:]+:)?$', bygroups(Generic.Heading, Generic.Emph)),
|
| 654 |
+
(r'^(\*\*+ .+?)( :[a-zA-Z0-9_@:]+:)?$', bygroups(Generic.Subheading, Generic.Emph)),
|
| 655 |
+
|
| 656 |
+
# Unordered lists items, including TODO items and description items
|
| 657 |
+
(r'^(?:( *)([+-] )|( +)(\* ))(\[[ X-]\])?(.+ ::)?',
|
| 658 |
+
bygroups(Whitespace, Keyword, Whitespace, Keyword, Generic.Prompt, Name.Label)),
|
| 659 |
+
|
| 660 |
+
# Ordered list items
|
| 661 |
+
(r'^( *)([0-9]+[.)])( \[@[0-9]+\])?', bygroups(Whitespace, Keyword, Generic.Emph)),
|
| 662 |
+
|
| 663 |
+
# Dynamic blocks
|
| 664 |
+
(r'(?i)^( *#\+begin: *)((?:.|\n)*?)(^ *#\+end: *$)',
|
| 665 |
+
bygroups(Operator.Word, using(this), Operator.Word)),
|
| 666 |
+
|
| 667 |
+
# Comment blocks
|
| 668 |
+
(r'(?i)^( *#\+begin_comment *\n)((?:.|\n)*?)(^ *#\+end_comment *$)',
|
| 669 |
+
bygroups(Operator.Word, Comment.Multiline, Operator.Word)),
|
| 670 |
+
|
| 671 |
+
# Source code blocks
|
| 672 |
+
# TODO: language-dependent syntax highlighting (see Markdown lexer)
|
| 673 |
+
(r'(?i)^( *#\+begin_src .*)((?:.|\n)*?)(^ *#\+end_src *$)',
|
| 674 |
+
bygroups(Operator.Word, Text, Operator.Word)),
|
| 675 |
+
|
| 676 |
+
# Other blocks
|
| 677 |
+
(r'(?i)^( *#\+begin_\w+)( *\n)((?:.|\n)*?)(^ *#\+end_\w+)( *$)',
|
| 678 |
+
bygroups(Operator.Word, Whitespace, Text, Operator.Word, Whitespace)),
|
| 679 |
+
|
| 680 |
+
# Keywords
|
| 681 |
+
(r'^(#\+\w+:)(.*)$', bygroups(Name.Namespace, Text)),
|
| 682 |
+
|
| 683 |
+
# Properties and drawers
|
| 684 |
+
(r'(?i)^( *:\w+: *\n)((?:.|\n)*?)(^ *:end: *$)',
|
| 685 |
+
bygroups(Name.Decorator, Comment.Special, Name.Decorator)),
|
| 686 |
+
|
| 687 |
+
# Line break operator
|
| 688 |
+
(r'\\\\$', Operator),
|
| 689 |
+
|
| 690 |
+
(r'^\s*CLOSED:\s+', Generic.Deleted, 'dateline'),
|
| 691 |
+
(r'^\s*(?:DEADLINE:|SCHEDULED:)\s+', Generic.Error, 'dateline'),
|
| 692 |
+
|
| 693 |
+
# Bold
|
| 694 |
+
(_inline(r'\*', r'\*+'), Generic.Strong),
|
| 695 |
+
# Italic
|
| 696 |
+
(_inline(r'/', r'/'), Generic.Emph),
|
| 697 |
+
# Verbatim
|
| 698 |
+
(_inline(r'=', r'='), String), # TODO token
|
| 699 |
+
# Code
|
| 700 |
+
(_inline(r'~', r'~'), String),
|
| 701 |
+
# Strikethrough
|
| 702 |
+
(_inline(r'\+', r'\+'), Generic.Deleted),
|
| 703 |
+
# Underline
|
| 704 |
+
(_inline(r'_', r'_+'), Generic.EmphStrong),
|
| 705 |
+
|
| 706 |
+
# Dates
|
| 707 |
+
(r'<.+?>', Literal.Date),
|
| 708 |
+
# Macros
|
| 709 |
+
(r'\{\{\{.+?\}\}\}', Comment.Preproc),
|
| 710 |
+
# Footnotes
|
| 711 |
+
(r'(?<!\[)\[fn:.+?\]', Name.Tag),
|
| 712 |
+
# Links
|
| 713 |
+
(r'(?s)(\[\[)(.*?)(\]\[)(.*?)(\]\])',
|
| 714 |
+
bygroups(Punctuation, Name.Attribute, Punctuation, Name.Tag, Punctuation)),
|
| 715 |
+
(r'(?s)(\[\[)(.+?)(\]\])', bygroups(Punctuation, Name.Attribute, Punctuation)),
|
| 716 |
+
(r'(<<)(.+?)(>>)', bygroups(Punctuation, Name.Attribute, Punctuation)),
|
| 717 |
+
|
| 718 |
+
# Tables
|
| 719 |
+
(r'^( *)(\|[ -].*?[ -]\|)$', bygroups(Whitespace, String)),
|
| 720 |
+
|
| 721 |
+
# Any other text
|
| 722 |
+
(r'[^#*+\-0-9:\\/=~_<{\[|\n]+', Text),
|
| 723 |
+
(r'[#*+\-0-9:\\/=~_<{\[|\n]', Text),
|
| 724 |
+
],
|
| 725 |
+
'dateline': [
|
| 726 |
+
(r'\s*CLOSED:\s+', Generic.Deleted),
|
| 727 |
+
(r'\s*(?:DEADLINE:|SCHEDULED:)\s+', Generic.Error),
|
| 728 |
+
(r'\[.+?\]', Literal.Date),
|
| 729 |
+
(r'<[^>]+?>', Literal.Date),
|
| 730 |
+
(r'(\s*)$', Text, '#pop'),
|
| 731 |
+
(r'.', Text),
|
| 732 |
+
],
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
+
class TiddlyWiki5Lexer(RegexLexer):
|
| 736 |
+
"""
|
| 737 |
+
For TiddlyWiki5 markup.
|
| 738 |
+
"""
|
| 739 |
+
name = 'tiddler'
|
| 740 |
+
url = 'https://tiddlywiki.com/#TiddlerFiles'
|
| 741 |
+
aliases = ['tid']
|
| 742 |
+
filenames = ['*.tid']
|
| 743 |
+
mimetypes = ["text/vnd.tiddlywiki"]
|
| 744 |
+
version_added = '2.7'
|
| 745 |
+
flags = re.MULTILINE
|
| 746 |
+
|
| 747 |
+
def _handle_codeblock(self, match):
|
| 748 |
+
"""
|
| 749 |
+
match args: 1:backticks, 2:lang_name, 3:newline, 4:code, 5:backticks
|
| 750 |
+
"""
|
| 751 |
+
from pygments.lexers import get_lexer_by_name
|
| 752 |
+
|
| 753 |
+
# section header
|
| 754 |
+
yield match.start(1), String, match.group(1)
|
| 755 |
+
yield match.start(2), String, match.group(2)
|
| 756 |
+
yield match.start(3), Text, match.group(3)
|
| 757 |
+
|
| 758 |
+
# lookup lexer if wanted and existing
|
| 759 |
+
lexer = None
|
| 760 |
+
if self.handlecodeblocks:
|
| 761 |
+
try:
|
| 762 |
+
lexer = get_lexer_by_name(match.group(2).strip())
|
| 763 |
+
except ClassNotFound:
|
| 764 |
+
pass
|
| 765 |
+
code = match.group(4)
|
| 766 |
+
|
| 767 |
+
# no lexer for this language. handle it like it was a code block
|
| 768 |
+
if lexer is None:
|
| 769 |
+
yield match.start(4), String, code
|
| 770 |
+
return
|
| 771 |
+
|
| 772 |
+
yield from do_insertions([], lexer.get_tokens_unprocessed(code))
|
| 773 |
+
|
| 774 |
+
yield match.start(5), String, match.group(5)
|
| 775 |
+
|
| 776 |
+
def _handle_cssblock(self, match):
|
| 777 |
+
"""
|
| 778 |
+
match args: 1:style tag 2:newline, 3:code, 4:closing style tag
|
| 779 |
+
"""
|
| 780 |
+
from pygments.lexers import get_lexer_by_name
|
| 781 |
+
|
| 782 |
+
# section header
|
| 783 |
+
yield match.start(1), String, match.group(1)
|
| 784 |
+
yield match.start(2), String, match.group(2)
|
| 785 |
+
|
| 786 |
+
lexer = None
|
| 787 |
+
if self.handlecodeblocks:
|
| 788 |
+
try:
|
| 789 |
+
lexer = get_lexer_by_name('css')
|
| 790 |
+
except ClassNotFound:
|
| 791 |
+
pass
|
| 792 |
+
code = match.group(3)
|
| 793 |
+
|
| 794 |
+
# no lexer for this language. handle it like it was a code block
|
| 795 |
+
if lexer is None:
|
| 796 |
+
yield match.start(3), String, code
|
| 797 |
+
return
|
| 798 |
+
|
| 799 |
+
yield from do_insertions([], lexer.get_tokens_unprocessed(code))
|
| 800 |
+
|
| 801 |
+
yield match.start(4), String, match.group(4)
|
| 802 |
+
|
| 803 |
+
tokens = {
|
| 804 |
+
'root': [
|
| 805 |
+
# title in metadata section
|
| 806 |
+
(r'^(title)(:\s)(.+\n)', bygroups(Keyword, Text, Generic.Heading)),
|
| 807 |
+
# headings
|
| 808 |
+
(r'^(!)([^!].+\n)', bygroups(Generic.Heading, Text)),
|
| 809 |
+
(r'^(!{2,6})(.+\n)', bygroups(Generic.Subheading, Text)),
|
| 810 |
+
# bulleted or numbered lists or single-line block quotes
|
| 811 |
+
# (can be mixed)
|
| 812 |
+
(r'^(\s*)([*#>]+)(\s*)(.+\n)',
|
| 813 |
+
bygroups(Text, Keyword, Text, using(this, state='inline'))),
|
| 814 |
+
# multi-line block quotes
|
| 815 |
+
(r'^(<<<.*\n)([\w\W]*?)(^<<<.*$)', bygroups(String, Text, String)),
|
| 816 |
+
# table header
|
| 817 |
+
(r'^(\|.*?\|h)$', bygroups(Generic.Strong)),
|
| 818 |
+
# table footer or caption
|
| 819 |
+
(r'^(\|.*?\|[cf])$', bygroups(Generic.Emph)),
|
| 820 |
+
# table class
|
| 821 |
+
(r'^(\|.*?\|k)$', bygroups(Name.Tag)),
|
| 822 |
+
# definitions
|
| 823 |
+
(r'^(;.*)$', bygroups(Generic.Strong)),
|
| 824 |
+
# text block
|
| 825 |
+
(r'^(```\n)([\w\W]*?)(^```$)', bygroups(String, Text, String)),
|
| 826 |
+
# code block with language
|
| 827 |
+
(r'^(```)(\w+)(\n)([\w\W]*?)(^```$)', _handle_codeblock),
|
| 828 |
+
# CSS style block
|
| 829 |
+
(r'^(<style>)(\n)([\w\W]*?)(^</style>$)', _handle_cssblock),
|
| 830 |
+
|
| 831 |
+
include('keywords'),
|
| 832 |
+
include('inline'),
|
| 833 |
+
],
|
| 834 |
+
'keywords': [
|
| 835 |
+
(words((
|
| 836 |
+
'\\define', '\\end', 'caption', 'created', 'modified', 'tags',
|
| 837 |
+
'title', 'type'), prefix=r'^', suffix=r'\b'),
|
| 838 |
+
Keyword),
|
| 839 |
+
],
|
| 840 |
+
'inline': [
|
| 841 |
+
# escape
|
| 842 |
+
(r'\\.', Text),
|
| 843 |
+
# created or modified date
|
| 844 |
+
(r'\d{17}', Number.Integer),
|
| 845 |
+
# italics
|
| 846 |
+
(r'(\s)(//[^/]+//)((?=\W|\n))',
|
| 847 |
+
bygroups(Text, Generic.Emph, Text)),
|
| 848 |
+
# superscript
|
| 849 |
+
(r'(\s)(\^\^[^\^]+\^\^)', bygroups(Text, Generic.Emph)),
|
| 850 |
+
# subscript
|
| 851 |
+
(r'(\s)(,,[^,]+,,)', bygroups(Text, Generic.Emph)),
|
| 852 |
+
# underscore
|
| 853 |
+
(r'(\s)(__[^_]+__)', bygroups(Text, Generic.Strong)),
|
| 854 |
+
# bold
|
| 855 |
+
(r"(\s)(''[^']+'')((?=\W|\n))",
|
| 856 |
+
bygroups(Text, Generic.Strong, Text)),
|
| 857 |
+
# strikethrough
|
| 858 |
+
(r'(\s)(~~[^~]+~~)((?=\W|\n))',
|
| 859 |
+
bygroups(Text, Generic.Deleted, Text)),
|
| 860 |
+
# TiddlyWiki variables
|
| 861 |
+
(r'<<[^>]+>>', Name.Tag),
|
| 862 |
+
(r'\$\$[^$]+\$\$', Name.Tag),
|
| 863 |
+
(r'\$\([^)]+\)\$', Name.Tag),
|
| 864 |
+
# TiddlyWiki style or class
|
| 865 |
+
(r'^@@.*$', Name.Tag),
|
| 866 |
+
# HTML tags
|
| 867 |
+
(r'</?[^>]+>', Name.Tag),
|
| 868 |
+
# inline code
|
| 869 |
+
(r'`[^`]+`', String.Backtick),
|
| 870 |
+
# HTML escaped symbols
|
| 871 |
+
(r'&\S*?;', String.Regex),
|
| 872 |
+
# Wiki links
|
| 873 |
+
(r'(\[{2})([^]\|]+)(\]{2})', bygroups(Text, Name.Tag, Text)),
|
| 874 |
+
# External links
|
| 875 |
+
(r'(\[{2})([^]\|]+)(\|)([^]\|]+)(\]{2})',
|
| 876 |
+
bygroups(Text, Name.Tag, Text, Name.Attribute, Text)),
|
| 877 |
+
# Transclusion
|
| 878 |
+
(r'(\{{2})([^}]+)(\}{2})', bygroups(Text, Name.Tag, Text)),
|
| 879 |
+
# URLs
|
| 880 |
+
(r'(\b.?.?tps?://[^\s"]+)', bygroups(Name.Attribute)),
|
| 881 |
+
|
| 882 |
+
# general text, must come last!
|
| 883 |
+
(r'[\w]+', Text),
|
| 884 |
+
(r'.', Text)
|
| 885 |
+
],
|
| 886 |
+
}
|
| 887 |
+
|
| 888 |
+
def __init__(self, **options):
|
| 889 |
+
self.handlecodeblocks = get_bool_opt(options, 'handlecodeblocks', True)
|
| 890 |
+
RegexLexer.__init__(self, **options)
|
| 891 |
+
|
| 892 |
+
|
| 893 |
+
class WikitextLexer(RegexLexer):
|
| 894 |
+
"""
|
| 895 |
+
For MediaWiki Wikitext.
|
| 896 |
+
|
| 897 |
+
Parsing Wikitext is tricky, and results vary between different MediaWiki
|
| 898 |
+
installations, so we only highlight common syntaxes (built-in or from
|
| 899 |
+
popular extensions), and also assume templates produce no unbalanced
|
| 900 |
+
syntaxes.
|
| 901 |
+
"""
|
| 902 |
+
name = 'Wikitext'
|
| 903 |
+
url = 'https://www.mediawiki.org/wiki/Wikitext'
|
| 904 |
+
aliases = ['wikitext', 'mediawiki']
|
| 905 |
+
filenames = []
|
| 906 |
+
mimetypes = ['text/x-wiki']
|
| 907 |
+
version_added = '2.15'
|
| 908 |
+
flags = re.MULTILINE
|
| 909 |
+
|
| 910 |
+
def nowiki_tag_rules(tag_name):
|
| 911 |
+
return [
|
| 912 |
+
(rf'(?i)(</)({tag_name})(\s*)(>)', bygroups(Punctuation,
|
| 913 |
+
Name.Tag, Whitespace, Punctuation), '#pop'),
|
| 914 |
+
include('entity'),
|
| 915 |
+
include('text'),
|
| 916 |
+
]
|
| 917 |
+
|
| 918 |
+
def plaintext_tag_rules(tag_name):
|
| 919 |
+
return [
|
| 920 |
+
(rf'(?si)(.*?)(</)({tag_name})(\s*)(>)', bygroups(Text,
|
| 921 |
+
Punctuation, Name.Tag, Whitespace, Punctuation), '#pop'),
|
| 922 |
+
]
|
| 923 |
+
|
| 924 |
+
def delegate_tag_rules(tag_name, lexer, **lexer_kwargs):
|
| 925 |
+
return [
|
| 926 |
+
(rf'(?i)(</)({tag_name})(\s*)(>)', bygroups(Punctuation,
|
| 927 |
+
Name.Tag, Whitespace, Punctuation), '#pop'),
|
| 928 |
+
(rf'(?si).+?(?=</{tag_name}\s*>)', using(lexer, **lexer_kwargs)),
|
| 929 |
+
]
|
| 930 |
+
|
| 931 |
+
def text_rules(token):
|
| 932 |
+
return [
|
| 933 |
+
(r'\w+', token),
|
| 934 |
+
(r'[^\S\n]+', token),
|
| 935 |
+
(r'(?s).', token),
|
| 936 |
+
]
|
| 937 |
+
|
| 938 |
+
def handle_syntaxhighlight(self, match, ctx):
|
| 939 |
+
from pygments.lexers import get_lexer_by_name
|
| 940 |
+
|
| 941 |
+
attr_content = match.group()
|
| 942 |
+
start = 0
|
| 943 |
+
index = 0
|
| 944 |
+
while True:
|
| 945 |
+
index = attr_content.find('>', start)
|
| 946 |
+
# Exclude comment end (-->)
|
| 947 |
+
if attr_content[index-2:index] != '--':
|
| 948 |
+
break
|
| 949 |
+
start = index + 1
|
| 950 |
+
|
| 951 |
+
if index == -1:
|
| 952 |
+
# No tag end
|
| 953 |
+
yield from self.get_tokens_unprocessed(attr_content, stack=['root', 'attr'])
|
| 954 |
+
return
|
| 955 |
+
attr = attr_content[:index]
|
| 956 |
+
yield from self.get_tokens_unprocessed(attr, stack=['root', 'attr'])
|
| 957 |
+
yield match.start(3) + index, Punctuation, '>'
|
| 958 |
+
|
| 959 |
+
lexer = None
|
| 960 |
+
content = attr_content[index+1:]
|
| 961 |
+
lang_match = re.findall(r'\blang=("|\'|)(\w+)(\1)', attr)
|
| 962 |
+
|
| 963 |
+
if len(lang_match) >= 1:
|
| 964 |
+
# Pick the last match in case of multiple matches
|
| 965 |
+
lang = lang_match[-1][1]
|
| 966 |
+
try:
|
| 967 |
+
lexer = get_lexer_by_name(lang)
|
| 968 |
+
except ClassNotFound:
|
| 969 |
+
pass
|
| 970 |
+
|
| 971 |
+
if lexer is None:
|
| 972 |
+
yield match.start() + index + 1, Text, content
|
| 973 |
+
else:
|
| 974 |
+
yield from lexer.get_tokens_unprocessed(content)
|
| 975 |
+
|
| 976 |
+
def handle_score(self, match, ctx):
|
| 977 |
+
attr_content = match.group()
|
| 978 |
+
start = 0
|
| 979 |
+
index = 0
|
| 980 |
+
while True:
|
| 981 |
+
index = attr_content.find('>', start)
|
| 982 |
+
# Exclude comment end (-->)
|
| 983 |
+
if attr_content[index-2:index] != '--':
|
| 984 |
+
break
|
| 985 |
+
start = index + 1
|
| 986 |
+
|
| 987 |
+
if index == -1:
|
| 988 |
+
# No tag end
|
| 989 |
+
yield from self.get_tokens_unprocessed(attr_content, stack=['root', 'attr'])
|
| 990 |
+
return
|
| 991 |
+
attr = attr_content[:index]
|
| 992 |
+
content = attr_content[index+1:]
|
| 993 |
+
yield from self.get_tokens_unprocessed(attr, stack=['root', 'attr'])
|
| 994 |
+
yield match.start(3) + index, Punctuation, '>'
|
| 995 |
+
|
| 996 |
+
lang_match = re.findall(r'\blang=("|\'|)(\w+)(\1)', attr)
|
| 997 |
+
# Pick the last match in case of multiple matches
|
| 998 |
+
lang = lang_match[-1][1] if len(lang_match) >= 1 else 'lilypond'
|
| 999 |
+
|
| 1000 |
+
if lang == 'lilypond': # Case sensitive
|
| 1001 |
+
yield from LilyPondLexer().get_tokens_unprocessed(content)
|
| 1002 |
+
else: # ABC
|
| 1003 |
+
# FIXME: Use ABC lexer in the future
|
| 1004 |
+
yield match.start() + index + 1, Text, content
|
| 1005 |
+
|
| 1006 |
+
# a-z removed to prevent linter from complaining, REMEMBER to use (?i)
|
| 1007 |
+
title_char = r' %!"$&\'()*,\-./0-9:;=?@A-Z\\\^_`~+\u0080-\uFFFF'
|
| 1008 |
+
nbsp_char = r'(?:\t| |&\#0*160;|&\#[Xx]0*[Aa]0;|[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000])'
|
| 1009 |
+
link_address = r'(?:[0-9.]+|\[[0-9a-f:.]+\]|[^\x00-\x20"<>\[\]\x7F\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFFFD])'
|
| 1010 |
+
link_char_class = r'[^\x00-\x20"<>\[\]\x7F\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFFFD]'
|
| 1011 |
+
double_slashes_i = {
|
| 1012 |
+
'__FORCETOC__', '__NOCONTENTCONVERT__', '__NOCC__', '__NOEDITSECTION__', '__NOGALLERY__',
|
| 1013 |
+
'__NOTITLECONVERT__', '__NOTC__', '__NOTOC__', '__TOC__',
|
| 1014 |
+
}
|
| 1015 |
+
double_slashes = {
|
| 1016 |
+
'__EXPECTUNUSEDCATEGORY__', '__HIDDENCAT__', '__INDEX__', '__NEWSECTIONLINK__',
|
| 1017 |
+
'__NOINDEX__', '__NONEWSECTIONLINK__', '__STATICREDIRECT__', '__NOGLOBAL__',
|
| 1018 |
+
'__DISAMBIG__', '__EXPECTED_UNCONNECTED_PAGE__',
|
| 1019 |
+
}
|
| 1020 |
+
protocols = {
|
| 1021 |
+
'bitcoin:', 'ftp://', 'ftps://', 'geo:', 'git://', 'gopher://', 'http://', 'https://',
|
| 1022 |
+
'irc://', 'ircs://', 'magnet:', 'mailto:', 'mms://', 'news:', 'nntp://', 'redis://',
|
| 1023 |
+
'sftp://', 'sip:', 'sips:', 'sms:', 'ssh://', 'svn://', 'tel:', 'telnet://', 'urn:',
|
| 1024 |
+
'worldwind://', 'xmpp:', '//',
|
| 1025 |
+
}
|
| 1026 |
+
non_relative_protocols = protocols - {'//'}
|
| 1027 |
+
html_tags = {
|
| 1028 |
+
'abbr', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'center', 'cite', 'code',
|
| 1029 |
+
'data', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'font', 'h1', 'h2', 'h3', 'h4', 'h5',
|
| 1030 |
+
'h6', 'hr', 'i', 'ins', 'kbd', 'li', 'link', 'mark', 'meta', 'ol', 'p', 'q', 'rb', 'rp',
|
| 1031 |
+
'rt', 'rtc', 'ruby', 's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup',
|
| 1032 |
+
'table', 'td', 'th', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr',
|
| 1033 |
+
}
|
| 1034 |
+
parser_tags = {
|
| 1035 |
+
'graph', 'charinsert', 'rss', 'chem', 'categorytree', 'nowiki', 'inputbox', 'math',
|
| 1036 |
+
'hiero', 'score', 'pre', 'ref', 'translate', 'imagemap', 'templatestyles', 'languages',
|
| 1037 |
+
'noinclude', 'mapframe', 'section', 'poem', 'syntaxhighlight', 'includeonly', 'tvar',
|
| 1038 |
+
'onlyinclude', 'templatedata', 'langconvert', 'timeline', 'dynamicpagelist', 'gallery',
|
| 1039 |
+
'maplink', 'ce', 'references',
|
| 1040 |
+
}
|
| 1041 |
+
variant_langs = {
|
| 1042 |
+
# ZhConverter.php
|
| 1043 |
+
'zh', 'zh-hans', 'zh-hant', 'zh-cn', 'zh-hk', 'zh-mo', 'zh-my', 'zh-sg', 'zh-tw',
|
| 1044 |
+
# WuuConverter.php
|
| 1045 |
+
'wuu', 'wuu-hans', 'wuu-hant',
|
| 1046 |
+
# UzConverter.php
|
| 1047 |
+
'uz', 'uz-latn', 'uz-cyrl',
|
| 1048 |
+
# TlyConverter.php
|
| 1049 |
+
'tly', 'tly-cyrl',
|
| 1050 |
+
# TgConverter.php
|
| 1051 |
+
'tg', 'tg-latn',
|
| 1052 |
+
# SrConverter.php
|
| 1053 |
+
'sr', 'sr-ec', 'sr-el',
|
| 1054 |
+
# ShiConverter.php
|
| 1055 |
+
'shi', 'shi-tfng', 'shi-latn',
|
| 1056 |
+
# ShConverter.php
|
| 1057 |
+
'sh-latn', 'sh-cyrl',
|
| 1058 |
+
# KuConverter.php
|
| 1059 |
+
'ku', 'ku-arab', 'ku-latn',
|
| 1060 |
+
# IuConverter.php
|
| 1061 |
+
'iu', 'ike-cans', 'ike-latn',
|
| 1062 |
+
# GanConverter.php
|
| 1063 |
+
'gan', 'gan-hans', 'gan-hant',
|
| 1064 |
+
# EnConverter.php
|
| 1065 |
+
'en', 'en-x-piglatin',
|
| 1066 |
+
# CrhConverter.php
|
| 1067 |
+
'crh', 'crh-cyrl', 'crh-latn',
|
| 1068 |
+
# BanConverter.php
|
| 1069 |
+
'ban', 'ban-bali', 'ban-x-dharma', 'ban-x-palmleaf', 'ban-x-pku',
|
| 1070 |
+
}
|
| 1071 |
+
magic_vars_i = {
|
| 1072 |
+
'ARTICLEPATH', 'INT', 'PAGEID', 'SCRIPTPATH', 'SERVER', 'SERVERNAME', 'STYLEPATH',
|
| 1073 |
+
}
|
| 1074 |
+
magic_vars = {
|
| 1075 |
+
'!', '=', 'BASEPAGENAME', 'BASEPAGENAMEE', 'CASCADINGSOURCES', 'CONTENTLANGUAGE',
|
| 1076 |
+
'CONTENTLANG', 'CURRENTDAY', 'CURRENTDAY2', 'CURRENTDAYNAME', 'CURRENTDOW', 'CURRENTHOUR',
|
| 1077 |
+
'CURRENTMONTH', 'CURRENTMONTH2', 'CURRENTMONTH1', 'CURRENTMONTHABBREV', 'CURRENTMONTHNAME',
|
| 1078 |
+
'CURRENTMONTHNAMEGEN', 'CURRENTTIME', 'CURRENTTIMESTAMP', 'CURRENTVERSION', 'CURRENTWEEK',
|
| 1079 |
+
'CURRENTYEAR', 'DIRECTIONMARK', 'DIRMARK', 'FULLPAGENAME', 'FULLPAGENAMEE', 'LOCALDAY',
|
| 1080 |
+
'LOCALDAY2', 'LOCALDAYNAME', 'LOCALDOW', 'LOCALHOUR', 'LOCALMONTH', 'LOCALMONTH2',
|
| 1081 |
+
'LOCALMONTH1', 'LOCALMONTHABBREV', 'LOCALMONTHNAME', 'LOCALMONTHNAMEGEN', 'LOCALTIME',
|
| 1082 |
+
'LOCALTIMESTAMP', 'LOCALWEEK', 'LOCALYEAR', 'NAMESPACE', 'NAMESPACEE', 'NAMESPACENUMBER',
|
| 1083 |
+
'NUMBEROFACTIVEUSERS', 'NUMBEROFADMINS', 'NUMBEROFARTICLES', 'NUMBEROFEDITS',
|
| 1084 |
+
'NUMBEROFFILES', 'NUMBEROFPAGES', 'NUMBEROFUSERS', 'PAGELANGUAGE', 'PAGENAME', 'PAGENAMEE',
|
| 1085 |
+
'REVISIONDAY', 'REVISIONDAY2', 'REVISIONID', 'REVISIONMONTH', 'REVISIONMONTH1',
|
| 1086 |
+
'REVISIONSIZE', 'REVISIONTIMESTAMP', 'REVISIONUSER', 'REVISIONYEAR', 'ROOTPAGENAME',
|
| 1087 |
+
'ROOTPAGENAMEE', 'SITENAME', 'SUBJECTPAGENAME', 'ARTICLEPAGENAME', 'SUBJECTPAGENAMEE',
|
| 1088 |
+
'ARTICLEPAGENAMEE', 'SUBJECTSPACE', 'ARTICLESPACE', 'SUBJECTSPACEE', 'ARTICLESPACEE',
|
| 1089 |
+
'SUBPAGENAME', 'SUBPAGENAMEE', 'TALKPAGENAME', 'TALKPAGENAMEE', 'TALKSPACE', 'TALKSPACEE',
|
| 1090 |
+
}
|
| 1091 |
+
parser_functions_i = {
|
| 1092 |
+
'ANCHORENCODE', 'BIDI', 'CANONICALURL', 'CANONICALURLE', 'FILEPATH', 'FORMATNUM',
|
| 1093 |
+
'FULLURL', 'FULLURLE', 'GENDER', 'GRAMMAR', 'INT', r'\#LANGUAGE', 'LC', 'LCFIRST', 'LOCALURL',
|
| 1094 |
+
'LOCALURLE', 'NS', 'NSE', 'PADLEFT', 'PADRIGHT', 'PAGEID', 'PLURAL', 'UC', 'UCFIRST',
|
| 1095 |
+
'URLENCODE',
|
| 1096 |
+
}
|
| 1097 |
+
parser_functions = {
|
| 1098 |
+
'BASEPAGENAME', 'BASEPAGENAMEE', 'CASCADINGSOURCES', 'DEFAULTSORT', 'DEFAULTSORTKEY',
|
| 1099 |
+
'DEFAULTCATEGORYSORT', 'FULLPAGENAME', 'FULLPAGENAMEE', 'NAMESPACE', 'NAMESPACEE',
|
| 1100 |
+
'NAMESPACENUMBER', 'NUMBERINGROUP', 'NUMINGROUP', 'NUMBEROFACTIVEUSERS', 'NUMBEROFADMINS',
|
| 1101 |
+
'NUMBEROFARTICLES', 'NUMBEROFEDITS', 'NUMBEROFFILES', 'NUMBEROFPAGES', 'NUMBEROFUSERS',
|
| 1102 |
+
'PAGENAME', 'PAGENAMEE', 'PAGESINCATEGORY', 'PAGESINCAT', 'PAGESIZE', 'PROTECTIONEXPIRY',
|
| 1103 |
+
'PROTECTIONLEVEL', 'REVISIONDAY', 'REVISIONDAY2', 'REVISIONID', 'REVISIONMONTH',
|
| 1104 |
+
'REVISIONMONTH1', 'REVISIONTIMESTAMP', 'REVISIONUSER', 'REVISIONYEAR', 'ROOTPAGENAME',
|
| 1105 |
+
'ROOTPAGENAMEE', 'SUBJECTPAGENAME', 'ARTICLEPAGENAME', 'SUBJECTPAGENAMEE',
|
| 1106 |
+
'ARTICLEPAGENAMEE', 'SUBJECTSPACE', 'ARTICLESPACE', 'SUBJECTSPACEE', 'ARTICLESPACEE',
|
| 1107 |
+
'SUBPAGENAME', 'SUBPAGENAMEE', 'TALKPAGENAME', 'TALKPAGENAMEE', 'TALKSPACE', 'TALKSPACEE',
|
| 1108 |
+
'INT', 'DISPLAYTITLE', 'PAGESINNAMESPACE', 'PAGESINNS',
|
| 1109 |
+
}
|
| 1110 |
+
|
| 1111 |
+
tokens = {
|
| 1112 |
+
'root': [
|
| 1113 |
+
# Redirects
|
| 1114 |
+
(r"""(?xi)
|
| 1115 |
+
(\A\s*?)(\#REDIRECT:?) # may contain a colon
|
| 1116 |
+
(\s+)(\[\[) (?=[^\]\n]* \]\]$)
|
| 1117 |
+
""",
|
| 1118 |
+
bygroups(Whitespace, Keyword, Whitespace, Punctuation), 'redirect-inner'),
|
| 1119 |
+
# Subheadings
|
| 1120 |
+
(r'^(={2,6})(.+?)(\1)(\s*$\n)',
|
| 1121 |
+
bygroups(Generic.Subheading, Generic.Subheading, Generic.Subheading, Whitespace)),
|
| 1122 |
+
# Headings
|
| 1123 |
+
(r'^(=.+?=)(\s*$\n)',
|
| 1124 |
+
bygroups(Generic.Heading, Whitespace)),
|
| 1125 |
+
# Double-slashed magic words
|
| 1126 |
+
(words(double_slashes_i, prefix=r'(?i)'), Name.Function.Magic),
|
| 1127 |
+
(words(double_slashes), Name.Function.Magic),
|
| 1128 |
+
# Raw URLs
|
| 1129 |
+
(r'(?i)\b(?:{}){}{}*'.format('|'.join(protocols),
|
| 1130 |
+
link_address, link_char_class), Name.Label),
|
| 1131 |
+
# Magic links
|
| 1132 |
+
(rf'\b(?:RFC|PMID){nbsp_char}+[0-9]+\b',
|
| 1133 |
+
Name.Function.Magic),
|
| 1134 |
+
(r"""(?x)
|
| 1135 |
+
\bISBN {nbsp_char}
|
| 1136 |
+
(?: 97[89] {nbsp_dash}? )?
|
| 1137 |
+
(?: [0-9] {nbsp_dash}? ){{9}} # escape format()
|
| 1138 |
+
[0-9Xx]\b
|
| 1139 |
+
""".format(nbsp_char=nbsp_char, nbsp_dash=f'(?:-|{nbsp_char})'), Name.Function.Magic),
|
| 1140 |
+
include('list'),
|
| 1141 |
+
include('inline'),
|
| 1142 |
+
include('text'),
|
| 1143 |
+
],
|
| 1144 |
+
'redirect-inner': [
|
| 1145 |
+
(r'(\]\])(\s*?\n)', bygroups(Punctuation, Whitespace), '#pop'),
|
| 1146 |
+
(r'(\#)([^#]*?)', bygroups(Punctuation, Name.Label)),
|
| 1147 |
+
(rf'(?i)[{title_char}]+', Name.Tag),
|
| 1148 |
+
],
|
| 1149 |
+
'list': [
|
| 1150 |
+
# Description lists
|
| 1151 |
+
(r'^;', Keyword, 'dt'),
|
| 1152 |
+
# Ordered lists, unordered lists and indents
|
| 1153 |
+
(r'^[#:*]+', Keyword),
|
| 1154 |
+
# Horizontal rules
|
| 1155 |
+
(r'^-{4,}', Keyword),
|
| 1156 |
+
],
|
| 1157 |
+
'inline': [
|
| 1158 |
+
# Signatures
|
| 1159 |
+
(r'~{3,5}', Keyword),
|
| 1160 |
+
# Entities
|
| 1161 |
+
include('entity'),
|
| 1162 |
+
# Bold & italic
|
| 1163 |
+
(r"('')(''')(?!')", bygroups(Generic.Emph,
|
| 1164 |
+
Generic.EmphStrong), 'inline-italic-bold'),
|
| 1165 |
+
(r"'''(?!')", Generic.Strong, 'inline-bold'),
|
| 1166 |
+
(r"''(?!')", Generic.Emph, 'inline-italic'),
|
| 1167 |
+
# Comments & parameters & templates
|
| 1168 |
+
include('replaceable'),
|
| 1169 |
+
# Media links
|
| 1170 |
+
(
|
| 1171 |
+
r"""(?xi)
|
| 1172 |
+
(\[\[)
|
| 1173 |
+
(File|Image) (:)
|
| 1174 |
+
((?: [{}] | \{{{{2,3}}[^{{}}]*?\}}{{2,3}} | <!--[\s\S]*?--> )*)
|
| 1175 |
+
(?: (\#) ([{}]*?) )?
|
| 1176 |
+
""".format(title_char, f'{title_char}#'),
|
| 1177 |
+
bygroups(Punctuation, Name.Namespace, Punctuation,
|
| 1178 |
+
using(this, state=['wikilink-name']), Punctuation, Name.Label),
|
| 1179 |
+
'medialink-inner'
|
| 1180 |
+
),
|
| 1181 |
+
# Wikilinks
|
| 1182 |
+
(
|
| 1183 |
+
r"""(?xi)
|
| 1184 |
+
(\[\[)(?!{}) # Should not contain URLs
|
| 1185 |
+
(?: ([{}]*) (:))?
|
| 1186 |
+
((?: [{}] | \{{{{2,3}}[^{{}}]*?\}}{{2,3}} | <!--[\s\S]*?--> )*?)
|
| 1187 |
+
(?: (\#) ([{}]*?) )?
|
| 1188 |
+
(\]\])
|
| 1189 |
+
""".format('|'.join(protocols), title_char.replace('/', ''),
|
| 1190 |
+
title_char, f'{title_char}#'),
|
| 1191 |
+
bygroups(Punctuation, Name.Namespace, Punctuation,
|
| 1192 |
+
using(this, state=['wikilink-name']), Punctuation, Name.Label, Punctuation)
|
| 1193 |
+
),
|
| 1194 |
+
(
|
| 1195 |
+
r"""(?xi)
|
| 1196 |
+
(\[\[)(?!{})
|
| 1197 |
+
(?: ([{}]*) (:))?
|
| 1198 |
+
((?: [{}] | \{{{{2,3}}[^{{}}]*?\}}{{2,3}} | <!--[\s\S]*?--> )*?)
|
| 1199 |
+
(?: (\#) ([{}]*?) )?
|
| 1200 |
+
(\|)
|
| 1201 |
+
""".format('|'.join(protocols), title_char.replace('/', ''),
|
| 1202 |
+
title_char, f'{title_char}#'),
|
| 1203 |
+
bygroups(Punctuation, Name.Namespace, Punctuation,
|
| 1204 |
+
using(this, state=['wikilink-name']), Punctuation, Name.Label, Punctuation),
|
| 1205 |
+
'wikilink-inner'
|
| 1206 |
+
),
|
| 1207 |
+
# External links
|
| 1208 |
+
(
|
| 1209 |
+
r"""(?xi)
|
| 1210 |
+
(\[)
|
| 1211 |
+
((?:{}) {} {}*)
|
| 1212 |
+
(\s*)
|
| 1213 |
+
""".format('|'.join(protocols), link_address, link_char_class),
|
| 1214 |
+
bygroups(Punctuation, Name.Label, Whitespace),
|
| 1215 |
+
'extlink-inner'
|
| 1216 |
+
),
|
| 1217 |
+
# Tables
|
| 1218 |
+
(r'^(:*)(\s*?)(\{\|)([^\n]*)$', bygroups(Keyword,
|
| 1219 |
+
Whitespace, Punctuation, using(this, state=['root', 'attr'])), 'table'),
|
| 1220 |
+
# HTML tags
|
| 1221 |
+
(r'(?i)(<)({})\b'.format('|'.join(html_tags)),
|
| 1222 |
+
bygroups(Punctuation, Name.Tag), 'tag-inner-ordinary'),
|
| 1223 |
+
(r'(?i)(</)({})\b(\s*)(>)'.format('|'.join(html_tags)),
|
| 1224 |
+
bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)),
|
| 1225 |
+
# <nowiki>
|
| 1226 |
+
(r'(?i)(<)(nowiki)\b', bygroups(Punctuation,
|
| 1227 |
+
Name.Tag), ('tag-nowiki', 'tag-inner')),
|
| 1228 |
+
# <pre>
|
| 1229 |
+
(r'(?i)(<)(pre)\b', bygroups(Punctuation,
|
| 1230 |
+
Name.Tag), ('tag-pre', 'tag-inner')),
|
| 1231 |
+
# <categorytree>
|
| 1232 |
+
(r'(?i)(<)(categorytree)\b', bygroups(
|
| 1233 |
+
Punctuation, Name.Tag), ('tag-categorytree', 'tag-inner')),
|
| 1234 |
+
# <hiero>
|
| 1235 |
+
(r'(?i)(<)(hiero)\b', bygroups(Punctuation,
|
| 1236 |
+
Name.Tag), ('tag-hiero', 'tag-inner')),
|
| 1237 |
+
# <math>
|
| 1238 |
+
(r'(?i)(<)(math)\b', bygroups(Punctuation,
|
| 1239 |
+
Name.Tag), ('tag-math', 'tag-inner')),
|
| 1240 |
+
# <chem>
|
| 1241 |
+
(r'(?i)(<)(chem)\b', bygroups(Punctuation,
|
| 1242 |
+
Name.Tag), ('tag-chem', 'tag-inner')),
|
| 1243 |
+
# <ce>
|
| 1244 |
+
(r'(?i)(<)(ce)\b', bygroups(Punctuation,
|
| 1245 |
+
Name.Tag), ('tag-ce', 'tag-inner')),
|
| 1246 |
+
# <charinsert>
|
| 1247 |
+
(r'(?i)(<)(charinsert)\b', bygroups(
|
| 1248 |
+
Punctuation, Name.Tag), ('tag-charinsert', 'tag-inner')),
|
| 1249 |
+
# <templatedata>
|
| 1250 |
+
(r'(?i)(<)(templatedata)\b', bygroups(
|
| 1251 |
+
Punctuation, Name.Tag), ('tag-templatedata', 'tag-inner')),
|
| 1252 |
+
# <gallery>
|
| 1253 |
+
(r'(?i)(<)(gallery)\b', bygroups(
|
| 1254 |
+
Punctuation, Name.Tag), ('tag-gallery', 'tag-inner')),
|
| 1255 |
+
# <graph>
|
| 1256 |
+
(r'(?i)(<)(gallery)\b', bygroups(
|
| 1257 |
+
Punctuation, Name.Tag), ('tag-graph', 'tag-inner')),
|
| 1258 |
+
# <dynamicpagelist>
|
| 1259 |
+
(r'(?i)(<)(dynamicpagelist)\b', bygroups(
|
| 1260 |
+
Punctuation, Name.Tag), ('tag-dynamicpagelist', 'tag-inner')),
|
| 1261 |
+
# <inputbox>
|
| 1262 |
+
(r'(?i)(<)(inputbox)\b', bygroups(
|
| 1263 |
+
Punctuation, Name.Tag), ('tag-inputbox', 'tag-inner')),
|
| 1264 |
+
# <rss>
|
| 1265 |
+
(r'(?i)(<)(rss)\b', bygroups(
|
| 1266 |
+
Punctuation, Name.Tag), ('tag-rss', 'tag-inner')),
|
| 1267 |
+
# <imagemap>
|
| 1268 |
+
(r'(?i)(<)(imagemap)\b', bygroups(
|
| 1269 |
+
Punctuation, Name.Tag), ('tag-imagemap', 'tag-inner')),
|
| 1270 |
+
# <syntaxhighlight>
|
| 1271 |
+
(r'(?i)(</)(syntaxhighlight)\b(\s*)(>)',
|
| 1272 |
+
bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)),
|
| 1273 |
+
(r'(?si)(<)(syntaxhighlight)\b([^>]*?(?<!/)>.*?)(?=</\2\s*>)',
|
| 1274 |
+
bygroups(Punctuation, Name.Tag, handle_syntaxhighlight)),
|
| 1275 |
+
# <syntaxhighlight>: Fallback case for self-closing tags
|
| 1276 |
+
(r'(?i)(<)(syntaxhighlight)\b(\s*?)((?:[^>]|-->)*?)(/\s*?(?<!--)>)', bygroups(
|
| 1277 |
+
Punctuation, Name.Tag, Whitespace, using(this, state=['root', 'attr']), Punctuation)),
|
| 1278 |
+
# <source>
|
| 1279 |
+
(r'(?i)(</)(source)\b(\s*)(>)',
|
| 1280 |
+
bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)),
|
| 1281 |
+
(r'(?si)(<)(source)\b([^>]*?(?<!/)>.*?)(?=</\2\s*>)',
|
| 1282 |
+
bygroups(Punctuation, Name.Tag, handle_syntaxhighlight)),
|
| 1283 |
+
# <source>: Fallback case for self-closing tags
|
| 1284 |
+
(r'(?i)(<)(source)\b(\s*?)((?:[^>]|-->)*?)(/\s*?(?<!--)>)', bygroups(
|
| 1285 |
+
Punctuation, Name.Tag, Whitespace, using(this, state=['root', 'attr']), Punctuation)),
|
| 1286 |
+
# <score>
|
| 1287 |
+
(r'(?i)(</)(score)\b(\s*)(>)',
|
| 1288 |
+
bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)),
|
| 1289 |
+
(r'(?si)(<)(score)\b([^>]*?(?<!/)>.*?)(?=</\2\s*>)',
|
| 1290 |
+
bygroups(Punctuation, Name.Tag, handle_score)),
|
| 1291 |
+
# <score>: Fallback case for self-closing tags
|
| 1292 |
+
(r'(?i)(<)(score)\b(\s*?)((?:[^>]|-->)*?)(/\s*?(?<!--)>)', bygroups(
|
| 1293 |
+
Punctuation, Name.Tag, Whitespace, using(this, state=['root', 'attr']), Punctuation)),
|
| 1294 |
+
# Other parser tags
|
| 1295 |
+
(r'(?i)(<)({})\b'.format('|'.join(parser_tags)),
|
| 1296 |
+
bygroups(Punctuation, Name.Tag), 'tag-inner-ordinary'),
|
| 1297 |
+
(r'(?i)(</)({})\b(\s*)(>)'.format('|'.join(parser_tags)),
|
| 1298 |
+
bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)),
|
| 1299 |
+
# LanguageConverter markups
|
| 1300 |
+
(
|
| 1301 |
+
r"""(?xi)
|
| 1302 |
+
(-\{{) # Use {{ to escape format()
|
| 1303 |
+
([^|]) (\|)
|
| 1304 |
+
(?:
|
| 1305 |
+
(?: ([^;]*?) (=>))?
|
| 1306 |
+
(\s* (?:{variants}) \s*) (:)
|
| 1307 |
+
)?
|
| 1308 |
+
""".format(variants='|'.join(variant_langs)),
|
| 1309 |
+
bygroups(Punctuation, Keyword, Punctuation,
|
| 1310 |
+
using(this, state=['root', 'lc-raw']),
|
| 1311 |
+
Operator, Name.Label, Punctuation),
|
| 1312 |
+
'lc-inner'
|
| 1313 |
+
),
|
| 1314 |
+
# LanguageConverter markups: composite conversion grammar
|
| 1315 |
+
(
|
| 1316 |
+
r"""(?xi)
|
| 1317 |
+
(-\{)
|
| 1318 |
+
([a-z\s;-]*?) (\|)
|
| 1319 |
+
""",
|
| 1320 |
+
bygroups(Punctuation,
|
| 1321 |
+
using(this, state=['root', 'lc-flag']),
|
| 1322 |
+
Punctuation),
|
| 1323 |
+
'lc-raw'
|
| 1324 |
+
),
|
| 1325 |
+
# LanguageConverter markups: fallbacks
|
| 1326 |
+
(
|
| 1327 |
+
r"""(?xi)
|
| 1328 |
+
(-\{{) (?!\{{) # Use {{ to escape format()
|
| 1329 |
+
(?: (\s* (?:{variants}) \s*) (:))?
|
| 1330 |
+
""".format(variants='|'.join(variant_langs)),
|
| 1331 |
+
bygroups(Punctuation, Name.Label, Punctuation),
|
| 1332 |
+
'lc-inner'
|
| 1333 |
+
),
|
| 1334 |
+
],
|
| 1335 |
+
'wikilink-name': [
|
| 1336 |
+
include('replaceable'),
|
| 1337 |
+
(r'[^{<]+', Name.Tag),
|
| 1338 |
+
(r'(?s).', Name.Tag),
|
| 1339 |
+
],
|
| 1340 |
+
'wikilink-inner': [
|
| 1341 |
+
# Quit in case of another wikilink
|
| 1342 |
+
(r'(?=\[\[)', Punctuation, '#pop'),
|
| 1343 |
+
(r'\]\]', Punctuation, '#pop'),
|
| 1344 |
+
include('inline'),
|
| 1345 |
+
include('text'),
|
| 1346 |
+
],
|
| 1347 |
+
'medialink-inner': [
|
| 1348 |
+
(r'\]\]', Punctuation, '#pop'),
|
| 1349 |
+
(r'(\|)([^\n=|]*)(=)',
|
| 1350 |
+
bygroups(Punctuation, Name.Attribute, Operator)),
|
| 1351 |
+
(r'\|', Punctuation),
|
| 1352 |
+
include('inline'),
|
| 1353 |
+
include('text'),
|
| 1354 |
+
],
|
| 1355 |
+
'quote-common': [
|
| 1356 |
+
# Quit in case of link/template endings
|
| 1357 |
+
(r'(?=\]\]|\{\{|\}\})', Punctuation, '#pop'),
|
| 1358 |
+
(r'\n', Text, '#pop'),
|
| 1359 |
+
],
|
| 1360 |
+
'inline-italic': [
|
| 1361 |
+
include('quote-common'),
|
| 1362 |
+
(r"('')(''')(?!')", bygroups(Generic.Emph,
|
| 1363 |
+
Generic.Strong), ('#pop', 'inline-bold')),
|
| 1364 |
+
(r"'''(?!')", Generic.EmphStrong, ('#pop', 'inline-italic-bold')),
|
| 1365 |
+
(r"''(?!')", Generic.Emph, '#pop'),
|
| 1366 |
+
include('inline'),
|
| 1367 |
+
include('text-italic'),
|
| 1368 |
+
],
|
| 1369 |
+
'inline-bold': [
|
| 1370 |
+
include('quote-common'),
|
| 1371 |
+
(r"(''')('')(?!')", bygroups(
|
| 1372 |
+
Generic.Strong, Generic.Emph), ('#pop', 'inline-italic')),
|
| 1373 |
+
(r"'''(?!')", Generic.Strong, '#pop'),
|
| 1374 |
+
(r"''(?!')", Generic.EmphStrong, ('#pop', 'inline-bold-italic')),
|
| 1375 |
+
include('inline'),
|
| 1376 |
+
include('text-bold'),
|
| 1377 |
+
],
|
| 1378 |
+
'inline-bold-italic': [
|
| 1379 |
+
include('quote-common'),
|
| 1380 |
+
(r"('')(''')(?!')", bygroups(Generic.EmphStrong,
|
| 1381 |
+
Generic.Strong), '#pop'),
|
| 1382 |
+
(r"'''(?!')", Generic.EmphStrong, ('#pop', 'inline-italic')),
|
| 1383 |
+
(r"''(?!')", Generic.EmphStrong, ('#pop', 'inline-bold')),
|
| 1384 |
+
include('inline'),
|
| 1385 |
+
include('text-bold-italic'),
|
| 1386 |
+
],
|
| 1387 |
+
'inline-italic-bold': [
|
| 1388 |
+
include('quote-common'),
|
| 1389 |
+
(r"(''')('')(?!')", bygroups(
|
| 1390 |
+
Generic.EmphStrong, Generic.Emph), '#pop'),
|
| 1391 |
+
(r"'''(?!')", Generic.EmphStrong, ('#pop', 'inline-italic')),
|
| 1392 |
+
(r"''(?!')", Generic.EmphStrong, ('#pop', 'inline-bold')),
|
| 1393 |
+
include('inline'),
|
| 1394 |
+
include('text-bold-italic'),
|
| 1395 |
+
],
|
| 1396 |
+
'lc-flag': [
|
| 1397 |
+
(r'\s+', Whitespace),
|
| 1398 |
+
(r';', Punctuation),
|
| 1399 |
+
*text_rules(Keyword),
|
| 1400 |
+
],
|
| 1401 |
+
'lc-inner': [
|
| 1402 |
+
(
|
| 1403 |
+
r"""(?xi)
|
| 1404 |
+
(;)
|
| 1405 |
+
(?: ([^;]*?) (=>))?
|
| 1406 |
+
(\s* (?:{variants}) \s*) (:)
|
| 1407 |
+
""".format(variants='|'.join(variant_langs)),
|
| 1408 |
+
bygroups(Punctuation, using(this, state=['root', 'lc-raw']),
|
| 1409 |
+
Operator, Name.Label, Punctuation)
|
| 1410 |
+
),
|
| 1411 |
+
(r';?\s*?\}-', Punctuation, '#pop'),
|
| 1412 |
+
include('inline'),
|
| 1413 |
+
include('text'),
|
| 1414 |
+
],
|
| 1415 |
+
'lc-raw': [
|
| 1416 |
+
(r'\}-', Punctuation, '#pop'),
|
| 1417 |
+
include('inline'),
|
| 1418 |
+
include('text'),
|
| 1419 |
+
],
|
| 1420 |
+
'replaceable': [
|
| 1421 |
+
# Comments
|
| 1422 |
+
(r'<!--[\s\S]*?(?:-->|\Z)', Comment.Multiline),
|
| 1423 |
+
# Parameters
|
| 1424 |
+
(
|
| 1425 |
+
r"""(?x)
|
| 1426 |
+
(\{{3})
|
| 1427 |
+
([^|]*?)
|
| 1428 |
+
(?=\}{3}|\|)
|
| 1429 |
+
""",
|
| 1430 |
+
bygroups(Punctuation, Name.Variable),
|
| 1431 |
+
'parameter-inner',
|
| 1432 |
+
),
|
| 1433 |
+
# Magic variables
|
| 1434 |
+
(r'(?i)(\{{\{{)(\s*)({})(\s*)(\}}\}})'.format('|'.join(magic_vars_i)),
|
| 1435 |
+
bygroups(Punctuation, Whitespace, Name.Function, Whitespace, Punctuation)),
|
| 1436 |
+
(r'(\{{\{{)(\s*)({})(\s*)(\}}\}})'.format('|'.join(magic_vars)),
|
| 1437 |
+
bygroups(Punctuation, Whitespace, Name.Function, Whitespace, Punctuation)),
|
| 1438 |
+
# Parser functions & templates
|
| 1439 |
+
(r'\{\{', Punctuation, 'template-begin-space'),
|
| 1440 |
+
# <tvar> legacy syntax
|
| 1441 |
+
(r'(?i)(<)(tvar)\b(\|)([^>]*?)(>)', bygroups(Punctuation,
|
| 1442 |
+
Name.Tag, Punctuation, String, Punctuation)),
|
| 1443 |
+
(r'</>', Punctuation, '#pop'),
|
| 1444 |
+
# <tvar>
|
| 1445 |
+
(r'(?i)(<)(tvar)\b', bygroups(Punctuation, Name.Tag), 'tag-inner-ordinary'),
|
| 1446 |
+
(r'(?i)(</)(tvar)\b(\s*)(>)',
|
| 1447 |
+
bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)),
|
| 1448 |
+
],
|
| 1449 |
+
'parameter-inner': [
|
| 1450 |
+
(r'\}{3}', Punctuation, '#pop'),
|
| 1451 |
+
(r'\|', Punctuation),
|
| 1452 |
+
include('inline'),
|
| 1453 |
+
include('text'),
|
| 1454 |
+
],
|
| 1455 |
+
'template-begin-space': [
|
| 1456 |
+
# Templates allow line breaks at the beginning, and due to how MediaWiki handles
|
| 1457 |
+
# comments, an extra state is required to handle things like {{\n<!---->\n name}}
|
| 1458 |
+
(r'<!--[\s\S]*?(?:-->|\Z)', Comment.Multiline),
|
| 1459 |
+
(r'\s+', Whitespace),
|
| 1460 |
+
# Parser functions
|
| 1461 |
+
(
|
| 1462 |
+
r'(?i)(\#[{}]*?|{})(:)'.format(title_char,
|
| 1463 |
+
'|'.join(parser_functions_i)),
|
| 1464 |
+
bygroups(Name.Function, Punctuation), ('#pop', 'template-inner')
|
| 1465 |
+
),
|
| 1466 |
+
(
|
| 1467 |
+
r'({})(:)'.format('|'.join(parser_functions)),
|
| 1468 |
+
bygroups(Name.Function, Punctuation), ('#pop', 'template-inner')
|
| 1469 |
+
),
|
| 1470 |
+
# Templates
|
| 1471 |
+
(
|
| 1472 |
+
rf'(?i)([{title_char}]*?)(:)',
|
| 1473 |
+
bygroups(Name.Namespace, Punctuation), ('#pop', 'template-name')
|
| 1474 |
+
),
|
| 1475 |
+
default(('#pop', 'template-name'),),
|
| 1476 |
+
],
|
| 1477 |
+
'template-name': [
|
| 1478 |
+
(r'(\s*?)(\|)', bygroups(Text, Punctuation), ('#pop', 'template-inner')),
|
| 1479 |
+
(r'\}\}', Punctuation, '#pop'),
|
| 1480 |
+
(r'\n', Text, '#pop'),
|
| 1481 |
+
include('replaceable'),
|
| 1482 |
+
*text_rules(Name.Tag),
|
| 1483 |
+
],
|
| 1484 |
+
'template-inner': [
|
| 1485 |
+
(r'\}\}', Punctuation, '#pop'),
|
| 1486 |
+
(r'\|', Punctuation),
|
| 1487 |
+
(
|
| 1488 |
+
r"""(?x)
|
| 1489 |
+
(?<=\|)
|
| 1490 |
+
( (?: (?! \{\{ | \}\} )[^=\|<])*? ) # Exclude templates and tags
|
| 1491 |
+
(=)
|
| 1492 |
+
""",
|
| 1493 |
+
bygroups(Name.Label, Operator)
|
| 1494 |
+
),
|
| 1495 |
+
include('inline'),
|
| 1496 |
+
include('text'),
|
| 1497 |
+
],
|
| 1498 |
+
'table': [
|
| 1499 |
+
# Use [ \t\n\r\0\x0B] instead of \s to follow PHP trim() behavior
|
| 1500 |
+
# Endings
|
| 1501 |
+
(r'^([ \t\n\r\0\x0B]*?)(\|\})',
|
| 1502 |
+
bygroups(Whitespace, Punctuation), '#pop'),
|
| 1503 |
+
# Table rows
|
| 1504 |
+
(r'^([ \t\n\r\0\x0B]*?)(\|-+)(.*)$', bygroups(Whitespace, Punctuation,
|
| 1505 |
+
using(this, state=['root', 'attr']))),
|
| 1506 |
+
# Captions
|
| 1507 |
+
(
|
| 1508 |
+
r"""(?x)
|
| 1509 |
+
^([ \t\n\r\0\x0B]*?)(\|\+)
|
| 1510 |
+
# Exclude links, template and tags
|
| 1511 |
+
(?: ( (?: (?! \[\[ | \{\{ )[^|\n<] )*? )(\|) )?
|
| 1512 |
+
(.*?)$
|
| 1513 |
+
""",
|
| 1514 |
+
bygroups(Whitespace, Punctuation, using(this, state=[
|
| 1515 |
+
'root', 'attr']), Punctuation, Generic.Heading),
|
| 1516 |
+
),
|
| 1517 |
+
# Table data
|
| 1518 |
+
(
|
| 1519 |
+
r"""(?x)
|
| 1520 |
+
( ^(?:[ \t\n\r\0\x0B]*?)\| | \|\| )
|
| 1521 |
+
(?: ( (?: (?! \[\[ | \{\{ )[^|\n<] )*? )(\|)(?!\|) )?
|
| 1522 |
+
""",
|
| 1523 |
+
bygroups(Punctuation, using(this, state=[
|
| 1524 |
+
'root', 'attr']), Punctuation),
|
| 1525 |
+
),
|
| 1526 |
+
# Table headers
|
| 1527 |
+
(
|
| 1528 |
+
r"""(?x)
|
| 1529 |
+
( ^(?:[ \t\n\r\0\x0B]*?)! )
|
| 1530 |
+
(?: ( (?: (?! \[\[ | \{\{ )[^|\n<] )*? )(\|)(?!\|) )?
|
| 1531 |
+
""",
|
| 1532 |
+
bygroups(Punctuation, using(this, state=[
|
| 1533 |
+
'root', 'attr']), Punctuation),
|
| 1534 |
+
'table-header',
|
| 1535 |
+
),
|
| 1536 |
+
include('list'),
|
| 1537 |
+
include('inline'),
|
| 1538 |
+
include('text'),
|
| 1539 |
+
],
|
| 1540 |
+
'table-header': [
|
| 1541 |
+
# Requires another state for || handling inside headers
|
| 1542 |
+
(r'\n', Text, '#pop'),
|
| 1543 |
+
(
|
| 1544 |
+
r"""(?x)
|
| 1545 |
+
(!!|\|\|)
|
| 1546 |
+
(?:
|
| 1547 |
+
( (?: (?! \[\[ | \{\{ )[^|\n<] )*? )
|
| 1548 |
+
(\|)(?!\|)
|
| 1549 |
+
)?
|
| 1550 |
+
""",
|
| 1551 |
+
bygroups(Punctuation, using(this, state=[
|
| 1552 |
+
'root', 'attr']), Punctuation)
|
| 1553 |
+
),
|
| 1554 |
+
*text_rules(Generic.Subheading),
|
| 1555 |
+
],
|
| 1556 |
+
'entity': [
|
| 1557 |
+
(r'&\S*?;', Name.Entity),
|
| 1558 |
+
],
|
| 1559 |
+
'dt': [
|
| 1560 |
+
(r'\n', Text, '#pop'),
|
| 1561 |
+
include('inline'),
|
| 1562 |
+
(r':', Keyword, '#pop'),
|
| 1563 |
+
include('text'),
|
| 1564 |
+
],
|
| 1565 |
+
'extlink-inner': [
|
| 1566 |
+
(r'\]', Punctuation, '#pop'),
|
| 1567 |
+
include('inline'),
|
| 1568 |
+
include('text'),
|
| 1569 |
+
],
|
| 1570 |
+
'nowiki-ish': [
|
| 1571 |
+
include('entity'),
|
| 1572 |
+
include('text'),
|
| 1573 |
+
],
|
| 1574 |
+
'attr': [
|
| 1575 |
+
include('replaceable'),
|
| 1576 |
+
(r'\s+', Whitespace),
|
| 1577 |
+
(r'(=)(\s*)(")', bygroups(Operator, Whitespace, String.Double), 'attr-val-2'),
|
| 1578 |
+
(r"(=)(\s*)(')", bygroups(Operator, Whitespace, String.Single), 'attr-val-1'),
|
| 1579 |
+
(r'(=)(\s*)', bygroups(Operator, Whitespace), 'attr-val-0'),
|
| 1580 |
+
(r'[\w:-]+', Name.Attribute),
|
| 1581 |
+
|
| 1582 |
+
],
|
| 1583 |
+
'attr-val-0': [
|
| 1584 |
+
(r'\s', Whitespace, '#pop'),
|
| 1585 |
+
include('replaceable'),
|
| 1586 |
+
*text_rules(String),
|
| 1587 |
+
],
|
| 1588 |
+
'attr-val-1': [
|
| 1589 |
+
(r"'", String.Single, '#pop'),
|
| 1590 |
+
include('replaceable'),
|
| 1591 |
+
*text_rules(String.Single),
|
| 1592 |
+
],
|
| 1593 |
+
'attr-val-2': [
|
| 1594 |
+
(r'"', String.Double, '#pop'),
|
| 1595 |
+
include('replaceable'),
|
| 1596 |
+
*text_rules(String.Double),
|
| 1597 |
+
],
|
| 1598 |
+
'tag-inner-ordinary': [
|
| 1599 |
+
(r'/?\s*>', Punctuation, '#pop'),
|
| 1600 |
+
include('tag-attr'),
|
| 1601 |
+
],
|
| 1602 |
+
'tag-inner': [
|
| 1603 |
+
# Return to root state for self-closing tags
|
| 1604 |
+
(r'/\s*>', Punctuation, '#pop:2'),
|
| 1605 |
+
(r'\s*>', Punctuation, '#pop'),
|
| 1606 |
+
include('tag-attr'),
|
| 1607 |
+
],
|
| 1608 |
+
# There states below are just like their non-tag variants, the key difference is
|
| 1609 |
+
# they forcibly quit when encountering tag closing markup
|
| 1610 |
+
'tag-attr': [
|
| 1611 |
+
include('replaceable'),
|
| 1612 |
+
(r'\s+', Whitespace),
|
| 1613 |
+
(r'(=)(\s*)(")', bygroups(Operator,
|
| 1614 |
+
Whitespace, String.Double), 'tag-attr-val-2'),
|
| 1615 |
+
(r"(=)(\s*)(')", bygroups(Operator,
|
| 1616 |
+
Whitespace, String.Single), 'tag-attr-val-1'),
|
| 1617 |
+
(r'(=)(\s*)', bygroups(Operator, Whitespace), 'tag-attr-val-0'),
|
| 1618 |
+
(r'[\w:-]+', Name.Attribute),
|
| 1619 |
+
|
| 1620 |
+
],
|
| 1621 |
+
'tag-attr-val-0': [
|
| 1622 |
+
(r'\s', Whitespace, '#pop'),
|
| 1623 |
+
(r'/?>', Punctuation, '#pop:2'),
|
| 1624 |
+
include('replaceable'),
|
| 1625 |
+
*text_rules(String),
|
| 1626 |
+
],
|
| 1627 |
+
'tag-attr-val-1': [
|
| 1628 |
+
(r"'", String.Single, '#pop'),
|
| 1629 |
+
(r'/?>', Punctuation, '#pop:2'),
|
| 1630 |
+
include('replaceable'),
|
| 1631 |
+
*text_rules(String.Single),
|
| 1632 |
+
],
|
| 1633 |
+
'tag-attr-val-2': [
|
| 1634 |
+
(r'"', String.Double, '#pop'),
|
| 1635 |
+
(r'/?>', Punctuation, '#pop:2'),
|
| 1636 |
+
include('replaceable'),
|
| 1637 |
+
*text_rules(String.Double),
|
| 1638 |
+
],
|
| 1639 |
+
'tag-nowiki': nowiki_tag_rules('nowiki'),
|
| 1640 |
+
'tag-pre': nowiki_tag_rules('pre'),
|
| 1641 |
+
'tag-categorytree': plaintext_tag_rules('categorytree'),
|
| 1642 |
+
'tag-dynamicpagelist': plaintext_tag_rules('dynamicpagelist'),
|
| 1643 |
+
'tag-hiero': plaintext_tag_rules('hiero'),
|
| 1644 |
+
'tag-inputbox': plaintext_tag_rules('inputbox'),
|
| 1645 |
+
'tag-imagemap': plaintext_tag_rules('imagemap'),
|
| 1646 |
+
'tag-charinsert': plaintext_tag_rules('charinsert'),
|
| 1647 |
+
'tag-timeline': plaintext_tag_rules('timeline'),
|
| 1648 |
+
'tag-gallery': plaintext_tag_rules('gallery'),
|
| 1649 |
+
'tag-graph': plaintext_tag_rules('graph'),
|
| 1650 |
+
'tag-rss': plaintext_tag_rules('rss'),
|
| 1651 |
+
'tag-math': delegate_tag_rules('math', TexLexer, state='math'),
|
| 1652 |
+
'tag-chem': delegate_tag_rules('chem', TexLexer, state='math'),
|
| 1653 |
+
'tag-ce': delegate_tag_rules('ce', TexLexer, state='math'),
|
| 1654 |
+
'tag-templatedata': delegate_tag_rules('templatedata', JsonLexer),
|
| 1655 |
+
'text-italic': text_rules(Generic.Emph),
|
| 1656 |
+
'text-bold': text_rules(Generic.Strong),
|
| 1657 |
+
'text-bold-italic': text_rules(Generic.EmphStrong),
|
| 1658 |
+
'text': text_rules(Text),
|
| 1659 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/maxima.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.maxima
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the computer algebra system Maxima.
|
| 6 |
+
|
| 7 |
+
Derived from pygments/lexers/algebra.py.
|
| 8 |
+
|
| 9 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 10 |
+
:license: BSD, see LICENSE for details.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import re
|
| 14 |
+
|
| 15 |
+
from pygments.lexer import RegexLexer, bygroups, words
|
| 16 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 17 |
+
Number, Punctuation
|
| 18 |
+
|
| 19 |
+
__all__ = ['MaximaLexer']
|
| 20 |
+
|
| 21 |
+
class MaximaLexer(RegexLexer):
|
| 22 |
+
"""
|
| 23 |
+
A Maxima lexer.
|
| 24 |
+
Derived from pygments.lexers.MuPADLexer.
|
| 25 |
+
"""
|
| 26 |
+
name = 'Maxima'
|
| 27 |
+
url = 'http://maxima.sourceforge.net'
|
| 28 |
+
aliases = ['maxima', 'macsyma']
|
| 29 |
+
filenames = ['*.mac', '*.max']
|
| 30 |
+
version_added = '2.11'
|
| 31 |
+
|
| 32 |
+
keywords = ('if', 'then', 'else', 'elseif',
|
| 33 |
+
'do', 'while', 'repeat', 'until',
|
| 34 |
+
'for', 'from', 'to', 'downto', 'step', 'thru')
|
| 35 |
+
|
| 36 |
+
constants = ('%pi', '%e', '%phi', '%gamma', '%i',
|
| 37 |
+
'und', 'ind', 'infinity', 'inf', 'minf',
|
| 38 |
+
'true', 'false', 'unknown', 'done')
|
| 39 |
+
|
| 40 |
+
operators = (r'.', r':', r'=', r'#',
|
| 41 |
+
r'+', r'-', r'*', r'/', r'^',
|
| 42 |
+
r'@', r'>', r'<', r'|', r'!', r"'")
|
| 43 |
+
|
| 44 |
+
operator_words = ('and', 'or', 'not')
|
| 45 |
+
|
| 46 |
+
tokens = {
|
| 47 |
+
'root': [
|
| 48 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 49 |
+
(r'"(?:[^"\\]|\\.)*"', String),
|
| 50 |
+
(r'\(|\)|\[|\]|\{|\}', Punctuation),
|
| 51 |
+
(r'[,;$]', Punctuation),
|
| 52 |
+
(words (constants), Name.Constant),
|
| 53 |
+
(words (keywords), Keyword),
|
| 54 |
+
(words (operators), Operator),
|
| 55 |
+
(words (operator_words), Operator.Word),
|
| 56 |
+
(r'''(?x)
|
| 57 |
+
((?:[a-zA-Z_#][\w#]*|`[^`]*`)
|
| 58 |
+
(?:::[a-zA-Z_#][\w#]*|`[^`]*`)*)(\s*)([(])''',
|
| 59 |
+
bygroups(Name.Function, Text.Whitespace, Punctuation)),
|
| 60 |
+
(r'''(?x)
|
| 61 |
+
(?:[a-zA-Z_#%][\w#%]*|`[^`]*`)
|
| 62 |
+
(?:::[a-zA-Z_#%][\w#%]*|`[^`]*`)*''', Name.Variable),
|
| 63 |
+
(r'[-+]?(\d*\.\d+([bdefls][-+]?\d+)?|\d+(\.\d*)?[bdefls][-+]?\d+)', Number.Float),
|
| 64 |
+
(r'[-+]?\d+', Number.Integer),
|
| 65 |
+
(r'\s+', Text.Whitespace),
|
| 66 |
+
(r'.', Text)
|
| 67 |
+
],
|
| 68 |
+
'comment': [
|
| 69 |
+
(r'[^*/]+', Comment.Multiline),
|
| 70 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 71 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 72 |
+
(r'[*/]', Comment.Multiline)
|
| 73 |
+
]
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
def analyse_text (text):
|
| 77 |
+
strength = 0.0
|
| 78 |
+
# Input expression terminator.
|
| 79 |
+
if re.search (r'\$\s*$', text, re.MULTILINE):
|
| 80 |
+
strength += 0.05
|
| 81 |
+
# Function definition operator.
|
| 82 |
+
if ':=' in text:
|
| 83 |
+
strength += 0.02
|
| 84 |
+
return strength
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/minecraft.py
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.minecraft
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Minecraft related languages.
|
| 6 |
+
|
| 7 |
+
SNBT. A data communication format used in Minecraft.
|
| 8 |
+
wiki: https://minecraft.wiki/w/NBT_format
|
| 9 |
+
|
| 10 |
+
MCFunction. The Function file for Minecraft Data packs and Add-ons.
|
| 11 |
+
official: https://learn.microsoft.com/en-us/minecraft/creator/documents/functionsintroduction
|
| 12 |
+
wiki: https://minecraft.wiki/w/Function
|
| 13 |
+
|
| 14 |
+
MCSchema. A kind of data Schema for Minecraft Add-on Development.
|
| 15 |
+
official: https://learn.microsoft.com/en-us/minecraft/creator/reference/content/schemasreference/
|
| 16 |
+
community example: https://www.mcbe-dev.net/addons/data-driven/manifest.html
|
| 17 |
+
|
| 18 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 19 |
+
:license: BSD, see LICENSE for details.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
from pygments.lexer import RegexLexer, default, include, bygroups
|
| 23 |
+
from pygments.token import Comment, Keyword, Literal, Name, Number, Operator, \
|
| 24 |
+
Punctuation, String, Text, Whitespace
|
| 25 |
+
|
| 26 |
+
__all__ = ['SNBTLexer', 'MCFunctionLexer', 'MCSchemaLexer']
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class SNBTLexer(RegexLexer):
|
| 30 |
+
"""Lexer for stringified NBT, a data format used in Minecraft
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
name = "SNBT"
|
| 34 |
+
url = "https://minecraft.wiki/w/NBT_format"
|
| 35 |
+
aliases = ["snbt"]
|
| 36 |
+
filenames = ["*.snbt"]
|
| 37 |
+
mimetypes = ["text/snbt"]
|
| 38 |
+
version_added = '2.12'
|
| 39 |
+
|
| 40 |
+
tokens = {
|
| 41 |
+
"root": [
|
| 42 |
+
# We only look for the open bracket here since square bracket
|
| 43 |
+
# is only valid in NBT pathing (which is a mcfunction idea).
|
| 44 |
+
(r"\{", Punctuation, "compound"),
|
| 45 |
+
(r"[^\{]+", Text),
|
| 46 |
+
],
|
| 47 |
+
|
| 48 |
+
"whitespace": [
|
| 49 |
+
(r"\s+", Whitespace),
|
| 50 |
+
],
|
| 51 |
+
|
| 52 |
+
"operators": [
|
| 53 |
+
(r"[,:;]", Punctuation),
|
| 54 |
+
],
|
| 55 |
+
|
| 56 |
+
"literals": [
|
| 57 |
+
(r"(true|false)", Keyword.Constant),
|
| 58 |
+
(r"-?\d+[eE]-?\d+", Number.Float),
|
| 59 |
+
(r"-?\d*\.\d+[fFdD]?", Number.Float),
|
| 60 |
+
(r"-?\d+[bBsSlLfFdD]?", Number.Integer),
|
| 61 |
+
|
| 62 |
+
# Separate states for both types of strings so they don't entangle
|
| 63 |
+
(r'"', String.Double, "literals.string_double"),
|
| 64 |
+
(r"'", String.Single, "literals.string_single"),
|
| 65 |
+
],
|
| 66 |
+
"literals.string_double": [
|
| 67 |
+
(r"\\.", String.Escape),
|
| 68 |
+
(r'[^\\"\n]+', String.Double),
|
| 69 |
+
(r'"', String.Double, "#pop"),
|
| 70 |
+
],
|
| 71 |
+
"literals.string_single": [
|
| 72 |
+
(r"\\.", String.Escape),
|
| 73 |
+
(r"[^\\'\n]+", String.Single),
|
| 74 |
+
(r"'", String.Single, "#pop"),
|
| 75 |
+
],
|
| 76 |
+
|
| 77 |
+
"compound": [
|
| 78 |
+
# this handles the unquoted snbt keys
|
| 79 |
+
# note: stringified keys still work
|
| 80 |
+
(r"[A-Z_a-z]+", Name.Attribute),
|
| 81 |
+
include("operators"),
|
| 82 |
+
include("whitespace"),
|
| 83 |
+
include("literals"),
|
| 84 |
+
(r"\{", Punctuation, "#push"),
|
| 85 |
+
(r"\[", Punctuation, "list"),
|
| 86 |
+
(r"\}", Punctuation, "#pop"),
|
| 87 |
+
],
|
| 88 |
+
|
| 89 |
+
"list": [
|
| 90 |
+
(r"[A-Z_a-z]+", Name.Attribute),
|
| 91 |
+
include("literals"),
|
| 92 |
+
include("operators"),
|
| 93 |
+
include("whitespace"),
|
| 94 |
+
(r"\[", Punctuation, "#push"),
|
| 95 |
+
(r"\{", Punctuation, "compound"),
|
| 96 |
+
(r"\]", Punctuation, "#pop"),
|
| 97 |
+
],
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
class MCFunctionLexer(RegexLexer):
|
| 102 |
+
"""Lexer for the mcfunction scripting language used in Minecraft.
|
| 103 |
+
|
| 104 |
+
Modelled somewhat after the `GitHub mcfunction grammar <https://github.com/Arcensoth/language-mcfunction>`_.
|
| 105 |
+
"""
|
| 106 |
+
|
| 107 |
+
name = "MCFunction"
|
| 108 |
+
url = "https://minecraft.wiki/w/Commands"
|
| 109 |
+
aliases = ["mcfunction", "mcf"]
|
| 110 |
+
filenames = ["*.mcfunction"]
|
| 111 |
+
mimetypes = ["text/mcfunction"]
|
| 112 |
+
version_added = '2.12'
|
| 113 |
+
|
| 114 |
+
# Used to denotate the start of a block comment, borrowed from Github's mcfunction
|
| 115 |
+
_block_comment_prefix = "[>!]"
|
| 116 |
+
|
| 117 |
+
tokens = {
|
| 118 |
+
"root": [
|
| 119 |
+
include("names"),
|
| 120 |
+
include("comments"),
|
| 121 |
+
include("literals"),
|
| 122 |
+
include("whitespace"),
|
| 123 |
+
include("property"),
|
| 124 |
+
include("operators"),
|
| 125 |
+
include("selectors"),
|
| 126 |
+
],
|
| 127 |
+
|
| 128 |
+
"names": [
|
| 129 |
+
# The start of a command (either beginning of line OR after the run keyword)
|
| 130 |
+
# We don't encode a list of keywords since mods, plugins, or even pre-processors
|
| 131 |
+
# may add new commands, so we have a 'close-enough' regex which catches them.
|
| 132 |
+
(r"^(\s*)([a-z_]+)", bygroups(Whitespace, Name.Builtin)),
|
| 133 |
+
(r"(?<=run)\s+[a-z_]+", Name.Builtin),
|
| 134 |
+
|
| 135 |
+
# UUID
|
| 136 |
+
(r"\b[0-9a-fA-F]+(?:-[0-9a-fA-F]+){4}\b", Name.Variable),
|
| 137 |
+
include("resource-name"),
|
| 138 |
+
# normal command names and scoreboards
|
| 139 |
+
# there's no way to know the differences unfortuntely
|
| 140 |
+
(r"[A-Za-z_][\w.#%$]+", Keyword.Constant),
|
| 141 |
+
(r"[#%$][\w.#%$]+", Name.Variable.Magic),
|
| 142 |
+
],
|
| 143 |
+
|
| 144 |
+
"resource-name": [
|
| 145 |
+
# resource names have to be lowercase
|
| 146 |
+
(r"#?[a-z_][a-z_.-]*:[a-z0-9_./-]+", Name.Function),
|
| 147 |
+
# similar to above except optional `:``
|
| 148 |
+
# a `/` must be present "somewhere"
|
| 149 |
+
(r"#?[a-z0-9_\.\-]+\/[a-z0-9_\.\-\/]+", Name.Function),
|
| 150 |
+
],
|
| 151 |
+
|
| 152 |
+
"whitespace": [
|
| 153 |
+
(r"\s+", Whitespace),
|
| 154 |
+
],
|
| 155 |
+
|
| 156 |
+
"comments": [
|
| 157 |
+
(rf"^\s*(#{_block_comment_prefix})", Comment.Multiline,
|
| 158 |
+
("comments.block", "comments.block.emphasized")),
|
| 159 |
+
(r"#.*$", Comment.Single),
|
| 160 |
+
],
|
| 161 |
+
"comments.block": [
|
| 162 |
+
(rf"^\s*#{_block_comment_prefix}", Comment.Multiline,
|
| 163 |
+
"comments.block.emphasized"),
|
| 164 |
+
(r"^\s*#", Comment.Multiline, "comments.block.normal"),
|
| 165 |
+
default("#pop"),
|
| 166 |
+
],
|
| 167 |
+
"comments.block.normal": [
|
| 168 |
+
include("comments.block.special"),
|
| 169 |
+
(r"\S+", Comment.Multiline),
|
| 170 |
+
(r"\n", Text, "#pop"),
|
| 171 |
+
include("whitespace"),
|
| 172 |
+
],
|
| 173 |
+
"comments.block.emphasized": [
|
| 174 |
+
include("comments.block.special"),
|
| 175 |
+
(r"\S+", String.Doc),
|
| 176 |
+
(r"\n", Text, "#pop"),
|
| 177 |
+
include("whitespace"),
|
| 178 |
+
],
|
| 179 |
+
"comments.block.special": [
|
| 180 |
+
# Params
|
| 181 |
+
(r"@\S+", Name.Decorator),
|
| 182 |
+
|
| 183 |
+
include("resource-name"),
|
| 184 |
+
|
| 185 |
+
# Scoreboard player names
|
| 186 |
+
(r"[#%$][\w.#%$]+", Name.Variable.Magic),
|
| 187 |
+
],
|
| 188 |
+
|
| 189 |
+
"operators": [
|
| 190 |
+
(r"[\-~%^?!+*<>\\/|&=.]", Operator),
|
| 191 |
+
],
|
| 192 |
+
|
| 193 |
+
"literals": [
|
| 194 |
+
(r"\.\.", Literal),
|
| 195 |
+
(r"(true|false)", Keyword.Pseudo),
|
| 196 |
+
|
| 197 |
+
# these are like unquoted strings and appear in many places
|
| 198 |
+
(r"[A-Za-z_]+", Name.Variable.Class),
|
| 199 |
+
|
| 200 |
+
(r"[0-7]b", Number.Byte),
|
| 201 |
+
(r"[+-]?\d*\.?\d+([eE]?[+-]?\d+)?[df]?\b", Number.Float),
|
| 202 |
+
(r"[+-]?\d+\b", Number.Integer),
|
| 203 |
+
(r'"', String.Double, "literals.string-double"),
|
| 204 |
+
(r"'", String.Single, "literals.string-single"),
|
| 205 |
+
],
|
| 206 |
+
"literals.string-double": [
|
| 207 |
+
(r"\\.", String.Escape),
|
| 208 |
+
(r'[^\\"\n]+', String.Double),
|
| 209 |
+
(r'"', String.Double, "#pop"),
|
| 210 |
+
],
|
| 211 |
+
"literals.string-single": [
|
| 212 |
+
(r"\\.", String.Escape),
|
| 213 |
+
(r"[^\\'\n]+", String.Single),
|
| 214 |
+
(r"'", String.Single, "#pop"),
|
| 215 |
+
],
|
| 216 |
+
|
| 217 |
+
"selectors": [
|
| 218 |
+
(r"@[a-z]", Name.Variable),
|
| 219 |
+
],
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
## Generic Property Container
|
| 223 |
+
# There are several, differing instances where the language accepts
|
| 224 |
+
# specific contained keys or contained key, value pairings.
|
| 225 |
+
#
|
| 226 |
+
# Property Maps:
|
| 227 |
+
# - Starts with either `[` or `{`
|
| 228 |
+
# - Key separated by `:` or `=`
|
| 229 |
+
# - Deliminated by `,`
|
| 230 |
+
#
|
| 231 |
+
# Property Lists:
|
| 232 |
+
# - Starts with `[`
|
| 233 |
+
# - Deliminated by `,`
|
| 234 |
+
#
|
| 235 |
+
# For simplicity, these patterns match a generic, nestable structure
|
| 236 |
+
# which follow a key, value pattern. For normal lists, there's only keys.
|
| 237 |
+
# This allow some "illegal" structures, but we'll accept those for
|
| 238 |
+
# sake of simplicity
|
| 239 |
+
#
|
| 240 |
+
# Examples:
|
| 241 |
+
# - `[facing=up, powered=true]` (blockstate)
|
| 242 |
+
# - `[name="hello world", nbt={key: 1b}]` (selector + nbt)
|
| 243 |
+
# - `[{"text": "value"}, "literal"]` (json)
|
| 244 |
+
##
|
| 245 |
+
"property": [
|
| 246 |
+
# This state gets included in root and also several substates
|
| 247 |
+
# We do this to shortcut the starting of new properties
|
| 248 |
+
# within other properties. Lists can have sublists and compounds
|
| 249 |
+
# and values can start a new property (see the `difficult_1.txt`
|
| 250 |
+
# snippet).
|
| 251 |
+
(r"\{", Punctuation, ("property.curly", "property.key")),
|
| 252 |
+
(r"\[", Punctuation, ("property.square", "property.key")),
|
| 253 |
+
],
|
| 254 |
+
"property.curly": [
|
| 255 |
+
include("whitespace"),
|
| 256 |
+
include("property"),
|
| 257 |
+
(r"\}", Punctuation, "#pop"),
|
| 258 |
+
],
|
| 259 |
+
"property.square": [
|
| 260 |
+
include("whitespace"),
|
| 261 |
+
include("property"),
|
| 262 |
+
(r"\]", Punctuation, "#pop"),
|
| 263 |
+
|
| 264 |
+
# lists can have sequences of items
|
| 265 |
+
(r",", Punctuation),
|
| 266 |
+
],
|
| 267 |
+
"property.key": [
|
| 268 |
+
include("whitespace"),
|
| 269 |
+
|
| 270 |
+
# resource names (for advancements)
|
| 271 |
+
# can omit `:` to default `minecraft:`
|
| 272 |
+
# must check if there is a future equals sign if `:` is in the name
|
| 273 |
+
(r"#?[a-z_][a-z_\.\-]*\:[a-z0-9_\.\-/]+(?=\s*\=)", Name.Attribute, "property.delimiter"),
|
| 274 |
+
(r"#?[a-z_][a-z0-9_\.\-/]+", Name.Attribute, "property.delimiter"),
|
| 275 |
+
|
| 276 |
+
# unquoted NBT key
|
| 277 |
+
(r"[A-Za-z_\-\+]+", Name.Attribute, "property.delimiter"),
|
| 278 |
+
|
| 279 |
+
# quoted JSON or NBT key
|
| 280 |
+
(r'"', Name.Attribute, "property.delimiter", "literals.string-double"),
|
| 281 |
+
(r"'", Name.Attribute, "property.delimiter", "literals.string-single"),
|
| 282 |
+
|
| 283 |
+
# index for a list
|
| 284 |
+
(r"-?\d+", Number.Integer, "property.delimiter"),
|
| 285 |
+
|
| 286 |
+
default("#pop"),
|
| 287 |
+
],
|
| 288 |
+
"property.key.string-double": [
|
| 289 |
+
(r"\\.", String.Escape),
|
| 290 |
+
(r'[^\\"\n]+', Name.Attribute),
|
| 291 |
+
(r'"', Name.Attribute, "#pop"),
|
| 292 |
+
],
|
| 293 |
+
"property.key.string-single": [
|
| 294 |
+
(r"\\.", String.Escape),
|
| 295 |
+
(r"[^\\'\n]+", Name.Attribute),
|
| 296 |
+
(r"'", Name.Attribute, "#pop"),
|
| 297 |
+
],
|
| 298 |
+
"property.delimiter": [
|
| 299 |
+
include("whitespace"),
|
| 300 |
+
|
| 301 |
+
(r"[:=]!?", Punctuation, "property.value"),
|
| 302 |
+
(r",", Punctuation),
|
| 303 |
+
|
| 304 |
+
default("#pop"),
|
| 305 |
+
],
|
| 306 |
+
"property.value": [
|
| 307 |
+
include("whitespace"),
|
| 308 |
+
|
| 309 |
+
# unquoted resource names are valid literals here
|
| 310 |
+
(r"#?[a-z_][a-z_\.\-]*\:[a-z0-9_\.\-/]+", Name.Tag),
|
| 311 |
+
(r"#?[a-z_][a-z0-9_\.\-/]+", Name.Tag),
|
| 312 |
+
|
| 313 |
+
include("literals"),
|
| 314 |
+
include("property"),
|
| 315 |
+
|
| 316 |
+
default("#pop"),
|
| 317 |
+
],
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
class MCSchemaLexer(RegexLexer):
|
| 322 |
+
"""Lexer for Minecraft Add-ons data Schemas, an interface structure standard used in Minecraft
|
| 323 |
+
"""
|
| 324 |
+
|
| 325 |
+
name = 'MCSchema'
|
| 326 |
+
url = 'https://learn.microsoft.com/en-us/minecraft/creator/reference/content/schemasreference/'
|
| 327 |
+
aliases = ['mcschema']
|
| 328 |
+
filenames = ['*.mcschema']
|
| 329 |
+
mimetypes = ['text/mcschema']
|
| 330 |
+
version_added = '2.14'
|
| 331 |
+
|
| 332 |
+
tokens = {
|
| 333 |
+
'commentsandwhitespace': [
|
| 334 |
+
(r'\s+', Whitespace),
|
| 335 |
+
(r'//.*?$', Comment.Single),
|
| 336 |
+
(r'/\*.*?\*/', Comment.Multiline)
|
| 337 |
+
],
|
| 338 |
+
'slashstartsregex': [
|
| 339 |
+
include('commentsandwhitespace'),
|
| 340 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 341 |
+
r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
|
| 342 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 343 |
+
default('#pop')
|
| 344 |
+
],
|
| 345 |
+
'badregex': [
|
| 346 |
+
(r'\n', Whitespace, '#pop')
|
| 347 |
+
],
|
| 348 |
+
'singlestring': [
|
| 349 |
+
(r'\\.', String.Escape),
|
| 350 |
+
(r"'", String.Single, '#pop'),
|
| 351 |
+
(r"[^\\']+", String.Single),
|
| 352 |
+
],
|
| 353 |
+
'doublestring': [
|
| 354 |
+
(r'\\.', String.Escape),
|
| 355 |
+
(r'"', String.Double, '#pop'),
|
| 356 |
+
(r'[^\\"]+', String.Double),
|
| 357 |
+
],
|
| 358 |
+
'root': [
|
| 359 |
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
| 360 |
+
include('commentsandwhitespace'),
|
| 361 |
+
|
| 362 |
+
# keywords for optional word and field types
|
| 363 |
+
(r'(?<=: )opt', Operator.Word),
|
| 364 |
+
(r'(?<=\s)[\w-]*(?=(\s+"|\n))', Keyword.Declaration),
|
| 365 |
+
|
| 366 |
+
# numeric literals
|
| 367 |
+
(r'0[bB][01]+', Number.Bin),
|
| 368 |
+
(r'0[oO]?[0-7]+', Number.Oct),
|
| 369 |
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
| 370 |
+
(r'\d+', Number.Integer),
|
| 371 |
+
(r'(\.\d+|\d+\.\d*|\d+)([eE][-+]?\d+)?', Number.Float),
|
| 372 |
+
|
| 373 |
+
# possible punctuations
|
| 374 |
+
(r'\.\.\.|=>', Punctuation),
|
| 375 |
+
(r'\+\+|--|~|\?\?=?|\?|:|\\(?=\n)|'
|
| 376 |
+
r'(<<|>>>?|==?|!=?|(?:\*\*|\|\||&&|[-<>+*%&|^/]))=?', Operator, 'slashstartsregex'),
|
| 377 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 378 |
+
(r'[})\].]', Punctuation),
|
| 379 |
+
|
| 380 |
+
# strings
|
| 381 |
+
(r"'", String.Single, 'singlestring'),
|
| 382 |
+
(r'"', String.Double, 'doublestring'),
|
| 383 |
+
|
| 384 |
+
# title line
|
| 385 |
+
(r'[\w-]*?(?=:\{?\n)', String.Symbol),
|
| 386 |
+
# title line with a version code, formatted
|
| 387 |
+
# `major.minor.patch-prerelease+buildmeta`
|
| 388 |
+
(r'([\w-]*?)(:)(\d+)(?:(\.)(\d+)(?:(\.)(\d+)(?:(\-)((?:[^\W_]|-)*(?:\.(?:[^\W_]|-)*)*))?(?:(\+)((?:[^\W_]|-)+(?:\.(?:[^\W_]|-)+)*))?)?)?(?=:\{?\n)', bygroups(String.Symbol, Operator, Number.Integer, Operator, Number.Integer, Operator, Number.Integer, Operator, String, Operator, String)),
|
| 389 |
+
|
| 390 |
+
(r'.*\n', Text),
|
| 391 |
+
]
|
| 392 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/mips.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.mips
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for MIPS assembly.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words
|
| 12 |
+
from pygments.token import Whitespace, Comment, String, Keyword, Name, Text
|
| 13 |
+
|
| 14 |
+
__all__ = ["MIPSLexer"]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class MIPSLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
A MIPS Assembly Lexer.
|
| 20 |
+
|
| 21 |
+
Based on the Emacs major mode by hlissner:
|
| 22 |
+
https://github.com/hlissner/emacs-mips-mode
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'MIPS'
|
| 26 |
+
aliases = ['mips']
|
| 27 |
+
version_added = ''
|
| 28 |
+
# TODO: add '*.s' and '*.asm', which will require designing an analyse_text
|
| 29 |
+
# method for this lexer and refactoring those from Gas and Nasm in order to
|
| 30 |
+
# have relatively reliable detection
|
| 31 |
+
filenames = ['*.mips', '*.MIPS']
|
| 32 |
+
url = 'https://mips.com'
|
| 33 |
+
|
| 34 |
+
keywords = [
|
| 35 |
+
# Arithmetic insturctions
|
| 36 |
+
"add", "sub", "subu", "addi", "subi", "addu", "addiu",
|
| 37 |
+
# Multiplication/division
|
| 38 |
+
"mul", "mult", "multu", "mulu", "madd", "maddu", "msub", "msubu", "div", "divu",
|
| 39 |
+
# Bitwise operations
|
| 40 |
+
"and", "or", "nor", "xor", "andi", "ori", "xori", "clo", "clz",
|
| 41 |
+
# Shifts
|
| 42 |
+
"sll", "srl", "sllv", "srlv", "sra", "srav",
|
| 43 |
+
# Comparisons
|
| 44 |
+
"slt", "sltu", "slti", "sltiu",
|
| 45 |
+
# Move data
|
| 46 |
+
"mfhi", "mthi", "mflo", "mtlo", "movn", "movz", "movf", "movt",
|
| 47 |
+
# Jump
|
| 48 |
+
"j", "jal", "jalr", "jr",
|
| 49 |
+
# branch
|
| 50 |
+
"bc1f", "bc1t", "beq", "bgez", "bgezal", "bgtz", "blez", "bltzal", "bltz", "bne",
|
| 51 |
+
# Load
|
| 52 |
+
"lui", "lb", "lbu", "lh", "lhu", "lw", "lwcl", "lwl", "lwr",
|
| 53 |
+
# Store
|
| 54 |
+
"sb", "sh", "sw", "swl", "swr", # coproc: swc1 sdc1
|
| 55 |
+
# Concurrent load/store
|
| 56 |
+
"ll", "sc",
|
| 57 |
+
# Trap handling
|
| 58 |
+
"teq", "teqi", "tne", "tneqi", "tge", "tgeu", "tgei", "tgeiu", "tlt", "tltu", "tlti",
|
| 59 |
+
"tltiu",
|
| 60 |
+
# Exception / Interrupt
|
| 61 |
+
"eret", "break", "bop", "syscall",
|
| 62 |
+
# --- Floats -----------------------------------------------------
|
| 63 |
+
# Arithmetic
|
| 64 |
+
"add.s", "add.d", "sub.s", "sub.d", "mul.s", "mul.d", "div.s", "div.d", "neg.d",
|
| 65 |
+
"neg.s",
|
| 66 |
+
# Comparison
|
| 67 |
+
"c.e.d", "c.e.s", "c.le.d", "c.le.s", "c.lt.s", "c.lt.d", # "c.gt.s", "c.gt.d",
|
| 68 |
+
"madd.s", "madd.d", "msub.s", "msub.d",
|
| 69 |
+
# Move Floats
|
| 70 |
+
"mov.d", "move.s", "movf.d", "movf.s", "movt.d", "movt.s", "movn.d", "movn.s",
|
| 71 |
+
"movnzd", "movz.s", "movz.d",
|
| 72 |
+
# Conversion
|
| 73 |
+
"cvt.d.s", "cvt.d.w", "cvt.s.d", "cvt.s.w", "cvt.w.d", "cvt.w.s", "trunc.w.d",
|
| 74 |
+
"trunc.w.s",
|
| 75 |
+
# Math
|
| 76 |
+
"abs.s", "abs.d", "sqrt.s", "sqrt.d", "ceil.w.d", "ceil.w.s", "floor.w.d",
|
| 77 |
+
"floor.w.s", "round.w.d", "round.w.s",
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
pseudoinstructions = [
|
| 81 |
+
# Arithmetic & logical
|
| 82 |
+
"rem", "remu", "mulo", "mulou", "abs", "neg", "negu", "not", "rol", "ror",
|
| 83 |
+
# branches
|
| 84 |
+
"b", "beqz", "bge", "bgeu", "bgt", "bgtu", "ble", "bleu", "blt", "bltu", "bnez",
|
| 85 |
+
# loads
|
| 86 |
+
"la", "li", "ld", "ulh", "ulhu", "ulw",
|
| 87 |
+
# Store
|
| 88 |
+
"sd", "ush", "usw",
|
| 89 |
+
# move
|
| 90 |
+
"move", # coproc: "mfc1.d",
|
| 91 |
+
# comparisons
|
| 92 |
+
"sgt", "sgtu", "sge", "sgeu", "sle", "sleu", "sne", "seq",
|
| 93 |
+
# --- Floats -----------------------------------------------------
|
| 94 |
+
# load-store
|
| 95 |
+
"l.d", "l.s", "s.d", "s.s",
|
| 96 |
+
]
|
| 97 |
+
|
| 98 |
+
directives = [
|
| 99 |
+
".align", ".ascii", ".asciiz", ".byte", ".data", ".double", ".extern", ".float",
|
| 100 |
+
".globl", ".half", ".kdata", ".ktext", ".space", ".text", ".word",
|
| 101 |
+
]
|
| 102 |
+
|
| 103 |
+
deprecated = [
|
| 104 |
+
"beql", "bnel", "bgtzl", "bgezl", "bltzl", "blezl", "bltzall", "bgezall",
|
| 105 |
+
]
|
| 106 |
+
|
| 107 |
+
tokens = {
|
| 108 |
+
'root': [
|
| 109 |
+
(r'\s+', Whitespace),
|
| 110 |
+
(r'#.*', Comment),
|
| 111 |
+
(r'"', String, 'string'),
|
| 112 |
+
(r'-?[0-9]+?', Keyword.Constant),
|
| 113 |
+
(r'\w*:', Name.Function),
|
| 114 |
+
(words(deprecated, suffix=r'\b'), Keyword.Pseudo), # need warning face
|
| 115 |
+
(words(pseudoinstructions, suffix=r'\b'), Name.Variable),
|
| 116 |
+
(words(keywords, suffix=r'\b'), Keyword),
|
| 117 |
+
(r'[slm][ftwd]c[0-9]([.]d)?', Keyword),
|
| 118 |
+
(r'\$(f?[0-2][0-9]|f?3[01]|[ft]?[0-9]|[vk][01]|a[0-3]|s[0-7]|[gsf]p|ra|at|zero)',
|
| 119 |
+
Keyword.Type),
|
| 120 |
+
(words(directives, suffix=r'\b'), Name.Entity), # Preprocessor?
|
| 121 |
+
(r':|,|;|\{|\}|=>|@|\$|=', Name.Builtin),
|
| 122 |
+
(r'\w+', Text),
|
| 123 |
+
(r'.', Text),
|
| 124 |
+
],
|
| 125 |
+
'string': [
|
| 126 |
+
(r'\\.', String.Escape),
|
| 127 |
+
(r'"', String, '#pop'),
|
| 128 |
+
(r'[^\\"]+', String),
|
| 129 |
+
],
|
| 130 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/ml.py
ADDED
|
@@ -0,0 +1,958 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.ml
|
| 3 |
+
~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for ML family languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, default, words
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Error
|
| 16 |
+
|
| 17 |
+
__all__ = ['SMLLexer', 'OcamlLexer', 'OpaLexer', 'ReasonLexer', 'FStarLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class SMLLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For the Standard ML language.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'Standard ML'
|
| 26 |
+
aliases = ['sml']
|
| 27 |
+
filenames = ['*.sml', '*.sig', '*.fun']
|
| 28 |
+
mimetypes = ['text/x-standardml', 'application/x-standardml']
|
| 29 |
+
url = 'https://en.wikipedia.org/wiki/Standard_ML'
|
| 30 |
+
version_added = '1.5'
|
| 31 |
+
|
| 32 |
+
alphanumid_reserved = {
|
| 33 |
+
# Core
|
| 34 |
+
'abstype', 'and', 'andalso', 'as', 'case', 'datatype', 'do', 'else',
|
| 35 |
+
'end', 'exception', 'fn', 'fun', 'handle', 'if', 'in', 'infix',
|
| 36 |
+
'infixr', 'let', 'local', 'nonfix', 'of', 'op', 'open', 'orelse',
|
| 37 |
+
'raise', 'rec', 'then', 'type', 'val', 'with', 'withtype', 'while',
|
| 38 |
+
# Modules
|
| 39 |
+
'eqtype', 'functor', 'include', 'sharing', 'sig', 'signature',
|
| 40 |
+
'struct', 'structure', 'where',
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
symbolicid_reserved = {
|
| 44 |
+
# Core
|
| 45 |
+
':', r'\|', '=', '=>', '->', '#',
|
| 46 |
+
# Modules
|
| 47 |
+
':>',
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
nonid_reserved = {'(', ')', '[', ']', '{', '}', ',', ';', '...', '_'}
|
| 51 |
+
|
| 52 |
+
alphanumid_re = r"[a-zA-Z][\w']*"
|
| 53 |
+
symbolicid_re = r"[!%&$#+\-/:<=>?@\\~`^|*]+"
|
| 54 |
+
|
| 55 |
+
# A character constant is a sequence of the form #s, where s is a string
|
| 56 |
+
# constant denoting a string of size one character. This setup just parses
|
| 57 |
+
# the entire string as either a String.Double or a String.Char (depending
|
| 58 |
+
# on the argument), even if the String.Char is an erroneous
|
| 59 |
+
# multiple-character string.
|
| 60 |
+
def stringy(whatkind):
|
| 61 |
+
return [
|
| 62 |
+
(r'[^"\\]', whatkind),
|
| 63 |
+
(r'\\[\\"abtnvfr]', String.Escape),
|
| 64 |
+
# Control-character notation is used for codes < 32,
|
| 65 |
+
# where \^@ == \000
|
| 66 |
+
(r'\\\^[\x40-\x5e]', String.Escape),
|
| 67 |
+
# Docs say 'decimal digits'
|
| 68 |
+
(r'\\[0-9]{3}', String.Escape),
|
| 69 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 70 |
+
(r'\\\s+\\', String.Interpol),
|
| 71 |
+
(r'"', whatkind, '#pop'),
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
# Callbacks for distinguishing tokens and reserved words
|
| 75 |
+
def long_id_callback(self, match):
|
| 76 |
+
if match.group(1) in self.alphanumid_reserved:
|
| 77 |
+
token = Error
|
| 78 |
+
else:
|
| 79 |
+
token = Name.Namespace
|
| 80 |
+
yield match.start(1), token, match.group(1)
|
| 81 |
+
yield match.start(2), Punctuation, match.group(2)
|
| 82 |
+
|
| 83 |
+
def end_id_callback(self, match):
|
| 84 |
+
if match.group(1) in self.alphanumid_reserved:
|
| 85 |
+
token = Error
|
| 86 |
+
elif match.group(1) in self.symbolicid_reserved:
|
| 87 |
+
token = Error
|
| 88 |
+
else:
|
| 89 |
+
token = Name
|
| 90 |
+
yield match.start(1), token, match.group(1)
|
| 91 |
+
|
| 92 |
+
def id_callback(self, match):
|
| 93 |
+
str = match.group(1)
|
| 94 |
+
if str in self.alphanumid_reserved:
|
| 95 |
+
token = Keyword.Reserved
|
| 96 |
+
elif str in self.symbolicid_reserved:
|
| 97 |
+
token = Punctuation
|
| 98 |
+
else:
|
| 99 |
+
token = Name
|
| 100 |
+
yield match.start(1), token, str
|
| 101 |
+
|
| 102 |
+
tokens = {
|
| 103 |
+
# Whitespace and comments are (almost) everywhere
|
| 104 |
+
'whitespace': [
|
| 105 |
+
(r'\s+', Text),
|
| 106 |
+
(r'\(\*', Comment.Multiline, 'comment'),
|
| 107 |
+
],
|
| 108 |
+
|
| 109 |
+
'delimiters': [
|
| 110 |
+
# This lexer treats these delimiters specially:
|
| 111 |
+
# Delimiters define scopes, and the scope is how the meaning of
|
| 112 |
+
# the `|' is resolved - is it a case/handle expression, or function
|
| 113 |
+
# definition by cases? (This is not how the Definition works, but
|
| 114 |
+
# it's how MLton behaves, see http://mlton.org/SMLNJDeviations)
|
| 115 |
+
(r'\(|\[|\{', Punctuation, 'main'),
|
| 116 |
+
(r'\)|\]|\}', Punctuation, '#pop'),
|
| 117 |
+
(r'\b(let|if|local)\b(?!\')', Keyword.Reserved, ('main', 'main')),
|
| 118 |
+
(r'\b(struct|sig|while)\b(?!\')', Keyword.Reserved, 'main'),
|
| 119 |
+
(r'\b(do|else|end|in|then)\b(?!\')', Keyword.Reserved, '#pop'),
|
| 120 |
+
],
|
| 121 |
+
|
| 122 |
+
'core': [
|
| 123 |
+
# Punctuation that doesn't overlap symbolic identifiers
|
| 124 |
+
(r'({})'.format('|'.join(re.escape(z) for z in nonid_reserved)),
|
| 125 |
+
Punctuation),
|
| 126 |
+
|
| 127 |
+
# Special constants: strings, floats, numbers in decimal and hex
|
| 128 |
+
(r'#"', String.Char, 'char'),
|
| 129 |
+
(r'"', String.Double, 'string'),
|
| 130 |
+
(r'~?0x[0-9a-fA-F]+', Number.Hex),
|
| 131 |
+
(r'0wx[0-9a-fA-F]+', Number.Hex),
|
| 132 |
+
(r'0w\d+', Number.Integer),
|
| 133 |
+
(r'~?\d+\.\d+[eE]~?\d+', Number.Float),
|
| 134 |
+
(r'~?\d+\.\d+', Number.Float),
|
| 135 |
+
(r'~?\d+[eE]~?\d+', Number.Float),
|
| 136 |
+
(r'~?\d+', Number.Integer),
|
| 137 |
+
|
| 138 |
+
# Labels
|
| 139 |
+
(r'#\s*[1-9][0-9]*', Name.Label),
|
| 140 |
+
(rf'#\s*({alphanumid_re})', Name.Label),
|
| 141 |
+
(rf'#\s+({symbolicid_re})', Name.Label),
|
| 142 |
+
# Some reserved words trigger a special, local lexer state change
|
| 143 |
+
(r'\b(datatype|abstype)\b(?!\')', Keyword.Reserved, 'dname'),
|
| 144 |
+
(r'\b(exception)\b(?!\')', Keyword.Reserved, 'ename'),
|
| 145 |
+
(r'\b(functor|include|open|signature|structure)\b(?!\')',
|
| 146 |
+
Keyword.Reserved, 'sname'),
|
| 147 |
+
(r'\b(type|eqtype)\b(?!\')', Keyword.Reserved, 'tname'),
|
| 148 |
+
|
| 149 |
+
# Regular identifiers, long and otherwise
|
| 150 |
+
(r'\'[\w\']*', Name.Decorator),
|
| 151 |
+
(rf'({alphanumid_re})(\.)', long_id_callback, "dotted"),
|
| 152 |
+
(rf'({alphanumid_re})', id_callback),
|
| 153 |
+
(rf'({symbolicid_re})', id_callback),
|
| 154 |
+
],
|
| 155 |
+
'dotted': [
|
| 156 |
+
(rf'({alphanumid_re})(\.)', long_id_callback),
|
| 157 |
+
(rf'({alphanumid_re})', end_id_callback, "#pop"),
|
| 158 |
+
(rf'({symbolicid_re})', end_id_callback, "#pop"),
|
| 159 |
+
(r'\s+', Error),
|
| 160 |
+
(r'\S+', Error),
|
| 161 |
+
],
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
# Main parser (prevents errors in files that have scoping errors)
|
| 165 |
+
'root': [
|
| 166 |
+
default('main')
|
| 167 |
+
],
|
| 168 |
+
|
| 169 |
+
# In this scope, I expect '|' to not be followed by a function name,
|
| 170 |
+
# and I expect 'and' to be followed by a binding site
|
| 171 |
+
'main': [
|
| 172 |
+
include('whitespace'),
|
| 173 |
+
|
| 174 |
+
# Special behavior of val/and/fun
|
| 175 |
+
(r'\b(val|and)\b(?!\')', Keyword.Reserved, 'vname'),
|
| 176 |
+
(r'\b(fun)\b(?!\')', Keyword.Reserved,
|
| 177 |
+
('#pop', 'main-fun', 'fname')),
|
| 178 |
+
|
| 179 |
+
include('delimiters'),
|
| 180 |
+
include('core'),
|
| 181 |
+
(r'\S+', Error),
|
| 182 |
+
],
|
| 183 |
+
|
| 184 |
+
# In this scope, I expect '|' and 'and' to be followed by a function
|
| 185 |
+
'main-fun': [
|
| 186 |
+
include('whitespace'),
|
| 187 |
+
|
| 188 |
+
(r'\s', Text),
|
| 189 |
+
(r'\(\*', Comment.Multiline, 'comment'),
|
| 190 |
+
|
| 191 |
+
# Special behavior of val/and/fun
|
| 192 |
+
(r'\b(fun|and)\b(?!\')', Keyword.Reserved, 'fname'),
|
| 193 |
+
(r'\b(val)\b(?!\')', Keyword.Reserved,
|
| 194 |
+
('#pop', 'main', 'vname')),
|
| 195 |
+
|
| 196 |
+
# Special behavior of '|' and '|'-manipulating keywords
|
| 197 |
+
(r'\|', Punctuation, 'fname'),
|
| 198 |
+
(r'\b(case|handle)\b(?!\')', Keyword.Reserved,
|
| 199 |
+
('#pop', 'main')),
|
| 200 |
+
|
| 201 |
+
include('delimiters'),
|
| 202 |
+
include('core'),
|
| 203 |
+
(r'\S+', Error),
|
| 204 |
+
],
|
| 205 |
+
|
| 206 |
+
# Character and string parsers
|
| 207 |
+
'char': stringy(String.Char),
|
| 208 |
+
'string': stringy(String.Double),
|
| 209 |
+
|
| 210 |
+
'breakout': [
|
| 211 |
+
(r'(?=\b({})\b(?!\'))'.format('|'.join(alphanumid_reserved)), Text, '#pop'),
|
| 212 |
+
],
|
| 213 |
+
|
| 214 |
+
# Dealing with what comes after module system keywords
|
| 215 |
+
'sname': [
|
| 216 |
+
include('whitespace'),
|
| 217 |
+
include('breakout'),
|
| 218 |
+
|
| 219 |
+
(rf'({alphanumid_re})', Name.Namespace),
|
| 220 |
+
default('#pop'),
|
| 221 |
+
],
|
| 222 |
+
|
| 223 |
+
# Dealing with what comes after the 'fun' (or 'and' or '|') keyword
|
| 224 |
+
'fname': [
|
| 225 |
+
include('whitespace'),
|
| 226 |
+
(r'\'[\w\']*', Name.Decorator),
|
| 227 |
+
(r'\(', Punctuation, 'tyvarseq'),
|
| 228 |
+
|
| 229 |
+
(rf'({alphanumid_re})', Name.Function, '#pop'),
|
| 230 |
+
(rf'({symbolicid_re})', Name.Function, '#pop'),
|
| 231 |
+
|
| 232 |
+
# Ignore interesting function declarations like "fun (x + y) = ..."
|
| 233 |
+
default('#pop'),
|
| 234 |
+
],
|
| 235 |
+
|
| 236 |
+
# Dealing with what comes after the 'val' (or 'and') keyword
|
| 237 |
+
'vname': [
|
| 238 |
+
include('whitespace'),
|
| 239 |
+
(r'\'[\w\']*', Name.Decorator),
|
| 240 |
+
(r'\(', Punctuation, 'tyvarseq'),
|
| 241 |
+
|
| 242 |
+
(rf'({alphanumid_re})(\s*)(=(?!{symbolicid_re}))',
|
| 243 |
+
bygroups(Name.Variable, Text, Punctuation), '#pop'),
|
| 244 |
+
(rf'({symbolicid_re})(\s*)(=(?!{symbolicid_re}))',
|
| 245 |
+
bygroups(Name.Variable, Text, Punctuation), '#pop'),
|
| 246 |
+
(rf'({alphanumid_re})', Name.Variable, '#pop'),
|
| 247 |
+
(rf'({symbolicid_re})', Name.Variable, '#pop'),
|
| 248 |
+
|
| 249 |
+
# Ignore interesting patterns like 'val (x, y)'
|
| 250 |
+
default('#pop'),
|
| 251 |
+
],
|
| 252 |
+
|
| 253 |
+
# Dealing with what comes after the 'type' (or 'and') keyword
|
| 254 |
+
'tname': [
|
| 255 |
+
include('whitespace'),
|
| 256 |
+
include('breakout'),
|
| 257 |
+
|
| 258 |
+
(r'\'[\w\']*', Name.Decorator),
|
| 259 |
+
(r'\(', Punctuation, 'tyvarseq'),
|
| 260 |
+
(rf'=(?!{symbolicid_re})', Punctuation, ('#pop', 'typbind')),
|
| 261 |
+
|
| 262 |
+
(rf'({alphanumid_re})', Keyword.Type),
|
| 263 |
+
(rf'({symbolicid_re})', Keyword.Type),
|
| 264 |
+
(r'\S+', Error, '#pop'),
|
| 265 |
+
],
|
| 266 |
+
|
| 267 |
+
# A type binding includes most identifiers
|
| 268 |
+
'typbind': [
|
| 269 |
+
include('whitespace'),
|
| 270 |
+
|
| 271 |
+
(r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')),
|
| 272 |
+
|
| 273 |
+
include('breakout'),
|
| 274 |
+
include('core'),
|
| 275 |
+
(r'\S+', Error, '#pop'),
|
| 276 |
+
],
|
| 277 |
+
|
| 278 |
+
# Dealing with what comes after the 'datatype' (or 'and') keyword
|
| 279 |
+
'dname': [
|
| 280 |
+
include('whitespace'),
|
| 281 |
+
include('breakout'),
|
| 282 |
+
|
| 283 |
+
(r'\'[\w\']*', Name.Decorator),
|
| 284 |
+
(r'\(', Punctuation, 'tyvarseq'),
|
| 285 |
+
(r'(=)(\s*)(datatype)',
|
| 286 |
+
bygroups(Punctuation, Text, Keyword.Reserved), '#pop'),
|
| 287 |
+
(rf'=(?!{symbolicid_re})', Punctuation,
|
| 288 |
+
('#pop', 'datbind', 'datcon')),
|
| 289 |
+
|
| 290 |
+
(rf'({alphanumid_re})', Keyword.Type),
|
| 291 |
+
(rf'({symbolicid_re})', Keyword.Type),
|
| 292 |
+
(r'\S+', Error, '#pop'),
|
| 293 |
+
],
|
| 294 |
+
|
| 295 |
+
# common case - A | B | C of int
|
| 296 |
+
'datbind': [
|
| 297 |
+
include('whitespace'),
|
| 298 |
+
|
| 299 |
+
(r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'dname')),
|
| 300 |
+
(r'\b(withtype)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')),
|
| 301 |
+
(r'\b(of)\b(?!\')', Keyword.Reserved),
|
| 302 |
+
|
| 303 |
+
(rf'(\|)(\s*)({alphanumid_re})',
|
| 304 |
+
bygroups(Punctuation, Text, Name.Class)),
|
| 305 |
+
(rf'(\|)(\s+)({symbolicid_re})',
|
| 306 |
+
bygroups(Punctuation, Text, Name.Class)),
|
| 307 |
+
|
| 308 |
+
include('breakout'),
|
| 309 |
+
include('core'),
|
| 310 |
+
(r'\S+', Error),
|
| 311 |
+
],
|
| 312 |
+
|
| 313 |
+
# Dealing with what comes after an exception
|
| 314 |
+
'ename': [
|
| 315 |
+
include('whitespace'),
|
| 316 |
+
|
| 317 |
+
(rf'(and\b)(\s+)({alphanumid_re})',
|
| 318 |
+
bygroups(Keyword.Reserved, Text, Name.Class)),
|
| 319 |
+
(rf'(and\b)(\s*)({symbolicid_re})',
|
| 320 |
+
bygroups(Keyword.Reserved, Text, Name.Class)),
|
| 321 |
+
(r'\b(of)\b(?!\')', Keyword.Reserved),
|
| 322 |
+
(rf'({alphanumid_re})|({symbolicid_re})', Name.Class),
|
| 323 |
+
|
| 324 |
+
default('#pop'),
|
| 325 |
+
],
|
| 326 |
+
|
| 327 |
+
'datcon': [
|
| 328 |
+
include('whitespace'),
|
| 329 |
+
(rf'({alphanumid_re})', Name.Class, '#pop'),
|
| 330 |
+
(rf'({symbolicid_re})', Name.Class, '#pop'),
|
| 331 |
+
(r'\S+', Error, '#pop'),
|
| 332 |
+
],
|
| 333 |
+
|
| 334 |
+
# Series of type variables
|
| 335 |
+
'tyvarseq': [
|
| 336 |
+
(r'\s', Text),
|
| 337 |
+
(r'\(\*', Comment.Multiline, 'comment'),
|
| 338 |
+
|
| 339 |
+
(r'\'[\w\']*', Name.Decorator),
|
| 340 |
+
(alphanumid_re, Name),
|
| 341 |
+
(r',', Punctuation),
|
| 342 |
+
(r'\)', Punctuation, '#pop'),
|
| 343 |
+
(symbolicid_re, Name),
|
| 344 |
+
],
|
| 345 |
+
|
| 346 |
+
'comment': [
|
| 347 |
+
(r'[^(*)]', Comment.Multiline),
|
| 348 |
+
(r'\(\*', Comment.Multiline, '#push'),
|
| 349 |
+
(r'\*\)', Comment.Multiline, '#pop'),
|
| 350 |
+
(r'[(*)]', Comment.Multiline),
|
| 351 |
+
],
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
class OcamlLexer(RegexLexer):
|
| 356 |
+
"""
|
| 357 |
+
For the OCaml language.
|
| 358 |
+
"""
|
| 359 |
+
|
| 360 |
+
name = 'OCaml'
|
| 361 |
+
url = 'https://ocaml.org/'
|
| 362 |
+
aliases = ['ocaml']
|
| 363 |
+
filenames = ['*.ml', '*.mli', '*.mll', '*.mly']
|
| 364 |
+
mimetypes = ['text/x-ocaml']
|
| 365 |
+
version_added = '0.7'
|
| 366 |
+
|
| 367 |
+
keywords = (
|
| 368 |
+
'and', 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done',
|
| 369 |
+
'downto', 'else', 'end', 'exception', 'external', 'false',
|
| 370 |
+
'for', 'fun', 'function', 'functor', 'if', 'in', 'include',
|
| 371 |
+
'inherit', 'initializer', 'lazy', 'let', 'match', 'method',
|
| 372 |
+
'module', 'mutable', 'new', 'object', 'of', 'open', 'private',
|
| 373 |
+
'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try',
|
| 374 |
+
'type', 'val', 'virtual', 'when', 'while', 'with',
|
| 375 |
+
)
|
| 376 |
+
keyopts = (
|
| 377 |
+
'!=', '#', '&', '&&', r'\(', r'\)', r'\*', r'\+', ',', '-',
|
| 378 |
+
r'-\.', '->', r'\.', r'\.\.', ':', '::', ':=', ':>', ';', ';;', '<',
|
| 379 |
+
'<-', '=', '>', '>]', r'>\}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>',
|
| 380 |
+
r'\[\|', ']', '_', '`', r'\{', r'\{<', r'\|', r'\|]', r'\}', '~'
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
operators = r'[!$%&*+\./:<=>?@^|~-]'
|
| 384 |
+
word_operators = ('asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'or')
|
| 385 |
+
prefix_syms = r'[!?~]'
|
| 386 |
+
infix_syms = r'[=<>@^|&+\*/$%-]'
|
| 387 |
+
primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array')
|
| 388 |
+
|
| 389 |
+
tokens = {
|
| 390 |
+
'escape-sequence': [
|
| 391 |
+
(r'\\[\\"\'ntbr]', String.Escape),
|
| 392 |
+
(r'\\[0-9]{3}', String.Escape),
|
| 393 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 394 |
+
],
|
| 395 |
+
'root': [
|
| 396 |
+
(r'\s+', Text),
|
| 397 |
+
(r'false|true|\(\)|\[\]', Name.Builtin.Pseudo),
|
| 398 |
+
(r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'),
|
| 399 |
+
(r'\b([A-Z][\w\']*)', Name.Class),
|
| 400 |
+
(r'\(\*(?![)])', Comment, 'comment'),
|
| 401 |
+
(r'\b({})\b'.format('|'.join(keywords)), Keyword),
|
| 402 |
+
(r'({})'.format('|'.join(keyopts[::-1])), Operator),
|
| 403 |
+
(rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
|
| 404 |
+
(r'\b({})\b'.format('|'.join(word_operators)), Operator.Word),
|
| 405 |
+
(r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
|
| 406 |
+
|
| 407 |
+
(r"[^\W\d][\w']*", Name),
|
| 408 |
+
|
| 409 |
+
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
|
| 410 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
|
| 411 |
+
(r'0[oO][0-7][0-7_]*', Number.Oct),
|
| 412 |
+
(r'0[bB][01][01_]*', Number.Bin),
|
| 413 |
+
(r'\d[\d_]*', Number.Integer),
|
| 414 |
+
|
| 415 |
+
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
|
| 416 |
+
String.Char),
|
| 417 |
+
(r"'.'", String.Char),
|
| 418 |
+
(r"'", Keyword), # a stray quote is another syntax element
|
| 419 |
+
|
| 420 |
+
(r'"', String.Double, 'string'),
|
| 421 |
+
|
| 422 |
+
(r'[~?][a-z][\w\']*:', Name.Variable),
|
| 423 |
+
],
|
| 424 |
+
'comment': [
|
| 425 |
+
(r'[^(*)]+', Comment),
|
| 426 |
+
(r'\(\*', Comment, '#push'),
|
| 427 |
+
(r'\*\)', Comment, '#pop'),
|
| 428 |
+
(r'[(*)]', Comment),
|
| 429 |
+
],
|
| 430 |
+
'string': [
|
| 431 |
+
(r'[^\\"]+', String.Double),
|
| 432 |
+
include('escape-sequence'),
|
| 433 |
+
(r'\\\n', String.Double),
|
| 434 |
+
(r'"', String.Double, '#pop'),
|
| 435 |
+
],
|
| 436 |
+
'dotted': [
|
| 437 |
+
(r'\s+', Text),
|
| 438 |
+
(r'\.', Punctuation),
|
| 439 |
+
(r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace),
|
| 440 |
+
(r'[A-Z][\w\']*', Name.Class, '#pop'),
|
| 441 |
+
(r'[a-z_][\w\']*', Name, '#pop'),
|
| 442 |
+
default('#pop'),
|
| 443 |
+
],
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
class OpaLexer(RegexLexer):
|
| 448 |
+
"""
|
| 449 |
+
Lexer for the Opa language.
|
| 450 |
+
"""
|
| 451 |
+
|
| 452 |
+
name = 'Opa'
|
| 453 |
+
aliases = ['opa']
|
| 454 |
+
filenames = ['*.opa']
|
| 455 |
+
mimetypes = ['text/x-opa']
|
| 456 |
+
url = 'http://opalang.org'
|
| 457 |
+
version_added = '1.5'
|
| 458 |
+
|
| 459 |
+
# most of these aren't strictly keywords
|
| 460 |
+
# but if you color only real keywords, you might just
|
| 461 |
+
# as well not color anything
|
| 462 |
+
keywords = (
|
| 463 |
+
'and', 'as', 'begin', 'case', 'client', 'css', 'database', 'db', 'do',
|
| 464 |
+
'else', 'end', 'external', 'forall', 'function', 'if', 'import',
|
| 465 |
+
'match', 'module', 'or', 'package', 'parser', 'rec', 'server', 'then',
|
| 466 |
+
'type', 'val', 'with', 'xml_parser',
|
| 467 |
+
)
|
| 468 |
+
|
| 469 |
+
# matches both stuff and `stuff`
|
| 470 |
+
ident_re = r'(([a-zA-Z_]\w*)|(`[^`]*`))'
|
| 471 |
+
|
| 472 |
+
op_re = r'[.=\-<>,@~%/+?*&^!]'
|
| 473 |
+
punc_re = r'[()\[\],;|]' # '{' and '}' are treated elsewhere
|
| 474 |
+
# because they are also used for inserts
|
| 475 |
+
|
| 476 |
+
tokens = {
|
| 477 |
+
# copied from the caml lexer, should be adapted
|
| 478 |
+
'escape-sequence': [
|
| 479 |
+
(r'\\[\\"\'ntr}]', String.Escape),
|
| 480 |
+
(r'\\[0-9]{3}', String.Escape),
|
| 481 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 482 |
+
],
|
| 483 |
+
|
| 484 |
+
# factorizing these rules, because they are inserted many times
|
| 485 |
+
'comments': [
|
| 486 |
+
(r'/\*', Comment, 'nested-comment'),
|
| 487 |
+
(r'//.*?$', Comment),
|
| 488 |
+
],
|
| 489 |
+
'comments-and-spaces': [
|
| 490 |
+
include('comments'),
|
| 491 |
+
(r'\s+', Text),
|
| 492 |
+
],
|
| 493 |
+
|
| 494 |
+
'root': [
|
| 495 |
+
include('comments-and-spaces'),
|
| 496 |
+
# keywords
|
| 497 |
+
(words(keywords, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 498 |
+
# directives
|
| 499 |
+
# we could parse the actual set of directives instead of anything
|
| 500 |
+
# starting with @, but this is troublesome
|
| 501 |
+
# because it needs to be adjusted all the time
|
| 502 |
+
# and assuming we parse only sources that compile, it is useless
|
| 503 |
+
(r'@' + ident_re + r'\b', Name.Builtin.Pseudo),
|
| 504 |
+
|
| 505 |
+
# number literals
|
| 506 |
+
(r'-?.[\d]+([eE][+\-]?\d+)', Number.Float),
|
| 507 |
+
(r'-?\d+.\d*([eE][+\-]?\d+)', Number.Float),
|
| 508 |
+
(r'-?\d+[eE][+\-]?\d+', Number.Float),
|
| 509 |
+
(r'0[xX][\da-fA-F]+', Number.Hex),
|
| 510 |
+
(r'0[oO][0-7]+', Number.Oct),
|
| 511 |
+
(r'0[bB][01]+', Number.Bin),
|
| 512 |
+
(r'\d+', Number.Integer),
|
| 513 |
+
# color literals
|
| 514 |
+
(r'#[\da-fA-F]{3,6}', Number.Integer),
|
| 515 |
+
|
| 516 |
+
# string literals
|
| 517 |
+
(r'"', String.Double, 'string'),
|
| 518 |
+
# char literal, should be checked because this is the regexp from
|
| 519 |
+
# the caml lexer
|
| 520 |
+
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2})|.)'",
|
| 521 |
+
String.Char),
|
| 522 |
+
|
| 523 |
+
# this is meant to deal with embedded exprs in strings
|
| 524 |
+
# every time we find a '}' we pop a state so that if we were
|
| 525 |
+
# inside a string, we are back in the string state
|
| 526 |
+
# as a consequence, we must also push a state every time we find a
|
| 527 |
+
# '{' or else we will have errors when parsing {} for instance
|
| 528 |
+
(r'\{', Operator, '#push'),
|
| 529 |
+
(r'\}', Operator, '#pop'),
|
| 530 |
+
|
| 531 |
+
# html literals
|
| 532 |
+
# this is a much more strict that the actual parser,
|
| 533 |
+
# since a<b would not be parsed as html
|
| 534 |
+
# but then again, the parser is way too lax, and we can't hope
|
| 535 |
+
# to have something as tolerant
|
| 536 |
+
(r'<(?=[a-zA-Z>])', String.Single, 'html-open-tag'),
|
| 537 |
+
|
| 538 |
+
# db path
|
| 539 |
+
# matching the '[_]' in '/a[_]' because it is a part
|
| 540 |
+
# of the syntax of the db path definition
|
| 541 |
+
# unfortunately, i don't know how to match the ']' in
|
| 542 |
+
# /a[1], so this is somewhat inconsistent
|
| 543 |
+
(r'[@?!]?(/\w+)+(\[_\])?', Name.Variable),
|
| 544 |
+
# putting the same color on <- as on db path, since
|
| 545 |
+
# it can be used only to mean Db.write
|
| 546 |
+
(r'<-(?!'+op_re+r')', Name.Variable),
|
| 547 |
+
|
| 548 |
+
# 'modules'
|
| 549 |
+
# although modules are not distinguished by their names as in caml
|
| 550 |
+
# the standard library seems to follow the convention that modules
|
| 551 |
+
# only area capitalized
|
| 552 |
+
(r'\b([A-Z]\w*)(?=\.)', Name.Namespace),
|
| 553 |
+
|
| 554 |
+
# operators
|
| 555 |
+
# = has a special role because this is the only
|
| 556 |
+
# way to syntactic distinguish binding constructions
|
| 557 |
+
# unfortunately, this colors the equal in {x=2} too
|
| 558 |
+
(r'=(?!'+op_re+r')', Keyword),
|
| 559 |
+
(rf'({op_re})+', Operator),
|
| 560 |
+
(rf'({punc_re})+', Operator),
|
| 561 |
+
|
| 562 |
+
# coercions
|
| 563 |
+
(r':', Operator, 'type'),
|
| 564 |
+
# type variables
|
| 565 |
+
# we need this rule because we don't parse specially type
|
| 566 |
+
# definitions so in "type t('a) = ...", "'a" is parsed by 'root'
|
| 567 |
+
("'"+ident_re, Keyword.Type),
|
| 568 |
+
|
| 569 |
+
# id literal, #something, or #{expr}
|
| 570 |
+
(r'#'+ident_re, String.Single),
|
| 571 |
+
(r'#(?=\{)', String.Single),
|
| 572 |
+
|
| 573 |
+
# identifiers
|
| 574 |
+
# this avoids to color '2' in 'a2' as an integer
|
| 575 |
+
(ident_re, Text),
|
| 576 |
+
|
| 577 |
+
# default, not sure if that is needed or not
|
| 578 |
+
# (r'.', Text),
|
| 579 |
+
],
|
| 580 |
+
|
| 581 |
+
# it is quite painful to have to parse types to know where they end
|
| 582 |
+
# this is the general rule for a type
|
| 583 |
+
# a type is either:
|
| 584 |
+
# * -> ty
|
| 585 |
+
# * type-with-slash
|
| 586 |
+
# * type-with-slash -> ty
|
| 587 |
+
# * type-with-slash (, type-with-slash)+ -> ty
|
| 588 |
+
#
|
| 589 |
+
# the code is pretty funky in here, but this code would roughly
|
| 590 |
+
# translate in caml to:
|
| 591 |
+
# let rec type stream =
|
| 592 |
+
# match stream with
|
| 593 |
+
# | [< "->"; stream >] -> type stream
|
| 594 |
+
# | [< ""; stream >] ->
|
| 595 |
+
# type_with_slash stream
|
| 596 |
+
# type_lhs_1 stream;
|
| 597 |
+
# and type_1 stream = ...
|
| 598 |
+
'type': [
|
| 599 |
+
include('comments-and-spaces'),
|
| 600 |
+
(r'->', Keyword.Type),
|
| 601 |
+
default(('#pop', 'type-lhs-1', 'type-with-slash')),
|
| 602 |
+
],
|
| 603 |
+
|
| 604 |
+
# parses all the atomic or closed constructions in the syntax of type
|
| 605 |
+
# expressions: record types, tuple types, type constructors, basic type
|
| 606 |
+
# and type variables
|
| 607 |
+
'type-1': [
|
| 608 |
+
include('comments-and-spaces'),
|
| 609 |
+
(r'\(', Keyword.Type, ('#pop', 'type-tuple')),
|
| 610 |
+
(r'~?\{', Keyword.Type, ('#pop', 'type-record')),
|
| 611 |
+
(ident_re+r'\(', Keyword.Type, ('#pop', 'type-tuple')),
|
| 612 |
+
(ident_re, Keyword.Type, '#pop'),
|
| 613 |
+
("'"+ident_re, Keyword.Type),
|
| 614 |
+
# this case is not in the syntax but sometimes
|
| 615 |
+
# we think we are parsing types when in fact we are parsing
|
| 616 |
+
# some css, so we just pop the states until we get back into
|
| 617 |
+
# the root state
|
| 618 |
+
default('#pop'),
|
| 619 |
+
],
|
| 620 |
+
|
| 621 |
+
# type-with-slash is either:
|
| 622 |
+
# * type-1
|
| 623 |
+
# * type-1 (/ type-1)+
|
| 624 |
+
'type-with-slash': [
|
| 625 |
+
include('comments-and-spaces'),
|
| 626 |
+
default(('#pop', 'slash-type-1', 'type-1')),
|
| 627 |
+
],
|
| 628 |
+
'slash-type-1': [
|
| 629 |
+
include('comments-and-spaces'),
|
| 630 |
+
('/', Keyword.Type, ('#pop', 'type-1')),
|
| 631 |
+
# same remark as above
|
| 632 |
+
default('#pop'),
|
| 633 |
+
],
|
| 634 |
+
|
| 635 |
+
# we go in this state after having parsed a type-with-slash
|
| 636 |
+
# while trying to parse a type
|
| 637 |
+
# and at this point we must determine if we are parsing an arrow
|
| 638 |
+
# type (in which case we must continue parsing) or not (in which
|
| 639 |
+
# case we stop)
|
| 640 |
+
'type-lhs-1': [
|
| 641 |
+
include('comments-and-spaces'),
|
| 642 |
+
(r'->', Keyword.Type, ('#pop', 'type')),
|
| 643 |
+
(r'(?=,)', Keyword.Type, ('#pop', 'type-arrow')),
|
| 644 |
+
default('#pop'),
|
| 645 |
+
],
|
| 646 |
+
'type-arrow': [
|
| 647 |
+
include('comments-and-spaces'),
|
| 648 |
+
# the look ahead here allows to parse f(x : int, y : float -> truc)
|
| 649 |
+
# correctly
|
| 650 |
+
(r',(?=[^:]*?->)', Keyword.Type, 'type-with-slash'),
|
| 651 |
+
(r'->', Keyword.Type, ('#pop', 'type')),
|
| 652 |
+
# same remark as above
|
| 653 |
+
default('#pop'),
|
| 654 |
+
],
|
| 655 |
+
|
| 656 |
+
# no need to do precise parsing for tuples and records
|
| 657 |
+
# because they are closed constructions, so we can simply
|
| 658 |
+
# find the closing delimiter
|
| 659 |
+
# note that this function would be not work if the source
|
| 660 |
+
# contained identifiers like `{)` (although it could be patched
|
| 661 |
+
# to support it)
|
| 662 |
+
'type-tuple': [
|
| 663 |
+
include('comments-and-spaces'),
|
| 664 |
+
(r'[^()/*]+', Keyword.Type),
|
| 665 |
+
(r'[/*]', Keyword.Type),
|
| 666 |
+
(r'\(', Keyword.Type, '#push'),
|
| 667 |
+
(r'\)', Keyword.Type, '#pop'),
|
| 668 |
+
],
|
| 669 |
+
'type-record': [
|
| 670 |
+
include('comments-and-spaces'),
|
| 671 |
+
(r'[^{}/*]+', Keyword.Type),
|
| 672 |
+
(r'[/*]', Keyword.Type),
|
| 673 |
+
(r'\{', Keyword.Type, '#push'),
|
| 674 |
+
(r'\}', Keyword.Type, '#pop'),
|
| 675 |
+
],
|
| 676 |
+
|
| 677 |
+
# 'type-tuple': [
|
| 678 |
+
# include('comments-and-spaces'),
|
| 679 |
+
# (r'\)', Keyword.Type, '#pop'),
|
| 680 |
+
# default(('#pop', 'type-tuple-1', 'type-1')),
|
| 681 |
+
# ],
|
| 682 |
+
# 'type-tuple-1': [
|
| 683 |
+
# include('comments-and-spaces'),
|
| 684 |
+
# (r',?\s*\)', Keyword.Type, '#pop'), # ,) is a valid end of tuple, in (1,)
|
| 685 |
+
# (r',', Keyword.Type, 'type-1'),
|
| 686 |
+
# ],
|
| 687 |
+
# 'type-record':[
|
| 688 |
+
# include('comments-and-spaces'),
|
| 689 |
+
# (r'\}', Keyword.Type, '#pop'),
|
| 690 |
+
# (r'~?(?:\w+|`[^`]*`)', Keyword.Type, 'type-record-field-expr'),
|
| 691 |
+
# ],
|
| 692 |
+
# 'type-record-field-expr': [
|
| 693 |
+
#
|
| 694 |
+
# ],
|
| 695 |
+
|
| 696 |
+
'nested-comment': [
|
| 697 |
+
(r'[^/*]+', Comment),
|
| 698 |
+
(r'/\*', Comment, '#push'),
|
| 699 |
+
(r'\*/', Comment, '#pop'),
|
| 700 |
+
(r'[/*]', Comment),
|
| 701 |
+
],
|
| 702 |
+
|
| 703 |
+
# the copy pasting between string and single-string
|
| 704 |
+
# is kinda sad. Is there a way to avoid that??
|
| 705 |
+
'string': [
|
| 706 |
+
(r'[^\\"{]+', String.Double),
|
| 707 |
+
(r'"', String.Double, '#pop'),
|
| 708 |
+
(r'\{', Operator, 'root'),
|
| 709 |
+
include('escape-sequence'),
|
| 710 |
+
],
|
| 711 |
+
'single-string': [
|
| 712 |
+
(r'[^\\\'{]+', String.Double),
|
| 713 |
+
(r'\'', String.Double, '#pop'),
|
| 714 |
+
(r'\{', Operator, 'root'),
|
| 715 |
+
include('escape-sequence'),
|
| 716 |
+
],
|
| 717 |
+
|
| 718 |
+
# all the html stuff
|
| 719 |
+
# can't really reuse some existing html parser
|
| 720 |
+
# because we must be able to parse embedded expressions
|
| 721 |
+
|
| 722 |
+
# we are in this state after someone parsed the '<' that
|
| 723 |
+
# started the html literal
|
| 724 |
+
'html-open-tag': [
|
| 725 |
+
(r'[\w\-:]+', String.Single, ('#pop', 'html-attr')),
|
| 726 |
+
(r'>', String.Single, ('#pop', 'html-content')),
|
| 727 |
+
],
|
| 728 |
+
|
| 729 |
+
# we are in this state after someone parsed the '</' that
|
| 730 |
+
# started the end of the closing tag
|
| 731 |
+
'html-end-tag': [
|
| 732 |
+
# this is a star, because </> is allowed
|
| 733 |
+
(r'[\w\-:]*>', String.Single, '#pop'),
|
| 734 |
+
],
|
| 735 |
+
|
| 736 |
+
# we are in this state after having parsed '<ident(:ident)?'
|
| 737 |
+
# we thus parse a possibly empty list of attributes
|
| 738 |
+
'html-attr': [
|
| 739 |
+
(r'\s+', Text),
|
| 740 |
+
(r'[\w\-:]+=', String.Single, 'html-attr-value'),
|
| 741 |
+
(r'/>', String.Single, '#pop'),
|
| 742 |
+
(r'>', String.Single, ('#pop', 'html-content')),
|
| 743 |
+
],
|
| 744 |
+
|
| 745 |
+
'html-attr-value': [
|
| 746 |
+
(r"'", String.Single, ('#pop', 'single-string')),
|
| 747 |
+
(r'"', String.Single, ('#pop', 'string')),
|
| 748 |
+
(r'#'+ident_re, String.Single, '#pop'),
|
| 749 |
+
(r'#(?=\{)', String.Single, ('#pop', 'root')),
|
| 750 |
+
(r'[^"\'{`=<>]+', String.Single, '#pop'),
|
| 751 |
+
(r'\{', Operator, ('#pop', 'root')), # this is a tail call!
|
| 752 |
+
],
|
| 753 |
+
|
| 754 |
+
# we should probably deal with '\' escapes here
|
| 755 |
+
'html-content': [
|
| 756 |
+
(r'<!--', Comment, 'html-comment'),
|
| 757 |
+
(r'</', String.Single, ('#pop', 'html-end-tag')),
|
| 758 |
+
(r'<', String.Single, 'html-open-tag'),
|
| 759 |
+
(r'\{', Operator, 'root'),
|
| 760 |
+
(r'[^<{]+', String.Single),
|
| 761 |
+
],
|
| 762 |
+
|
| 763 |
+
'html-comment': [
|
| 764 |
+
(r'-->', Comment, '#pop'),
|
| 765 |
+
(r'[^\-]+|-', Comment),
|
| 766 |
+
],
|
| 767 |
+
}
|
| 768 |
+
|
| 769 |
+
|
| 770 |
+
class ReasonLexer(RegexLexer):
|
| 771 |
+
"""
|
| 772 |
+
For the ReasonML language.
|
| 773 |
+
"""
|
| 774 |
+
|
| 775 |
+
name = 'ReasonML'
|
| 776 |
+
url = 'https://reasonml.github.io/'
|
| 777 |
+
aliases = ['reasonml', 'reason']
|
| 778 |
+
filenames = ['*.re', '*.rei']
|
| 779 |
+
mimetypes = ['text/x-reasonml']
|
| 780 |
+
version_added = '2.6'
|
| 781 |
+
|
| 782 |
+
keywords = (
|
| 783 |
+
'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done', 'downto',
|
| 784 |
+
'else', 'end', 'exception', 'external', 'false', 'for', 'fun', 'esfun',
|
| 785 |
+
'function', 'functor', 'if', 'in', 'include', 'inherit', 'initializer', 'lazy',
|
| 786 |
+
'let', 'switch', 'module', 'pub', 'mutable', 'new', 'nonrec', 'object', 'of',
|
| 787 |
+
'open', 'pri', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try',
|
| 788 |
+
'type', 'val', 'virtual', 'when', 'while', 'with',
|
| 789 |
+
)
|
| 790 |
+
keyopts = (
|
| 791 |
+
'!=', '#', '&', '&&', r'\(', r'\)', r'\*', r'\+', ',', '-',
|
| 792 |
+
r'-\.', '=>', r'\.', r'\.\.', r'\.\.\.', ':', '::', ':=', ':>', ';', ';;', '<',
|
| 793 |
+
'<-', '=', '>', '>]', r'>\}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>',
|
| 794 |
+
r'\[\|', ']', '_', '`', r'\{', r'\{<', r'\|', r'\|\|', r'\|]', r'\}', '~'
|
| 795 |
+
)
|
| 796 |
+
|
| 797 |
+
operators = r'[!$%&*+\./:<=>?@^|~-]'
|
| 798 |
+
word_operators = ('and', 'asr', 'land', 'lor', 'lsl', 'lsr', 'lxor', 'mod', 'or')
|
| 799 |
+
prefix_syms = r'[!?~]'
|
| 800 |
+
infix_syms = r'[=<>@^|&+\*/$%-]'
|
| 801 |
+
primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array')
|
| 802 |
+
|
| 803 |
+
tokens = {
|
| 804 |
+
'escape-sequence': [
|
| 805 |
+
(r'\\[\\"\'ntbr]', String.Escape),
|
| 806 |
+
(r'\\[0-9]{3}', String.Escape),
|
| 807 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 808 |
+
],
|
| 809 |
+
'root': [
|
| 810 |
+
(r'\s+', Text),
|
| 811 |
+
(r'false|true|\(\)|\[\]', Name.Builtin.Pseudo),
|
| 812 |
+
(r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'),
|
| 813 |
+
(r'\b([A-Z][\w\']*)', Name.Class),
|
| 814 |
+
(r'//.*?\n', Comment.Single),
|
| 815 |
+
(r'\/\*(?!/)', Comment.Multiline, 'comment'),
|
| 816 |
+
(r'\b({})\b'.format('|'.join(keywords)), Keyword),
|
| 817 |
+
(r'({})'.format('|'.join(keyopts[::-1])), Operator.Word),
|
| 818 |
+
(rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
|
| 819 |
+
(r'\b({})\b'.format('|'.join(word_operators)), Operator.Word),
|
| 820 |
+
(r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
|
| 821 |
+
|
| 822 |
+
(r"[^\W\d][\w']*", Name),
|
| 823 |
+
|
| 824 |
+
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
|
| 825 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
|
| 826 |
+
(r'0[oO][0-7][0-7_]*', Number.Oct),
|
| 827 |
+
(r'0[bB][01][01_]*', Number.Bin),
|
| 828 |
+
(r'\d[\d_]*', Number.Integer),
|
| 829 |
+
|
| 830 |
+
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
|
| 831 |
+
String.Char),
|
| 832 |
+
(r"'.'", String.Char),
|
| 833 |
+
(r"'", Keyword),
|
| 834 |
+
|
| 835 |
+
(r'"', String.Double, 'string'),
|
| 836 |
+
|
| 837 |
+
(r'[~?][a-z][\w\']*:', Name.Variable),
|
| 838 |
+
],
|
| 839 |
+
'comment': [
|
| 840 |
+
(r'[^/*]+', Comment.Multiline),
|
| 841 |
+
(r'\/\*', Comment.Multiline, '#push'),
|
| 842 |
+
(r'\*\/', Comment.Multiline, '#pop'),
|
| 843 |
+
(r'\*', Comment.Multiline),
|
| 844 |
+
],
|
| 845 |
+
'string': [
|
| 846 |
+
(r'[^\\"]+', String.Double),
|
| 847 |
+
include('escape-sequence'),
|
| 848 |
+
(r'\\\n', String.Double),
|
| 849 |
+
(r'"', String.Double, '#pop'),
|
| 850 |
+
],
|
| 851 |
+
'dotted': [
|
| 852 |
+
(r'\s+', Text),
|
| 853 |
+
(r'\.', Punctuation),
|
| 854 |
+
(r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace),
|
| 855 |
+
(r'[A-Z][\w\']*', Name.Class, '#pop'),
|
| 856 |
+
(r'[a-z_][\w\']*', Name, '#pop'),
|
| 857 |
+
default('#pop'),
|
| 858 |
+
],
|
| 859 |
+
}
|
| 860 |
+
|
| 861 |
+
|
| 862 |
+
class FStarLexer(RegexLexer):
|
| 863 |
+
"""
|
| 864 |
+
For the F* language.
|
| 865 |
+
"""
|
| 866 |
+
|
| 867 |
+
name = 'FStar'
|
| 868 |
+
url = 'https://www.fstar-lang.org/'
|
| 869 |
+
aliases = ['fstar']
|
| 870 |
+
filenames = ['*.fst', '*.fsti']
|
| 871 |
+
mimetypes = ['text/x-fstar']
|
| 872 |
+
version_added = '2.7'
|
| 873 |
+
|
| 874 |
+
keywords = (
|
| 875 |
+
'abstract', 'attributes', 'noeq', 'unopteq', 'and'
|
| 876 |
+
'begin', 'by', 'default', 'effect', 'else', 'end', 'ensures',
|
| 877 |
+
'exception', 'exists', 'false', 'forall', 'fun', 'function', 'if',
|
| 878 |
+
'in', 'include', 'inline', 'inline_for_extraction', 'irreducible',
|
| 879 |
+
'logic', 'match', 'module', 'mutable', 'new', 'new_effect', 'noextract',
|
| 880 |
+
'of', 'open', 'opaque', 'private', 'range_of', 'reifiable',
|
| 881 |
+
'reify', 'reflectable', 'requires', 'set_range_of', 'sub_effect',
|
| 882 |
+
'synth', 'then', 'total', 'true', 'try', 'type', 'unfold', 'unfoldable',
|
| 883 |
+
'val', 'when', 'with', 'not'
|
| 884 |
+
)
|
| 885 |
+
decl_keywords = ('let', 'rec')
|
| 886 |
+
assume_keywords = ('assume', 'admit', 'assert', 'calc')
|
| 887 |
+
keyopts = (
|
| 888 |
+
r'~', r'-', r'/\\', r'\\/', r'<:', r'<@', r'\(\|', r'\|\)', r'#', r'u#',
|
| 889 |
+
r'&', r'\(', r'\)', r'\(\)', r',', r'~>', r'->', r'<-', r'<--', r'<==>',
|
| 890 |
+
r'==>', r'\.', r'\?', r'\?\.', r'\.\[', r'\.\(', r'\.\(\|', r'\.\[\|',
|
| 891 |
+
r'\{:pattern', r':', r'::', r':=', r';', r';;', r'=', r'%\[', r'!\{',
|
| 892 |
+
r'\[', r'\[@', r'\[\|', r'\|>', r'\]', r'\|\]', r'\{', r'\|', r'\}', r'\$'
|
| 893 |
+
)
|
| 894 |
+
|
| 895 |
+
operators = r'[!$%&*+\./:<=>?@^|~-]'
|
| 896 |
+
prefix_syms = r'[!?~]'
|
| 897 |
+
infix_syms = r'[=<>@^|&+\*/$%-]'
|
| 898 |
+
primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array')
|
| 899 |
+
|
| 900 |
+
tokens = {
|
| 901 |
+
'escape-sequence': [
|
| 902 |
+
(r'\\[\\"\'ntbr]', String.Escape),
|
| 903 |
+
(r'\\[0-9]{3}', String.Escape),
|
| 904 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 905 |
+
],
|
| 906 |
+
'root': [
|
| 907 |
+
(r'\s+', Text),
|
| 908 |
+
(r'false|true|False|True|\(\)|\[\]', Name.Builtin.Pseudo),
|
| 909 |
+
(r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'),
|
| 910 |
+
(r'\b([A-Z][\w\']*)', Name.Class),
|
| 911 |
+
(r'\(\*(?![)])', Comment, 'comment'),
|
| 912 |
+
(r'\/\/.+$', Comment),
|
| 913 |
+
(r'\b({})\b'.format('|'.join(keywords)), Keyword),
|
| 914 |
+
(r'\b({})\b'.format('|'.join(assume_keywords)), Name.Exception),
|
| 915 |
+
(r'\b({})\b'.format('|'.join(decl_keywords)), Keyword.Declaration),
|
| 916 |
+
(r'({})'.format('|'.join(keyopts[::-1])), Operator),
|
| 917 |
+
(rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
|
| 918 |
+
(r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
|
| 919 |
+
|
| 920 |
+
(r"[^\W\d][\w']*", Name),
|
| 921 |
+
|
| 922 |
+
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
|
| 923 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
|
| 924 |
+
(r'0[oO][0-7][0-7_]*', Number.Oct),
|
| 925 |
+
(r'0[bB][01][01_]*', Number.Bin),
|
| 926 |
+
(r'\d[\d_]*', Number.Integer),
|
| 927 |
+
|
| 928 |
+
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
|
| 929 |
+
String.Char),
|
| 930 |
+
(r"'.'", String.Char),
|
| 931 |
+
(r"'", Keyword), # a stray quote is another syntax element
|
| 932 |
+
(r"\`([\w\'.]+)\`", Operator.Word), # for infix applications
|
| 933 |
+
(r"\`", Keyword), # for quoting
|
| 934 |
+
(r'"', String.Double, 'string'),
|
| 935 |
+
|
| 936 |
+
(r'[~?][a-z][\w\']*:', Name.Variable),
|
| 937 |
+
],
|
| 938 |
+
'comment': [
|
| 939 |
+
(r'[^(*)]+', Comment),
|
| 940 |
+
(r'\(\*', Comment, '#push'),
|
| 941 |
+
(r'\*\)', Comment, '#pop'),
|
| 942 |
+
(r'[(*)]', Comment),
|
| 943 |
+
],
|
| 944 |
+
'string': [
|
| 945 |
+
(r'[^\\"]+', String.Double),
|
| 946 |
+
include('escape-sequence'),
|
| 947 |
+
(r'\\\n', String.Double),
|
| 948 |
+
(r'"', String.Double, '#pop'),
|
| 949 |
+
],
|
| 950 |
+
'dotted': [
|
| 951 |
+
(r'\s+', Text),
|
| 952 |
+
(r'\.', Punctuation),
|
| 953 |
+
(r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace),
|
| 954 |
+
(r'[A-Z][\w\']*', Name.Class, '#pop'),
|
| 955 |
+
(r'[a-z_][\w\']*', Name, '#pop'),
|
| 956 |
+
default('#pop'),
|
| 957 |
+
],
|
| 958 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/modeling.py
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, using, default
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Whitespace
|
| 16 |
+
|
| 17 |
+
from pygments.lexers.html import HtmlLexer
|
| 18 |
+
from pygments.lexers import _stan_builtins
|
| 19 |
+
|
| 20 |
+
__all__ = ['ModelicaLexer', 'BugsLexer', 'JagsLexer', 'StanLexer']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class ModelicaLexer(RegexLexer):
|
| 24 |
+
"""
|
| 25 |
+
For Modelica source code.
|
| 26 |
+
"""
|
| 27 |
+
name = 'Modelica'
|
| 28 |
+
url = 'http://www.modelica.org/'
|
| 29 |
+
aliases = ['modelica']
|
| 30 |
+
filenames = ['*.mo']
|
| 31 |
+
mimetypes = ['text/x-modelica']
|
| 32 |
+
version_added = '1.1'
|
| 33 |
+
|
| 34 |
+
flags = re.DOTALL | re.MULTILINE
|
| 35 |
+
|
| 36 |
+
_name = r"(?:'(?:[^\\']|\\.)+'|[a-zA-Z_]\w*)"
|
| 37 |
+
|
| 38 |
+
tokens = {
|
| 39 |
+
'whitespace': [
|
| 40 |
+
(r'[\s\ufeff]+', Text),
|
| 41 |
+
(r'//[^\n]*\n?', Comment.Single),
|
| 42 |
+
(r'/\*.*?\*/', Comment.Multiline)
|
| 43 |
+
],
|
| 44 |
+
'root': [
|
| 45 |
+
include('whitespace'),
|
| 46 |
+
(r'"', String.Double, 'string'),
|
| 47 |
+
(r'[()\[\]{},;]+', Punctuation),
|
| 48 |
+
(r'\.?[*^/+-]|\.|<>|[<>:=]=?', Operator),
|
| 49 |
+
(r'\d+(\.?\d*[eE][-+]?\d+|\.\d*)', Number.Float),
|
| 50 |
+
(r'\d+', Number.Integer),
|
| 51 |
+
(r'(abs|acos|actualStream|array|asin|assert|AssertionLevel|atan|'
|
| 52 |
+
r'atan2|backSample|Boolean|cardinality|cat|ceil|change|Clock|'
|
| 53 |
+
r'Connections|cos|cosh|cross|delay|diagonal|div|edge|exp|'
|
| 54 |
+
r'ExternalObject|fill|floor|getInstanceName|hold|homotopy|'
|
| 55 |
+
r'identity|inStream|integer|Integer|interval|inverse|isPresent|'
|
| 56 |
+
r'linspace|log|log10|matrix|max|min|mod|ndims|noClock|noEvent|'
|
| 57 |
+
r'ones|outerProduct|pre|previous|product|Real|reinit|rem|rooted|'
|
| 58 |
+
r'sample|scalar|semiLinear|shiftSample|sign|sin|sinh|size|skew|'
|
| 59 |
+
r'smooth|spatialDistribution|sqrt|StateSelect|String|subSample|'
|
| 60 |
+
r'sum|superSample|symmetric|tan|tanh|terminal|terminate|time|'
|
| 61 |
+
r'transpose|vector|zeros)\b', Name.Builtin),
|
| 62 |
+
(r'(algorithm|annotation|break|connect|constant|constrainedby|der|'
|
| 63 |
+
r'discrete|each|else|elseif|elsewhen|encapsulated|enumeration|'
|
| 64 |
+
r'equation|exit|expandable|extends|external|firstTick|final|flow|for|if|'
|
| 65 |
+
r'import|impure|in|initial|inner|input|interval|loop|nondiscrete|outer|'
|
| 66 |
+
r'output|parameter|partial|protected|public|pure|redeclare|'
|
| 67 |
+
r'replaceable|return|stream|then|when|while)\b',
|
| 68 |
+
Keyword.Reserved),
|
| 69 |
+
(r'(and|not|or)\b', Operator.Word),
|
| 70 |
+
(r'(block|class|connector|end|function|model|operator|package|'
|
| 71 |
+
r'record|type)\b', Keyword.Reserved, 'class'),
|
| 72 |
+
(r'(false|true)\b', Keyword.Constant),
|
| 73 |
+
(r'within\b', Keyword.Reserved, 'package-prefix'),
|
| 74 |
+
(_name, Name)
|
| 75 |
+
],
|
| 76 |
+
'class': [
|
| 77 |
+
include('whitespace'),
|
| 78 |
+
(r'(function|record)\b', Keyword.Reserved),
|
| 79 |
+
(r'(if|for|when|while)\b', Keyword.Reserved, '#pop'),
|
| 80 |
+
(_name, Name.Class, '#pop'),
|
| 81 |
+
default('#pop')
|
| 82 |
+
],
|
| 83 |
+
'package-prefix': [
|
| 84 |
+
include('whitespace'),
|
| 85 |
+
(_name, Name.Namespace, '#pop'),
|
| 86 |
+
default('#pop')
|
| 87 |
+
],
|
| 88 |
+
'string': [
|
| 89 |
+
(r'"', String.Double, '#pop'),
|
| 90 |
+
(r'\\[\'"?\\abfnrtv]', String.Escape),
|
| 91 |
+
(r'(?i)<\s*html\s*>([^\\"]|\\.)+?(<\s*/\s*html\s*>|(?="))',
|
| 92 |
+
using(HtmlLexer)),
|
| 93 |
+
(r'<|\\?[^"\\<]+', String.Double)
|
| 94 |
+
]
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
class BugsLexer(RegexLexer):
|
| 99 |
+
"""
|
| 100 |
+
Pygments Lexer for OpenBugs and WinBugs
|
| 101 |
+
models.
|
| 102 |
+
"""
|
| 103 |
+
|
| 104 |
+
name = 'BUGS'
|
| 105 |
+
aliases = ['bugs', 'winbugs', 'openbugs']
|
| 106 |
+
filenames = ['*.bug']
|
| 107 |
+
url = 'https://www.mrc-bsu.cam.ac.uk/software/bugs/openbugs'
|
| 108 |
+
version_added = '1.6'
|
| 109 |
+
|
| 110 |
+
_FUNCTIONS = (
|
| 111 |
+
# Scalar functions
|
| 112 |
+
'abs', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh',
|
| 113 |
+
'cloglog', 'cos', 'cosh', 'cumulative', 'cut', 'density', 'deviance',
|
| 114 |
+
'equals', 'expr', 'gammap', 'ilogit', 'icloglog', 'integral', 'log',
|
| 115 |
+
'logfact', 'loggam', 'logit', 'max', 'min', 'phi', 'post.p.value',
|
| 116 |
+
'pow', 'prior.p.value', 'probit', 'replicate.post', 'replicate.prior',
|
| 117 |
+
'round', 'sin', 'sinh', 'solution', 'sqrt', 'step', 'tan', 'tanh',
|
| 118 |
+
'trunc',
|
| 119 |
+
# Vector functions
|
| 120 |
+
'inprod', 'interp.lin', 'inverse', 'logdet', 'mean', 'eigen.vals',
|
| 121 |
+
'ode', 'prod', 'p.valueM', 'rank', 'ranked', 'replicate.postM',
|
| 122 |
+
'sd', 'sort', 'sum',
|
| 123 |
+
# Special
|
| 124 |
+
'D', 'I', 'F', 'T', 'C')
|
| 125 |
+
""" OpenBUGS built-in functions
|
| 126 |
+
|
| 127 |
+
From http://www.openbugs.info/Manuals/ModelSpecification.html#ContentsAII
|
| 128 |
+
|
| 129 |
+
This also includes
|
| 130 |
+
|
| 131 |
+
- T, C, I : Truncation and censoring.
|
| 132 |
+
``T`` and ``C`` are in OpenBUGS. ``I`` in WinBUGS.
|
| 133 |
+
- D : ODE
|
| 134 |
+
- F : Functional http://www.openbugs.info/Examples/Functionals.html
|
| 135 |
+
|
| 136 |
+
"""
|
| 137 |
+
|
| 138 |
+
_DISTRIBUTIONS = ('dbern', 'dbin', 'dcat', 'dnegbin', 'dpois',
|
| 139 |
+
'dhyper', 'dbeta', 'dchisqr', 'ddexp', 'dexp',
|
| 140 |
+
'dflat', 'dgamma', 'dgev', 'df', 'dggamma', 'dgpar',
|
| 141 |
+
'dloglik', 'dlnorm', 'dlogis', 'dnorm', 'dpar',
|
| 142 |
+
'dt', 'dunif', 'dweib', 'dmulti', 'ddirch', 'dmnorm',
|
| 143 |
+
'dmt', 'dwish')
|
| 144 |
+
""" OpenBUGS built-in distributions
|
| 145 |
+
|
| 146 |
+
Functions from
|
| 147 |
+
http://www.openbugs.info/Manuals/ModelSpecification.html#ContentsAI
|
| 148 |
+
"""
|
| 149 |
+
|
| 150 |
+
tokens = {
|
| 151 |
+
'whitespace': [
|
| 152 |
+
(r"\s+", Text),
|
| 153 |
+
],
|
| 154 |
+
'comments': [
|
| 155 |
+
# Comments
|
| 156 |
+
(r'#.*$', Comment.Single),
|
| 157 |
+
],
|
| 158 |
+
'root': [
|
| 159 |
+
# Comments
|
| 160 |
+
include('comments'),
|
| 161 |
+
include('whitespace'),
|
| 162 |
+
# Block start
|
| 163 |
+
(r'(model)(\s+)(\{)',
|
| 164 |
+
bygroups(Keyword.Namespace, Text, Punctuation)),
|
| 165 |
+
# Reserved Words
|
| 166 |
+
(r'(for|in)(?![\w.])', Keyword.Reserved),
|
| 167 |
+
# Built-in Functions
|
| 168 |
+
(r'({})(?=\s*\()'.format(r'|'.join(_FUNCTIONS + _DISTRIBUTIONS)),
|
| 169 |
+
Name.Builtin),
|
| 170 |
+
# Regular variable names
|
| 171 |
+
(r'[A-Za-z][\w.]*', Name),
|
| 172 |
+
# Number Literals
|
| 173 |
+
(r'[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?', Number),
|
| 174 |
+
# Punctuation
|
| 175 |
+
(r'\[|\]|\(|\)|:|,|;', Punctuation),
|
| 176 |
+
# Assignment operators
|
| 177 |
+
# SLexer makes these tokens Operators.
|
| 178 |
+
(r'<-|~', Operator),
|
| 179 |
+
# Infix and prefix operators
|
| 180 |
+
(r'\+|-|\*|/', Operator),
|
| 181 |
+
# Block
|
| 182 |
+
(r'[{}]', Punctuation),
|
| 183 |
+
]
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
def analyse_text(text):
|
| 187 |
+
if re.search(r"^\s*model\s*{", text, re.M):
|
| 188 |
+
return 0.7
|
| 189 |
+
else:
|
| 190 |
+
return 0.0
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
class JagsLexer(RegexLexer):
|
| 194 |
+
"""
|
| 195 |
+
Pygments Lexer for JAGS.
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
name = 'JAGS'
|
| 199 |
+
aliases = ['jags']
|
| 200 |
+
filenames = ['*.jag', '*.bug']
|
| 201 |
+
url = 'https://mcmc-jags.sourceforge.io'
|
| 202 |
+
version_added = '1.6'
|
| 203 |
+
|
| 204 |
+
# JAGS
|
| 205 |
+
_FUNCTIONS = (
|
| 206 |
+
'abs', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh',
|
| 207 |
+
'cos', 'cosh', 'cloglog',
|
| 208 |
+
'equals', 'exp', 'icloglog', 'ifelse', 'ilogit', 'log', 'logfact',
|
| 209 |
+
'loggam', 'logit', 'phi', 'pow', 'probit', 'round', 'sin', 'sinh',
|
| 210 |
+
'sqrt', 'step', 'tan', 'tanh', 'trunc', 'inprod', 'interp.lin',
|
| 211 |
+
'logdet', 'max', 'mean', 'min', 'prod', 'sum', 'sd', 'inverse',
|
| 212 |
+
'rank', 'sort', 't', 'acos', 'acosh', 'asin', 'asinh', 'atan',
|
| 213 |
+
# Truncation/Censoring (should I include)
|
| 214 |
+
'T', 'I')
|
| 215 |
+
# Distributions with density, probability and quartile functions
|
| 216 |
+
_DISTRIBUTIONS = tuple(f'[dpq]{x}' for x in
|
| 217 |
+
('bern', 'beta', 'dchiqsqr', 'ddexp', 'dexp',
|
| 218 |
+
'df', 'gamma', 'gen.gamma', 'logis', 'lnorm',
|
| 219 |
+
'negbin', 'nchisqr', 'norm', 'par', 'pois', 'weib'))
|
| 220 |
+
# Other distributions without density and probability
|
| 221 |
+
_OTHER_DISTRIBUTIONS = (
|
| 222 |
+
'dt', 'dunif', 'dbetabin', 'dbern', 'dbin', 'dcat', 'dhyper',
|
| 223 |
+
'ddirch', 'dmnorm', 'dwish', 'dmt', 'dmulti', 'dbinom', 'dchisq',
|
| 224 |
+
'dnbinom', 'dweibull', 'ddirich')
|
| 225 |
+
|
| 226 |
+
tokens = {
|
| 227 |
+
'whitespace': [
|
| 228 |
+
(r"\s+", Text),
|
| 229 |
+
],
|
| 230 |
+
'names': [
|
| 231 |
+
# Regular variable names
|
| 232 |
+
(r'[a-zA-Z][\w.]*\b', Name),
|
| 233 |
+
],
|
| 234 |
+
'comments': [
|
| 235 |
+
# do not use stateful comments
|
| 236 |
+
(r'(?s)/\*.*?\*/', Comment.Multiline),
|
| 237 |
+
# Comments
|
| 238 |
+
(r'#.*$', Comment.Single),
|
| 239 |
+
],
|
| 240 |
+
'root': [
|
| 241 |
+
# Comments
|
| 242 |
+
include('comments'),
|
| 243 |
+
include('whitespace'),
|
| 244 |
+
# Block start
|
| 245 |
+
(r'(model|data)(\s+)(\{)',
|
| 246 |
+
bygroups(Keyword.Namespace, Text, Punctuation)),
|
| 247 |
+
(r'var(?![\w.])', Keyword.Declaration),
|
| 248 |
+
# Reserved Words
|
| 249 |
+
(r'(for|in)(?![\w.])', Keyword.Reserved),
|
| 250 |
+
# Builtins
|
| 251 |
+
# Need to use lookahead because . is a valid char
|
| 252 |
+
(r'({})(?=\s*\()'.format(r'|'.join(_FUNCTIONS
|
| 253 |
+
+ _DISTRIBUTIONS
|
| 254 |
+
+ _OTHER_DISTRIBUTIONS)),
|
| 255 |
+
Name.Builtin),
|
| 256 |
+
# Names
|
| 257 |
+
include('names'),
|
| 258 |
+
# Number Literals
|
| 259 |
+
(r'[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?', Number),
|
| 260 |
+
(r'\[|\]|\(|\)|:|,|;', Punctuation),
|
| 261 |
+
# Assignment operators
|
| 262 |
+
(r'<-|~', Operator),
|
| 263 |
+
# # JAGS includes many more than OpenBUGS
|
| 264 |
+
(r'\+|-|\*|\/|\|\|[&]{2}|[<>=]=?|\^|%.*?%', Operator),
|
| 265 |
+
(r'[{}]', Punctuation),
|
| 266 |
+
]
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
def analyse_text(text):
|
| 270 |
+
if re.search(r'^\s*model\s*\{', text, re.M):
|
| 271 |
+
if re.search(r'^\s*data\s*\{', text, re.M):
|
| 272 |
+
return 0.9
|
| 273 |
+
elif re.search(r'^\s*var', text, re.M):
|
| 274 |
+
return 0.9
|
| 275 |
+
else:
|
| 276 |
+
return 0.3
|
| 277 |
+
else:
|
| 278 |
+
return 0
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
class StanLexer(RegexLexer):
|
| 282 |
+
"""Pygments Lexer for Stan models.
|
| 283 |
+
|
| 284 |
+
The Stan modeling language is specified in the *Stan Modeling Language
|
| 285 |
+
User's Guide and Reference Manual, v2.17.0*,
|
| 286 |
+
`pdf <https://github.com/stan-dev/stan/releases/download/v2.17.0/stan-reference-2.17.0.pdf>`__.
|
| 287 |
+
"""
|
| 288 |
+
|
| 289 |
+
name = 'Stan'
|
| 290 |
+
aliases = ['stan']
|
| 291 |
+
filenames = ['*.stan']
|
| 292 |
+
url = 'https://mc-stan.org'
|
| 293 |
+
version_added = '1.6'
|
| 294 |
+
|
| 295 |
+
tokens = {
|
| 296 |
+
'whitespace': [
|
| 297 |
+
(r"\s+", Text),
|
| 298 |
+
],
|
| 299 |
+
'comments': [
|
| 300 |
+
(r'(?s)/\*.*?\*/', Comment.Multiline),
|
| 301 |
+
# Comments
|
| 302 |
+
(r'(//|#).*$', Comment.Single),
|
| 303 |
+
],
|
| 304 |
+
'root': [
|
| 305 |
+
(r'"[^"]*"', String),
|
| 306 |
+
# Comments
|
| 307 |
+
include('comments'),
|
| 308 |
+
# block start
|
| 309 |
+
include('whitespace'),
|
| 310 |
+
# Block start
|
| 311 |
+
(r'({})(\s*)(\{{)'.format(r'|'.join(('functions', 'data', r'transformed\s+?data',
|
| 312 |
+
'parameters', r'transformed\s+parameters',
|
| 313 |
+
'model', r'generated\s+quantities'))),
|
| 314 |
+
bygroups(Keyword.Namespace, Text, Punctuation)),
|
| 315 |
+
# target keyword
|
| 316 |
+
(r'target\s*\+=', Keyword),
|
| 317 |
+
# jacobian += statement
|
| 318 |
+
(r'jacobian\s*\+=', Keyword),
|
| 319 |
+
# Reserved Words
|
| 320 |
+
(r'({})\b'.format(r'|'.join(_stan_builtins.KEYWORDS)), Keyword),
|
| 321 |
+
# Truncation
|
| 322 |
+
(r'T(?=\s*\[)', Keyword),
|
| 323 |
+
# Data types
|
| 324 |
+
(r'({})\b'.format(r'|'.join(_stan_builtins.TYPES)), Keyword.Type),
|
| 325 |
+
# < should be punctuation, but elsewhere I can't tell if it is in
|
| 326 |
+
# a range constraint
|
| 327 |
+
(r'(<)(\s*)(upper|lower|offset|multiplier)(\s*)(=)',
|
| 328 |
+
bygroups(Operator, Whitespace, Keyword, Whitespace, Punctuation)),
|
| 329 |
+
(r'(,)(\s*)(upper)(\s*)(=)',
|
| 330 |
+
bygroups(Punctuation, Whitespace, Keyword, Whitespace, Punctuation)),
|
| 331 |
+
# Punctuation
|
| 332 |
+
(r"[;,\[\]()]", Punctuation),
|
| 333 |
+
# Builtin
|
| 334 |
+
(r'({})(?=\s*\()'.format('|'.join(_stan_builtins.FUNCTIONS)), Name.Builtin),
|
| 335 |
+
(r'(~)(\s*)({})(?=\s*\()'.format('|'.join(_stan_builtins.DISTRIBUTIONS)),
|
| 336 |
+
bygroups(Operator, Whitespace, Name.Builtin)),
|
| 337 |
+
# Special names ending in __, like lp__
|
| 338 |
+
(r'[A-Za-z]\w*__\b', Name.Builtin.Pseudo),
|
| 339 |
+
(r'({})\b'.format(r'|'.join(_stan_builtins.RESERVED)), Keyword.Reserved),
|
| 340 |
+
# user-defined functions
|
| 341 |
+
(r'[A-Za-z]\w*(?=\s*\()]', Name.Function),
|
| 342 |
+
# Imaginary Literals
|
| 343 |
+
(r'[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?i', Number.Float),
|
| 344 |
+
(r'\.[0-9]+([eE][+-]?[0-9]+)?i', Number.Float),
|
| 345 |
+
(r'[0-9]+i', Number.Float),
|
| 346 |
+
# Real Literals
|
| 347 |
+
(r'[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?', Number.Float),
|
| 348 |
+
(r'\.[0-9]+([eE][+-]?[0-9]+)?', Number.Float),
|
| 349 |
+
# Integer Literals
|
| 350 |
+
(r'[0-9]+', Number.Integer),
|
| 351 |
+
# Regular variable names
|
| 352 |
+
(r'[A-Za-z]\w*\b', Name),
|
| 353 |
+
# Assignment operators
|
| 354 |
+
(r'<-|(?:\+|-|\.?/|\.?\*|=)?=|~', Operator),
|
| 355 |
+
# Infix, prefix and postfix operators (and = )
|
| 356 |
+
(r"\+|-|\.?\*|\.?/|\\|'|\.?\^|!=?|<=?|>=?|\|\||&&|%|\?|:|%/%|!", Operator),
|
| 357 |
+
# Block delimiters
|
| 358 |
+
(r'[{}]', Punctuation),
|
| 359 |
+
# Distribution |
|
| 360 |
+
(r'\|', Punctuation)
|
| 361 |
+
]
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
def analyse_text(text):
|
| 365 |
+
if re.search(r'^\s*parameters\s*\{', text, re.M):
|
| 366 |
+
return 1.0
|
| 367 |
+
else:
|
| 368 |
+
return 0.0
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/mojo.py
ADDED
|
@@ -0,0 +1,707 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.mojo
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Mojo and related languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import keyword
|
| 12 |
+
|
| 13 |
+
from pygments import unistring as uni
|
| 14 |
+
from pygments.lexer import (
|
| 15 |
+
RegexLexer,
|
| 16 |
+
bygroups,
|
| 17 |
+
combined,
|
| 18 |
+
default,
|
| 19 |
+
include,
|
| 20 |
+
this,
|
| 21 |
+
using,
|
| 22 |
+
words,
|
| 23 |
+
)
|
| 24 |
+
from pygments.token import (
|
| 25 |
+
Comment,
|
| 26 |
+
# Error,
|
| 27 |
+
Keyword,
|
| 28 |
+
Name,
|
| 29 |
+
Number,
|
| 30 |
+
Operator,
|
| 31 |
+
Punctuation,
|
| 32 |
+
String,
|
| 33 |
+
Text,
|
| 34 |
+
Whitespace,
|
| 35 |
+
)
|
| 36 |
+
from pygments.util import shebang_matches
|
| 37 |
+
|
| 38 |
+
__all__ = ["MojoLexer"]
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class MojoLexer(RegexLexer):
|
| 42 |
+
"""
|
| 43 |
+
For Mojo source code (version 24.2.1).
|
| 44 |
+
"""
|
| 45 |
+
|
| 46 |
+
name = "Mojo"
|
| 47 |
+
url = "https://docs.modular.com/mojo/"
|
| 48 |
+
aliases = ["mojo", "🔥"]
|
| 49 |
+
filenames = [
|
| 50 |
+
"*.mojo",
|
| 51 |
+
"*.🔥",
|
| 52 |
+
]
|
| 53 |
+
mimetypes = [
|
| 54 |
+
"text/x-mojo",
|
| 55 |
+
"application/x-mojo",
|
| 56 |
+
]
|
| 57 |
+
version_added = "2.18"
|
| 58 |
+
|
| 59 |
+
uni_name = f"[{uni.xid_start}][{uni.xid_continue}]*"
|
| 60 |
+
|
| 61 |
+
def innerstring_rules(ttype):
|
| 62 |
+
return [
|
| 63 |
+
# the old style '%s' % (...) string formatting (still valid in Py3)
|
| 64 |
+
(
|
| 65 |
+
r"%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?"
|
| 66 |
+
"[hlL]?[E-GXc-giorsaux%]",
|
| 67 |
+
String.Interpol,
|
| 68 |
+
),
|
| 69 |
+
# the new style '{}'.format(...) string formatting
|
| 70 |
+
(
|
| 71 |
+
r"\{"
|
| 72 |
+
r"((\w+)((\.\w+)|(\[[^\]]+\]))*)?" # field name
|
| 73 |
+
r"(\![sra])?" # conversion
|
| 74 |
+
r"(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?"
|
| 75 |
+
r"\}",
|
| 76 |
+
String.Interpol,
|
| 77 |
+
),
|
| 78 |
+
# backslashes, quotes and formatting signs must be parsed one at a time
|
| 79 |
+
(r'[^\\\'"%{\n]+', ttype),
|
| 80 |
+
(r'[\'"\\]', ttype),
|
| 81 |
+
# unhandled string formatting sign
|
| 82 |
+
(r"%|(\{{1,2})", ttype),
|
| 83 |
+
# newlines are an error (use "nl" state)
|
| 84 |
+
]
|
| 85 |
+
|
| 86 |
+
def fstring_rules(ttype):
|
| 87 |
+
return [
|
| 88 |
+
# Assuming that a '}' is the closing brace after format specifier.
|
| 89 |
+
# Sadly, this means that we won't detect syntax error. But it's
|
| 90 |
+
# more important to parse correct syntax correctly, than to
|
| 91 |
+
# highlight invalid syntax.
|
| 92 |
+
(r"\}", String.Interpol),
|
| 93 |
+
(r"\{", String.Interpol, "expr-inside-fstring"),
|
| 94 |
+
# backslashes, quotes and formatting signs must be parsed one at a time
|
| 95 |
+
(r'[^\\\'"{}\n]+', ttype),
|
| 96 |
+
(r'[\'"\\]', ttype),
|
| 97 |
+
# newlines are an error (use "nl" state)
|
| 98 |
+
]
|
| 99 |
+
|
| 100 |
+
tokens = {
|
| 101 |
+
"root": [
|
| 102 |
+
(r"\s+", Whitespace),
|
| 103 |
+
(
|
| 104 |
+
r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")',
|
| 105 |
+
bygroups(Whitespace, String.Affix, String.Doc),
|
| 106 |
+
),
|
| 107 |
+
(
|
| 108 |
+
r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')",
|
| 109 |
+
bygroups(Whitespace, String.Affix, String.Doc),
|
| 110 |
+
),
|
| 111 |
+
(r"\A#!.+$", Comment.Hashbang),
|
| 112 |
+
(r"#.*$", Comment.Single),
|
| 113 |
+
(r"\\\n", Whitespace),
|
| 114 |
+
(r"\\", Whitespace),
|
| 115 |
+
include("keywords"),
|
| 116 |
+
include("soft-keywords"),
|
| 117 |
+
# In the original PR, all the below here used ((?:\s|\\\s)+) to
|
| 118 |
+
# designate whitespace, but I can't find any example of this being
|
| 119 |
+
# needed in the example file, so we're replacing it with `\s+`.
|
| 120 |
+
(
|
| 121 |
+
r"(alias)(\s+)",
|
| 122 |
+
bygroups(Keyword, Whitespace),
|
| 123 |
+
"varname", # TODO varname the right fit?
|
| 124 |
+
),
|
| 125 |
+
(r"(var)(\s+)", bygroups(Keyword, Whitespace), "varname"),
|
| 126 |
+
(r"(def)(\s+)", bygroups(Keyword, Whitespace), "funcname"),
|
| 127 |
+
(r"(fn)(\s+)", bygroups(Keyword, Whitespace), "funcname"),
|
| 128 |
+
(
|
| 129 |
+
r"(class)(\s+)",
|
| 130 |
+
bygroups(Keyword, Whitespace),
|
| 131 |
+
"classname",
|
| 132 |
+
), # not implemented yet
|
| 133 |
+
(r"(struct)(\s+)", bygroups(Keyword, Whitespace), "structname"),
|
| 134 |
+
(r"(trait)(\s+)", bygroups(Keyword, Whitespace), "structname"),
|
| 135 |
+
(r"(from)(\s+)", bygroups(Keyword.Namespace, Whitespace), "fromimport"),
|
| 136 |
+
(r"(import)(\s+)", bygroups(Keyword.Namespace, Whitespace), "import"),
|
| 137 |
+
include("expr"),
|
| 138 |
+
],
|
| 139 |
+
"expr": [
|
| 140 |
+
# raw f-strings
|
| 141 |
+
(
|
| 142 |
+
'(?i)(rf|fr)(""")',
|
| 143 |
+
bygroups(String.Affix, String.Double),
|
| 144 |
+
combined("rfstringescape", "tdqf"),
|
| 145 |
+
),
|
| 146 |
+
(
|
| 147 |
+
"(?i)(rf|fr)(''')",
|
| 148 |
+
bygroups(String.Affix, String.Single),
|
| 149 |
+
combined("rfstringescape", "tsqf"),
|
| 150 |
+
),
|
| 151 |
+
(
|
| 152 |
+
'(?i)(rf|fr)(")',
|
| 153 |
+
bygroups(String.Affix, String.Double),
|
| 154 |
+
combined("rfstringescape", "dqf"),
|
| 155 |
+
),
|
| 156 |
+
(
|
| 157 |
+
"(?i)(rf|fr)(')",
|
| 158 |
+
bygroups(String.Affix, String.Single),
|
| 159 |
+
combined("rfstringescape", "sqf"),
|
| 160 |
+
),
|
| 161 |
+
# non-raw f-strings
|
| 162 |
+
(
|
| 163 |
+
'([fF])(""")',
|
| 164 |
+
bygroups(String.Affix, String.Double),
|
| 165 |
+
combined("fstringescape", "tdqf"),
|
| 166 |
+
),
|
| 167 |
+
(
|
| 168 |
+
"([fF])(''')",
|
| 169 |
+
bygroups(String.Affix, String.Single),
|
| 170 |
+
combined("fstringescape", "tsqf"),
|
| 171 |
+
),
|
| 172 |
+
(
|
| 173 |
+
'([fF])(")',
|
| 174 |
+
bygroups(String.Affix, String.Double),
|
| 175 |
+
combined("fstringescape", "dqf"),
|
| 176 |
+
),
|
| 177 |
+
(
|
| 178 |
+
"([fF])(')",
|
| 179 |
+
bygroups(String.Affix, String.Single),
|
| 180 |
+
combined("fstringescape", "sqf"),
|
| 181 |
+
),
|
| 182 |
+
# raw bytes and strings
|
| 183 |
+
('(?i)(rb|br|r)(""")', bygroups(String.Affix, String.Double), "tdqs"),
|
| 184 |
+
("(?i)(rb|br|r)(''')", bygroups(String.Affix, String.Single), "tsqs"),
|
| 185 |
+
('(?i)(rb|br|r)(")', bygroups(String.Affix, String.Double), "dqs"),
|
| 186 |
+
("(?i)(rb|br|r)(')", bygroups(String.Affix, String.Single), "sqs"),
|
| 187 |
+
# non-raw strings
|
| 188 |
+
(
|
| 189 |
+
'([uU]?)(""")',
|
| 190 |
+
bygroups(String.Affix, String.Double),
|
| 191 |
+
combined("stringescape", "tdqs"),
|
| 192 |
+
),
|
| 193 |
+
(
|
| 194 |
+
"([uU]?)(''')",
|
| 195 |
+
bygroups(String.Affix, String.Single),
|
| 196 |
+
combined("stringescape", "tsqs"),
|
| 197 |
+
),
|
| 198 |
+
(
|
| 199 |
+
'([uU]?)(")',
|
| 200 |
+
bygroups(String.Affix, String.Double),
|
| 201 |
+
combined("stringescape", "dqs"),
|
| 202 |
+
),
|
| 203 |
+
(
|
| 204 |
+
"([uU]?)(')",
|
| 205 |
+
bygroups(String.Affix, String.Single),
|
| 206 |
+
combined("stringescape", "sqs"),
|
| 207 |
+
),
|
| 208 |
+
# non-raw bytes
|
| 209 |
+
(
|
| 210 |
+
'([bB])(""")',
|
| 211 |
+
bygroups(String.Affix, String.Double),
|
| 212 |
+
combined("bytesescape", "tdqs"),
|
| 213 |
+
),
|
| 214 |
+
(
|
| 215 |
+
"([bB])(''')",
|
| 216 |
+
bygroups(String.Affix, String.Single),
|
| 217 |
+
combined("bytesescape", "tsqs"),
|
| 218 |
+
),
|
| 219 |
+
(
|
| 220 |
+
'([bB])(")',
|
| 221 |
+
bygroups(String.Affix, String.Double),
|
| 222 |
+
combined("bytesescape", "dqs"),
|
| 223 |
+
),
|
| 224 |
+
(
|
| 225 |
+
"([bB])(')",
|
| 226 |
+
bygroups(String.Affix, String.Single),
|
| 227 |
+
combined("bytesescape", "sqs"),
|
| 228 |
+
),
|
| 229 |
+
(r"[^\S\n]+", Text),
|
| 230 |
+
include("numbers"),
|
| 231 |
+
(r"!=|==|<<|>>|:=|[-~+/*%=<>&^|.]", Operator),
|
| 232 |
+
(r"([]{}:\(\),;[])+", Punctuation),
|
| 233 |
+
(r"(in|is|and|or|not)\b", Operator.Word),
|
| 234 |
+
include("expr-keywords"),
|
| 235 |
+
include("builtins"),
|
| 236 |
+
include("magicfuncs"),
|
| 237 |
+
include("magicvars"),
|
| 238 |
+
include("name"),
|
| 239 |
+
],
|
| 240 |
+
"expr-inside-fstring": [
|
| 241 |
+
(r"[{([]", Punctuation, "expr-inside-fstring-inner"),
|
| 242 |
+
# without format specifier
|
| 243 |
+
(
|
| 244 |
+
r"(=\s*)?" # debug (https://bugs.python.org/issue36817)
|
| 245 |
+
r"(\![sraf])?" # conversion
|
| 246 |
+
r"\}",
|
| 247 |
+
String.Interpol,
|
| 248 |
+
"#pop",
|
| 249 |
+
),
|
| 250 |
+
# with format specifier
|
| 251 |
+
# we'll catch the remaining '}' in the outer scope
|
| 252 |
+
(
|
| 253 |
+
r"(=\s*)?" # debug (https://bugs.python.org/issue36817)
|
| 254 |
+
r"(\![sraf])?" # conversion
|
| 255 |
+
r":",
|
| 256 |
+
String.Interpol,
|
| 257 |
+
"#pop",
|
| 258 |
+
),
|
| 259 |
+
(r"\s+", Whitespace), # allow new lines
|
| 260 |
+
include("expr"),
|
| 261 |
+
],
|
| 262 |
+
"expr-inside-fstring-inner": [
|
| 263 |
+
(r"[{([]", Punctuation, "expr-inside-fstring-inner"),
|
| 264 |
+
(r"[])}]", Punctuation, "#pop"),
|
| 265 |
+
(r"\s+", Whitespace), # allow new lines
|
| 266 |
+
include("expr"),
|
| 267 |
+
],
|
| 268 |
+
"expr-keywords": [
|
| 269 |
+
# Based on https://docs.python.org/3/reference/expressions.html
|
| 270 |
+
(
|
| 271 |
+
words(
|
| 272 |
+
(
|
| 273 |
+
"async for", # TODO https://docs.modular.com/mojo/roadmap#no-async-for-or-async-with
|
| 274 |
+
"async with", # TODO https://docs.modular.com/mojo/roadmap#no-async-for-or-async-with
|
| 275 |
+
"await",
|
| 276 |
+
"else",
|
| 277 |
+
"for",
|
| 278 |
+
"if",
|
| 279 |
+
"lambda",
|
| 280 |
+
"yield",
|
| 281 |
+
"yield from",
|
| 282 |
+
),
|
| 283 |
+
suffix=r"\b",
|
| 284 |
+
),
|
| 285 |
+
Keyword,
|
| 286 |
+
),
|
| 287 |
+
(words(("True", "False", "None"), suffix=r"\b"), Keyword.Constant),
|
| 288 |
+
],
|
| 289 |
+
"keywords": [
|
| 290 |
+
(
|
| 291 |
+
words(
|
| 292 |
+
(
|
| 293 |
+
"assert",
|
| 294 |
+
"async",
|
| 295 |
+
"await",
|
| 296 |
+
"borrowed",
|
| 297 |
+
"break",
|
| 298 |
+
"continue",
|
| 299 |
+
"del",
|
| 300 |
+
"elif",
|
| 301 |
+
"else",
|
| 302 |
+
"except",
|
| 303 |
+
"finally",
|
| 304 |
+
"for",
|
| 305 |
+
"global",
|
| 306 |
+
"if",
|
| 307 |
+
"lambda",
|
| 308 |
+
"pass",
|
| 309 |
+
"raise",
|
| 310 |
+
"nonlocal",
|
| 311 |
+
"return",
|
| 312 |
+
"try",
|
| 313 |
+
"while",
|
| 314 |
+
"yield",
|
| 315 |
+
"yield from",
|
| 316 |
+
"as",
|
| 317 |
+
"with",
|
| 318 |
+
),
|
| 319 |
+
suffix=r"\b",
|
| 320 |
+
),
|
| 321 |
+
Keyword,
|
| 322 |
+
),
|
| 323 |
+
(words(("True", "False", "None"), suffix=r"\b"), Keyword.Constant),
|
| 324 |
+
],
|
| 325 |
+
"soft-keywords": [
|
| 326 |
+
# `match`, `case` and `_` soft keywords
|
| 327 |
+
(
|
| 328 |
+
r"(^[ \t]*)" # at beginning of line + possible indentation
|
| 329 |
+
r"(match|case)\b" # a possible keyword
|
| 330 |
+
r"(?![ \t]*(?:" # not followed by...
|
| 331 |
+
r"[:,;=^&|@~)\]}]|(?:" + # characters and keywords that mean this isn't
|
| 332 |
+
# pattern matching (but None/True/False is ok)
|
| 333 |
+
r"|".join(k for k in keyword.kwlist if k[0].islower())
|
| 334 |
+
+ r")\b))",
|
| 335 |
+
bygroups(Whitespace, Keyword),
|
| 336 |
+
"soft-keywords-inner",
|
| 337 |
+
),
|
| 338 |
+
],
|
| 339 |
+
"soft-keywords-inner": [
|
| 340 |
+
# optional `_` keyword
|
| 341 |
+
(r"(\s+)([^\n_]*)(_\b)", bygroups(Whitespace, using(this), Keyword)),
|
| 342 |
+
default("#pop"),
|
| 343 |
+
],
|
| 344 |
+
"builtins": [
|
| 345 |
+
(
|
| 346 |
+
words(
|
| 347 |
+
(
|
| 348 |
+
"__import__",
|
| 349 |
+
"abs",
|
| 350 |
+
"aiter",
|
| 351 |
+
"all",
|
| 352 |
+
"any",
|
| 353 |
+
"bin",
|
| 354 |
+
"bool",
|
| 355 |
+
"bytearray",
|
| 356 |
+
"breakpoint",
|
| 357 |
+
"bytes",
|
| 358 |
+
"callable",
|
| 359 |
+
"chr",
|
| 360 |
+
"classmethod",
|
| 361 |
+
"compile",
|
| 362 |
+
"complex",
|
| 363 |
+
"delattr",
|
| 364 |
+
"dict",
|
| 365 |
+
"dir",
|
| 366 |
+
"divmod",
|
| 367 |
+
"enumerate",
|
| 368 |
+
"eval",
|
| 369 |
+
"filter",
|
| 370 |
+
"float",
|
| 371 |
+
"format",
|
| 372 |
+
"frozenset",
|
| 373 |
+
"getattr",
|
| 374 |
+
"globals",
|
| 375 |
+
"hasattr",
|
| 376 |
+
"hash",
|
| 377 |
+
"hex",
|
| 378 |
+
"id",
|
| 379 |
+
"input",
|
| 380 |
+
"int",
|
| 381 |
+
"isinstance",
|
| 382 |
+
"issubclass",
|
| 383 |
+
"iter",
|
| 384 |
+
"len",
|
| 385 |
+
"list",
|
| 386 |
+
"locals",
|
| 387 |
+
"map",
|
| 388 |
+
"max",
|
| 389 |
+
"memoryview",
|
| 390 |
+
"min",
|
| 391 |
+
"next",
|
| 392 |
+
"object",
|
| 393 |
+
"oct",
|
| 394 |
+
"open",
|
| 395 |
+
"ord",
|
| 396 |
+
"pow",
|
| 397 |
+
"print",
|
| 398 |
+
"property",
|
| 399 |
+
"range",
|
| 400 |
+
"repr",
|
| 401 |
+
"reversed",
|
| 402 |
+
"round",
|
| 403 |
+
"set",
|
| 404 |
+
"setattr",
|
| 405 |
+
"slice",
|
| 406 |
+
"sorted",
|
| 407 |
+
"staticmethod",
|
| 408 |
+
"str",
|
| 409 |
+
"sum",
|
| 410 |
+
"super",
|
| 411 |
+
"tuple",
|
| 412 |
+
"type",
|
| 413 |
+
"vars",
|
| 414 |
+
"zip",
|
| 415 |
+
# Mojo builtin types: https://docs.modular.com/mojo/stdlib/builtin/
|
| 416 |
+
"AnyType",
|
| 417 |
+
"Coroutine",
|
| 418 |
+
"DType",
|
| 419 |
+
"Error",
|
| 420 |
+
"Int",
|
| 421 |
+
"List",
|
| 422 |
+
"ListLiteral",
|
| 423 |
+
"Scalar",
|
| 424 |
+
"Int8",
|
| 425 |
+
"UInt8",
|
| 426 |
+
"Int16",
|
| 427 |
+
"UInt16",
|
| 428 |
+
"Int32",
|
| 429 |
+
"UInt32",
|
| 430 |
+
"Int64",
|
| 431 |
+
"UInt64",
|
| 432 |
+
"BFloat16",
|
| 433 |
+
"Float16",
|
| 434 |
+
"Float32",
|
| 435 |
+
"Float64",
|
| 436 |
+
"SIMD",
|
| 437 |
+
"String",
|
| 438 |
+
"Tensor",
|
| 439 |
+
"Tuple",
|
| 440 |
+
"Movable",
|
| 441 |
+
"Copyable",
|
| 442 |
+
"CollectionElement",
|
| 443 |
+
),
|
| 444 |
+
prefix=r"(?<!\.)",
|
| 445 |
+
suffix=r"\b",
|
| 446 |
+
),
|
| 447 |
+
Name.Builtin,
|
| 448 |
+
),
|
| 449 |
+
(r"(?<!\.)(self|Ellipsis|NotImplemented|cls)\b", Name.Builtin.Pseudo),
|
| 450 |
+
(
|
| 451 |
+
words(
|
| 452 |
+
("Error",),
|
| 453 |
+
prefix=r"(?<!\.)",
|
| 454 |
+
suffix=r"\b",
|
| 455 |
+
),
|
| 456 |
+
Name.Exception,
|
| 457 |
+
),
|
| 458 |
+
],
|
| 459 |
+
"magicfuncs": [
|
| 460 |
+
(
|
| 461 |
+
words(
|
| 462 |
+
(
|
| 463 |
+
"__abs__",
|
| 464 |
+
"__add__",
|
| 465 |
+
"__aenter__",
|
| 466 |
+
"__aexit__",
|
| 467 |
+
"__aiter__",
|
| 468 |
+
"__and__",
|
| 469 |
+
"__anext__",
|
| 470 |
+
"__await__",
|
| 471 |
+
"__bool__",
|
| 472 |
+
"__bytes__",
|
| 473 |
+
"__call__",
|
| 474 |
+
"__complex__",
|
| 475 |
+
"__contains__",
|
| 476 |
+
"__del__",
|
| 477 |
+
"__delattr__",
|
| 478 |
+
"__delete__",
|
| 479 |
+
"__delitem__",
|
| 480 |
+
"__dir__",
|
| 481 |
+
"__divmod__",
|
| 482 |
+
"__enter__",
|
| 483 |
+
"__eq__",
|
| 484 |
+
"__exit__",
|
| 485 |
+
"__float__",
|
| 486 |
+
"__floordiv__",
|
| 487 |
+
"__format__",
|
| 488 |
+
"__ge__",
|
| 489 |
+
"__get__",
|
| 490 |
+
"__getattr__",
|
| 491 |
+
"__getattribute__",
|
| 492 |
+
"__getitem__",
|
| 493 |
+
"__gt__",
|
| 494 |
+
"__hash__",
|
| 495 |
+
"__iadd__",
|
| 496 |
+
"__iand__",
|
| 497 |
+
"__ifloordiv__",
|
| 498 |
+
"__ilshift__",
|
| 499 |
+
"__imatmul__",
|
| 500 |
+
"__imod__",
|
| 501 |
+
"__imul__",
|
| 502 |
+
"__index__",
|
| 503 |
+
"__init__",
|
| 504 |
+
"__instancecheck__",
|
| 505 |
+
"__int__",
|
| 506 |
+
"__invert__",
|
| 507 |
+
"__ior__",
|
| 508 |
+
"__ipow__",
|
| 509 |
+
"__irshift__",
|
| 510 |
+
"__isub__",
|
| 511 |
+
"__iter__",
|
| 512 |
+
"__itruediv__",
|
| 513 |
+
"__ixor__",
|
| 514 |
+
"__le__",
|
| 515 |
+
"__len__",
|
| 516 |
+
"__length_hint__",
|
| 517 |
+
"__lshift__",
|
| 518 |
+
"__lt__",
|
| 519 |
+
"__matmul__",
|
| 520 |
+
"__missing__",
|
| 521 |
+
"__mod__",
|
| 522 |
+
"__mul__",
|
| 523 |
+
"__ne__",
|
| 524 |
+
"__neg__",
|
| 525 |
+
"__new__",
|
| 526 |
+
"__next__",
|
| 527 |
+
"__or__",
|
| 528 |
+
"__pos__",
|
| 529 |
+
"__pow__",
|
| 530 |
+
"__prepare__",
|
| 531 |
+
"__radd__",
|
| 532 |
+
"__rand__",
|
| 533 |
+
"__rdivmod__",
|
| 534 |
+
"__repr__",
|
| 535 |
+
"__reversed__",
|
| 536 |
+
"__rfloordiv__",
|
| 537 |
+
"__rlshift__",
|
| 538 |
+
"__rmatmul__",
|
| 539 |
+
"__rmod__",
|
| 540 |
+
"__rmul__",
|
| 541 |
+
"__ror__",
|
| 542 |
+
"__round__",
|
| 543 |
+
"__rpow__",
|
| 544 |
+
"__rrshift__",
|
| 545 |
+
"__rshift__",
|
| 546 |
+
"__rsub__",
|
| 547 |
+
"__rtruediv__",
|
| 548 |
+
"__rxor__",
|
| 549 |
+
"__set__",
|
| 550 |
+
"__setattr__",
|
| 551 |
+
"__setitem__",
|
| 552 |
+
"__str__",
|
| 553 |
+
"__sub__",
|
| 554 |
+
"__subclasscheck__",
|
| 555 |
+
"__truediv__",
|
| 556 |
+
"__xor__",
|
| 557 |
+
),
|
| 558 |
+
suffix=r"\b",
|
| 559 |
+
),
|
| 560 |
+
Name.Function.Magic,
|
| 561 |
+
),
|
| 562 |
+
],
|
| 563 |
+
"magicvars": [
|
| 564 |
+
(
|
| 565 |
+
words(
|
| 566 |
+
(
|
| 567 |
+
"__annotations__",
|
| 568 |
+
"__bases__",
|
| 569 |
+
"__class__",
|
| 570 |
+
"__closure__",
|
| 571 |
+
"__code__",
|
| 572 |
+
"__defaults__",
|
| 573 |
+
"__dict__",
|
| 574 |
+
"__doc__",
|
| 575 |
+
"__file__",
|
| 576 |
+
"__func__",
|
| 577 |
+
"__globals__",
|
| 578 |
+
"__kwdefaults__",
|
| 579 |
+
"__module__",
|
| 580 |
+
"__mro__",
|
| 581 |
+
"__name__",
|
| 582 |
+
"__objclass__",
|
| 583 |
+
"__qualname__",
|
| 584 |
+
"__self__",
|
| 585 |
+
"__slots__",
|
| 586 |
+
"__weakref__",
|
| 587 |
+
),
|
| 588 |
+
suffix=r"\b",
|
| 589 |
+
),
|
| 590 |
+
Name.Variable.Magic,
|
| 591 |
+
),
|
| 592 |
+
],
|
| 593 |
+
"numbers": [
|
| 594 |
+
(
|
| 595 |
+
r"(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)"
|
| 596 |
+
r"([eE][+-]?\d(?:_?\d)*)?",
|
| 597 |
+
Number.Float,
|
| 598 |
+
),
|
| 599 |
+
(r"\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?", Number.Float),
|
| 600 |
+
(r"0[oO](?:_?[0-7])+", Number.Oct),
|
| 601 |
+
(r"0[bB](?:_?[01])+", Number.Bin),
|
| 602 |
+
(r"0[xX](?:_?[a-fA-F0-9])+", Number.Hex),
|
| 603 |
+
(r"\d(?:_?\d)*", Number.Integer),
|
| 604 |
+
],
|
| 605 |
+
"name": [
|
| 606 |
+
(r"@" + uni_name, Name.Decorator),
|
| 607 |
+
(r"@", Operator), # new matrix multiplication operator
|
| 608 |
+
(uni_name, Name),
|
| 609 |
+
],
|
| 610 |
+
"varname": [
|
| 611 |
+
(uni_name, Name.Variable, "#pop"),
|
| 612 |
+
],
|
| 613 |
+
"funcname": [
|
| 614 |
+
include("magicfuncs"),
|
| 615 |
+
(uni_name, Name.Function, "#pop"),
|
| 616 |
+
default("#pop"),
|
| 617 |
+
],
|
| 618 |
+
"classname": [
|
| 619 |
+
(uni_name, Name.Class, "#pop"),
|
| 620 |
+
],
|
| 621 |
+
"structname": [
|
| 622 |
+
(uni_name, Name.Struct, "#pop"),
|
| 623 |
+
],
|
| 624 |
+
"import": [
|
| 625 |
+
(r"(\s+)(as)(\s+)", bygroups(Whitespace, Keyword, Whitespace)),
|
| 626 |
+
(r"\.", Name.Namespace),
|
| 627 |
+
(uni_name, Name.Namespace),
|
| 628 |
+
(r"(\s*)(,)(\s*)", bygroups(Whitespace, Operator, Whitespace)),
|
| 629 |
+
default("#pop"), # all else: go back
|
| 630 |
+
],
|
| 631 |
+
"fromimport": [
|
| 632 |
+
(r"(\s+)(import)\b", bygroups(Whitespace, Keyword.Namespace), "#pop"),
|
| 633 |
+
(r"\.", Name.Namespace),
|
| 634 |
+
# if None occurs here, it's "raise x from None", since None can
|
| 635 |
+
# never be a module name
|
| 636 |
+
(r"None\b", Keyword.Constant, "#pop"),
|
| 637 |
+
(uni_name, Name.Namespace),
|
| 638 |
+
default("#pop"),
|
| 639 |
+
],
|
| 640 |
+
"rfstringescape": [
|
| 641 |
+
(r"\{\{", String.Escape),
|
| 642 |
+
(r"\}\}", String.Escape),
|
| 643 |
+
],
|
| 644 |
+
"fstringescape": [
|
| 645 |
+
include("rfstringescape"),
|
| 646 |
+
include("stringescape"),
|
| 647 |
+
],
|
| 648 |
+
"bytesescape": [
|
| 649 |
+
(r'\\([\\abfnrtv"\']|\n|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
| 650 |
+
],
|
| 651 |
+
"stringescape": [
|
| 652 |
+
(r"\\(N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8})", String.Escape),
|
| 653 |
+
include("bytesescape"),
|
| 654 |
+
],
|
| 655 |
+
"fstrings-single": fstring_rules(String.Single),
|
| 656 |
+
"fstrings-double": fstring_rules(String.Double),
|
| 657 |
+
"strings-single": innerstring_rules(String.Single),
|
| 658 |
+
"strings-double": innerstring_rules(String.Double),
|
| 659 |
+
"dqf": [
|
| 660 |
+
(r'"', String.Double, "#pop"),
|
| 661 |
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
| 662 |
+
include("fstrings-double"),
|
| 663 |
+
],
|
| 664 |
+
"sqf": [
|
| 665 |
+
(r"'", String.Single, "#pop"),
|
| 666 |
+
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
| 667 |
+
include("fstrings-single"),
|
| 668 |
+
],
|
| 669 |
+
"dqs": [
|
| 670 |
+
(r'"', String.Double, "#pop"),
|
| 671 |
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
| 672 |
+
include("strings-double"),
|
| 673 |
+
],
|
| 674 |
+
"sqs": [
|
| 675 |
+
(r"'", String.Single, "#pop"),
|
| 676 |
+
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
| 677 |
+
include("strings-single"),
|
| 678 |
+
],
|
| 679 |
+
"tdqf": [
|
| 680 |
+
(r'"""', String.Double, "#pop"),
|
| 681 |
+
include("fstrings-double"),
|
| 682 |
+
(r"\n", String.Double),
|
| 683 |
+
],
|
| 684 |
+
"tsqf": [
|
| 685 |
+
(r"'''", String.Single, "#pop"),
|
| 686 |
+
include("fstrings-single"),
|
| 687 |
+
(r"\n", String.Single),
|
| 688 |
+
],
|
| 689 |
+
"tdqs": [
|
| 690 |
+
(r'"""', String.Double, "#pop"),
|
| 691 |
+
include("strings-double"),
|
| 692 |
+
(r"\n", String.Double),
|
| 693 |
+
],
|
| 694 |
+
"tsqs": [
|
| 695 |
+
(r"'''", String.Single, "#pop"),
|
| 696 |
+
include("strings-single"),
|
| 697 |
+
(r"\n", String.Single),
|
| 698 |
+
],
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
+
def analyse_text(text):
|
| 702 |
+
# TODO supported?
|
| 703 |
+
if shebang_matches(text, r"mojo?"):
|
| 704 |
+
return 1.0
|
| 705 |
+
if "import " in text[:1000]:
|
| 706 |
+
return 0.9
|
| 707 |
+
return 0
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/monte.py
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.monte
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Monte programming language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \
|
| 12 |
+
Punctuation, String, Whitespace
|
| 13 |
+
from pygments.lexer import RegexLexer, include, words
|
| 14 |
+
|
| 15 |
+
__all__ = ['MonteLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# `var` handled separately
|
| 19 |
+
# `interface` handled separately
|
| 20 |
+
_declarations = ['bind', 'def', 'fn', 'object']
|
| 21 |
+
_methods = ['method', 'to']
|
| 22 |
+
_keywords = [
|
| 23 |
+
'as', 'break', 'catch', 'continue', 'else', 'escape', 'exit', 'exports',
|
| 24 |
+
'extends', 'finally', 'for', 'guards', 'if', 'implements', 'import',
|
| 25 |
+
'in', 'match', 'meta', 'pass', 'return', 'switch', 'try', 'via', 'when',
|
| 26 |
+
'while',
|
| 27 |
+
]
|
| 28 |
+
_operators = [
|
| 29 |
+
# Unary
|
| 30 |
+
'~', '!',
|
| 31 |
+
# Binary
|
| 32 |
+
'+', '-', '*', '/', '%', '**', '&', '|', '^', '<<', '>>',
|
| 33 |
+
# Binary augmented
|
| 34 |
+
'+=', '-=', '*=', '/=', '%=', '**=', '&=', '|=', '^=', '<<=', '>>=',
|
| 35 |
+
# Comparison
|
| 36 |
+
'==', '!=', '<', '<=', '>', '>=', '<=>',
|
| 37 |
+
# Patterns and assignment
|
| 38 |
+
':=', '?', '=~', '!~', '=>',
|
| 39 |
+
# Calls and sends
|
| 40 |
+
'.', '<-', '->',
|
| 41 |
+
]
|
| 42 |
+
_escape_pattern = (
|
| 43 |
+
r'(?:\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|'
|
| 44 |
+
r'\\["\'\\bftnr])')
|
| 45 |
+
# _char = _escape_chars + [('.', String.Char)]
|
| 46 |
+
_identifier = r'[_a-zA-Z]\w*'
|
| 47 |
+
|
| 48 |
+
_constants = [
|
| 49 |
+
# Void constants
|
| 50 |
+
'null',
|
| 51 |
+
# Bool constants
|
| 52 |
+
'false', 'true',
|
| 53 |
+
# Double constants
|
| 54 |
+
'Infinity', 'NaN',
|
| 55 |
+
# Special objects
|
| 56 |
+
'M', 'Ref', 'throw', 'traceln',
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
+
_guards = [
|
| 60 |
+
'Any', 'Binding', 'Bool', 'Bytes', 'Char', 'DeepFrozen', 'Double',
|
| 61 |
+
'Empty', 'Int', 'List', 'Map', 'Near', 'NullOk', 'Same', 'Selfless',
|
| 62 |
+
'Set', 'Str', 'SubrangeGuard', 'Transparent', 'Void',
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
_safeScope = [
|
| 66 |
+
'_accumulateList', '_accumulateMap', '_auditedBy', '_bind',
|
| 67 |
+
'_booleanFlow', '_comparer', '_equalizer', '_iterForever', '_loop',
|
| 68 |
+
'_makeBytes', '_makeDouble', '_makeFinalSlot', '_makeInt', '_makeList',
|
| 69 |
+
'_makeMap', '_makeMessageDesc', '_makeOrderedSpace', '_makeParamDesc',
|
| 70 |
+
'_makeProtocolDesc', '_makeSourceSpan', '_makeString', '_makeVarSlot',
|
| 71 |
+
'_makeVerbFacet', '_mapExtract', '_matchSame', '_quasiMatcher',
|
| 72 |
+
'_slotToBinding', '_splitList', '_suchThat', '_switchFailed',
|
| 73 |
+
'_validateFor', 'b__quasiParser', 'eval', 'import', 'm__quasiParser',
|
| 74 |
+
'makeBrandPair', 'makeLazySlot', 'safeScope', 'simple__quasiParser',
|
| 75 |
+
]
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
class MonteLexer(RegexLexer):
|
| 79 |
+
"""
|
| 80 |
+
Lexer for the Monte programming language.
|
| 81 |
+
"""
|
| 82 |
+
name = 'Monte'
|
| 83 |
+
url = 'https://monte.readthedocs.io/'
|
| 84 |
+
aliases = ['monte']
|
| 85 |
+
filenames = ['*.mt']
|
| 86 |
+
version_added = '2.2'
|
| 87 |
+
|
| 88 |
+
tokens = {
|
| 89 |
+
'root': [
|
| 90 |
+
# Comments
|
| 91 |
+
(r'#[^\n]*\n', Comment),
|
| 92 |
+
|
| 93 |
+
# Docstrings
|
| 94 |
+
# Apologies for the non-greedy matcher here.
|
| 95 |
+
(r'/\*\*.*?\*/', String.Doc),
|
| 96 |
+
|
| 97 |
+
# `var` declarations
|
| 98 |
+
(r'\bvar\b', Keyword.Declaration, 'var'),
|
| 99 |
+
|
| 100 |
+
# `interface` declarations
|
| 101 |
+
(r'\binterface\b', Keyword.Declaration, 'interface'),
|
| 102 |
+
|
| 103 |
+
# method declarations
|
| 104 |
+
(words(_methods, prefix='\\b', suffix='\\b'),
|
| 105 |
+
Keyword, 'method'),
|
| 106 |
+
|
| 107 |
+
# All other declarations
|
| 108 |
+
(words(_declarations, prefix='\\b', suffix='\\b'),
|
| 109 |
+
Keyword.Declaration),
|
| 110 |
+
|
| 111 |
+
# Keywords
|
| 112 |
+
(words(_keywords, prefix='\\b', suffix='\\b'), Keyword),
|
| 113 |
+
|
| 114 |
+
# Literals
|
| 115 |
+
('[+-]?0x[_0-9a-fA-F]+', Number.Hex),
|
| 116 |
+
(r'[+-]?[_0-9]+\.[_0-9]*([eE][+-]?[_0-9]+)?', Number.Float),
|
| 117 |
+
('[+-]?[_0-9]+', Number.Integer),
|
| 118 |
+
("'", String.Double, 'char'),
|
| 119 |
+
('"', String.Double, 'string'),
|
| 120 |
+
|
| 121 |
+
# Quasiliterals
|
| 122 |
+
('`', String.Backtick, 'ql'),
|
| 123 |
+
|
| 124 |
+
# Operators
|
| 125 |
+
(words(_operators), Operator),
|
| 126 |
+
|
| 127 |
+
# Verb operators
|
| 128 |
+
(_identifier + '=', Operator.Word),
|
| 129 |
+
|
| 130 |
+
# Safe scope constants
|
| 131 |
+
(words(_constants, prefix='\\b', suffix='\\b'),
|
| 132 |
+
Keyword.Pseudo),
|
| 133 |
+
|
| 134 |
+
# Safe scope guards
|
| 135 |
+
(words(_guards, prefix='\\b', suffix='\\b'), Keyword.Type),
|
| 136 |
+
|
| 137 |
+
# All other safe scope names
|
| 138 |
+
(words(_safeScope, prefix='\\b', suffix='\\b'),
|
| 139 |
+
Name.Builtin),
|
| 140 |
+
|
| 141 |
+
# Identifiers
|
| 142 |
+
(_identifier, Name),
|
| 143 |
+
|
| 144 |
+
# Punctuation
|
| 145 |
+
(r'\(|\)|\{|\}|\[|\]|:|,', Punctuation),
|
| 146 |
+
|
| 147 |
+
# Whitespace
|
| 148 |
+
(' +', Whitespace),
|
| 149 |
+
|
| 150 |
+
# Definite lexer errors
|
| 151 |
+
('=', Error),
|
| 152 |
+
],
|
| 153 |
+
'char': [
|
| 154 |
+
# It is definitely an error to have a char of width == 0.
|
| 155 |
+
("'", Error, 'root'),
|
| 156 |
+
(_escape_pattern, String.Escape, 'charEnd'),
|
| 157 |
+
('.', String.Char, 'charEnd'),
|
| 158 |
+
],
|
| 159 |
+
'charEnd': [
|
| 160 |
+
("'", String.Char, '#pop:2'),
|
| 161 |
+
# It is definitely an error to have a char of width > 1.
|
| 162 |
+
('.', Error),
|
| 163 |
+
],
|
| 164 |
+
# The state of things coming into an interface.
|
| 165 |
+
'interface': [
|
| 166 |
+
(' +', Whitespace),
|
| 167 |
+
(_identifier, Name.Class, '#pop'),
|
| 168 |
+
include('root'),
|
| 169 |
+
],
|
| 170 |
+
# The state of things coming into a method.
|
| 171 |
+
'method': [
|
| 172 |
+
(' +', Whitespace),
|
| 173 |
+
(_identifier, Name.Function, '#pop'),
|
| 174 |
+
include('root'),
|
| 175 |
+
],
|
| 176 |
+
'string': [
|
| 177 |
+
('"', String.Double, 'root'),
|
| 178 |
+
(_escape_pattern, String.Escape),
|
| 179 |
+
(r'\n', String.Double),
|
| 180 |
+
('.', String.Double),
|
| 181 |
+
],
|
| 182 |
+
'ql': [
|
| 183 |
+
('`', String.Backtick, 'root'),
|
| 184 |
+
(r'\$' + _escape_pattern, String.Escape),
|
| 185 |
+
(r'\$\$', String.Escape),
|
| 186 |
+
(r'@@', String.Escape),
|
| 187 |
+
(r'\$\{', String.Interpol, 'qlNest'),
|
| 188 |
+
(r'@\{', String.Interpol, 'qlNest'),
|
| 189 |
+
(r'\$' + _identifier, Name),
|
| 190 |
+
('@' + _identifier, Name),
|
| 191 |
+
('.', String.Backtick),
|
| 192 |
+
],
|
| 193 |
+
'qlNest': [
|
| 194 |
+
(r'\}', String.Interpol, '#pop'),
|
| 195 |
+
include('root'),
|
| 196 |
+
],
|
| 197 |
+
# The state of things immediately following `var`.
|
| 198 |
+
'var': [
|
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.mosel
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the mosel language.
|
| 6 |
+
http://www.fico.com/en/products/fico-xpress-optimization
|
| 7 |
+
|
| 8 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 9 |
+
:license: BSD, see LICENSE for details.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
from pygments.lexer import RegexLexer, words
|
| 13 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 14 |
+
Number, Punctuation
|
| 15 |
+
|
| 16 |
+
__all__ = ['MoselLexer']
|
| 17 |
+
|
| 18 |
+
FUNCTIONS = (
|
| 19 |
+
# core functions
|
| 20 |
+
'_',
|
| 21 |
+
'abs',
|
| 22 |
+
'arctan',
|
| 23 |
+
'asproc',
|
| 24 |
+
'assert',
|
| 25 |
+
'bitflip',
|
| 26 |
+
'bitneg',
|
| 27 |
+
'bitset',
|
| 28 |
+
'bitshift',
|
| 29 |
+
'bittest',
|
| 30 |
+
'bitval',
|
| 31 |
+
'ceil',
|
| 32 |
+
'cos',
|
| 33 |
+
'create',
|
| 34 |
+
'currentdate',
|
| 35 |
+
'currenttime',
|
| 36 |
+
'cutelt',
|
| 37 |
+
'cutfirst',
|
| 38 |
+
'cuthead',
|
| 39 |
+
'cutlast',
|
| 40 |
+
'cuttail',
|
| 41 |
+
'datablock',
|
| 42 |
+
'delcell',
|
| 43 |
+
'exists',
|
| 44 |
+
'exit',
|
| 45 |
+
'exp',
|
| 46 |
+
'exportprob',
|
| 47 |
+
'fclose',
|
| 48 |
+
'fflush',
|
| 49 |
+
'finalize',
|
| 50 |
+
'findfirst',
|
| 51 |
+
'findlast',
|
| 52 |
+
'floor',
|
| 53 |
+
'fopen',
|
| 54 |
+
'fselect',
|
| 55 |
+
'fskipline',
|
| 56 |
+
'fwrite',
|
| 57 |
+
'fwrite_',
|
| 58 |
+
'fwriteln',
|
| 59 |
+
'fwriteln_',
|
| 60 |
+
'getact',
|
| 61 |
+
'getcoeff',
|
| 62 |
+
'getcoeffs',
|
| 63 |
+
'getdual',
|
| 64 |
+
'getelt',
|
| 65 |
+
'getfid',
|
| 66 |
+
'getfirst',
|
| 67 |
+
'getfname',
|
| 68 |
+
'gethead',
|
| 69 |
+
'getlast',
|
| 70 |
+
'getobjval',
|
| 71 |
+
'getparam',
|
| 72 |
+
'getrcost',
|
| 73 |
+
'getreadcnt',
|
| 74 |
+
'getreverse',
|
| 75 |
+
'getsize',
|
| 76 |
+
'getslack',
|
| 77 |
+
'getsol',
|
| 78 |
+
'gettail',
|
| 79 |
+
'gettype',
|
| 80 |
+
'getvars',
|
| 81 |
+
'isdynamic',
|
| 82 |
+
'iseof',
|
| 83 |
+
'isfinite',
|
| 84 |
+
'ishidden',
|
| 85 |
+
'isinf',
|
| 86 |
+
'isnan',
|
| 87 |
+
'isodd',
|
| 88 |
+
'ln',
|
| 89 |
+
'localsetparam',
|
| 90 |
+
'log',
|
| 91 |
+
'makesos1',
|
| 92 |
+
'makesos2',
|
| 93 |
+
'maxlist',
|
| 94 |
+
'memoryuse',
|
| 95 |
+
'minlist',
|
| 96 |
+
'newmuid',
|
| 97 |
+
'publish',
|
| 98 |
+
'random',
|
| 99 |
+
'read',
|
| 100 |
+
'readln',
|
| 101 |
+
'reset',
|
| 102 |
+
'restoreparam',
|
| 103 |
+
'reverse',
|
| 104 |
+
'round',
|
| 105 |
+
'setcoeff',
|
| 106 |
+
'sethidden',
|
| 107 |
+
'setioerr',
|
| 108 |
+
'setmatherr',
|
| 109 |
+
'setname',
|
| 110 |
+
'setparam',
|
| 111 |
+
'setrandseed',
|
| 112 |
+
'setrange',
|
| 113 |
+
'settype',
|
| 114 |
+
'sin',
|
| 115 |
+
'splithead',
|
| 116 |
+
'splittail',
|
| 117 |
+
'sqrt',
|
| 118 |
+
'strfmt',
|
| 119 |
+
'substr',
|
| 120 |
+
'timestamp',
|
| 121 |
+
'unpublish',
|
| 122 |
+
'versionnum',
|
| 123 |
+
'versionstr',
|
| 124 |
+
'write',
|
| 125 |
+
'write_',
|
| 126 |
+
'writeln',
|
| 127 |
+
'writeln_',
|
| 128 |
+
|
| 129 |
+
# mosel exam mmxprs | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u
|
| 130 |
+
'addcut',
|
| 131 |
+
'addcuts',
|
| 132 |
+
'addmipsol',
|
| 133 |
+
'basisstability',
|
| 134 |
+
'calcsolinfo',
|
| 135 |
+
'clearmipdir',
|
| 136 |
+
'clearmodcut',
|
| 137 |
+
'command',
|
| 138 |
+
'copysoltoinit',
|
| 139 |
+
'crossoverlpsol',
|
| 140 |
+
'defdelayedrows',
|
| 141 |
+
'defsecurevecs',
|
| 142 |
+
'delcuts',
|
| 143 |
+
'dropcuts',
|
| 144 |
+
'estimatemarginals',
|
| 145 |
+
'fixglobal',
|
| 146 |
+
'flushmsgq',
|
| 147 |
+
'getbstat',
|
| 148 |
+
'getcnlist',
|
| 149 |
+
'getcplist',
|
| 150 |
+
'getdualray',
|
| 151 |
+
'getiis',
|
| 152 |
+
'getiissense',
|
| 153 |
+
'getiistype',
|
| 154 |
+
'getinfcause',
|
| 155 |
+
'getinfeas',
|
| 156 |
+
'getlb',
|
| 157 |
+
'getlct',
|
| 158 |
+
'getleft',
|
| 159 |
+
'getloadedlinctrs',
|
| 160 |
+
'getloadedmpvars',
|
| 161 |
+
'getname',
|
| 162 |
+
'getprimalray',
|
| 163 |
+
'getprobstat',
|
| 164 |
+
'getrange',
|
| 165 |
+
'getright',
|
| 166 |
+
'getsensrng',
|
| 167 |
+
'getsize',
|
| 168 |
+
'getsol',
|
| 169 |
+
'gettype',
|
| 170 |
+
'getub',
|
| 171 |
+
'getvars',
|
| 172 |
+
'gety',
|
| 173 |
+
'hasfeature',
|
| 174 |
+
'implies',
|
| 175 |
+
'indicator',
|
| 176 |
+
'initglobal',
|
| 177 |
+
'ishidden',
|
| 178 |
+
'isiisvalid',
|
| 179 |
+
'isintegral',
|
| 180 |
+
'loadbasis',
|
| 181 |
+
'loadcuts',
|
| 182 |
+
'loadlpsol',
|
| 183 |
+
'loadmipsol',
|
| 184 |
+
'loadprob',
|
| 185 |
+
'maximise',
|
| 186 |
+
'maximize',
|
| 187 |
+
'minimise',
|
| 188 |
+
'minimize',
|
| 189 |
+
'postsolve',
|
| 190 |
+
'readbasis',
|
| 191 |
+
'readdirs',
|
| 192 |
+
'readsol',
|
| 193 |
+
'refinemipsol',
|
| 194 |
+
'rejectintsol',
|
| 195 |
+
'repairinfeas',
|
| 196 |
+
'repairinfeas_deprec',
|
| 197 |
+
'resetbasis',
|
| 198 |
+
'resetiis',
|
| 199 |
+
'resetsol',
|
| 200 |
+
'savebasis',
|
| 201 |
+
'savemipsol',
|
| 202 |
+
'savesol',
|
| 203 |
+
'savestate',
|
| 204 |
+
'selectsol',
|
| 205 |
+
'setarchconsistency',
|
| 206 |
+
'setbstat',
|
| 207 |
+
'setcallback',
|
| 208 |
+
'setcbcutoff',
|
| 209 |
+
'setgndata',
|
| 210 |
+
'sethidden',
|
| 211 |
+
'setlb',
|
| 212 |
+
'setmipdir',
|
| 213 |
+
'setmodcut',
|
| 214 |
+
'setsol',
|
| 215 |
+
'setub',
|
| 216 |
+
'setucbdata',
|
| 217 |
+
'stopoptimise',
|
| 218 |
+
'stopoptimize',
|
| 219 |
+
'storecut',
|
| 220 |
+
'storecuts',
|
| 221 |
+
'unloadprob',
|
| 222 |
+
'uselastbarsol',
|
| 223 |
+
'writebasis',
|
| 224 |
+
'writedirs',
|
| 225 |
+
'writeprob',
|
| 226 |
+
'writesol',
|
| 227 |
+
'xor',
|
| 228 |
+
'xprs_addctr',
|
| 229 |
+
'xprs_addindic',
|
| 230 |
+
|
| 231 |
+
# mosel exam mmsystem | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u
|
| 232 |
+
'addmonths',
|
| 233 |
+
'copytext',
|
| 234 |
+
'cuttext',
|
| 235 |
+
'deltext',
|
| 236 |
+
'endswith',
|
| 237 |
+
'erase',
|
| 238 |
+
'expandpath',
|
| 239 |
+
'fcopy',
|
| 240 |
+
'fdelete',
|
| 241 |
+
'findfiles',
|
| 242 |
+
'findtext',
|
| 243 |
+
'fmove',
|
| 244 |
+
'formattext',
|
| 245 |
+
'getasnumber',
|
| 246 |
+
'getchar',
|
| 247 |
+
'getcwd',
|
| 248 |
+
'getdate',
|
| 249 |
+
'getday',
|
| 250 |
+
'getdaynum',
|
| 251 |
+
'getdays',
|
| 252 |
+
'getdirsep',
|
| 253 |
+
'getdsoparam',
|
| 254 |
+
'getendparse',
|
| 255 |
+
'getenv',
|
| 256 |
+
'getfsize',
|
| 257 |
+
'getfstat',
|
| 258 |
+
'getftime',
|
| 259 |
+
'gethour',
|
| 260 |
+
'getminute',
|
| 261 |
+
'getmonth',
|
| 262 |
+
'getmsec',
|
| 263 |
+
'getoserrmsg',
|
| 264 |
+
'getoserror',
|
| 265 |
+
'getpathsep',
|
| 266 |
+
'getqtype',
|
| 267 |
+
'getsecond',
|
| 268 |
+
'getsepchar',
|
| 269 |
+
'getsize',
|
| 270 |
+
'getstart',
|
| 271 |
+
'getsucc',
|
| 272 |
+
'getsysinfo',
|
| 273 |
+
'getsysstat',
|
| 274 |
+
'gettime',
|
| 275 |
+
'gettmpdir',
|
| 276 |
+
'gettrim',
|
| 277 |
+
'getweekday',
|
| 278 |
+
'getyear',
|
| 279 |
+
'inserttext',
|
| 280 |
+
'isvalid',
|
| 281 |
+
'jointext',
|
| 282 |
+
'makedir',
|
| 283 |
+
'makepath',
|
| 284 |
+
'newtar',
|
| 285 |
+
'newzip',
|
| 286 |
+
'nextfield',
|
| 287 |
+
'openpipe',
|
| 288 |
+
'parseextn',
|
| 289 |
+
'parseint',
|
| 290 |
+
'parsereal',
|
| 291 |
+
'parsetext',
|
| 292 |
+
'pastetext',
|
| 293 |
+
'pathmatch',
|
| 294 |
+
'pathsplit',
|
| 295 |
+
'qsort',
|
| 296 |
+
'quote',
|
| 297 |
+
'readtextline',
|
| 298 |
+
'regmatch',
|
| 299 |
+
'regreplace',
|
| 300 |
+
'removedir',
|
| 301 |
+
'removefiles',
|
| 302 |
+
'setchar',
|
| 303 |
+
'setdate',
|
| 304 |
+
'setday',
|
| 305 |
+
'setdsoparam',
|
| 306 |
+
'setendparse',
|
| 307 |
+
'setenv',
|
| 308 |
+
'sethour',
|
| 309 |
+
'setminute',
|
| 310 |
+
'setmonth',
|
| 311 |
+
'setmsec',
|
| 312 |
+
'setoserror',
|
| 313 |
+
'setqtype',
|
| 314 |
+
'setsecond',
|
| 315 |
+
'setsepchar',
|
| 316 |
+
'setstart',
|
| 317 |
+
'setsucc',
|
| 318 |
+
'settime',
|
| 319 |
+
'settrim',
|
| 320 |
+
'setyear',
|
| 321 |
+
'sleep',
|
| 322 |
+
'splittext',
|
| 323 |
+
'startswith',
|
| 324 |
+
'system',
|
| 325 |
+
'tarlist',
|
| 326 |
+
'textfmt',
|
| 327 |
+
'tolower',
|
| 328 |
+
'toupper',
|
| 329 |
+
'trim',
|
| 330 |
+
'untar',
|
| 331 |
+
'unzip',
|
| 332 |
+
'ziplist',
|
| 333 |
+
|
| 334 |
+
# mosel exam mmjobs | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u
|
| 335 |
+
'canceltimer',
|
| 336 |
+
'clearaliases',
|
| 337 |
+
'compile',
|
| 338 |
+
'connect',
|
| 339 |
+
'detach',
|
| 340 |
+
'disconnect',
|
| 341 |
+
'dropnextevent',
|
| 342 |
+
'findxsrvs',
|
| 343 |
+
'getaliases',
|
| 344 |
+
'getannidents',
|
| 345 |
+
'getannotations',
|
| 346 |
+
'getbanner',
|
| 347 |
+
'getclass',
|
| 348 |
+
'getdsoprop',
|
| 349 |
+
'getdsopropnum',
|
| 350 |
+
'getexitcode',
|
| 351 |
+
'getfromgid',
|
| 352 |
+
'getfromid',
|
| 353 |
+
'getfromuid',
|
| 354 |
+
'getgid',
|
| 355 |
+
'gethostalias',
|
| 356 |
+
'getid',
|
| 357 |
+
'getmodprop',
|
| 358 |
+
'getmodpropnum',
|
| 359 |
+
'getnextevent',
|
| 360 |
+
'getnode',
|
| 361 |
+
'getrmtid',
|
| 362 |
+
'getstatus',
|
| 363 |
+
'getsysinfo',
|
| 364 |
+
'gettimer',
|
| 365 |
+
'getuid',
|
| 366 |
+
'getvalue',
|
| 367 |
+
'isqueueempty',
|
| 368 |
+
'load',
|
| 369 |
+
'nullevent',
|
| 370 |
+
'peeknextevent',
|
| 371 |
+
'resetmodpar',
|
| 372 |
+
'run',
|
| 373 |
+
'send',
|
| 374 |
+
'setcontrol',
|
| 375 |
+
'setdefstream',
|
| 376 |
+
'setgid',
|
| 377 |
+
'sethostalias',
|
| 378 |
+
'setmodpar',
|
| 379 |
+
'settimer',
|
| 380 |
+
'setuid',
|
| 381 |
+
'setworkdir',
|
| 382 |
+
'stop',
|
| 383 |
+
'unload',
|
| 384 |
+
'wait',
|
| 385 |
+
'waitexpired',
|
| 386 |
+
'waitfor',
|
| 387 |
+
'waitforend',
|
| 388 |
+
)
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
class MoselLexer(RegexLexer):
|
| 392 |
+
"""
|
| 393 |
+
For the Mosel optimization language.
|
| 394 |
+
"""
|
| 395 |
+
name = 'Mosel'
|
| 396 |
+
aliases = ['mosel']
|
| 397 |
+
filenames = ['*.mos']
|
| 398 |
+
url = 'https://www.fico.com/fico-xpress-optimization/docs/latest/mosel/mosel_lang/dhtml/moselreflang.html'
|
| 399 |
+
version_added = '2.6'
|
| 400 |
+
|
| 401 |
+
tokens = {
|
| 402 |
+
'root': [
|
| 403 |
+
(r'\n', Text),
|
| 404 |
+
(r'\s+', Text.Whitespace),
|
| 405 |
+
(r'!.*?\n', Comment.Single),
|
| 406 |
+
(r'\(!(.|\n)*?!\)', Comment.Multiline),
|
| 407 |
+
(words((
|
| 408 |
+
'and', 'as', 'break', 'case', 'count', 'declarations', 'do',
|
| 409 |
+
'dynamic', 'elif', 'else', 'end-', 'end', 'evaluation', 'false',
|
| 410 |
+
'forall', 'forward', 'from', 'function', 'hashmap', 'if',
|
| 411 |
+
'imports', 'include', 'initialisations', 'initializations', 'inter',
|
| 412 |
+
'max', 'min', 'model', 'namespace', 'next', 'not', 'nsgroup',
|
| 413 |
+
'nssearch', 'of', 'options', 'or', 'package', 'parameters',
|
| 414 |
+
'procedure', 'public', 'prod', 'record', 'repeat', 'requirements',
|
| 415 |
+
'return', 'sum', 'then', 'to', 'true', 'union', 'until', 'uses',
|
| 416 |
+
'version', 'while', 'with'), prefix=r'\b', suffix=r'\b'),
|
| 417 |
+
Keyword.Builtin),
|
| 418 |
+
(words((
|
| 419 |
+
'range', 'array', 'set', 'list', 'mpvar', 'mpproblem', 'linctr',
|
| 420 |
+
'nlctr', 'integer', 'string', 'real', 'boolean', 'text', 'time',
|
| 421 |
+
'date', 'datetime', 'returned', 'Model', 'Mosel', 'counter',
|
| 422 |
+
'xmldoc', 'is_sos1', 'is_sos2', 'is_integer', 'is_binary',
|
| 423 |
+
'is_continuous', 'is_free', 'is_semcont', 'is_semint',
|
| 424 |
+
'is_partint'), prefix=r'\b', suffix=r'\b'),
|
| 425 |
+
Keyword.Type),
|
| 426 |
+
(r'(\+|\-|\*|/|=|<=|>=|\||\^|<|>|<>|\.\.|\.|:=|::|:|in|mod|div)',
|
| 427 |
+
Operator),
|
| 428 |
+
(r'[()\[\]{},;]+', Punctuation),
|
| 429 |
+
(words(FUNCTIONS, prefix=r'\b', suffix=r'\b'), Name.Function),
|
| 430 |
+
(r'(\d+\.(?!\.)\d*|\.(?!.)\d+)([eE][+-]?\d+)?', Number.Float),
|
| 431 |
+
(r'\d+([eE][+-]?\d+)?', Number.Integer),
|
| 432 |
+
(r'[+-]?Infinity', Number.Integer),
|
| 433 |
+
(r'0[xX][0-9a-fA-F]+', Number),
|
| 434 |
+
(r'"', String.Double, 'double_quote'),
|
| 435 |
+
(r'\'', String.Single, 'single_quote'),
|
| 436 |
+
(r'(\w+|(\.(?!\.)))', Text),
|
| 437 |
+
],
|
| 438 |
+
'single_quote': [
|
| 439 |
+
(r'\'', String.Single, '#pop'),
|
| 440 |
+
(r'[^\']+', String.Single),
|
| 441 |
+
],
|
| 442 |
+
'double_quote': [
|
| 443 |
+
(r'(\\"|\\[0-7]{1,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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.ncl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for NCAR Command Language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, words
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation
|
| 16 |
+
|
| 17 |
+
__all__ = ['NCLLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class NCLLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Lexer for NCL code.
|
| 23 |
+
"""
|
| 24 |
+
name = 'NCL'
|
| 25 |
+
aliases = ['ncl']
|
| 26 |
+
filenames = ['*.ncl']
|
| 27 |
+
mimetypes = ['text/ncl']
|
| 28 |
+
url = 'https://www.ncl.ucar.edu'
|
| 29 |
+
version_added = '2.2'
|
| 30 |
+
|
| 31 |
+
flags = re.MULTILINE
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
'root': [
|
| 35 |
+
(r';.*\n', Comment),
|
| 36 |
+
include('strings'),
|
| 37 |
+
include('core'),
|
| 38 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 39 |
+
include('nums'),
|
| 40 |
+
(r'[\s]+', Text),
|
| 41 |
+
],
|
| 42 |
+
'core': [
|
| 43 |
+
# Statements
|
| 44 |
+
(words((
|
| 45 |
+
'begin', 'break', 'continue', 'create', 'defaultapp', 'do',
|
| 46 |
+
'else', 'end', 'external', 'exit', 'True', 'False', 'file', 'function',
|
| 47 |
+
'getvalues', 'graphic', 'group', 'if', 'list', 'load', 'local',
|
| 48 |
+
'new', '_Missing', 'Missing', 'noparent', 'procedure',
|
| 49 |
+
'quit', 'QUIT', 'Quit', 'record', 'return', 'setvalues', 'stop',
|
| 50 |
+
'then', 'while'), prefix=r'\b', suffix=r'\s*\b'),
|
| 51 |
+
Keyword),
|
| 52 |
+
|
| 53 |
+
# Data Types
|
| 54 |
+
(words((
|
| 55 |
+
'ubyte', 'uint', 'uint64', 'ulong', 'string', 'byte',
|
| 56 |
+
'character', 'double', 'float', 'integer', 'int64', 'logical',
|
| 57 |
+
'long', 'short', 'ushort', 'enumeric', 'numeric', 'snumeric'),
|
| 58 |
+
prefix=r'\b', suffix=r'\s*\b'),
|
| 59 |
+
Keyword.Type),
|
| 60 |
+
|
| 61 |
+
# Operators
|
| 62 |
+
(r'[\%^*+\-/<>]', Operator),
|
| 63 |
+
|
| 64 |
+
# punctuation:
|
| 65 |
+
(r'[\[\]():@$!&|.,\\{}]', Punctuation),
|
| 66 |
+
(r'[=:]', Punctuation),
|
| 67 |
+
|
| 68 |
+
# Intrinsics
|
| 69 |
+
(words((
|
| 70 |
+
'abs', 'acos', 'addfile', 'addfiles', 'all', 'angmom_atm', 'any',
|
| 71 |
+
'area_conserve_remap', 'area_hi2lores', 'area_poly_sphere',
|
| 72 |
+
'asciiread', 'asciiwrite', 'asin', 'atan', 'atan2', 'attsetvalues',
|
| 73 |
+
'avg', 'betainc', 'bin_avg', 'bin_sum', 'bw_bandpass_filter',
|
| 74 |
+
'cancor', 'cbinread', 'cbinwrite', 'cd_calendar', 'cd_inv_calendar',
|
| 75 |
+
'cdfbin_p', 'cdfbin_pr', 'cdfbin_s', 'cdfbin_xn', 'cdfchi_p',
|
| 76 |
+
'cdfchi_x', 'cdfgam_p', 'cdfgam_x', 'cdfnor_p', 'cdfnor_x',
|
| 77 |
+
'cdft_p', 'cdft_t', 'ceil', 'center_finite_diff',
|
| 78 |
+
'center_finite_diff_n', 'cfftb', 'cfftf', 'cfftf_frq_reorder',
|
| 79 |
+
'charactertodouble', 'charactertofloat', 'charactertointeger',
|
| 80 |
+
'charactertolong', 'charactertoshort', 'charactertostring',
|
| 81 |
+
'chartodouble', 'chartofloat', 'chartoint', 'chartointeger',
|
| 82 |
+
'chartolong', 'chartoshort', 'chartostring', 'chiinv', 'clear',
|
| 83 |
+
'color_index_to_rgba', 'conform', 'conform_dims', 'cos', 'cosh',
|
| 84 |
+
'count_unique_values', 'covcorm', 'covcorm_xy', 'craybinnumrec',
|
| 85 |
+
'craybinrecread', 'create_graphic', 'csa1', 'csa1d', 'csa1s',
|
| 86 |
+
'csa1x', 'csa1xd', 'csa1xs', 'csa2', 'csa2d', 'csa2l', 'csa2ld',
|
| 87 |
+
'csa2ls', 'csa2lx', 'csa2lxd', 'csa2lxs', 'csa2s', 'csa2x',
|
| 88 |
+
'csa2xd', 'csa2xs', 'csa3', 'csa3d', 'csa3l', 'csa3ld', 'csa3ls',
|
| 89 |
+
'csa3lx', 'csa3lxd', 'csa3lxs', 'csa3s', 'csa3x', 'csa3xd',
|
| 90 |
+
'csa3xs', 'csc2s', 'csgetp', 'css2c', 'cssetp', 'cssgrid', 'csstri',
|
| 91 |
+
'csvoro', 'cumsum', 'cz2ccm', 'datatondc', 'day_of_week',
|
| 92 |
+
'day_of_year', 'days_in_month', 'default_fillvalue', 'delete',
|
| 93 |
+
'depth_to_pres', 'destroy', 'determinant', 'dewtemp_trh',
|
| 94 |
+
'dgeevx_lapack', 'dim_acumrun_n', 'dim_avg', 'dim_avg_n',
|
| 95 |
+
'dim_avg_wgt', 'dim_avg_wgt_n', 'dim_cumsum', 'dim_cumsum_n',
|
| 96 |
+
'dim_gamfit_n', 'dim_gbits', 'dim_max', 'dim_max_n', 'dim_median',
|
| 97 |
+
'dim_median_n', 'dim_min', 'dim_min_n', 'dim_num', 'dim_num_n',
|
| 98 |
+
'dim_numrun_n', 'dim_pqsort', 'dim_pqsort_n', 'dim_product',
|
| 99 |
+
'dim_product_n', 'dim_rmsd', 'dim_rmsd_n', 'dim_rmvmean',
|
| 100 |
+
'dim_rmvmean_n', 'dim_rmvmed', 'dim_rmvmed_n', 'dim_spi_n',
|
| 101 |
+
'dim_standardize', 'dim_standardize_n', 'dim_stat4', 'dim_stat4_n',
|
| 102 |
+
'dim_stddev', 'dim_stddev_n', 'dim_sum', 'dim_sum_n', 'dim_sum_wgt',
|
| 103 |
+
'dim_sum_wgt_n', 'dim_variance', 'dim_variance_n', 'dimsizes',
|
| 104 |
+
'doubletobyte', 'doubletochar', 'doubletocharacter',
|
| 105 |
+
'doubletofloat', 'doubletoint', 'doubletointeger', 'doubletolong',
|
| 106 |
+
'doubletoshort', 'dpres_hybrid_ccm', 'dpres_plevel', 'draw',
|
| 107 |
+
'draw_color_palette', 'dsgetp', 'dsgrid2', 'dsgrid2d', 'dsgrid2s',
|
| 108 |
+
'dsgrid3', 'dsgrid3d', 'dsgrid3s', 'dspnt2', 'dspnt2d', 'dspnt2s',
|
| 109 |
+
'dspnt3', 'dspnt3d', 'dspnt3s', 'dssetp', 'dtrend', 'dtrend_msg',
|
| 110 |
+
'dtrend_msg_n', 'dtrend_n', 'dtrend_quadratic',
|
| 111 |
+
'dtrend_quadratic_msg_n', 'dv2uvf', 'dv2uvg', 'dz_height',
|
| 112 |
+
'echo_off', 'echo_on', 'eof2data', 'eof_varimax', 'eofcor',
|
| 113 |
+
'eofcor_pcmsg', 'eofcor_ts', 'eofcov', 'eofcov_pcmsg', 'eofcov_ts',
|
| 114 |
+
'eofunc', 'eofunc_ts', 'eofunc_varimax', 'equiv_sample_size', 'erf',
|
| 115 |
+
'erfc', 'esacr', 'esacv', 'esccr', 'esccv', 'escorc', 'escorc_n',
|
| 116 |
+
'escovc', 'exit', 'exp', 'exp_tapersh', 'exp_tapersh_wgts',
|
| 117 |
+
'exp_tapershC', 'ezfftb', 'ezfftb_n', 'ezfftf', 'ezfftf_n',
|
| 118 |
+
'f2fosh', 'f2foshv', 'f2fsh', 'f2fshv', 'f2gsh', 'f2gshv', 'fabs',
|
| 119 |
+
'fbindirread', 'fbindirwrite', 'fbinnumrec', 'fbinread',
|
| 120 |
+
'fbinrecread', 'fbinrecwrite', 'fbinwrite', 'fft2db', 'fft2df',
|
| 121 |
+
'fftshift', 'fileattdef', 'filechunkdimdef', 'filedimdef',
|
| 122 |
+
'fileexists', 'filegrpdef', 'filevarattdef', 'filevarchunkdef',
|
| 123 |
+
'filevarcompressleveldef', 'filevardef', 'filevardimsizes',
|
| 124 |
+
'filwgts_lancos', 'filwgts_lanczos', 'filwgts_normal',
|
| 125 |
+
'floattobyte', 'floattochar', 'floattocharacter', 'floattoint',
|
| 126 |
+
'floattointeger', 'floattolong', 'floattoshort', 'floor',
|
| 127 |
+
'fluxEddy', 'fo2fsh', 'fo2fshv', 'fourier_info', 'frame', 'fspan',
|
| 128 |
+
'ftcurv', 'ftcurvd', 'ftcurvi', 'ftcurvp', 'ftcurvpi', 'ftcurvps',
|
| 129 |
+
'ftcurvs', 'ftest', 'ftgetp', 'ftkurv', 'ftkurvd', 'ftkurvp',
|
| 130 |
+
'ftkurvpd', 'ftsetp', 'ftsurf', 'g2fsh', 'g2fshv', 'g2gsh',
|
| 131 |
+
'g2gshv', 'gamma', 'gammainc', 'gaus', 'gaus_lobat',
|
| 132 |
+
'gaus_lobat_wgt', 'gc_aangle', 'gc_clkwise', 'gc_dangle',
|
| 133 |
+
'gc_inout', 'gc_latlon', 'gc_onarc', 'gc_pnt2gc', 'gc_qarea',
|
| 134 |
+
'gc_tarea', 'generate_2d_array', 'get_color_index',
|
| 135 |
+
'get_color_rgba', 'get_cpu_time', 'get_isolines', 'get_ncl_version',
|
| 136 |
+
'get_script_name', 'get_script_prefix_name', 'get_sphere_radius',
|
| 137 |
+
'get_unique_values', 'getbitsone', 'getenv', 'getfiledimsizes',
|
| 138 |
+
'getfilegrpnames', 'getfilepath', 'getfilevaratts',
|
| 139 |
+
'getfilevarchunkdimsizes', 'getfilevardims', 'getfilevardimsizes',
|
| 140 |
+
'getfilevarnames', 'getfilevartypes', 'getvaratts', 'getvardims',
|
| 141 |
+
'gradsf', 'gradsg', 'greg2jul', 'grid2triple', 'hlsrgb', 'hsvrgb',
|
| 142 |
+
'hydro', 'hyi2hyo', 'idsfft', 'igradsf', 'igradsg', 'ilapsf',
|
| 143 |
+
'ilapsg', 'ilapvf', 'ilapvg', 'ind', 'ind_resolve', 'int2p',
|
| 144 |
+
'int2p_n', 'integertobyte', 'integertochar', 'integertocharacter',
|
| 145 |
+
'integertoshort', 'inttobyte', 'inttochar', 'inttoshort',
|
| 146 |
+
'inverse_matrix', 'isatt', 'isbigendian', 'isbyte', 'ischar',
|
| 147 |
+
'iscoord', 'isdefined', 'isdim', 'isdimnamed', 'isdouble',
|
| 148 |
+
'isenumeric', 'isfile', 'isfilepresent', 'isfilevar',
|
| 149 |
+
'isfilevaratt', 'isfilevarcoord', 'isfilevardim', 'isfloat',
|
| 150 |
+
'isfunc', 'isgraphic', 'isint', 'isint64', 'isinteger',
|
| 151 |
+
'isleapyear', 'islogical', 'islong', 'ismissing', 'isnan_ieee',
|
| 152 |
+
'isnumeric', 'ispan', 'isproc', 'isshort', 'issnumeric', 'isstring',
|
| 153 |
+
'isubyte', 'isuint', 'isuint64', 'isulong', 'isunlimited',
|
| 154 |
+
'isunsigned', 'isushort', 'isvar', 'jul2greg', 'kmeans_as136',
|
| 155 |
+
'kolsm2_n', 'kron_product', 'lapsf', 'lapsg', 'lapvf', 'lapvg',
|
| 156 |
+
'latlon2utm', 'lclvl', 'lderuvf', 'lderuvg', 'linint1', 'linint1_n',
|
| 157 |
+
'linint2', 'linint2_points', 'linmsg', 'linmsg_n', 'linrood_latwgt',
|
| 158 |
+
'linrood_wgt', 'list_files', 'list_filevars', 'list_hlus',
|
| 159 |
+
'list_procfuncs', 'list_vars', 'ListAppend', 'ListCount',
|
| 160 |
+
'ListGetType', 'ListIndex', 'ListIndexFromName', 'ListPop',
|
| 161 |
+
'ListPush', 'ListSetType', 'loadscript', 'local_max', 'local_min',
|
| 162 |
+
'log', 'log10', 'longtobyte', 'longtochar', 'longtocharacter',
|
| 163 |
+
'longtoint', 'longtointeger', 'longtoshort', 'lspoly', 'lspoly_n',
|
| 164 |
+
'mask', 'max', 'maxind', 'min', 'minind', 'mixed_layer_depth',
|
| 165 |
+
'mixhum_ptd', 'mixhum_ptrh', 'mjo_cross_coh2pha',
|
| 166 |
+
'mjo_cross_segment', 'moc_globe_atl', 'monthday', 'natgrid',
|
| 167 |
+
'natgridd', 'natgrids', 'ncargpath', 'ncargversion', 'ndctodata',
|
| 168 |
+
'ndtooned', 'new', 'NewList', 'ngezlogo', 'nggcog', 'nggetp',
|
| 169 |
+
'nglogo', 'ngsetp', 'NhlAddAnnotation', 'NhlAddData',
|
| 170 |
+
'NhlAddOverlay', 'NhlAddPrimitive', 'NhlAppGetDefaultParentId',
|
| 171 |
+
'NhlChangeWorkstation', 'NhlClassName', 'NhlClearWorkstation',
|
| 172 |
+
'NhlDataPolygon', 'NhlDataPolyline', 'NhlDataPolymarker',
|
| 173 |
+
'NhlDataToNDC', 'NhlDestroy', 'NhlDraw', 'NhlFrame', 'NhlFreeColor',
|
| 174 |
+
'NhlGetBB', 'NhlGetClassResources', 'NhlGetErrorObjectId',
|
| 175 |
+
'NhlGetNamedColorIndex', 'NhlGetParentId',
|
| 176 |
+
'NhlGetParentWorkstation', 'NhlGetWorkspaceObjectId',
|
| 177 |
+
'NhlIsAllocatedColor', 'NhlIsApp', 'NhlIsDataComm', 'NhlIsDataItem',
|
| 178 |
+
'NhlIsDataSpec', 'NhlIsTransform', 'NhlIsView', 'NhlIsWorkstation',
|
| 179 |
+
'NhlName', 'NhlNDCPolygon', 'NhlNDCPolyline', 'NhlNDCPolymarker',
|
| 180 |
+
'NhlNDCToData', 'NhlNewColor', 'NhlNewDashPattern', 'NhlNewMarker',
|
| 181 |
+
'NhlPalGetDefined', 'NhlRemoveAnnotation', 'NhlRemoveData',
|
| 182 |
+
'NhlRemoveOverlay', 'NhlRemovePrimitive', 'NhlSetColor',
|
| 183 |
+
'NhlSetDashPattern', 'NhlSetMarker', 'NhlUpdateData',
|
| 184 |
+
'NhlUpdateWorkstation', 'nice_mnmxintvl', 'nngetaspectd',
|
| 185 |
+
'nngetaspects', 'nngetp', 'nngetsloped', 'nngetslopes', 'nngetwts',
|
| 186 |
+
'nngetwtsd', 'nnpnt', 'nnpntd', 'nnpntend', 'nnpntendd',
|
| 187 |
+
'nnpntinit', 'nnpntinitd', 'nnpntinits', 'nnpnts', 'nnsetp', 'num',
|
| 188 |
+
'obj_anal_ic', 'omega_ccm', 'onedtond', 'overlay', 'paleo_outline',
|
| 189 |
+
'pdfxy_bin', 'poisson_grid_fill', 'pop_remap', 'potmp_insitu_ocn',
|
| 190 |
+
'prcwater_dp', 'pres2hybrid', 'pres_hybrid_ccm', 'pres_sigma',
|
| 191 |
+
'print', 'print_table', 'printFileVarSummary', 'printVarSummary',
|
| 192 |
+
'product', 'pslec', 'pslhor', 'pslhyp', 'qsort', 'rand',
|
| 193 |
+
'random_chi', 'random_gamma', 'random_normal', 'random_setallseed',
|
| 194 |
+
'random_uniform', 'rcm2points', 'rcm2rgrid', 'rdsstoi',
|
| 195 |
+
'read_colormap_file', 'reg_multlin', 'regcoef', 'regCoef_n',
|
| 196 |
+
'regline', 'relhum', 'replace_ieeenan', 'reshape', 'reshape_ind',
|
| 197 |
+
'rgba_to_color_index', 'rgbhls', 'rgbhsv', 'rgbyiq', 'rgrid2rcm',
|
| 198 |
+
'rhomb_trunc', 'rip_cape_2d', 'rip_cape_3d', 'round', 'rtest',
|
| 199 |
+
'runave', 'runave_n', 'set_default_fillvalue', 'set_sphere_radius',
|
| 200 |
+
'setfileoption', 'sfvp2uvf', 'sfvp2uvg', 'shaec', 'shagc',
|
| 201 |
+
'shgetnp', 'shgetp', 'shgrid', 'shorttobyte', 'shorttochar',
|
| 202 |
+
'shorttocharacter', 'show_ascii', 'shsec', 'shsetp', 'shsgc',
|
| 203 |
+
'shsgc_R42', 'sigma2hybrid', 'simpeq', 'simpne', 'sin',
|
| 204 |
+
'sindex_yrmo', 'sinh', 'sizeof', 'sleep', 'smth9', 'snindex_yrmo',
|
| 205 |
+
'solve_linsys', 'span_color_indexes', 'span_color_rgba',
|
| 206 |
+
'sparse_matrix_mult', 'spcorr', 'spcorr_n', 'specx_anal',
|
| 207 |
+
'specxy_anal', 'spei', 'sprintf', 'sprinti', 'sqrt', 'sqsort',
|
| 208 |
+
'srand', 'stat2', 'stat4', 'stat_medrng', 'stat_trim',
|
| 209 |
+
'status_exit', 'stdatmus_p2tdz', 'stdatmus_z2tdp', 'stddev',
|
| 210 |
+
'str_capital', 'str_concat', 'str_fields_count', 'str_get_cols',
|
| 211 |
+
'str_get_dq', 'str_get_field', 'str_get_nl', 'str_get_sq',
|
| 212 |
+
'str_get_tab', 'str_index_of_substr', 'str_insert', 'str_is_blank',
|
| 213 |
+
'str_join', 'str_left_strip', 'str_lower', 'str_match',
|
| 214 |
+
'str_match_ic', 'str_match_ic_regex', 'str_match_ind',
|
| 215 |
+
'str_match_ind_ic', 'str_match_ind_ic_regex', 'str_match_ind_regex',
|
| 216 |
+
'str_match_regex', 'str_right_strip', 'str_split',
|
| 217 |
+
'str_split_by_length', 'str_split_csv', 'str_squeeze', 'str_strip',
|
| 218 |
+
'str_sub_str', 'str_switch', 'str_upper', 'stringtochar',
|
| 219 |
+
'stringtocharacter', 'stringtodouble', 'stringtofloat',
|
| 220 |
+
'stringtoint', 'stringtointeger', 'stringtolong', 'stringtoshort',
|
| 221 |
+
'strlen', 'student_t', 'sum', 'svd_lapack', 'svdcov', 'svdcov_sv',
|
| 222 |
+
'svdstd', 'svdstd_sv', 'system', 'systemfunc', 'tan', 'tanh',
|
| 223 |
+
'taper', 'taper_n', 'tdclrs', 'tdctri', 'tdcudp', 'tdcurv',
|
| 224 |
+
'tddtri', 'tdez2d', 'tdez3d', 'tdgetp', 'tdgrds', 'tdgrid',
|
| 225 |
+
'tdgtrs', 'tdinit', 'tditri', 'tdlbla', 'tdlblp', 'tdlbls',
|
| 226 |
+
'tdline', 'tdlndp', 'tdlnpa', 'tdlpdp', 'tdmtri', 'tdotri',
|
| 227 |
+
'tdpara', 'tdplch', 'tdprpa', 'tdprpi', 'tdprpt', 'tdsetp',
|
| 228 |
+
'tdsort', 'tdstri', 'tdstrs', 'tdttri', 'thornthwaite', 'tobyte',
|
| 229 |
+
'tochar', 'todouble', 'tofloat', 'toint', 'toint64', 'tointeger',
|
| 230 |
+
'tolong', 'toshort', 'tosigned', 'tostring', 'tostring_with_format',
|
| 231 |
+
'totype', 'toubyte', 'touint', 'touint64', 'toulong', 'tounsigned',
|
| 232 |
+
'toushort', 'trend_manken', 'tri_trunc', 'triple2grid',
|
| 233 |
+
'triple2grid2d', 'trop_wmo', 'ttest', 'typeof', 'undef',
|
| 234 |
+
'unique_string', 'update', 'ushorttoint', 'ut_calendar',
|
| 235 |
+
'ut_inv_calendar', 'utm2latlon', 'uv2dv_cfd', 'uv2dvf', 'uv2dvg',
|
| 236 |
+
'uv2sfvpf', 'uv2sfvpg', 'uv2vr_cfd', 'uv2vrdvf', 'uv2vrdvg',
|
| 237 |
+
'uv2vrf', 'uv2vrg', 'v5d_close', 'v5d_create', 'v5d_setLowLev',
|
| 238 |
+
'v5d_setUnits', 'v5d_write', 'v5d_write_var', 'variance', 'vhaec',
|
| 239 |
+
'vhagc', 'vhsec', 'vhsgc', 'vibeta', 'vinth2p', 'vinth2p_ecmwf',
|
| 240 |
+
'vinth2p_ecmwf_nodes', 'vinth2p_nodes', 'vintp2p_ecmwf', 'vr2uvf',
|
| 241 |
+
'vr2uvg', 'vrdv2uvf', 'vrdv2uvg', 'wavelet', 'wavelet_default',
|
| 242 |
+
'weibull', 'wgt_area_smooth', 'wgt_areaave', 'wgt_areaave2',
|
| 243 |
+
'wgt_arearmse', 'wgt_arearmse2', 'wgt_areasum2', 'wgt_runave',
|
| 244 |
+
'wgt_runave_n', 'wgt_vert_avg_beta', 'wgt_volave', 'wgt_volave_ccm',
|
| 245 |
+
'wgt_volrmse', 'wgt_volrmse_ccm', 'where', 'wk_smooth121', 'wmbarb',
|
| 246 |
+
'wmbarbmap', 'wmdrft', 'wmgetp', 'wmlabs', 'wmsetp', 'wmstnm',
|
| 247 |
+
'wmvect', 'wmvectmap', 'wmvlbl', 'wrf_avo', 'wrf_cape_2d',
|
| 248 |
+
'wrf_cape_3d', 'wrf_dbz', 'wrf_eth', 'wrf_helicity', 'wrf_ij_to_ll',
|
| 249 |
+
'wrf_interp_1d', 'wrf_interp_2d_xy', 'wrf_interp_3d_z',
|
| 250 |
+
'wrf_latlon_to_ij', 'wrf_ll_to_ij', 'wrf_omega', 'wrf_pvo',
|
| 251 |
+
'wrf_rh', 'wrf_slp', 'wrf_smooth_2d', 'wrf_td', 'wrf_tk',
|
| 252 |
+
'wrf_updraft_helicity', 'wrf_uvmet', 'wrf_virtual_temp',
|
| 253 |
+
'wrf_wetbulb', 'wrf_wps_close_int', 'wrf_wps_open_int',
|
| 254 |
+
'wrf_wps_rddata_int', 'wrf_wps_rdhead_int', 'wrf_wps_read_int',
|
| 255 |
+
'wrf_wps_write_int', 'write_matrix', 'write_table', 'yiqrgb',
|
| 256 |
+
'z2geouv', 'zonal_mpsi', 'addfiles_GetVar', 'advect_variable',
|
| 257 |
+
'area_conserve_remap_Wrap', 'area_hi2lores_Wrap',
|
| 258 |
+
'array_append_record', 'assignFillValue', 'byte2flt',
|
| 259 |
+
'byte2flt_hdf', 'calcDayAnomTLL', 'calcMonAnomLLLT',
|
| 260 |
+
'calcMonAnomLLT', 'calcMonAnomTLL', 'calcMonAnomTLLL',
|
| 261 |
+
'calculate_monthly_values', 'cd_convert', 'changeCase',
|
| 262 |
+
'changeCaseChar', 'clmDayTLL', 'clmDayTLLL', 'clmMon2clmDay',
|
| 263 |
+
'clmMonLLLT', 'clmMonLLT', 'clmMonTLL', 'clmMonTLLL', 'closest_val',
|
| 264 |
+
'copy_VarAtts', 'copy_VarCoords', 'copy_VarCoords_1',
|
| 265 |
+
'copy_VarCoords_2', 'copy_VarMeta', 'copyatt', 'crossp3',
|
| 266 |
+
'cshstringtolist', 'cssgrid_Wrap', 'dble2flt', 'decimalPlaces',
|
| 267 |
+
'delete_VarAtts', 'dim_avg_n_Wrap', 'dim_avg_wgt_n_Wrap',
|
| 268 |
+
'dim_avg_wgt_Wrap', 'dim_avg_Wrap', 'dim_cumsum_n_Wrap',
|
| 269 |
+
'dim_cumsum_Wrap', 'dim_max_n_Wrap', 'dim_min_n_Wrap',
|
| 270 |
+
'dim_rmsd_n_Wrap', 'dim_rmsd_Wrap', 'dim_rmvmean_n_Wrap',
|
| 271 |
+
'dim_rmvmean_Wrap', 'dim_rmvmed_n_Wrap', 'dim_rmvmed_Wrap',
|
| 272 |
+
'dim_standardize_n_Wrap', 'dim_standardize_Wrap',
|
| 273 |
+
'dim_stddev_n_Wrap', 'dim_stddev_Wrap', 'dim_sum_n_Wrap',
|
| 274 |
+
'dim_sum_wgt_n_Wrap', 'dim_sum_wgt_Wrap', 'dim_sum_Wrap',
|
| 275 |
+
'dim_variance_n_Wrap', 'dim_variance_Wrap', 'dpres_plevel_Wrap',
|
| 276 |
+
'dtrend_leftdim', 'dv2uvF_Wrap', 'dv2uvG_Wrap', 'eof_north',
|
| 277 |
+
'eofcor_Wrap', 'eofcov_Wrap', 'eofunc_north', 'eofunc_ts_Wrap',
|
| 278 |
+
'eofunc_varimax_reorder', 'eofunc_varimax_Wrap', 'eofunc_Wrap',
|
| 279 |
+
'epsZero', 'f2fosh_Wrap', 'f2foshv_Wrap', 'f2fsh_Wrap',
|
| 280 |
+
'f2fshv_Wrap', 'f2gsh_Wrap', 'f2gshv_Wrap', 'fbindirSwap',
|
| 281 |
+
'fbinseqSwap1', 'fbinseqSwap2', 'flt2dble', 'flt2string',
|
| 282 |
+
'fo2fsh_Wrap', 'fo2fshv_Wrap', 'g2fsh_Wrap', 'g2fshv_Wrap',
|
| 283 |
+
'g2gsh_Wrap', 'g2gshv_Wrap', 'generate_resample_indices',
|
| 284 |
+
'generate_sample_indices', 'generate_unique_indices',
|
| 285 |
+
'genNormalDist', 'get1Dindex', 'get1Dindex_Collapse',
|
| 286 |
+
'get1Dindex_Exclude', 'get_file_suffix', 'GetFillColor',
|
| 287 |
+
'GetFillColorIndex', 'getFillValue', 'getind_latlon2d',
|
| 288 |
+
'getVarDimNames', 'getVarFillValue', 'grib_stime2itime',
|
| 289 |
+
'hyi2hyo_Wrap', 'ilapsF_Wrap', 'ilapsG_Wrap', 'ind_nearest_coord',
|
| 290 |
+
'indStrSubset', 'int2dble', 'int2flt', 'int2p_n_Wrap', 'int2p_Wrap',
|
| 291 |
+
'isMonotonic', 'isStrSubset', 'latGau', 'latGauWgt', 'latGlobeF',
|
| 292 |
+
'latGlobeFo', 'latRegWgt', 'linint1_n_Wrap', 'linint1_Wrap',
|
| 293 |
+
'linint2_points_Wrap', 'linint2_Wrap', 'local_max_1d',
|
| 294 |
+
'local_min_1d', 'lonFlip', 'lonGlobeF', 'lonGlobeFo', 'lonPivot',
|
| 295 |
+
'merge_levels_sfc', 'mod', 'month_to_annual',
|
| 296 |
+
'month_to_annual_weighted', 'month_to_season', 'month_to_season12',
|
| 297 |
+
'month_to_seasonN', 'monthly_total_to_daily_mean', 'nameDim',
|
| 298 |
+
'natgrid_Wrap', 'NewCosWeight', 'niceLatLon2D', 'NormCosWgtGlobe',
|
| 299 |
+
'numAsciiCol', 'numAsciiRow', 'numeric2int',
|
| 300 |
+
'obj_anal_ic_deprecated', 'obj_anal_ic_Wrap', 'omega_ccm_driver',
|
| 301 |
+
'omega_to_w', 'oneDtostring', 'pack_values', 'pattern_cor', 'pdfx',
|
| 302 |
+
'pdfxy', 'pdfxy_conform', 'pot_temp', 'pot_vort_hybrid',
|
| 303 |
+
'pot_vort_isobaric', 'pres2hybrid_Wrap', 'print_clock',
|
| 304 |
+
'printMinMax', 'quadroots', 'rcm2points_Wrap', 'rcm2rgrid_Wrap',
|
| 305 |
+
'readAsciiHead', 'readAsciiTable', 'reg_multlin_stats',
|
| 306 |
+
'region_ind', 'regline_stats', 'relhum_ttd', 'replaceSingleChar',
|
| 307 |
+
'RGBtoCmap', 'rgrid2rcm_Wrap', 'rho_mwjf', 'rm_single_dims',
|
| 308 |
+
'rmAnnCycle1D', 'rmInsufData', 'rmMonAnnCycLLLT', 'rmMonAnnCycLLT',
|
| 309 |
+
'rmMonAnnCycTLL', 'runave_n_Wrap', 'runave_Wrap', 'short2flt',
|
| 310 |
+
'short2flt_hdf', 'shsgc_R42_Wrap', 'sign_f90', 'sign_matlab',
|
| 311 |
+
'smth9_Wrap', 'smthClmDayTLL', 'smthClmDayTLLL', 'SqrtCosWeight',
|
| 312 |
+
'stat_dispersion', 'static_stability', 'stdMonLLLT', 'stdMonLLT',
|
| 313 |
+
'stdMonTLL', 'stdMonTLLL', 'symMinMaxPlt', 'table_attach_columns',
|
| 314 |
+
'table_attach_rows', 'time_to_newtime', 'transpose',
|
| 315 |
+
'triple2grid_Wrap', 'ut_convert', 'uv2dvF_Wrap', 'uv2dvG_Wrap',
|
| 316 |
+
'uv2vrF_Wrap', 'uv2vrG_Wrap', 'vr2uvF_Wrap', 'vr2uvG_Wrap',
|
| 317 |
+
'w_to_omega', 'wallClockElapseTime', 'wave_number_spc',
|
| 318 |
+
'wgt_areaave_Wrap', 'wgt_runave_leftdim', 'wgt_runave_n_Wrap',
|
| 319 |
+
'wgt_runave_Wrap', 'wgt_vertical_n', 'wind_component',
|
| 320 |
+
'wind_direction', 'yyyyddd_to_yyyymmdd', 'yyyymm_time',
|
| 321 |
+
'yyyymm_to_yyyyfrac', 'yyyymmdd_time', 'yyyymmdd_to_yyyyddd',
|
| 322 |
+
'yyyymmdd_to_yyyyfrac', 'yyyymmddhh_time', 'yyyymmddhh_to_yyyyfrac',
|
| 323 |
+
'zonal_mpsi_Wrap', 'zonalAve', 'calendar_decode2', 'cd_string',
|
| 324 |
+
'kf_filter', 'run_cor', 'time_axis_labels', 'ut_string',
|
| 325 |
+
'wrf_contour', 'wrf_map', 'wrf_map_overlay', 'wrf_map_overlays',
|
| 326 |
+
'wrf_map_resources', 'wrf_map_zoom', 'wrf_overlay', 'wrf_overlays',
|
| 327 |
+
'wrf_user_getvar', 'wrf_user_ij_to_ll', 'wrf_user_intrp2d',
|
| 328 |
+
'wrf_user_intrp3d', 'wrf_user_latlon_to_ij', 'wrf_user_list_times',
|
| 329 |
+
'wrf_user_ll_to_ij', 'wrf_user_unstagger', 'wrf_user_vert_interp',
|
| 330 |
+
'wrf_vector', 'gsn_add_annotation', 'gsn_add_polygon',
|
| 331 |
+
'gsn_add_polyline', 'gsn_add_polymarker',
|
| 332 |
+
'gsn_add_shapefile_polygons', 'gsn_add_shapefile_polylines',
|
| 333 |
+
'gsn_add_shapefile_polymarkers', 'gsn_add_text', 'gsn_attach_plots',
|
| 334 |
+
'gsn_blank_plot', 'gsn_contour', 'gsn_contour_map',
|
| 335 |
+
'gsn_contour_shade', 'gsn_coordinates', 'gsn_create_labelbar',
|
| 336 |
+
'gsn_create_legend', 'gsn_create_text',
|
| 337 |
+
'gsn_csm_attach_zonal_means', 'gsn_csm_blank_plot',
|
| 338 |
+
'gsn_csm_contour', 'gsn_csm_contour_map', 'gsn_csm_contour_map_ce',
|
| 339 |
+
'gsn_csm_contour_map_overlay', 'gsn_csm_contour_map_polar',
|
| 340 |
+
'gsn_csm_hov', 'gsn_csm_lat_time', 'gsn_csm_map', 'gsn_csm_map_ce',
|
| 341 |
+
'gsn_csm_map_polar', 'gsn_csm_pres_hgt',
|
| 342 |
+
'gsn_csm_pres_hgt_streamline', 'gsn_csm_pres_hgt_vector',
|
| 343 |
+
'gsn_csm_streamline', 'gsn_csm_streamline_contour_map',
|
| 344 |
+
'gsn_csm_streamline_contour_map_ce',
|
| 345 |
+
'gsn_csm_streamline_contour_map_polar', 'gsn_csm_streamline_map',
|
| 346 |
+
'gsn_csm_streamline_map_ce', 'gsn_csm_streamline_map_polar',
|
| 347 |
+
'gsn_csm_streamline_scalar', 'gsn_csm_streamline_scalar_map',
|
| 348 |
+
'gsn_csm_streamline_scalar_map_ce',
|
| 349 |
+
'gsn_csm_streamline_scalar_map_polar', 'gsn_csm_time_lat',
|
| 350 |
+
'gsn_csm_vector', 'gsn_csm_vector_map', 'gsn_csm_vector_map_ce',
|
| 351 |
+
'gsn_csm_vector_map_polar', 'gsn_csm_vector_scalar',
|
| 352 |
+
'gsn_csm_vector_scalar_map', 'gsn_csm_vector_scalar_map_ce',
|
| 353 |
+
'gsn_csm_vector_scalar_map_polar', 'gsn_csm_x2y', 'gsn_csm_x2y2',
|
| 354 |
+
'gsn_csm_xy', 'gsn_csm_xy2', 'gsn_csm_xy3', 'gsn_csm_y',
|
| 355 |
+
'gsn_define_colormap', 'gsn_draw_colormap', 'gsn_draw_named_colors',
|
| 356 |
+
'gsn_histogram', 'gsn_labelbar_ndc', 'gsn_legend_ndc', 'gsn_map',
|
| 357 |
+
'gsn_merge_colormaps', 'gsn_open_wks', 'gsn_panel', 'gsn_polygon',
|
| 358 |
+
'gsn_polygon_ndc', 'gsn_polyline', 'gsn_polyline_ndc',
|
| 359 |
+
'gsn_polymarker', 'gsn_polymarker_ndc', 'gsn_retrieve_colormap',
|
| 360 |
+
'gsn_reverse_colormap', 'gsn_streamline', 'gsn_streamline_map',
|
| 361 |
+
'gsn_streamline_scalar', 'gsn_streamline_scalar_map', 'gsn_table',
|
| 362 |
+
'gsn_text', 'gsn_text_ndc', 'gsn_vector', 'gsn_vector_map',
|
| 363 |
+
'gsn_vector_scalar', 'gsn_vector_scalar_map', 'gsn_xy', 'gsn_y',
|
| 364 |
+
'hsv2rgb', 'maximize_output', 'namedcolor2rgb', 'namedcolor2rgba',
|
| 365 |
+
'reset_device_coordinates', 'span_named_colors'), prefix=r'\b'),
|
| 366 |
+
Name.Builtin),
|
| 367 |
+
|
| 368 |
+
# Resources
|
| 369 |
+
(words((
|
| 370 |
+
'amDataXF', 'amDataYF', 'amJust', 'amOn', 'amOrthogonalPosF',
|
| 371 |
+
'amParallelPosF', 'amResizeNotify', 'amSide', 'amTrackData',
|
| 372 |
+
'amViewId', 'amZone', 'appDefaultParent', 'appFileSuffix',
|
| 373 |
+
'appResources', 'appSysDir', 'appUsrDir', 'caCopyArrays',
|
| 374 |
+
'caXArray', 'caXCast', 'caXMaxV', 'caXMinV', 'caXMissingV',
|
| 375 |
+
'caYArray', 'caYCast', 'caYMaxV', 'caYMinV', 'caYMissingV',
|
| 376 |
+
'cnCellFillEdgeColor', 'cnCellFillMissingValEdgeColor',
|
| 377 |
+
'cnConpackParams', 'cnConstFEnableFill', 'cnConstFLabelAngleF',
|
| 378 |
+
'cnConstFLabelBackgroundColor', 'cnConstFLabelConstantSpacingF',
|
| 379 |
+
'cnConstFLabelFont', 'cnConstFLabelFontAspectF',
|
| 380 |
+
'cnConstFLabelFontColor', 'cnConstFLabelFontHeightF',
|
| 381 |
+
'cnConstFLabelFontQuality', 'cnConstFLabelFontThicknessF',
|
| 382 |
+
'cnConstFLabelFormat', 'cnConstFLabelFuncCode', 'cnConstFLabelJust',
|
| 383 |
+
'cnConstFLabelOn', 'cnConstFLabelOrthogonalPosF',
|
| 384 |
+
'cnConstFLabelParallelPosF', 'cnConstFLabelPerimColor',
|
| 385 |
+
'cnConstFLabelPerimOn', 'cnConstFLabelPerimSpaceF',
|
| 386 |
+
'cnConstFLabelPerimThicknessF', 'cnConstFLabelSide',
|
| 387 |
+
'cnConstFLabelString', 'cnConstFLabelTextDirection',
|
| 388 |
+
'cnConstFLabelZone', 'cnConstFUseInfoLabelRes',
|
| 389 |
+
'cnExplicitLabelBarLabelsOn', 'cnExplicitLegendLabelsOn',
|
| 390 |
+
'cnExplicitLineLabelsOn', 'cnFillBackgroundColor', 'cnFillColor',
|
| 391 |
+
'cnFillColors', 'cnFillDotSizeF', 'cnFillDrawOrder', 'cnFillMode',
|
| 392 |
+
'cnFillOn', 'cnFillOpacityF', 'cnFillPalette', 'cnFillPattern',
|
| 393 |
+
'cnFillPatterns', 'cnFillScaleF', 'cnFillScales', 'cnFixFillBleed',
|
| 394 |
+
'cnGridBoundFillColor', 'cnGridBoundFillPattern',
|
| 395 |
+
'cnGridBoundFillScaleF', 'cnGridBoundPerimColor',
|
| 396 |
+
'cnGridBoundPerimDashPattern', 'cnGridBoundPerimOn',
|
| 397 |
+
'cnGridBoundPerimThicknessF', 'cnHighLabelAngleF',
|
| 398 |
+
'cnHighLabelBackgroundColor', 'cnHighLabelConstantSpacingF',
|
| 399 |
+
'cnHighLabelCount', 'cnHighLabelFont', 'cnHighLabelFontAspectF',
|
| 400 |
+
'cnHighLabelFontColor', 'cnHighLabelFontHeightF',
|
| 401 |
+
'cnHighLabelFontQuality', 'cnHighLabelFontThicknessF',
|
| 402 |
+
'cnHighLabelFormat', 'cnHighLabelFuncCode', 'cnHighLabelPerimColor',
|
| 403 |
+
'cnHighLabelPerimOn', 'cnHighLabelPerimSpaceF',
|
| 404 |
+
'cnHighLabelPerimThicknessF', 'cnHighLabelString', 'cnHighLabelsOn',
|
| 405 |
+
'cnHighLowLabelOverlapMode', 'cnHighUseLineLabelRes',
|
| 406 |
+
'cnInfoLabelAngleF', 'cnInfoLabelBackgroundColor',
|
| 407 |
+
'cnInfoLabelConstantSpacingF', 'cnInfoLabelFont',
|
| 408 |
+
'cnInfoLabelFontAspectF', 'cnInfoLabelFontColor',
|
| 409 |
+
'cnInfoLabelFontHeightF', 'cnInfoLabelFontQuality',
|
| 410 |
+
'cnInfoLabelFontThicknessF', 'cnInfoLabelFormat',
|
| 411 |
+
'cnInfoLabelFuncCode', 'cnInfoLabelJust', 'cnInfoLabelOn',
|
| 412 |
+
'cnInfoLabelOrthogonalPosF', 'cnInfoLabelParallelPosF',
|
| 413 |
+
'cnInfoLabelPerimColor', 'cnInfoLabelPerimOn',
|
| 414 |
+
'cnInfoLabelPerimSpaceF', 'cnInfoLabelPerimThicknessF',
|
| 415 |
+
'cnInfoLabelSide', 'cnInfoLabelString', 'cnInfoLabelTextDirection',
|
| 416 |
+
'cnInfoLabelZone', 'cnLabelBarEndLabelsOn', 'cnLabelBarEndStyle',
|
| 417 |
+
'cnLabelDrawOrder', 'cnLabelMasking', 'cnLabelScaleFactorF',
|
| 418 |
+
'cnLabelScaleValueF', 'cnLabelScalingMode', 'cnLegendLevelFlags',
|
| 419 |
+
'cnLevelCount', 'cnLevelFlag', 'cnLevelFlags', 'cnLevelSelectionMode',
|
| 420 |
+
'cnLevelSpacingF', 'cnLevels', 'cnLineColor', 'cnLineColors',
|
| 421 |
+
'cnLineDashPattern', 'cnLineDashPatterns', 'cnLineDashSegLenF',
|
| 422 |
+
'cnLineDrawOrder', 'cnLineLabelAngleF', 'cnLineLabelBackgroundColor',
|
| 423 |
+
'cnLineLabelConstantSpacingF', 'cnLineLabelCount',
|
| 424 |
+
'cnLineLabelDensityF', 'cnLineLabelFont', 'cnLineLabelFontAspectF',
|
| 425 |
+
'cnLineLabelFontColor', 'cnLineLabelFontColors',
|
| 426 |
+
'cnLineLabelFontHeightF', 'cnLineLabelFontQuality',
|
| 427 |
+
'cnLineLabelFontThicknessF', 'cnLineLabelFormat',
|
| 428 |
+
'cnLineLabelFuncCode', 'cnLineLabelInterval', 'cnLineLabelPerimColor',
|
| 429 |
+
'cnLineLabelPerimOn', 'cnLineLabelPerimSpaceF',
|
| 430 |
+
'cnLineLabelPerimThicknessF', 'cnLineLabelPlacementMode',
|
| 431 |
+
'cnLineLabelStrings', 'cnLineLabelsOn', 'cnLinePalette',
|
| 432 |
+
'cnLineThicknessF', 'cnLineThicknesses', 'cnLinesOn',
|
| 433 |
+
'cnLowLabelAngleF', 'cnLowLabelBackgroundColor',
|
| 434 |
+
'cnLowLabelConstantSpacingF', 'cnLowLabelCount', 'cnLowLabelFont',
|
| 435 |
+
'cnLowLabelFontAspectF', 'cnLowLabelFontColor',
|
| 436 |
+
'cnLowLabelFontHeightF', 'cnLowLabelFontQuality',
|
| 437 |
+
'cnLowLabelFontThicknessF', 'cnLowLabelFormat', 'cnLowLabelFuncCode',
|
| 438 |
+
'cnLowLabelPerimColor', 'cnLowLabelPerimOn', 'cnLowLabelPerimSpaceF',
|
| 439 |
+
'cnLowLabelPerimThicknessF', 'cnLowLabelString', 'cnLowLabelsOn',
|
| 440 |
+
'cnLowUseHighLabelRes', 'cnMaxDataValueFormat', 'cnMaxLevelCount',
|
| 441 |
+
'cnMaxLevelValF', 'cnMaxPointDistanceF', 'cnMinLevelValF',
|
| 442 |
+
'cnMissingValFillColor', 'cnMissingValFillPattern',
|
| 443 |
+
'cnMissingValFillScaleF', 'cnMissingValPerimColor',
|
| 444 |
+
'cnMissingValPerimDashPattern', 'cnMissingValPerimGridBoundOn',
|
| 445 |
+
'cnMissingValPerimOn', 'cnMissingValPerimThicknessF',
|
| 446 |
+
'cnMonoFillColor', 'cnMonoFillPattern', 'cnMonoFillScale',
|
| 447 |
+
'cnMonoLevelFlag', 'cnMonoLineColor', 'cnMonoLineDashPattern',
|
| 448 |
+
'cnMonoLineLabelFontColor', 'cnMonoLineThickness', 'cnNoDataLabelOn',
|
| 449 |
+
'cnNoDataLabelString', 'cnOutOfRangeFillColor',
|
| 450 |
+
'cnOutOfRangeFillPattern', 'cnOutOfRangeFillScaleF',
|
| 451 |
+
'cnOutOfRangePerimColor', 'cnOutOfRangePerimDashPattern',
|
| 452 |
+
'cnOutOfRangePerimOn', 'cnOutOfRangePerimThicknessF',
|
| 453 |
+
'cnRasterCellSizeF', 'cnRasterMinCellSizeF', 'cnRasterModeOn',
|
| 454 |
+
'cnRasterSampleFactorF', 'cnRasterSmoothingOn', 'cnScalarFieldData',
|
| 455 |
+
'cnSmoothingDistanceF', 'cnSmoothingOn', 'cnSmoothingTensionF',
|
| 456 |
+
'cnSpanFillPalette', 'cnSpanLinePalette', 'ctCopyTables',
|
| 457 |
+
'ctXElementSize', 'ctXMaxV', 'ctXMinV', 'ctXMissingV', 'ctXTable',
|
| 458 |
+
'ctXTableLengths', 'ctXTableType', 'ctYElementSize', 'ctYMaxV',
|
| 459 |
+
'ctYMinV', 'ctYMissingV', 'ctYTable', 'ctYTableLengths',
|
| 460 |
+
'ctYTableType', 'dcDelayCompute', 'errBuffer',
|
| 461 |
+
'errFileName', 'errFilePtr', 'errLevel', 'errPrint', 'errUnitNumber',
|
| 462 |
+
'gsClipOn', 'gsColors', 'gsEdgeColor', 'gsEdgeDashPattern',
|
| 463 |
+
'gsEdgeDashSegLenF', 'gsEdgeThicknessF', 'gsEdgesOn',
|
| 464 |
+
'gsFillBackgroundColor', 'gsFillColor', 'gsFillDotSizeF',
|
| 465 |
+
'gsFillIndex', 'gsFillLineThicknessF', 'gsFillOpacityF',
|
| 466 |
+
'gsFillScaleF', 'gsFont', 'gsFontAspectF', 'gsFontColor',
|
| 467 |
+
'gsFontHeightF', 'gsFontOpacityF', 'gsFontQuality',
|
| 468 |
+
'gsFontThicknessF', 'gsLineColor', 'gsLineDashPattern',
|
| 469 |
+
'gsLineDashSegLenF', 'gsLineLabelConstantSpacingF', 'gsLineLabelFont',
|
| 470 |
+
'gsLineLabelFontAspectF', 'gsLineLabelFontColor',
|
| 471 |
+
'gsLineLabelFontHeightF', 'gsLineLabelFontQuality',
|
| 472 |
+
'gsLineLabelFontThicknessF', 'gsLineLabelFuncCode',
|
| 473 |
+
'gsLineLabelString', 'gsLineOpacityF', 'gsLineThicknessF',
|
| 474 |
+
'gsMarkerColor', 'gsMarkerIndex', 'gsMarkerOpacityF', 'gsMarkerSizeF',
|
| 475 |
+
'gsMarkerThicknessF', 'gsSegments', 'gsTextAngleF',
|
| 476 |
+
'gsTextConstantSpacingF', 'gsTextDirection', 'gsTextFuncCode',
|
| 477 |
+
'gsTextJustification', 'gsnAboveYRefLineBarColors',
|
| 478 |
+
'gsnAboveYRefLineBarFillScales', 'gsnAboveYRefLineBarPatterns',
|
| 479 |
+
'gsnAboveYRefLineColor', 'gsnAddCyclic', 'gsnAttachBorderOn',
|
| 480 |
+
'gsnAttachPlotsXAxis', 'gsnBelowYRefLineBarColors',
|
| 481 |
+
'gsnBelowYRefLineBarFillScales', 'gsnBelowYRefLineBarPatterns',
|
| 482 |
+
'gsnBelowYRefLineColor', 'gsnBoxMargin', 'gsnCenterString',
|
| 483 |
+
'gsnCenterStringFontColor', 'gsnCenterStringFontHeightF',
|
| 484 |
+
'gsnCenterStringFuncCode', 'gsnCenterStringOrthogonalPosF',
|
| 485 |
+
'gsnCenterStringParallelPosF', 'gsnContourLineThicknessesScale',
|
| 486 |
+
'gsnContourNegLineDashPattern', 'gsnContourPosLineDashPattern',
|
| 487 |
+
'gsnContourZeroLineThicknessF', 'gsnDebugWriteFileName', 'gsnDraw',
|
| 488 |
+
'gsnFrame', 'gsnHistogramBarWidthPercent', 'gsnHistogramBinIntervals',
|
| 489 |
+
'gsnHistogramBinMissing', 'gsnHistogramBinWidth',
|
| 490 |
+
'gsnHistogramClassIntervals', 'gsnHistogramCompare',
|
| 491 |
+
'gsnHistogramComputePercentages',
|
| 492 |
+
'gsnHistogramComputePercentagesNoMissing',
|
| 493 |
+
'gsnHistogramDiscreteBinValues', 'gsnHistogramDiscreteClassValues',
|
| 494 |
+
'gsnHistogramHorizontal', 'gsnHistogramMinMaxBinsOn',
|
| 495 |
+
'gsnHistogramNumberOfBins', 'gsnHistogramPercentSign',
|
| 496 |
+
'gsnHistogramSelectNiceIntervals', 'gsnLeftString',
|
| 497 |
+
'gsnLeftStringFontColor', 'gsnLeftStringFontHeightF',
|
| 498 |
+
'gsnLeftStringFuncCode', 'gsnLeftStringOrthogonalPosF',
|
| 499 |
+
'gsnLeftStringParallelPosF', 'gsnMajorLatSpacing',
|
| 500 |
+
'gsnMajorLonSpacing', 'gsnMaskLambertConformal',
|
| 501 |
+
'gsnMaskLambertConformalOutlineOn', 'gsnMaximize',
|
| 502 |
+
'gsnMinorLatSpacing', 'gsnMinorLonSpacing', 'gsnPanelBottom',
|
| 503 |
+
'gsnPanelCenter', 'gsnPanelDebug', 'gsnPanelFigureStrings',
|
| 504 |
+
'gsnPanelFigureStringsBackgroundFillColor',
|
| 505 |
+
'gsnPanelFigureStringsFontHeightF', 'gsnPanelFigureStringsJust',
|
| 506 |
+
'gsnPanelFigureStringsPerimOn', 'gsnPanelLabelBar', 'gsnPanelLeft',
|
| 507 |
+
'gsnPanelMainFont', 'gsnPanelMainFontColor',
|
| 508 |
+
'gsnPanelMainFontHeightF', 'gsnPanelMainString', 'gsnPanelRight',
|
| 509 |
+
'gsnPanelRowSpec', 'gsnPanelScalePlotIndex', 'gsnPanelTop',
|
| 510 |
+
'gsnPanelXF', 'gsnPanelXWhiteSpacePercent', 'gsnPanelYF',
|
| 511 |
+
'gsnPanelYWhiteSpacePercent', 'gsnPaperHeight', 'gsnPaperMargin',
|
| 512 |
+
'gsnPaperOrientation', 'gsnPaperWidth', 'gsnPolar',
|
| 513 |
+
'gsnPolarLabelDistance', 'gsnPolarLabelFont',
|
| 514 |
+
'gsnPolarLabelFontHeightF', 'gsnPolarLabelSpacing', 'gsnPolarTime',
|
| 515 |
+
'gsnPolarUT', 'gsnRightString', 'gsnRightStringFontColor',
|
| 516 |
+
'gsnRightStringFontHeightF', 'gsnRightStringFuncCode',
|
| 517 |
+
'gsnRightStringOrthogonalPosF', 'gsnRightStringParallelPosF',
|
| 518 |
+
'gsnScalarContour', 'gsnScale', 'gsnShape', 'gsnSpreadColorEnd',
|
| 519 |
+
'gsnSpreadColorStart', 'gsnSpreadColors', 'gsnStringFont',
|
| 520 |
+
'gsnStringFontColor', 'gsnStringFontHeightF', 'gsnStringFuncCode',
|
| 521 |
+
'gsnTickMarksOn', 'gsnXAxisIrregular2Linear', 'gsnXAxisIrregular2Log',
|
| 522 |
+
'gsnXRefLine', 'gsnXRefLineColor', 'gsnXRefLineDashPattern',
|
| 523 |
+
'gsnXRefLineThicknessF', 'gsnXYAboveFillColors', 'gsnXYBarChart',
|
| 524 |
+
'gsnXYBarChartBarWidth', 'gsnXYBarChartColors',
|
| 525 |
+
'gsnXYBarChartColors2', 'gsnXYBarChartFillDotSizeF',
|
| 526 |
+
'gsnXYBarChartFillLineThicknessF', 'gsnXYBarChartFillOpacityF',
|
| 527 |
+
'gsnXYBarChartFillScaleF', 'gsnXYBarChartOutlineOnly',
|
| 528 |
+
'gsnXYBarChartOutlineThicknessF', 'gsnXYBarChartPatterns',
|
| 529 |
+
'gsnXYBarChartPatterns2', 'gsnXYBelowFillColors', 'gsnXYFillColors',
|
| 530 |
+
'gsnXYFillOpacities', 'gsnXYLeftFillColors', 'gsnXYRightFillColors',
|
| 531 |
+
'gsnYAxisIrregular2Linear', 'gsnYAxisIrregular2Log', 'gsnYRefLine',
|
| 532 |
+
'gsnYRefLineColor', 'gsnYRefLineColors', 'gsnYRefLineDashPattern',
|
| 533 |
+
'gsnYRefLineDashPatterns', 'gsnYRefLineThicknessF',
|
| 534 |
+
'gsnYRefLineThicknesses', 'gsnZonalMean', 'gsnZonalMeanXMaxF',
|
| 535 |
+
'gsnZonalMeanXMinF', 'gsnZonalMeanYRefLine', 'lbAutoManage',
|
| 536 |
+
'lbBottomMarginF', 'lbBoxCount', 'lbBoxEndCapStyle', 'lbBoxFractions',
|
| 537 |
+
'lbBoxLineColor', 'lbBoxLineDashPattern', 'lbBoxLineDashSegLenF',
|
| 538 |
+
'lbBoxLineThicknessF', 'lbBoxLinesOn', 'lbBoxMajorExtentF',
|
| 539 |
+
'lbBoxMinorExtentF', 'lbBoxSeparatorLinesOn', 'lbBoxSizing',
|
| 540 |
+
'lbFillBackground', 'lbFillColor', 'lbFillColors', 'lbFillDotSizeF',
|
| 541 |
+
'lbFillLineThicknessF', 'lbFillPattern', 'lbFillPatterns',
|
| 542 |
+
'lbFillScaleF', 'lbFillScales', 'lbJustification', 'lbLabelAlignment',
|
| 543 |
+
'lbLabelAngleF', 'lbLabelAutoStride', 'lbLabelBarOn',
|
| 544 |
+
'lbLabelConstantSpacingF', 'lbLabelDirection', 'lbLabelFont',
|
| 545 |
+
'lbLabelFontAspectF', 'lbLabelFontColor', 'lbLabelFontHeightF',
|
| 546 |
+
'lbLabelFontQuality', 'lbLabelFontThicknessF', 'lbLabelFuncCode',
|
| 547 |
+
'lbLabelJust', 'lbLabelOffsetF', 'lbLabelPosition', 'lbLabelStride',
|
| 548 |
+
'lbLabelStrings', 'lbLabelsOn', 'lbLeftMarginF', 'lbMaxLabelLenF',
|
| 549 |
+
'lbMinLabelSpacingF', 'lbMonoFillColor', 'lbMonoFillPattern',
|
| 550 |
+
'lbMonoFillScale', 'lbOrientation', 'lbPerimColor',
|
| 551 |
+
'lbPerimDashPattern', 'lbPerimDashSegLenF', 'lbPerimFill',
|
| 552 |
+
'lbPerimFillColor', 'lbPerimOn', 'lbPerimThicknessF',
|
| 553 |
+
'lbRasterFillOn', 'lbRightMarginF', 'lbTitleAngleF',
|
| 554 |
+
'lbTitleConstantSpacingF', 'lbTitleDirection', 'lbTitleExtentF',
|
| 555 |
+
'lbTitleFont', 'lbTitleFontAspectF', 'lbTitleFontColor',
|
| 556 |
+
'lbTitleFontHeightF', 'lbTitleFontQuality', 'lbTitleFontThicknessF',
|
| 557 |
+
'lbTitleFuncCode', 'lbTitleJust', 'lbTitleOffsetF', 'lbTitleOn',
|
| 558 |
+
'lbTitlePosition', 'lbTitleString', 'lbTopMarginF', 'lgAutoManage',
|
| 559 |
+
'lgBottomMarginF', 'lgBoxBackground', 'lgBoxLineColor',
|
| 560 |
+
'lgBoxLineDashPattern', 'lgBoxLineDashSegLenF', 'lgBoxLineThicknessF',
|
| 561 |
+
'lgBoxLinesOn', 'lgBoxMajorExtentF', 'lgBoxMinorExtentF',
|
| 562 |
+
'lgDashIndex', 'lgDashIndexes', 'lgItemCount', 'lgItemOrder',
|
| 563 |
+
'lgItemPlacement', 'lgItemPositions', 'lgItemType', 'lgItemTypes',
|
| 564 |
+
'lgJustification', 'lgLabelAlignment', 'lgLabelAngleF',
|
| 565 |
+
'lgLabelAutoStride', 'lgLabelConstantSpacingF', 'lgLabelDirection',
|
| 566 |
+
'lgLabelFont', 'lgLabelFontAspectF', 'lgLabelFontColor',
|
| 567 |
+
'lgLabelFontHeightF', 'lgLabelFontQuality', 'lgLabelFontThicknessF',
|
| 568 |
+
'lgLabelFuncCode', 'lgLabelJust', 'lgLabelOffsetF', 'lgLabelPosition',
|
| 569 |
+
'lgLabelStride', 'lgLabelStrings', 'lgLabelsOn', 'lgLeftMarginF',
|
| 570 |
+
'lgLegendOn', 'lgLineColor', 'lgLineColors', 'lgLineDashSegLenF',
|
| 571 |
+
'lgLineDashSegLens', 'lgLineLabelConstantSpacingF', 'lgLineLabelFont',
|
| 572 |
+
'lgLineLabelFontAspectF', 'lgLineLabelFontColor',
|
| 573 |
+
'lgLineLabelFontColors', 'lgLineLabelFontHeightF',
|
| 574 |
+
'lgLineLabelFontHeights', 'lgLineLabelFontQuality',
|
| 575 |
+
'lgLineLabelFontThicknessF', 'lgLineLabelFuncCode',
|
| 576 |
+
'lgLineLabelStrings', 'lgLineLabelsOn', 'lgLineThicknessF',
|
| 577 |
+
'lgLineThicknesses', 'lgMarkerColor', 'lgMarkerColors',
|
| 578 |
+
'lgMarkerIndex', 'lgMarkerIndexes', 'lgMarkerSizeF', 'lgMarkerSizes',
|
| 579 |
+
'lgMarkerThicknessF', 'lgMarkerThicknesses', 'lgMonoDashIndex',
|
| 580 |
+
'lgMonoItemType', 'lgMonoLineColor', 'lgMonoLineDashSegLen',
|
| 581 |
+
'lgMonoLineLabelFontColor', 'lgMonoLineLabelFontHeight',
|
| 582 |
+
'lgMonoLineThickness', 'lgMonoMarkerColor', 'lgMonoMarkerIndex',
|
| 583 |
+
'lgMonoMarkerSize', 'lgMonoMarkerThickness', 'lgOrientation',
|
| 584 |
+
'lgPerimColor', 'lgPerimDashPattern', 'lgPerimDashSegLenF',
|
| 585 |
+
'lgPerimFill', 'lgPerimFillColor', 'lgPerimOn', 'lgPerimThicknessF',
|
| 586 |
+
'lgRightMarginF', 'lgTitleAngleF', 'lgTitleConstantSpacingF',
|
| 587 |
+
'lgTitleDirection', 'lgTitleExtentF', 'lgTitleFont',
|
| 588 |
+
'lgTitleFontAspectF', 'lgTitleFontColor', 'lgTitleFontHeightF',
|
| 589 |
+
'lgTitleFontQuality', 'lgTitleFontThicknessF', 'lgTitleFuncCode',
|
| 590 |
+
'lgTitleJust', 'lgTitleOffsetF', 'lgTitleOn', 'lgTitlePosition',
|
| 591 |
+
'lgTitleString', 'lgTopMarginF', 'mpAreaGroupCount',
|
| 592 |
+
'mpAreaMaskingOn', 'mpAreaNames', 'mpAreaTypes', 'mpBottomAngleF',
|
| 593 |
+
'mpBottomMapPosF', 'mpBottomNDCF', 'mpBottomNPCF',
|
| 594 |
+
'mpBottomPointLatF', 'mpBottomPointLonF', 'mpBottomWindowF',
|
| 595 |
+
'mpCenterLatF', 'mpCenterLonF', 'mpCenterRotF', 'mpCountyLineColor',
|
| 596 |
+
'mpCountyLineDashPattern', 'mpCountyLineDashSegLenF',
|
| 597 |
+
'mpCountyLineThicknessF', 'mpDataBaseVersion', 'mpDataResolution',
|
| 598 |
+
'mpDataSetName', 'mpDefaultFillColor', 'mpDefaultFillPattern',
|
| 599 |
+
'mpDefaultFillScaleF', 'mpDynamicAreaGroups', 'mpEllipticalBoundary',
|
| 600 |
+
'mpFillAreaSpecifiers', 'mpFillBoundarySets', 'mpFillColor',
|
| 601 |
+
'mpFillColors', 'mpFillColors-default', 'mpFillDotSizeF',
|
| 602 |
+
'mpFillDrawOrder', 'mpFillOn', 'mpFillPatternBackground',
|
| 603 |
+
'mpFillPattern', 'mpFillPatterns', 'mpFillPatterns-default',
|
| 604 |
+
'mpFillScaleF', 'mpFillScales', 'mpFillScales-default',
|
| 605 |
+
'mpFixedAreaGroups', 'mpGeophysicalLineColor',
|
| 606 |
+
'mpGeophysicalLineDashPattern', 'mpGeophysicalLineDashSegLenF',
|
| 607 |
+
'mpGeophysicalLineThicknessF', 'mpGreatCircleLinesOn',
|
| 608 |
+
'mpGridAndLimbDrawOrder', 'mpGridAndLimbOn', 'mpGridLatSpacingF',
|
| 609 |
+
'mpGridLineColor', 'mpGridLineDashPattern', 'mpGridLineDashSegLenF',
|
| 610 |
+
'mpGridLineThicknessF', 'mpGridLonSpacingF', 'mpGridMaskMode',
|
| 611 |
+
'mpGridMaxLatF', 'mpGridPolarLonSpacingF', 'mpGridSpacingF',
|
| 612 |
+
'mpInlandWaterFillColor', 'mpInlandWaterFillPattern',
|
| 613 |
+
'mpInlandWaterFillScaleF', 'mpLabelDrawOrder', 'mpLabelFontColor',
|
| 614 |
+
'mpLabelFontHeightF', 'mpLabelsOn', 'mpLambertMeridianF',
|
| 615 |
+
'mpLambertParallel1F', 'mpLambertParallel2F', 'mpLandFillColor',
|
| 616 |
+
'mpLandFillPattern', 'mpLandFillScaleF', 'mpLeftAngleF',
|
| 617 |
+
'mpLeftCornerLatF', 'mpLeftCornerLonF', 'mpLeftMapPosF',
|
| 618 |
+
'mpLeftNDCF', 'mpLeftNPCF', 'mpLeftPointLatF',
|
| 619 |
+
'mpLeftPointLonF', 'mpLeftWindowF', 'mpLimbLineColor',
|
| 620 |
+
'mpLimbLineDashPattern', 'mpLimbLineDashSegLenF',
|
| 621 |
+
'mpLimbLineThicknessF', 'mpLimitMode', 'mpMaskAreaSpecifiers',
|
| 622 |
+
'mpMaskOutlineSpecifiers', 'mpMaxLatF', 'mpMaxLonF',
|
| 623 |
+
'mpMinLatF', 'mpMinLonF', 'mpMonoFillColor', 'mpMonoFillPattern',
|
| 624 |
+
'mpMonoFillScale', 'mpNationalLineColor', 'mpNationalLineDashPattern',
|
| 625 |
+
'mpNationalLineThicknessF', 'mpOceanFillColor', 'mpOceanFillPattern',
|
| 626 |
+
'mpOceanFillScaleF', 'mpOutlineBoundarySets', 'mpOutlineDrawOrder',
|
| 627 |
+
'mpOutlineMaskingOn', 'mpOutlineOn', 'mpOutlineSpecifiers',
|
| 628 |
+
'mpPerimDrawOrder', 'mpPerimLineColor', 'mpPerimLineDashPattern',
|
| 629 |
+
'mpPerimLineDashSegLenF', 'mpPerimLineThicknessF', 'mpPerimOn',
|
| 630 |
+
'mpPolyMode', 'mpProjection', 'mpProvincialLineColor',
|
| 631 |
+
'mpProvincialLineDashPattern', 'mpProvincialLineDashSegLenF',
|
| 632 |
+
'mpProvincialLineThicknessF', 'mpRelativeCenterLat',
|
| 633 |
+
'mpRelativeCenterLon', 'mpRightAngleF', 'mpRightCornerLatF',
|
| 634 |
+
'mpRightCornerLonF', 'mpRightMapPosF', 'mpRightNDCF',
|
| 635 |
+
'mpRightNPCF', 'mpRightPointLatF', 'mpRightPointLonF',
|
| 636 |
+
'mpRightWindowF', 'mpSatelliteAngle1F', 'mpSatelliteAngle2F',
|
| 637 |
+
'mpSatelliteDistF', 'mpShapeMode', 'mpSpecifiedFillColors',
|
| 638 |
+
'mpSpecifiedFillDirectIndexing', 'mpSpecifiedFillPatterns',
|
| 639 |
+
'mpSpecifiedFillPriority', 'mpSpecifiedFillScales',
|
| 640 |
+
'mpTopAngleF', 'mpTopMapPosF', 'mpTopNDCF', 'mpTopNPCF',
|
| 641 |
+
'mpTopPointLatF', 'mpTopPointLonF', 'mpTopWindowF',
|
| 642 |
+
'mpUSStateLineColor', 'mpUSStateLineDashPattern',
|
| 643 |
+
'mpUSStateLineDashSegLenF', 'mpUSStateLineThicknessF',
|
| 644 |
+
'pmAnnoManagers', 'pmAnnoViews', 'pmLabelBarDisplayMode',
|
| 645 |
+
'pmLabelBarHeightF', 'pmLabelBarKeepAspect', 'pmLabelBarOrthogonalPosF',
|
| 646 |
+
'pmLabelBarParallelPosF', 'pmLabelBarSide', 'pmLabelBarWidthF',
|
| 647 |
+
'pmLabelBarZone', 'pmLegendDisplayMode', 'pmLegendHeightF',
|
| 648 |
+
'pmLegendKeepAspect', 'pmLegendOrthogonalPosF',
|
| 649 |
+
'pmLegendParallelPosF', 'pmLegendSide', 'pmLegendWidthF',
|
| 650 |
+
'pmLegendZone', 'pmOverlaySequenceIds', 'pmTickMarkDisplayMode',
|
| 651 |
+
'pmTickMarkZone', 'pmTitleDisplayMode', 'pmTitleZone',
|
| 652 |
+
'prGraphicStyle', 'prPolyType', 'prXArray', 'prYArray',
|
| 653 |
+
'sfCopyData', 'sfDataArray', 'sfDataMaxV', 'sfDataMinV',
|
| 654 |
+
'sfElementNodes', 'sfExchangeDimensions', 'sfFirstNodeIndex',
|
| 655 |
+
'sfMissingValueV', 'sfXArray', 'sfXCActualEndF', 'sfXCActualStartF',
|
| 656 |
+
'sfXCEndIndex', 'sfXCEndSubsetV', 'sfXCEndV', 'sfXCStartIndex',
|
| 657 |
+
'sfXCStartSubsetV', 'sfXCStartV', 'sfXCStride', 'sfXCellBounds',
|
| 658 |
+
'sfYArray', 'sfYCActualEndF', 'sfYCActualStartF', 'sfYCEndIndex',
|
| 659 |
+
'sfYCEndSubsetV', 'sfYCEndV', 'sfYCStartIndex', 'sfYCStartSubsetV',
|
| 660 |
+
'sfYCStartV', 'sfYCStride', 'sfYCellBounds', 'stArrowLengthF',
|
| 661 |
+
'stArrowStride', 'stCrossoverCheckCount',
|
| 662 |
+
'stExplicitLabelBarLabelsOn', 'stLabelBarEndLabelsOn',
|
| 663 |
+
'stLabelFormat', 'stLengthCheckCount', 'stLevelColors',
|
| 664 |
+
'stLevelCount', 'stLevelPalette', 'stLevelSelectionMode',
|
| 665 |
+
'stLevelSpacingF', 'stLevels', 'stLineColor', 'stLineOpacityF',
|
| 666 |
+
'stLineStartStride', 'stLineThicknessF', 'stMapDirection',
|
| 667 |
+
'stMaxLevelCount', 'stMaxLevelValF', 'stMinArrowSpacingF',
|
| 668 |
+
'stMinDistanceF', 'stMinLevelValF', 'stMinLineSpacingF',
|
| 669 |
+
'stMinStepFactorF', 'stMonoLineColor', 'stNoDataLabelOn',
|
| 670 |
+
'stNoDataLabelString', 'stScalarFieldData', 'stScalarMissingValColor',
|
| 671 |
+
'stSpanLevelPalette', 'stStepSizeF', 'stStreamlineDrawOrder',
|
| 672 |
+
'stUseScalarArray', 'stVectorFieldData', 'stZeroFLabelAngleF',
|
| 673 |
+
'stZeroFLabelBackgroundColor', 'stZeroFLabelConstantSpacingF',
|
| 674 |
+
'stZeroFLabelFont', 'stZeroFLabelFontAspectF',
|
| 675 |
+
'stZeroFLabelFontColor', 'stZeroFLabelFontHeightF',
|
| 676 |
+
'stZeroFLabelFontQuality', 'stZeroFLabelFontThicknessF',
|
| 677 |
+
'stZeroFLabelFuncCode', 'stZeroFLabelJust', 'stZeroFLabelOn',
|
| 678 |
+
'stZeroFLabelOrthogonalPosF', 'stZeroFLabelParallelPosF',
|
| 679 |
+
'stZeroFLabelPerimColor', 'stZeroFLabelPerimOn',
|
| 680 |
+
'stZeroFLabelPerimSpaceF', 'stZeroFLabelPerimThicknessF',
|
| 681 |
+
'stZeroFLabelSide', 'stZeroFLabelString', 'stZeroFLabelTextDirection',
|
| 682 |
+
'stZeroFLabelZone', 'tfDoNDCOverlay', 'tfPlotManagerOn',
|
| 683 |
+
'tfPolyDrawList', 'tfPolyDrawOrder', 'tiDeltaF', 'tiMainAngleF',
|
| 684 |
+
'tiMainConstantSpacingF', 'tiMainDirection', 'tiMainFont',
|
| 685 |
+
'tiMainFontAspectF', 'tiMainFontColor', 'tiMainFontHeightF',
|
| 686 |
+
'tiMainFontQuality', 'tiMainFontThicknessF', 'tiMainFuncCode',
|
| 687 |
+
'tiMainJust', 'tiMainOffsetXF', 'tiMainOffsetYF', 'tiMainOn',
|
| 688 |
+
'tiMainPosition', 'tiMainSide', 'tiMainString', 'tiUseMainAttributes',
|
| 689 |
+
'tiXAxisAngleF', 'tiXAxisConstantSpacingF', 'tiXAxisDirection',
|
| 690 |
+
'tiXAxisFont', 'tiXAxisFontAspectF', 'tiXAxisFontColor',
|
| 691 |
+
'tiXAxisFontHeightF', 'tiXAxisFontQuality', 'tiXAxisFontThicknessF',
|
| 692 |
+
'tiXAxisFuncCode', 'tiXAxisJust', 'tiXAxisOffsetXF',
|
| 693 |
+
'tiXAxisOffsetYF', 'tiXAxisOn', 'tiXAxisPosition', 'tiXAxisSide',
|
| 694 |
+
'tiXAxisString', 'tiYAxisAngleF', 'tiYAxisConstantSpacingF',
|
| 695 |
+
'tiYAxisDirection', 'tiYAxisFont', 'tiYAxisFontAspectF',
|
| 696 |
+
'tiYAxisFontColor', 'tiYAxisFontHeightF', 'tiYAxisFontQuality',
|
| 697 |
+
'tiYAxisFontThicknessF', 'tiYAxisFuncCode', 'tiYAxisJust',
|
| 698 |
+
'tiYAxisOffsetXF', 'tiYAxisOffsetYF', 'tiYAxisOn', 'tiYAxisPosition',
|
| 699 |
+
'tiYAxisSide', 'tiYAxisString', 'tmBorderLineColor',
|
| 700 |
+
'tmBorderThicknessF', 'tmEqualizeXYSizes', 'tmLabelAutoStride',
|
| 701 |
+
'tmSciNoteCutoff', 'tmXBAutoPrecision', 'tmXBBorderOn',
|
| 702 |
+
'tmXBDataLeftF', 'tmXBDataRightF', 'tmXBFormat', 'tmXBIrrTensionF',
|
| 703 |
+
'tmXBIrregularPoints', 'tmXBLabelAngleF', 'tmXBLabelConstantSpacingF',
|
| 704 |
+
'tmXBLabelDeltaF', 'tmXBLabelDirection', 'tmXBLabelFont',
|
| 705 |
+
'tmXBLabelFontAspectF', 'tmXBLabelFontColor', 'tmXBLabelFontHeightF',
|
| 706 |
+
'tmXBLabelFontQuality', 'tmXBLabelFontThicknessF',
|
| 707 |
+
'tmXBLabelFuncCode', 'tmXBLabelJust', 'tmXBLabelStride', 'tmXBLabels',
|
| 708 |
+
'tmXBLabelsOn', 'tmXBMajorLengthF', 'tmXBMajorLineColor',
|
| 709 |
+
'tmXBMajorOutwardLengthF', 'tmXBMajorThicknessF', 'tmXBMaxLabelLenF',
|
| 710 |
+
'tmXBMaxTicks', 'tmXBMinLabelSpacingF', 'tmXBMinorLengthF',
|
| 711 |
+
'tmXBMinorLineColor', 'tmXBMinorOn', 'tmXBMinorOutwardLengthF',
|
| 712 |
+
'tmXBMinorPerMajor', 'tmXBMinorThicknessF', 'tmXBMinorValues',
|
| 713 |
+
'tmXBMode', 'tmXBOn', 'tmXBPrecision', 'tmXBStyle', 'tmXBTickEndF',
|
| 714 |
+
'tmXBTickSpacingF', 'tmXBTickStartF', 'tmXBValues', 'tmXMajorGrid',
|
| 715 |
+
'tmXMajorGridLineColor', 'tmXMajorGridLineDashPattern',
|
| 716 |
+
'tmXMajorGridThicknessF', 'tmXMinorGrid', 'tmXMinorGridLineColor',
|
| 717 |
+
'tmXMinorGridLineDashPattern', 'tmXMinorGridThicknessF',
|
| 718 |
+
'tmXTAutoPrecision', 'tmXTBorderOn', 'tmXTDataLeftF',
|
| 719 |
+
'tmXTDataRightF', 'tmXTFormat', 'tmXTIrrTensionF',
|
| 720 |
+
'tmXTIrregularPoints', 'tmXTLabelAngleF', 'tmXTLabelConstantSpacingF',
|
| 721 |
+
'tmXTLabelDeltaF', 'tmXTLabelDirection', 'tmXTLabelFont',
|
| 722 |
+
'tmXTLabelFontAspectF', 'tmXTLabelFontColor', 'tmXTLabelFontHeightF',
|
| 723 |
+
'tmXTLabelFontQuality', 'tmXTLabelFontThicknessF',
|
| 724 |
+
'tmXTLabelFuncCode', 'tmXTLabelJust', 'tmXTLabelStride', 'tmXTLabels',
|
| 725 |
+
'tmXTLabelsOn', 'tmXTMajorLengthF', 'tmXTMajorLineColor',
|
| 726 |
+
'tmXTMajorOutwardLengthF', 'tmXTMajorThicknessF', 'tmXTMaxLabelLenF',
|
| 727 |
+
'tmXTMaxTicks', 'tmXTMinLabelSpacingF', 'tmXTMinorLengthF',
|
| 728 |
+
'tmXTMinorLineColor', 'tmXTMinorOn', 'tmXTMinorOutwardLengthF',
|
| 729 |
+
'tmXTMinorPerMajor', 'tmXTMinorThicknessF', 'tmXTMinorValues',
|
| 730 |
+
'tmXTMode', 'tmXTOn', 'tmXTPrecision', 'tmXTStyle', 'tmXTTickEndF',
|
| 731 |
+
'tmXTTickSpacingF', 'tmXTTickStartF', 'tmXTValues', 'tmXUseBottom',
|
| 732 |
+
'tmYLAutoPrecision', 'tmYLBorderOn', 'tmYLDataBottomF',
|
| 733 |
+
'tmYLDataTopF', 'tmYLFormat', 'tmYLIrrTensionF',
|
| 734 |
+
'tmYLIrregularPoints', 'tmYLLabelAngleF', 'tmYLLabelConstantSpacingF',
|
| 735 |
+
'tmYLLabelDeltaF', 'tmYLLabelDirection', 'tmYLLabelFont',
|
| 736 |
+
'tmYLLabelFontAspectF', 'tmYLLabelFontColor', 'tmYLLabelFontHeightF',
|
| 737 |
+
'tmYLLabelFontQuality', 'tmYLLabelFontThicknessF',
|
| 738 |
+
'tmYLLabelFuncCode', 'tmYLLabelJust', 'tmYLLabelStride', 'tmYLLabels',
|
| 739 |
+
'tmYLLabelsOn', 'tmYLMajorLengthF', 'tmYLMajorLineColor',
|
| 740 |
+
'tmYLMajorOutwardLengthF', 'tmYLMajorThicknessF', 'tmYLMaxLabelLenF',
|
| 741 |
+
'tmYLMaxTicks', 'tmYLMinLabelSpacingF', 'tmYLMinorLengthF',
|
| 742 |
+
'tmYLMinorLineColor', 'tmYLMinorOn', 'tmYLMinorOutwardLengthF',
|
| 743 |
+
'tmYLMinorPerMajor', 'tmYLMinorThicknessF', 'tmYLMinorValues',
|
| 744 |
+
'tmYLMode', 'tmYLOn', 'tmYLPrecision', 'tmYLStyle', 'tmYLTickEndF',
|
| 745 |
+
'tmYLTickSpacingF', 'tmYLTickStartF', 'tmYLValues', 'tmYMajorGrid',
|
| 746 |
+
'tmYMajorGridLineColor', 'tmYMajorGridLineDashPattern',
|
| 747 |
+
'tmYMajorGridThicknessF', 'tmYMinorGrid', 'tmYMinorGridLineColor',
|
| 748 |
+
'tmYMinorGridLineDashPattern', 'tmYMinorGridThicknessF',
|
| 749 |
+
'tmYRAutoPrecision', 'tmYRBorderOn', 'tmYRDataBottomF',
|
| 750 |
+
'tmYRDataTopF', 'tmYRFormat', 'tmYRIrrTensionF',
|
| 751 |
+
'tmYRIrregularPoints', 'tmYRLabelAngleF', 'tmYRLabelConstantSpacingF',
|
| 752 |
+
'tmYRLabelDeltaF', 'tmYRLabelDirection', 'tmYRLabelFont',
|
| 753 |
+
'tmYRLabelFontAspectF', 'tmYRLabelFontColor', 'tmYRLabelFontHeightF',
|
| 754 |
+
'tmYRLabelFontQuality', 'tmYRLabelFontThicknessF',
|
| 755 |
+
'tmYRLabelFuncCode', 'tmYRLabelJust', 'tmYRLabelStride', 'tmYRLabels',
|
| 756 |
+
'tmYRLabelsOn', 'tmYRMajorLengthF', 'tmYRMajorLineColor',
|
| 757 |
+
'tmYRMajorOutwardLengthF', 'tmYRMajorThicknessF', 'tmYRMaxLabelLenF',
|
| 758 |
+
'tmYRMaxTicks', 'tmYRMinLabelSpacingF', 'tmYRMinorLengthF',
|
| 759 |
+
'tmYRMinorLineColor', 'tmYRMinorOn', 'tmYRMinorOutwardLengthF',
|
| 760 |
+
'tmYRMinorPerMajor', 'tmYRMinorThicknessF', 'tmYRMinorValues',
|
| 761 |
+
'tmYRMode', 'tmYROn', 'tmYRPrecision', 'tmYRStyle', 'tmYRTickEndF',
|
| 762 |
+
'tmYRTickSpacingF', 'tmYRTickStartF', 'tmYRValues', 'tmYUseLeft',
|
| 763 |
+
'trGridType', 'trLineInterpolationOn',
|
| 764 |
+
'trXAxisType', 'trXCoordPoints', 'trXInterPoints', 'trXLog',
|
| 765 |
+
'trXMaxF', 'trXMinF', 'trXReverse', 'trXSamples', 'trXTensionF',
|
| 766 |
+
'trYAxisType', 'trYCoordPoints', 'trYInterPoints', 'trYLog',
|
| 767 |
+
'trYMaxF', 'trYMinF', 'trYReverse', 'trYSamples', 'trYTensionF',
|
| 768 |
+
'txAngleF', 'txBackgroundFillColor', 'txConstantSpacingF', 'txDirection',
|
| 769 |
+
'txFont', 'HLU-Fonts', 'txFontAspectF', 'txFontColor',
|
| 770 |
+
'txFontHeightF', 'txFontOpacityF', 'txFontQuality',
|
| 771 |
+
'txFontThicknessF', 'txFuncCode', 'txJust', 'txPerimColor',
|
| 772 |
+
'txPerimDashLengthF', 'txPerimDashPattern', 'txPerimOn',
|
| 773 |
+
'txPerimSpaceF', 'txPerimThicknessF', 'txPosXF', 'txPosYF',
|
| 774 |
+
'txString', 'vcExplicitLabelBarLabelsOn', 'vcFillArrowEdgeColor',
|
| 775 |
+
'vcFillArrowEdgeThicknessF', 'vcFillArrowFillColor',
|
| 776 |
+
'vcFillArrowHeadInteriorXF', 'vcFillArrowHeadMinFracXF',
|
| 777 |
+
'vcFillArrowHeadMinFracYF', 'vcFillArrowHeadXF', 'vcFillArrowHeadYF',
|
| 778 |
+
'vcFillArrowMinFracWidthF', 'vcFillArrowWidthF', 'vcFillArrowsOn',
|
| 779 |
+
'vcFillOverEdge', 'vcGlyphOpacityF', 'vcGlyphStyle',
|
| 780 |
+
'vcLabelBarEndLabelsOn', 'vcLabelFontColor', 'vcLabelFontHeightF',
|
| 781 |
+
'vcLabelsOn', 'vcLabelsUseVectorColor', 'vcLevelColors',
|
| 782 |
+
'vcLevelCount', 'vcLevelPalette', 'vcLevelSelectionMode',
|
| 783 |
+
'vcLevelSpacingF', 'vcLevels', 'vcLineArrowColor',
|
| 784 |
+
'vcLineArrowHeadMaxSizeF', 'vcLineArrowHeadMinSizeF',
|
| 785 |
+
'vcLineArrowThicknessF', 'vcMagnitudeFormat',
|
| 786 |
+
'vcMagnitudeScaleFactorF', 'vcMagnitudeScaleValueF',
|
| 787 |
+
'vcMagnitudeScalingMode', 'vcMapDirection', 'vcMaxLevelCount',
|
| 788 |
+
'vcMaxLevelValF', 'vcMaxMagnitudeF', 'vcMinAnnoAngleF',
|
| 789 |
+
'vcMinAnnoArrowAngleF', 'vcMinAnnoArrowEdgeColor',
|
| 790 |
+
'vcMinAnnoArrowFillColor', 'vcMinAnnoArrowLineColor',
|
| 791 |
+
'vcMinAnnoArrowMinOffsetF', 'vcMinAnnoArrowSpaceF',
|
| 792 |
+
'vcMinAnnoArrowUseVecColor', 'vcMinAnnoBackgroundColor',
|
| 793 |
+
'vcMinAnnoConstantSpacingF', 'vcMinAnnoExplicitMagnitudeF',
|
| 794 |
+
'vcMinAnnoFont', 'vcMinAnnoFontAspectF', 'vcMinAnnoFontColor',
|
| 795 |
+
'vcMinAnnoFontHeightF', 'vcMinAnnoFontQuality',
|
| 796 |
+
'vcMinAnnoFontThicknessF', 'vcMinAnnoFuncCode', 'vcMinAnnoJust',
|
| 797 |
+
'vcMinAnnoOn', 'vcMinAnnoOrientation', 'vcMinAnnoOrthogonalPosF',
|
| 798 |
+
'vcMinAnnoParallelPosF', 'vcMinAnnoPerimColor', 'vcMinAnnoPerimOn',
|
| 799 |
+
'vcMinAnnoPerimSpaceF', 'vcMinAnnoPerimThicknessF', 'vcMinAnnoSide',
|
| 800 |
+
'vcMinAnnoString1', 'vcMinAnnoString1On', 'vcMinAnnoString2',
|
| 801 |
+
'vcMinAnnoString2On', 'vcMinAnnoTextDirection', 'vcMinAnnoZone',
|
| 802 |
+
'vcMinDistanceF', 'vcMinFracLengthF', 'vcMinLevelValF',
|
| 803 |
+
'vcMinMagnitudeF', 'vcMonoFillArrowEdgeColor',
|
| 804 |
+
'vcMonoFillArrowFillColor', 'vcMonoLineArrowColor',
|
| 805 |
+
'vcMonoWindBarbColor', 'vcNoDataLabelOn', 'vcNoDataLabelString',
|
| 806 |
+
'vcPositionMode', 'vcRefAnnoAngleF', 'vcRefAnnoArrowAngleF',
|
| 807 |
+
'vcRefAnnoArrowEdgeColor', 'vcRefAnnoArrowFillColor',
|
| 808 |
+
'vcRefAnnoArrowLineColor', 'vcRefAnnoArrowMinOffsetF',
|
| 809 |
+
'vcRefAnnoArrowSpaceF', 'vcRefAnnoArrowUseVecColor',
|
| 810 |
+
'vcRefAnnoBackgroundColor', 'vcRefAnnoConstantSpacingF',
|
| 811 |
+
'vcRefAnnoExplicitMagnitudeF', 'vcRefAnnoFont',
|
| 812 |
+
'vcRefAnnoFontAspectF', 'vcRefAnnoFontColor', 'vcRefAnnoFontHeightF',
|
| 813 |
+
'vcRefAnnoFontQuality', 'vcRefAnnoFontThicknessF',
|
| 814 |
+
'vcRefAnnoFuncCode', 'vcRefAnnoJust', 'vcRefAnnoOn',
|
| 815 |
+
'vcRefAnnoOrientation', 'vcRefAnnoOrthogonalPosF',
|
| 816 |
+
'vcRefAnnoParallelPosF', 'vcRefAnnoPerimColor', 'vcRefAnnoPerimOn',
|
| 817 |
+
'vcRefAnnoPerimSpaceF', 'vcRefAnnoPerimThicknessF', 'vcRefAnnoSide',
|
| 818 |
+
'vcRefAnnoString1', 'vcRefAnnoString1On', 'vcRefAnnoString2',
|
| 819 |
+
'vcRefAnnoString2On', 'vcRefAnnoTextDirection', 'vcRefAnnoZone',
|
| 820 |
+
'vcRefLengthF', 'vcRefMagnitudeF', 'vcScalarFieldData',
|
| 821 |
+
'vcScalarMissingValColor', 'vcScalarValueFormat',
|
| 822 |
+
'vcScalarValueScaleFactorF', 'vcScalarValueScaleValueF',
|
| 823 |
+
'vcScalarValueScalingMode', 'vcSpanLevelPalette', 'vcUseRefAnnoRes',
|
| 824 |
+
'vcUseScalarArray', 'vcVectorDrawOrder', 'vcVectorFieldData',
|
| 825 |
+
'vcWindBarbCalmCircleSizeF', 'vcWindBarbColor',
|
| 826 |
+
'vcWindBarbLineThicknessF', 'vcWindBarbScaleFactorF',
|
| 827 |
+
'vcWindBarbTickAngleF', 'vcWindBarbTickLengthF',
|
| 828 |
+
'vcWindBarbTickSpacingF', 'vcZeroFLabelAngleF',
|
| 829 |
+
'vcZeroFLabelBackgroundColor', 'vcZeroFLabelConstantSpacingF',
|
| 830 |
+
'vcZeroFLabelFont', 'vcZeroFLabelFontAspectF',
|
| 831 |
+
'vcZeroFLabelFontColor', 'vcZeroFLabelFontHeightF',
|
| 832 |
+
'vcZeroFLabelFontQuality', 'vcZeroFLabelFontThicknessF',
|
| 833 |
+
'vcZeroFLabelFuncCode', 'vcZeroFLabelJust', 'vcZeroFLabelOn',
|
| 834 |
+
'vcZeroFLabelOrthogonalPosF', 'vcZeroFLabelParallelPosF',
|
| 835 |
+
'vcZeroFLabelPerimColor', 'vcZeroFLabelPerimOn',
|
| 836 |
+
'vcZeroFLabelPerimSpaceF', 'vcZeroFLabelPerimThicknessF',
|
| 837 |
+
'vcZeroFLabelSide', 'vcZeroFLabelString', 'vcZeroFLabelTextDirection',
|
| 838 |
+
'vcZeroFLabelZone', 'vfCopyData', 'vfDataArray',
|
| 839 |
+
'vfExchangeDimensions', 'vfExchangeUVData', 'vfMagMaxV', 'vfMagMinV',
|
| 840 |
+
'vfMissingUValueV', 'vfMissingVValueV', 'vfPolarData',
|
| 841 |
+
'vfSingleMissingValue', 'vfUDataArray', 'vfUMaxV', 'vfUMinV',
|
| 842 |
+
'vfVDataArray', 'vfVMaxV', 'vfVMinV', 'vfXArray', 'vfXCActualEndF',
|
| 843 |
+
'vfXCActualStartF', 'vfXCEndIndex', 'vfXCEndSubsetV', 'vfXCEndV',
|
| 844 |
+
'vfXCStartIndex', 'vfXCStartSubsetV', 'vfXCStartV', 'vfXCStride',
|
| 845 |
+
'vfYArray', 'vfYCActualEndF', 'vfYCActualStartF', 'vfYCEndIndex',
|
| 846 |
+
'vfYCEndSubsetV', 'vfYCEndV', 'vfYCStartIndex', 'vfYCStartSubsetV',
|
| 847 |
+
'vfYCStartV', 'vfYCStride', 'vpAnnoManagerId', 'vpClipOn',
|
| 848 |
+
'vpHeightF', 'vpKeepAspect', 'vpOn', 'vpUseSegments', 'vpWidthF',
|
| 849 |
+
'vpXF', 'vpYF', 'wkAntiAlias', 'wkBackgroundColor', 'wkBackgroundOpacityF',
|
| 850 |
+
'wkColorMapLen', 'wkColorMap', 'wkColorModel', 'wkDashTableLength',
|
| 851 |
+
'wkDefGraphicStyleId', 'wkDeviceLowerX', 'wkDeviceLowerY',
|
| 852 |
+
'wkDeviceUpperX', 'wkDeviceUpperY', 'wkFileName', 'wkFillTableLength',
|
| 853 |
+
'wkForegroundColor', 'wkFormat', 'wkFullBackground', 'wkGksWorkId',
|
| 854 |
+
'wkHeight', 'wkMarkerTableLength', 'wkMetaName', 'wkOrientation',
|
| 855 |
+
'wkPDFFileName', 'wkPDFFormat', 'wkPDFResolution', 'wkPSFileName',
|
| 856 |
+
'wkPSFormat', 'wkPSResolution', 'wkPaperHeightF', 'wkPaperSize',
|
| 857 |
+
'wkPaperWidthF', 'wkPause', 'wkTopLevelViews', 'wkViews',
|
| 858 |
+
'wkVisualType', 'wkWidth', 'wkWindowId', 'wkXColorMode', 'wsCurrentSize',
|
| 859 |
+
'wsMaximumSize', 'wsThresholdSize', 'xyComputeXMax',
|
| 860 |
+
'xyComputeXMin', 'xyComputeYMax', 'xyComputeYMin', 'xyCoordData',
|
| 861 |
+
'xyCoordDataSpec', 'xyCurveDrawOrder', 'xyDashPattern',
|
| 862 |
+
'xyDashPatterns', 'xyExplicitLabels', 'xyExplicitLegendLabels',
|
| 863 |
+
'xyLabelMode', 'xyLineColor', 'xyLineColors', 'xyLineDashSegLenF',
|
| 864 |
+
'xyLineLabelConstantSpacingF', 'xyLineLabelFont',
|
| 865 |
+
'xyLineLabelFontAspectF', 'xyLineLabelFontColor',
|
| 866 |
+
'xyLineLabelFontColors', 'xyLineLabelFontHeightF',
|
| 867 |
+
'xyLineLabelFontQuality', 'xyLineLabelFontThicknessF',
|
| 868 |
+
'xyLineLabelFuncCode', 'xyLineThicknessF', 'xyLineThicknesses',
|
| 869 |
+
'xyMarkLineMode', 'xyMarkLineModes', 'xyMarker', 'xyMarkerColor',
|
| 870 |
+
'xyMarkerColors', 'xyMarkerSizeF', 'xyMarkerSizes',
|
| 871 |
+
'xyMarkerThicknessF', 'xyMarkerThicknesses', 'xyMarkers',
|
| 872 |
+
'xyMonoDashPattern', 'xyMonoLineColor', 'xyMonoLineLabelFontColor',
|
| 873 |
+
'xyMonoLineThickness', 'xyMonoMarkLineMode', 'xyMonoMarker',
|
| 874 |
+
'xyMonoMarkerColor', 'xyMonoMarkerSize', 'xyMonoMarkerThickness',
|
| 875 |
+
'xyXIrrTensionF', 'xyXIrregularPoints', 'xyXStyle', 'xyYIrrTensionF',
|
| 876 |
+
'xyYIrregularPoints', 'xyYStyle'), prefix=r'\b'),
|
| 877 |
+
Name.Builtin),
|
| 878 |
+
|
| 879 |
+
# Booleans
|
| 880 |
+
(r'\.(True|False)\.', Name.Builtin),
|
| 881 |
+
# Comparing Operators
|
| 882 |
+
(r'\.(eq|ne|lt|le|gt|ge|not|and|or|xor)\.', Operator.Word),
|
| 883 |
+
],
|
| 884 |
+
|
| 885 |
+
'strings': [
|
| 886 |
+
(r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
|
| 887 |
+
],
|
| 888 |
+
|
| 889 |
+
'nums': [
|
| 890 |
+
(r'\d+(?![.e])(_[a-z]\w+)?', Number.Integer),
|
| 891 |
+
(r'[+-]?\d*\.\d+(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float),
|
| 892 |
+
(r'[+-]?\d+\.\d*(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float),
|
| 893 |
+
],
|
| 894 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/nit.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.nit
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Nit language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['NitLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class NitLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For nit source.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Nit'
|
| 24 |
+
url = 'http://nitlanguage.org'
|
| 25 |
+
aliases = ['nit']
|
| 26 |
+
filenames = ['*.nit']
|
| 27 |
+
version_added = '2.0'
|
| 28 |
+
tokens = {
|
| 29 |
+
'root': [
|
| 30 |
+
(r'#.*?$', Comment.Single),
|
| 31 |
+
(words((
|
| 32 |
+
'package', 'module', 'import', 'class', 'abstract', 'interface',
|
| 33 |
+
'universal', 'enum', 'end', 'fun', 'type', 'init', 'redef',
|
| 34 |
+
'isa', 'do', 'readable', 'writable', 'var', 'intern', 'extern',
|
| 35 |
+
'public', 'protected', 'private', 'intrude', 'if', 'then',
|
| 36 |
+
'else', 'while', 'loop', 'for', 'in', 'and', 'or', 'not',
|
| 37 |
+
'implies', 'return', 'continue', 'break', 'abort', 'assert',
|
| 38 |
+
'new', 'is', 'once', 'super', 'self', 'true', 'false', 'nullable',
|
| 39 |
+
'null', 'as', 'isset', 'label', '__debug__'), suffix=r'(?=[\r\n\t( ])'),
|
| 40 |
+
Keyword),
|
| 41 |
+
(r'[A-Z]\w*', Name.Class),
|
| 42 |
+
(r'"""(([^\'\\]|\\.)|\\r|\\n)*((\{\{?)?(""?\{\{?)*""""*)', String), # Simple long string
|
| 43 |
+
(r'\'\'\'(((\\.|[^\'\\])|\\r|\\n)|\'((\\.|[^\'\\])|\\r|\\n)|'
|
| 44 |
+
r'\'\'((\\.|[^\'\\])|\\r|\\n))*\'\'\'', String), # Simple long string alt
|
| 45 |
+
(r'"""(([^\'\\]|\\.)|\\r|\\n)*((""?)?(\{\{?""?)*\{\{\{\{*)', String), # Start long string
|
| 46 |
+
(r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(""?)?(\{\{?""?)*\{\{\{\{*', String), # Mid long string
|
| 47 |
+
(r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(\{\{?)?(""?\{\{?)*""""*', String), # End long string
|
| 48 |
+
(r'"(\\.|([^"}{\\]))*"', String), # Simple String
|
| 49 |
+
(r'"(\\.|([^"}{\\]))*\{', String), # Start string
|
| 50 |
+
(r'\}(\\.|([^"}{\\]))*\{', String), # Mid String
|
| 51 |
+
(r'\}(\\.|([^"}{\\]))*"', String), # End String
|
| 52 |
+
(r'(\'[^\'\\]\')|(\'\\.\')', String.Char),
|
| 53 |
+
(r'[0-9]+', Number.Integer),
|
| 54 |
+
(r'[0-9]*.[0-9]+', Number.Float),
|
| 55 |
+
(r'0(x|X)[0-9A-Fa-f]+', Number.Hex),
|
| 56 |
+
(r'[a-z]\w*', Name),
|
| 57 |
+
(r'_\w+', Name.Variable.Instance),
|
| 58 |
+
(r'==|!=|<==>|>=|>>|>|<=|<<|<|\+|-|=|/|\*|%|\+=|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.nix
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the NixOS Nix language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Literal
|
| 16 |
+
|
| 17 |
+
__all__ = ['NixLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class NixLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For the Nix language.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'Nix'
|
| 26 |
+
url = 'http://nixos.org/nix/'
|
| 27 |
+
aliases = ['nixos', 'nix']
|
| 28 |
+
filenames = ['*.nix']
|
| 29 |
+
mimetypes = ['text/x-nix']
|
| 30 |
+
version_added = '2.0'
|
| 31 |
+
|
| 32 |
+
keywords = ['rec', 'with', 'let', 'in', 'inherit', 'assert', 'if',
|
| 33 |
+
'else', 'then', '...']
|
| 34 |
+
builtins = ['import', 'abort', 'baseNameOf', 'dirOf', 'isNull', 'builtins',
|
| 35 |
+
'map', 'removeAttrs', 'throw', 'toString', 'derivation']
|
| 36 |
+
operators = ['++', '+', '?', '.', '!', '//', '==', '/',
|
| 37 |
+
'!=', '&&', '||', '->', '=', '<', '>', '*', '-']
|
| 38 |
+
|
| 39 |
+
punctuations = ["(", ")", "[", "]", ";", "{", "}", ":", ",", "@"]
|
| 40 |
+
|
| 41 |
+
tokens = {
|
| 42 |
+
'root': [
|
| 43 |
+
# comments starting with #
|
| 44 |
+
(r'#.*$', Comment.Single),
|
| 45 |
+
|
| 46 |
+
# multiline comments
|
| 47 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 48 |
+
|
| 49 |
+
# whitespace
|
| 50 |
+
(r'\s+', Text),
|
| 51 |
+
|
| 52 |
+
# keywords
|
| 53 |
+
('({})'.format('|'.join(re.escape(entry) + '\\b' for entry in keywords)), Keyword),
|
| 54 |
+
|
| 55 |
+
# highlight the builtins
|
| 56 |
+
('({})'.format('|'.join(re.escape(entry) + '\\b' for entry in builtins)),
|
| 57 |
+
Name.Builtin),
|
| 58 |
+
|
| 59 |
+
(r'\b(true|false|null)\b', Name.Constant),
|
| 60 |
+
|
| 61 |
+
# floats
|
| 62 |
+
(r'-?(\d+\.\d*|\.\d+)([eE][-+]?\d+)?', Number.Float),
|
| 63 |
+
|
| 64 |
+
# integers
|
| 65 |
+
(r'-?[0-9]+', Number.Integer),
|
| 66 |
+
|
| 67 |
+
# paths
|
| 68 |
+
(r'[\w.+-]*(\/[\w.+-]+)+', Literal),
|
| 69 |
+
(r'~(\/[\w.+-]+)+', Literal),
|
| 70 |
+
(r'\<[\w.+-]+(\/[\w.+-]+)*\>', Literal),
|
| 71 |
+
|
| 72 |
+
# operators
|
| 73 |
+
('({})'.format('|'.join(re.escape(entry) for entry in operators)),
|
| 74 |
+
Operator),
|
| 75 |
+
|
| 76 |
+
# word operators
|
| 77 |
+
(r'\b(or|and)\b', Operator.Word),
|
| 78 |
+
|
| 79 |
+
(r'\{', Punctuation, 'block'),
|
| 80 |
+
|
| 81 |
+
# punctuations
|
| 82 |
+
('({})'.format('|'.join(re.escape(entry) for entry in punctuations)), Punctuation),
|
| 83 |
+
|
| 84 |
+
# strings
|
| 85 |
+
(r'"', String.Double, 'doublequote'),
|
| 86 |
+
(r"''", String.Multiline, 'multiline'),
|
| 87 |
+
|
| 88 |
+
# urls
|
| 89 |
+
(r'[a-zA-Z][a-zA-Z0-9\+\-\.]*\:[\w%/?:@&=+$,\\.!~*\'-]+', Literal),
|
| 90 |
+
|
| 91 |
+
# names of variables
|
| 92 |
+
(r'[\w-]+(?=\s*=)', String.Symbol),
|
| 93 |
+
(r'[a-zA-Z_][\w\'-]*', Text),
|
| 94 |
+
|
| 95 |
+
(r"\$\{", String.Interpol, 'antiquote'),
|
| 96 |
+
],
|
| 97 |
+
'comment': [
|
| 98 |
+
(r'[^/*]+', Comment.Multiline),
|
| 99 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 100 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 101 |
+
(r'[*/]', Comment.Multiline),
|
| 102 |
+
],
|
| 103 |
+
'multiline': [
|
| 104 |
+
(r"''(\$|'|\\n|\\r|\\t|\\)", String.Escape),
|
| 105 |
+
(r"''", String.Multiline, '#pop'),
|
| 106 |
+
(r'\$\{', String.Interpol, 'antiquote'),
|
| 107 |
+
(r"[^'\$]+", String.Multiline),
|
| 108 |
+
(r"\$[^\{']", String.Multiline),
|
| 109 |
+
(r"'[^']", String.Multiline),
|
| 110 |
+
(r"\$(?=')", String.Multiline),
|
| 111 |
+
],
|
| 112 |
+
'doublequote': [
|
| 113 |
+
(r'\\(\\|"|\$|n)', String.Escape),
|
| 114 |
+
(r'"', String.Double, '#pop'),
|
| 115 |
+
(r'\$\{', String.Interpol, 'antiquote'),
|
| 116 |
+
(r'[^"\\\$]+', String.Double),
|
| 117 |
+
(r'\$[^\{"]', String.Double),
|
| 118 |
+
(r'\$(?=")', String.Double),
|
| 119 |
+
(r'\\', String.Double),
|
| 120 |
+
],
|
| 121 |
+
'antiquote': [
|
| 122 |
+
(r"\}", String.Interpol, '#pop'),
|
| 123 |
+
# TODO: we should probably escape also here ''${ \${
|
| 124 |
+
(r"\$\{", String.Interpol, '#push'),
|
| 125 |
+
include('root'),
|
| 126 |
+
],
|
| 127 |
+
'block': [
|
| 128 |
+
(r"\}", Punctuation, '#pop'),
|
| 129 |
+
include('root'),
|
| 130 |
+
],
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
def analyse_text(text):
|
| 134 |
+
rv = 0.0
|
| 135 |
+
# TODO: let/in
|
| 136 |
+
if re.search(r'import.+?<[^>]+>', text):
|
| 137 |
+
rv += 0.4
|
| 138 |
+
if re.search(r'mkDerivation\s+(\(|\{|rec)', text):
|
| 139 |
+
rv += 0.4
|
| 140 |
+
if re.search(r'=\s+mkIf\s+', text):
|
| 141 |
+
rv += 0.4
|
| 142 |
+
if re.search(r'\{[a-zA-Z,\s]+\}:', text):
|
| 143 |
+
rv += 0.1
|
| 144 |
+
return rv
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/numbair.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.numbair
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for other Numba Intermediate Representation.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, include, bygroups, words
|
| 12 |
+
from pygments.token import Whitespace, Name, String, Punctuation, Keyword, \
|
| 13 |
+
Operator, Number
|
| 14 |
+
|
| 15 |
+
__all__ = ["NumbaIRLexer"]
|
| 16 |
+
|
| 17 |
+
class NumbaIRLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
Lexer for Numba IR
|
| 20 |
+
"""
|
| 21 |
+
name = 'Numba_IR'
|
| 22 |
+
url = "https://numba.readthedocs.io/en/stable/developer/architecture.html#stage-2-generate-the-numba-ir"
|
| 23 |
+
aliases = ['numba_ir', 'numbair']
|
| 24 |
+
filenames = ['*.numba_ir']
|
| 25 |
+
mimetypes = ['text/x-numba_ir', 'text/x-numbair']
|
| 26 |
+
version_added = '2.19'
|
| 27 |
+
|
| 28 |
+
identifier = r'\$[a-zA-Z0-9._]+'
|
| 29 |
+
fun_or_var = r'([a-zA-Z_]+[a-zA-Z0-9]*)'
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'root' : [
|
| 33 |
+
(r'(label)(\ [0-9]+)(:)$',
|
| 34 |
+
bygroups(Keyword, Name.Label, Punctuation)),
|
| 35 |
+
|
| 36 |
+
(r'=', Operator),
|
| 37 |
+
include('whitespace'),
|
| 38 |
+
include('keyword'),
|
| 39 |
+
|
| 40 |
+
(identifier, Name.Variable),
|
| 41 |
+
(fun_or_var + r'(\()',
|
| 42 |
+
bygroups(Name.Function, Punctuation)),
|
| 43 |
+
(fun_or_var + r'(\=)',
|
| 44 |
+
bygroups(Name.Attribute, Punctuation)),
|
| 45 |
+
(fun_or_var, Name.Constant),
|
| 46 |
+
(r'[0-9]+', Number),
|
| 47 |
+
|
| 48 |
+
# <built-in function some>
|
| 49 |
+
(r'<[^>\n]*>', String),
|
| 50 |
+
|
| 51 |
+
(r'[=<>{}\[\]()*.,!\':]|x\b', Punctuation)
|
| 52 |
+
],
|
| 53 |
+
|
| 54 |
+
'keyword':[
|
| 55 |
+
(words((
|
| 56 |
+
'del', 'jump', 'call', 'branch',
|
| 57 |
+
), suffix=' '), Ke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Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, words
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation
|
| 16 |
+
|
| 17 |
+
__all__ = ['ComponentPascalLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class ComponentPascalLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For Component Pascal source code.
|
| 23 |
+
"""
|
| 24 |
+
name = 'Component Pascal'
|
| 25 |
+
aliases = ['componentpascal', 'cp']
|
| 26 |
+
filenames = ['*.cp', '*.cps']
|
| 27 |
+
mimetypes = ['text/x-component-pascal']
|
| 28 |
+
url = 'https://blackboxframework.org'
|
| 29 |
+
version_added = '2.1'
|
| 30 |
+
|
| 31 |
+
flags = re.MULTILINE | re.DOTALL
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
'root': [
|
| 35 |
+
include('whitespace'),
|
| 36 |
+
include('comments'),
|
| 37 |
+
include('punctuation'),
|
| 38 |
+
include('numliterals'),
|
| 39 |
+
include('strings'),
|
| 40 |
+
include('operators'),
|
| 41 |
+
include('builtins'),
|
| 42 |
+
include('identifiers'),
|
| 43 |
+
],
|
| 44 |
+
'whitespace': [
|
| 45 |
+
(r'\n+', Text), # blank lines
|
| 46 |
+
(r'\s+', Text), # whitespace
|
| 47 |
+
],
|
| 48 |
+
'comments': [
|
| 49 |
+
(r'\(\*([^$].*?)\*\)', Comment.Multiline),
|
| 50 |
+
# TODO: nested comments (* (* ... *) ... (* ... *) *) not supported!
|
| 51 |
+
],
|
| 52 |
+
'punctuation': [
|
| 53 |
+
(r'[()\[\]{},.:;|]', Punctuation),
|
| 54 |
+
],
|
| 55 |
+
'numliterals': [
|
| 56 |
+
(r'[0-9A-F]+X\b', Number.Hex), # char code
|
| 57 |
+
(r'[0-9A-F]+[HL]\b', Number.Hex), # hexadecimal number
|
| 58 |
+
(r'[0-9]+\.[0-9]+E[+-][0-9]+', Number.Float), # real number
|
| 59 |
+
(r'[0-9]+\.[0-9]+', Number.Float), # real number
|
| 60 |
+
(r'[0-9]+', Number.Integer), # decimal whole number
|
| 61 |
+
],
|
| 62 |
+
'strings': [
|
| 63 |
+
(r"'[^\n']*'", String), # single quoted string
|
| 64 |
+
(r'"[^\n"]*"', String), # double quoted string
|
| 65 |
+
],
|
| 66 |
+
'operators': [
|
| 67 |
+
# Arithmetic Operators
|
| 68 |
+
(r'[+-]', Operator),
|
| 69 |
+
(r'[*/]', Operator),
|
| 70 |
+
# Relational Operators
|
| 71 |
+
(r'[=#<>]', Operator),
|
| 72 |
+
# Dereferencing Operator
|
| 73 |
+
(r'\^', Operator),
|
| 74 |
+
# Logical AND Operator
|
| 75 |
+
(r'&', Operator),
|
| 76 |
+
# Logical NOT Operator
|
| 77 |
+
(r'~', Operator),
|
| 78 |
+
# Assignment Symbol
|
| 79 |
+
(r':=', Operator),
|
| 80 |
+
# Range Constructor
|
| 81 |
+
(r'\.\.', Operator),
|
| 82 |
+
(r'\$', Operator),
|
| 83 |
+
],
|
| 84 |
+
'identifiers': [
|
| 85 |
+
(r'([a-zA-Z_$][\w$]*)', Name),
|
| 86 |
+
],
|
| 87 |
+
'builtins': [
|
| 88 |
+
(words((
|
| 89 |
+
'ANYPTR', 'ANYREC', 'BOOLEAN', 'BYTE', 'CHAR', 'INTEGER', 'LONGINT',
|
| 90 |
+
'REAL', 'SET', 'SHORTCHAR', 'SHORTINT', 'SHORTREAL'
|
| 91 |
+
), suffix=r'\b'), Keyword.Type),
|
| 92 |
+
(words((
|
| 93 |
+
'ABS', 'ABSTRACT', 'ARRAY', 'ASH', 'ASSERT', 'BEGIN', 'BITS', 'BY',
|
| 94 |
+
'CAP', 'CASE', 'CHR', 'CLOSE', 'CONST', 'DEC', 'DIV', 'DO', 'ELSE',
|
| 95 |
+
'ELSIF', 'EMPTY', 'END', 'ENTIER', 'EXCL', 'EXIT', 'EXTENSIBLE', 'FOR',
|
| 96 |
+
'HALT', 'IF', 'IMPORT', 'IN', 'INC', 'INCL', 'IS', 'LEN', 'LIMITED',
|
| 97 |
+
'LONG', 'LOOP', 'MAX', 'MIN', 'MOD', 'MODULE', 'NEW', 'ODD', 'OF',
|
| 98 |
+
'OR', 'ORD', 'OUT', 'POINTER', 'PROCEDURE', 'RECORD', 'REPEAT', 'RETURN',
|
| 99 |
+
'SHORT', 'SHORTCHAR', 'SHORTINT', 'SIZE', 'THEN', 'TYPE', 'TO', 'UNTIL',
|
| 100 |
+
'VAR', 'WHILE', 'WITH'
|
| 101 |
+
), suffix=r'\b'), Keyword.Reserved),
|
| 102 |
+
(r'(TRUE|FALSE|NIL|INF)\b', Keyword.Constant),
|
| 103 |
+
]
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
def analyse_text(text):
|
| 107 |
+
"""The only other lexer using .cp is the C++ one, so we check if for
|
| 108 |
+
a few common Pascal keywords here. Those are unfortunately quite
|
| 109 |
+
common across various business languages as well."""
|
| 110 |
+
result = 0
|
| 111 |
+
if 'BEGIN' in text:
|
| 112 |
+
result += 0.01
|
| 113 |
+
if 'END' in text:
|
| 114 |
+
result += 0.01
|
| 115 |
+
if 'PROCEDURE' in text:
|
| 116 |
+
result += 0.01
|
| 117 |
+
if 'MODULE' in text:
|
| 118 |
+
result += 0.01
|
| 119 |
+
|
| 120 |
+
return result
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/objective.py
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, using, this, words, \
|
| 14 |
+
inherit, default
|
| 15 |
+
from pygments.token import Text, Keyword, Name, String, Operator, \
|
| 16 |
+
Number, Punctuation, Literal, Comment, Whitespace
|
| 17 |
+
|
| 18 |
+
from pygments.lexers.c_cpp import CLexer, CppLexer
|
| 19 |
+
|
| 20 |
+
__all__ = ['ObjectiveCLexer', 'ObjectiveCppLexer', 'LogosLexer', 'SwiftLexer']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def objective(baselexer):
|
| 24 |
+
"""
|
| 25 |
+
Generate a subclass of baselexer that accepts the Objective-C syntax
|
| 26 |
+
extensions.
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
# Have to be careful not to accidentally match JavaDoc/Doxygen syntax here,
|
| 30 |
+
# since that's quite common in ordinary C/C++ files. It's OK to match
|
| 31 |
+
# JavaDoc/Doxygen keywords that only apply to Objective-C, mind.
|
| 32 |
+
#
|
| 33 |
+
# The upshot of this is that we CANNOT match @class or @interface
|
| 34 |
+
_oc_keywords = re.compile(r'@(?:end|implementation|protocol)')
|
| 35 |
+
|
| 36 |
+
# Matches [ <ws>? identifier <ws> ( identifier <ws>? ] | identifier? : )
|
| 37 |
+
# (note the identifier is *optional* when there is a ':'!)
|
| 38 |
+
_oc_message = re.compile(r'\[\s*[a-zA-Z_]\w*\s+'
|
| 39 |
+
r'(?:[a-zA-Z_]\w*\s*\]|'
|
| 40 |
+
r'(?:[a-zA-Z_]\w*)?:)')
|
| 41 |
+
|
| 42 |
+
class GeneratedObjectiveCVariant(baselexer):
|
| 43 |
+
"""
|
| 44 |
+
Implements Objective-C syntax on top of an existing C family lexer.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
tokens = {
|
| 48 |
+
'statements': [
|
| 49 |
+
(r'@"', String, 'string'),
|
| 50 |
+
(r'@(YES|NO)', Number),
|
| 51 |
+
(r"@'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
| 52 |
+
(r'@(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
|
| 53 |
+
(r'@(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 54 |
+
(r'@0x[0-9a-fA-F]+[Ll]?', Number.Hex),
|
| 55 |
+
(r'@0[0-7]+[Ll]?', Number.Oct),
|
| 56 |
+
(r'@\d+[Ll]?', Number.Integer),
|
| 57 |
+
(r'@\(', Literal, 'literal_number'),
|
| 58 |
+
(r'@\[', Literal, 'literal_array'),
|
| 59 |
+
(r'@\{', Literal, 'literal_dictionary'),
|
| 60 |
+
(words((
|
| 61 |
+
'@selector', '@private', '@protected', '@public', '@encode',
|
| 62 |
+
'@synchronized', '@try', '@throw', '@catch', '@finally',
|
| 63 |
+
'@end', '@property', '@synthesize', '__bridge', '__bridge_transfer',
|
| 64 |
+
'__autoreleasing', '__block', '__weak', '__strong', 'weak', 'strong',
|
| 65 |
+
'copy', 'retain', 'assign', 'unsafe_unretained', 'atomic', 'nonatomic',
|
| 66 |
+
'readonly', 'readwrite', 'setter', 'getter', 'typeof', 'in',
|
| 67 |
+
'out', 'inout', 'release', 'class', '@dynamic', '@optional',
|
| 68 |
+
'@required', '@autoreleasepool', '@import'), suffix=r'\b'),
|
| 69 |
+
Keyword),
|
| 70 |
+
(words(('id', 'instancetype', 'Class', 'IMP', 'SEL', 'BOOL',
|
| 71 |
+
'IBOutlet', 'IBAction', 'unichar'), suffix=r'\b'),
|
| 72 |
+
Keyword.Type),
|
| 73 |
+
(r'@(true|false|YES|NO)\n', Name.Builtin),
|
| 74 |
+
(r'(YES|NO|nil|self|super)\b', Name.Builtin),
|
| 75 |
+
# Carbon types
|
| 76 |
+
(r'(Boolean|UInt8|SInt8|UInt16|SInt16|UInt32|SInt32)\b', Keyword.Type),
|
| 77 |
+
# Carbon built-ins
|
| 78 |
+
(r'(TRUE|FALSE)\b', Name.Builtin),
|
| 79 |
+
(r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text),
|
| 80 |
+
('#pop', 'oc_classname')),
|
| 81 |
+
(r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
|
| 82 |
+
('#pop', 'oc_forward_classname')),
|
| 83 |
+
# @ can also prefix other expressions like @{...} or @(...)
|
| 84 |
+
(r'@', Punctuation),
|
| 85 |
+
inherit,
|
| 86 |
+
],
|
| 87 |
+
'oc_classname': [
|
| 88 |
+
# interface definition that inherits
|
| 89 |
+
(r'([a-zA-Z$_][\w$]*)(\s*:\s*)([a-zA-Z$_][\w$]*)?(\s*)(\{)',
|
| 90 |
+
bygroups(Name.Class, Text, Name.Class, Text, Punctuation),
|
| 91 |
+
('#pop', 'oc_ivars')),
|
| 92 |
+
(r'([a-zA-Z$_][\w$]*)(\s*:\s*)([a-zA-Z$_][\w$]*)?',
|
| 93 |
+
bygroups(Name.Class, Text, Name.Class), '#pop'),
|
| 94 |
+
# interface definition for a category
|
| 95 |
+
(r'([a-zA-Z$_][\w$]*)(\s*)(\([a-zA-Z$_][\w$]*\))(\s*)(\{)',
|
| 96 |
+
bygroups(Name.Class, Text, Name.Label, Text, Punctuation),
|
| 97 |
+
('#pop', 'oc_ivars')),
|
| 98 |
+
(r'([a-zA-Z$_][\w$]*)(\s*)(\([a-zA-Z$_][\w$]*\))',
|
| 99 |
+
bygroups(Name.Class, Text, Name.Label), '#pop'),
|
| 100 |
+
# simple interface / implementation
|
| 101 |
+
(r'([a-zA-Z$_][\w$]*)(\s*)(\{)',
|
| 102 |
+
bygroups(Name.Class, Text, Punctuation), ('#pop', 'oc_ivars')),
|
| 103 |
+
(r'([a-zA-Z$_][\w$]*)', Name.Class, '#pop')
|
| 104 |
+
],
|
| 105 |
+
'oc_forward_classname': [
|
| 106 |
+
(r'([a-zA-Z$_][\w$]*)(\s*,\s*)',
|
| 107 |
+
bygroups(Name.Class, Text), 'oc_forward_classname'),
|
| 108 |
+
(r'([a-zA-Z$_][\w$]*)(\s*;?)',
|
| 109 |
+
bygroups(Name.Class, Text), '#pop')
|
| 110 |
+
],
|
| 111 |
+
'oc_ivars': [
|
| 112 |
+
include('whitespace'),
|
| 113 |
+
include('statements'),
|
| 114 |
+
(';', Punctuation),
|
| 115 |
+
(r'\{', Punctuation, '#push'),
|
| 116 |
+
(r'\}', Punctuation, '#pop'),
|
| 117 |
+
],
|
| 118 |
+
'root': [
|
| 119 |
+
# methods
|
| 120 |
+
(r'^([-+])(\s*)' # method marker
|
| 121 |
+
r'(\(.*?\))?(\s*)' # return type
|
| 122 |
+
r'([a-zA-Z$_][\w$]*:?)', # begin of method name
|
| 123 |
+
bygroups(Punctuation, Text, using(this),
|
| 124 |
+
Text, Name.Function),
|
| 125 |
+
'method'),
|
| 126 |
+
inherit,
|
| 127 |
+
],
|
| 128 |
+
'method': [
|
| 129 |
+
include('whitespace'),
|
| 130 |
+
# TODO unsure if ellipses are allowed elsewhere, see
|
| 131 |
+
# discussion in Issue 789
|
| 132 |
+
(r',', Punctuation),
|
| 133 |
+
(r'\.\.\.', Punctuation),
|
| 134 |
+
(r'(\(.*?\))(\s*)([a-zA-Z$_][\w$]*)',
|
| 135 |
+
bygroups(using(this), Text, Name.Variable)),
|
| 136 |
+
(r'[a-zA-Z$_][\w$]*:', Name.Function),
|
| 137 |
+
(';', Punctuation, '#pop'),
|
| 138 |
+
(r'\{', Punctuation, 'function'),
|
| 139 |
+
default('#pop'),
|
| 140 |
+
],
|
| 141 |
+
'literal_number': [
|
| 142 |
+
(r'\(', Punctuation, 'literal_number_inner'),
|
| 143 |
+
(r'\)', Literal, '#pop'),
|
| 144 |
+
include('statement'),
|
| 145 |
+
],
|
| 146 |
+
'literal_number_inner': [
|
| 147 |
+
(r'\(', Punctuation, '#push'),
|
| 148 |
+
(r'\)', Punctuation, '#pop'),
|
| 149 |
+
include('statement'),
|
| 150 |
+
],
|
| 151 |
+
'literal_array': [
|
| 152 |
+
(r'\[', Punctuation, 'literal_array_inner'),
|
| 153 |
+
(r'\]', Literal, '#pop'),
|
| 154 |
+
include('statement'),
|
| 155 |
+
],
|
| 156 |
+
'literal_array_inner': [
|
| 157 |
+
(r'\[', Punctuation, '#push'),
|
| 158 |
+
(r'\]', Punctuation, '#pop'),
|
| 159 |
+
include('statement'),
|
| 160 |
+
],
|
| 161 |
+
'literal_dictionary': [
|
| 162 |
+
(r'\}', Literal, '#pop'),
|
| 163 |
+
include('statement'),
|
| 164 |
+
],
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
def analyse_text(text):
|
| 168 |
+
if _oc_keywords.search(text):
|
| 169 |
+
return 1.0
|
| 170 |
+
elif '@"' in text: # strings
|
| 171 |
+
return 0.8
|
| 172 |
+
elif re.search('@[0-9]+', text):
|
| 173 |
+
return 0.7
|
| 174 |
+
elif _oc_message.search(text):
|
| 175 |
+
return 0.8
|
| 176 |
+
return 0
|
| 177 |
+
|
| 178 |
+
def get_tokens_unprocessed(self, text, stack=('root',)):
|
| 179 |
+
from pygments.lexers._cocoa_builtins import COCOA_INTERFACES, \
|
| 180 |
+
COCOA_PROTOCOLS, COCOA_PRIMITIVES
|
| 181 |
+
|
| 182 |
+
for index, token, value in \
|
| 183 |
+
baselexer.get_tokens_unprocessed(self, text, stack):
|
| 184 |
+
if token is Name or token is Name.Class:
|
| 185 |
+
if value in COCOA_INTERFACES or value in COCOA_PROTOCOLS \
|
| 186 |
+
or value in COCOA_PRIMITIVES:
|
| 187 |
+
token = Name.Builtin.Pseudo
|
| 188 |
+
|
| 189 |
+
yield index, token, value
|
| 190 |
+
|
| 191 |
+
return GeneratedObjectiveCVariant
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
class ObjectiveCLexer(objective(CLexer)):
|
| 195 |
+
"""
|
| 196 |
+
For Objective-C source code with preprocessor directives.
|
| 197 |
+
"""
|
| 198 |
+
|
| 199 |
+
name = 'Objective-C'
|
| 200 |
+
url = 'https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html'
|
| 201 |
+
aliases = ['objective-c', 'objectivec', 'obj-c', 'objc']
|
| 202 |
+
filenames = ['*.m', '*.h']
|
| 203 |
+
mimetypes = ['text/x-objective-c']
|
| 204 |
+
version_added = ''
|
| 205 |
+
priority = 0.05 # Lower than C
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
class ObjectiveCppLexer(objective(CppLexer)):
|
| 209 |
+
"""
|
| 210 |
+
For Objective-C++ source code with preprocessor directives.
|
| 211 |
+
"""
|
| 212 |
+
|
| 213 |
+
name = 'Objective-C++'
|
| 214 |
+
aliases = ['objective-c++', 'objectivec++', 'obj-c++', 'objc++']
|
| 215 |
+
filenames = ['*.mm', '*.hh']
|
| 216 |
+
mimetypes = ['text/x-objective-c++']
|
| 217 |
+
version_added = ''
|
| 218 |
+
priority = 0.05 # Lower than C++
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
class LogosLexer(ObjectiveCppLexer):
|
| 222 |
+
"""
|
| 223 |
+
For Logos + Objective-C source code with preprocessor directives.
|
| 224 |
+
"""
|
| 225 |
+
|
| 226 |
+
name = 'Logos'
|
| 227 |
+
aliases = ['logos']
|
| 228 |
+
filenames = ['*.x', '*.xi', '*.xm', '*.xmi']
|
| 229 |
+
mimetypes = ['text/x-logos']
|
| 230 |
+
version_added = '1.6'
|
| 231 |
+
priority = 0.25
|
| 232 |
+
|
| 233 |
+
tokens = {
|
| 234 |
+
'statements': [
|
| 235 |
+
(r'(%orig|%log)\b', Keyword),
|
| 236 |
+
(r'(%c)\b(\()(\s*)([a-zA-Z$_][\w$]*)(\s*)(\))',
|
| 237 |
+
bygroups(Keyword, Punctuation, Text, Name.Class, Text, Punctuation)),
|
| 238 |
+
(r'(%init)\b(\()',
|
| 239 |
+
bygroups(Keyword, Punctuation), 'logos_init_directive'),
|
| 240 |
+
(r'(%init)(?=\s*;)', bygroups(Keyword)),
|
| 241 |
+
(r'(%hook|%group)(\s+)([a-zA-Z$_][\w$]+)',
|
| 242 |
+
bygroups(Keyword, Text, Name.Class), '#pop'),
|
| 243 |
+
(r'(%subclass)(\s+)', bygroups(Keyword, Text),
|
| 244 |
+
('#pop', 'logos_classname')),
|
| 245 |
+
inherit,
|
| 246 |
+
],
|
| 247 |
+
'logos_init_directive': [
|
| 248 |
+
(r'\s+', Text),
|
| 249 |
+
(',', Punctuation, ('logos_init_directive', '#pop')),
|
| 250 |
+
(r'([a-zA-Z$_][\w$]*)(\s*)(=)(\s*)([^);]*)',
|
| 251 |
+
bygroups(Name.Class, Text, Punctuation, Text, Text)),
|
| 252 |
+
(r'([a-zA-Z$_][\w$]*)', Name.Class),
|
| 253 |
+
(r'\)', Punctuation, '#pop'),
|
| 254 |
+
],
|
| 255 |
+
'logos_classname': [
|
| 256 |
+
(r'([a-zA-Z$_][\w$]*)(\s*:\s*)([a-zA-Z$_][\w$]*)?',
|
| 257 |
+
bygroups(Name.Class, Text, Name.Class), '#pop'),
|
| 258 |
+
(r'([a-zA-Z$_][\w$]*)', Name.Class, '#pop')
|
| 259 |
+
],
|
| 260 |
+
'root': [
|
| 261 |
+
(r'(%subclass)(\s+)', bygroups(Keyword, Text),
|
| 262 |
+
'logos_classname'),
|
| 263 |
+
(r'(%hook|%group)(\s+)([a-zA-Z$_][\w$]+)',
|
| 264 |
+
bygroups(Keyword, Text, Name.Class)),
|
| 265 |
+
(r'(%config)(\s*\(\s*)(\w+)(\s*=)(.*?)(\)\s*)',
|
| 266 |
+
bygroups(Keyword, Text, Name.Variable, Text, String, Text)),
|
| 267 |
+
(r'(%ctor)(\s*)(\{)', bygroups(Keyword, Text, Punctuation),
|
| 268 |
+
'function'),
|
| 269 |
+
(r'(%new)(\s*)(\()(.*?)(\))',
|
| 270 |
+
bygroups(Keyword, Text, Keyword, String, Keyword)),
|
| 271 |
+
(r'(\s*)(%end)(\s*)', bygroups(Text, Keyword, Text)),
|
| 272 |
+
inherit,
|
| 273 |
+
],
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
_logos_keywords = re.compile(r'%(?:hook|ctor|init|c\()')
|
| 277 |
+
|
| 278 |
+
def analyse_text(text):
|
| 279 |
+
if LogosLexer._logos_keywords.search(text):
|
| 280 |
+
return 1.0
|
| 281 |
+
return 0
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
class SwiftLexer(RegexLexer):
|
| 285 |
+
"""
|
| 286 |
+
For Swift source.
|
| 287 |
+
"""
|
| 288 |
+
name = 'Swift'
|
| 289 |
+
url = 'https://www.swift.org/'
|
| 290 |
+
filenames = ['*.swift']
|
| 291 |
+
aliases = ['swift']
|
| 292 |
+
mimetypes = ['text/x-swift']
|
| 293 |
+
version_added = '2.0'
|
| 294 |
+
|
| 295 |
+
tokens = {
|
| 296 |
+
'root': [
|
| 297 |
+
# Whitespace and Comments
|
| 298 |
+
(r'\n', Text),
|
| 299 |
+
(r'\s+', Whitespace),
|
| 300 |
+
(r'//', Comment.Single, 'comment-single'),
|
| 301 |
+
(r'/\*', Comment.Multiline, 'comment-multi'),
|
| 302 |
+
(r'#(if|elseif|else|endif|available)\b', Comment.Preproc, 'preproc'),
|
| 303 |
+
|
| 304 |
+
# Keywords
|
| 305 |
+
include('keywords'),
|
| 306 |
+
|
| 307 |
+
# Global Types
|
| 308 |
+
(words((
|
| 309 |
+
'Array', 'AutoreleasingUnsafeMutablePointer', 'BidirectionalReverseView',
|
| 310 |
+
'Bit', 'Bool', 'CFunctionPointer', 'COpaquePointer', 'CVaListPointer',
|
| 311 |
+
'Character', 'ClosedInterval', 'CollectionOfOne', 'ContiguousArray',
|
| 312 |
+
'Dictionary', 'DictionaryGenerator', 'DictionaryIndex', 'Double',
|
| 313 |
+
'EmptyCollection', 'EmptyGenerator', 'EnumerateGenerator',
|
| 314 |
+
'EnumerateSequence', 'FilterCollectionView',
|
| 315 |
+
'FilterCollectionViewIndex', 'FilterGenerator', 'FilterSequenceView',
|
| 316 |
+
'Float', 'Float80', 'FloatingPointClassification', 'GeneratorOf',
|
| 317 |
+
'GeneratorOfOne', 'GeneratorSequence', 'HalfOpenInterval', 'HeapBuffer',
|
| 318 |
+
'HeapBufferStorage', 'ImplicitlyUnwrappedOptional', 'IndexingGenerator',
|
| 319 |
+
'Int', 'Int16', 'Int32', 'Int64', 'Int8', 'LazyBidirectionalCollection',
|
| 320 |
+
'LazyForwardCollection', 'LazyRandomAccessCollection',
|
| 321 |
+
'LazySequence', 'MapCollectionView', 'MapSequenceGenerator',
|
| 322 |
+
'MapSequenceView', 'MirrorDisposition', 'ObjectIdentifier', 'OnHeap',
|
| 323 |
+
'Optional', 'PermutationGenerator', 'QuickLookObject',
|
| 324 |
+
'RandomAccessReverseView', 'Range', 'RangeGenerator', 'RawByte', 'Repeat',
|
| 325 |
+
'ReverseBidirectionalIndex', 'ReverseRandomAccessIndex', 'SequenceOf',
|
| 326 |
+
'SinkOf', 'Slice', 'StaticString', 'StrideThrough', 'StrideThroughGenerator',
|
| 327 |
+
'StrideTo', 'StrideToGenerator', 'String', 'UInt', 'UInt16', 'UInt32',
|
| 328 |
+
'UInt64', 'UInt8', 'UTF16', 'UTF32', 'UTF8', 'UnicodeDecodingResult',
|
| 329 |
+
'UnicodeScalar', 'Unmanaged', 'UnsafeBufferPointer',
|
| 330 |
+
'UnsafeBufferPointerGenerator', 'UnsafeMutableBufferPointer',
|
| 331 |
+
'UnsafeMutablePointer', 'UnsafePointer', 'Zip2', 'ZipGenerator2',
|
| 332 |
+
# Protocols
|
| 333 |
+
'AbsoluteValuable', 'AnyObject', 'ArrayLiteralConvertible',
|
| 334 |
+
'BidirectionalIndexType', 'BitwiseOperationsType',
|
| 335 |
+
'BooleanLiteralConvertible', 'BooleanType', 'CVarArgType',
|
| 336 |
+
'CollectionType', 'Comparable', 'DebugPrintable',
|
| 337 |
+
'DictionaryLiteralConvertible', 'Equatable',
|
| 338 |
+
'ExtendedGraphemeClusterLiteralConvertible',
|
| 339 |
+
'ExtensibleCollectionType', 'FloatLiteralConvertible',
|
| 340 |
+
'FloatingPointType', 'ForwardIndexType', 'GeneratorType', 'Hashable',
|
| 341 |
+
'IntegerArithmeticType', 'IntegerLiteralConvertible', 'IntegerType',
|
| 342 |
+
'IntervalType', 'MirrorType', 'MutableCollectionType', 'MutableSliceable',
|
| 343 |
+
'NilLiteralConvertible', 'OutputStreamType', 'Printable',
|
| 344 |
+
'RandomAccessIndexType', 'RangeReplaceableCollectionType',
|
| 345 |
+
'RawOptionSetType', 'RawRepresentable', 'Reflectable', 'SequenceType',
|
| 346 |
+
'SignedIntegerType', 'SignedNumberType', 'SinkType', 'Sliceable',
|
| 347 |
+
'Streamable', 'Strideable', 'StringInterpolationConvertible',
|
| 348 |
+
'StringLiteralConvertible', 'UnicodeCodecType',
|
| 349 |
+
'UnicodeScalarLiteralConvertible', 'UnsignedIntegerType',
|
| 350 |
+
'_ArrayBufferType', '_BidirectionalIndexType', '_CocoaStringType',
|
| 351 |
+
'_CollectionType', '_Comparable', '_ExtensibleCollectionType',
|
| 352 |
+
'_ForwardIndexType', '_Incrementable', '_IntegerArithmeticType',
|
| 353 |
+
'_IntegerType', '_ObjectiveCBridgeable', '_RandomAccessIndexType',
|
| 354 |
+
'_RawOptionSetType', '_SequenceType', '_Sequence_Type',
|
| 355 |
+
'_SignedIntegerType', '_SignedNumberType', '_Sliceable', '_Strideable',
|
| 356 |
+
'_SwiftNSArrayRequiredOverridesType', '_SwiftNSArrayType',
|
| 357 |
+
'_SwiftNSCopyingType', '_SwiftNSDictionaryRequiredOverridesType',
|
| 358 |
+
'_SwiftNSDictionaryType', '_SwiftNSEnumeratorType',
|
| 359 |
+
'_SwiftNSFastEnumerationType', '_SwiftNSStringRequiredOverridesType',
|
| 360 |
+
'_SwiftNSStringType', '_UnsignedIntegerType',
|
| 361 |
+
# Variables
|
| 362 |
+
'C_ARGC', 'C_ARGV', 'Process',
|
| 363 |
+
# Typealiases
|
| 364 |
+
'Any', 'AnyClass', 'BooleanLiteralType', 'CBool', 'CChar', 'CChar16',
|
| 365 |
+
'CChar32', 'CDouble', 'CFloat', 'CInt', 'CLong', 'CLongLong', 'CShort',
|
| 366 |
+
'CSignedChar', 'CUnsignedInt', 'CUnsignedLong', 'CUnsignedShort',
|
| 367 |
+
'CWideChar', 'ExtendedGraphemeClusterType', 'Float32', 'Float64',
|
| 368 |
+
'FloatLiteralType', 'IntMax', 'IntegerLiteralType', 'StringLiteralType',
|
| 369 |
+
'UIntMax', 'UWord', 'UnicodeScalarType', 'Void', 'Word',
|
| 370 |
+
# Foundation/Cocoa
|
| 371 |
+
'NSErrorPointer', 'NSObjectProtocol', 'Selector'), suffix=r'\b'),
|
| 372 |
+
Name.Builtin),
|
| 373 |
+
# Functions
|
| 374 |
+
(words((
|
| 375 |
+
'abs', 'advance', 'alignof', 'alignofValue', 'assert', 'assertionFailure',
|
| 376 |
+
'contains', 'count', 'countElements', 'debugPrint', 'debugPrintln',
|
| 377 |
+
'distance', 'dropFirst', 'dropLast', 'dump', 'enumerate', 'equal',
|
| 378 |
+
'extend', 'fatalError', 'filter', 'find', 'first', 'getVaList', 'indices',
|
| 379 |
+
'insert', 'isEmpty', 'join', 'last', 'lazy', 'lexicographicalCompare',
|
| 380 |
+
'map', 'max', 'maxElement', 'min', 'minElement', 'numericCast', 'overlaps',
|
| 381 |
+
'partition', 'precondition', 'preconditionFailure', 'prefix', 'print',
|
| 382 |
+
'println', 'reduce', 'reflect', 'removeAll', 'removeAtIndex', 'removeLast',
|
| 383 |
+
'removeRange', 'reverse', 'sizeof', 'sizeofValue', 'sort', 'sorted',
|
| 384 |
+
'splice', 'split', 'startsWith', 'stride', 'strideof', 'strideofValue',
|
| 385 |
+
'suffix', 'swap', 'toDebugString', 'toString', 'transcode',
|
| 386 |
+
'underestimateCount', 'unsafeAddressOf', 'unsafeBitCast', 'unsafeDowncast',
|
| 387 |
+
'withExtendedLifetime', 'withUnsafeMutablePointer',
|
| 388 |
+
'withUnsafeMutablePointers', 'withUnsafePointer', 'withUnsafePointers',
|
| 389 |
+
'withVaList'), suffix=r'\b'),
|
| 390 |
+
Name.Builtin.Pseudo),
|
| 391 |
+
|
| 392 |
+
# Implicit Block Variables
|
| 393 |
+
(r'\$\d+', Name.Variable),
|
| 394 |
+
|
| 395 |
+
# Binary Literal
|
| 396 |
+
(r'0b[01_]+', Number.Bin),
|
| 397 |
+
# Octal Literal
|
| 398 |
+
(r'0o[0-7_]+', Number.Oct),
|
| 399 |
+
# Hexadecimal Literal
|
| 400 |
+
(r'0x[0-9a-fA-F_]+', Number.Hex),
|
| 401 |
+
# Decimal Literal
|
| 402 |
+
(r'[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?[0-9_]+|'
|
| 403 |
+
r'\.[0-9_]*|[eE][+\-]?[0-9_]+)', Number.Float),
|
| 404 |
+
(r'[0-9][0-9_]*', Number.Integer),
|
| 405 |
+
# String Literal
|
| 406 |
+
(r'"""', String, 'string-multi'),
|
| 407 |
+
(r'"', String, 'string'),
|
| 408 |
+
|
| 409 |
+
# Operators and Punctuation
|
| 410 |
+
(r'[(){}\[\].,:;=@#`?]|->|[<&?](?=\w)|(?<=\w)[>!?]', Punctuation),
|
| 411 |
+
(r'[/=\-+!*%<>&|^?~]+', Operator),
|
| 412 |
+
|
| 413 |
+
# Identifier
|
| 414 |
+
(r'[a-zA-Z_]\w*', Name)
|
| 415 |
+
],
|
| 416 |
+
'keywords': [
|
| 417 |
+
(words((
|
| 418 |
+
'as', 'async', 'await', 'break', 'case', 'catch', 'continue', 'default', 'defer',
|
| 419 |
+
'do', 'else', 'fallthrough', 'for', 'guard', 'if', 'in', 'is',
|
| 420 |
+
'repeat', 'return', '#selector', 'switch', 'throw', 'try',
|
| 421 |
+
'where', 'while'), suffix=r'\b'),
|
| 422 |
+
Keyword),
|
| 423 |
+
(r'@availability\([^)]+\)', Keyword.Reserved),
|
| 424 |
+
(words((
|
| 425 |
+
'associativity', 'convenience', 'dynamic', 'didSet', 'final',
|
| 426 |
+
'get', 'indirect', 'infix', 'inout', 'lazy', 'left', 'mutating',
|
| 427 |
+
'none', 'nonmutating', 'optional', 'override', 'postfix',
|
| 428 |
+
'precedence', 'prefix', 'Protocol', 'required', 'rethrows',
|
| 429 |
+
'right', 'set', 'throws', 'Type', 'unowned', 'weak', 'willSet',
|
| 430 |
+
'@availability', '@autoclosure', '@noreturn',
|
| 431 |
+
'@NSApplicationMain', '@NSCopying', '@NSManaged', '@objc',
|
| 432 |
+
'@UIApplicationMain', '@IBAction', '@IBDesignable',
|
| 433 |
+
'@IBInspectable', '@IBOutlet'), suffix=r'\b'),
|
| 434 |
+
Keyword.Reserved),
|
| 435 |
+
(r'(as|dynamicType|false|is|nil|self|Self|super|true|__COLUMN__'
|
| 436 |
+
r'|__FILE__|__FUNCTION__|__LINE__|_'
|
| 437 |
+
r'|#(?:file|line|column|function))\b', Keyword.Constant),
|
| 438 |
+
(r'import\b', Keyword.Declaration, 'module'),
|
| 439 |
+
(r'(class|enum|extension|struct|protocol)(\s+)([a-zA-Z_]\w*)',
|
| 440 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Class)),
|
| 441 |
+
(r'(func)(\s+)([a-zA-Z_]\w*)',
|
| 442 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Function)),
|
| 443 |
+
(r'(var|let)(\s+)([a-zA-Z_]\w*)', bygroups(Keyword.Declaration,
|
| 444 |
+
Whitespace, Name.Variable)),
|
| 445 |
+
(words((
|
| 446 |
+
'actor', 'associatedtype', 'class', 'deinit', 'enum', 'extension', 'func', 'import',
|
| 447 |
+
'init', 'internal', 'let', 'operator', 'private', 'protocol', 'public',
|
| 448 |
+
'static', 'struct', 'subscript', 'typealias', 'var'), suffix=r'\b'),
|
| 449 |
+
Keyword.Declaration)
|
| 450 |
+
],
|
| 451 |
+
'comment': [
|
| 452 |
+
(r':param: [a-zA-Z_]\w*|:returns?:|(FIXME|MARK|TODO):',
|
| 453 |
+
Comment.Special)
|
| 454 |
+
],
|
| 455 |
+
|
| 456 |
+
# Nested
|
| 457 |
+
'comment-single': [
|
| 458 |
+
(r'\n', Whitespace, '#pop'),
|
| 459 |
+
include('comment'),
|
| 460 |
+
(r'[^\n]+', Comment.Single)
|
| 461 |
+
],
|
| 462 |
+
'comment-multi': [
|
| 463 |
+
include('comment'),
|
| 464 |
+
(r'[^*/]+', Comment.Multiline),
|
| 465 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 466 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 467 |
+
(r'[*/]+', Comment.Multiline)
|
| 468 |
+
],
|
| 469 |
+
'module': [
|
| 470 |
+
(r'\n', Whitespace, '#pop'),
|
| 471 |
+
(r'[a-zA-Z_]\w*', Name.Class),
|
| 472 |
+
include('root')
|
| 473 |
+
],
|
| 474 |
+
'preproc': [
|
| 475 |
+
(r'\n', Whitespace, '#pop'),
|
| 476 |
+
include('keywords'),
|
| 477 |
+
(r'[A-Za-z]\w*', Comment.Preproc),
|
| 478 |
+
include('root')
|
| 479 |
+
],
|
| 480 |
+
'string': [
|
| 481 |
+
(r'"', String, '#pop'),
|
| 482 |
+
include("string-common"),
|
| 483 |
+
],
|
| 484 |
+
'string-multi': [
|
| 485 |
+
(r'"""', String, '#pop'),
|
| 486 |
+
include("string-common"),
|
| 487 |
+
],
|
| 488 |
+
'string-common': [
|
| 489 |
+
(r'\\\(', String.Interpol, 'string-intp'),
|
| 490 |
+
(r"""\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}"""
|
| 491 |
+
r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}""", String.Escape),
|
| 492 |
+
(r'[^\\"]+', String),
|
| 493 |
+
(r'\\', String)
|
| 494 |
+
],
|
| 495 |
+
'string-intp': [
|
| 496 |
+
(r'\(', String.Interpol, '#push'),
|
| 497 |
+
(r'\)', String.Interpol, '#pop'),
|
| 498 |
+
include('root')
|
| 499 |
+
]
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
def get_tokens_unprocessed(self, text):
|
| 503 |
+
from pygments.lexers._cocoa_builtins import COCOA_INTERFACES, \
|
| 504 |
+
COCOA_PROTOCOLS, COCOA_PRIMITIVES
|
| 505 |
+
|
| 506 |
+
for index, token, value in \
|
| 507 |
+
RegexLexer.get_tokens_unprocessed(self, text):
|
| 508 |
+
if token is Name or token is Name.Class:
|
| 509 |
+
if value in COCOA_INTERFACES or value in COCOA_PROTOCOLS \
|
| 510 |
+
or value in COCOA_PRIMITIVES:
|
| 511 |
+
token = Name.Builtin.Pseudo
|
| 512 |
+
|
| 513 |
+
yield index, token, value
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/ooc.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.ooc
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Ooc language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, words
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['OocLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class OocLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Ooc source code
|
| 21 |
+
"""
|
| 22 |
+
name = 'Ooc'
|
| 23 |
+
url = 'https://ooc-lang.github.io/'
|
| 24 |
+
aliases = ['ooc']
|
| 25 |
+
filenames = ['*.ooc']
|
| 26 |
+
mimetypes = ['text/x-ooc']
|
| 27 |
+
version_added = '1.2'
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
'root': [
|
| 31 |
+
(words((
|
| 32 |
+
'class', 'interface', 'implement', 'abstract', 'extends', 'from',
|
| 33 |
+
'this', 'super', 'new', 'const', 'final', 'static', 'import',
|
| 34 |
+
'use', 'extern', 'inline', 'proto', 'break', 'continue',
|
| 35 |
+
'fallthrough', 'operator', 'if', 'else', 'for', 'while', 'do',
|
| 36 |
+
'switch', 'case', 'as', 'in', 'version', 'return', 'true',
|
| 37 |
+
'false', 'null'), prefix=r'\b', suffix=r'\b'),
|
| 38 |
+
Keyword),
|
| 39 |
+
(r'include\b', Keyword, 'include'),
|
| 40 |
+
(r'(cover)([ \t]+)(from)([ \t]+)(\w+[*@]?)',
|
| 41 |
+
bygroups(Keyword, Text, Keyword, Text, Name.Class)),
|
| 42 |
+
(r'(func)((?:[ \t]|\\\n)+)(~[a-z_]\w*)',
|
| 43 |
+
bygroups(Keyword, Text, Name.Function)),
|
| 44 |
+
(r'\bfunc\b', Keyword),
|
| 45 |
+
# Note: %= not listed on https://ooc-lang.github.io/docs/lang/operators/
|
| 46 |
+
(r'//.*', Comment),
|
| 47 |
+
(r'(?s)/\*.*?\*/', Comment.Multiline),
|
| 48 |
+
(r'(==?|\+=?|-[=>]?|\*=?|/=?|:=|!=?|%=?|\?|>{1,3}=?|<{1,3}=?|\.\.|'
|
| 49 |
+
r'&&?|\|\|?|\^=?)', Operator),
|
| 50 |
+
(r'(\.)([ \t]*)([a-z]\w*)', bygroups(Operator, Text,
|
| 51 |
+
Name.Function)),
|
| 52 |
+
(r'[A-Z][A-Z0-9_]+', Name.Constant),
|
| 53 |
+
(r'[A-Z]\w*([@*]|\[[ \t]*\])?', Name.Class),
|
| 54 |
+
|
| 55 |
+
(r'([a-z]\w*(?:~[a-z]\w*)?)((?:[ \t]|\\\n)*)(?=\()',
|
| 56 |
+
bygroups(Name.Function, Text)),
|
| 57 |
+
(r'[a-z]\w*', Name.Variable),
|
| 58 |
+
|
| 59 |
+
# : introduces types
|
| 60 |
+
(r'[:(){}\[\];,]', Punctuation),
|
| 61 |
+
|
| 62 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 63 |
+
(r'0c[0-9]+', Number.Oct),
|
| 64 |
+
(r'0b[01]+', Number.Bin),
|
| 65 |
+
(r'[0-9_]\.[0-9_]*(?!\.)', Number.Float),
|
| 66 |
+
(r'[0-9_]+', Number.Decimal),
|
| 67 |
+
|
| 68 |
+
(r'"(?:\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\"])*"',
|
| 69 |
+
String.Double),
|
| 70 |
+
(r"'(?:\\.|\\[0-9]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
|
| 71 |
+
String.Char),
|
| 72 |
+
(r'@', Punctuation), # pointer dereference
|
| 73 |
+
(r'\.', Punctuation), # imports or chain operator
|
| 74 |
+
|
| 75 |
+
(r'\\[ \t\n]', Text),
|
| 76 |
+
(r'[ \t]+', Text),
|
| 77 |
+
],
|
| 78 |
+
'include': [
|
| 79 |
+
(r'[\w/]+', Name),
|
| 80 |
+
(r',', Punctuation),
|
| 81 |
+
(r'[ \t]', Text),
|
| 82 |
+
(r'[;\n]', Text, '#pop'),
|
| 83 |
+
],
|
| 84 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/openscad.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.openscad
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the OpenSCAD languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, words, include
|
| 12 |
+
from pygments.token import Text, Comment, Punctuation, Operator, Keyword, Name, Number, Whitespace, Literal, String
|
| 13 |
+
|
| 14 |
+
__all__ = ['OpenScadLexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class OpenScadLexer(RegexLexer):
|
| 18 |
+
"""For openSCAD code.
|
| 19 |
+
"""
|
| 20 |
+
name = "OpenSCAD"
|
| 21 |
+
url = "https://openscad.org/"
|
| 22 |
+
aliases = ["openscad"]
|
| 23 |
+
filenames = ["*.scad"]
|
| 24 |
+
mimetypes = ["application/x-openscad"]
|
| 25 |
+
version_added = '2.16'
|
| 26 |
+
|
| 27 |
+
tokens = {
|
| 28 |
+
"root": [
|
| 29 |
+
(r"[^\S\n]+", Whitespace),
|
| 30 |
+
(r'//', Comment.Single, 'comment-single'),
|
| 31 |
+
(r'/\*', Comment.Multiline, 'comment-multi'),
|
| 32 |
+
(r"[{}\[\]\(\),;:]", Punctuation),
|
| 33 |
+
(r"[*!#%\-+=?/]", Operator),
|
| 34 |
+
(r"<=|<|==|!=|>=|>|&&|\|\|", Operator),
|
| 35 |
+
(r"\$(f[asn]|t|vp[rtd]|children)", Operator),
|
| 36 |
+
(r"(undef|PI)\b", Keyword.Constant),
|
| 37 |
+
(
|
| 38 |
+
r"(use|include)((?:\s|\\\\s)+)",
|
| 39 |
+
bygroups(Keyword.Namespace, Text),
|
| 40 |
+
"includes",
|
| 41 |
+
),
|
| 42 |
+
(r"(module)(\s*)([^\s\(]+)",
|
| 43 |
+
bygroups(Keyword.Namespace, Whitespace, Name.Namespace)),
|
| 44 |
+
(r"(function)(\s*)([^\s\(]+)",
|
| 45 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Function)),
|
| 46 |
+
(words(("true", "false"), prefix=r"\b", suffix=r"\b"), Literal),
|
| 47 |
+
(words((
|
| 48 |
+
"function", "module", "include", "use", "for",
|
| 49 |
+
"intersection_for", "if", "else", "return"
|
| 50 |
+
), prefix=r"\b", suffix=r"\b"), Keyword
|
| 51 |
+
),
|
| 52 |
+
(words((
|
| 53 |
+
"circle", "square", "polygon", "text", "sphere", "cube",
|
| 54 |
+
"cylinder", "polyhedron", "translate", "rotate", "scale",
|
| 55 |
+
"resize", "mirror", "multmatrix", "color", "offset", "hull",
|
| 56 |
+
"minkowski", "union", "difference", "intersection", "abs",
|
| 57 |
+
"sign", "sin", "cos", "tan", "acos", "asin", "atan", "atan2",
|
| 58 |
+
"floor", "round", "ceil", "ln", "log", "pow", "sqrt", "exp",
|
| 59 |
+
"rands", "min", "max", "concat", "lookup", "str", "chr",
|
| 60 |
+
"search", "version", "version_num", "norm", "cross",
|
| 61 |
+
"parent_module", "echo", "import", "import_dxf",
|
| 62 |
+
"dxf_linear_extrude", "linear_extrude", "rotate_extrude",
|
| 63 |
+
"surface", "projection", "render", "dxf_cross",
|
| 64 |
+
"dxf_dim", "let", "assign", "len"
|
| 65 |
+
), prefix=r"\b", suffix=r"\b"),
|
| 66 |
+
Name.Builtin
|
| 67 |
+
),
|
| 68 |
+
(r"\bchildren\b", Name.Builtin.Pseudo),
|
| 69 |
+
(r'""".*?"""', String.Double),
|
| 70 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 71 |
+
(r"-?\d+(\.\d+)?(e[+-]?\d+)?", Number),
|
| 72 |
+
(r"\w+", Name),
|
| 73 |
+
],
|
| 74 |
+
"includes": [
|
| 75 |
+
(
|
| 76 |
+
r"(<)([^>]*)(>)",
|
| 77 |
+
bygroups(Punctuation, Comment.PreprocFile, Punctuation),
|
| 78 |
+
),
|
| 79 |
+
],
|
| 80 |
+
'comment': [
|
| 81 |
+
(r':param: [a-zA-Z_]\w*|:returns?:|(FIXME|MARK|TODO):',
|
| 82 |
+
Comment.Special)
|
| 83 |
+
],
|
| 84 |
+
'comment-single': [
|
| 85 |
+
(r'\n', Text, '#pop'),
|
| 86 |
+
include('comment'),
|
| 87 |
+
(r'[^\n]+', Comment.Single)
|
| 88 |
+
],
|
| 89 |
+
'comment-multi': [
|
| 90 |
+
include('comment'),
|
| 91 |
+
(r'[^*/]+', Comment.Multiline),
|
| 92 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 93 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 94 |
+
(r'[*/]', Comment.Multiline)
|
| 95 |
+
],
|
| 96 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/other.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.other
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Just export lexer classes previously contained in this module.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
# ruff: noqa: F401
|
| 12 |
+
from pygments.lexers.sql import SqlLexer, MySqlLexer, SqliteConsoleLexer
|
| 13 |
+
from pygments.lexers.shell import BashLexer, BashSessionLexer, BatchLexer, \
|
| 14 |
+
TcshLexer
|
| 15 |
+
from pygments.lexers.robotframework import RobotFrameworkLexer
|
| 16 |
+
from pygments.lexers.testing import GherkinLexer
|
| 17 |
+
from pygments.lexers.esoteric import BrainfuckLexer, BefungeLexer, RedcodeLexer
|
| 18 |
+
from pygments.lexers.prolog import LogtalkLexer
|
| 19 |
+
from pygments.lexers.snobol import SnobolLexer
|
| 20 |
+
from pygments.lexers.rebol import RebolLexer
|
| 21 |
+
from pygments.lexers.configs import KconfigLexer, Cfengine3Lexer
|
| 22 |
+
from pygments.lexers.modeling import ModelicaLexer
|
| 23 |
+
from pygments.lexers.scripting import AppleScriptLexer, MOOCodeLexer, \
|
| 24 |
+
HybrisLexer
|
| 25 |
+
from pygments.lexers.graphics import PostScriptLexer, GnuplotLexer, \
|
| 26 |
+
AsymptoteLexer, PovrayLexer
|
| 27 |
+
from pygments.lexers.business import ABAPLexer, OpenEdgeLexer, \
|
| 28 |
+
GoodDataCLLexer, MaqlLexer
|
| 29 |
+
from pygments.lexers.automation import AutoItLexer, AutohotkeyLexer
|
| 30 |
+
from pygments.lexers.dsls import ProtoBufLexer, BroLexer, PuppetLexer, \
|
| 31 |
+
MscgenLexer, VGLLexer
|
| 32 |
+
from pygments.lexers.basic import CbmBasicV2Lexer
|
| 33 |
+
from pygments.lexers.pawn import SourcePawnLexer, PawnLexer
|
| 34 |
+
from pygments.lexers.ecl import ECLLexer
|
| 35 |
+
from pygments.lexers.urbi import UrbiscriptLexer
|
| 36 |
+
from pygments.lexers.smalltalk import SmalltalkLexer, NewspeakLexer
|
| 37 |
+
from pygments.lexers.installers import NSISLexer, RPMSpecLexer
|
| 38 |
+
from pygments.lexers.textedit import AwkLexer
|
| 39 |
+
from pygments.lexers.smv import NuSMVLexer
|
| 40 |
+
|
| 41 |
+
__all__ = []
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/parasail.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.parasail
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for ParaSail.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Literal
|
| 16 |
+
|
| 17 |
+
__all__ = ['ParaSailLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class ParaSailLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For ParaSail source code.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'ParaSail'
|
| 26 |
+
url = 'http://www.parasail-lang.org'
|
| 27 |
+
aliases = ['parasail']
|
| 28 |
+
filenames = ['*.psi', '*.psl']
|
| 29 |
+
mimetypes = ['text/x-parasail']
|
| 30 |
+
version_added = '2.1'
|
| 31 |
+
|
| 32 |
+
flags = re.MULTILINE
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'root': [
|
| 36 |
+
(r'[^\S\n]+', Text),
|
| 37 |
+
(r'//.*?\n', Comment.Single),
|
| 38 |
+
(r'\b(and|or|xor)=', Operator.Word),
|
| 39 |
+
(r'\b(and(\s+then)?|or(\s+else)?|xor|rem|mod|'
|
| 40 |
+
r'(is|not)\s+null)\b',
|
| 41 |
+
Operator.Word),
|
| 42 |
+
# Keywords
|
| 43 |
+
(r'\b(abs|abstract|all|block|class|concurrent|const|continue|'
|
| 44 |
+
r'each|end|exit|extends|exports|forward|func|global|implements|'
|
| 45 |
+
r'import|in|interface|is|lambda|locked|new|not|null|of|op|'
|
| 46 |
+
r'optional|private|queued|ref|return|reverse|separate|some|'
|
| 47 |
+
r'type|until|var|with|'
|
| 48 |
+
# Control flow
|
| 49 |
+
r'if|then|else|elsif|case|for|while|loop)\b',
|
| 50 |
+
Keyword.Reserved),
|
| 51 |
+
(r'(abstract\s+)?(interface|class|op|func|type)',
|
| 52 |
+
Keyword.Declaration),
|
| 53 |
+
# Literals
|
| 54 |
+
(r'"[^"]*"', String),
|
| 55 |
+
(r'\\[\'ntrf"0]', String.Escape),
|
| 56 |
+
(r'#[a-zA-Z]\w*', Literal), # Enumeration
|
| 57 |
+
include('numbers'),
|
| 58 |
+
(r"'[^']'", String.Char),
|
| 59 |
+
(r'[a-zA-Z]\w*', Name),
|
| 60 |
+
# Operators and Punctuation
|
| 61 |
+
(r'(<==|==>|<=>|\*\*=|<\|=|<<=|>>=|==|!=|=\?|<=|>=|'
|
| 62 |
+
r'\*\*|<<|>>|=>|:=|\+=|-=|\*=|\|=|\||/=|\+|-|\*|/|'
|
| 63 |
+
r'\.\.|<\.\.|\.\.<|<\.\.<)',
|
| 64 |
+
Operator),
|
| 65 |
+
(r'(<|>|\[|\]|\(|\)|\||:|;|,|.|\{|\}|->)',
|
| 66 |
+
Punctuation),
|
| 67 |
+
(r'\n+', Text),
|
| 68 |
+
],
|
| 69 |
+
'numbers': [
|
| 70 |
+
(r'\d[0-9_]*#[0-9a-fA-F][0-9a-fA-F_]*#', Number.Hex), # any base
|
| 71 |
+
(r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex), # C-like hex
|
| 72 |
+
(r'0[bB][01][01_]*', Number.Bin), # C-like bin
|
| 73 |
+
(r'\d[0-9_]*\.\d[0-9_]*[eE][+-]\d[0-9_]*',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 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, DelegatingLexer, \
|
| 14 |
+
include, bygroups, using
|
| 15 |
+
from pygments.token import Punctuation, Other, Text, Comment, Operator, \
|
| 16 |
+
Keyword, Name, String, Number, Whitespace
|
| 17 |
+
from pygments.lexers.jvm import JavaLexer
|
| 18 |
+
from pygments.lexers.c_cpp import CLexer, CppLexer
|
| 19 |
+
from pygments.lexers.objective import ObjectiveCLexer
|
| 20 |
+
from pygments.lexers.d import DLexer
|
| 21 |
+
from pygments.lexers.dotnet import CSharpLexer
|
| 22 |
+
from pygments.lexers.ruby import RubyLexer
|
| 23 |
+
from pygments.lexers.python import PythonLexer
|
| 24 |
+
from pygments.lexers.perl import PerlLexer
|
| 25 |
+
|
| 26 |
+
__all__ = ['RagelLexer', 'RagelEmbeddedLexer', 'RagelCLexer', 'RagelDLexer',
|
| 27 |
+
'RagelCppLexer', 'RagelObjectiveCLexer', 'RagelRubyLexer',
|
| 28 |
+
'RagelJavaLexer', 'AntlrLexer', 'AntlrPythonLexer',
|
| 29 |
+
'AntlrPerlLexer', 'AntlrRubyLexer', 'AntlrCppLexer',
|
| 30 |
+
'AntlrCSharpLexer', 'AntlrObjectiveCLexer',
|
| 31 |
+
'AntlrJavaLexer', 'AntlrActionScriptLexer',
|
| 32 |
+
'TreetopLexer', 'EbnfLexer']
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class RagelLexer(RegexLexer):
|
| 36 |
+
"""A pure `Ragel <www.colm.net/open-source/ragel>`_ lexer.
|
| 37 |
+
|
| 38 |
+
Use this for fragments of Ragel. For ``.rl`` files, use
|
| 39 |
+
:class:`RagelEmbeddedLexer` instead (or one of the language-specific
|
| 40 |
+
subclasses).
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
name = 'Ragel'
|
| 44 |
+
url = 'http://www.colm.net/open-source/ragel/'
|
| 45 |
+
aliases = ['ragel']
|
| 46 |
+
filenames = []
|
| 47 |
+
version_added = '1.1'
|
| 48 |
+
|
| 49 |
+
tokens = {
|
| 50 |
+
'whitespace': [
|
| 51 |
+
(r'\s+', Whitespace)
|
| 52 |
+
],
|
| 53 |
+
'comments': [
|
| 54 |
+
(r'\#.*$', Comment),
|
| 55 |
+
],
|
| 56 |
+
'keywords': [
|
| 57 |
+
(r'(access|action|alphtype)\b', Keyword),
|
| 58 |
+
(r'(getkey|write|machine|include)\b', Keyword),
|
| 59 |
+
(r'(any|ascii|extend|alpha|digit|alnum|lower|upper)\b', Keyword),
|
| 60 |
+
(r'(xdigit|cntrl|graph|print|punct|space|zlen|empty)\b', Keyword)
|
| 61 |
+
],
|
| 62 |
+
'numbers': [
|
| 63 |
+
(r'0x[0-9A-Fa-f]+', Number.Hex),
|
| 64 |
+
(r'[+-]?[0-9]+', Number.Integer),
|
| 65 |
+
],
|
| 66 |
+
'literals': [
|
| 67 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 68 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 69 |
+
(r'\[(\\\\|\\[^\\]|[^\\\]])*\]', String), # square bracket literals
|
| 70 |
+
(r'/(?!\*)(\\\\|\\[^\\]|[^/\\])*/', String.Regex), # regular expressions
|
| 71 |
+
],
|
| 72 |
+
'identifiers': [
|
| 73 |
+
(r'[a-zA-Z_]\w*', Name.Variable),
|
| 74 |
+
],
|
| 75 |
+
'operators': [
|
| 76 |
+
(r',', Operator), # Join
|
| 77 |
+
(r'\||&|--?', Operator), # Union, Intersection and Subtraction
|
| 78 |
+
(r'\.|<:|:>>?', Operator), # Concatention
|
| 79 |
+
(r':', Operator), # Label
|
| 80 |
+
(r'->', Operator), # Epsilon Transition
|
| 81 |
+
(r'(>|\$|%|<|@|<>)(/|eof\b)', Operator), # EOF Actions
|
| 82 |
+
(r'(>|\$|%|<|@|<>)(!|err\b)', Operator), # Global Error Actions
|
| 83 |
+
(r'(>|\$|%|<|@|<>)(\^|lerr\b)', Operator), # Local Error Actions
|
| 84 |
+
(r'(>|\$|%|<|@|<>)(~|to\b)', Operator), # To-State Actions
|
| 85 |
+
(r'(>|\$|%|<|@|<>)(\*|from\b)', Operator), # From-State Actions
|
| 86 |
+
(r'>|@|\$|%', Operator), # Transition Actions and Priorities
|
| 87 |
+
(r'\*|\?|\+|\{[0-9]*,[0-9]*\}', Operator), # Repetition
|
| 88 |
+
(r'!|\^', Operator), # Negation
|
| 89 |
+
(r'\(|\)', Operator), # Grouping
|
| 90 |
+
],
|
| 91 |
+
'root': [
|
| 92 |
+
include('literals'),
|
| 93 |
+
include('whitespace'),
|
| 94 |
+
include('comments'),
|
| 95 |
+
include('keywords'),
|
| 96 |
+
include('numbers'),
|
| 97 |
+
include('identifiers'),
|
| 98 |
+
include('operators'),
|
| 99 |
+
(r'\{', Punctuation, 'host'),
|
| 100 |
+
(r'=', Operator),
|
| 101 |
+
(r';', Punctuation),
|
| 102 |
+
],
|
| 103 |
+
'host': [
|
| 104 |
+
(r'(' + r'|'.join(( # keep host code in largest possible chunks
|
| 105 |
+
r'[^{}\'"/#]+', # exclude unsafe characters
|
| 106 |
+
r'[^\\]\\[{}]', # allow escaped { or }
|
| 107 |
+
|
| 108 |
+
# strings and comments may safely contain unsafe characters
|
| 109 |
+
r'"(\\\\|\\[^\\]|[^"\\])*"',
|
| 110 |
+
r"'(\\\\|\\[^\\]|[^'\\])*'",
|
| 111 |
+
r'//.*$\n?', # single line comment
|
| 112 |
+
r'/\*(.|\n)*?\*/', # multi-line javadoc-style comment
|
| 113 |
+
r'\#.*$\n?', # ruby comment
|
| 114 |
+
|
| 115 |
+
# regular expression: There's no reason for it to start
|
| 116 |
+
# with a * and this stops confusion with comments.
|
| 117 |
+
r'/(?!\*)(\\\\|\\[^\\]|[^/\\])*/',
|
| 118 |
+
|
| 119 |
+
# / is safe now that we've handled regex and javadoc comments
|
| 120 |
+
r'/',
|
| 121 |
+
)) + r')+', Other),
|
| 122 |
+
|
| 123 |
+
(r'\{', Punctuation, '#push'),
|
| 124 |
+
(r'\}', Punctuation, '#pop'),
|
| 125 |
+
],
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
class RagelEmbeddedLexer(RegexLexer):
|
| 130 |
+
"""
|
| 131 |
+
A lexer for Ragel embedded in a host language file.
|
| 132 |
+
|
| 133 |
+
This will only highlight Ragel statements. If you want host language
|
| 134 |
+
highlighting then call the language-specific Ragel lexer.
|
| 135 |
+
"""
|
| 136 |
+
|
| 137 |
+
name = 'Embedded Ragel'
|
| 138 |
+
aliases = ['ragel-em']
|
| 139 |
+
filenames = ['*.rl']
|
| 140 |
+
url = 'http://www.colm.net/open-source/ragel/'
|
| 141 |
+
version_added = '1.1'
|
| 142 |
+
|
| 143 |
+
tokens = {
|
| 144 |
+
'root': [
|
| 145 |
+
(r'(' + r'|'.join(( # keep host code in largest possible chunks
|
| 146 |
+
r'[^%\'"/#]+', # exclude unsafe characters
|
| 147 |
+
r'%(?=[^%]|$)', # a single % sign is okay, just not 2 of them
|
| 148 |
+
|
| 149 |
+
# strings and comments may safely contain unsafe characters
|
| 150 |
+
r'"(\\\\|\\[^\\]|[^"\\])*"',
|
| 151 |
+
r"'(\\\\|\\[^\\]|[^'\\])*'",
|
| 152 |
+
r'/\*(.|\n)*?\*/', # multi-line javadoc-style comment
|
| 153 |
+
r'//.*$\n?', # single line comment
|
| 154 |
+
r'\#.*$\n?', # ruby/ragel comment
|
| 155 |
+
r'/(?!\*)(\\\\|\\[^\\]|[^/\\])*/', # regular expression
|
| 156 |
+
|
| 157 |
+
# / is safe now that we've handled regex and javadoc comments
|
| 158 |
+
r'/',
|
| 159 |
+
)) + r')+', Other),
|
| 160 |
+
|
| 161 |
+
# Single Line FSM.
|
| 162 |
+
# Please don't put a quoted newline in a single line FSM.
|
| 163 |
+
# That's just mean. It will break this.
|
| 164 |
+
(r'(%%)(?![{%])(.*)($|;)(\n?)', bygroups(Punctuation,
|
| 165 |
+
using(RagelLexer),
|
| 166 |
+
Punctuation, Text)),
|
| 167 |
+
|
| 168 |
+
# Multi Line FSM.
|
| 169 |
+
(r'(%%%%|%%)\{', Punctuation, 'multi-line-fsm'),
|
| 170 |
+
],
|
| 171 |
+
'multi-line-fsm': [
|
| 172 |
+
(r'(' + r'|'.join(( # keep ragel code in largest possible chunks.
|
| 173 |
+
r'(' + r'|'.join((
|
| 174 |
+
r'[^}\'"\[/#]', # exclude unsafe characters
|
| 175 |
+
r'\}(?=[^%]|$)', # } is okay as long as it's not followed by %
|
| 176 |
+
r'\}%(?=[^%]|$)', # ...well, one %'s okay, just not two...
|
| 177 |
+
r'[^\\]\\[{}]', # ...and } is okay if it's escaped
|
| 178 |
+
|
| 179 |
+
# allow / if it's preceded with one of these symbols
|
| 180 |
+
# (ragel EOF actions)
|
| 181 |
+
r'(>|\$|%|<|@|<>)/',
|
| 182 |
+
|
| 183 |
+
# specifically allow regex followed immediately by *
|
| 184 |
+
# so it doesn't get mistaken for a comment
|
| 185 |
+
r'/(?!\*)(\\\\|\\[^\\]|[^/\\])*/\*',
|
| 186 |
+
|
| 187 |
+
# allow / as long as it's not followed by another / or by a *
|
| 188 |
+
r'/(?=[^/*]|$)',
|
| 189 |
+
|
| 190 |
+
# We want to match as many of these as we can in one block.
|
| 191 |
+
# Not sure if we need the + sign here,
|
| 192 |
+
# does it help performance?
|
| 193 |
+
)) + r')+',
|
| 194 |
+
|
| 195 |
+
# strings and comments may safely contain unsafe characters
|
| 196 |
+
r'"(\\\\|\\[^\\]|[^"\\])*"',
|
| 197 |
+
r"'(\\\\|\\[^\\]|[^'\\])*'",
|
| 198 |
+
r"\[(\\\\|\\[^\\]|[^\]\\])*\]", # square bracket literal
|
| 199 |
+
r'/\*(.|\n)*?\*/', # multi-line javadoc-style comment
|
| 200 |
+
r'//.*$\n?', # single line comment
|
| 201 |
+
r'\#.*$\n?', # ruby/ragel comment
|
| 202 |
+
)) + r')+', using(RagelLexer)),
|
| 203 |
+
|
| 204 |
+
(r'\}%%', Punctuation, '#pop'),
|
| 205 |
+
]
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
def analyse_text(text):
|
| 209 |
+
return '@LANG: indep' in text
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
class RagelRubyLexer(DelegatingLexer):
|
| 213 |
+
"""
|
| 214 |
+
A lexer for Ragel in a Ruby host file.
|
| 215 |
+
"""
|
| 216 |
+
|
| 217 |
+
name = 'Ragel in Ruby Host'
|
| 218 |
+
aliases = ['ragel-ruby', 'ragel-rb']
|
| 219 |
+
filenames = ['*.rl']
|
| 220 |
+
url = 'http://www.colm.net/open-source/ragel/'
|
| 221 |
+
version_added = '1.1'
|
| 222 |
+
|
| 223 |
+
def __init__(self, **options):
|
| 224 |
+
super().__init__(RubyLexer, RagelEmbeddedLexer, **options)
|
| 225 |
+
|
| 226 |
+
def analyse_text(text):
|
| 227 |
+
return '@LANG: ruby' in text
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
class RagelCLexer(DelegatingLexer):
|
| 231 |
+
"""
|
| 232 |
+
A lexer for Ragel in a C host file.
|
| 233 |
+
"""
|
| 234 |
+
|
| 235 |
+
name = 'Ragel in C Host'
|
| 236 |
+
aliases = ['ragel-c']
|
| 237 |
+
filenames = ['*.rl']
|
| 238 |
+
url = 'http://www.colm.net/open-source/ragel/'
|
| 239 |
+
version_added = '1.1'
|
| 240 |
+
|
| 241 |
+
def __init__(self, **options):
|
| 242 |
+
super().__init__(CLexer, RagelEmbeddedLexer, **options)
|
| 243 |
+
|
| 244 |
+
def analyse_text(text):
|
| 245 |
+
return '@LANG: c' in text
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
class RagelDLexer(DelegatingLexer):
|
| 249 |
+
"""
|
| 250 |
+
A lexer for Ragel in a D host file.
|
| 251 |
+
"""
|
| 252 |
+
|
| 253 |
+
name = 'Ragel in D Host'
|
| 254 |
+
aliases = ['ragel-d']
|
| 255 |
+
filenames = ['*.rl']
|
| 256 |
+
url = 'http://www.colm.net/open-source/ragel/'
|
| 257 |
+
version_added = '1.1'
|
| 258 |
+
|
| 259 |
+
def __init__(self, **options):
|
| 260 |
+
super().__init__(DLexer, RagelEmbeddedLexer, **options)
|
| 261 |
+
|
| 262 |
+
def analyse_text(text):
|
| 263 |
+
return '@LANG: d' in text
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
class RagelCppLexer(DelegatingLexer):
|
| 267 |
+
"""
|
| 268 |
+
A lexer for Ragel in a C++ host file.
|
| 269 |
+
"""
|
| 270 |
+
|
| 271 |
+
name = 'Ragel in CPP Host'
|
| 272 |
+
aliases = ['ragel-cpp']
|
| 273 |
+
filenames = ['*.rl']
|
| 274 |
+
url = 'http://www.colm.net/open-source/ragel/'
|
| 275 |
+
version_added = '1.1'
|
| 276 |
+
|
| 277 |
+
def __init__(self, **options):
|
| 278 |
+
super().__init__(CppLexer, RagelEmbeddedLexer, **options)
|
| 279 |
+
|
| 280 |
+
def analyse_text(text):
|
| 281 |
+
return '@LANG: c++' in text
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
class RagelObjectiveCLexer(DelegatingLexer):
|
| 285 |
+
"""
|
| 286 |
+
A lexer for Ragel in an Objective C host file.
|
| 287 |
+
"""
|
| 288 |
+
|
| 289 |
+
name = 'Ragel in Objective C Host'
|
| 290 |
+
aliases = ['ragel-objc']
|
| 291 |
+
filenames = ['*.rl']
|
| 292 |
+
url = 'http://www.colm.net/open-source/ragel/'
|
| 293 |
+
version_added = '1.1'
|
| 294 |
+
|
| 295 |
+
def __init__(self, **options):
|
| 296 |
+
super().__init__(ObjectiveCLexer, RagelEmbeddedLexer, **options)
|
| 297 |
+
|
| 298 |
+
def analyse_text(text):
|
| 299 |
+
return '@LANG: objc' in text
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
class RagelJavaLexer(DelegatingLexer):
|
| 303 |
+
"""
|
| 304 |
+
A lexer for Ragel in a Java host file.
|
| 305 |
+
"""
|
| 306 |
+
|
| 307 |
+
name = 'Ragel in Java Host'
|
| 308 |
+
aliases = ['ragel-java']
|
| 309 |
+
filenames = ['*.rl']
|
| 310 |
+
url = 'http://www.colm.net/open-source/ragel/'
|
| 311 |
+
version_added = '1.1'
|
| 312 |
+
|
| 313 |
+
def __init__(self, **options):
|
| 314 |
+
super().__init__(JavaLexer, RagelEmbeddedLexer, **options)
|
| 315 |
+
|
| 316 |
+
def analyse_text(text):
|
| 317 |
+
return '@LANG: java' in text
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
class AntlrLexer(RegexLexer):
|
| 321 |
+
"""
|
| 322 |
+
Generic ANTLR Lexer.
|
| 323 |
+
Should not be called directly, instead
|
| 324 |
+
use DelegatingLexer for your target language.
|
| 325 |
+
"""
|
| 326 |
+
|
| 327 |
+
name = 'ANTLR'
|
| 328 |
+
aliases = ['antlr']
|
| 329 |
+
filenames = []
|
| 330 |
+
url = 'https://www.antlr.org'
|
| 331 |
+
version_added = '1.1'
|
| 332 |
+
|
| 333 |
+
_id = r'[A-Za-z]\w*'
|
| 334 |
+
_TOKEN_REF = r'[A-Z]\w*'
|
| 335 |
+
_RULE_REF = r'[a-z]\w*'
|
| 336 |
+
_STRING_LITERAL = r'\'(?:\\\\|\\\'|[^\']*)\''
|
| 337 |
+
_INT = r'[0-9]+'
|
| 338 |
+
|
| 339 |
+
tokens = {
|
| 340 |
+
'whitespace': [
|
| 341 |
+
(r'\s+', Whitespace),
|
| 342 |
+
],
|
| 343 |
+
'comments': [
|
| 344 |
+
(r'//.*$', Comment),
|
| 345 |
+
(r'/\*(.|\n)*?\*/', Comment),
|
| 346 |
+
],
|
| 347 |
+
'root': [
|
| 348 |
+
include('whitespace'),
|
| 349 |
+
include('comments'),
|
| 350 |
+
|
| 351 |
+
(r'(lexer|parser|tree)?(\s*)(grammar\b)(\s*)(' + _id + ')(;)',
|
| 352 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Class,
|
| 353 |
+
Punctuation)),
|
| 354 |
+
# optionsSpec
|
| 355 |
+
(r'options\b', Keyword, 'options'),
|
| 356 |
+
# tokensSpec
|
| 357 |
+
(r'tokens\b', Keyword, 'tokens'),
|
| 358 |
+
# attrScope
|
| 359 |
+
(r'(scope)(\s*)(' + _id + r')(\s*)(\{)',
|
| 360 |
+
bygroups(Keyword, Whitespace, Name.Variable, Whitespace,
|
| 361 |
+
Punctuation), 'action'),
|
| 362 |
+
# exception
|
| 363 |
+
(r'(catch|finally)\b', Keyword, 'exception'),
|
| 364 |
+
# action
|
| 365 |
+
(r'(@' + _id + r')(\s*)(::)?(\s*)(' + _id + r')(\s*)(\{)',
|
| 366 |
+
bygroups(Name.Label, Whitespace, Punctuation, Whitespace,
|
| 367 |
+
Name.Label, Whitespace, Punctuation), 'action'),
|
| 368 |
+
# rule
|
| 369 |
+
(r'((?:protected|private|public|fragment)\b)?(\s*)(' + _id + ')(!)?',
|
| 370 |
+
bygroups(Keyword, Whitespace, Name.Label, Punctuation),
|
| 371 |
+
('rule-alts', 'rule-prelims')),
|
| 372 |
+
],
|
| 373 |
+
'exception': [
|
| 374 |
+
(r'\n', Whitespace, '#pop'),
|
| 375 |
+
(r'\s', Whitespace),
|
| 376 |
+
include('comments'),
|
| 377 |
+
|
| 378 |
+
(r'\[', Punctuation, 'nested-arg-action'),
|
| 379 |
+
(r'\{', Punctuation, 'action'),
|
| 380 |
+
],
|
| 381 |
+
'rule-prelims': [
|
| 382 |
+
include('whitespace'),
|
| 383 |
+
include('comments'),
|
| 384 |
+
|
| 385 |
+
(r'returns\b', Keyword),
|
| 386 |
+
(r'\[', Punctuation, 'nested-arg-action'),
|
| 387 |
+
(r'\{', Punctuation, 'action'),
|
| 388 |
+
# throwsSpec
|
| 389 |
+
(r'(throws)(\s+)(' + _id + ')',
|
| 390 |
+
bygroups(Keyword, Whitespace, Name.Label)),
|
| 391 |
+
(r'(,)(\s*)(' + _id + ')',
|
| 392 |
+
bygroups(Punctuation, Whitespace, Name.Label)), # Additional throws
|
| 393 |
+
# optionsSpec
|
| 394 |
+
(r'options\b', Keyword, 'options'),
|
| 395 |
+
# ruleScopeSpec - scope followed by target language code or name of action
|
| 396 |
+
# TODO finish implementing other possibilities for scope
|
| 397 |
+
# L173 ANTLRv3.g from ANTLR book
|
| 398 |
+
(r'(scope)(\s+)(\{)', bygroups(Keyword, Whitespace, Punctuation),
|
| 399 |
+
'action'),
|
| 400 |
+
(r'(scope)(\s+)(' + _id + r')(\s*)(;)',
|
| 401 |
+
bygroups(Keyword, Whitespace, Name.Label, Whitespace, Punctuation)),
|
| 402 |
+
# ruleAction
|
| 403 |
+
(r'(@' + _id + r')(\s*)(\{)',
|
| 404 |
+
bygroups(Name.Label, Whitespace, Punctuation), 'action'),
|
| 405 |
+
# finished prelims, go to rule alts!
|
| 406 |
+
(r':', Punctuation, '#pop')
|
| 407 |
+
],
|
| 408 |
+
'rule-alts': [
|
| 409 |
+
include('whitespace'),
|
| 410 |
+
include('comments'),
|
| 411 |
+
|
| 412 |
+
# These might need to go in a separate 'block' state triggered by (
|
| 413 |
+
(r'options\b', Keyword, 'options'),
|
| 414 |
+
(r':', Punctuation),
|
| 415 |
+
|
| 416 |
+
# literals
|
| 417 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 418 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 419 |
+
(r'<<([^>]|>[^>])>>', String),
|
| 420 |
+
# identifiers
|
| 421 |
+
# Tokens start with capital letter.
|
| 422 |
+
(r'\$?[A-Z_]\w*', Name.Constant),
|
| 423 |
+
# Rules start with small letter.
|
| 424 |
+
(r'\$?[a-z_]\w*', Name.Variable),
|
| 425 |
+
# operators
|
| 426 |
+
(r'(\+|\||->|=>|=|\(|\)|\.\.|\.|\?|\*|\^|!|\#|~)', Operator),
|
| 427 |
+
(r',', Punctuation),
|
| 428 |
+
(r'\[', Punctuation, 'nested-arg-action'),
|
| 429 |
+
(r'\{', Punctuation, 'action'),
|
| 430 |
+
(r';', Punctuation, '#pop')
|
| 431 |
+
],
|
| 432 |
+
'tokens': [
|
| 433 |
+
include('whitespace'),
|
| 434 |
+
include('comments'),
|
| 435 |
+
(r'\{', Punctuation),
|
| 436 |
+
(r'(' + _TOKEN_REF + r')(\s*)(=)?(\s*)(' + _STRING_LITERAL
|
| 437 |
+
+ r')?(\s*)(;)',
|
| 438 |
+
bygroups(Name.Label, Whitespace, Punctuation, Whitespace,
|
| 439 |
+
String, Whitespace, Punctuation)),
|
| 440 |
+
(r'\}', Punctuation, '#pop'),
|
| 441 |
+
],
|
| 442 |
+
'options': [
|
| 443 |
+
include('whitespace'),
|
| 444 |
+
include('comments'),
|
| 445 |
+
(r'\{', Punctuation),
|
| 446 |
+
(r'(' + _id + r')(\s*)(=)(\s*)(' +
|
| 447 |
+
'|'.join((_id, _STRING_LITERAL, _INT, r'\*')) + r')(\s*)(;)',
|
| 448 |
+
bygroups(Name.Variable, Whitespace, Punctuation, Whitespace,
|
| 449 |
+
Text, Whitespace, Punctuation)),
|
| 450 |
+
(r'\}', Punctuation, '#pop'),
|
| 451 |
+
],
|
| 452 |
+
'action': [
|
| 453 |
+
(r'(' + r'|'.join(( # keep host code in largest possible chunks
|
| 454 |
+
r'[^${}\'"/\\]+', # exclude unsafe characters
|
| 455 |
+
|
| 456 |
+
# strings and comments may safely contain unsafe characters
|
| 457 |
+
r'"(\\\\|\\[^\\]|[^"\\])*"',
|
| 458 |
+
r"'(\\\\|\\[^\\]|[^'\\])*'",
|
| 459 |
+
r'//.*$\n?', # single line comment
|
| 460 |
+
r'/\*(.|\n)*?\*/', # multi-line javadoc-style comment
|
| 461 |
+
|
| 462 |
+
# regular expression: There's no reason for it to start
|
| 463 |
+
# with a * and this stops confusion with comments.
|
| 464 |
+
r'/(?!\*)(\\\\|\\[^\\]|[^/\\])*/',
|
| 465 |
+
|
| 466 |
+
# backslashes are okay, as long as we are not backslashing a %
|
| 467 |
+
r'\\(?!%)',
|
| 468 |
+
|
| 469 |
+
# Now that we've handled regex and javadoc comments
|
| 470 |
+
# it's safe to let / through.
|
| 471 |
+
r'/',
|
| 472 |
+
)) + r')+', Other),
|
| 473 |
+
(r'(\\)(%)', bygroups(Punctuation, Other)),
|
| 474 |
+
(r'(\$[a-zA-Z]+)(\.?)(text|value)?',
|
| 475 |
+
bygroups(Name.Variable, Punctuation, Name.Property)),
|
| 476 |
+
(r'\{', Punctuation, '#push'),
|
| 477 |
+
(r'\}', Punctuation, '#pop'),
|
| 478 |
+
],
|
| 479 |
+
'nested-arg-action': [
|
| 480 |
+
(r'(' + r'|'.join(( # keep host code in largest possible chunks.
|
| 481 |
+
r'[^$\[\]\'"/]+', # exclude unsafe characters
|
| 482 |
+
|
| 483 |
+
# strings and comments may safely contain unsafe characters
|
| 484 |
+
r'"(\\\\|\\[^\\]|[^"\\])*"',
|
| 485 |
+
r"'(\\\\|\\[^\\]|[^'\\])*'",
|
| 486 |
+
r'//.*$\n?', # single line comment
|
| 487 |
+
r'/\*(.|\n)*?\*/', # multi-line javadoc-style comment
|
| 488 |
+
|
| 489 |
+
# regular expression: There's no reason for it to start
|
| 490 |
+
# with a * and this stops confusion with comments.
|
| 491 |
+
r'/(?!\*)(\\\\|\\[^\\]|[^/\\])*/',
|
| 492 |
+
|
| 493 |
+
# Now that we've handled regex and javadoc comments
|
| 494 |
+
# it's safe to let / through.
|
| 495 |
+
r'/',
|
| 496 |
+
)) + r')+', Other),
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
(r'\[', Punctuation, '#push'),
|
| 500 |
+
(r'\]', Punctuation, '#pop'),
|
| 501 |
+
(r'(\$[a-zA-Z]+)(\.?)(text|value)?',
|
| 502 |
+
bygroups(Name.Variable, Punctuation, Name.Property)),
|
| 503 |
+
(r'(\\\\|\\\]|\\\[|[^\[\]])+', Other),
|
| 504 |
+
]
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
def analyse_text(text):
|
| 508 |
+
return re.search(r'^\s*grammar\s+[a-zA-Z0-9]+\s*;', text, re.M)
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
# http://www.antlr.org/wiki/display/ANTLR3/Code+Generation+Targets
|
| 512 |
+
|
| 513 |
+
class AntlrCppLexer(DelegatingLexer):
|
| 514 |
+
"""
|
| 515 |
+
ANTLR with C++ Target
|
| 516 |
+
"""
|
| 517 |
+
|
| 518 |
+
name = 'ANTLR With CPP Target'
|
| 519 |
+
aliases = ['antlr-cpp']
|
| 520 |
+
filenames = ['*.G', '*.g']
|
| 521 |
+
url = 'https://www.antlr.org'
|
| 522 |
+
version_added = '1.1'
|
| 523 |
+
|
| 524 |
+
def __init__(self, **options):
|
| 525 |
+
super().__init__(CppLexer, AntlrLexer, **options)
|
| 526 |
+
|
| 527 |
+
def analyse_text(text):
|
| 528 |
+
return AntlrLexer.analyse_text(text) and \
|
| 529 |
+
re.search(r'^\s*language\s*=\s*C\s*;', text, re.M)
|
| 530 |
+
|
| 531 |
+
|
| 532 |
+
class AntlrObjectiveCLexer(DelegatingLexer):
|
| 533 |
+
"""
|
| 534 |
+
ANTLR with Objective-C Target
|
| 535 |
+
"""
|
| 536 |
+
|
| 537 |
+
name = 'ANTLR With ObjectiveC Target'
|
| 538 |
+
aliases = ['antlr-objc']
|
| 539 |
+
filenames = ['*.G', '*.g']
|
| 540 |
+
url = 'https://www.antlr.org'
|
| 541 |
+
version_added = '1.1'
|
| 542 |
+
|
| 543 |
+
def __init__(self, **options):
|
| 544 |
+
super().__init__(ObjectiveCLexer, AntlrLexer, **options)
|
| 545 |
+
|
| 546 |
+
def analyse_text(text):
|
| 547 |
+
return AntlrLexer.analyse_text(text) and \
|
| 548 |
+
re.search(r'^\s*language\s*=\s*ObjC\s*;', text)
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
class AntlrCSharpLexer(DelegatingLexer):
|
| 552 |
+
"""
|
| 553 |
+
ANTLR with C# Target
|
| 554 |
+
"""
|
| 555 |
+
|
| 556 |
+
name = 'ANTLR With C# Target'
|
| 557 |
+
aliases = ['antlr-csharp', 'antlr-c#']
|
| 558 |
+
filenames = ['*.G', '*.g']
|
| 559 |
+
url = 'https://www.antlr.org'
|
| 560 |
+
version_added = '1.1'
|
| 561 |
+
|
| 562 |
+
def __init__(self, **options):
|
| 563 |
+
super().__init__(CSharpLexer, AntlrLexer, **options)
|
| 564 |
+
|
| 565 |
+
def analyse_text(text):
|
| 566 |
+
return AntlrLexer.analyse_text(text) and \
|
| 567 |
+
re.search(r'^\s*language\s*=\s*CSharp2\s*;', text, re.M)
|
| 568 |
+
|
| 569 |
+
|
| 570 |
+
class AntlrPythonLexer(DelegatingLexer):
|
| 571 |
+
"""
|
| 572 |
+
ANTLR with Python Target
|
| 573 |
+
"""
|
| 574 |
+
|
| 575 |
+
name = 'ANTLR With Python Target'
|
| 576 |
+
aliases = ['antlr-python']
|
| 577 |
+
filenames = ['*.G', '*.g']
|
| 578 |
+
url = 'https://www.antlr.org'
|
| 579 |
+
version_added = '1.1'
|
| 580 |
+
|
| 581 |
+
def __init__(self, **options):
|
| 582 |
+
super().__init__(PythonLexer, AntlrLexer, **options)
|
| 583 |
+
|
| 584 |
+
def analyse_text(text):
|
| 585 |
+
return AntlrLexer.analyse_text(text) and \
|
| 586 |
+
re.search(r'^\s*language\s*=\s*Python\s*;', text, re.M)
|
| 587 |
+
|
| 588 |
+
|
| 589 |
+
class AntlrJavaLexer(DelegatingLexer):
|
| 590 |
+
"""
|
| 591 |
+
ANTLR with Java Target
|
| 592 |
+
"""
|
| 593 |
+
|
| 594 |
+
name = 'ANTLR With Java Target'
|
| 595 |
+
aliases = ['antlr-java']
|
| 596 |
+
filenames = ['*.G', '*.g']
|
| 597 |
+
url = 'https://www.antlr.org'
|
| 598 |
+
version_added = '1.1'
|
| 599 |
+
|
| 600 |
+
def __init__(self, **options):
|
| 601 |
+
super().__init__(JavaLexer, AntlrLexer, **options)
|
| 602 |
+
|
| 603 |
+
def analyse_text(text):
|
| 604 |
+
# Antlr language is Java by default
|
| 605 |
+
return AntlrLexer.analyse_text(text) and 0.9
|
| 606 |
+
|
| 607 |
+
|
| 608 |
+
class AntlrRubyLexer(DelegatingLexer):
|
| 609 |
+
"""
|
| 610 |
+
ANTLR with Ruby Target
|
| 611 |
+
"""
|
| 612 |
+
|
| 613 |
+
name = 'ANTLR With Ruby Target'
|
| 614 |
+
aliases = ['antlr-ruby', 'antlr-rb']
|
| 615 |
+
filenames = ['*.G', '*.g']
|
| 616 |
+
url = 'https://www.antlr.org'
|
| 617 |
+
version_added = '1.1'
|
| 618 |
+
|
| 619 |
+
def __init__(self, **options):
|
| 620 |
+
super().__init__(RubyLexer, AntlrLexer, **options)
|
| 621 |
+
|
| 622 |
+
def analyse_text(text):
|
| 623 |
+
return AntlrLexer.analyse_text(text) and \
|
| 624 |
+
re.search(r'^\s*language\s*=\s*Ruby\s*;', text, re.M)
|
| 625 |
+
|
| 626 |
+
|
| 627 |
+
class AntlrPerlLexer(DelegatingLexer):
|
| 628 |
+
"""
|
| 629 |
+
ANTLR with Perl Target
|
| 630 |
+
"""
|
| 631 |
+
|
| 632 |
+
name = 'ANTLR With Perl Target'
|
| 633 |
+
aliases = ['antlr-perl']
|
| 634 |
+
filenames = ['*.G', '*.g']
|
| 635 |
+
url = 'https://www.antlr.org'
|
| 636 |
+
version_added = '1.1'
|
| 637 |
+
|
| 638 |
+
def __init__(self, **options):
|
| 639 |
+
super().__init__(PerlLexer, AntlrLexer, **options)
|
| 640 |
+
|
| 641 |
+
def analyse_text(text):
|
| 642 |
+
return AntlrLexer.analyse_text(text) and \
|
| 643 |
+
re.search(r'^\s*language\s*=\s*Perl5\s*;', text, re.M)
|
| 644 |
+
|
| 645 |
+
|
| 646 |
+
class AntlrActionScriptLexer(DelegatingLexer):
|
| 647 |
+
"""
|
| 648 |
+
ANTLR with ActionScript Target
|
| 649 |
+
"""
|
| 650 |
+
|
| 651 |
+
name = 'ANTLR With ActionScript Target'
|
| 652 |
+
aliases = ['antlr-actionscript', 'antlr-as']
|
| 653 |
+
filenames = ['*.G', '*.g']
|
| 654 |
+
url = 'https://www.antlr.org'
|
| 655 |
+
version_added = '1.1'
|
| 656 |
+
|
| 657 |
+
def __init__(self, **options):
|
| 658 |
+
from pygments.lexers.actionscript import ActionScriptLexer
|
| 659 |
+
super().__init__(ActionScriptLexer, AntlrLexer, **options)
|
| 660 |
+
|
| 661 |
+
def analyse_text(text):
|
| 662 |
+
return AntlrLexer.analyse_text(text) and \
|
| 663 |
+
re.search(r'^\s*language\s*=\s*ActionScript\s*;', text, re.M)
|
| 664 |
+
|
| 665 |
+
|
| 666 |
+
class TreetopBaseLexer(RegexLexer):
|
| 667 |
+
"""
|
| 668 |
+
A base lexer for `Treetop <http://treetop.rubyforge.org/>`_ grammars.
|
| 669 |
+
Not for direct use; use :class:`TreetopLexer` instead.
|
| 670 |
+
|
| 671 |
+
.. versionadded:: 1.6
|
| 672 |
+
"""
|
| 673 |
+
|
| 674 |
+
tokens = {
|
| 675 |
+
'root': [
|
| 676 |
+
include('space'),
|
| 677 |
+
(r'require[ \t]+[^\n\r]+[\n\r]', Other),
|
| 678 |
+
(r'module\b', Keyword.Namespace, 'module'),
|
| 679 |
+
(r'grammar\b', Keyword, 'grammar'),
|
| 680 |
+
],
|
| 681 |
+
'module': [
|
| 682 |
+
include('space'),
|
| 683 |
+
include('end'),
|
| 684 |
+
(r'module\b', Keyword, '#push'),
|
| 685 |
+
(r'grammar\b', Keyword, 'grammar'),
|
| 686 |
+
(r'[A-Z]\w*(?:::[A-Z]\w*)*', Name.Namespace),
|
| 687 |
+
],
|
| 688 |
+
'grammar': [
|
| 689 |
+
include('space'),
|
| 690 |
+
include('end'),
|
| 691 |
+
(r'rule\b', Keyword, 'rule'),
|
| 692 |
+
(r'include\b', Keyword, 'include'),
|
| 693 |
+
(r'[A-Z]\w*', Name),
|
| 694 |
+
],
|
| 695 |
+
'include': [
|
| 696 |
+
include('space'),
|
| 697 |
+
(r'[A-Z]\w*(?:::[A-Z]\w*)*', Name.Class, '#pop'),
|
| 698 |
+
],
|
| 699 |
+
'rule': [
|
| 700 |
+
include('space'),
|
| 701 |
+
include('end'),
|
| 702 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 703 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 704 |
+
(r'([A-Za-z_]\w*)(:)', bygroups(Name.Label, Punctuation)),
|
| 705 |
+
(r'[A-Za-z_]\w*', Name),
|
| 706 |
+
(r'[()]', Punctuation),
|
| 707 |
+
(r'[?+*/&!~]', Operator),
|
| 708 |
+
(r'\[(?:\\.|\[:\^?[a-z]+:\]|[^\\\]])+\]', String.Regex),
|
| 709 |
+
(r'([0-9]*)(\.\.)([0-9]*)',
|
| 710 |
+
bygroups(Number.Integer, Operator, Number.Integer)),
|
| 711 |
+
(r'(<)([^>]+)(>)', bygroups(Punctuation, Name.Class, Punctuation)),
|
| 712 |
+
(r'\{', Punctuation, 'inline_module'),
|
| 713 |
+
(r'\.', String.Regex),
|
| 714 |
+
],
|
| 715 |
+
'inline_module': [
|
| 716 |
+
(r'\{', Other, 'ruby'),
|
| 717 |
+
(r'\}', Punctuation, '#pop'),
|
| 718 |
+
(r'[^{}]+', Other),
|
| 719 |
+
],
|
| 720 |
+
'ruby': [
|
| 721 |
+
(r'\{', Other, '#push'),
|
| 722 |
+
(r'\}', Other, '#pop'),
|
| 723 |
+
(r'[^{}]+', Other),
|
| 724 |
+
],
|
| 725 |
+
'space': [
|
| 726 |
+
(r'[ \t\n\r]+', Whitespace),
|
| 727 |
+
(r'#[^\n]*', Comment.Single),
|
| 728 |
+
],
|
| 729 |
+
'end': [
|
| 730 |
+
(r'end\b', Keyword, '#pop'),
|
| 731 |
+
],
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
|
| 735 |
+
class TreetopLexer(DelegatingLexer):
|
| 736 |
+
"""
|
| 737 |
+
A lexer for Treetop grammars.
|
| 738 |
+
"""
|
| 739 |
+
|
| 740 |
+
name = 'Treetop'
|
| 741 |
+
aliases = ['treetop']
|
| 742 |
+
filenames = ['*.treetop', '*.tt']
|
| 743 |
+
url = 'https://cjheath.github.io/treetop'
|
| 744 |
+
version_added = '1.6'
|
| 745 |
+
|
| 746 |
+
def __init__(self, **options):
|
| 747 |
+
super().__init__(RubyLexer, TreetopBaseLexer, **options)
|
| 748 |
+
|
| 749 |
+
|
| 750 |
+
class EbnfLexer(RegexLexer):
|
| 751 |
+
"""
|
| 752 |
+
Lexer for `ISO/IEC 14977 EBNF
|
| 753 |
+
<https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form>`_
|
| 754 |
+
grammars.
|
| 755 |
+
"""
|
| 756 |
+
|
| 757 |
+
name = 'EBNF'
|
| 758 |
+
aliases = ['ebnf']
|
| 759 |
+
filenames = ['*.ebnf']
|
| 760 |
+
mimetypes = ['text/x-ebnf']
|
| 761 |
+
url = 'https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form'
|
| 762 |
+
version_added = '2.0'
|
| 763 |
+
|
| 764 |
+
tokens = {
|
| 765 |
+
'root': [
|
| 766 |
+
include('whitespace'),
|
| 767 |
+
include('comment_start'),
|
| 768 |
+
include('identifier'),
|
| 769 |
+
(r'=', Operator, 'production'),
|
| 770 |
+
],
|
| 771 |
+
'production': [
|
| 772 |
+
include('whitespace'),
|
| 773 |
+
include('comment_start'),
|
| 774 |
+
include('identifier'),
|
| 775 |
+
(r'"[^"]*"', String.Double),
|
| 776 |
+
(r"'[^']*'", String.Single),
|
| 777 |
+
(r'(\?[^?]*\?)', Name.Entity),
|
| 778 |
+
(r'[\[\]{}(),|]', Punctuation),
|
| 779 |
+
(r'-', Operator),
|
| 780 |
+
(r';', Punctuation, '#pop'),
|
| 781 |
+
(r'\.', Punctuation, '#pop'),
|
| 782 |
+
],
|
| 783 |
+
'whitespace': [
|
| 784 |
+
(r'\s+', Text),
|
| 785 |
+
],
|
| 786 |
+
'comment_start': [
|
| 787 |
+
(r'\(\*', Comment.Multiline, 'comment'),
|
| 788 |
+
],
|
| 789 |
+
'comment': [
|
| 790 |
+
(r'[^*)]', Comment.Multiline),
|
| 791 |
+
include('comment_start'),
|
| 792 |
+
(r'\*\)', Comment.Multiline, '#pop'),
|
| 793 |
+
(r'[*)]', Comment.Multiline),
|
| 794 |
+
],
|
| 795 |
+
'identifier': [
|
| 796 |
+
(r'([a-zA-Z][\w \-]*)', Keyword),
|
| 797 |
+
],
|
| 798 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pascal.py
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.pascal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Pascal family languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import Lexer
|
| 14 |
+
from pygments.util import get_bool_opt, get_list_opt
|
| 15 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Error, Whitespace
|
| 17 |
+
from pygments.scanner import Scanner
|
| 18 |
+
|
| 19 |
+
# compatibility import
|
| 20 |
+
from pygments.lexers.modula2 import Modula2Lexer # noqa: F401
|
| 21 |
+
|
| 22 |
+
__all__ = ['DelphiLexer', 'PortugolLexer']
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class PortugolLexer(Lexer):
|
| 26 |
+
"""For Portugol, a Pascal dialect with keywords in Portuguese."""
|
| 27 |
+
name = 'Portugol'
|
| 28 |
+
aliases = ['portugol']
|
| 29 |
+
filenames = ['*.alg', '*.portugol']
|
| 30 |
+
mimetypes = []
|
| 31 |
+
url = "https://www.apoioinformatica.inf.br/produtos/visualg/linguagem"
|
| 32 |
+
version_added = ''
|
| 33 |
+
|
| 34 |
+
def __init__(self, **options):
|
| 35 |
+
Lexer.__init__(self, **options)
|
| 36 |
+
self.lexer = DelphiLexer(**options, portugol=True)
|
| 37 |
+
|
| 38 |
+
def get_tokens_unprocessed(self, text):
|
| 39 |
+
return self.lexer.get_tokens_unprocessed(text)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class DelphiLexer(Lexer):
|
| 43 |
+
"""
|
| 44 |
+
For Delphi (Borland Object Pascal),
|
| 45 |
+
Turbo Pascal and Free Pascal source code.
|
| 46 |
+
|
| 47 |
+
Additional options accepted:
|
| 48 |
+
|
| 49 |
+
`turbopascal`
|
| 50 |
+
Highlight Turbo Pascal specific keywords (default: ``True``).
|
| 51 |
+
`delphi`
|
| 52 |
+
Highlight Borland Delphi specific keywords (default: ``True``).
|
| 53 |
+
`freepascal`
|
| 54 |
+
Highlight Free Pascal specific keywords (default: ``True``).
|
| 55 |
+
`units`
|
| 56 |
+
A list of units that should be considered builtin, supported are
|
| 57 |
+
``System``, ``SysUtils``, ``Classes`` and ``Math``.
|
| 58 |
+
Default is to consider all of them builtin.
|
| 59 |
+
"""
|
| 60 |
+
name = 'Delphi'
|
| 61 |
+
aliases = ['delphi', 'pas', 'pascal', 'objectpascal']
|
| 62 |
+
filenames = ['*.pas', '*.dpr']
|
| 63 |
+
mimetypes = ['text/x-pascal']
|
| 64 |
+
url = 'https://www.embarcadero.com/products/delphi'
|
| 65 |
+
version_added = ''
|
| 66 |
+
|
| 67 |
+
TURBO_PASCAL_KEYWORDS = (
|
| 68 |
+
'absolute', 'and', 'array', 'asm', 'begin', 'break', 'case',
|
| 69 |
+
'const', 'constructor', 'continue', 'destructor', 'div', 'do',
|
| 70 |
+
'downto', 'else', 'end', 'file', 'for', 'function', 'goto',
|
| 71 |
+
'if', 'implementation', 'in', 'inherited', 'inline', 'interface',
|
| 72 |
+
'label', 'mod', 'nil', 'not', 'object', 'of', 'on', 'operator',
|
| 73 |
+
'or', 'packed', 'procedure', 'program', 'record', 'reintroduce',
|
| 74 |
+
'repeat', 'self', 'set', 'shl', 'shr', 'string', 'then', 'to',
|
| 75 |
+
'type', 'unit', 'until', 'uses', 'var', 'while', 'with', 'xor'
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
DELPHI_KEYWORDS = (
|
| 79 |
+
'as', 'class', 'except', 'exports', 'finalization', 'finally',
|
| 80 |
+
'initialization', 'is', 'library', 'on', 'property', 'raise',
|
| 81 |
+
'threadvar', 'try'
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
FREE_PASCAL_KEYWORDS = (
|
| 85 |
+
'dispose', 'exit', 'false', 'new', 'true'
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
BLOCK_KEYWORDS = {
|
| 89 |
+
'begin', 'class', 'const', 'constructor', 'destructor', 'end',
|
| 90 |
+
'finalization', 'function', 'implementation', 'initialization',
|
| 91 |
+
'label', 'library', 'operator', 'procedure', 'program', 'property',
|
| 92 |
+
'record', 'threadvar', 'type', 'unit', 'uses', 'var'
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
FUNCTION_MODIFIERS = {
|
| 96 |
+
'alias', 'cdecl', 'export', 'inline', 'interrupt', 'nostackframe',
|
| 97 |
+
'pascal', 'register', 'safecall', 'softfloat', 'stdcall',
|
| 98 |
+
'varargs', 'name', 'dynamic', 'near', 'virtual', 'external',
|
| 99 |
+
'override', 'assembler'
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
# XXX: those aren't global. but currently we know no way for defining
|
| 103 |
+
# them just for the type context.
|
| 104 |
+
DIRECTIVES = {
|
| 105 |
+
'absolute', 'abstract', 'assembler', 'cppdecl', 'default', 'far',
|
| 106 |
+
'far16', 'forward', 'index', 'oldfpccall', 'private', 'protected',
|
| 107 |
+
'published', 'public'
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
BUILTIN_TYPES = {
|
| 111 |
+
'ansichar', 'ansistring', 'bool', 'boolean', 'byte', 'bytebool',
|
| 112 |
+
'cardinal', 'char', 'comp', 'currency', 'double', 'dword',
|
| 113 |
+
'extended', 'int64', 'integer', 'iunknown', 'longbool', 'longint',
|
| 114 |
+
'longword', 'pansichar', 'pansistring', 'pbool', 'pboolean',
|
| 115 |
+
'pbyte', 'pbytearray', 'pcardinal', 'pchar', 'pcomp', 'pcurrency',
|
| 116 |
+
'pdate', 'pdatetime', 'pdouble', 'pdword', 'pextended', 'phandle',
|
| 117 |
+
'pint64', 'pinteger', 'plongint', 'plongword', 'pointer',
|
| 118 |
+
'ppointer', 'pshortint', 'pshortstring', 'psingle', 'psmallint',
|
| 119 |
+
'pstring', 'pvariant', 'pwidechar', 'pwidestring', 'pword',
|
| 120 |
+
'pwordarray', 'pwordbool', 'real', 'real48', 'shortint',
|
| 121 |
+
'shortstring', 'single', 'smallint', 'string', 'tclass', 'tdate',
|
| 122 |
+
'tdatetime', 'textfile', 'thandle', 'tobject', 'ttime', 'variant',
|
| 123 |
+
'widechar', 'widestring', 'word', 'wordbool'
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
BUILTIN_UNITS = {
|
| 127 |
+
'System': (
|
| 128 |
+
'abs', 'acquireexceptionobject', 'addr', 'ansitoutf8',
|
| 129 |
+
'append', 'arctan', 'assert', 'assigned', 'assignfile',
|
| 130 |
+
'beginthread', 'blockread', 'blockwrite', 'break', 'chdir',
|
| 131 |
+
'chr', 'close', 'closefile', 'comptocurrency', 'comptodouble',
|
| 132 |
+
'concat', 'continue', 'copy', 'cos', 'dec', 'delete',
|
| 133 |
+
'dispose', 'doubletocomp', 'endthread', 'enummodules',
|
| 134 |
+
'enumresourcemodules', 'eof', 'eoln', 'erase', 'exceptaddr',
|
| 135 |
+
'exceptobject', 'exclude', 'exit', 'exp', 'filepos', 'filesize',
|
| 136 |
+
'fillchar', 'finalize', 'findclasshinstance', 'findhinstance',
|
| 137 |
+
'findresourcehinstance', 'flush', 'frac', 'freemem',
|
| 138 |
+
'get8087cw', 'getdir', 'getlasterror', 'getmem',
|
| 139 |
+
'getmemorymanager', 'getmodulefilename', 'getvariantmanager',
|
| 140 |
+
'halt', 'hi', 'high', 'inc', 'include', 'initialize', 'insert',
|
| 141 |
+
'int', 'ioresult', 'ismemorymanagerset', 'isvariantmanagerset',
|
| 142 |
+
'length', 'ln', 'lo', 'low', 'mkdir', 'move', 'new', 'odd',
|
| 143 |
+
'olestrtostring', 'olestrtostrvar', 'ord', 'paramcount',
|
| 144 |
+
'paramstr', 'pi', 'pos', 'pred', 'ptr', 'pucs4chars', 'random',
|
| 145 |
+
'randomize', 'read', 'readln', 'reallocmem',
|
| 146 |
+
'releaseexceptionobject', 'rename', 'reset', 'rewrite', 'rmdir',
|
| 147 |
+
'round', 'runerror', 'seek', 'seekeof', 'seekeoln',
|
| 148 |
+
'set8087cw', 'setlength', 'setlinebreakstyle',
|
| 149 |
+
'setmemorymanager', 'setstring', 'settextbuf',
|
| 150 |
+
'setvariantmanager', 'sin', 'sizeof', 'slice', 'sqr', 'sqrt',
|
| 151 |
+
'str', 'stringofchar', 'stringtoolestr', 'stringtowidechar',
|
| 152 |
+
'succ', 'swap', 'trunc', 'truncate', 'typeinfo',
|
| 153 |
+
'ucs4stringtowidestring', 'unicodetoutf8', 'uniquestring',
|
| 154 |
+
'upcase', 'utf8decode', 'utf8encode', 'utf8toansi',
|
| 155 |
+
'utf8tounicode', 'val', 'vararrayredim', 'varclear',
|
| 156 |
+
'widecharlentostring', 'widecharlentostrvar',
|
| 157 |
+
'widechartostring', 'widechartostrvar',
|
| 158 |
+
'widestringtoucs4string', 'write', 'writeln'
|
| 159 |
+
),
|
| 160 |
+
'SysUtils': (
|
| 161 |
+
'abort', 'addexitproc', 'addterminateproc', 'adjustlinebreaks',
|
| 162 |
+
'allocmem', 'ansicomparefilename', 'ansicomparestr',
|
| 163 |
+
'ansicomparetext', 'ansidequotedstr', 'ansiextractquotedstr',
|
| 164 |
+
'ansilastchar', 'ansilowercase', 'ansilowercasefilename',
|
| 165 |
+
'ansipos', 'ansiquotedstr', 'ansisamestr', 'ansisametext',
|
| 166 |
+
'ansistrcomp', 'ansistricomp', 'ansistrlastchar', 'ansistrlcomp',
|
| 167 |
+
'ansistrlicomp', 'ansistrlower', 'ansistrpos', 'ansistrrscan',
|
| 168 |
+
'ansistrscan', 'ansistrupper', 'ansiuppercase',
|
| 169 |
+
'ansiuppercasefilename', 'appendstr', 'assignstr', 'beep',
|
| 170 |
+
'booltostr', 'bytetocharindex', 'bytetocharlen', 'bytetype',
|
| 171 |
+
'callterminateprocs', 'changefileext', 'charlength',
|
| 172 |
+
'chartobyteindex', 'chartobytelen', 'comparemem', 'comparestr',
|
| 173 |
+
'comparetext', 'createdir', 'createguid', 'currentyear',
|
| 174 |
+
'currtostr', 'currtostrf', 'date', 'datetimetofiledate',
|
| 175 |
+
'datetimetostr', 'datetimetostring', 'datetimetosystemtime',
|
| 176 |
+
'datetimetotimestamp', 'datetostr', 'dayofweek', 'decodedate',
|
| 177 |
+
'decodedatefully', 'decodetime', 'deletefile', 'directoryexists',
|
| 178 |
+
'diskfree', 'disksize', 'disposestr', 'encodedate', 'encodetime',
|
| 179 |
+
'exceptionerrormessage', 'excludetrailingbackslash',
|
| 180 |
+
'excludetrailingpathdelimiter', 'expandfilename',
|
| 181 |
+
'expandfilenamecase', 'expanduncfilename', 'extractfiledir',
|
| 182 |
+
'extractfiledrive', 'extractfileext', 'extractfilename',
|
| 183 |
+
'extractfilepath', 'extractrelativepath', 'extractshortpathname',
|
| 184 |
+
'fileage', 'fileclose', 'filecreate', 'filedatetodatetime',
|
| 185 |
+
'fileexists', 'filegetattr', 'filegetdate', 'fileisreadonly',
|
| 186 |
+
'fileopen', 'fileread', 'filesearch', 'fileseek', 'filesetattr',
|
| 187 |
+
'filesetdate', 'filesetreadonly', 'filewrite', 'finalizepackage',
|
| 188 |
+
'findclose', 'findcmdlineswitch', 'findfirst', 'findnext',
|
| 189 |
+
'floattocurr', 'floattodatetime', 'floattodecimal', 'floattostr',
|
| 190 |
+
'floattostrf', 'floattotext', 'floattotextfmt', 'fmtloadstr',
|
| 191 |
+
'fmtstr', 'forcedirectories', 'format', 'formatbuf', 'formatcurr',
|
| 192 |
+
'formatdatetime', 'formatfloat', 'freeandnil', 'getcurrentdir',
|
| 193 |
+
'getenvironmentvariable', 'getfileversion', 'getformatsettings',
|
| 194 |
+
'getlocaleformatsettings', 'getmodulename', 'getpackagedescription',
|
| 195 |
+
'getpackageinfo', 'gettime', 'guidtostring', 'incamonth',
|
| 196 |
+
'includetrailingbackslash', 'includetrailingpathdelimiter',
|
| 197 |
+
'incmonth', 'initializepackage', 'interlockeddecrement',
|
| 198 |
+
'interlockedexchange', 'interlockedexchangeadd',
|
| 199 |
+
'interlockedincrement', 'inttohex', 'inttostr', 'isdelimiter',
|
| 200 |
+
'isequalguid', 'isleapyear', 'ispathdelimiter', 'isvalidident',
|
| 201 |
+
'languages', 'lastdelimiter', 'loadpackage', 'loadstr',
|
| 202 |
+
'lowercase', 'msecstotimestamp', 'newstr', 'nextcharindex', 'now',
|
| 203 |
+
'outofmemoryerror', 'quotedstr', 'raiselastoserror',
|
| 204 |
+
'raiselastwin32error', 'removedir', 'renamefile', 'replacedate',
|
| 205 |
+
'replacetime', 'safeloadlibrary', 'samefilename', 'sametext',
|
| 206 |
+
'setcurrentdir', 'showexception', 'sleep', 'stralloc', 'strbufsize',
|
| 207 |
+
'strbytetype', 'strcat', 'strcharlength', 'strcomp', 'strcopy',
|
| 208 |
+
'strdispose', 'strecopy', 'strend', 'strfmt', 'stricomp',
|
| 209 |
+
'stringreplace', 'stringtoguid', 'strlcat', 'strlcomp', 'strlcopy',
|
| 210 |
+
'strlen', 'strlfmt', 'strlicomp', 'strlower', 'strmove', 'strnew',
|
| 211 |
+
'strnextchar', 'strpas', 'strpcopy', 'strplcopy', 'strpos',
|
| 212 |
+
'strrscan', 'strscan', 'strtobool', 'strtobooldef', 'strtocurr',
|
| 213 |
+
'strtocurrdef', 'strtodate', 'strtodatedef', 'strtodatetime',
|
| 214 |
+
'strtodatetimedef', 'strtofloat', 'strtofloatdef', 'strtoint',
|
| 215 |
+
'strtoint64', 'strtoint64def', 'strtointdef', 'strtotime',
|
| 216 |
+
'strtotimedef', 'strupper', 'supports', 'syserrormessage',
|
| 217 |
+
'systemtimetodatetime', 'texttofloat', 'time', 'timestamptodatetime',
|
| 218 |
+
'timestamptomsecs', 'timetostr', 'trim', 'trimleft', 'trimright',
|
| 219 |
+
'tryencodedate', 'tryencodetime', 'tryfloattocurr', 'tryfloattodatetime',
|
| 220 |
+
'trystrtobool', 'trystrtocurr', 'trystrtodate', 'trystrtodatetime',
|
| 221 |
+
'trystrtofloat', 'trystrtoint', 'trystrtoint64', 'trystrtotime',
|
| 222 |
+
'unloadpackage', 'uppercase', 'widecomparestr', 'widecomparetext',
|
| 223 |
+
'widefmtstr', 'wideformat', 'wideformatbuf', 'widelowercase',
|
| 224 |
+
'widesamestr', 'widesametext', 'wideuppercase', 'win32check',
|
| 225 |
+
'wraptext'
|
| 226 |
+
),
|
| 227 |
+
'Classes': (
|
| 228 |
+
'activateclassgroup', 'allocatehwnd', 'bintohex', 'checksynchronize',
|
| 229 |
+
'collectionsequal', 'countgenerations', 'deallocatehwnd', 'equalrect',
|
| 230 |
+
'extractstrings', 'findclass', 'findglobalcomponent', 'getclass',
|
| 231 |
+
'groupdescendantswith', 'hextobin', 'identtoint',
|
| 232 |
+
'initinheritedcomponent', 'inttoident', 'invalidpoint',
|
| 233 |
+
'isuniqueglobalcomponentname', 'linestart', 'objectbinarytotext',
|
| 234 |
+
'objectresourcetotext', 'objecttexttobinary', 'objecttexttoresource',
|
| 235 |
+
'pointsequal', 'readcomponentres', 'readcomponentresex',
|
| 236 |
+
'readcomponentresfile', 'rect', 'registerclass', 'registerclassalias',
|
| 237 |
+
'registerclasses', 'registercomponents', 'registerintegerconsts',
|
| 238 |
+
'registernoicon', 'registernonactivex', 'smallpoint', 'startclassgroup',
|
| 239 |
+
'teststreamformat', 'unregisterclass', 'unregisterclasses',
|
| 240 |
+
'unregisterintegerconsts', 'unregistermoduleclasses',
|
| 241 |
+
'writecomponentresfile'
|
| 242 |
+
),
|
| 243 |
+
'Math': (
|
| 244 |
+
'arccos', 'arccosh', 'arccot', 'arccoth', 'arccsc', 'arccsch', 'arcsec',
|
| 245 |
+
'arcsech', 'arcsin', 'arcsinh', 'arctan2', 'arctanh', 'ceil',
|
| 246 |
+
'comparevalue', 'cosecant', 'cosh', 'cot', 'cotan', 'coth', 'csc',
|
| 247 |
+
'csch', 'cycletodeg', 'cycletograd', 'cycletorad', 'degtocycle',
|
| 248 |
+
'degtograd', 'degtorad', 'divmod', 'doubledecliningbalance',
|
| 249 |
+
'ensurerange', 'floor', 'frexp', 'futurevalue', 'getexceptionmask',
|
| 250 |
+
'getprecisionmode', 'getroundmode', 'gradtocycle', 'gradtodeg',
|
| 251 |
+
'gradtorad', 'hypot', 'inrange', 'interestpayment', 'interestrate',
|
| 252 |
+
'internalrateofreturn', 'intpower', 'isinfinite', 'isnan', 'iszero',
|
| 253 |
+
'ldexp', 'lnxp1', 'log10', 'log2', 'logn', 'max', 'maxintvalue',
|
| 254 |
+
'maxvalue', 'mean', 'meanandstddev', 'min', 'minintvalue', 'minvalue',
|
| 255 |
+
'momentskewkurtosis', 'netpresentvalue', 'norm', 'numberofperiods',
|
| 256 |
+
'payment', 'periodpayment', 'poly', 'popnstddev', 'popnvariance',
|
| 257 |
+
'power', 'presentvalue', 'radtocycle', 'radtodeg', 'radtograd',
|
| 258 |
+
'randg', 'randomrange', 'roundto', 'samevalue', 'sec', 'secant',
|
| 259 |
+
'sech', 'setexceptionmask', 'setprecisionmode', 'setroundmode',
|
| 260 |
+
'sign', 'simpleroundto', 'sincos', 'sinh', 'slndepreciation', 'stddev',
|
| 261 |
+
'sum', 'sumint', 'sumofsquares', 'sumsandsquares', 'syddepreciation',
|
| 262 |
+
'tan', 'tanh', 'totalvariance', 'variance'
|
| 263 |
+
)
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
ASM_REGISTERS = {
|
| 267 |
+
'ah', 'al', 'ax', 'bh', 'bl', 'bp', 'bx', 'ch', 'cl', 'cr0',
|
| 268 |
+
'cr1', 'cr2', 'cr3', 'cr4', 'cs', 'cx', 'dh', 'di', 'dl', 'dr0',
|
| 269 |
+
'dr1', 'dr2', 'dr3', 'dr4', 'dr5', 'dr6', 'dr7', 'ds', 'dx',
|
| 270 |
+
'eax', 'ebp', 'ebx', 'ecx', 'edi', 'edx', 'es', 'esi', 'esp',
|
| 271 |
+
'fs', 'gs', 'mm0', 'mm1', 'mm2', 'mm3', 'mm4', 'mm5', 'mm6',
|
| 272 |
+
'mm7', 'si', 'sp', 'ss', 'st0', 'st1', 'st2', 'st3', 'st4', 'st5',
|
| 273 |
+
'st6', 'st7', 'xmm0', 'xmm1', 'xmm2', 'xmm3', 'xmm4', 'xmm5',
|
| 274 |
+
'xmm6', 'xmm7'
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
ASM_INSTRUCTIONS = {
|
| 278 |
+
'aaa', 'aad', 'aam', 'aas', 'adc', 'add', 'and', 'arpl', 'bound',
|
| 279 |
+
'bsf', 'bsr', 'bswap', 'bt', 'btc', 'btr', 'bts', 'call', 'cbw',
|
| 280 |
+
'cdq', 'clc', 'cld', 'cli', 'clts', 'cmc', 'cmova', 'cmovae',
|
| 281 |
+
'cmovb', 'cmovbe', 'cmovc', 'cmovcxz', 'cmove', 'cmovg',
|
| 282 |
+
'cmovge', 'cmovl', 'cmovle', 'cmovna', 'cmovnae', 'cmovnb',
|
| 283 |
+
'cmovnbe', 'cmovnc', 'cmovne', 'cmovng', 'cmovnge', 'cmovnl',
|
| 284 |
+
'cmovnle', 'cmovno', 'cmovnp', 'cmovns', 'cmovnz', 'cmovo',
|
| 285 |
+
'cmovp', 'cmovpe', 'cmovpo', 'cmovs', 'cmovz', 'cmp', 'cmpsb',
|
| 286 |
+
'cmpsd', 'cmpsw', 'cmpxchg', 'cmpxchg486', 'cmpxchg8b', 'cpuid',
|
| 287 |
+
'cwd', 'cwde', 'daa', 'das', 'dec', 'div', 'emms', 'enter', 'hlt',
|
| 288 |
+
'ibts', 'icebp', 'idiv', 'imul', 'in', 'inc', 'insb', 'insd',
|
| 289 |
+
'insw', 'int', 'int01', 'int03', 'int1', 'int3', 'into', 'invd',
|
| 290 |
+
'invlpg', 'iret', 'iretd', 'iretw', 'ja', 'jae', 'jb', 'jbe',
|
| 291 |
+
'jc', 'jcxz', 'jcxz', 'je', 'jecxz', 'jg', 'jge', 'jl', 'jle',
|
| 292 |
+
'jmp', 'jna', 'jnae', 'jnb', 'jnbe', 'jnc', 'jne', 'jng', 'jnge',
|
| 293 |
+
'jnl', 'jnle', 'jno', 'jnp', 'jns', 'jnz', 'jo', 'jp', 'jpe',
|
| 294 |
+
'jpo', 'js', 'jz', 'lahf', 'lar', 'lcall', 'lds', 'lea', 'leave',
|
| 295 |
+
'les', 'lfs', 'lgdt', 'lgs', 'lidt', 'ljmp', 'lldt', 'lmsw',
|
| 296 |
+
'loadall', 'loadall286', 'lock', 'lodsb', 'lodsd', 'lodsw',
|
| 297 |
+
'loop', 'loope', 'loopne', 'loopnz', 'loopz', 'lsl', 'lss', 'ltr',
|
| 298 |
+
'mov', 'movd', 'movq', 'movsb', 'movsd', 'movsw', 'movsx',
|
| 299 |
+
'movzx', 'mul', 'neg', 'nop', 'not', 'or', 'out', 'outsb', 'outsd',
|
| 300 |
+
'outsw', 'pop', 'popa', 'popad', 'popaw', 'popf', 'popfd', 'popfw',
|
| 301 |
+
'push', 'pusha', 'pushad', 'pushaw', 'pushf', 'pushfd', 'pushfw',
|
| 302 |
+
'rcl', 'rcr', 'rdmsr', 'rdpmc', 'rdshr', 'rdtsc', 'rep', 'repe',
|
| 303 |
+
'repne', 'repnz', 'repz', 'ret', 'retf', 'retn', 'rol', 'ror',
|
| 304 |
+
'rsdc', 'rsldt', 'rsm', 'sahf', 'sal', 'salc', 'sar', 'sbb',
|
| 305 |
+
'scasb', 'scasd', 'scasw', 'seta', 'setae', 'setb', 'setbe',
|
| 306 |
+
'setc', 'setcxz', 'sete', 'setg', 'setge', 'setl', 'setle',
|
| 307 |
+
'setna', 'setnae', 'setnb', 'setnbe', 'setnc', 'setne', 'setng',
|
| 308 |
+
'setnge', 'setnl', 'setnle', 'setno', 'setnp', 'setns', 'setnz',
|
| 309 |
+
'seto', 'setp', 'setpe', 'setpo', 'sets', 'setz', 'sgdt', 'shl',
|
| 310 |
+
'shld', 'shr', 'shrd', 'sidt', 'sldt', 'smi', 'smint', 'smintold',
|
| 311 |
+
'smsw', 'stc', 'std', 'sti', 'stosb', 'stosd', 'stosw', 'str',
|
| 312 |
+
'sub', 'svdc', 'svldt', 'svts', 'syscall', 'sysenter', 'sysexit',
|
| 313 |
+
'sysret', 'test', 'ud1', 'ud2', 'umov', 'verr', 'verw', 'wait',
|
| 314 |
+
'wbinvd', 'wrmsr', 'wrshr', 'xadd', 'xbts', 'xchg', 'xlat',
|
| 315 |
+
'xlatb', 'xor'
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
PORTUGOL_KEYWORDS = (
|
| 319 |
+
'aleatorio',
|
| 320 |
+
'algoritmo',
|
| 321 |
+
'arquivo',
|
| 322 |
+
'ate',
|
| 323 |
+
'caso',
|
| 324 |
+
'cronometro',
|
| 325 |
+
'debug',
|
| 326 |
+
'e',
|
| 327 |
+
'eco',
|
| 328 |
+
'enquanto',
|
| 329 |
+
'entao',
|
| 330 |
+
'escolha',
|
| 331 |
+
'escreva',
|
| 332 |
+
'escreval',
|
| 333 |
+
'faca',
|
| 334 |
+
'falso',
|
| 335 |
+
'fimalgoritmo',
|
| 336 |
+
'fimenquanto',
|
| 337 |
+
'fimescolha',
|
| 338 |
+
'fimfuncao',
|
| 339 |
+
'fimpara',
|
| 340 |
+
'fimprocedimento',
|
| 341 |
+
'fimrepita',
|
| 342 |
+
'fimse',
|
| 343 |
+
'funcao',
|
| 344 |
+
'inicio',
|
| 345 |
+
'int',
|
| 346 |
+
'interrompa',
|
| 347 |
+
'leia',
|
| 348 |
+
'limpatela',
|
| 349 |
+
'mod',
|
| 350 |
+
'nao',
|
| 351 |
+
'ou',
|
| 352 |
+
'outrocaso',
|
| 353 |
+
'para',
|
| 354 |
+
'passo',
|
| 355 |
+
'pausa',
|
| 356 |
+
'procedimento',
|
| 357 |
+
'repita',
|
| 358 |
+
'retorne',
|
| 359 |
+
'se',
|
| 360 |
+
'senao',
|
| 361 |
+
'timer',
|
| 362 |
+
'var',
|
| 363 |
+
'vetor',
|
| 364 |
+
'verdadeiro',
|
| 365 |
+
'xou',
|
| 366 |
+
'div',
|
| 367 |
+
'mod',
|
| 368 |
+
'abs',
|
| 369 |
+
'arccos',
|
| 370 |
+
'arcsen',
|
| 371 |
+
'arctan',
|
| 372 |
+
'cos',
|
| 373 |
+
'cotan',
|
| 374 |
+
'Exp',
|
| 375 |
+
'grauprad',
|
| 376 |
+
'int',
|
| 377 |
+
'log',
|
| 378 |
+
'logn',
|
| 379 |
+
'pi',
|
| 380 |
+
'quad',
|
| 381 |
+
'radpgrau',
|
| 382 |
+
'raizq',
|
| 383 |
+
'rand',
|
| 384 |
+
'randi',
|
| 385 |
+
'sen',
|
| 386 |
+
'Tan',
|
| 387 |
+
'asc',
|
| 388 |
+
'carac',
|
| 389 |
+
'caracpnum',
|
| 390 |
+
'compr',
|
| 391 |
+
'copia',
|
| 392 |
+
'maiusc',
|
| 393 |
+
'minusc',
|
| 394 |
+
'numpcarac',
|
| 395 |
+
'pos',
|
| 396 |
+
)
|
| 397 |
+
|
| 398 |
+
PORTUGOL_BUILTIN_TYPES = {
|
| 399 |
+
'inteiro', 'real', 'caractere', 'logico'
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
def __init__(self, **options):
|
| 403 |
+
Lexer.__init__(self, **options)
|
| 404 |
+
self.keywords = set()
|
| 405 |
+
self.builtins = set()
|
| 406 |
+
if get_bool_opt(options, 'portugol', False):
|
| 407 |
+
self.keywords.update(self.PORTUGOL_KEYWORDS)
|
| 408 |
+
self.builtins.update(self.PORTUGOL_BUILTIN_TYPES)
|
| 409 |
+
self.is_portugol = True
|
| 410 |
+
else:
|
| 411 |
+
self.is_portugol = False
|
| 412 |
+
|
| 413 |
+
if get_bool_opt(options, 'turbopascal', True):
|
| 414 |
+
self.keywords.update(self.TURBO_PASCAL_KEYWORDS)
|
| 415 |
+
if get_bool_opt(options, 'delphi', True):
|
| 416 |
+
self.keywords.update(self.DELPHI_KEYWORDS)
|
| 417 |
+
if get_bool_opt(options, 'freepascal', True):
|
| 418 |
+
self.keywords.update(self.FREE_PASCAL_KEYWORDS)
|
| 419 |
+
for unit in get_list_opt(options, 'units', list(self.BUILTIN_UNITS)):
|
| 420 |
+
self.builtins.update(self.BUILTIN_UNITS[unit])
|
| 421 |
+
|
| 422 |
+
def get_tokens_unprocessed(self, text):
|
| 423 |
+
scanner = Scanner(text, re.DOTALL | re.MULTILINE | re.IGNORECASE)
|
| 424 |
+
stack = ['initial']
|
| 425 |
+
in_function_block = False
|
| 426 |
+
in_property_block = False
|
| 427 |
+
was_dot = False
|
| 428 |
+
next_token_is_function = False
|
| 429 |
+
next_token_is_property = False
|
| 430 |
+
collect_labels = False
|
| 431 |
+
block_labels = set()
|
| 432 |
+
brace_balance = [0, 0]
|
| 433 |
+
|
| 434 |
+
while not scanner.eos:
|
| 435 |
+
token = Error
|
| 436 |
+
|
| 437 |
+
if stack[-1] == 'initial':
|
| 438 |
+
if scanner.scan(r'\s+'):
|
| 439 |
+
token = Whitespace
|
| 440 |
+
elif not self.is_portugol and scanner.scan(r'\{.*?\}|\(\*.*?\*\)'):
|
| 441 |
+
if scanner.match.startswith('$'):
|
| 442 |
+
token = Comment.Preproc
|
| 443 |
+
else:
|
| 444 |
+
token = Comment.Multiline
|
| 445 |
+
elif scanner.scan(r'//.*?$'):
|
| 446 |
+
token = Comment.Single
|
| 447 |
+
elif self.is_portugol and scanner.scan(r'(<\-)|(>=)|(<=)|%|<|>|-|\+|\*|\=|(<>)|\/|\.|:|,'):
|
| 448 |
+
token = Operator
|
| 449 |
+
elif not self.is_portugol and scanner.scan(r'[-+*\/=<>:;,.@\^]'):
|
| 450 |
+
token = Operator
|
| 451 |
+
# stop label highlighting on next ";"
|
| 452 |
+
if collect_labels and scanner.match == ';':
|
| 453 |
+
collect_labels = False
|
| 454 |
+
elif scanner.scan(r'[\(\)\[\]]+'):
|
| 455 |
+
token = Punctuation
|
| 456 |
+
# abort function naming ``foo = Function(...)``
|
| 457 |
+
next_token_is_function = False
|
| 458 |
+
# if we are in a function block we count the open
|
| 459 |
+
# braces because ootherwise it's impossible to
|
| 460 |
+
# determine the end of the modifier context
|
| 461 |
+
if in_function_block or in_property_block:
|
| 462 |
+
if scanner.match == '(':
|
| 463 |
+
brace_balance[0] += 1
|
| 464 |
+
elif scanner.match == ')':
|
| 465 |
+
brace_balance[0] -= 1
|
| 466 |
+
elif scanner.match == '[':
|
| 467 |
+
brace_balance[1] += 1
|
| 468 |
+
elif scanner.match == ']':
|
| 469 |
+
brace_balance[1] -= 1
|
| 470 |
+
elif scanner.scan(r'[A-Za-z_][A-Za-z_0-9]*'):
|
| 471 |
+
lowercase_name = scanner.match.lower()
|
| 472 |
+
if lowercase_name == 'result':
|
| 473 |
+
token = Name.Builtin.Pseudo
|
| 474 |
+
elif lowercase_name in self.keywords:
|
| 475 |
+
token = Keyword
|
| 476 |
+
# if we are in a special block and a
|
| 477 |
+
# block ending keyword occurs (and the parenthesis
|
| 478 |
+
# is balanced) we end the current block context
|
| 479 |
+
if self.is_portugol:
|
| 480 |
+
if lowercase_name in ('funcao', 'procedimento'):
|
| 481 |
+
in_function_block = True
|
| 482 |
+
next_token_is_function = True
|
| 483 |
+
else:
|
| 484 |
+
if (in_function_block or in_property_block) and \
|
| 485 |
+
lowercase_name in self.BLOCK_KEYWORDS and \
|
| 486 |
+
brace_balance[0] <= 0 and \
|
| 487 |
+
brace_balance[1] <= 0:
|
| 488 |
+
in_function_block = False
|
| 489 |
+
in_property_block = False
|
| 490 |
+
brace_balance = [0, 0]
|
| 491 |
+
block_labels = set()
|
| 492 |
+
if lowercase_name in ('label', 'goto'):
|
| 493 |
+
collect_labels = True
|
| 494 |
+
elif lowercase_name == 'asm':
|
| 495 |
+
stack.append('asm')
|
| 496 |
+
elif lowercase_name == 'property':
|
| 497 |
+
in_property_block = True
|
| 498 |
+
next_token_is_property = True
|
| 499 |
+
elif lowercase_name in ('procedure', 'operator',
|
| 500 |
+
'function', 'constructor',
|
| 501 |
+
'destructor'):
|
| 502 |
+
in_function_block = True
|
| 503 |
+
next_token_is_function = True
|
| 504 |
+
# we are in a function block and the current name
|
| 505 |
+
# is in the set of registered modifiers. highlight
|
| 506 |
+
# it as pseudo keyword
|
| 507 |
+
elif not self.is_portugol and in_function_block and \
|
| 508 |
+
lowercase_name in self.FUNCTION_MODIFIERS:
|
| 509 |
+
token = Keyword.Pseudo
|
| 510 |
+
# if we are in a property highlight some more
|
| 511 |
+
# modifiers
|
| 512 |
+
elif not self.is_portugol and in_property_block and \
|
| 513 |
+
lowercase_name in ('read', 'write'):
|
| 514 |
+
token = Keyword.Pseudo
|
| 515 |
+
next_token_is_function = True
|
| 516 |
+
# if the last iteration set next_token_is_function
|
| 517 |
+
# to true we now want this name highlighted as
|
| 518 |
+
# function. so do that and reset the state
|
| 519 |
+
elif next_token_is_function:
|
| 520 |
+
# Look if the next token is a dot. If yes it's
|
| 521 |
+
# not a function, but a class name and the
|
| 522 |
+
# part after the dot a function name
|
| 523 |
+
if not self.is_portugol and scanner.test(r'\s*\.\s*'):
|
| 524 |
+
token = Name.Class
|
| 525 |
+
# it's not a dot, our job is done
|
| 526 |
+
else:
|
| 527 |
+
token = Name.Function
|
| 528 |
+
next_token_is_function = False
|
| 529 |
+
|
| 530 |
+
if self.is_portugol:
|
| 531 |
+
block_labels.add(scanner.match.lower())
|
| 532 |
+
|
| 533 |
+
# same for properties
|
| 534 |
+
elif not self.is_portugol and next_token_is_property:
|
| 535 |
+
token = Name.Property
|
| 536 |
+
next_token_is_property = False
|
| 537 |
+
# Highlight this token as label and add it
|
| 538 |
+
# to the list of known labels
|
| 539 |
+
elif not self.is_portugol and collect_labels:
|
| 540 |
+
token = Name.Label
|
| 541 |
+
block_labels.add(scanner.match.lower())
|
| 542 |
+
# name is in list of known labels
|
| 543 |
+
elif lowercase_name in block_labels:
|
| 544 |
+
token = Name.Label
|
| 545 |
+
elif self.is_portugol and lowercase_name in self.PORTUGOL_BUILTIN_TYPES:
|
| 546 |
+
token = Keyword.Type
|
| 547 |
+
elif not self.is_portugol and lowercase_name in self.BUILTIN_TYPES:
|
| 548 |
+
token = Keyword.Type
|
| 549 |
+
elif not self.is_portugol and lowercase_name in self.DIRECTIVES:
|
| 550 |
+
token = Keyword.Pseudo
|
| 551 |
+
# builtins are just builtins if the token
|
| 552 |
+
# before isn't a dot
|
| 553 |
+
elif not self.is_portugol and not was_dot and lowercase_name in self.builtins:
|
| 554 |
+
token = Name.Builtin
|
| 555 |
+
else:
|
| 556 |
+
token = Name
|
| 557 |
+
elif self.is_portugol and scanner.scan(r"\""):
|
| 558 |
+
token = String
|
| 559 |
+
stack.append('string')
|
| 560 |
+
elif not self.is_portugol and scanner.scan(r"'"):
|
| 561 |
+
token = String
|
| 562 |
+
stack.append('string')
|
| 563 |
+
elif not self.is_portugol and scanner.scan(r'\#(\d+|\$[0-9A-Fa-f]+)'):
|
| 564 |
+
token = String.Char
|
| 565 |
+
elif not self.is_portugol and scanner.scan(r'\$[0-9A-Fa-f]+'):
|
| 566 |
+
token = Number.Hex
|
| 567 |
+
elif scanner.scan(r'\d+(?![eE]|\.[^.])'):
|
| 568 |
+
token = Number.Integer
|
| 569 |
+
elif scanner.scan(r'\d+(\.\d+([eE][+-]?\d+)?|[eE][+-]?\d+)'):
|
| 570 |
+
token = Number.Float
|
| 571 |
+
else:
|
| 572 |
+
# if the stack depth is deeper than once, pop
|
| 573 |
+
if len(stack) > 1:
|
| 574 |
+
stack.pop()
|
| 575 |
+
scanner.get_char()
|
| 576 |
+
|
| 577 |
+
elif stack[-1] == 'string':
|
| 578 |
+
if self.is_portugol:
|
| 579 |
+
if scanner.scan(r"''"):
|
| 580 |
+
token = String.Escape
|
| 581 |
+
elif scanner.scan(r"\""):
|
| 582 |
+
token = String
|
| 583 |
+
stack.pop()
|
| 584 |
+
elif scanner.scan(r"[^\"]*"):
|
| 585 |
+
token = String
|
| 586 |
+
else:
|
| 587 |
+
scanner.get_char()
|
| 588 |
+
stack.pop()
|
| 589 |
+
else:
|
| 590 |
+
if scanner.scan(r"''"):
|
| 591 |
+
token = String.Escape
|
| 592 |
+
elif scanner.scan(r"'"):
|
| 593 |
+
token = String
|
| 594 |
+
stack.pop()
|
| 595 |
+
elif scanner.scan(r"[^']*"):
|
| 596 |
+
token = String
|
| 597 |
+
else:
|
| 598 |
+
scanner.get_char()
|
| 599 |
+
stack.pop()
|
| 600 |
+
elif not self.is_portugol and stack[-1] == 'asm':
|
| 601 |
+
if scanner.scan(r'\s+'):
|
| 602 |
+
token = Whitespace
|
| 603 |
+
elif scanner.scan(r'end'):
|
| 604 |
+
token = Keyword
|
| 605 |
+
stack.pop()
|
| 606 |
+
elif scanner.scan(r'\{.*?\}|\(\*.*?\*\)'):
|
| 607 |
+
if scanner.match.startswith('$'):
|
| 608 |
+
token = Comment.Preproc
|
| 609 |
+
else:
|
| 610 |
+
token = Comment.Multiline
|
| 611 |
+
elif scanner.scan(r'//.*?$'):
|
| 612 |
+
token = Comment.Single
|
| 613 |
+
elif scanner.scan(r"'"):
|
| 614 |
+
token = String
|
| 615 |
+
stack.append('string')
|
| 616 |
+
elif scanner.scan(r'@@[A-Za-z_][A-Za-z_0-9]*'):
|
| 617 |
+
token = Name.Label
|
| 618 |
+
elif scanner.scan(r'[A-Za-z_][A-Za-z_0-9]*'):
|
| 619 |
+
lowercase_name = scanner.match.lower()
|
| 620 |
+
if lowercase_name in self.ASM_INSTRUCTIONS:
|
| 621 |
+
token = Keyword
|
| 622 |
+
elif lowercase_name in self.ASM_REGISTERS:
|
| 623 |
+
token = Name.Builtin
|
| 624 |
+
else:
|
| 625 |
+
token = Name
|
| 626 |
+
elif scanner.scan(r'[-+*\/=<>:;,.@\^]+'):
|
| 627 |
+
token = Operator
|
| 628 |
+
elif scanner.scan(r'[\(\)\[\]]+'):
|
| 629 |
+
token = Punctuation
|
| 630 |
+
elif scanner.scan(r'\$[0-9A-Fa-f]+'):
|
| 631 |
+
token = Number.Hex
|
| 632 |
+
elif scanner.scan(r'\d+(?![eE]|\.[^.])'):
|
| 633 |
+
token = Number.Integer
|
| 634 |
+
elif scanner.scan(r'\d+(\.\d+([eE][+-]?\d+)?|[eE][+-]?\d+)'):
|
| 635 |
+
token = Number.Float
|
| 636 |
+
else:
|
| 637 |
+
scanner.get_char()
|
| 638 |
+
stack.pop()
|
| 639 |
+
|
| 640 |
+
# save the dot!!!11
|
| 641 |
+
if not self.is_portugol and scanner.match.strip():
|
| 642 |
+
was_dot = scanner.match == '.'
|
| 643 |
+
|
| 644 |
+
yield scanner.start_pos, token, scanner.match or ''
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pawn.py
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.pawn
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Pawn languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation
|
| 14 |
+
from pygments.util import get_bool_opt
|
| 15 |
+
|
| 16 |
+
__all__ = ['SourcePawnLexer', 'PawnLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class SourcePawnLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
For SourcePawn source code with preprocessor directives.
|
| 22 |
+
"""
|
| 23 |
+
name = 'SourcePawn'
|
| 24 |
+
aliases = ['sp']
|
| 25 |
+
filenames = ['*.sp']
|
| 26 |
+
mimetypes = ['text/x-sourcepawn']
|
| 27 |
+
url = 'https://github.com/alliedmodders/sourcepawn'
|
| 28 |
+
version_added = '1.6'
|
| 29 |
+
|
| 30 |
+
#: optional Comment or Whitespace
|
| 31 |
+
_ws = r'(?:\s|//.*?\n|/\*.*?\*/)+'
|
| 32 |
+
#: only one /* */ style comment
|
| 33 |
+
_ws1 = r'\s*(?:/[*].*?[*]/\s*)*'
|
| 34 |
+
|
| 35 |
+
tokens = {
|
| 36 |
+
'root': [
|
| 37 |
+
# preprocessor directives: without whitespace
|
| 38 |
+
(r'^#if\s+0', Comment.Preproc, 'if0'),
|
| 39 |
+
('^#', Comment.Preproc, 'macro'),
|
| 40 |
+
# or with whitespace
|
| 41 |
+
('^' + _ws1 + r'#if\s+0', Comment.Preproc, 'if0'),
|
| 42 |
+
('^' + _ws1 + '#', Comment.Preproc, 'macro'),
|
| 43 |
+
(r'\n', Text),
|
| 44 |
+
(r'\s+', Text),
|
| 45 |
+
(r'\\\n', Text), # line continuation
|
| 46 |
+
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
| 47 |
+
(r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
|
| 48 |
+
(r'[{}]', Punctuation),
|
| 49 |
+
(r'L?"', String, 'string'),
|
| 50 |
+
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
| 51 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
|
| 52 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 53 |
+
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
| 54 |
+
(r'0[0-7]+[LlUu]*', Number.Oct),
|
| 55 |
+
(r'\d+[LlUu]*', Number.Integer),
|
| 56 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 57 |
+
(r'[()\[\],.;]', Punctuation),
|
| 58 |
+
(r'(case|const|continue|native|'
|
| 59 |
+
r'default|else|enum|for|if|new|operator|'
|
| 60 |
+
r'public|return|sizeof|static|decl|struct|switch)\b', Keyword),
|
| 61 |
+
(r'(bool|Float)\b', Keyword.Type),
|
| 62 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 63 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 64 |
+
],
|
| 65 |
+
'string': [
|
| 66 |
+
(r'"', String, '#pop'),
|
| 67 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
| 68 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 69 |
+
(r'\\\n', String), # line continuation
|
| 70 |
+
(r'\\', String), # stray backslash
|
| 71 |
+
],
|
| 72 |
+
'macro': [
|
| 73 |
+
(r'[^/\n]+', Comment.Preproc),
|
| 74 |
+
(r'/\*(.|\n)*?\*/', Comment.Multiline),
|
| 75 |
+
(r'//.*?\n', Comment.Single, '#pop'),
|
| 76 |
+
(r'/', Comment.Preproc),
|
| 77 |
+
(r'(?<=\\)\n', Comment.Preproc),
|
| 78 |
+
(r'\n', Comment.Preproc, '#pop'),
|
| 79 |
+
],
|
| 80 |
+
'if0': [
|
| 81 |
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
| 82 |
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
| 83 |
+
(r'.*?\n', Comment),
|
| 84 |
+
]
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
SM_TYPES = {'Action', 'bool', 'Float', 'Plugin', 'String', 'any',
|
| 88 |
+
'AdminFlag', 'OverrideType', 'OverrideRule', 'ImmunityType',
|
| 89 |
+
'GroupId', 'AdminId', 'AdmAccessMode', 'AdminCachePart',
|
| 90 |
+
'CookieAccess', 'CookieMenu', 'CookieMenuAction', 'NetFlow',
|
| 91 |
+
'ConVarBounds', 'QueryCookie', 'ReplySource',
|
| 92 |
+
'ConVarQueryResult', 'ConVarQueryFinished', 'Function',
|
| 93 |
+
'Action', 'Identity', 'PluginStatus', 'PluginInfo', 'DBResult',
|
| 94 |
+
'DBBindType', 'DBPriority', 'PropType', 'PropFieldType',
|
| 95 |
+
'MoveType', 'RenderMode', 'RenderFx', 'EventHookMode',
|
| 96 |
+
'EventHook', 'FileType', 'FileTimeMode', 'PathType',
|
| 97 |
+
'ParamType', 'ExecType', 'DialogType', 'Handle', 'KvDataTypes',
|
| 98 |
+
'NominateResult', 'MapChange', 'MenuStyle', 'MenuAction',
|
| 99 |
+
'MenuSource', 'RegexError', 'SDKCallType', 'SDKLibrary',
|
| 100 |
+
'SDKFuncConfSource', 'SDKType', 'SDKPassMethod', 'RayType',
|
| 101 |
+
'TraceEntityFilter', 'ListenOverride', 'SortOrder', 'SortType',
|
| 102 |
+
'SortFunc2D', 'APLRes', 'FeatureType', 'FeatureStatus',
|
| 103 |
+
'SMCResult', 'SMCError', 'TFClassType', 'TFTeam', 'TFCond',
|
| 104 |
+
'TFResourceType', 'Timer', 'TopMenuAction', 'TopMenuObjectType',
|
| 105 |
+
'TopMenuPosition', 'TopMenuObject', 'UserMsg'}
|
| 106 |
+
|
| 107 |
+
def __init__(self, **options):
|
| 108 |
+
self.smhighlighting = get_bool_opt(options,
|
| 109 |
+
'sourcemod', True)
|
| 110 |
+
|
| 111 |
+
self._functions = set()
|
| 112 |
+
if self.smhighlighting:
|
| 113 |
+
from pygments.lexers._sourcemod_builtins import FUNCTIONS
|
| 114 |
+
self._functions.update(FUNCTIONS)
|
| 115 |
+
RegexLexer.__init__(self, **options)
|
| 116 |
+
|
| 117 |
+
def get_tokens_unprocessed(self, text):
|
| 118 |
+
for index, token, value in \
|
| 119 |
+
RegexLexer.get_tokens_unprocessed(self, text):
|
| 120 |
+
if token is Name:
|
| 121 |
+
if self.smhighlighting:
|
| 122 |
+
if value in self.SM_TYPES:
|
| 123 |
+
token = Keyword.Type
|
| 124 |
+
elif value in self._functions:
|
| 125 |
+
token = Name.Builtin
|
| 126 |
+
yield index, token, value
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
class PawnLexer(RegexLexer):
|
| 130 |
+
"""
|
| 131 |
+
For Pawn source code.
|
| 132 |
+
"""
|
| 133 |
+
|
| 134 |
+
name = 'Pawn'
|
| 135 |
+
aliases = ['pawn']
|
| 136 |
+
filenames = ['*.p', '*.pwn', '*.inc']
|
| 137 |
+
mimetypes = ['text/x-pawn']
|
| 138 |
+
url = 'https://www.compuphase.com/pawn/pawn.htm'
|
| 139 |
+
version_added = '2.0'
|
| 140 |
+
|
| 141 |
+
#: optional Comment or Whitespace
|
| 142 |
+
_ws = r'(?:\s|//.*?\n|/[*][\w\W]*?[*]/)+'
|
| 143 |
+
#: only one /* */ style comment
|
| 144 |
+
_ws1 = r'\s*(?:/[*].*?[*]/\s*)*'
|
| 145 |
+
|
| 146 |
+
tokens = {
|
| 147 |
+
'root': [
|
| 148 |
+
# preprocessor directives: without whitespace
|
| 149 |
+
(r'^#if\s+0', Comment.Preproc, 'if0'),
|
| 150 |
+
('^#', Comment.Preproc, 'macro'),
|
| 151 |
+
# or with whitespace
|
| 152 |
+
('^' + _ws1 + r'#if\s+0', Comment.Preproc, 'if0'),
|
| 153 |
+
('^' + _ws1 + '#', Comment.Preproc, 'macro'),
|
| 154 |
+
(r'\n', Text),
|
| 155 |
+
(r'\s+', Text),
|
| 156 |
+
(r'\\\n', Text), # line continuation
|
| 157 |
+
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
| 158 |
+
(r'/(\\\n)?\*[\w\W]*?\*(\\\n)?/', Comment.Multiline),
|
| 159 |
+
(r'[{}]', Punctuation),
|
| 160 |
+
(r'L?"', String, 'string'),
|
| 161 |
+
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
| 162 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
|
| 163 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 164 |
+
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
| 165 |
+
(r'0[0-7]+[LlUu]*', Number.Oct),
|
| 166 |
+
(r'\d+[LlUu]*', Number.Integer),
|
| 167 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 168 |
+
(r'[()\[\],.;]', Punctuation),
|
| 169 |
+
(r'(switch|case|default|const|new|static|char|continue|break|'
|
| 170 |
+
r'if|else|for|while|do|operator|enum|'
|
| 171 |
+
r'public|return|sizeof|tagof|state|goto)\b', Keyword),
|
| 172 |
+
(r'(bool|Float)\b', Keyword.Type),
|
| 173 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 174 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 175 |
+
],
|
| 176 |
+
'string': [
|
| 177 |
+
(r'"', String, '#pop'),
|
| 178 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
| 179 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 180 |
+
(r'\\\n', String), # line continuation
|
| 181 |
+
(r'\\', String), # stray backslash
|
| 182 |
+
],
|
| 183 |
+
'macro': [
|
| 184 |
+
(r'[^/\n]+', Comment.Preproc),
|
| 185 |
+
(r'/\*(.|\n)*?\*/', Comment.Multiline),
|
| 186 |
+
(r'//.*?\n', Comment.Single, '#pop'),
|
| 187 |
+
(r'/', Comment.Preproc),
|
| 188 |
+
(r'(?<=\\)\n', Comment.Preproc),
|
| 189 |
+
(r'\n', Comment.Preproc, '#pop'),
|
| 190 |
+
],
|
| 191 |
+
'if0': [
|
| 192 |
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
| 193 |
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
| 194 |
+
(r'.*?\n', Comment),
|
| 195 |
+
]
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
def analyse_text(text):
|
| 199 |
+
"""This is basically C. There is a keyword which doesn't exist in C
|
| 200 |
+
though and is nearly unique to this language."""
|
| 201 |
+
if 'tagof' in text:
|
| 202 |
+
return 0.01
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pddl.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.pddl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Planning Domain Definition Language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
from pygments.lexer import RegexLexer, words, include
|
| 13 |
+
from pygments.token import Punctuation, Keyword, Whitespace, Name, Comment, \
|
| 14 |
+
Operator, Number
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
__all__ = ['PddlLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class PddlLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
A PDDL lexer.
|
| 23 |
+
|
| 24 |
+
It should support up to PDDL 3.1.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'PDDL'
|
| 28 |
+
aliases = ['pddl']
|
| 29 |
+
filenames = ['*.pddl']
|
| 30 |
+
# there doesn't really seem to be a PDDL homepage.
|
| 31 |
+
url = 'https://en.wikipedia.org/wiki/Planning_Domain_Definition_Language'
|
| 32 |
+
version_added = '2.19'
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'root': [
|
| 36 |
+
(r'\s+', Whitespace),
|
| 37 |
+
(r';.*$', Comment.Singleline),
|
| 38 |
+
include('keywords'),
|
| 39 |
+
include('builtins'),
|
| 40 |
+
(r'[()]', Punctuation),
|
| 41 |
+
(r'[=/*+><-]', Operator),
|
| 42 |
+
(r'[a-zA-Z][a-zA-Z0-9_-]*', Name),
|
| 43 |
+
(r'\?[a-zA-Z][a-zA-Z0-9_-]*', Name.Variable),
|
| 44 |
+
(r'[0-9]+\.[0-9]+', Number.Float),
|
| 45 |
+
(r'[0-9]+', Number.Integer),
|
| 46 |
+
],
|
| 47 |
+
'keywords': [
|
| 48 |
+
(words((
|
| 49 |
+
':requirements', ':types', ':constants',
|
| 50 |
+
':predicates', ':functions', ':action', ':agent',
|
| 51 |
+
':parameters', ':precondition', ':effect',
|
| 52 |
+
':durative-action', ':duration', ':condition',
|
| 53 |
+
':derived', ':domain', ':objects', ':init',
|
| 54 |
+
':goal', ':metric', ':length', ':serial', ':parallel',
|
| 55 |
+
# the following are requirements
|
| 56 |
+
':strips', ':typing', ':negative-preconditions',
|
| 57 |
+
':disjunctive-preconditions', ':equality',
|
| 58 |
+
':existential-preconditions', ':universal-preconditions',
|
| 59 |
+
':conditional-effects', ':fluents', ':numeric-fluents',
|
| 60 |
+
':object-fluents', ':adl', ':durative-actions',
|
| 61 |
+
':continuous-effects', ':derived-predicates',
|
| 62 |
+
':time-intial-literals', ':preferences',
|
| 63 |
+
':constraints', ':action-costs', ':multi-agent',
|
| 64 |
+
':unfactored-privacy', ':factored-privacy',
|
| 65 |
+
':non-deterministic'
|
| 66 |
+
), suffix=r'\b'), Keyword)
|
| 67 |
+
],
|
| 68 |
+
'builtins': [
|
| 69 |
+
(words((
|
| 70 |
+
'define', 'domain', 'object', 'either', 'and',
|
| 71 |
+
'forall', 'preference', 'imply', 'or', 'exists',
|
| 72 |
+
'not', 'when', 'assign', 'scale-up', 'scale-down',
|
| 73 |
+
'increase', 'decrease', 'at', 'over', 'start',
|
| 74 |
+
'end', 'all', 'problem', 'always', 'sometime',
|
| 75 |
+
'within', 'at-most-once', 'sometime-after',
|
| 76 |
+
'sometime-before', 'always-within', 'hold-during',
|
| 77 |
+
'hold-after', 'minimize', 'maximize',
|
| 78 |
+
'total-time', 'is-violated'), suffix=r'\b'),
|
| 79 |
+
Name.Builtin)
|
| 80 |
+
]
|
| 81 |
+
}
|
| 82 |
+
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/perl.py
ADDED
|
@@ -0,0 +1,733 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.perl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Perl, Raku and related languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, bygroups, \
|
| 14 |
+
using, this, default, words
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Whitespace
|
| 17 |
+
from pygments.util import shebang_matches
|
| 18 |
+
|
| 19 |
+
__all__ = ['PerlLexer', 'Perl6Lexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class PerlLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For Perl source code.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'Perl'
|
| 28 |
+
url = 'https://www.perl.org'
|
| 29 |
+
aliases = ['perl', 'pl']
|
| 30 |
+
filenames = ['*.pl', '*.pm', '*.t', '*.perl']
|
| 31 |
+
mimetypes = ['text/x-perl', 'application/x-perl']
|
| 32 |
+
version_added = ''
|
| 33 |
+
|
| 34 |
+
flags = re.DOTALL | re.MULTILINE
|
| 35 |
+
# TODO: give this to a perl guy who knows how to parse perl...
|
| 36 |
+
tokens = {
|
| 37 |
+
'balanced-regex': [
|
| 38 |
+
(r'/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*', String.Regex, '#pop'),
|
| 39 |
+
(r'!(\\\\|\\[^\\]|[^\\!])*![egimosx]*', String.Regex, '#pop'),
|
| 40 |
+
(r'\\(\\\\|[^\\])*\\[egimosx]*', String.Regex, '#pop'),
|
| 41 |
+
(r'\{(\\\\|\\[^\\]|[^\\}])*\}[egimosx]*', String.Regex, '#pop'),
|
| 42 |
+
(r'<(\\\\|\\[^\\]|[^\\>])*>[egimosx]*', String.Regex, '#pop'),
|
| 43 |
+
(r'\[(\\\\|\\[^\\]|[^\\\]])*\][egimosx]*', String.Regex, '#pop'),
|
| 44 |
+
(r'\((\\\\|\\[^\\]|[^\\)])*\)[egimosx]*', String.Regex, '#pop'),
|
| 45 |
+
(r'@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*', String.Regex, '#pop'),
|
| 46 |
+
(r'%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*', String.Regex, '#pop'),
|
| 47 |
+
(r'\$(\\\\|\\[^\\]|[^\\$])*\$[egimosx]*', String.Regex, '#pop'),
|
| 48 |
+
],
|
| 49 |
+
'root': [
|
| 50 |
+
(r'\A\#!.+?$', Comment.Hashbang),
|
| 51 |
+
(r'\#.*?$', Comment.Single),
|
| 52 |
+
(r'^=[a-zA-Z0-9]+\s+.*?\n=cut', Comment.Multiline),
|
| 53 |
+
(words((
|
| 54 |
+
'case', 'continue', 'do', 'else', 'elsif', 'for', 'foreach',
|
| 55 |
+
'if', 'last', 'my', 'next', 'our', 'redo', 'reset', 'then',
|
| 56 |
+
'unless', 'until', 'while', 'print', 'new', 'BEGIN',
|
| 57 |
+
'CHECK', 'INIT', 'END', 'return'), suffix=r'\b'),
|
| 58 |
+
Keyword),
|
| 59 |
+
(r'(format)(\s+)(\w+)(\s*)(=)(\s*\n)',
|
| 60 |
+
bygroups(Keyword, Whitespace, Name, Whitespace, Punctuation, Whitespace), 'format'),
|
| 61 |
+
(r'(eq|lt|gt|le|ge|ne|not|and|or|cmp)\b', Operator.Word),
|
| 62 |
+
# common delimiters
|
| 63 |
+
(r's/(\\\\|\\[^\\]|[^\\/])*/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*',
|
| 64 |
+
String.Regex),
|
| 65 |
+
(r's!(\\\\|\\!|[^!])*!(\\\\|\\!|[^!])*![egimosx]*', String.Regex),
|
| 66 |
+
(r's\\(\\\\|[^\\])*\\(\\\\|[^\\])*\\[egimosx]*', String.Regex),
|
| 67 |
+
(r's@(\\\\|\\[^\\]|[^\\@])*@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*',
|
| 68 |
+
String.Regex),
|
| 69 |
+
(r's%(\\\\|\\[^\\]|[^\\%])*%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*',
|
| 70 |
+
String.Regex),
|
| 71 |
+
# balanced delimiters
|
| 72 |
+
(r's\{(\\\\|\\[^\\]|[^\\}])*\}\s*', String.Regex, 'balanced-regex'),
|
| 73 |
+
(r's<(\\\\|\\[^\\]|[^\\>])*>\s*', String.Regex, 'balanced-regex'),
|
| 74 |
+
(r's\[(\\\\|\\[^\\]|[^\\\]])*\]\s*', String.Regex,
|
| 75 |
+
'balanced-regex'),
|
| 76 |
+
(r's\((\\\\|\\[^\\]|[^\\)])*\)\s*', String.Regex,
|
| 77 |
+
'balanced-regex'),
|
| 78 |
+
|
| 79 |
+
(r'm?/(\\\\|\\[^\\]|[^\\/\n])*/[gcimosx]*', String.Regex),
|
| 80 |
+
(r'm(?=[/!\\{<\[(@%$])', String.Regex, 'balanced-regex'),
|
| 81 |
+
(r'((?<==~)|(?<=\())\s*/(\\\\|\\[^\\]|[^\\/])*/[gcimosx]*',
|
| 82 |
+
String.Regex),
|
| 83 |
+
(r'\s+', Whitespace),
|
| 84 |
+
(words((
|
| 85 |
+
'abs', 'accept', 'alarm', 'atan2', 'bind', 'binmode', 'bless', 'caller', 'chdir',
|
| 86 |
+
'chmod', 'chomp', 'chop', 'chown', 'chr', 'chroot', 'close', 'closedir', 'connect',
|
| 87 |
+
'continue', 'cos', 'crypt', 'dbmclose', 'dbmopen', 'defined', 'delete', 'die',
|
| 88 |
+
'dump', 'each', 'endgrent', 'endhostent', 'endnetent', 'endprotoent',
|
| 89 |
+
'endpwent', 'endservent', 'eof', 'eval', 'exec', 'exists', 'exit', 'exp', 'fcntl',
|
| 90 |
+
'fileno', 'flock', 'fork', 'format', 'formline', 'getc', 'getgrent', 'getgrgid',
|
| 91 |
+
'getgrnam', 'gethostbyaddr', 'gethostbyname', 'gethostent', 'getlogin',
|
| 92 |
+
'getnetbyaddr', 'getnetbyname', 'getnetent', 'getpeername', 'getpgrp',
|
| 93 |
+
'getppid', 'getpriority', 'getprotobyname', 'getprotobynumber',
|
| 94 |
+
'getprotoent', 'getpwent', 'getpwnam', 'getpwuid', 'getservbyname',
|
| 95 |
+
'getservbyport', 'getservent', 'getsockname', 'getsockopt', 'glob', 'gmtime',
|
| 96 |
+
'goto', 'grep', 'hex', 'import', 'index', 'int', 'ioctl', 'join', 'keys', 'kill', 'last',
|
| 97 |
+
'lc', 'lcfirst', 'length', 'link', 'listen', 'local', 'localtime', 'log', 'lstat',
|
| 98 |
+
'map', 'mkdir', 'msgctl', 'msgget', 'msgrcv', 'msgsnd', 'my', 'next', 'oct', 'open',
|
| 99 |
+
'opendir', 'ord', 'our', 'pack', 'pipe', 'pop', 'pos', 'printf',
|
| 100 |
+
'prototype', 'push', 'quotemeta', 'rand', 'read', 'readdir',
|
| 101 |
+
'readline', 'readlink', 'readpipe', 'recv', 'redo', 'ref', 'rename',
|
| 102 |
+
'reverse', 'rewinddir', 'rindex', 'rmdir', 'scalar', 'seek', 'seekdir',
|
| 103 |
+
'select', 'semctl', 'semget', 'semop', 'send', 'setgrent', 'sethostent', 'setnetent',
|
| 104 |
+
'setpgrp', 'setpriority', 'setprotoent', 'setpwent', 'setservent',
|
| 105 |
+
'setsockopt', 'shift', 'shmctl', 'shmget', 'shmread', 'shmwrite', 'shutdown',
|
| 106 |
+
'sin', 'sleep', 'socket', 'socketpair', 'sort', 'splice', 'split', 'sprintf', 'sqrt',
|
| 107 |
+
'srand', 'stat', 'study', 'substr', 'symlink', 'syscall', 'sysopen', 'sysread',
|
| 108 |
+
'sysseek', 'system', 'syswrite', 'tell', 'telldir', 'tie', 'tied', 'time', 'times', 'tr',
|
| 109 |
+
'truncate', 'uc', 'ucfirst', 'umask', 'undef', 'unlink', 'unpack', 'unshift', 'untie',
|
| 110 |
+
'utime', 'values', 'vec', 'wait', 'waitpid', 'wantarray', 'warn', 'write'), suffix=r'\b'),
|
| 111 |
+
Name.Builtin),
|
| 112 |
+
(r'((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b', Name.Builtin.Pseudo),
|
| 113 |
+
(r'(<<)([\'"]?)([a-zA-Z_]\w*)(\2;?\n.*?\n)(\3)(\n)',
|
| 114 |
+
bygroups(String, String, String.Delimiter, String, String.Delimiter, Whitespace)),
|
| 115 |
+
(r'__END__', Comment.Preproc, 'end-part'),
|
| 116 |
+
(r'\$\^[ADEFHILMOPSTWX]', Name.Variable.Global),
|
| 117 |
+
(r"\$[\\\"\[\]'&`+*.,;=%~?@$!<>(^|/-](?!\w)", Name.Variable.Global),
|
| 118 |
+
(r'[$@%#]+', Name.Variable, 'varname'),
|
| 119 |
+
(r'0_?[0-7]+(_[0-7]+)*', Number.Oct),
|
| 120 |
+
(r'0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*', Number.Hex),
|
| 121 |
+
(r'0b[01]+(_[01]+)*', Number.Bin),
|
| 122 |
+
(r'(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?',
|
| 123 |
+
Number.Float),
|
| 124 |
+
(r'(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*', Number.Float),
|
| 125 |
+
(r'\d+(_\d+)*', Number.Integer),
|
| 126 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String),
|
| 127 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 128 |
+
(r'`(\\\\|\\[^\\]|[^`\\])*`', String.Backtick),
|
| 129 |
+
(r'<([^\s>]+)>', String.Regex),
|
| 130 |
+
(r'(q|qq|qw|qr|qx)\{', String.Other, 'cb-string'),
|
| 131 |
+
(r'(q|qq|qw|qr|qx)\(', String.Other, 'rb-string'),
|
| 132 |
+
(r'(q|qq|qw|qr|qx)\[', String.Other, 'sb-string'),
|
| 133 |
+
(r'(q|qq|qw|qr|qx)\<', String.Other, 'lt-string'),
|
| 134 |
+
(r'(q|qq|qw|qr|qx)([\W_])(.|\n)*?\2', String.Other),
|
| 135 |
+
(r'(package)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)',
|
| 136 |
+
bygroups(Keyword, Whitespace, Name.Namespace)),
|
| 137 |
+
(r'(use|require|no)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)',
|
| 138 |
+
bygroups(Keyword, Whitespace, Name.Namespace)),
|
| 139 |
+
(r'(sub)(\s+)', bygroups(Keyword, Whitespace), 'funcname'),
|
| 140 |
+
(words((
|
| 141 |
+
'no', 'package', 'require', 'use'), suffix=r'\b'),
|
| 142 |
+
Keyword),
|
| 143 |
+
(r'(\[\]|\*\*|::|<<|>>|>=|<=>|<=|={3}|!=|=~|'
|
| 144 |
+
r'!~|&&?|\|\||\.{1,3})', Operator),
|
| 145 |
+
(r'[-+/*%=<>&^|!\\~]=?', Operator),
|
| 146 |
+
(r'[()\[\]:;,<>/?{}]', Punctuation), # yes, there's no shortage
|
| 147 |
+
# of punctuation in Perl!
|
| 148 |
+
(r'(?=\w)', Name, 'name'),
|
| 149 |
+
],
|
| 150 |
+
'format': [
|
| 151 |
+
(r'\.\n', String.Interpol, '#pop'),
|
| 152 |
+
(r'[^\n]*\n', String.Interpol),
|
| 153 |
+
],
|
| 154 |
+
'varname': [
|
| 155 |
+
(r'\s+', Whitespace),
|
| 156 |
+
(r'\{', Punctuation, '#pop'), # hash syntax?
|
| 157 |
+
(r'\)|,', Punctuation, '#pop'), # argument specifier
|
| 158 |
+
(r'\w+::', Name.Namespace),
|
| 159 |
+
(r'[\w:]+', Name.Variable, '#pop'),
|
| 160 |
+
],
|
| 161 |
+
'name': [
|
| 162 |
+
(r'[a-zA-Z_]\w*(::[a-zA-Z_]\w*)*(::)?(?=\s*->)', Name.Namespace, '#pop'),
|
| 163 |
+
(r'[a-zA-Z_]\w*(::[a-zA-Z_]\w*)*::', Name.Namespace, '#pop'),
|
| 164 |
+
(r'[\w:]+', Name, '#pop'),
|
| 165 |
+
(r'[A-Z_]+(?=\W)', Name.Constant, '#pop'),
|
| 166 |
+
(r'(?=\W)', Text, '#pop'),
|
| 167 |
+
],
|
| 168 |
+
'funcname': [
|
| 169 |
+
(r'[a-zA-Z_]\w*[!?]?', Name.Function),
|
| 170 |
+
(r'\s+', Whitespace),
|
| 171 |
+
# argument declaration
|
| 172 |
+
(r'(\([$@%]*\))(\s*)', bygroups(Punctuation, Whitespace)),
|
| 173 |
+
(r';', Punctuation, '#pop'),
|
| 174 |
+
(r'.*?\{', Punctuation, '#pop'),
|
| 175 |
+
],
|
| 176 |
+
'cb-string': [
|
| 177 |
+
(r'\\[{}\\]', String.Other),
|
| 178 |
+
(r'\\', String.Other),
|
| 179 |
+
(r'\{', String.Other, 'cb-string'),
|
| 180 |
+
(r'\}', String.Other, '#pop'),
|
| 181 |
+
(r'[^{}\\]+', String.Other)
|
| 182 |
+
],
|
| 183 |
+
'rb-string': [
|
| 184 |
+
(r'\\[()\\]', String.Other),
|
| 185 |
+
(r'\\', String.Other),
|
| 186 |
+
(r'\(', String.Other, 'rb-string'),
|
| 187 |
+
(r'\)', String.Other, '#pop'),
|
| 188 |
+
(r'[^()]+', String.Other)
|
| 189 |
+
],
|
| 190 |
+
'sb-string': [
|
| 191 |
+
(r'\\[\[\]\\]', String.Other),
|
| 192 |
+
(r'\\', String.Other),
|
| 193 |
+
(r'\[', String.Other, 'sb-string'),
|
| 194 |
+
(r'\]', String.Other, '#pop'),
|
| 195 |
+
(r'[^\[\]]+', String.Other)
|
| 196 |
+
],
|
| 197 |
+
'lt-string': [
|
| 198 |
+
(r'\\[<>\\]', String.Other),
|
| 199 |
+
(r'\\', String.Other),
|
| 200 |
+
(r'\<', String.Other, 'lt-string'),
|
| 201 |
+
(r'\>', String.Other, '#pop'),
|
| 202 |
+
(r'[^<>]+', String.Other)
|
| 203 |
+
],
|
| 204 |
+
'end-part': [
|
| 205 |
+
(r'.+', Comment.Preproc, '#pop')
|
| 206 |
+
]
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
def analyse_text(text):
|
| 210 |
+
if shebang_matches(text, r'perl'):
|
| 211 |
+
return True
|
| 212 |
+
|
| 213 |
+
result = 0
|
| 214 |
+
|
| 215 |
+
if re.search(r'(?:my|our)\s+[$@%(]', text):
|
| 216 |
+
result += 0.9
|
| 217 |
+
|
| 218 |
+
if ':=' in text:
|
| 219 |
+
# := is not valid Perl, but it appears in unicon, so we should
|
| 220 |
+
# become less confident if we think we found Perl with :=
|
| 221 |
+
result /= 2
|
| 222 |
+
|
| 223 |
+
return result
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
class Perl6Lexer(ExtendedRegexLexer):
|
| 227 |
+
"""
|
| 228 |
+
For Raku (a.k.a. Perl 6) source code.
|
| 229 |
+
"""
|
| 230 |
+
|
| 231 |
+
name = 'Perl6'
|
| 232 |
+
url = 'https://www.raku.org'
|
| 233 |
+
aliases = ['perl6', 'pl6', 'raku']
|
| 234 |
+
filenames = ['*.pl', '*.pm', '*.nqp', '*.p6', '*.6pl', '*.p6l', '*.pl6',
|
| 235 |
+
'*.6pm', '*.p6m', '*.pm6', '*.t', '*.raku', '*.rakumod',
|
| 236 |
+
'*.rakutest', '*.rakudoc']
|
| 237 |
+
mimetypes = ['text/x-perl6', 'application/x-perl6']
|
| 238 |
+
version_added = '2.0'
|
| 239 |
+
flags = re.MULTILINE | re.DOTALL
|
| 240 |
+
|
| 241 |
+
PERL6_IDENTIFIER_RANGE = r"['\w:-]"
|
| 242 |
+
|
| 243 |
+
PERL6_KEYWORDS = (
|
| 244 |
+
#Phasers
|
| 245 |
+
'BEGIN','CATCH','CHECK','CLOSE','CONTROL','DOC','END','ENTER','FIRST',
|
| 246 |
+
'INIT','KEEP','LAST','LEAVE','NEXT','POST','PRE','QUIT','UNDO',
|
| 247 |
+
#Keywords
|
| 248 |
+
'anon','augment','but','class','constant','default','does','else',
|
| 249 |
+
'elsif','enum','for','gather','given','grammar','has','if','import',
|
| 250 |
+
'is','let','loop','made','make','method','module','multi','my','need',
|
| 251 |
+
'orwith','our','proceed','proto','repeat','require','return',
|
| 252 |
+
'return-rw','returns','role','rule','state','sub','submethod','subset',
|
| 253 |
+
'succeed','supersede','token','try','unit','unless','until','use',
|
| 254 |
+
'when','while','with','without',
|
| 255 |
+
#Traits
|
| 256 |
+
'export','native','repr','required','rw','symbol',
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
+
PERL6_BUILTINS = (
|
| 260 |
+
'ACCEPTS','abs','abs2rel','absolute','accept','accessed','acos',
|
| 261 |
+
'acosec','acosech','acosh','acotan','acotanh','acquire','act','action',
|
| 262 |
+
'actions','add','add_attribute','add_enum_value','add_fallback',
|
| 263 |
+
'add_method','add_parent','add_private_method','add_role','add_trustee',
|
| 264 |
+
'adverb','after','all','allocate','allof','allowed','alternative-names',
|
| 265 |
+
'annotations','antipair','antipairs','any','anyof','app_lifetime',
|
| 266 |
+
'append','arch','archname','args','arity','Array','asec','asech','asin',
|
| 267 |
+
'asinh','ASSIGN-KEY','ASSIGN-POS','assuming','ast','at','atan','atan2',
|
| 268 |
+
'atanh','AT-KEY','atomic-assign','atomic-dec-fetch','atomic-fetch',
|
| 269 |
+
'atomic-fetch-add','atomic-fetch-dec','atomic-fetch-inc',
|
| 270 |
+
'atomic-fetch-sub','atomic-inc-fetch','AT-POS','attributes','auth',
|
| 271 |
+
'await','backtrace','Bag','BagHash','bail-out','base','basename',
|
| 272 |
+
'base-repeating','batch','BIND-KEY','BIND-POS','bind-stderr',
|
| 273 |
+
'bind-stdin','bind-stdout','bind-udp','bits','bless','block','Bool',
|
| 274 |
+
'bool-only','bounds','break','Bridge','broken','BUILD','build-date',
|
| 275 |
+
'bytes','cache','callframe','calling-package','CALL-ME','callsame',
|
| 276 |
+
'callwith','can','cancel','candidates','cando','can-ok','canonpath',
|
| 277 |
+
'caps','caption','Capture','cas','catdir','categorize','categorize-list',
|
| 278 |
+
'catfile','catpath','cause','ceiling','cglobal','changed','Channel',
|
| 279 |
+
'chars','chdir','child','child-name','child-typename','chmod','chomp',
|
| 280 |
+
'chop','chr','chrs','chunks','cis','classify','classify-list','cleanup',
|
| 281 |
+
'clone','close','closed','close-stdin','cmp-ok','code','codes','collate',
|
| 282 |
+
'column','comb','combinations','command','comment','compiler','Complex',
|
| 283 |
+
'compose','compose_type','composer','condition','config',
|
| 284 |
+
'configure_destroy','configure_type_checking','conj','connect',
|
| 285 |
+
'constraints','construct','contains','contents','copy','cos','cosec',
|
| 286 |
+
'cosech','cosh','cotan','cotanh','count','count-only','cpu-cores',
|
| 287 |
+
'cpu-usage','CREATE','create_type','cross','cue','curdir','curupdir','d',
|
| 288 |
+
'Date','DateTime','day','daycount','day-of-month','day-of-week',
|
| 289 |
+
'day-of-year','days-in-month','declaration','decode','decoder','deepmap',
|
| 290 |
+
'default','defined','DEFINITE','delayed','DELETE-KEY','DELETE-POS',
|
| 291 |
+
'denominator','desc','DESTROY','destroyers','devnull','diag',
|
| 292 |
+
'did-you-mean','die','dies-ok','dir','dirname','dir-sep','DISTROnames',
|
| 293 |
+
'do','does','does-ok','done','done-testing','duckmap','dynamic','e',
|
| 294 |
+
'eager','earlier','elems','emit','enclosing','encode','encoder',
|
| 295 |
+
'encoding','end','ends-with','enum_from_value','enum_value_list',
|
| 296 |
+
'enum_values','enums','eof','EVAL','eval-dies-ok','EVALFILE',
|
| 297 |
+
'eval-lives-ok','exception','excludes-max','excludes-min','EXISTS-KEY',
|
| 298 |
+
'EXISTS-POS','exit','exitcode','exp','expected','explicitly-manage',
|
| 299 |
+
'expmod','extension','f','fail','fails-like','fc','feature','file',
|
| 300 |
+
'filename','find_method','find_method_qualified','finish','first','flat',
|
| 301 |
+
'flatmap','flip','floor','flunk','flush','fmt','format','formatter',
|
| 302 |
+
'freeze','from','from-list','from-loop','from-posix','full',
|
| 303 |
+
'full-barrier','get','get_value','getc','gist','got','grab','grabpairs',
|
| 304 |
+
'grep','handle','handled','handles','hardware','has_accessor','Hash',
|
| 305 |
+
'head','headers','hh-mm-ss','hidden','hides','hour','how','hyper','id',
|
| 306 |
+
'illegal','im','in','indent','index','indices','indir','infinite',
|
| 307 |
+
'infix','infix:<+>','infix:<->','install_method_cache','Instant',
|
| 308 |
+
'instead','Int','int-bounds','interval','in-timezone','invalid-str',
|
| 309 |
+
'invert','invocant','IO','IO::Notification.watch-path','is_trusted',
|
| 310 |
+
'is_type','isa','is-absolute','isa-ok','is-approx','is-deeply',
|
| 311 |
+
'is-hidden','is-initial-thread','is-int','is-lazy','is-leap-year',
|
| 312 |
+
'isNaN','isnt','is-prime','is-relative','is-routine','is-setting',
|
| 313 |
+
'is-win','item','iterator','join','keep','kept','KERNELnames','key',
|
| 314 |
+
'keyof','keys','kill','kv','kxxv','l','lang','last','lastcall','later',
|
| 315 |
+
'lazy','lc','leading','level','like','line','lines','link','List',
|
| 316 |
+
'listen','live','lives-ok','local','lock','log','log10','lookup','lsb',
|
| 317 |
+
'made','MAIN','make','Map','match','max','maxpairs','merge','message',
|
| 318 |
+
'method','method_table','methods','migrate','min','minmax','minpairs',
|
| 319 |
+
'minute','misplaced','Mix','MixHash','mkdir','mode','modified','month',
|
| 320 |
+
'move','mro','msb','multi','multiness','my','name','named','named_names',
|
| 321 |
+
'narrow','nativecast','native-descriptor','nativesizeof','new','new_type',
|
| 322 |
+
'new-from-daycount','new-from-pairs','next','nextcallee','next-handle',
|
| 323 |
+
'nextsame','nextwith','NFC','NFD','NFKC','NFKD','nl-in','nl-out',
|
| 324 |
+
'nodemap','nok','none','norm','not','note','now','nude','Num',
|
| 325 |
+
'numerator','Numeric','of','offset','offset-in-hours','offset-in-minutes',
|
| 326 |
+
'ok','old','on-close','one','on-switch','open','opened','operation',
|
| 327 |
+
'optional','ord','ords','orig','os-error','osname','out-buffer','pack',
|
| 328 |
+
'package','package-kind','package-name','packages','pair','pairs',
|
| 329 |
+
'pairup','parameter','params','parent','parent-name','parents','parse',
|
| 330 |
+
'parse-base','parsefile','parse-names','parts','pass','path','path-sep',
|
| 331 |
+
'payload','peer-host','peer-port','periods','perl','permutations','phaser',
|
| 332 |
+
'pick','pickpairs','pid','placeholder','plan','plus','polar','poll',
|
| 333 |
+
'polymod','pop','pos','positional','posix','postfix','postmatch',
|
| 334 |
+
'precomp-ext','precomp-target','pred','prefix','prematch','prepend',
|
| 335 |
+
'print','printf','print-nl','print-to','private','private_method_table',
|
| 336 |
+
'proc','produce','Promise','prompt','protect','pull-one','push',
|
| 337 |
+
'push-all','push-at-least','push-exactly','push-until-lazy','put',
|
| 338 |
+
'qualifier-type','quit','r','race','radix','rand','range','Rat','raw',
|
| 339 |
+
're','read','readchars','readonly','ready','Real','reallocate','reals',
|
| 340 |
+
'reason','rebless','receive','recv','redispatcher','redo','reduce',
|
| 341 |
+
'rel2abs','relative','release','rename','repeated','replacement',
|
| 342 |
+
'report','reserved','resolve','restore','result','resume','rethrow',
|
| 343 |
+
'reverse','right','rindex','rmdir','role','roles_to_compose','rolish',
|
| 344 |
+
'roll','rootdir','roots','rotate','rotor','round','roundrobin',
|
| 345 |
+
'routine-type','run','rwx','s','samecase','samemark','samewith','say',
|
| 346 |
+
'schedule-on','scheduler','scope','sec','sech','second','seek','self',
|
| 347 |
+
'send','Set','set_hidden','set_name','set_package','set_rw','set_value',
|
| 348 |
+
'SetHash','set-instruments','setup_finalization','shape','share','shell',
|
| 349 |
+
'shift','sibling','sigil','sign','signal','signals','signature','sin',
|
| 350 |
+
'sinh','sink','sink-all','skip','skip-at-least','skip-at-least-pull-one',
|
| 351 |
+
'skip-one','skip-rest','sleep','sleep-timer','sleep-until','Slip','slurp',
|
| 352 |
+
'slurp-rest','slurpy','snap','snapper','so','socket-host','socket-port',
|
| 353 |
+
'sort','source','source-package','spawn','SPEC','splice','split',
|
| 354 |
+
'splitdir','splitpath','sprintf','spurt','sqrt','squish','srand','stable',
|
| 355 |
+
'start','started','starts-with','status','stderr','stdout','Str',
|
| 356 |
+
'sub_signature','subbuf','subbuf-rw','subname','subparse','subst',
|
| 357 |
+
'subst-mutate','substr','substr-eq','substr-rw','subtest','succ','sum',
|
| 358 |
+
'Supply','symlink','t','tail','take','take-rw','tan','tanh','tap',
|
| 359 |
+
'target','target-name','tc','tclc','tell','then','throttle','throw',
|
| 360 |
+
'throws-like','timezone','tmpdir','to','today','todo','toggle','to-posix',
|
| 361 |
+
'total','trailing','trans','tree','trim','trim-leading','trim-trailing',
|
| 362 |
+
'truncate','truncated-to','trusts','try_acquire','trying','twigil','type',
|
| 363 |
+
'type_captures','typename','uc','udp','uncaught_handler','unimatch',
|
| 364 |
+
'uniname','uninames','uniparse','uniprop','uniprops','unique','unival',
|
| 365 |
+
'univals','unlike','unlink','unlock','unpack','unpolar','unshift',
|
| 366 |
+
'unwrap','updir','USAGE','use-ok','utc','val','value','values','VAR',
|
| 367 |
+
'variable','verbose-config','version','VMnames','volume','vow','w','wait',
|
| 368 |
+
'warn','watch','watch-path','week','weekday-of-month','week-number',
|
| 369 |
+
'week-year','WHAT','when','WHERE','WHEREFORE','WHICH','WHO',
|
| 370 |
+
'whole-second','WHY','wordcase','words','workaround','wrap','write',
|
| 371 |
+
'write-to','x','yada','year','yield','yyyy-mm-dd','z','zip','zip-latest',
|
| 372 |
+
|
| 373 |
+
)
|
| 374 |
+
|
| 375 |
+
PERL6_BUILTIN_CLASSES = (
|
| 376 |
+
#Booleans
|
| 377 |
+
'False','True',
|
| 378 |
+
#Classes
|
| 379 |
+
'Any','Array','Associative','AST','atomicint','Attribute','Backtrace',
|
| 380 |
+
'Backtrace::Frame','Bag','Baggy','BagHash','Blob','Block','Bool','Buf',
|
| 381 |
+
'Callable','CallFrame','Cancellation','Capture','CArray','Channel','Code',
|
| 382 |
+
'compiler','Complex','ComplexStr','Cool','CurrentThreadScheduler',
|
| 383 |
+
'Cursor','Date','Dateish','DateTime','Distro','Duration','Encoding',
|
| 384 |
+
'Exception','Failure','FatRat','Grammar','Hash','HyperWhatever','Instant',
|
| 385 |
+
'Int','int16','int32','int64','int8','IntStr','IO','IO::ArgFiles',
|
| 386 |
+
'IO::CatHandle','IO::Handle','IO::Notification','IO::Path',
|
| 387 |
+
'IO::Path::Cygwin','IO::Path::QNX','IO::Path::Unix','IO::Path::Win32',
|
| 388 |
+
'IO::Pipe','IO::Socket','IO::Socket::Async','IO::Socket::INET','IO::Spec',
|
| 389 |
+
'IO::Spec::Cygwin','IO::Spec::QNX','IO::Spec::Unix','IO::Spec::Win32',
|
| 390 |
+
'IO::Special','Iterable','Iterator','Junction','Kernel','Label','List',
|
| 391 |
+
'Lock','Lock::Async','long','longlong','Macro','Map','Match',
|
| 392 |
+
'Metamodel::AttributeContainer','Metamodel::C3MRO','Metamodel::ClassHOW',
|
| 393 |
+
'Metamodel::EnumHOW','Metamodel::Finalization','Metamodel::MethodContainer',
|
| 394 |
+
'Metamodel::MROBasedMethodDispatch','Metamodel::MultipleInheritance',
|
| 395 |
+
'Metamodel::Naming','Metamodel::Primitives','Metamodel::PrivateMethodContainer',
|
| 396 |
+
'Metamodel::RoleContainer','Metamodel::Trusting','Method','Mix','MixHash',
|
| 397 |
+
'Mixy','Mu','NFC','NFD','NFKC','NFKD','Nil','Num','num32','num64',
|
| 398 |
+
'Numeric','NumStr','ObjAt','Order','Pair','Parameter','Perl','Pod::Block',
|
| 399 |
+
'Pod::Block::Code','Pod::Block::Comment','Pod::Block::Declarator',
|
| 400 |
+
'Pod::Block::Named','Pod::Block::Para','Pod::Block::Table','Pod::Heading',
|
| 401 |
+
'Pod::Item','Pointer','Positional','PositionalBindFailover','Proc',
|
| 402 |
+
'Proc::Async','Promise','Proxy','PseudoStash','QuantHash','Range','Rat',
|
| 403 |
+
'Rational','RatStr','Real','Regex','Routine','Scalar','Scheduler',
|
| 404 |
+
'Semaphore','Seq','Set','SetHash','Setty','Signature','size_t','Slip',
|
| 405 |
+
'Stash','Str','StrDistance','Stringy','Sub','Submethod','Supplier',
|
| 406 |
+
'Supplier::Preserving','Supply','Systemic','Tap','Telemetry',
|
| 407 |
+
'Telemetry::Instrument::Thread','Telemetry::Instrument::Usage',
|
| 408 |
+
'Telemetry::Period','Telemetry::Sampler','Thread','ThreadPoolScheduler',
|
| 409 |
+
'UInt','uint16','uint32','uint64','uint8','Uni','utf8','Variable',
|
| 410 |
+
'Version','VM','Whatever','WhateverCode','WrapHandle'
|
| 411 |
+
)
|
| 412 |
+
|
| 413 |
+
PERL6_OPERATORS = (
|
| 414 |
+
'X', 'Z', 'after', 'also', 'and', 'andthen', 'before', 'cmp', 'div',
|
| 415 |
+
'eq', 'eqv', 'extra', 'ff', 'fff', 'ge', 'gt', 'le', 'leg', 'lt', 'm',
|
| 416 |
+
'mm', 'mod', 'ne', 'or', 'orelse', 'rx', 's', 'tr', 'x', 'xor', 'xx',
|
| 417 |
+
'++', '--', '**', '!', '+', '-', '~', '?', '|', '||', '+^', '~^', '?^',
|
| 418 |
+
'^', '*', '/', '%', '%%', '+&', '+<', '+>', '~&', '~<', '~>', '?&',
|
| 419 |
+
'gcd', 'lcm', '+', '-', '+|', '+^', '~|', '~^', '?|', '?^',
|
| 420 |
+
'~', '&', '^', 'but', 'does', '<=>', '..', '..^', '^..', '^..^',
|
| 421 |
+
'!=', '==', '<', '<=', '>', '>=', '~~', '===', '!eqv',
|
| 422 |
+
'&&', '||', '^^', '//', 'min', 'max', '??', '!!', 'ff', 'fff', 'so',
|
| 423 |
+
'not', '<==', '==>', '<<==', '==>>','unicmp',
|
| 424 |
+
)
|
| 425 |
+
|
| 426 |
+
# Perl 6 has a *lot* of possible bracketing characters
|
| 427 |
+
# this list was lifted from STD.pm6 (https://github.com/perl6/std)
|
| 428 |
+
PERL6_BRACKETS = {
|
| 429 |
+
'\u0028': '\u0029', '\u003c': '\u003e', '\u005b': '\u005d',
|
| 430 |
+
'\u007b': '\u007d', '\u00ab': '\u00bb', '\u0f3a': '\u0f3b',
|
| 431 |
+
'\u0f3c': '\u0f3d', '\u169b': '\u169c', '\u2018': '\u2019',
|
| 432 |
+
'\u201a': '\u2019', '\u201b': '\u2019', '\u201c': '\u201d',
|
| 433 |
+
'\u201e': '\u201d', '\u201f': '\u201d', '\u2039': '\u203a',
|
| 434 |
+
'\u2045': '\u2046', '\u207d': '\u207e', '\u208d': '\u208e',
|
| 435 |
+
'\u2208': '\u220b', '\u2209': '\u220c', '\u220a': '\u220d',
|
| 436 |
+
'\u2215': '\u29f5', '\u223c': '\u223d', '\u2243': '\u22cd',
|
| 437 |
+
'\u2252': '\u2253', '\u2254': '\u2255', '\u2264': '\u2265',
|
| 438 |
+
'\u2266': '\u2267', '\u2268': '\u2269', '\u226a': '\u226b',
|
| 439 |
+
'\u226e': '\u226f', '\u2270': '\u2271', '\u2272': '\u2273',
|
| 440 |
+
'\u2274': '\u2275', '\u2276': '\u2277', '\u2278': '\u2279',
|
| 441 |
+
'\u227a': '\u227b', '\u227c': '\u227d', '\u227e': '\u227f',
|
| 442 |
+
'\u2280': '\u2281', '\u2282': '\u2283', '\u2284': '\u2285',
|
| 443 |
+
'\u2286': '\u2287', '\u2288': '\u2289', '\u228a': '\u228b',
|
| 444 |
+
'\u228f': '\u2290', '\u2291': '\u2292', '\u2298': '\u29b8',
|
| 445 |
+
'\u22a2': '\u22a3', '\u22a6': '\u2ade', '\u22a8': '\u2ae4',
|
| 446 |
+
'\u22a9': '\u2ae3', '\u22ab': '\u2ae5', '\u22b0': '\u22b1',
|
| 447 |
+
'\u22b2': '\u22b3', '\u22b4': '\u22b5', '\u22b6': '\u22b7',
|
| 448 |
+
'\u22c9': '\u22ca', '\u22cb': '\u22cc', '\u22d0': '\u22d1',
|
| 449 |
+
'\u22d6': '\u22d7', '\u22d8': '\u22d9', '\u22da': '\u22db',
|
| 450 |
+
'\u22dc': '\u22dd', '\u22de': '\u22df', '\u22e0': '\u22e1',
|
| 451 |
+
'\u22e2': '\u22e3', '\u22e4': '\u22e5', '\u22e6': '\u22e7',
|
| 452 |
+
'\u22e8': '\u22e9', '\u22ea': '\u22eb', '\u22ec': '\u22ed',
|
| 453 |
+
'\u22f0': '\u22f1', '\u22f2': '\u22fa', '\u22f3': '\u22fb',
|
| 454 |
+
'\u22f4': '\u22fc', '\u22f6': '\u22fd', '\u22f7': '\u22fe',
|
| 455 |
+
'\u2308': '\u2309', '\u230a': '\u230b', '\u2329': '\u232a',
|
| 456 |
+
'\u23b4': '\u23b5', '\u2768': '\u2769', '\u276a': '\u276b',
|
| 457 |
+
'\u276c': '\u276d', '\u276e': '\u276f', '\u2770': '\u2771',
|
| 458 |
+
'\u2772': '\u2773', '\u2774': '\u2775', '\u27c3': '\u27c4',
|
| 459 |
+
'\u27c5': '\u27c6', '\u27d5': '\u27d6', '\u27dd': '\u27de',
|
| 460 |
+
'\u27e2': '\u27e3', '\u27e4': '\u27e5', '\u27e6': '\u27e7',
|
| 461 |
+
'\u27e8': '\u27e9', '\u27ea': '\u27eb', '\u2983': '\u2984',
|
| 462 |
+
'\u2985': '\u2986', '\u2987': '\u2988', '\u2989': '\u298a',
|
| 463 |
+
'\u298b': '\u298c', '\u298d': '\u298e', '\u298f': '\u2990',
|
| 464 |
+
'\u2991': '\u2992', '\u2993': '\u2994', '\u2995': '\u2996',
|
| 465 |
+
'\u2997': '\u2998', '\u29c0': '\u29c1', '\u29c4': '\u29c5',
|
| 466 |
+
'\u29cf': '\u29d0', '\u29d1': '\u29d2', '\u29d4': '\u29d5',
|
| 467 |
+
'\u29d8': '\u29d9', '\u29da': '\u29db', '\u29f8': '\u29f9',
|
| 468 |
+
'\u29fc': '\u29fd', '\u2a2b': '\u2a2c', '\u2a2d': '\u2a2e',
|
| 469 |
+
'\u2a34': '\u2a35', '\u2a3c': '\u2a3d', '\u2a64': '\u2a65',
|
| 470 |
+
'\u2a79': '\u2a7a', '\u2a7d': '\u2a7e', '\u2a7f': '\u2a80',
|
| 471 |
+
'\u2a81': '\u2a82', '\u2a83': '\u2a84', '\u2a8b': '\u2a8c',
|
| 472 |
+
'\u2a91': '\u2a92', '\u2a93': '\u2a94', '\u2a95': '\u2a96',
|
| 473 |
+
'\u2a97': '\u2a98', '\u2a99': '\u2a9a', '\u2a9b': '\u2a9c',
|
| 474 |
+
'\u2aa1': '\u2aa2', '\u2aa6': '\u2aa7', '\u2aa8': '\u2aa9',
|
| 475 |
+
'\u2aaa': '\u2aab', '\u2aac': '\u2aad', '\u2aaf': '\u2ab0',
|
| 476 |
+
'\u2ab3': '\u2ab4', '\u2abb': '\u2abc', '\u2abd': '\u2abe',
|
| 477 |
+
'\u2abf': '\u2ac0', '\u2ac1': '\u2ac2', '\u2ac3': '\u2ac4',
|
| 478 |
+
'\u2ac5': '\u2ac6', '\u2acd': '\u2ace', '\u2acf': '\u2ad0',
|
| 479 |
+
'\u2ad1': '\u2ad2', '\u2ad3': '\u2ad4', '\u2ad5': '\u2ad6',
|
| 480 |
+
'\u2aec': '\u2aed', '\u2af7': '\u2af8', '\u2af9': '\u2afa',
|
| 481 |
+
'\u2e02': '\u2e03', '\u2e04': '\u2e05', '\u2e09': '\u2e0a',
|
| 482 |
+
'\u2e0c': '\u2e0d', '\u2e1c': '\u2e1d', '\u2e20': '\u2e21',
|
| 483 |
+
'\u3008': '\u3009', '\u300a': '\u300b', '\u300c': '\u300d',
|
| 484 |
+
'\u300e': '\u300f', '\u3010': '\u3011', '\u3014': '\u3015',
|
| 485 |
+
'\u3016': '\u3017', '\u3018': '\u3019', '\u301a': '\u301b',
|
| 486 |
+
'\u301d': '\u301e', '\ufd3e': '\ufd3f', '\ufe17': '\ufe18',
|
| 487 |
+
'\ufe35': '\ufe36', '\ufe37': '\ufe38', '\ufe39': '\ufe3a',
|
| 488 |
+
'\ufe3b': '\ufe3c', '\ufe3d': '\ufe3e', '\ufe3f': '\ufe40',
|
| 489 |
+
'\ufe41': '\ufe42', '\ufe43': '\ufe44', '\ufe47': '\ufe48',
|
| 490 |
+
'\ufe59': '\ufe5a', '\ufe5b': '\ufe5c', '\ufe5d': '\ufe5e',
|
| 491 |
+
'\uff08': '\uff09', '\uff1c': '\uff1e', '\uff3b': '\uff3d',
|
| 492 |
+
'\uff5b': '\uff5d', '\uff5f': '\uff60', '\uff62': '\uff63',
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
def _build_word_match(words, boundary_regex_fragment=None, prefix='', suffix=''):
|
| 496 |
+
if boundary_regex_fragment is None:
|
| 497 |
+
return r'\b(' + prefix + r'|'.join(re.escape(x) for x in words) + \
|
| 498 |
+
suffix + r')\b'
|
| 499 |
+
else:
|
| 500 |
+
return r'(?<!' + boundary_regex_fragment + r')' + prefix + r'(' + \
|
| 501 |
+
r'|'.join(re.escape(x) for x in words) + r')' + suffix + r'(?!' + \
|
| 502 |
+
boundary_regex_fragment + r')'
|
| 503 |
+
|
| 504 |
+
def brackets_callback(token_class):
|
| 505 |
+
def callback(lexer, match, context):
|
| 506 |
+
groups = match.groupdict()
|
| 507 |
+
opening_chars = groups['delimiter']
|
| 508 |
+
n_chars = len(opening_chars)
|
| 509 |
+
adverbs = groups.get('adverbs')
|
| 510 |
+
|
| 511 |
+
closer = Perl6Lexer.PERL6_BRACKETS.get(opening_chars[0])
|
| 512 |
+
text = context.text
|
| 513 |
+
|
| 514 |
+
if closer is None: # it's not a mirrored character, which means we
|
| 515 |
+
# just need to look for the next occurrence
|
| 516 |
+
|
| 517 |
+
end_pos = text.find(opening_chars, match.start('delimiter') + n_chars)
|
| 518 |
+
else: # we need to look for the corresponding closing character,
|
| 519 |
+
# keep nesting in mind
|
| 520 |
+
closing_chars = closer * n_chars
|
| 521 |
+
nesting_level = 1
|
| 522 |
+
|
| 523 |
+
search_pos = match.start('delimiter')
|
| 524 |
+
|
| 525 |
+
while nesting_level > 0:
|
| 526 |
+
next_open_pos = text.find(opening_chars, search_pos + n_chars)
|
| 527 |
+
next_close_pos = text.find(closing_chars, search_pos + n_chars)
|
| 528 |
+
|
| 529 |
+
if next_close_pos == -1:
|
| 530 |
+
next_close_pos = len(text)
|
| 531 |
+
nesting_level = 0
|
| 532 |
+
elif next_open_pos != -1 and next_open_pos < next_close_pos:
|
| 533 |
+
nesting_level += 1
|
| 534 |
+
search_pos = next_open_pos
|
| 535 |
+
else: # next_close_pos < next_open_pos
|
| 536 |
+
nesting_level -= 1
|
| 537 |
+
search_pos = next_close_pos
|
| 538 |
+
|
| 539 |
+
end_pos = next_close_pos
|
| 540 |
+
|
| 541 |
+
if end_pos < 0: # if we didn't find a closer, just highlight the
|
| 542 |
+
# rest of the text in this class
|
| 543 |
+
end_pos = len(text)
|
| 544 |
+
|
| 545 |
+
if adverbs is not None and re.search(r':to\b', adverbs):
|
| 546 |
+
heredoc_terminator = text[match.start('delimiter') + n_chars:end_pos]
|
| 547 |
+
end_heredoc = re.search(r'^\s*' + re.escape(heredoc_terminator) +
|
| 548 |
+
r'\s*$', text[end_pos:], re.MULTILINE)
|
| 549 |
+
|
| 550 |
+
if end_heredoc:
|
| 551 |
+
end_pos += end_heredoc.end()
|
| 552 |
+
else:
|
| 553 |
+
end_pos = len(text)
|
| 554 |
+
|
| 555 |
+
yield match.start(), token_class, text[match.start():end_pos + n_chars]
|
| 556 |
+
context.pos = end_pos + n_chars
|
| 557 |
+
|
| 558 |
+
return callback
|
| 559 |
+
|
| 560 |
+
def opening_brace_callback(lexer, match, context):
|
| 561 |
+
stack = context.stack
|
| 562 |
+
|
| 563 |
+
yield match.start(), Text, context.text[match.start():match.end()]
|
| 564 |
+
context.pos = match.end()
|
| 565 |
+
|
| 566 |
+
# if we encounter an opening brace and we're one level
|
| 567 |
+
# below a token state, it means we need to increment
|
| 568 |
+
# the nesting level for braces so we know later when
|
| 569 |
+
# we should return to the token rules.
|
| 570 |
+
if len(stack) > 2 and stack[-2] == 'token':
|
| 571 |
+
context.perl6_token_nesting_level += 1
|
| 572 |
+
|
| 573 |
+
def closing_brace_callback(lexer, match, context):
|
| 574 |
+
stack = context.stack
|
| 575 |
+
|
| 576 |
+
yield match.start(), Text, context.text[match.start():match.end()]
|
| 577 |
+
context.pos = match.end()
|
| 578 |
+
|
| 579 |
+
# if we encounter a free closing brace and we're one level
|
| 580 |
+
# below a token state, it means we need to check the nesting
|
| 581 |
+
# level to see if we need to return to the token state.
|
| 582 |
+
if len(stack) > 2 and stack[-2] == 'token':
|
| 583 |
+
context.perl6_token_nesting_level -= 1
|
| 584 |
+
if context.perl6_token_nesting_level == 0:
|
| 585 |
+
stack.pop()
|
| 586 |
+
|
| 587 |
+
def embedded_perl6_callback(lexer, match, context):
|
| 588 |
+
context.perl6_token_nesting_level = 1
|
| 589 |
+
yield match.start(), Text, context.text[match.start():match.end()]
|
| 590 |
+
context.pos = match.end()
|
| 591 |
+
context.stack.append('root')
|
| 592 |
+
|
| 593 |
+
# If you're modifying these rules, be careful if you need to process '{' or '}'
|
| 594 |
+
# characters. We have special logic for processing these characters (due to the fact
|
| 595 |
+
# that you can nest Perl 6 code in regex blocks), so if you need to process one of
|
| 596 |
+
# them, make sure you also process the corresponding one!
|
| 597 |
+
tokens = {
|
| 598 |
+
'common': [
|
| 599 |
+
(r'#[`|=](?P<delimiter>(?P<first_char>[' + ''.join(PERL6_BRACKETS) + r'])(?P=first_char)*)',
|
| 600 |
+
brackets_callback(Comment.Multiline)),
|
| 601 |
+
(r'#[^\n]*$', Comment.Single),
|
| 602 |
+
(r'^(\s*)=begin\s+(\w+)\b.*?^\1=end\s+\2', Comment.Multiline),
|
| 603 |
+
(r'^(\s*)=for.*?\n\s*?\n', Comment.Multiline),
|
| 604 |
+
(r'^=.*?\n\s*?\n', Comment.Multiline),
|
| 605 |
+
(r'(regex|token|rule)(\s*' + PERL6_IDENTIFIER_RANGE + '+:sym)',
|
| 606 |
+
bygroups(Keyword, Name), 'token-sym-brackets'),
|
| 607 |
+
(r'(regex|token|rule)(?!' + PERL6_IDENTIFIER_RANGE + r')(\s*' + PERL6_IDENTIFIER_RANGE + '+)?',
|
| 608 |
+
bygroups(Keyword, Name), 'pre-token'),
|
| 609 |
+
# deal with a special case in the Perl 6 grammar (role q { ... })
|
| 610 |
+
(r'(role)(\s+)(q)(\s*)', bygroups(Keyword, Whitespace, Name, Whitespace)),
|
| 611 |
+
(_build_word_match(PERL6_KEYWORDS, PERL6_IDENTIFIER_RANGE), Keyword),
|
| 612 |
+
(_build_word_match(PERL6_BUILTIN_CLASSES, PERL6_IDENTIFIER_RANGE, suffix='(?::[UD])?'),
|
| 613 |
+
Name.Builtin),
|
| 614 |
+
(_build_word_match(PERL6_BUILTINS, PERL6_IDENTIFIER_RANGE), Name.Builtin),
|
| 615 |
+
# copied from PerlLexer
|
| 616 |
+
(r'[$@%&][.^:?=!~]?' + PERL6_IDENTIFIER_RANGE + '+(?:<<.*?>>|<.*?>|«.*?»)*',
|
| 617 |
+
Name.Variable),
|
| 618 |
+
(r'\$[!/](?:<<.*?>>|<.*?>|«.*?»)*', Name.Variable.Global),
|
| 619 |
+
(r'::\?\w+', Name.Variable.Global),
|
| 620 |
+
(r'[$@%&]\*' + PERL6_IDENTIFIER_RANGE + '+(?:<<.*?>>|<.*?>|«.*?»)*',
|
| 621 |
+
Name.Variable.Global),
|
| 622 |
+
(r'\$(?:<.*?>)+', Name.Variable),
|
| 623 |
+
(r'(?:q|qq|Q)[a-zA-Z]?\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^0-9a-zA-Z:\s])'
|
| 624 |
+
r'(?P=first_char)*)', brackets_callback(String)),
|
| 625 |
+
# copied from PerlLexer
|
| 626 |
+
(r'0_?[0-7]+(_[0-7]+)*', Number.Oct),
|
| 627 |
+
(r'0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*', Number.Hex),
|
| 628 |
+
(r'0b[01]+(_[01]+)*', Number.Bin),
|
| 629 |
+
(r'(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?',
|
| 630 |
+
Number.Float),
|
| 631 |
+
(r'(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*', Number.Float),
|
| 632 |
+
(r'\d+(_\d+)*', Number.Integer),
|
| 633 |
+
(r'(?<=~~)\s*/(?:\\\\|\\/|.)*?/', String.Regex),
|
| 634 |
+
(r'(?<=[=(,])\s*/(?:\\\\|\\/|.)*?/', String.Regex),
|
| 635 |
+
(r'm\w+(?=\()', Name),
|
| 636 |
+
(r'(?:m|ms|rx)\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^\w:\s])'
|
| 637 |
+
r'(?P=first_char)*)', brackets_callback(String.Regex)),
|
| 638 |
+
(r'(?:s|ss|tr)\s*(?::[\w\s:]+)?\s*/(?:\\\\|\\/|.)*?/(?:\\\\|\\/|.)*?/',
|
| 639 |
+
String.Regex),
|
| 640 |
+
(r'<[^\s=].*?\S>', String),
|
| 641 |
+
(_build_word_match(PERL6_OPERATORS), Operator),
|
| 642 |
+
(r'\w' + PERL6_IDENTIFIER_RANGE + '*', Name),
|
| 643 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String),
|
| 644 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 645 |
+
],
|
| 646 |
+
'root': [
|
| 647 |
+
include('common'),
|
| 648 |
+
(r'\{', opening_brace_callback),
|
| 649 |
+
(r'\}', closing_brace_callback),
|
| 650 |
+
(r'.+?', Text),
|
| 651 |
+
],
|
| 652 |
+
'pre-token': [
|
| 653 |
+
include('common'),
|
| 654 |
+
(r'\{', Text, ('#pop', 'token')),
|
| 655 |
+
(r'.+?', Text),
|
| 656 |
+
],
|
| 657 |
+
'token-sym-brackets': [
|
| 658 |
+
(r'(?P<delimiter>(?P<first_char>[' + ''.join(PERL6_BRACKETS) + '])(?P=first_char)*)',
|
| 659 |
+
brackets_callback(Name), ('#pop', 'pre-token')),
|
| 660 |
+
default(('#pop', 'pre-token')),
|
| 661 |
+
],
|
| 662 |
+
'token': [
|
| 663 |
+
(r'\}', Text, '#pop'),
|
| 664 |
+
(r'(?<=:)(?:my|our|state|constant|temp|let).*?;', using(this)),
|
| 665 |
+
# make sure that quotes in character classes aren't treated as strings
|
| 666 |
+
(r'<(?:[-!?+.]\s*)?\[.*?\]>', String.Regex),
|
| 667 |
+
# make sure that '#' characters in quotes aren't treated as comments
|
| 668 |
+
(r"(?<!\\)'(\\\\|\\[^\\]|[^'\\])*'", String.Regex),
|
| 669 |
+
(r'(?<!\\)"(\\\\|\\[^\\]|[^"\\])*"', String.Regex),
|
| 670 |
+
(r'#.*?$', Comment.Single),
|
| 671 |
+
(r'\{', embedded_perl6_callback),
|
| 672 |
+
('.+?', String.Regex),
|
| 673 |
+
],
|
| 674 |
+
}
|
| 675 |
+
|
| 676 |
+
def analyse_text(text):
|
| 677 |
+
def strip_pod(lines):
|
| 678 |
+
in_pod = False
|
| 679 |
+
stripped_lines = []
|
| 680 |
+
|
| 681 |
+
for line in lines:
|
| 682 |
+
if re.match(r'^=(?:end|cut)', line):
|
| 683 |
+
in_pod = False
|
| 684 |
+
elif re.match(r'^=\w+', line):
|
| 685 |
+
in_pod = True
|
| 686 |
+
elif not in_pod:
|
| 687 |
+
stripped_lines.append(line)
|
| 688 |
+
|
| 689 |
+
return stripped_lines
|
| 690 |
+
|
| 691 |
+
# XXX handle block comments
|
| 692 |
+
lines = text.splitlines()
|
| 693 |
+
lines = strip_pod(lines)
|
| 694 |
+
text = '\n'.join(lines)
|
| 695 |
+
|
| 696 |
+
if shebang_matches(text, r'perl6|rakudo|niecza|pugs'):
|
| 697 |
+
return True
|
| 698 |
+
|
| 699 |
+
saw_perl_decl = False
|
| 700 |
+
rating = False
|
| 701 |
+
|
| 702 |
+
# check for my/our/has declarations
|
| 703 |
+
if re.search(r"(?:my|our|has)\s+(?:" + Perl6Lexer.PERL6_IDENTIFIER_RANGE +
|
| 704 |
+
r"+\s+)?[$@%&(]", text):
|
| 705 |
+
rating = 0.8
|
| 706 |
+
saw_perl_decl = True
|
| 707 |
+
|
| 708 |
+
for line in lines:
|
| 709 |
+
line = re.sub('#.*', '', line)
|
| 710 |
+
if re.match(r'^\s*$', line):
|
| 711 |
+
continue
|
| 712 |
+
|
| 713 |
+
# match v6; use v6; use v6.0; use v6.0.0;
|
| 714 |
+
if re.match(r'^\s*(?:use\s+)?v6(?:\.\d(?:\.\d)?)?;', line):
|
| 715 |
+
return True
|
| 716 |
+
# match class, module, role, enum, grammar declarations
|
| 717 |
+
class_decl = re.match(r'^\s*(?:(?P<scope>my|our)\s+)?(?:module|class|role|enum|grammar)', line)
|
| 718 |
+
if class_decl:
|
| 719 |
+
if saw_perl_decl or class_decl.group('scope') is not None:
|
| 720 |
+
return True
|
| 721 |
+
rating = 0.05
|
| 722 |
+
continue
|
| 723 |
+
break
|
| 724 |
+
|
| 725 |
+
if ':=' in text:
|
| 726 |
+
# Same logic as above for PerlLexer
|
| 727 |
+
rating /= 2
|
| 728 |
+
|
| 729 |
+
return rating
|
| 730 |
+
|
| 731 |
+
def __init__(self, **options):
|
| 732 |
+
super().__init__(**options)
|
| 733 |
+
self.encoding = options.get('encoding', 'utf-8')
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/phix.py
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.phix
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Phix.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, words
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['PhixLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class PhixLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Pygments Lexer for Phix files (.exw).
|
| 23 |
+
See http://phix.x10.mx
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = 'Phix'
|
| 27 |
+
url = 'http://phix.x10.mx'
|
| 28 |
+
aliases = ['phix']
|
| 29 |
+
filenames = ['*.exw']
|
| 30 |
+
mimetypes = ['text/x-phix']
|
| 31 |
+
version_added = '2.14'
|
| 32 |
+
|
| 33 |
+
flags = re.MULTILINE # nb: **NOT** re.DOTALL! (totally spanners comment handling)
|
| 34 |
+
|
| 35 |
+
preproc = (
|
| 36 |
+
'ifdef', 'elsifdef', 'elsedef'
|
| 37 |
+
)
|
| 38 |
+
# Note these lists are auto-generated by pwa/p2js.exw, when pwa\src\p2js_keywords.e (etc)
|
| 39 |
+
# change, though of course subsequent copy/commit/pull requests are all manual steps.
|
| 40 |
+
types = (
|
| 41 |
+
'string', 'nullable_string', 'atom_string', 'atom', 'bool', 'boolean',
|
| 42 |
+
'cdCanvan', 'cdCanvas', 'complex', 'CURLcode', 'dictionary', 'int',
|
| 43 |
+
'integer', 'Ihandle', 'Ihandles', 'Ihandln', 'mpfr', 'mpq', 'mpz',
|
| 44 |
+
'mpz_or_string', 'number', 'rid_string', 'seq', 'sequence', 'timedate',
|
| 45 |
+
'object'
|
| 46 |
+
)
|
| 47 |
+
keywords = (
|
| 48 |
+
'abstract', 'class', 'continue', 'export', 'extends', 'nullable',
|
| 49 |
+
'private', 'public', 'static', 'struct', 'trace',
|
| 50 |
+
'and', 'break', 'by', 'case', 'catch', 'const', 'constant', 'debug',
|
| 51 |
+
'default', 'do', 'else', 'elsif', 'end', 'enum', 'exit', 'fallthru',
|
| 52 |
+
'fallthrough', 'for', 'forward', 'function', 'global', 'if', 'in',
|
| 53 |
+
'include', 'js', 'javascript', 'javascript_semantics', 'let', 'not',
|
| 54 |
+
'or', 'procedure', 'profile', 'profile_time', 'return', 'safe_mode',
|
| 55 |
+
'switch', 'then', 'to', 'try', 'type', 'type_check', 'until', 'warning',
|
| 56 |
+
'while', 'with', 'without', 'xor'
|
| 57 |
+
)
|
| 58 |
+
routines = (
|
| 59 |
+
'abort', 'abs', 'adjust_timedate', 'and_bits', 'and_bitsu', 'apply',
|
| 60 |
+
'append', 'arccos', 'arcsin', 'arctan', 'assert', 'atan2',
|
| 61 |
+
'atom_to_float32', 'atom_to_float64', 'bankers_rounding', 'beep',
|
| 62 |
+
'begins', 'binary_search', 'bits_to_int', 'bk_color', 'bytes_to_int',
|
| 63 |
+
'call_func', 'call_proc', 'cdCanvasActivate', 'cdCanvasArc',
|
| 64 |
+
'cdCanvasBegin', 'cdCanvasBox', 'cdCanvasChord', 'cdCanvasCircle',
|
| 65 |
+
'cdCanvasClear', 'cdCanvasEnd', 'cdCanvasFlush', 'cdCanvasFont',
|
| 66 |
+
'cdCanvasGetImageRGB', 'cdCanvasGetSize', 'cdCanvasGetTextAlignment',
|
| 67 |
+
'cdCanvasGetTextSize', 'cdCanvasLine', 'cdCanvasMark',
|
| 68 |
+
'cdCanvasMarkSize', 'cdCanvasMultiLineVectorText', 'cdCanvasPixel',
|
| 69 |
+
'cdCanvasRect', 'cdCanvasRoundedBox', 'cdCanvasRoundedRect',
|
| 70 |
+
'cdCanvasSector', 'cdCanvasSetAttribute', 'cdCanvasSetBackground',
|
| 71 |
+
'cdCanvasSetFillMode', 'cdCanvasSetForeground',
|
| 72 |
+
'cdCanvasSetInteriorStyle', 'cdCanvasSetLineStyle',
|
| 73 |
+
'cdCanvasSetLineWidth', 'cdCanvasSetTextAlignment', 'cdCanvasText',
|
| 74 |
+
'cdCanvasSetTextOrientation', 'cdCanvasGetTextOrientation',
|
| 75 |
+
'cdCanvasVectorText', 'cdCanvasVectorTextDirection',
|
| 76 |
+
'cdCanvasVectorTextSize', 'cdCanvasVertex', 'cdCreateCanvas',
|
| 77 |
+
'cdDecodeAlpha', 'cdDecodeColor', 'cdDecodeColorAlpha', 'cdEncodeAlpha',
|
| 78 |
+
'cdEncodeColor', 'cdEncodeColorAlpha', 'cdKillCanvas', 'cdVersion',
|
| 79 |
+
'cdVersionDate', 'ceil', 'change_timezone', 'choose', 'clear_screen',
|
| 80 |
+
'columnize', 'command_line', 'compare', 'complex_abs', 'complex_add',
|
| 81 |
+
'complex_arg', 'complex_conjugate', 'complex_cos', 'complex_cosh',
|
| 82 |
+
'complex_div', 'complex_exp', 'complex_imag', 'complex_inv',
|
| 83 |
+
'complex_log', 'complex_mul', 'complex_neg', 'complex_new',
|
| 84 |
+
'complex_norm', 'complex_power', 'complex_rho', 'complex_real',
|
| 85 |
+
'complex_round', 'complex_sin', 'complex_sinh', 'complex_sprint',
|
| 86 |
+
'complex_sqrt', 'complex_sub', 'complex_theta', 'concat', 'cos',
|
| 87 |
+
'crash', 'custom_sort', 'date', 'day_of_week', 'day_of_year',
|
| 88 |
+
'days_in_month', 'decode_base64', 'decode_flags', 'deep_copy', 'deld',
|
| 89 |
+
'deserialize', 'destroy_dict', 'destroy_queue', 'destroy_stack',
|
| 90 |
+
'dict_name', 'dict_size', 'elapsed', 'elapsed_short', 'encode_base64',
|
| 91 |
+
'equal', 'even', 'exp', 'extract', 'factorial', 'factors',
|
| 92 |
+
'file_size_k', 'find', 'find_all', 'find_any', 'find_replace', 'filter',
|
| 93 |
+
'flatten', 'float32_to_atom', 'float64_to_atom', 'floor',
|
| 94 |
+
'format_timedate', 'free_console', 'from_polar', 'gcd', 'get_file_base',
|
| 95 |
+
'get_file_extension', 'get_file_name', 'get_file_name_and_path',
|
| 96 |
+
'get_file_path', 'get_file_path_and_name', 'get_maxprime', 'get_prime',
|
| 97 |
+
'get_primes', 'get_primes_le', 'get_proper_dir', 'get_proper_path',
|
| 98 |
+
'get_rand', 'get_routine_info', 'get_test_abort', 'get_test_logfile',
|
| 99 |
+
'get_test_pause', 'get_test_verbosity', 'get_tzid', 'getd', 'getdd',
|
| 100 |
+
'getd_all_keys', 'getd_by_index', 'getd_index', 'getd_partial_key',
|
| 101 |
+
'glAttachShader', 'glBindBuffer', 'glBindTexture', 'glBufferData',
|
| 102 |
+
'glCanvasSpecialText', 'glClear', 'glClearColor', 'glColor',
|
| 103 |
+
'glCompileShader', 'glCreateBuffer', 'glCreateProgram',
|
| 104 |
+
'glCreateShader', 'glCreateTexture', 'glDeleteProgram',
|
| 105 |
+
'glDeleteShader', 'glDrawArrays', 'glEnable',
|
| 106 |
+
'glEnableVertexAttribArray', 'glFloat32Array', 'glInt32Array',
|
| 107 |
+
'glFlush', 'glGetAttribLocation', 'glGetError', 'glGetProgramInfoLog',
|
| 108 |
+
'glGetProgramParameter', 'glGetShaderInfoLog', 'glGetShaderParameter',
|
| 109 |
+
'glGetUniformLocation', 'glLinkProgram', 'glLoadIdentity',
|
| 110 |
+
'glMatrixMode', 'glOrtho', 'glRotatef', 'glShadeModel',
|
| 111 |
+
'glShaderSource', 'glSimpleA7texcoords', 'glTexImage2Dc',
|
| 112 |
+
'glTexParameteri', 'glTranslate', 'glUniform1f', 'glUniform1i',
|
| 113 |
+
'glUniformMatrix4fv', 'glUseProgram', 'glVertex',
|
| 114 |
+
'glVertexAttribPointer', 'glViewport', 'head', 'hsv_to_rgb', 'iff',
|
| 115 |
+
'iif', 'include_file', 'incl0de_file', 'insert', 'instance',
|
| 116 |
+
'int_to_bits', 'int_to_bytes', 'is_dict', 'is_integer', 's_leap_year',
|
| 117 |
+
'is_prime', 'is_prime2', 'islower', 'isupper', 'Icallback',
|
| 118 |
+
'iup_isdouble', 'iup_isprint', 'iup_XkeyBase', 'IupAppend', 'IupAlarm',
|
| 119 |
+
'IupBackgroundBox', 'IupButton', 'IupCalendar', 'IupCanvas',
|
| 120 |
+
'IupClipboard', 'IupClose', 'IupCloseOnEscape', 'IupControlsOpen',
|
| 121 |
+
'IupDatePick', 'IupDestroy', 'IupDialog', 'IupDrawArc', 'IupDrawBegin',
|
| 122 |
+
'IupDrawEnd', 'IupDrawGetSize', 'IupDrawGetTextSize', 'IupDrawLine',
|
| 123 |
+
'IupDrawRectangle', 'IupDrawText', 'IupExpander', 'IupFill',
|
| 124 |
+
'IupFlatLabel', 'IupFlatList', 'IupFlatTree', 'IupFlush', 'IupFrame',
|
| 125 |
+
'IupGetAttribute', 'IupGetAttributeId', 'IupGetAttributePtr',
|
| 126 |
+
'IupGetBrother', 'IupGetChild', 'IupGetChildCount', 'IupGetClassName',
|
| 127 |
+
'IupGetDialog', 'IupGetDialogChild', 'IupGetDouble', 'IupGetFocus',
|
| 128 |
+
'IupGetGlobal', 'IupGetGlobalInt', 'IupGetGlobalIntInt', 'IupGetInt',
|
| 129 |
+
'IupGetInt2', 'IupGetIntId', 'IupGetIntInt', 'IupGetParent',
|
| 130 |
+
'IupGLCanvas', 'IupGLCanvasOpen', 'IupGLMakeCurrent', 'IupGraph',
|
| 131 |
+
'IupHbox', 'IupHide', 'IupImage', 'IupImageRGBA', 'IupItem',
|
| 132 |
+
'iupKeyCodeToName', 'IupLabel', 'IupLink', 'IupList', 'IupMap',
|
| 133 |
+
'IupMenu', 'IupMenuItem', 'IupMessage', 'IupMessageDlg', 'IupMultiBox',
|
| 134 |
+
'IupMultiLine', 'IupNextField', 'IupNormaliser', 'IupOpen',
|
| 135 |
+
'IupPlayInput', 'IupPopup', 'IupPreviousField', 'IupProgressBar',
|
| 136 |
+
'IupRadio', 'IupRecordInput', 'IupRedraw', 'IupRefresh',
|
| 137 |
+
'IupRefreshChildren', 'IupSeparator', 'IupSetAttribute',
|
| 138 |
+
'IupSetAttributes', 'IupSetAttributeHandle', 'IupSetAttributeId',
|
| 139 |
+
'IupSetAttributePtr', 'IupSetCallback', 'IupSetCallbacks',
|
| 140 |
+
'IupSetDouble', 'IupSetFocus', 'IupSetGlobal', 'IupSetGlobalInt',
|
| 141 |
+
'IupSetGlobalFunction', 'IupSetHandle', 'IupSetInt',
|
| 142 |
+
'IupSetStrAttribute', 'IupSetStrGlobal', 'IupShow', 'IupShowXY',
|
| 143 |
+
'IupSplit', 'IupStoreAttribute', 'IupSubmenu', 'IupTable',
|
| 144 |
+
'IupTableClearSelected', 'IupTableClick_cb', 'IupTableGetSelected',
|
| 145 |
+
'IupTableResize_cb', 'IupTableSetData', 'IupTabs', 'IupText',
|
| 146 |
+
'IupTimer', 'IupToggle', 'IupTreeAddNodes', 'IupTreeView', 'IupUpdate',
|
| 147 |
+
'IupValuator', 'IupVbox', 'join', 'join_by', 'join_path', 'k_perm',
|
| 148 |
+
'largest', 'lcm', 'length', 'log', 'log10', 'log2', 'lower',
|
| 149 |
+
'm4_crossProduct', 'm4_inverse', 'm4_lookAt', 'm4_multiply',
|
| 150 |
+
'm4_normalize', 'm4_perspective', 'm4_subtractVectors', 'm4_xRotate',
|
| 151 |
+
'm4_yRotate', 'machine_bits', 'machine_word', 'match', 'match_all',
|
| 152 |
+
'match_replace', 'max', 'maxsq', 'min', 'minsq', 'mod', 'mpfr_add',
|
| 153 |
+
'mpfr_ceil', 'mpfr_cmp', 'mpfr_cmp_si', 'mpfr_const_pi', 'mpfr_div',
|
| 154 |
+
'mpfr_div_si', 'mpfr_div_z', 'mpfr_floor', 'mpfr_free', 'mpfr_get_d',
|
| 155 |
+
'mpfr_get_default_precision', 'mpfr_get_default_rounding_mode',
|
| 156 |
+
'mpfr_get_fixed', 'mpfr_get_precision', 'mpfr_get_si', 'mpfr_init',
|
| 157 |
+
'mpfr_inits', 'mpfr_init_set', 'mpfr_init_set_q', 'mpfr_init_set_z',
|
| 158 |
+
'mpfr_mul', 'mpfr_mul_si', 'mpfr_pow_si', 'mpfr_set', 'mpfr_set_d',
|
| 159 |
+
'mpfr_set_default_precision', 'mpfr_set_default_rounding_mode',
|
| 160 |
+
'mpfr_set_precision', 'mpfr_set_q', 'mpfr_set_si', 'mpfr_set_str',
|
| 161 |
+
'mpfr_set_z', 'mpfr_si_div', 'mpfr_si_sub', 'mpfr_sqrt', 'mpfr_sub',
|
| 162 |
+
'mpfr_sub_si', 'mpq_abs', 'mpq_add', 'mpq_add_si', 'mpq_canonicalize',
|
| 163 |
+
'mpq_cmp', 'mpq_cmp_si', 'mpq_div', 'mpq_div_2exp', 'mpq_free',
|
| 164 |
+
'mpq_get_den', 'mpq_get_num', 'mpq_get_str', 'mpq_init', 'mpq_init_set',
|
| 165 |
+
'mpq_init_set_si', 'mpq_init_set_str', 'mpq_init_set_z', 'mpq_inits',
|
| 166 |
+
'mpq_inv', 'mpq_mul', 'mpq_neg', 'mpq_set', 'mpq_set_si', 'mpq_set_str',
|
| 167 |
+
'mpq_set_z', 'mpq_sub', 'mpz_abs', 'mpz_add', 'mpz_addmul',
|
| 168 |
+
'mpz_addmul_ui', 'mpz_addmul_si', 'mpz_add_si', 'mpz_add_ui', 'mpz_and',
|
| 169 |
+
'mpz_bin_uiui', 'mpz_cdiv_q', 'mpz_cmp', 'mpz_cmp_si', 'mpz_divexact',
|
| 170 |
+
'mpz_divexact_ui', 'mpz_divisible_p', 'mpz_divisible_ui_p', 'mpz_even',
|
| 171 |
+
'mpz_fac_ui', 'mpz_factorstring', 'mpz_fdiv_q', 'mpz_fdiv_q_2exp',
|
| 172 |
+
'mpz_fdiv_q_ui', 'mpz_fdiv_qr', 'mpz_fdiv_r', 'mpz_fdiv_ui',
|
| 173 |
+
'mpz_fib_ui', 'mpz_fib2_ui', 'mpz_fits_atom', 'mpz_fits_integer',
|
| 174 |
+
'mpz_free', 'mpz_gcd', 'mpz_gcd_ui', 'mpz_get_atom', 'mpz_get_integer',
|
| 175 |
+
'mpz_get_short_str', 'mpz_get_str', 'mpz_init', 'mpz_init_set',
|
| 176 |
+
'mpz_inits', 'mpz_invert', 'mpz_lcm', 'mpz_lcm_ui', 'mpz_max',
|
| 177 |
+
'mpz_min', 'mpz_mod', 'mpz_mod_ui', 'mpz_mul', 'mpz_mul_2exp',
|
| 178 |
+
'mpz_mul_d', 'mpz_mul_si', 'mpz_neg', 'mpz_nthroot', 'mpz_odd',
|
| 179 |
+
'mpz_pollard_rho', 'mpz_pow_ui', 'mpz_powm', 'mpz_powm_ui', 'mpz_prime',
|
| 180 |
+
'mpz_prime_factors', 'mpz_prime_mr', 'mpz_rand', 'mpz_rand_ui',
|
| 181 |
+
'mpz_re_compose', 'mpz_remove', 'mpz_scan0', 'mpz_scan1', 'mpz_set',
|
| 182 |
+
'mpz_set_d', 'mpz_set_si', 'mpz_set_str', 'mpz_set_v', 'mpz_sign',
|
| 183 |
+
'mpz_sizeinbase', 'mpz_sqrt', 'mpz_sub', 'mpz_sub_si', 'mpz_sub_ui',
|
| 184 |
+
'mpz_si_sub', 'mpz_tdiv_q_2exp', 'mpz_tdiv_r_2exp', 'mpz_tstbit',
|
| 185 |
+
'mpz_ui_pow_ui', 'mpz_xor', 'named_dict', 'new_dict', 'new_queue',
|
| 186 |
+
'new_stack', 'not_bits', 'not_bitsu', 'odd', 'or_all', 'or_allu',
|
| 187 |
+
'or_bits', 'or_bitsu', 'ord', 'ordinal', 'ordinant',
|
| 188 |
+
'override_timezone', 'pad', 'pad_head', 'pad_tail', 'parse_date_string',
|
| 189 |
+
'papply', 'peep', 'peepn', 'peep_dict', 'permute', 'permutes',
|
| 190 |
+
'platform', 'pop', 'popn', 'pop_dict', 'power', 'pp', 'ppEx', 'ppExf',
|
| 191 |
+
'ppf', 'ppOpt', 'pq_add', 'pq_destroy', 'pq_empty', 'pq_new', 'pq_peek',
|
| 192 |
+
'pq_pop', 'pq_pop_data', 'pq_size', 'prepend', 'prime_factors',
|
| 193 |
+
'printf', 'product', 'proper', 'push', 'pushn', 'putd', 'puts',
|
| 194 |
+
'queue_empty', 'queue_size', 'rand', 'rand_range', 'reinstate',
|
| 195 |
+
'remainder', 'remove', 'remove_all', 'repeat', 'repeatch', 'replace',
|
| 196 |
+
'requires', 'reverse', 'rfind', 'rgb', 'rmatch', 'rmdr', 'rnd', 'round',
|
| 197 |
+
'routine_id', 'scanf', 'serialize', 'series', 'set_rand',
|
| 198 |
+
'set_test_abort', 'set_test_logfile', 'set_test_module',
|
| 199 |
+
'set_test_pause', 'set_test_verbosity', 'set_timedate_formats',
|
| 200 |
+
'set_timezone', 'setd', 'setd_default', 'shorten', 'sha256',
|
| 201 |
+
'shift_bits', 'shuffle', 'sign', 'sin', 'smallest', 'sort',
|
| 202 |
+
'sort_columns', 'speak', 'splice', 'split', 'split_any', 'split_by',
|
| 203 |
+
'sprint', 'sprintf', 'sq_abs', 'sq_add', 'sq_and', 'sq_and_bits',
|
| 204 |
+
'sq_arccos', 'sq_arcsin', 'sq_arctan', 'sq_atom', 'sq_ceil', 'sq_cmp',
|
| 205 |
+
'sq_cos', 'sq_div', 'sq_even', 'sq_eq', 'sq_floor', 'sq_floor_div',
|
| 206 |
+
'sq_ge', 'sq_gt', 'sq_int', 'sq_le', 'sq_log', 'sq_log10', 'sq_log2',
|
| 207 |
+
'sq_lt', 'sq_max', 'sq_min', 'sq_mod', 'sq_mul', 'sq_ne', 'sq_not',
|
| 208 |
+
'sq_not_bits', 'sq_odd', 'sq_or', 'sq_or_bits', 'sq_power', 'sq_rand',
|
| 209 |
+
'sq_remainder', 'sq_rmdr', 'sq_rnd', 'sq_round', 'sq_seq', 'sq_sign',
|
| 210 |
+
'sq_sin', 'sq_sqrt', 'sq_str', 'sq_sub', 'sq_tan', 'sq_trunc',
|
| 211 |
+
'sq_uminus', 'sq_xor', 'sq_xor_bits', 'sqrt', 'square_free',
|
| 212 |
+
'stack_empty', 'stack_size', 'substitute', 'substitute_all', 'sum',
|
| 213 |
+
'tail', 'tan', 'test_equal', 'test_fail', 'test_false',
|
| 214 |
+
'test_not_equal', 'test_pass', 'test_summary', 'test_true',
|
| 215 |
+
'text_color', 'throw', 'time', 'timedate_diff', 'timedelta',
|
| 216 |
+
'to_integer', 'to_number', 'to_rgb', 'to_string', 'traverse_dict',
|
| 217 |
+
'traverse_dict_partial_key', 'trim', 'trim_head', 'trim_tail', 'trunc',
|
| 218 |
+
'tagset', 'tagstart', 'typeof', 'unique', 'unix_dict', 'upper',
|
| 219 |
+
'utf8_to_utf32', 'utf32_to_utf8', 'version', 'vlookup', 'vslice',
|
| 220 |
+
'wglGetProcAddress', 'wildcard_file', 'wildcard_match', 'with_rho',
|
| 221 |
+
'with_theta', 'xml_new_doc', 'xml_new_element', 'xml_set_attribute',
|
| 222 |
+
'xml_sprint', 'xor_bits', 'xor_bitsu',
|
| 223 |
+
'accept', 'allocate', 'allocate_string', 'allow_break', 'ARM',
|
| 224 |
+
'atom_to_float80', 'c_func', 'c_proc', 'call_back', 'chdir',
|
| 225 |
+
'check_break', 'clearDib', 'close', 'closesocket', 'console',
|
| 226 |
+
'copy_file', 'create', 'create_directory', 'create_thread',
|
| 227 |
+
'curl_easy_cleanup', 'curl_easy_get_file', 'curl_easy_init',
|
| 228 |
+
'curl_easy_perform', 'curl_easy_perform_ex', 'curl_easy_setopt',
|
| 229 |
+
'curl_easy_strerror', 'curl_global_cleanup', 'curl_global_init',
|
| 230 |
+
'curl_slist_append', 'curl_slist_free_all', 'current_dir', 'cursor',
|
| 231 |
+
'define_c_func', 'define_c_proc', 'delete', 'delete_cs', 'delete_file',
|
| 232 |
+
'dir', 'DLL', 'drawDib', 'drawShadedPolygonToDib', 'ELF32', 'ELF64',
|
| 233 |
+
'enter_cs', 'eval', 'exit_thread', 'free', 'file_exists', 'final',
|
| 234 |
+
'float80_to_atom', 'format', 'get_bytes', 'get_file_date',
|
| 235 |
+
'get_file_size', 'get_file_type', 'get_interpreter', 'get_key',
|
| 236 |
+
'get_socket_error', 'get_text', 'get_thread_exitcode', 'get_thread_id',
|
| 237 |
+
'getc', 'getenv', 'gets', 'getsockaddr', 'glBegin', 'glCallList',
|
| 238 |
+
'glFrustum', 'glGenLists', 'glGetString', 'glLight', 'glMaterial',
|
| 239 |
+
'glNewList', 'glNormal', 'glPopMatrix', 'glPushMatrix', 'glRotate',
|
| 240 |
+
'glEnd', 'glEndList', 'glTexImage2D', 'goto', 'GUI', 'icons', 'ilASM',
|
| 241 |
+
'include_files', 'include_paths', 'init_cs', 'ip_to_string',
|
| 242 |
+
'IupConfig', 'IupConfigDialogClosed', 'IupConfigDialogShow',
|
| 243 |
+
'IupConfigGetVariableInt', 'IupConfigLoad', 'IupConfigSave',
|
| 244 |
+
'IupConfigSetVariableInt', 'IupExitLoop', 'IupFileDlg', 'IupFileList',
|
| 245 |
+
'IupGLSwapBuffers', 'IupHelp', 'IupLoopStep', 'IupMainLoop',
|
| 246 |
+
'IupNormalizer', 'IupPlot', 'IupPlotAdd', 'IupPlotBegin', 'IupPlotEnd',
|
| 247 |
+
'IupPlotInsert', 'IupSaveImage', 'IupTreeGetUserId', 'IupUser',
|
| 248 |
+
'IupVersion', 'IupVersionDate', 'IupVersionNumber', 'IupVersionShow',
|
| 249 |
+
'killDib', 'leave_cs', 'listen', 'manifest', 'mem_copy', 'mem_set',
|
| 250 |
+
'mpfr_gamma', 'mpfr_printf', 'mpfr_sprintf', 'mpz_export', 'mpz_import',
|
| 251 |
+
'namespace', 'new', 'newDib', 'open', 'open_dll', 'PE32', 'PE64',
|
| 252 |
+
'peek', 'peek_string', 'peek1s', 'peek1u', 'peek2s', 'peek2u', 'peek4s',
|
| 253 |
+
'peek4u', 'peek8s', 'peek8u', 'peekNS', 'peekns', 'peeknu', 'poke',
|
| 254 |
+
'poke2', 'poke4', 'poke8', 'pokeN', 'poke_string', 'poke_wstring',
|
| 255 |
+
'position', 'progress', 'prompt_number', 'prompt_string', 'read_file',
|
| 256 |
+
'read_lines', 'recv', 'resume_thread', 'seek', 'select', 'send',
|
| 257 |
+
'setHandler', 'shutdown', 'sleep', 'SO', 'sockaddr_in', 'socket',
|
| 258 |
+
'split_path', 'suspend_thread', 'system', 'system_exec', 'system_open',
|
| 259 |
+
'system_wait', 'task_clock_start', 'task_clock_stop', 'task_create',
|
| 260 |
+
'task_delay', 'task_list', 'task_schedule', 'task_self', 'task_status',
|
| 261 |
+
'task_suspend', 'task_yield', 'thread_safe_string', 'try_cs',
|
| 262 |
+
'utf8_to_utf16', 'utf16_to_utf8', 'utf16_to_utf32', 'utf32_to_utf16',
|
| 263 |
+
'video_config', 'WSACleanup', 'wait_thread', 'walk_dir', 'where',
|
| 264 |
+
'write_lines', 'wait_key'
|
| 265 |
+
)
|
| 266 |
+
constants = (
|
| 267 |
+
'ANY_QUEUE', 'ASCENDING', 'BLACK', 'BLOCK_CURSOR', 'BLUE',
|
| 268 |
+
'BRIGHT_CYAN', 'BRIGHT_BLUE', 'BRIGHT_GREEN', 'BRIGHT_MAGENTA',
|
| 269 |
+
'BRIGHT_RED', 'BRIGHT_WHITE', 'BROWN', 'C_DWORD', 'C_INT', 'C_POINTER',
|
| 270 |
+
'C_USHORT', 'C_WORD', 'CD_AMBER', 'CD_BLACK', 'CD_BLUE', 'CD_BOLD',
|
| 271 |
+
'CD_BOLD_ITALIC', 'CD_BOX', 'CD_CENTER', 'CD_CIRCLE', 'CD_CLOSED_LINES',
|
| 272 |
+
'CD_CONTINUOUS', 'CD_CUSTOM', 'CD_CYAN', 'CD_DARK_BLUE', 'CD_DARK_CYAN',
|
| 273 |
+
'CD_DARK_GRAY', 'CD_DARK_GREY', 'CD_DARK_GREEN', 'CD_DARK_MAGENTA',
|
| 274 |
+
'CD_DARK_RED', 'CD_DARK_YELLOW', 'CD_DASH_DOT', 'CD_DASH_DOT_DOT',
|
| 275 |
+
'CD_DASHED', 'CD_DBUFFER', 'CD_DEG2RAD', 'CD_DIAMOND', 'CD_DOTTED',
|
| 276 |
+
'CD_EAST', 'CD_EVENODD', 'CD_FILL', 'CD_GL', 'CD_GRAY', 'CD_GREY',
|
| 277 |
+
'CD_GREEN', 'CD_HATCH', 'CD_HOLLOW', 'CD_HOLLOW_BOX',
|
| 278 |
+
'CD_HOLLOW_CIRCLE', 'CD_HOLLOW_DIAMOND', 'CD_INDIGO', 'CD_ITALIC',
|
| 279 |
+
'CD_IUP', 'CD_IUPDBUFFER', 'CD_LIGHT_BLUE', 'CD_LIGHT_GRAY',
|
| 280 |
+
'CD_LIGHT_GREY', 'CD_LIGHT_GREEN', 'CD_LIGHT_PARCHMENT', 'CD_MAGENTA',
|
| 281 |
+
'CD_NAVY', 'CD_NORTH', 'CD_NORTH_EAST', 'CD_NORTH_WEST', 'CD_OLIVE',
|
| 282 |
+
'CD_OPEN_LINES', 'CD_ORANGE', 'CD_PARCHMENT', 'CD_PATTERN',
|
| 283 |
+
'CD_PRINTER', 'CD_PURPLE', 'CD_PLAIN', 'CD_PLUS', 'CD_QUERY',
|
| 284 |
+
'CD_RAD2DEG', 'CD_RED', 'CD_SILVER', 'CD_SOLID', 'CD_SOUTH_EAST',
|
| 285 |
+
'CD_SOUTH_WEST', 'CD_STAR', 'CD_STIPPLE', 'CD_STRIKEOUT',
|
| 286 |
+
'CD_UNDERLINE', 'CD_WEST', 'CD_WHITE', 'CD_WINDING', 'CD_VIOLET',
|
| 287 |
+
'CD_X', 'CD_YELLOW', 'CURLE_OK', 'CURLOPT_MAIL_FROM',
|
| 288 |
+
'CURLOPT_MAIL_RCPT', 'CURLOPT_PASSWORD', 'CURLOPT_READDATA',
|
| 289 |
+
'CURLOPT_READFUNCTION', 'CURLOPT_SSL_VERIFYPEER',
|
| 290 |
+
'CURLOPT_SSL_VERIFYHOST', 'CURLOPT_UPLOAD', 'CURLOPT_URL',
|
| 291 |
+
'CURLOPT_USE_SSL', 'CURLOPT_USERNAME', 'CURLOPT_VERBOSE',
|
| 292 |
+
'CURLOPT_WRITEFUNCTION', 'CURLUSESSL_ALL', 'CYAN', 'D_NAME',
|
| 293 |
+
'D_ATTRIBUTES', 'D_SIZE', 'D_YEAR', 'D_MONTH', 'D_DAY', 'D_HOUR',
|
| 294 |
+
'D_MINUTE', 'D_SECOND', 'D_CREATION', 'D_LASTACCESS', 'D_MODIFICATION',
|
| 295 |
+
'DT_YEAR', 'DT_MONTH', 'DT_DAY', 'DT_HOUR', 'DT_MINUTE', 'DT_SECOND',
|
| 296 |
+
'DT_DOW', 'DT_MSEC', 'DT_DOY', 'DT_GMT', 'EULER', 'E_CODE', 'E_ADDR',
|
| 297 |
+
'E_LINE', 'E_RTN', 'E_NAME', 'E_FILE', 'E_PATH', 'E_USER', 'false',
|
| 298 |
+
'False', 'FALSE', 'FIFO_QUEUE', 'FILETYPE_DIRECTORY', 'FILETYPE_FILE',
|
| 299 |
+
'GET_EOF', 'GET_FAIL', 'GET_IGNORE', 'GET_SUCCESS',
|
| 300 |
+
'GL_AMBIENT_AND_DIFFUSE', 'GL_ARRAY_BUFFER', 'GL_CLAMP',
|
| 301 |
+
'GL_CLAMP_TO_BORDER', 'GL_CLAMP_TO_EDGE', 'GL_COLOR_BUFFER_BIT',
|
| 302 |
+
'GL_COMPILE', 'GL_COMPILE_STATUS', 'GL_CULL_FACE',
|
| 303 |
+
'GL_DEPTH_BUFFER_BIT', 'GL_DEPTH_TEST', 'GL_EXTENSIONS', 'GL_FLAT',
|
| 304 |
+
'GL_FLOAT', 'GL_FRAGMENT_SHADER', 'GL_FRONT', 'GL_LIGHT0',
|
| 305 |
+
'GL_LIGHTING', 'GL_LINEAR', 'GL_LINK_STATUS', 'GL_MODELVIEW',
|
| 306 |
+
'GL_NEAREST', 'GL_NO_ERROR', 'GL_NORMALIZE', 'GL_POSITION',
|
| 307 |
+
'GL_PROJECTION', 'GL_QUAD_STRIP', 'GL_QUADS', 'GL_RENDERER',
|
| 308 |
+
'GL_REPEAT', 'GL_RGB', 'GL_RGBA', 'GL_SMOOTH', 'GL_STATIC_DRAW',
|
| 309 |
+
'GL_TEXTURE_2D', 'GL_TEXTURE_MAG_FILTER', 'GL_TEXTURE_MIN_FILTER',
|
| 310 |
+
'GL_TEXTURE_WRAP_S', 'GL_TEXTURE_WRAP_T', 'GL_TRIANGLES',
|
| 311 |
+
'GL_UNSIGNED_BYTE', 'GL_VENDOR', 'GL_VERSION', 'GL_VERTEX_SHADER',
|
| 312 |
+
'GRAY', 'GREEN', 'GT_LF_STRIPPED', 'GT_WHOLE_FILE', 'INVLN10',
|
| 313 |
+
'IUP_CLOSE', 'IUP_CONTINUE', 'IUP_DEFAULT', 'IUP_BLACK', 'IUP_BLUE',
|
| 314 |
+
'IUP_BUTTON1', 'IUP_BUTTON3', 'IUP_CENTER', 'IUP_CYAN', 'IUP_DARK_BLUE',
|
| 315 |
+
'IUP_DARK_CYAN', 'IUP_DARK_GRAY', 'IUP_DARK_GREY', 'IUP_DARK_GREEN',
|
| 316 |
+
'IUP_DARK_MAGENTA', 'IUP_DARK_RED', 'IUP_GRAY', 'IUP_GREY', 'IUP_GREEN',
|
| 317 |
+
'IUP_IGNORE', 'IUP_INDIGO', 'IUP_MAGENTA', 'IUP_MASK_INT',
|
| 318 |
+
'IUP_MASK_UINT', 'IUP_MOUSEPOS', 'IUP_NAVY', 'IUP_OLIVE', 'IUP_RECTEXT',
|
| 319 |
+
'IUP_RED', 'IUP_LIGHT_BLUE', 'IUP_LIGHT_GRAY', 'IUP_LIGHT_GREY',
|
| 320 |
+
'IUP_LIGHT_GREEN', 'IUP_ORANGE', 'IUP_PARCHMENT', 'IUP_PURPLE',
|
| 321 |
+
'IUP_SILVER', 'IUP_TEAL', 'IUP_VIOLET', 'IUP_WHITE', 'IUP_YELLOW',
|
| 322 |
+
'K_BS', 'K_cA', 'K_cC', 'K_cD', 'K_cF5', 'K_cK', 'K_cM', 'K_cN', 'K_cO',
|
| 323 |
+
'K_cP', 'K_cR', 'K_cS', 'K_cT', 'K_cW', 'K_CR', 'K_DEL', 'K_DOWN',
|
| 324 |
+
'K_END', 'K_ESC', 'K_F1', 'K_F2', 'K_F3', 'K_F4', 'K_F5', 'K_F6',
|
| 325 |
+
'K_F7', 'K_F8', 'K_F9', 'K_F10', 'K_F11', 'K_F12', 'K_HOME', 'K_INS',
|
| 326 |
+
'K_LEFT', 'K_MIDDLE', 'K_PGDN', 'K_PGUP', 'K_RIGHT', 'K_SP', 'K_TAB',
|
| 327 |
+
'K_UP', 'K_h', 'K_i', 'K_j', 'K_p', 'K_r', 'K_s', 'JS', 'LIFO_QUEUE',
|
| 328 |
+
'LINUX', 'MAX_HEAP', 'MAGENTA', 'MIN_HEAP', 'Nan', 'NO_CURSOR', 'null',
|
| 329 |
+
'NULL', 'PI', 'pp_Ascii', 'pp_Brkt', 'pp_Date', 'pp_File', 'pp_FltFmt',
|
| 330 |
+
'pp_Indent', 'pp_IntCh', 'pp_IntFmt', 'pp_Maxlen', 'pp_Nest',
|
| 331 |
+
'pp_Pause', 'pp_Q22', 'pp_StrFmt', 'RED', 'SEEK_OK', 'SLASH',
|
| 332 |
+
'TEST_ABORT', 'TEST_CRASH', 'TEST_PAUSE', 'TEST_PAUSE_FAIL',
|
| 333 |
+
'TEST_QUIET', 'TEST_SHOW_ALL', 'TEST_SHOW_FAILED', 'TEST_SUMMARY',
|
| 334 |
+
'true', 'True', 'TRUE', 'VC_SCRNLINES', 'WHITE', 'WINDOWS', 'YELLOW'
|
| 335 |
+
)
|
| 336 |
+
|
| 337 |
+
tokens = {
|
| 338 |
+
'root': [
|
| 339 |
+
(r"\s+", Whitespace),
|
| 340 |
+
(r'/\*|--/\*|#\[', Comment.Multiline, 'comment'),
|
| 341 |
+
(r'(?://|--|#!).*$', Comment.Single),
|
| 342 |
+
#Alt:
|
| 343 |
+
# (r'//.*$|--.*$|#!.*$', Comment.Single),
|
| 344 |
+
(r'"([^"\\]|\\.)*"', String.Other),
|
| 345 |
+
(r'\'[^\']*\'', String.Other),
|
| 346 |
+
(r'`[^`]*`', String.Other),
|
| 347 |
+
|
| 348 |
+
(words(types, prefix=r'\b', suffix=r'\b'), Name.Function),
|
| 349 |
+
(words(routines, prefix=r'\b', suffix=r'\b'), Name.Function),
|
| 350 |
+
(words(preproc, prefix=r'\b', suffix=r'\b'), Keyword.Declaration),
|
| 351 |
+
(words(keywords, prefix=r'\b', suffix=r'\b'), Keyword.Declaration),
|
| 352 |
+
(words(constants, prefix=r'\b', suffix=r'\b'), Name.Constant),
|
| 353 |
+
# Aside: Phix only supports/uses the ascii/non-unicode tilde
|
| 354 |
+
(r'!=|==|<<|>>|:=|[-~+/*%=<>&^|\.(){},?:\[\]$\\;#]', Operator),
|
| 355 |
+
(r'[\w-]+', Text)
|
| 356 |
+
],
|
| 357 |
+
'comment': [
|
| 358 |
+
(r'[^*/#]+', Comment.Multiline),
|
| 359 |
+
(r'/\*|#\[', Comment.Multiline, '#push'),
|
| 360 |
+
(r'\*/|#\]', Comment.Multiline, '#pop'),
|
| 361 |
+
(r'[*/#]', Comment.Multiline)
|
| 362 |
+
]
|
| 363 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/php.py
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.php
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for PHP and related languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import Lexer, RegexLexer, include, bygroups, default, \
|
| 14 |
+
using, this, words, do_insertions, line_re
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Other, Generic
|
| 17 |
+
from pygments.util import get_bool_opt, get_list_opt, shebang_matches
|
| 18 |
+
|
| 19 |
+
__all__ = ['ZephirLexer', 'PsyshConsoleLexer', 'PhpLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class ZephirLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For Zephir language source code.
|
| 25 |
+
|
| 26 |
+
Zephir is a compiled high level language aimed
|
| 27 |
+
to the creation of C-extensions for PHP.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
name = 'Zephir'
|
| 31 |
+
url = 'http://zephir-lang.com/'
|
| 32 |
+
aliases = ['zephir']
|
| 33 |
+
filenames = ['*.zep']
|
| 34 |
+
version_added = '2.0'
|
| 35 |
+
|
| 36 |
+
zephir_keywords = ['fetch', 'echo', 'isset', 'empty']
|
| 37 |
+
zephir_type = ['bit', 'bits', 'string']
|
| 38 |
+
|
| 39 |
+
flags = re.DOTALL | re.MULTILINE
|
| 40 |
+
|
| 41 |
+
tokens = {
|
| 42 |
+
'commentsandwhitespace': [
|
| 43 |
+
(r'\s+', Text),
|
| 44 |
+
(r'//.*?\n', Comment.Single),
|
| 45 |
+
(r'/\*.*?\*/', Comment.Multiline)
|
| 46 |
+
],
|
| 47 |
+
'slashstartsregex': [
|
| 48 |
+
include('commentsandwhitespace'),
|
| 49 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 50 |
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
| 51 |
+
(r'/', Operator, '#pop'),
|
| 52 |
+
default('#pop')
|
| 53 |
+
],
|
| 54 |
+
'badregex': [
|
| 55 |
+
(r'\n', Text, '#pop')
|
| 56 |
+
],
|
| 57 |
+
'root': [
|
| 58 |
+
(r'^(?=\s|/)', Text, 'slashstartsregex'),
|
| 59 |
+
include('commentsandwhitespace'),
|
| 60 |
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
| 61 |
+
r'(<<|>>>?|==?|!=?|->|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
|
| 62 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 63 |
+
(r'[})\].]', Punctuation),
|
| 64 |
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|loop|'
|
| 65 |
+
r'require|inline|throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
| 66 |
+
r'namespace|use|extends|this|fetch|isset|unset|echo|fetch|likely|unlikely|'
|
| 67 |
+
r'empty)\b', Keyword, 'slashstartsregex'),
|
| 68 |
+
(r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
| 69 |
+
(r'(abstract|boolean|bool|char|class|const|double|enum|export|extends|final|'
|
| 70 |
+
r'native|goto|implements|import|int|string|interface|long|ulong|char|uchar|'
|
| 71 |
+
r'float|unsigned|private|protected|public|short|static|self|throws|reverse|'
|
| 72 |
+
r'transient|volatile|readonly)\b', Keyword.Reserved),
|
| 73 |
+
(r'(true|false|null|undefined)\b', Keyword.Constant),
|
| 74 |
+
(r'(Array|Boolean|Date|_REQUEST|_COOKIE|_SESSION|'
|
| 75 |
+
r'_GET|_POST|_SERVER|this|stdClass|range|count|iterator|'
|
| 76 |
+
r'window)\b', Name.Builtin),
|
| 77 |
+
(r'[$a-zA-Z_][\w\\]*', Name.Other),
|
| 78 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 79 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 80 |
+
(r'[0-9]+', Number.Integer),
|
| 81 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 82 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 83 |
+
]
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class PsyshConsoleLexer(Lexer):
|
| 88 |
+
"""
|
| 89 |
+
For PsySH console output, such as:
|
| 90 |
+
|
| 91 |
+
.. sourcecode:: psysh
|
| 92 |
+
|
| 93 |
+
>>> $greeting = function($name): string {
|
| 94 |
+
... return "Hello, {$name}";
|
| 95 |
+
... };
|
| 96 |
+
=> Closure($name): string {#2371 …3}
|
| 97 |
+
>>> $greeting('World')
|
| 98 |
+
=> "Hello, World"
|
| 99 |
+
"""
|
| 100 |
+
name = 'PsySH console session for PHP'
|
| 101 |
+
url = 'https://psysh.org/'
|
| 102 |
+
aliases = ['psysh']
|
| 103 |
+
version_added = '2.7'
|
| 104 |
+
|
| 105 |
+
def __init__(self, **options):
|
| 106 |
+
options['startinline'] = True
|
| 107 |
+
Lexer.__init__(self, **options)
|
| 108 |
+
|
| 109 |
+
def get_tokens_unprocessed(self, text):
|
| 110 |
+
phplexer = PhpLexer(**self.options)
|
| 111 |
+
curcode = ''
|
| 112 |
+
insertions = []
|
| 113 |
+
for match in line_re.finditer(text):
|
| 114 |
+
line = match.group()
|
| 115 |
+
if line.startswith('>>> ') or line.startswith('... '):
|
| 116 |
+
insertions.append((len(curcode),
|
| 117 |
+
[(0, Generic.Prompt, line[:4])]))
|
| 118 |
+
curcode += line[4:]
|
| 119 |
+
elif line.rstrip() == '...':
|
| 120 |
+
insertions.append((len(curcode),
|
| 121 |
+
[(0, Generic.Prompt, '...')]))
|
| 122 |
+
curcode += line[3:]
|
| 123 |
+
else:
|
| 124 |
+
if curcode:
|
| 125 |
+
yield from do_insertions(
|
| 126 |
+
insertions, phplexer.get_tokens_unprocessed(curcode))
|
| 127 |
+
curcode = ''
|
| 128 |
+
insertions = []
|
| 129 |
+
yield match.start(), Generic.Output, line
|
| 130 |
+
if curcode:
|
| 131 |
+
yield from do_insertions(insertions,
|
| 132 |
+
phplexer.get_tokens_unprocessed(curcode))
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
class PhpLexer(RegexLexer):
|
| 136 |
+
"""
|
| 137 |
+
For PHP source code.
|
| 138 |
+
For PHP embedded in HTML, use the `HtmlPhpLexer`.
|
| 139 |
+
|
| 140 |
+
Additional options accepted:
|
| 141 |
+
|
| 142 |
+
`startinline`
|
| 143 |
+
If given and ``True`` the lexer starts highlighting with
|
| 144 |
+
php code (i.e.: no starting ``<?php`` required). The default
|
| 145 |
+
is ``False``.
|
| 146 |
+
`funcnamehighlighting`
|
| 147 |
+
If given and ``True``, highlight builtin function names
|
| 148 |
+
(default: ``True``).
|
| 149 |
+
`disabledmodules`
|
| 150 |
+
If given, must be a list of module names whose function names
|
| 151 |
+
should not be highlighted. By default all modules are highlighted
|
| 152 |
+
except the special ``'unknown'`` module that includes functions
|
| 153 |
+
that are known to php but are undocumented.
|
| 154 |
+
|
| 155 |
+
To get a list of allowed modules have a look into the
|
| 156 |
+
`_php_builtins` module:
|
| 157 |
+
|
| 158 |
+
.. sourcecode:: pycon
|
| 159 |
+
|
| 160 |
+
>>> from pygments.lexers._php_builtins import MODULES
|
| 161 |
+
>>> MODULES.keys()
|
| 162 |
+
['PHP Options/Info', 'Zip', 'dba', ...]
|
| 163 |
+
|
| 164 |
+
In fact the names of those modules match the module names from
|
| 165 |
+
the php documentation.
|
| 166 |
+
"""
|
| 167 |
+
|
| 168 |
+
name = 'PHP'
|
| 169 |
+
url = 'https://www.php.net/'
|
| 170 |
+
aliases = ['php', 'php3', 'php4', 'php5']
|
| 171 |
+
filenames = ['*.php', '*.php[345]', '*.inc']
|
| 172 |
+
mimetypes = ['text/x-php']
|
| 173 |
+
version_added = ''
|
| 174 |
+
|
| 175 |
+
# Note that a backslash is included, PHP uses a backslash as a namespace
|
| 176 |
+
# separator.
|
| 177 |
+
_ident_inner = r'(?:[\\_a-z]|[^\x00-\x7f])(?:[\\\w]|[^\x00-\x7f])*'
|
| 178 |
+
# But not inside strings.
|
| 179 |
+
_ident_nons = r'(?:[_a-z]|[^\x00-\x7f])(?:\w|[^\x00-\x7f])*'
|
| 180 |
+
|
| 181 |
+
flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
|
| 182 |
+
tokens = {
|
| 183 |
+
'root': [
|
| 184 |
+
(r'<\?(php)?', Comment.Preproc, 'php'),
|
| 185 |
+
(r'[^<]+', Other),
|
| 186 |
+
(r'<', Other)
|
| 187 |
+
],
|
| 188 |
+
'php': [
|
| 189 |
+
(r'\?>', Comment.Preproc, '#pop'),
|
| 190 |
+
(r'(<<<)([\'"]?)(' + _ident_nons + r')(\2\n.*?\n\s*)(\3)(;?)(\n)',
|
| 191 |
+
bygroups(String, String, String.Delimiter, String, String.Delimiter,
|
| 192 |
+
Punctuation, Text)),
|
| 193 |
+
(r'\s+', Text),
|
| 194 |
+
(r'#\[', Punctuation, 'attribute'),
|
| 195 |
+
(r'#.*?\n', Comment.Single),
|
| 196 |
+
(r'//.*?\n', Comment.Single),
|
| 197 |
+
# put the empty comment here, it is otherwise seen as
|
| 198 |
+
# the start of a docstring
|
| 199 |
+
(r'/\*\*/', Comment.Multiline),
|
| 200 |
+
(r'/\*\*.*?\*/', String.Doc),
|
| 201 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 202 |
+
(r'(->|::)(\s*)(' + _ident_nons + ')',
|
| 203 |
+
bygroups(Operator, Text, Name.Attribute)),
|
| 204 |
+
(r'[~!%^&*+=|:.<>/@-]+', Operator),
|
| 205 |
+
(r'\?', Operator), # don't add to the charclass above!
|
| 206 |
+
(r'[\[\]{}();,]+', Punctuation),
|
| 207 |
+
(r'(new)(\s+)(class)\b', bygroups(Keyword, Text, Keyword)),
|
| 208 |
+
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
|
| 209 |
+
(r'(function)(\s*)(?=\()', bygroups(Keyword, Text)),
|
| 210 |
+
(r'(function)(\s+)(&?)(\s*)',
|
| 211 |
+
bygroups(Keyword, Text, Operator, Text), 'functionname'),
|
| 212 |
+
(r'(const)(\s+)(' + _ident_inner + ')',
|
| 213 |
+
bygroups(Keyword, Text, Name.Constant)),
|
| 214 |
+
# source: https://www.php.net/manual/en/reserved.keywords.php
|
| 215 |
+
(r'(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|'
|
| 216 |
+
r'eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|'
|
| 217 |
+
r'FALSE|print|for|require|continue|foreach|require_once|'
|
| 218 |
+
r'declare|return|default|static|do|switch|die|stdClass|'
|
| 219 |
+
r'echo|else|TRUE|elseif|var|empty|if|xor|enddeclare|include|'
|
| 220 |
+
r'virtual|endfor|include_once|while|endforeach|global|'
|
| 221 |
+
r'endif|list|endswitch|new|endwhile|not|'
|
| 222 |
+
r'array|E_ALL|NULL|final|php_user_filter|interface|'
|
| 223 |
+
r'implements|public|private|protected|abstract|clone|try|'
|
| 224 |
+
r'catch|throw|this|use|namespace|trait|yield( from)?|'
|
| 225 |
+
r'finally|match|readonly)\b', Keyword),
|
| 226 |
+
(r'(true|false|null)\b', Keyword.Constant),
|
| 227 |
+
include('magicconstants'),
|
| 228 |
+
(r'\$\{', Name.Variable, 'variablevariable'),
|
| 229 |
+
(r'\$+' + _ident_inner, Name.Variable),
|
| 230 |
+
(_ident_inner, Name.Other),
|
| 231 |
+
(r'(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?', Number.Float),
|
| 232 |
+
(r'\d+e[+-]?[0-9]+', Number.Float),
|
| 233 |
+
(r'0[0-7]+', Number.Oct),
|
| 234 |
+
(r'0x[a-f0-9]+', Number.Hex),
|
| 235 |
+
(r'\d+', Number.Integer),
|
| 236 |
+
(r'0b[01]+', Number.Bin),
|
| 237 |
+
(r"'([^'\\]*(?:\\.[^'\\]*)*)'", String.Single),
|
| 238 |
+
(r'`([^`\\]*(?:\\.[^`\\]*)*)`', String.Backtick),
|
| 239 |
+
(r'"', String.Double, 'string'),
|
| 240 |
+
],
|
| 241 |
+
'variablevariable': [
|
| 242 |
+
(r'\}', Name.Variable, '#pop'),
|
| 243 |
+
include('php')
|
| 244 |
+
],
|
| 245 |
+
'magicfuncs': [
|
| 246 |
+
# source: http://php.net/manual/en/language.oop5.magic.php
|
| 247 |
+
(words((
|
| 248 |
+
'__construct', '__destruct', '__call', '__callStatic', '__get', '__set',
|
| 249 |
+
'__isset', '__unset', '__sleep', '__wakeup', '__toString', '__invoke',
|
| 250 |
+
'__set_state', '__clone', '__debugInfo',), suffix=r'\b'),
|
| 251 |
+
Name.Function.Magic),
|
| 252 |
+
],
|
| 253 |
+
'magicconstants': [
|
| 254 |
+
# source: https://www.php.net/manual/en/language.constants.magic.php
|
| 255 |
+
(words((
|
| 256 |
+
'__LINE__', '__FILE__', '__DIR__', '__FUNCTION__', '__CLASS__',
|
| 257 |
+
'__TRAIT__', '__METHOD__', '__NAMESPACE__', '__PROPERTY__',),
|
| 258 |
+
suffix=r'\b'),
|
| 259 |
+
Name.Constant),
|
| 260 |
+
],
|
| 261 |
+
'classname': [
|
| 262 |
+
(_ident_inner, Name.Class, '#pop')
|
| 263 |
+
],
|
| 264 |
+
'functionname': [
|
| 265 |
+
include('magicfuncs'),
|
| 266 |
+
(_ident_inner, Name.Function, '#pop'),
|
| 267 |
+
default('#pop')
|
| 268 |
+
],
|
| 269 |
+
'string': [
|
| 270 |
+
(r'"', String.Double, '#pop'),
|
| 271 |
+
(r'[^{$"\\]+', String.Double),
|
| 272 |
+
(r'\\([nrt"$\\]|[0-7]{1,3}|x[0-9a-f]{1,2})', String.Escape),
|
| 273 |
+
(r'\$' + _ident_nons + r'(\[\S+?\]|->' + _ident_nons + ')?',
|
| 274 |
+
String.Interpol),
|
| 275 |
+
(r'(\{\$\{)(.*?)(\}\})',
|
| 276 |
+
bygroups(String.Interpol, using(this, _startinline=True),
|
| 277 |
+
String.Interpol)),
|
| 278 |
+
(r'(\{)(\$.*?)(\})',
|
| 279 |
+
bygroups(String.Interpol, using(this, _startinline=True),
|
| 280 |
+
String.Interpol)),
|
| 281 |
+
(r'(\$\{)(\S+)(\})',
|
| 282 |
+
bygroups(String.Interpol, Name.Variable, String.Interpol)),
|
| 283 |
+
(r'[${\\]', String.Double)
|
| 284 |
+
],
|
| 285 |
+
'attribute': [
|
| 286 |
+
(r'\]', Punctuation, '#pop'),
|
| 287 |
+
(r'\(', Punctuation, 'attributeparams'),
|
| 288 |
+
(_ident_inner, Name.Decorator),
|
| 289 |
+
include('php')
|
| 290 |
+
],
|
| 291 |
+
'attributeparams': [
|
| 292 |
+
(r'\)', Punctuation, '#pop'),
|
| 293 |
+
include('php')
|
| 294 |
+
],
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
def __init__(self, **options):
|
| 298 |
+
self.funcnamehighlighting = get_bool_opt(
|
| 299 |
+
options, 'funcnamehighlighting', True)
|
| 300 |
+
self.disabledmodules = get_list_opt(
|
| 301 |
+
options, 'disabledmodules', ['unknown'])
|
| 302 |
+
self.startinline = get_bool_opt(options, 'startinline', False)
|
| 303 |
+
|
| 304 |
+
# private option argument for the lexer itself
|
| 305 |
+
if '_startinline' in options:
|
| 306 |
+
self.startinline = options.pop('_startinline')
|
| 307 |
+
|
| 308 |
+
# collect activated functions in a set
|
| 309 |
+
self._functions = set()
|
| 310 |
+
if self.funcnamehighlighting:
|
| 311 |
+
from pygments.lexers._php_builtins import MODULES
|
| 312 |
+
for key, value in MODULES.items():
|
| 313 |
+
if key not in self.disabledmodules:
|
| 314 |
+
self._functions.update(value)
|
| 315 |
+
RegexLexer.__init__(self, **options)
|
| 316 |
+
|
| 317 |
+
def get_tokens_unprocessed(self, text):
|
| 318 |
+
stack = ['root']
|
| 319 |
+
if self.startinline:
|
| 320 |
+
stack.append('php')
|
| 321 |
+
for index, token, value in \
|
| 322 |
+
RegexLexer.get_tokens_unprocessed(self, text, stack):
|
| 323 |
+
if token is Name.Other:
|
| 324 |
+
if value in self._functions:
|
| 325 |
+
yield index, Name.Builtin, value
|
| 326 |
+
continue
|
| 327 |
+
yield index, token, value
|
| 328 |
+
|
| 329 |
+
def analyse_text(text):
|
| 330 |
+
if shebang_matches(text, r'php'):
|
| 331 |
+
return True
|
| 332 |
+
rv = 0.0
|
| 333 |
+
if re.search(r'<\?(?!xml)', text):
|
| 334 |
+
rv += 0.3
|
| 335 |
+
return rv
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pointless.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.pointless
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Pointless.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words
|
| 12 |
+
from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, String, Text
|
| 14 |
+
|
| 15 |
+
__all__ = ['PointlessLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class PointlessLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Pointless source code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Pointless'
|
| 24 |
+
url = 'https://ptls.dev'
|
| 25 |
+
aliases = ['pointless']
|
| 26 |
+
filenames = ['*.ptls']
|
| 27 |
+
version_added = '2.7'
|
| 28 |
+
|
| 29 |
+
ops = words([
|
| 30 |
+
"+", "-", "*", "/", "**", "%", "+=", "-=", "*=",
|
| 31 |
+
"/=", "**=", "%=", "|>", "=", "==", "!=", "<", ">",
|
| 32 |
+
"<=", ">=", "=>", "$", "++",
|
| 33 |
+
])
|
| 34 |
+
|
| 35 |
+
keywords = words([
|
| 36 |
+
"if", "then", "else", "where", "with", "cond",
|
| 37 |
+
"case", "and", "or", "not", "in", "as", "for",
|
| 38 |
+
"requires", "throw", "try", "catch", "when",
|
| 39 |
+
"yield", "upval",
|
| 40 |
+
], suffix=r'\b')
|
| 41 |
+
|
| 42 |
+
tokens = {
|
| 43 |
+
'root': [
|
| 44 |
+
(r'[ \n\r]+', Text),
|
| 45 |
+
(r'--.*$', Comment.Single),
|
| 46 |
+
(r'"""', String, 'multiString'),
|
| 47 |
+
(r'"', String, 'string'),
|
| 48 |
+
(r'[\[\](){}:;,.]', Punctuation),
|
| 49 |
+
(ops, Operator),
|
| 50 |
+
(keywords, Keyword),
|
| 51 |
+
(r'\d+|\d*\.\d+', Number),
|
| 52 |
+
(r'(true|false)\b', Name.Builtin),
|
| 53 |
+
(r'[A-Z][a-zA-Z0-9]*\b', String.Symbol),
|
| 54 |
+
(r'output\b', Name.Variable.Magic),
|
| 55 |
+
(r'(export|import)\b', Keyword.Namespace),
|
| 56 |
+
(r'[a-z][a-zA-Z0-9]*\b', Name.Variable)
|
| 57 |
+
],
|
| 58 |
+
'multiString': [
|
| 59 |
+
(r'\\.', String.Escape),
|
| 60 |
+
(r'"""', String, '#pop'),
|
| 61 |
+
(r'"', String),
|
| 62 |
+
(r'[^\\"]+', String),
|
| 63 |
+
],
|
| 64 |
+
'string': [
|
| 65 |
+
(r'\\.', String.Escape),
|
| 66 |
+
(r'"', String, '#pop'),
|
| 67 |
+
(r'\n', Error),
|
| 68 |
+
(r'[^\\"]+', String),
|
| 69 |
+
],
|
| 70 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/pony.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.pony
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Pony and related languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, words
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['PonyLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class PonyLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Pony source code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Pony'
|
| 24 |
+
aliases = ['pony']
|
| 25 |
+
filenames = ['*.pony']
|
| 26 |
+
url = 'https://www.ponylang.io'
|
| 27 |
+
version_added = '2.4'
|
| 28 |
+
|
| 29 |
+
_caps = r'(iso|trn|ref|val|box|tag)'
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'root': [
|
| 33 |
+
(r'\n', Text),
|
| 34 |
+
(r'[^\S\n]+', Text),
|
| 35 |
+
(r'//.*\n', Comment.Single),
|
| 36 |
+
(r'/\*', Comment.Multiline, 'nested_comment'),
|
| 37 |
+
(r'"""(?:.|\n)*?"""', String.Doc),
|
| 38 |
+
(r'"', String, 'string'),
|
| 39 |
+
(r'\'.*\'', String.Char),
|
| 40 |
+
(r'=>|[]{}:().~;,|&!^?[]', Punctuation),
|
| 41 |
+
(words((
|
| 42 |
+
'addressof', 'and', 'as', 'consume', 'digestof', 'is', 'isnt',
|
| 43 |
+
'not', 'or'),
|
| 44 |
+
suffix=r'\b'),
|
| 45 |
+
Operator.Word),
|
| 46 |
+
(r'!=|==|<<|>>|[-+/*%=<>]', Operator),
|
| 47 |
+
(words((
|
| 48 |
+
'box', 'break', 'compile_error', 'compile_intrinsic',
|
| 49 |
+
'continue', 'do', 'else', 'elseif', 'embed', 'end', 'error',
|
| 50 |
+
'for', 'if', 'ifdef', 'in', 'iso', 'lambda', 'let', 'match',
|
| 51 |
+
'object', 'recover', 'ref', 'repeat', 'return', 'tag', 'then',
|
| 52 |
+
'this', 'trn', 'try', 'until', 'use', 'var', 'val', 'where',
|
| 53 |
+
'while', 'with', '#any', '#read', '#send', '#share'),
|
| 54 |
+
suffix=r'\b'),
|
| 55 |
+
Keyword),
|
| 56 |
+
(r'(actor|class|struct|primitive|interface|trait|type)((?:\s)+)',
|
| 57 |
+
bygroups(Keyword, Text), 'typename'),
|
| 58 |
+
(r'(new|fun|be)((?:\s)+)', bygroups(Keyword, Text), 'methodname'),
|
| 59 |
+
(words((
|
| 60 |
+
'I8', 'U8', 'I16', 'U16', 'I32', 'U32', 'I64', 'U64', 'I128',
|
| 61 |
+
'U128', 'ILong', 'ULong', 'ISize', 'USize', 'F32', 'F64',
|
| 62 |
+
'Bool', 'Pointer', 'None', 'Any', 'Array', 'String',
|
| 63 |
+
'Iterator'),
|
| 64 |
+
suffix=r'\b'),
|
| 65 |
+
Name.Builtin.Type),
|
| 66 |
+
(r'_?[A-Z]\w*', Name.Type),
|
| 67 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
|
| 68 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 69 |
+
(r'\d+', Number.Integer),
|
| 70 |
+
(r'(true|false)\b', Name.Builtin),
|
| 71 |
+
(r'_\d*', Name),
|
| 72 |
+
(r'_?[a-z][\w\']*', Name)
|
| 73 |
+
],
|
| 74 |
+
'typename': [
|
| 75 |
+
(_caps + r'?((?:\s)*)(_?[A-Z]\w*)',
|
| 76 |
+
bygroups(Keyword, Text, Name.Class), '#pop')
|
| 77 |
+
],
|
| 78 |
+
'methodname': [
|
| 79 |
+
(_caps + r'?((?:\s)*)(_?[a-z]\w*)',
|
| 80 |
+
bygroups(Keyword, Text, Name.Function), '#pop')
|
| 81 |
+
],
|
| 82 |
+
'nested_comment': [
|
| 83 |
+
(r'[^*/]+', Comment.Multiline),
|
| 84 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 85 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 86 |
+
(r'[*/]', Comment.Multiline)
|
| 87 |
+
],
|
| 88 |
+
'string': [
|
| 89 |
+
(r'"', String, '#pop'),
|
| 90 |
+
(r'\\"', String),
|
| 91 |
+
(r'[^\\"]+', String)
|
| 92 |
+
]
|
| 93 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/praat.py
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.praat
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Praat
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words, bygroups, include
|
| 12 |
+
from pygments.token import Name, Text, Comment, Keyword, String, Punctuation, \
|
| 13 |
+
Number, Operator, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['PraatLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class PraatLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Praat scripts.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Praat'
|
| 24 |
+
url = 'http://www.praat.org'
|
| 25 |
+
aliases = ['praat']
|
| 26 |
+
filenames = ['*.praat', '*.proc', '*.psc']
|
| 27 |
+
version_added = '2.1'
|
| 28 |
+
|
| 29 |
+
keywords = (
|
| 30 |
+
'if', 'then', 'else', 'elsif', 'elif', 'endif', 'fi', 'for', 'from', 'to',
|
| 31 |
+
'endfor', 'endproc', 'while', 'endwhile', 'repeat', 'until', 'select', 'plus',
|
| 32 |
+
'minus', 'demo', 'assert', 'stopwatch', 'nocheck', 'nowarn', 'noprogress',
|
| 33 |
+
'editor', 'endeditor', 'clearinfo',
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
functions_string = (
|
| 37 |
+
'backslashTrigraphsToUnicode', 'chooseDirectory', 'chooseReadFile',
|
| 38 |
+
'chooseWriteFile', 'date', 'demoKey', 'do', 'environment', 'extractLine',
|
| 39 |
+
'extractWord', 'fixed', 'info', 'left', 'mid', 'percent', 'readFile', 'replace',
|
| 40 |
+
'replace_regex', 'right', 'selected', 'string', 'unicodeToBackslashTrigraphs',
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
functions_numeric = (
|
| 44 |
+
'abs', 'appendFile', 'appendFileLine', 'appendInfo', 'appendInfoLine', 'arccos',
|
| 45 |
+
'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'barkToHertz',
|
| 46 |
+
'beginPause', 'beginSendPraat', 'besselI', 'besselK', 'beta', 'beta2',
|
| 47 |
+
'binomialP', 'binomialQ', 'boolean', 'ceiling', 'chiSquareP', 'chiSquareQ',
|
| 48 |
+
'choice', 'comment', 'cos', 'cosh', 'createDirectory', 'deleteFile',
|
| 49 |
+
'demoClicked', 'demoClickedIn', 'demoCommandKeyPressed',
|
| 50 |
+
'demoExtraControlKeyPressed', 'demoInput', 'demoKeyPressed',
|
| 51 |
+
'demoOptionKeyPressed', 'demoShiftKeyPressed', 'demoShow', 'demoWaitForInput',
|
| 52 |
+
'demoWindowTitle', 'demoX', 'demoY', 'differenceLimensToPhon', 'do', 'editor',
|
| 53 |
+
'endPause', 'endSendPraat', 'endsWith', 'erb', 'erbToHertz', 'erf', 'erfc',
|
| 54 |
+
'exitScript', 'exp', 'extractNumber', 'fileReadable', 'fisherP', 'fisherQ',
|
| 55 |
+
'floor', 'gaussP', 'gaussQ', 'hertzToBark', 'hertzToErb', 'hertzToMel',
|
| 56 |
+
'hertzToSemitones', 'imax', 'imin', 'incompleteBeta', 'incompleteGammaP', 'index',
|
| 57 |
+
'index_regex', 'integer', 'invBinomialP', 'invBinomialQ', 'invChiSquareQ', 'invFisherQ',
|
| 58 |
+
'invGaussQ', 'invSigmoid', 'invStudentQ', 'length', 'ln', 'lnBeta', 'lnGamma',
|
| 59 |
+
'log10', 'log2', 'max', 'melToHertz', 'min', 'minusObject', 'natural', 'number',
|
| 60 |
+
'numberOfColumns', 'numberOfRows', 'numberOfSelected', 'objectsAreIdentical',
|
| 61 |
+
'option', 'optionMenu', 'pauseScript', 'phonToDifferenceLimens', 'plusObject',
|
| 62 |
+
'positive', 'randomBinomial', 'randomGauss', 'randomInteger', 'randomPoisson',
|
| 63 |
+
'randomUniform', 'real', 'readFile', 'removeObject', 'rindex', 'rindex_regex',
|
| 64 |
+
'round', 'runScript', 'runSystem', 'runSystem_nocheck', 'selectObject',
|
| 65 |
+
'selected', 'semitonesToHertz', 'sentence', 'sentencetext', 'sigmoid', 'sin', 'sinc',
|
| 66 |
+
'sincpi', 'sinh', 'soundPressureToPhon', 'sqrt', 'startsWith', 'studentP',
|
| 67 |
+
'studentQ', 'tan', 'tanh', 'text', 'variableExists', 'word', 'writeFile', 'writeFileLine',
|
| 68 |
+
'writeInfo', 'writeInfoLine',
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
functions_array = (
|
| 72 |
+
'linear', 'randomGauss', 'randomInteger', 'randomUniform', 'zero',
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
objects = (
|
| 76 |
+
'Activation', 'AffineTransform', 'AmplitudeTier', 'Art', 'Artword',
|
| 77 |
+
'Autosegment', 'BarkFilter', 'BarkSpectrogram', 'CCA', 'Categories',
|
| 78 |
+
'Cepstrogram', 'Cepstrum', 'Cepstrumc', 'ChebyshevSeries', 'ClassificationTable',
|
| 79 |
+
'Cochleagram', 'Collection', 'ComplexSpectrogram', 'Configuration', 'Confusion',
|
| 80 |
+
'ContingencyTable', 'Corpus', 'Correlation', 'Covariance',
|
| 81 |
+
'CrossCorrelationTable', 'CrossCorrelationTables', 'DTW', 'DataModeler',
|
| 82 |
+
'Diagonalizer', 'Discriminant', 'Dissimilarity', 'Distance', 'Distributions',
|
| 83 |
+
'DurationTier', 'EEG', 'ERP', 'ERPTier', 'EditCostsTable', 'EditDistanceTable',
|
| 84 |
+
'Eigen', 'Excitation', 'Excitations', 'ExperimentMFC', 'FFNet', 'FeatureWeights',
|
| 85 |
+
'FileInMemory', 'FilesInMemory', 'Formant', 'FormantFilter', 'FormantGrid',
|
| 86 |
+
'FormantModeler', 'FormantPoint', 'FormantTier', 'GaussianMixture', 'HMM',
|
| 87 |
+
'HMM_Observation', 'HMM_ObservationSequence', 'HMM_State', 'HMM_StateSequence',
|
| 88 |
+
'Harmonicity', 'ISpline', 'Index', 'Intensity', 'IntensityTier', 'IntervalTier',
|
| 89 |
+
'KNN', 'KlattGrid', 'KlattTable', 'LFCC', 'LPC', 'Label', 'LegendreSeries',
|
| 90 |
+
'LinearRegression', 'LogisticRegression', 'LongSound', 'Ltas', 'MFCC', 'MSpline',
|
| 91 |
+
'ManPages', 'Manipulation', 'Matrix', 'MelFilter', 'MelSpectrogram',
|
| 92 |
+
'MixingMatrix', 'Movie', 'Network', 'Object', 'OTGrammar', 'OTHistory', 'OTMulti',
|
| 93 |
+
'PCA', 'PairDistribution', 'ParamCurve', 'Pattern', 'Permutation', 'Photo',
|
| 94 |
+
'Pitch', 'PitchModeler', 'PitchTier', 'PointProcess', 'Polygon', 'Polynomial',
|
| 95 |
+
'PowerCepstrogram', 'PowerCepstrum', 'Procrustes', 'RealPoint', 'RealTier',
|
| 96 |
+
'ResultsMFC', 'Roots', 'SPINET', 'SSCP', 'SVD', 'Salience', 'ScalarProduct',
|
| 97 |
+
'Similarity', 'SimpleString', 'SortedSetOfString', 'Sound', 'Speaker',
|
| 98 |
+
'Spectrogram', 'Spectrum', 'SpectrumTier', 'SpeechSynthesizer', 'SpellingChecker',
|
| 99 |
+
'Strings', 'StringsIndex', 'Table', 'TableOfReal', 'TextGrid', 'TextInterval',
|
| 100 |
+
'TextPoint', 'TextTier', 'Tier', 'Transition', 'VocalTract', 'VocalTractTier',
|
| 101 |
+
'Weight', 'WordList',
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
variables_numeric = (
|
| 105 |
+
'macintosh', 'windows', 'unix', 'praatVersion', 'pi', 'e', 'undefined',
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
variables_string = (
|
| 109 |
+
'praatVersion', 'tab', 'shellDirectory', 'homeDirectory',
|
| 110 |
+
'preferencesDirectory', 'newline', 'temporaryDirectory',
|
| 111 |
+
'defaultDirectory',
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
object_attributes = (
|
| 115 |
+
'ncol', 'nrow', 'xmin', 'ymin', 'xmax', 'ymax', 'nx', 'ny', 'dx', 'dy',
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
tokens = {
|
| 119 |
+
'root': [
|
| 120 |
+
(r'(\s+)(#.*?$)', bygroups(Whitespace, Comment.Single)),
|
| 121 |
+
(r'^#.*?$', Comment.Single),
|
| 122 |
+
(r';[^\n]*', Comment.Single),
|
| 123 |
+
(r'\s+', Whitespace),
|
| 124 |
+
|
| 125 |
+
(r'\bprocedure\b', Keyword, 'procedure_definition'),
|
| 126 |
+
(r'\bcall\b', Keyword, 'procedure_call'),
|
| 127 |
+
(r'@', Name.Function, 'procedure_call'),
|
| 128 |
+
|
| 129 |
+
include('function_call'),
|
| 130 |
+
|
| 131 |
+
(words(keywords, suffix=r'\b'), Keyword),
|
| 132 |
+
|
| 133 |
+
(r'(\bform\b)(\s+)([^\n]+)',
|
| 134 |
+
bygroups(Keyword, Whitespace, String), 'old_form'),
|
| 135 |
+
|
| 136 |
+
(r'(print(?:line|tab)?|echo|exit|asserterror|pause|send(?:praat|socket)|'
|
| 137 |
+
r'include|execute|system(?:_nocheck)?)(\s+)',
|
| 138 |
+
bygroups(Keyword, Whitespace), 'string_unquoted'),
|
| 139 |
+
|
| 140 |
+
(r'(goto|label)(\s+)(\w+)', bygroups(Keyword, Whitespace, Name.Label)),
|
| 141 |
+
|
| 142 |
+
include('variable_name'),
|
| 143 |
+
include('number'),
|
| 144 |
+
|
| 145 |
+
(r'"', String, 'string'),
|
| 146 |
+
|
| 147 |
+
(words((objects), suffix=r'(?=\s+\S+\n)'), Name.Class, 'string_unquoted'),
|
| 148 |
+
|
| 149 |
+
(r'\b[A-Z]', Keyword, 'command'),
|
| 150 |
+
(r'(\.{3}|[)(,])', Punctuation),
|
| 151 |
+
],
|
| 152 |
+
'command': [
|
| 153 |
+
(r'( ?[\w()-]+ ?)', Keyword),
|
| 154 |
+
|
| 155 |
+
include('string_interpolated'),
|
| 156 |
+
|
| 157 |
+
(r'\.{3}', Keyword, ('#pop', 'old_arguments')),
|
| 158 |
+
(r':', Keyword, ('#pop', 'comma_list')),
|
| 159 |
+
(r'\s', Whitespace, '#pop'),
|
| 160 |
+
],
|
| 161 |
+
'procedure_call': [
|
| 162 |
+
(r'\s+', Whitespace),
|
| 163 |
+
(r'([\w.]+)(?:(:)|(?:(\s*)(\()))',
|
| 164 |
+
bygroups(Name.Function, Punctuation,
|
| 165 |
+
Text.Whitespace, Punctuation), '#pop'),
|
| 166 |
+
(r'([\w.]+)', Name.Function, ('#pop', 'old_arguments')),
|
| 167 |
+
],
|
| 168 |
+
'procedure_definition': [
|
| 169 |
+
(r'\s', Whitespace),
|
| 170 |
+
(r'([\w.]+)(\s*?[(:])',
|
| 171 |
+
bygroups(Name.Function, Whitespace), '#pop'),
|
| 172 |
+
(r'([\w.]+)([^\n]*)',
|
| 173 |
+
bygroups(Name.Function, Text), '#pop'),
|
| 174 |
+
],
|
| 175 |
+
'function_call': [
|
| 176 |
+
(words(functions_string, suffix=r'\$(?=\s*[:(])'), Name.Function, 'function'),
|
| 177 |
+
(words(functions_array, suffix=r'#(?=\s*[:(])'), Name.Function, 'function'),
|
| 178 |
+
(words(functions_numeric, suffix=r'(?=\s*[:(])'), Name.Function, 'function'),
|
| 179 |
+
],
|
| 180 |
+
'function': [
|
| 181 |
+
(r'\s+', Whitespace),
|
| 182 |
+
(r':', Punctuation, ('#pop', 'comma_list')),
|
| 183 |
+
(r'\s*\(', Punctuation, ('#pop', 'comma_list')),
|
| 184 |
+
],
|
| 185 |
+
'comma_list': [
|
| 186 |
+
(r'(\s*\n\s*)(\.{3})', bygroups(Whitespace, Punctuation)),
|
| 187 |
+
|
| 188 |
+
(r'(\s*)(?:([)\]])|(\n))', bygroups(
|
| 189 |
+
Whitespace, Punctuation, Whitespace), '#pop'),
|
| 190 |
+
|
| 191 |
+
(r'\s+', Whitespace),
|
| 192 |
+
(r'"', String, 'string'),
|
| 193 |
+
(r'\b(if|then|else|fi|endif)\b', Keyword),
|
| 194 |
+
|
| 195 |
+
include('function_call'),
|
| 196 |
+
include('variable_name'),
|
| 197 |
+
include('operator'),
|
| 198 |
+
include('number'),
|
| 199 |
+
|
| 200 |
+
(r'[()]', Text),
|
| 201 |
+
(r',', Punctuation),
|
| 202 |
+
],
|
| 203 |
+
'old_arguments': [
|
| 204 |
+
(r'\n', Whitespace, '#pop'),
|
| 205 |
+
|
| 206 |
+
include('variable_name'),
|
| 207 |
+
include('operator'),
|
| 208 |
+
include('number'),
|
| 209 |
+
|
| 210 |
+
(r'"', String, 'string'),
|
| 211 |
+
(r'[^\n]', Text),
|
| 212 |
+
],
|
| 213 |
+
'number': [
|
| 214 |
+
(r'\n', Whitespace, '#pop'),
|
| 215 |
+
(r'\b\d+(\.\d*)?([eE][-+]?\d+)?%?', Number),
|
| 216 |
+
],
|
| 217 |
+
'object_reference': [
|
| 218 |
+
include('string_interpolated'),
|
| 219 |
+
(r'([a-z][a-zA-Z0-9_]*|\d+)', Name.Builtin),
|
| 220 |
+
|
| 221 |
+
(words(object_attributes, prefix=r'\.'), Name.Builtin, '#pop'),
|
| 222 |
+
|
| 223 |
+
(r'\$', Name.Builtin),
|
| 224 |
+
(r'\[', Text, '#pop'),
|
| 225 |
+
],
|
| 226 |
+
'variable_name': [
|
| 227 |
+
include('operator'),
|
| 228 |
+
include('number'),
|
| 229 |
+
|
| 230 |
+
(words(variables_string, suffix=r'\$'), Name.Variable.Global),
|
| 231 |
+
(words(variables_numeric,
|
| 232 |
+
suffix=r'(?=[^a-zA-Z0-9_."\'$#\[:(]|\s|^|$)'),
|
| 233 |
+
Name.Variable.Global),
|
| 234 |
+
|
| 235 |
+
(words(objects, prefix=r'\b', suffix=r"(_)"),
|
| 236 |
+
bygroups(Name.Builtin, Name.Builtin),
|
| 237 |
+
'object_reference'),
|
| 238 |
+
|
| 239 |
+
(r'\.?_?[a-z][\w.]*(\$|#)?', Text),
|
| 240 |
+
(r'[\[\]]', Punctuation, 'comma_list'),
|
| 241 |
+
|
| 242 |
+
include('string_interpolated'),
|
| 243 |
+
],
|
| 244 |
+
'operator': [
|
| 245 |
+
(r'([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)', Operator),
|
| 246 |
+
(r'(?<![\w.])(and|or|not|div|mod)(?![\w.])', Operator.Word),
|
| 247 |
+
],
|
| 248 |
+
'string_interpolated': [
|
| 249 |
+
(r'\'[_a-z][^\[\]\'":]*(\[([\d,]+|"[\w,]+")\])?(:[0-9]+)?\'',
|
| 250 |
+
String.Interpol),
|
| 251 |
+
],
|
| 252 |
+
'string_unquoted': [
|
| 253 |
+
(r'(\n\s*)(\.{3})', bygroups(Whitespace, Punctuation)),
|
| 254 |
+
|
| 255 |
+
(r'\n', Whitespace, '#pop'),
|
| 256 |
+
(r'\s', Whitespace),
|
| 257 |
+
|
| 258 |
+
include('string_interpolated'),
|
| 259 |
+
|
| 260 |
+
(r"'", String),
|
| 261 |
+
(r"[^'\n]+", String),
|
| 262 |
+
],
|
| 263 |
+
'string': [
|
| 264 |
+
(r'(\n\s*)(\.{3})', bygroups(Whitespace, Punctuation)),
|
| 265 |
+
|
| 266 |
+
(r'"', String, '#pop'),
|
| 267 |
+
|
| 268 |
+
include('string_interpolated'),
|
| 269 |
+
|
| 270 |
+
(r"'", String),
|
| 271 |
+
(r'[^\'"\n]+', String),
|
| 272 |
+
],
|
| 273 |
+
'old_form': [
|
| 274 |
+
(r'(\s+)(#.*?$)', bygroups(Whitespace, Comment.Single)),
|
| 275 |
+
(r'\s+', Whitespace),
|
| 276 |
+
|
| 277 |
+
(r'(optionmenu|choice)([ \t]+)(\S+)(:)([ \t]+)',
|
| 278 |
+
bygroups(Keyword, Whitespace, Text, Punctuation, Whitespace), 'number'),
|
| 279 |
+
|
| 280 |
+
(r'(option|button)([ \t]+)',
|
| 281 |
+
bygroups(Keyword, Whitespace), 'string_unquoted'),
|
| 282 |
+
|
| 283 |
+
(r'(sentence|text)([ \t]+)(\S+)',
|
| 284 |
+
bygroups(Keyword, Whitespace, String), 'string_unquoted'),
|
| 285 |
+
|
| 286 |
+
(r'(word)([ \t]+)(\S+)([ \t]*)(\S+)?(?:([ \t]+)(.*))?',
|
| 287 |
+
bygroups(Keyword, Whitespace, Text, Whitespace, Text, Whitespace, Text)),
|
| 288 |
+
|
| 289 |
+
(r'(boolean)(\s+\S+\s*)(0|1|"?(?:yes|no)"?)',
|
| 290 |
+
bygroups(Keyword, Whitespace, Name.Variable)),
|
| 291 |
+
|
| 292 |
+
# Ideally processing of the number would happen in the 'number'
|
| 293 |
+
# but that doesn't seem to work
|
| 294 |
+
(r'(real|natural|positive|integer)([ \t]+\S+[ \t]*)([+-]?)(\d+(?:\.\d*)?'
|
| 295 |
+
r'(?:[eE][-+]?\d+)?%?)',
|
| 296 |
+
bygroups(Keyword, Whitespace, Operator, Number)),
|
| 297 |
+
|
| 298 |
+
(r'(comment)(\s+)',
|
| 299 |
+
bygroups(Keyword, Whitespace), 'string_unquoted'),
|
| 300 |
+
|
| 301 |
+
(r'\bendform\b', Keyword, '#pop'),
|
| 302 |
+
]
|
| 303 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/procfile.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.procfile
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Procfile file format.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups
|
| 12 |
+
from pygments.token import Name, Number, String, Text, Punctuation
|
| 13 |
+
|
| 14 |
+
__all__ = ["ProcfileLexer"]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class ProcfileLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
Lexer for Procfile file format.
|
| 20 |
+
|
| 21 |
+
The format is used to run processes on Heroku or is used by Foreman or
|
| 22 |
+
Honcho tools.
|
| 23 |
+
"""
|
| 24 |
+
name = 'Procfile'
|
| 25 |
+
url = 'https://devcenter.heroku.com/articles/procfile#procfile-format'
|
| 26 |
+
aliases = ['procfile']
|
| 27 |
+
filenames = ['Procfile']
|
| 28 |
+
version_added = '2.10'
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
(r'^([a-z]+)(:)', bygroups(Name.Label, Punctuation)),
|
| 33 |
+
(r'\s+', Text.Whitespace),
|
| 34 |
+
(r'"[^"]*"', String),
|
| 35 |
+
(r"'[^']*'", String),
|
| 36 |
+
(r'[0-9]+', Number.Integer),
|
| 37 |
+
(r'\$[a-zA-Z_][\w]*', Name.Variable),
|
| 38 |
+
(r'(\w+)(=)(\w+)', bygroups(Name.Variable, Punctuation, String)),
|
| 39 |
+
(r'([\w\-\./]+)', Text),
|
| 40 |
+
],
|
| 41 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/prolog.py
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.prolog
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Prolog and Prolog-like languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, bygroups
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation
|
| 16 |
+
|
| 17 |
+
__all__ = ['PrologLexer', 'LogtalkLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class PrologLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Lexer for Prolog files.
|
| 23 |
+
"""
|
| 24 |
+
name = 'Prolog'
|
| 25 |
+
aliases = ['prolog']
|
| 26 |
+
filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl']
|
| 27 |
+
mimetypes = ['text/x-prolog']
|
| 28 |
+
url = 'https://en.wikipedia.org/wiki/Prolog'
|
| 29 |
+
version_added = ''
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'root': [
|
| 33 |
+
(r'/\*', Comment.Multiline, 'nested-comment'),
|
| 34 |
+
(r'%.*', Comment.Single),
|
| 35 |
+
# character literal
|
| 36 |
+
(r'0\'.', String.Char),
|
| 37 |
+
(r'0b[01]+', Number.Bin),
|
| 38 |
+
(r'0o[0-7]+', Number.Oct),
|
| 39 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 40 |
+
# literal with prepended base
|
| 41 |
+
(r'\d\d?\'[a-zA-Z0-9]+', Number.Integer),
|
| 42 |
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
| 43 |
+
(r'\d+', Number.Integer),
|
| 44 |
+
(r'[\[\](){}|.,;!]', Punctuation),
|
| 45 |
+
(r':-|-->', Punctuation),
|
| 46 |
+
(r'"(?:\\x[0-9a-fA-F]+\\|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|'
|
| 47 |
+
r'\\[0-7]+\\|\\["\\abcefnrstv]|[^\\"])*"', String.Double),
|
| 48 |
+
(r"'(?:''|[^'])*'", String.Atom), # quoted atom
|
| 49 |
+
# Needs to not be followed by an atom.
|
| 50 |
+
# (r'=(?=\s|[a-zA-Z\[])', Operator),
|
| 51 |
+
(r'is\b', Operator),
|
| 52 |
+
(r'(<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])',
|
| 53 |
+
Operator),
|
| 54 |
+
(r'(mod|div|not)\b', Operator),
|
| 55 |
+
(r'_', Keyword), # The don't-care variable
|
| 56 |
+
(r'([a-z]+)(:)', bygroups(Name.Namespace, Punctuation)),
|
| 57 |
+
(r'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
|
| 58 |
+
r'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
|
| 59 |
+
r'(\s*)(:-|-->)',
|
| 60 |
+
bygroups(Name.Function, Text, Operator)), # function defn
|
| 61 |
+
(r'([a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
|
| 62 |
+
r'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*)'
|
| 63 |
+
r'(\s*)(\()',
|
| 64 |
+
bygroups(Name.Function, Text, Punctuation)),
|
| 65 |
+
(r'[a-z\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]'
|
| 66 |
+
r'[\w$\u00c0-\u1fff\u3040-\ud7ff\ue000-\uffef]*',
|
| 67 |
+
String.Atom), # atom, characters
|
| 68 |
+
# This one includes !
|
| 69 |
+
(r'[#&*+\-./:<=>?@\\^~\u00a1-\u00bf\u2010-\u303f]+',
|
| 70 |
+
String.Atom), # atom, graphics
|
| 71 |
+
(r'[A-Z_]\w*', Name.Variable),
|
| 72 |
+
(r'\s+|[\u2000-\u200f\ufff0-\ufffe\uffef]', Text),
|
| 73 |
+
],
|
| 74 |
+
'nested-comment': [
|
| 75 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 76 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 77 |
+
(r'[^*/]+', Comment.Multiline),
|
| 78 |
+
(r'[*/]', Comment.Multiline),
|
| 79 |
+
],
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
def analyse_text(text):
|
| 83 |
+
"""Competes with IDL and Visual Prolog on *.pro"""
|
| 84 |
+
if ':-' in text:
|
| 85 |
+
# Visual Prolog also uses :-
|
| 86 |
+
return 0.5
|
| 87 |
+
else:
|
| 88 |
+
return 0
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
class LogtalkLexer(RegexLexer):
|
| 92 |
+
"""
|
| 93 |
+
For Logtalk source code.
|
| 94 |
+
"""
|
| 95 |
+
|
| 96 |
+
name = 'Logtalk'
|
| 97 |
+
url = 'http://logtalk.org/'
|
| 98 |
+
aliases = ['logtalk']
|
| 99 |
+
filenames = ['*.lgt', '*.logtalk']
|
| 100 |
+
mimetypes = ['text/x-logtalk']
|
| 101 |
+
version_added = '0.10'
|
| 102 |
+
|
| 103 |
+
tokens = {
|
| 104 |
+
'root': [
|
| 105 |
+
# Directives
|
| 106 |
+
(r'^\s*:-\s', Punctuation, 'directive'),
|
| 107 |
+
# Comments
|
| 108 |
+
(r'%.*?\n', Comment),
|
| 109 |
+
(r'/\*(.|\n)*?\*/', Comment),
|
| 110 |
+
# Whitespace
|
| 111 |
+
(r'\n', Text),
|
| 112 |
+
(r'\s+', Text),
|
| 113 |
+
# Numbers
|
| 114 |
+
(r"0'[\\]?.", Number),
|
| 115 |
+
(r'0b[01]+', Number.Bin),
|
| 116 |
+
(r'0o[0-7]+', Number.Oct),
|
| 117 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 118 |
+
(r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
|
| 119 |
+
# Variables
|
| 120 |
+
(r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
|
| 121 |
+
# Event handlers
|
| 122 |
+
(r'(after|before)(?=[(])', Keyword),
|
| 123 |
+
# Message forwarding handler
|
| 124 |
+
(r'forward(?=[(])', Keyword),
|
| 125 |
+
# Execution-context methods
|
| 126 |
+
(r'(context|parameter|this|se(lf|nder))(?=[(])', Keyword),
|
| 127 |
+
# Reflection
|
| 128 |
+
(r'(current_predicate|predicate_property)(?=[(])', Keyword),
|
| 129 |
+
# DCGs and term expansion
|
| 130 |
+
(r'(expand_(goal|term)|(goal|term)_expansion|phrase)(?=[(])', Keyword),
|
| 131 |
+
# Entity
|
| 132 |
+
(r'(abolish|c(reate|urrent))_(object|protocol|category)(?=[(])', Keyword),
|
| 133 |
+
(r'(object|protocol|category)_property(?=[(])', Keyword),
|
| 134 |
+
# Entity relations
|
| 135 |
+
(r'co(mplements_object|nforms_to_protocol)(?=[(])', Keyword),
|
| 136 |
+
(r'extends_(object|protocol|category)(?=[(])', Keyword),
|
| 137 |
+
(r'imp(lements_protocol|orts_category)(?=[(])', Keyword),
|
| 138 |
+
(r'(instantiat|specializ)es_class(?=[(])', Keyword),
|
| 139 |
+
# Events
|
| 140 |
+
(r'(current_event|(abolish|define)_events)(?=[(])', Keyword),
|
| 141 |
+
# Flags
|
| 142 |
+
(r'(create|current|set)_logtalk_flag(?=[(])', Keyword),
|
| 143 |
+
# Compiling, loading, and library paths
|
| 144 |
+
(r'logtalk_(compile|l(ibrary_path|oad|oad_context)|make(_target_action)?)(?=[(])', Keyword),
|
| 145 |
+
(r'\blogtalk_make\b', Keyword),
|
| 146 |
+
# Database
|
| 147 |
+
(r'(clause|retract(all)?)(?=[(])', Keyword),
|
| 148 |
+
(r'a(bolish|ssert(a|z))(?=[(])', Keyword),
|
| 149 |
+
# Control constructs
|
| 150 |
+
(r'(ca(ll|tch)|throw)(?=[(])', Keyword),
|
| 151 |
+
(r'(fa(il|lse)|true|(instantiation|system)_error)\b', Keyword),
|
| 152 |
+
(r'(uninstantiation|type|domain|existence|permission|representation|evaluation|resource|syntax)_error(?=[(])', Keyword),
|
| 153 |
+
# All solutions
|
| 154 |
+
(r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword),
|
| 155 |
+
# Multi-threading predicates
|
| 156 |
+
(r'threaded(_(ca(ll|ncel)|once|ignore|exit|peek|wait|notify))?(?=[(])', Keyword),
|
| 157 |
+
# Engine predicates
|
| 158 |
+
(r'threaded_engine(_(create|destroy|self|next|next_reified|yield|post|fetch))?(?=[(])', Keyword),
|
| 159 |
+
# Term unification
|
| 160 |
+
(r'(subsumes_term|unify_with_occurs_check)(?=[(])', Keyword),
|
| 161 |
+
# Term creation and decomposition
|
| 162 |
+
(r'(functor|arg|copy_term|numbervars|term_variables)(?=[(])', Keyword),
|
| 163 |
+
# Evaluable functors
|
| 164 |
+
(r'(div|rem|m(ax|in|od)|abs|sign)(?=[(])', Keyword),
|
| 165 |
+
(r'float(_(integer|fractional)_part)?(?=[(])', Keyword),
|
| 166 |
+
(r'(floor|t(an|runcate)|round|ceiling)(?=[(])', Keyword),
|
| 167 |
+
# Other arithmetic functors
|
| 168 |
+
(r'(cos|a(cos|sin|tan|tan2)|exp|log|s(in|qrt)|xor)(?=[(])', Keyword),
|
| 169 |
+
# Term testing
|
| 170 |
+
(r'(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|ground|acyclic_term)(?=[(])', Keyword),
|
| 171 |
+
# Term comparison
|
| 172 |
+
(r'compare(?=[(])', Keyword),
|
| 173 |
+
# Stream selection and control
|
| 174 |
+
(r'(curren|se)t_(in|out)put(?=[(])', Keyword),
|
| 175 |
+
(r'(open|close)(?=[(])', Keyword),
|
| 176 |
+
(r'flush_output(?=[(])', Keyword),
|
| 177 |
+
(r'(at_end_of_stream|flush_output)\b', Keyword),
|
| 178 |
+
(r'(stream_property|at_end_of_stream|set_stream_position)(?=[(])', Keyword),
|
| 179 |
+
# Character and byte input/output
|
| 180 |
+
(r'(nl|(get|peek|put)_(byte|c(har|ode)))(?=[(])', Keyword),
|
| 181 |
+
(r'\bnl\b', Keyword),
|
| 182 |
+
# Term input/output
|
| 183 |
+
(r'read(_term)?(?=[(])', Keyword),
|
| 184 |
+
(r'write(q|_(canonical|term))?(?=[(])', Keyword),
|
| 185 |
+
(r'(current_)?op(?=[(])', Keyword),
|
| 186 |
+
(r'(current_)?char_conversion(?=[(])', Keyword),
|
| 187 |
+
# Atomic term processing
|
| 188 |
+
(r'atom_(length|c(hars|o(ncat|des)))(?=[(])', Keyword),
|
| 189 |
+
(r'(char_code|sub_atom)(?=[(])', Keyword),
|
| 190 |
+
(r'number_c(har|ode)s(?=[(])', Keyword),
|
| 191 |
+
# Implementation defined hooks functions
|
| 192 |
+
(r'(se|curren)t_prolog_flag(?=[(])', Keyword),
|
| 193 |
+
(r'\bhalt\b', Keyword),
|
| 194 |
+
(r'halt(?=[(])', Keyword),
|
| 195 |
+
# Message sending operators
|
| 196 |
+
(r'(::|:|\^\^)', Operator),
|
| 197 |
+
# External call
|
| 198 |
+
(r'[{}]', Keyword),
|
| 199 |
+
# Logic and control
|
| 200 |
+
(r'(ignore|once)(?=[(])', Keyword),
|
| 201 |
+
(r'\brepeat\b', Keyword),
|
| 202 |
+
# Sorting
|
| 203 |
+
(r'(key)?sort(?=[(])', Keyword),
|
| 204 |
+
# Bitwise functors
|
| 205 |
+
(r'(>>|<<|/\\|\\\\|\\)', Operator),
|
| 206 |
+
# Predicate aliases
|
| 207 |
+
(r'\bas\b', Operator),
|
| 208 |
+
# Arithmetic evaluation
|
| 209 |
+
(r'\bis\b', Keyword),
|
| 210 |
+
# Arithmetic comparison
|
| 211 |
+
(r'(=:=|=\\=|<|=<|>=|>)', Operator),
|
| 212 |
+
# Term creation and decomposition
|
| 213 |
+
(r'=\.\.', Operator),
|
| 214 |
+
# Term unification
|
| 215 |
+
(r'(=|\\=)', Operator),
|
| 216 |
+
# Term comparison
|
| 217 |
+
(r'(==|\\==|@=<|@<|@>=|@>)', Operator),
|
| 218 |
+
# Evaluable functors
|
| 219 |
+
(r'(//|[-+*/])', Operator),
|
| 220 |
+
(r'\b(e|pi|div|mod|rem)\b', Operator),
|
| 221 |
+
# Other arithmetic functors
|
| 222 |
+
(r'\b\*\*\b', Operator),
|
| 223 |
+
# DCG rules
|
| 224 |
+
(r'-->', Operator),
|
| 225 |
+
# Control constructs
|
| 226 |
+
(r'([!;]|->)', Operator),
|
| 227 |
+
# Logic and control
|
| 228 |
+
(r'\\+', Operator),
|
| 229 |
+
# Mode operators
|
| 230 |
+
(r'[?@]', Operator),
|
| 231 |
+
# Existential quantifier
|
| 232 |
+
(r'\^', Operator),
|
| 233 |
+
# Punctuation
|
| 234 |
+
(r'[()\[\],.|]', Text),
|
| 235 |
+
# Atoms
|
| 236 |
+
(r"[a-z][a-zA-Z0-9_]*", Text),
|
| 237 |
+
(r"'", String, 'quoted_atom'),
|
| 238 |
+
# Double-quoted terms
|
| 239 |
+
(r'"', String, 'double_quoted_term'),
|
| 240 |
+
],
|
| 241 |
+
|
| 242 |
+
'quoted_atom': [
|
| 243 |
+
(r"''", String),
|
| 244 |
+
(r"'", String, '#pop'),
|
| 245 |
+
(r'\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)', String.Escape),
|
| 246 |
+
(r"[^\\'\n]+", String),
|
| 247 |
+
(r'\\', String),
|
| 248 |
+
],
|
| 249 |
+
|
| 250 |
+
'double_quoted_term': [
|
| 251 |
+
(r'""', String),
|
| 252 |
+
(r'"', String, '#pop'),
|
| 253 |
+
(r'\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)', String.Escape),
|
| 254 |
+
(r'[^\\"\n]+', String),
|
| 255 |
+
(r'\\', String),
|
| 256 |
+
],
|
| 257 |
+
|
| 258 |
+
'directive': [
|
| 259 |
+
# Conditional compilation directives
|
| 260 |
+
(r'(el)?if(?=[(])', Keyword, 'root'),
|
| 261 |
+
(r'(e(lse|ndif))(?=[.])', Keyword, 'root'),
|
| 262 |
+
# Entity directives
|
| 263 |
+
(r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'),
|
| 264 |
+
(r'(end_(category|object|protocol))(?=[.])', Keyword, 'root'),
|
| 265 |
+
# Predicate scope directives
|
| 266 |
+
(r'(public|protected|private)(?=[(])', Keyword, 'root'),
|
| 267 |
+
# Other directives
|
| 268 |
+
(r'e(n(coding|sure_loaded)|xport)(?=[(])', Keyword, 'root'),
|
| 269 |
+
(r'in(clude|itialization|fo)(?=[(])', Keyword, 'root'),
|
| 270 |
+
(r'(built_in|dynamic|synchronized|threaded)(?=[.])', Keyword, 'root'),
|
| 271 |
+
(r'(alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|s(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'),
|
| 272 |
+
(r'op(?=[(])', Keyword, 'root'),
|
| 273 |
+
(r'(c(alls|oinductive)|module|reexport|use(s|_module))(?=[(])', Keyword, 'root'),
|
| 274 |
+
(r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'),
|
| 275 |
+
(r'[a-z][a-zA-Z0-9_]*(?=[.])', Text, 'root'),
|
| 276 |
+
],
|
| 277 |
+
|
| 278 |
+
'entityrelations': [
|
| 279 |
+
(r'(complements|extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])', Keyword),
|
| 280 |
+
# Numbers
|
| 281 |
+
(r"0'[\\]?.", Number),
|
| 282 |
+
(r'0b[01]+', Number.Bin),
|
| 283 |
+
(r'0o[0-7]+', Number.Oct),
|
| 284 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 285 |
+
(r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
|
| 286 |
+
# Variables
|
| 287 |
+
(r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
|
| 288 |
+
# Atoms
|
| 289 |
+
(r"[a-z][a-zA-Z0-9_]*", Text),
|
| 290 |
+
(r"'", String, 'quoted_atom'),
|
| 291 |
+
# Double-quoted terms
|
| 292 |
+
(r'"', String, 'double_quoted_term'),
|
| 293 |
+
# End of entity-opening directive
|
| 294 |
+
(r'([)]\.)', Text, 'root'),
|
| 295 |
+
# Scope operator
|
| 296 |
+
(r'(::)', Operator),
|
| 297 |
+
# Punctuation
|
| 298 |
+
(r'[()\[\],.|]', Text),
|
| 299 |
+
# Comments
|
| 300 |
+
(r'%.*?\n', Comment),
|
| 301 |
+
(r'/\*(.|\n)*?\*/', Comment),
|
| 302 |
+
# Whitespace
|
| 303 |
+
(r'\n', Text),
|
| 304 |
+
(r'\s+', Text),
|
| 305 |
+
]
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
def analyse_text(text):
|
| 309 |
+
if ':- object(' in text:
|
| 310 |
+
return 1.0
|
| 311 |
+
elif ':- protocol(' in text:
|
| 312 |
+
return 1.0
|
| 313 |
+
elif ':- category(' in text:
|
| 314 |
+
return 1.0
|
| 315 |
+
elif re.search(r'^:-\s[a-z]', text, re.M):
|
| 316 |
+
return 0.9
|
| 317 |
+
else:
|
| 318 |
+
return 0.0
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/promql.py
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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us Query Language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, default, words
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, String, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ["PromQLLexer"]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class PromQLLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For PromQL queries.
|
| 21 |
+
|
| 22 |
+
For details about the grammar see:
|
| 23 |
+
https://github.com/prometheus/prometheus/tree/master/promql/parser
|
| 24 |
+
|
| 25 |
+
.. versionadded: 2.7
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
name = "PromQL"
|
| 29 |
+
url = 'https://prometheus.io/docs/prometheus/latest/querying/basics/'
|
| 30 |
+
aliases = ["promql"]
|
| 31 |
+
filenames = ["*.promql"]
|
| 32 |
+
version_added = ''
|
| 33 |
+
|
| 34 |
+
base_keywords = (
|
| 35 |
+
words(
|
| 36 |
+
(
|
| 37 |
+
"bool",
|
| 38 |
+
"by",
|
| 39 |
+
"group_left",
|
| 40 |
+
"group_right",
|
| 41 |
+
"ignoring",
|
| 42 |
+
"offset",
|
| 43 |
+
"on",
|
| 44 |
+
"without",
|
| 45 |
+
),
|
| 46 |
+
suffix=r"\b",
|
| 47 |
+
),
|
| 48 |
+
Keyword,
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
aggregator_keywords = (
|
| 52 |
+
words(
|
| 53 |
+
(
|
| 54 |
+
"sum",
|
| 55 |
+
"min",
|
| 56 |
+
"max",
|
| 57 |
+
"avg",
|
| 58 |
+
"group",
|
| 59 |
+
"stddev",
|
| 60 |
+
"stdvar",
|
| 61 |
+
"count",
|
| 62 |
+
"count_values",
|
| 63 |
+
"bottomk",
|
| 64 |
+
"topk",
|
| 65 |
+
"quantile",
|
| 66 |
+
),
|
| 67 |
+
suffix=r"\b",
|
| 68 |
+
),
|
| 69 |
+
Keyword,
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
function_keywords = (
|
| 73 |
+
words(
|
| 74 |
+
(
|
| 75 |
+
"abs",
|
| 76 |
+
"absent",
|
| 77 |
+
"absent_over_time",
|
| 78 |
+
"avg_over_time",
|
| 79 |
+
"ceil",
|
| 80 |
+
"changes",
|
| 81 |
+
"clamp_max",
|
| 82 |
+
"clamp_min",
|
| 83 |
+
"count_over_time",
|
| 84 |
+
"day_of_month",
|
| 85 |
+
"day_of_week",
|
| 86 |
+
"days_in_month",
|
| 87 |
+
"delta",
|
| 88 |
+
"deriv",
|
| 89 |
+
"exp",
|
| 90 |
+
"floor",
|
| 91 |
+
"histogram_quantile",
|
| 92 |
+
"holt_winters",
|
| 93 |
+
"hour",
|
| 94 |
+
"idelta",
|
| 95 |
+
"increase",
|
| 96 |
+
"irate",
|
| 97 |
+
"label_join",
|
| 98 |
+
"label_replace",
|
| 99 |
+
"ln",
|
| 100 |
+
"log10",
|
| 101 |
+
"log2",
|
| 102 |
+
"max_over_time",
|
| 103 |
+
"min_over_time",
|
| 104 |
+
"minute",
|
| 105 |
+
"month",
|
| 106 |
+
"predict_linear",
|
| 107 |
+
"quantile_over_time",
|
| 108 |
+
"rate",
|
| 109 |
+
"resets",
|
| 110 |
+
"round",
|
| 111 |
+
"scalar",
|
| 112 |
+
"sort",
|
| 113 |
+
"sort_desc",
|
| 114 |
+
"sqrt",
|
| 115 |
+
"stddev_over_time",
|
| 116 |
+
"stdvar_over_time",
|
| 117 |
+
"sum_over_time",
|
| 118 |
+
"time",
|
| 119 |
+
"timestamp",
|
| 120 |
+
"vector",
|
| 121 |
+
"year",
|
| 122 |
+
),
|
| 123 |
+
suffix=r"\b",
|
| 124 |
+
),
|
| 125 |
+
Keyword.Reserved,
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
tokens = {
|
| 129 |
+
"root": [
|
| 130 |
+
(r"\n", Whitespace),
|
| 131 |
+
(r"\s+", Whitespace),
|
| 132 |
+
(r",", Punctuation),
|
| 133 |
+
# Keywords
|
| 134 |
+
base_keywords,
|
| 135 |
+
aggregator_keywords,
|
| 136 |
+
function_keywords,
|
| 137 |
+
# Offsets
|
| 138 |
+
(r"[1-9][0-9]*[smhdwy]", String),
|
| 139 |
+
# Numbers
|
| 140 |
+
(r"-?[0-9]+\.[0-9]+", Number.Float),
|
| 141 |
+
(r"-?[0-9]+", Number.Integer),
|
| 142 |
+
# Comments
|
| 143 |
+
(r"#.*?$", Comment.Single),
|
| 144 |
+
# Operators
|
| 145 |
+
(r"(\+|\-|\*|\/|\%|\^)", Operator),
|
| 146 |
+
(r"==|!=|>=|<=|<|>", Operator),
|
| 147 |
+
(r"and|or|unless", Operator.Word),
|
| 148 |
+
# Metrics
|
| 149 |
+
(r"[_a-zA-Z][a-zA-Z0-9_]+", Name.Variable),
|
| 150 |
+
# Params
|
| 151 |
+
(r'(["\'])(.*?)(["\'])', bygroups(Punctuation, String, Punctuation)),
|
| 152 |
+
# Other states
|
| 153 |
+
(r"\(", Operator, "function"),
|
| 154 |
+
(r"\)", Operator),
|
| 155 |
+
(r"\{", Punctuation, "labels"),
|
| 156 |
+
(r"\[", Punctuation, "range"),
|
| 157 |
+
],
|
| 158 |
+
"labels": [
|
| 159 |
+
(r"\}", Punctuation, "#pop"),
|
| 160 |
+
(r"\n", Whitespace),
|
| 161 |
+
(r"\s+", Whitespace),
|
| 162 |
+
(r",", Punctuation),
|
| 163 |
+
(r'([_a-zA-Z][a-zA-Z0-9_]*?)(\s*?)(=~|!=|=|!~)(\s*?)("|\')(.*?)("|\')',
|
| 164 |
+
bygroups(Name.Label, Whitespace, Operator, Whitespace,
|
| 165 |
+
Punctuation, String, Punctuation)),
|
| 166 |
+
],
|
| 167 |
+
"range": [
|
| 168 |
+
(r"\]", Punctuation, "#pop"),
|
| 169 |
+
(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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.prql
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the PRQL query language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, combined, words, include, bygroups
|
| 12 |
+
from pygments.token import Comment, Literal, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, String, Text, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['PrqlLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class PrqlLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For PRQL source code.
|
| 21 |
+
|
| 22 |
+
grammar: https://github.com/PRQL/prql/tree/main/grammars
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'PRQL'
|
| 26 |
+
url = 'https://prql-lang.org/'
|
| 27 |
+
aliases = ['prql']
|
| 28 |
+
filenames = ['*.prql']
|
| 29 |
+
mimetypes = ['application/prql', 'application/x-prql']
|
| 30 |
+
version_added = '2.17'
|
| 31 |
+
|
| 32 |
+
builtinTypes = words((
|
| 33 |
+
"bool",
|
| 34 |
+
"int",
|
| 35 |
+
"int8", "int16", "int32", "int64", "int128",
|
| 36 |
+
"float",
|
| 37 |
+
"text",
|
| 38 |
+
"set"), suffix=r'\b')
|
| 39 |
+
|
| 40 |
+
def innerstring_rules(ttype):
|
| 41 |
+
return [
|
| 42 |
+
# the new style '{}'.format(...) string formatting
|
| 43 |
+
(r'\{'
|
| 44 |
+
r'((\w+)((\.\w+)|(\[[^\]]+\]))*)?' # field name
|
| 45 |
+
r'(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?'
|
| 46 |
+
r'\}', String.Interpol),
|
| 47 |
+
|
| 48 |
+
(r'[^\\\'"%{\n]+', ttype),
|
| 49 |
+
(r'[\'"\\]', ttype),
|
| 50 |
+
(r'%|(\{{1,2})', ttype)
|
| 51 |
+
]
|
| 52 |
+
|
| 53 |
+
def fstring_rules(ttype):
|
| 54 |
+
return [
|
| 55 |
+
(r'\}', String.Interpol),
|
| 56 |
+
(r'\{', String.Interpol, 'expr-inside-fstring'),
|
| 57 |
+
(r'[^\\\'"{}\n]+', ttype),
|
| 58 |
+
(r'[\'"\\]', ttype),
|
| 59 |
+
]
|
| 60 |
+
|
| 61 |
+
tokens = {
|
| 62 |
+
'root': [
|
| 63 |
+
|
| 64 |
+
# Comments
|
| 65 |
+
(r'#!.*', String.Doc),
|
| 66 |
+
(r'#.*', Comment.Single),
|
| 67 |
+
|
| 68 |
+
# Whitespace
|
| 69 |
+
(r'\s+', Whitespace),
|
| 70 |
+
|
| 71 |
+
# Modules
|
| 72 |
+
(r'^(\s*)(module)(\s*)',
|
| 73 |
+
bygroups(Whitespace, Keyword.Namespace, Whitespace),
|
| 74 |
+
'imports'),
|
| 75 |
+
|
| 76 |
+
(builtinTypes, Keyword.Type),
|
| 77 |
+
|
| 78 |
+
# Main
|
| 79 |
+
(r'^prql ', Keyword.Reserved),
|
| 80 |
+
|
| 81 |
+
('let', Keyword.Declaration),
|
| 82 |
+
|
| 83 |
+
include('keywords'),
|
| 84 |
+
include('expr'),
|
| 85 |
+
|
| 86 |
+
# Transforms
|
| 87 |
+
(r'^[A-Za-z_][a-zA-Z0-9_]*', Keyword),
|
| 88 |
+
],
|
| 89 |
+
'expr': [
|
| 90 |
+
# non-raw f-strings
|
| 91 |
+
('(f)(""")', bygroups(String.Affix, String.Double),
|
| 92 |
+
combined('fstringescape', 'tdqf')),
|
| 93 |
+
("(f)(''')", bygroups(String.Affix, String.Single),
|
| 94 |
+
combined('fstringescape', 'tsqf')),
|
| 95 |
+
('(f)(")', bygroups(String.Affix, String.Double),
|
| 96 |
+
combined('fstringescape', 'dqf')),
|
| 97 |
+
("(f)(')", bygroups(String.Affix, String.Single),
|
| 98 |
+
combined('fstringescape', 'sqf')),
|
| 99 |
+
|
| 100 |
+
# non-raw s-strings
|
| 101 |
+
('(s)(""")', bygroups(String.Affix, String.Double),
|
| 102 |
+
combined('stringescape', 'tdqf')),
|
| 103 |
+
("(s)(''')", bygroups(String.Affix, String.Single),
|
| 104 |
+
combined('stringescape', 'tsqf')),
|
| 105 |
+
('(s)(")', bygroups(String.Affix, String.Double),
|
| 106 |
+
combined('stringescape', 'dqf')),
|
| 107 |
+
("(s)(')", bygroups(String.Affix, String.Single),
|
| 108 |
+
combined('stringescape', 'sqf')),
|
| 109 |
+
|
| 110 |
+
# raw strings
|
| 111 |
+
('(?i)(r)(""")',
|
| 112 |
+
bygroups(String.Affix, String.Double), 'tdqs'),
|
| 113 |
+
("(?i)(r)(''')",
|
| 114 |
+
bygroups(String.Affix, String.Single), 'tsqs'),
|
| 115 |
+
('(?i)(r)(")',
|
| 116 |
+
bygroups(String.Affix, String.Double), 'dqs'),
|
| 117 |
+
("(?i)(r)(')",
|
| 118 |
+
bygroups(String.Affix, String.Single), 'sqs'),
|
| 119 |
+
|
| 120 |
+
# non-raw strings
|
| 121 |
+
('"""', String.Double, combined('stringescape', 'tdqs')),
|
| 122 |
+
("'''", String.Single, combined('stringescape', 'tsqs')),
|
| 123 |
+
('"', String.Double, combined('stringescape', 'dqs')),
|
| 124 |
+
("'", String.Single, combined('stringescape', 'sqs')),
|
| 125 |
+
|
| 126 |
+
# Time and dates
|
| 127 |
+
(r'@\d{4}-\d{2}-\d{2}T\d{2}(:\d{2})?(:\d{2})?(\.\d{1,6})?(Z|[+-]\d{1,2}(:\d{1,2})?)?', Literal.Date),
|
| 128 |
+
(r'@\d{4}-\d{2}-\d{2}', Literal.Date),
|
| 129 |
+
(r'@\d{2}(:\d{2})?(:\d{2})?(\.\d{1,6})?(Z|[+-]\d{1,2}(:\d{1,2})?)?', Literal.Date),
|
| 130 |
+
|
| 131 |
+
(r'[^\S\n]+', Text),
|
| 132 |
+
include('numbers'),
|
| 133 |
+
(r'->|=>|==|!=|>=|<=|~=|&&|\|\||\?\?|\/\/', Operator),
|
| 134 |
+
(r'[-~+/*%=<>&^|.@]', Operator),
|
| 135 |
+
(r'[]{}:(),;[]', Punctuation),
|
| 136 |
+
include('functions'),
|
| 137 |
+
|
| 138 |
+
# Variable Names
|
| 139 |
+
(r'[A-Za-z_][a-zA-Z0-9_]*', Name.Variable),
|
| 140 |
+
],
|
| 141 |
+
'numbers': [
|
| 142 |
+
(r'(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)'
|
| 143 |
+
r'([eE][+-]?\d(?:_?\d)*)?', Number.Float),
|
| 144 |
+
(r'\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?', Number.Float),
|
| 145 |
+
(r'0[oO](?:_?[0-7])+', Number.Oct),
|
| 146 |
+
(r'0[bB](?:_?[01])+', Number.Bin),
|
| 147 |
+
(r'0[xX](?:_?[a-fA-F0-9])+', Number.Hex),
|
| 148 |
+
(r'\d(?:_?\d)*', Number.Integer),
|
| 149 |
+
],
|
| 150 |
+
'fstringescape': [
|
| 151 |
+
include('stringescape'),
|
| 152 |
+
],
|
| 153 |
+
'bytesescape': [
|
| 154 |
+
(r'\\([\\bfnrt"\']|\n|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
| 155 |
+
],
|
| 156 |
+
'stringescape': [
|
| 157 |
+
(r'\\(N\{.*?\}|u\{[a-fA-F0-9]{1,6}\})', String.Escape),
|
| 158 |
+
include('bytesescape')
|
| 159 |
+
],
|
| 160 |
+
'fstrings-single': fstring_rules(String.Single),
|
| 161 |
+
'fstrings-double': fstring_rules(String.Double),
|
| 162 |
+
'strings-single': innerstring_rules(String.Single),
|
| 163 |
+
'strings-double': innerstring_rules(String.Double),
|
| 164 |
+
'dqf': [
|
| 165 |
+
(r'"', String.Double, '#pop'),
|
| 166 |
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
| 167 |
+
include('fstrings-double')
|
| 168 |
+
],
|
| 169 |
+
'sqf': [
|
| 170 |
+
(r"'", String.Single, '#pop'),
|
| 171 |
+
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
| 172 |
+
include('fstrings-single')
|
| 173 |
+
],
|
| 174 |
+
'dqs': [
|
| 175 |
+
(r'"', String.Double, '#pop'),
|
| 176 |
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
| 177 |
+
include('strings-double')
|
| 178 |
+
],
|
| 179 |
+
'sqs': [
|
| 180 |
+
(r"'", String.Single, '#pop'),
|
| 181 |
+
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
| 182 |
+
include('strings-single')
|
| 183 |
+
],
|
| 184 |
+
'tdqf': [
|
| 185 |
+
(r'"""', String.Double, '#pop'),
|
| 186 |
+
include('fstrings-double'),
|
| 187 |
+
(r'\n', String.Double)
|
| 188 |
+
],
|
| 189 |
+
'tsqf': [
|
| 190 |
+
(r"'''", String.Single, '#pop'),
|
| 191 |
+
include('fstrings-single'),
|
| 192 |
+
(r'\n', String.Single)
|
| 193 |
+
],
|
| 194 |
+
'tdqs': [
|
| 195 |
+
(r'"""', String.Double, '#pop'),
|
| 196 |
+
include('strings-double'),
|
| 197 |
+
(r'\n', String.Double)
|
| 198 |
+
],
|
| 199 |
+
'tsqs': [
|
| 200 |
+
(r"'''", String.Single, '#pop'),
|
| 201 |
+
include('strings-single'),
|
| 202 |
+
(r'\n', String.Single)
|
| 203 |
+
],
|
| 204 |
+
|
| 205 |
+
'expr-inside-fstring': [
|
| 206 |
+
(r'[{([]', Punctuation, 'expr-inside-fstring-inner'),
|
| 207 |
+
# without format specifier
|
| 208 |
+
(r'(=\s*)?' # debug (https://bugs.python.org/issue36817)
|
| 209 |
+
r'\}', String.Interpol, '#pop'),
|
| 210 |
+
# with format specifier
|
| 211 |
+
# we'll catch the remaining '}' in the outer scope
|
| 212 |
+
(r'(=\s*)?' # debug (https://bugs.python.org/issue36817)
|
| 213 |
+
r':', String.Interpol, '#pop'),
|
| 214 |
+
(r'\s+', Whitespace), # allow new lines
|
| 215 |
+
include('expr'),
|
| 216 |
+
],
|
| 217 |
+
'expr-inside-fstring-inner': [
|
| 218 |
+
(r'[{([]', Punctuation, 'expr-inside-fstring-inner'),
|
| 219 |
+
(r'[])}]', Punctuation, '#pop'),
|
| 220 |
+
(r'\s+', Whitespace), # allow new lines
|
| 221 |
+
include('expr'),
|
| 222 |
+
],
|
| 223 |
+
'keywords': [
|
| 224 |
+
(words((
|
| 225 |
+
'into', 'case', 'type', 'module', 'internal',
|
| 226 |
+
), suffix=r'\b'),
|
| 227 |
+
Keyword),
|
| 228 |
+
(words(('true', 'false', 'null'), suffix=r'\b'), Keyword.Constant),
|
| 229 |
+
],
|
| 230 |
+
'functions': [
|
| 231 |
+
(words((
|
| 232 |
+
"min", "max", "sum", "average", "stddev", "every", "any",
|
| 233 |
+
"concat_array", "count", "lag", "lead", "first", "last",
|
| 234 |
+
"rank", "rank_dense", "row_number", "round", "as", "in",
|
| 235 |
+
"tuple_every", "tuple_map", "tuple_zip", "_eq", "_is_null",
|
| 236 |
+
"from_text", "lower", "upper", "read_parquet", "read_csv"),
|
| 237 |
+
suffix=r'\b'),
|
| 238 |
+
Name.Function),
|
| 239 |
+
],
|
| 240 |
+
|
| 241 |
+
'comment': [
|
| 242 |
+
(r'-(?!\})', Comment.Multiline),
|
| 243 |
+
(r'\{-', Comment.Multiline, 'comment'),
|
| 244 |
+
(r'[^-}]', Comment.Multiline),
|
| 245 |
+
(r'-\}', Comment.Multiline, '#pop'),
|
| 246 |
+
],
|
| 247 |
+
|
| 248 |
+
'imports': [
|
| 249 |
+
(r'\w+(\.\w+)*', Name.Class, '#pop'),
|
| 250 |
+
],
|
| 251 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/ptx.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.ptx
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for other PTX language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, include, words
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, String, Number, \
|
| 13 |
+
Punctuation, Whitespace, Operator
|
| 14 |
+
|
| 15 |
+
__all__ = ["PtxLexer"]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class PtxLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For NVIDIA `PTX <https://docs.nvidia.com/cuda/parallel-thread-execution/>`_
|
| 21 |
+
source.
|
| 22 |
+
"""
|
| 23 |
+
name = 'PTX'
|
| 24 |
+
url = "https://docs.nvidia.com/cuda/parallel-thread-execution/"
|
| 25 |
+
filenames = ['*.ptx']
|
| 26 |
+
aliases = ['ptx']
|
| 27 |
+
mimetypes = ['text/x-ptx']
|
| 28 |
+
version_added = '2.16'
|
| 29 |
+
|
| 30 |
+
#: optional Comment or Whitespace
|
| 31 |
+
string = r'"[^"]*?"'
|
| 32 |
+
followsym = r'[a-zA-Z0-9_$]'
|
| 33 |
+
identifier = r'([-a-zA-Z$._][\w\-$.]*|' + string + ')'
|
| 34 |
+
block_label = r'(' + identifier + r'|(\d+))'
|
| 35 |
+
|
| 36 |
+
tokens = {
|
| 37 |
+
'root': [
|
| 38 |
+
include('whitespace'),
|
| 39 |
+
|
| 40 |
+
(block_label + r'\s*:', Name.Label),
|
| 41 |
+
|
| 42 |
+
include('keyword'),
|
| 43 |
+
|
| 44 |
+
(r'%' + identifier, Name.Variable),
|
| 45 |
+
(r'%\d+', Name.Variable.Anonymous),
|
| 46 |
+
(r'c?' + string, String),
|
| 47 |
+
(identifier, Name.Variable),
|
| 48 |
+
(r';', Punctuation),
|
| 49 |
+
(r'[*+-/]', Operator),
|
| 50 |
+
|
| 51 |
+
(r'0[xX][a-fA-F0-9]+', Number),
|
| 52 |
+
(r'-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?', Number),
|
| 53 |
+
|
| 54 |
+
(r'[=<>{}\[\]()*.,!]|x\b', Punctuation)
|
| 55 |
+
|
| 56 |
+
],
|
| 57 |
+
'whitespace': [
|
| 58 |
+
(r'(\n|\s+)+', Whitespace),
|
| 59 |
+
(r'//.*?\n', Comment)
|
| 60 |
+
],
|
| 61 |
+
|
| 62 |
+
'keyword': [
|
| 63 |
+
# Instruction keywords
|
| 64 |
+
(words((
|
| 65 |
+
'abs', 'discard', 'min', 'shf', 'vadd',
|
| 66 |
+
'activemask', 'div', 'mma', 'shfl', 'vadd2',
|
| 67 |
+
'add', 'dp2a', 'mov', 'shl', 'vadd4',
|
| 68 |
+
'addc', 'dp4a', 'movmatrix', 'shr', 'vavrg2',
|
| 69 |
+
'alloca', 'elect', 'mul', 'sin', 'vavrg4',
|
| 70 |
+
'and', 'ex2', 'mul24', 'slct', 'vmad',
|
| 71 |
+
'applypriority', 'exit', 'multimem', 'sqrt', 'vmax',
|
| 72 |
+
'atom', 'fence', 'nanosleep', 'st', 'vmax2',
|
| 73 |
+
'bar', 'fma', 'neg', 'stackrestore', 'vmax4',
|
| 74 |
+
'barrier', 'fns', 'not', 'stacksave', 'vmin',
|
| 75 |
+
'bfe', 'getctarank', 'or', 'stmatrix', 'vmin2',
|
| 76 |
+
'bfi', 'griddepcontrol', 'pmevent', 'sub', 'vmin4',
|
| 77 |
+
'bfind', 'isspacep', 'popc', 'subc', 'vote',
|
| 78 |
+
'bmsk', 'istypep', 'prefetch', 'suld', 'vset',
|
| 79 |
+
'bra', 'ld', 'prefetchu', 'suq', 'vset2',
|
| 80 |
+
'brev', 'ldmatrix', 'prmt', 'sured', 'vset4',
|
| 81 |
+
'brkpt', 'ldu', 'rcp', 'sust', 'vshl',
|
| 82 |
+
'brx', 'lg2', 'red', 'szext', 'vshr',
|
| 83 |
+
'call', 'lop3', 'redux', 'tanh', 'vsub',
|
| 84 |
+
'clz', 'mad', 'rem', 'testp', 'vsub2',
|
| 85 |
+
'cnot', 'mad24', 'ret', 'tex', 'vsub4',
|
| 86 |
+
'copysign', 'madc', 'rsqrt', 'tld4', 'wgmma',
|
| 87 |
+
'cos', 'mapa', 'sad', 'trap', 'wmma',
|
| 88 |
+
'cp', 'match', 'selp', 'txq', 'xor',
|
| 89 |
+
'createpolicy', 'max', 'set', 'vabsdiff', 'cvt',
|
| 90 |
+
'mbarrier', 'setmaxnreg', 'vabsdiff2', 'cvta',
|
| 91 |
+
'membar', 'setp', 'vabsdiff4')), Keyword),
|
| 92 |
+
# State Spaces and Suffixes
|
| 93 |
+
(words((
|
| 94 |
+
'reg', '.sreg', '.const', '.global',
|
| 95 |
+
'.local', '.param', '.shared', '.tex',
|
| 96 |
+
'.wide', '.loc'
|
| 97 |
+
)), Keyword.Pseudo),
|
| 98 |
+
# PTX Directives
|
| 99 |
+
(words((
|
| 100 |
+
'.address_size', '.explicitcluster', '.maxnreg', '.section',
|
| 101 |
+
'.alias', '.extern', '.maxntid', '.shared',
|
| 102 |
+
'.align', '.file', '.minnctapersm', '.sreg',
|
| 103 |
+
'.branchtargets', '.func', '.noreturn', '.target',
|
| 104 |
+
'.callprototype', '.global', '.param', '.tex',
|
| 105 |
+
'.calltargets', '.loc', '.pragma', '.version',
|
| 106 |
+
'.common', '.local', '.reg', '.visible',
|
| 107 |
+
'.const', '.maxclusterrank', '.reqnctapercluster', '.weak',
|
| 108 |
+
'.entry', '.maxnctapersm', '.reqntid')), Keyword.Reserved),
|
| 109 |
+
# Fundamental Types
|
| 110 |
+
(words((
|
| 111 |
+
'.s8', '.s16', '.s32', '.s64',
|
| 112 |
+
'.u8', '.u16', '.u32', '.u64',
|
| 113 |
+
'.f16', '.f16x2', '.f32', '.f64',
|
| 114 |
+
'.b8', '.b16', '.b32', '.b64',
|
| 115 |
+
'.pred'
|
| 116 |
+
)), Keyword.Type)
|
| 117 |
+
],
|
| 118 |
+
|
| 119 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/python.py
ADDED
|
@@ -0,0 +1,1204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.python
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Python and related languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import keyword
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import DelegatingLexer, RegexLexer, include, \
|
| 14 |
+
bygroups, using, default, words, combined, this
|
| 15 |
+
from pygments.util import get_bool_opt, shebang_matches
|
| 16 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 17 |
+
Number, Punctuation, Generic, Other, Error, Whitespace
|
| 18 |
+
from pygments import unistring as uni
|
| 19 |
+
|
| 20 |
+
__all__ = ['PythonLexer', 'PythonConsoleLexer', 'PythonTracebackLexer',
|
| 21 |
+
'Python2Lexer', 'Python2TracebackLexer',
|
| 22 |
+
'CythonLexer', 'DgLexer', 'NumPyLexer']
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class PythonLexer(RegexLexer):
|
| 26 |
+
"""
|
| 27 |
+
For Python source code (version 3.x).
|
| 28 |
+
|
| 29 |
+
.. versionchanged:: 2.5
|
| 30 |
+
This is now the default ``PythonLexer``. It is still available as the
|
| 31 |
+
alias ``Python3Lexer``.
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
name = 'Python'
|
| 35 |
+
url = 'https://www.python.org'
|
| 36 |
+
aliases = ['python', 'py', 'sage', 'python3', 'py3', 'bazel', 'starlark', 'pyi']
|
| 37 |
+
filenames = [
|
| 38 |
+
'*.py',
|
| 39 |
+
'*.pyw',
|
| 40 |
+
# Type stubs
|
| 41 |
+
'*.pyi',
|
| 42 |
+
# Jython
|
| 43 |
+
'*.jy',
|
| 44 |
+
# Sage
|
| 45 |
+
'*.sage',
|
| 46 |
+
# SCons
|
| 47 |
+
'*.sc',
|
| 48 |
+
'SConstruct',
|
| 49 |
+
'SConscript',
|
| 50 |
+
# Skylark/Starlark (used by Bazel, Buck, and Pants)
|
| 51 |
+
'*.bzl',
|
| 52 |
+
'BUCK',
|
| 53 |
+
'BUILD',
|
| 54 |
+
'BUILD.bazel',
|
| 55 |
+
'WORKSPACE',
|
| 56 |
+
# Twisted Application infrastructure
|
| 57 |
+
'*.tac',
|
| 58 |
+
# Execubot level format
|
| 59 |
+
'*.pye',
|
| 60 |
+
]
|
| 61 |
+
mimetypes = ['text/x-python', 'application/x-python',
|
| 62 |
+
'text/x-python3', 'application/x-python3']
|
| 63 |
+
version_added = '0.10'
|
| 64 |
+
|
| 65 |
+
uni_name = f"[{uni.xid_start}][{uni.xid_continue}]*"
|
| 66 |
+
|
| 67 |
+
def innerstring_rules(ttype):
|
| 68 |
+
return [
|
| 69 |
+
# the old style '%s' % (...) string formatting (still valid in Py3)
|
| 70 |
+
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
| 71 |
+
'[hlL]?[E-GXc-giorsaux%]', String.Interpol),
|
| 72 |
+
# the new style '{}'.format(...) string formatting
|
| 73 |
+
(r'\{'
|
| 74 |
+
r'((\w+)((\.\w+)|(\[[^\]]+\]))*)?' # field name
|
| 75 |
+
r'(\![sra])?' # conversion
|
| 76 |
+
r'(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?'
|
| 77 |
+
r'\}', String.Interpol),
|
| 78 |
+
|
| 79 |
+
# backslashes, quotes and formatting signs must be parsed one at a time
|
| 80 |
+
(r'[^\\\'"%{\n]+', ttype),
|
| 81 |
+
(r'[\'"\\]', ttype),
|
| 82 |
+
# unhandled string formatting sign
|
| 83 |
+
(r'%|(\{{1,2})', ttype)
|
| 84 |
+
# newlines are an error (use "nl" state)
|
| 85 |
+
]
|
| 86 |
+
|
| 87 |
+
def fstring_rules(ttype):
|
| 88 |
+
return [
|
| 89 |
+
# Assuming that a '}' is the closing brace after format specifier.
|
| 90 |
+
# Sadly, this means that we won't detect syntax error. But it's
|
| 91 |
+
# more important to parse correct syntax correctly, than to
|
| 92 |
+
# highlight invalid syntax.
|
| 93 |
+
(r'\}', String.Interpol),
|
| 94 |
+
(r'\{', String.Interpol, 'expr-inside-fstring'),
|
| 95 |
+
# backslashes, quotes and formatting signs must be parsed one at a time
|
| 96 |
+
(r'[^\\\'"{}\n]+', ttype),
|
| 97 |
+
(r'[\'"\\]', ttype),
|
| 98 |
+
# newlines are an error (use "nl" state)
|
| 99 |
+
]
|
| 100 |
+
|
| 101 |
+
tokens = {
|
| 102 |
+
'root': [
|
| 103 |
+
(r'\n', Whitespace),
|
| 104 |
+
(r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")',
|
| 105 |
+
bygroups(Whitespace, String.Affix, String.Doc)),
|
| 106 |
+
(r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')",
|
| 107 |
+
bygroups(Whitespace, String.Affix, String.Doc)),
|
| 108 |
+
(r'\A#!.+$', Comment.Hashbang),
|
| 109 |
+
(r'#.*$', Comment.Single),
|
| 110 |
+
(r'\\\n', Text),
|
| 111 |
+
(r'\\', Text),
|
| 112 |
+
include('keywords'),
|
| 113 |
+
include('soft-keywords'),
|
| 114 |
+
(r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Whitespace), 'funcname'),
|
| 115 |
+
(r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Whitespace), 'classname'),
|
| 116 |
+
(r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Whitespace),
|
| 117 |
+
'fromimport'),
|
| 118 |
+
(r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Whitespace),
|
| 119 |
+
'import'),
|
| 120 |
+
include('expr'),
|
| 121 |
+
],
|
| 122 |
+
'expr': [
|
| 123 |
+
# raw f-strings and t-strings
|
| 124 |
+
('(?i)(r[ft]|[ft]r)(""")',
|
| 125 |
+
bygroups(String.Affix, String.Double),
|
| 126 |
+
combined('rfstringescape', 'tdqf')),
|
| 127 |
+
("(?i)(r[ft]|[ft]r)(''')",
|
| 128 |
+
bygroups(String.Affix, String.Single),
|
| 129 |
+
combined('rfstringescape', 'tsqf')),
|
| 130 |
+
('(?i)(r[ft]|[ft]r)(")',
|
| 131 |
+
bygroups(String.Affix, String.Double),
|
| 132 |
+
combined('rfstringescape', 'dqf')),
|
| 133 |
+
("(?i)(r[ft]|[ft]r)(')",
|
| 134 |
+
bygroups(String.Affix, String.Single),
|
| 135 |
+
combined('rfstringescape', 'sqf')),
|
| 136 |
+
# non-raw f-strings and t-strings
|
| 137 |
+
('([fFtT])(""")', bygroups(String.Affix, String.Double),
|
| 138 |
+
combined('fstringescape', 'tdqf')),
|
| 139 |
+
("([fFtT])(''')", bygroups(String.Affix, String.Single),
|
| 140 |
+
combined('fstringescape', 'tsqf')),
|
| 141 |
+
('([fFtT])(")', bygroups(String.Affix, String.Double),
|
| 142 |
+
combined('fstringescape', 'dqf')),
|
| 143 |
+
("([fFtT])(')", bygroups(String.Affix, String.Single),
|
| 144 |
+
combined('fstringescape', 'sqf')),
|
| 145 |
+
# raw bytes and strings
|
| 146 |
+
('(?i)(rb|br|r)(""")',
|
| 147 |
+
bygroups(String.Affix, String.Double), 'tdqs'),
|
| 148 |
+
("(?i)(rb|br|r)(''')",
|
| 149 |
+
bygroups(String.Affix, String.Single), 'tsqs'),
|
| 150 |
+
('(?i)(rb|br|r)(")',
|
| 151 |
+
bygroups(String.Affix, String.Double), 'dqs'),
|
| 152 |
+
("(?i)(rb|br|r)(')",
|
| 153 |
+
bygroups(String.Affix, String.Single), 'sqs'),
|
| 154 |
+
# non-raw strings
|
| 155 |
+
('([uU]?)(""")', bygroups(String.Affix, String.Double),
|
| 156 |
+
combined('stringescape', 'tdqs')),
|
| 157 |
+
("([uU]?)(''')", bygroups(String.Affix, String.Single),
|
| 158 |
+
combined('stringescape', 'tsqs')),
|
| 159 |
+
('([uU]?)(")', bygroups(String.Affix, String.Double),
|
| 160 |
+
combined('stringescape', 'dqs')),
|
| 161 |
+
("([uU]?)(')", bygroups(String.Affix, String.Single),
|
| 162 |
+
combined('stringescape', 'sqs')),
|
| 163 |
+
# non-raw bytes
|
| 164 |
+
('([bB])(""")', bygroups(String.Affix, String.Double),
|
| 165 |
+
combined('bytesescape', 'tdqs')),
|
| 166 |
+
("([bB])(''')", bygroups(String.Affix, String.Single),
|
| 167 |
+
combined('bytesescape', 'tsqs')),
|
| 168 |
+
('([bB])(")', bygroups(String.Affix, String.Double),
|
| 169 |
+
combined('bytesescape', 'dqs')),
|
| 170 |
+
("([bB])(')", bygroups(String.Affix, String.Single),
|
| 171 |
+
combined('bytesescape', 'sqs')),
|
| 172 |
+
|
| 173 |
+
(r'[^\S\n]+', Text),
|
| 174 |
+
include('numbers'),
|
| 175 |
+
(r'!=|==|<<|>>|:=|[-~+/*%=<>&^|.]', Operator),
|
| 176 |
+
(r'[]{}:(),;[]', Punctuation),
|
| 177 |
+
(r'(in|is|and|or|not)\b', Operator.Word),
|
| 178 |
+
include('expr-keywords'),
|
| 179 |
+
include('builtins'),
|
| 180 |
+
include('magicfuncs'),
|
| 181 |
+
include('magicvars'),
|
| 182 |
+
include('name'),
|
| 183 |
+
],
|
| 184 |
+
'expr-inside-fstring': [
|
| 185 |
+
(r'[{([]', Punctuation, 'expr-inside-fstring-inner'),
|
| 186 |
+
# without format specifier
|
| 187 |
+
(r'(=\s*)?' # debug (https://bugs.python.org/issue36817)
|
| 188 |
+
r'(\![sraf])?' # conversion
|
| 189 |
+
r'\}', String.Interpol, '#pop'),
|
| 190 |
+
# with format specifier
|
| 191 |
+
# we'll catch the remaining '}' in the outer scope
|
| 192 |
+
(r'(=\s*)?' # debug (https://bugs.python.org/issue36817)
|
| 193 |
+
r'(\![sraf])?' # conversion
|
| 194 |
+
r':', String.Interpol, '#pop'),
|
| 195 |
+
(r'\s+', Whitespace), # allow new lines
|
| 196 |
+
include('expr'),
|
| 197 |
+
],
|
| 198 |
+
'expr-inside-fstring-inner': [
|
| 199 |
+
(r'[{([]', Punctuation, 'expr-inside-fstring-inner'),
|
| 200 |
+
(r'[])}]', Punctuation, '#pop'),
|
| 201 |
+
(r'\s+', Whitespace), # allow new lines
|
| 202 |
+
include('expr'),
|
| 203 |
+
],
|
| 204 |
+
'expr-keywords': [
|
| 205 |
+
# Based on https://docs.python.org/3/reference/expressions.html
|
| 206 |
+
(words((
|
| 207 |
+
'async for', 'await', 'else', 'for', 'if', 'lambda',
|
| 208 |
+
'yield', 'yield from'), suffix=r'\b'),
|
| 209 |
+
Keyword),
|
| 210 |
+
(words(('True', 'False', 'None'), suffix=r'\b'), Keyword.Constant),
|
| 211 |
+
],
|
| 212 |
+
'keywords': [
|
| 213 |
+
(words((
|
| 214 |
+
'assert', 'async', 'await', 'break', 'continue', 'del', 'elif',
|
| 215 |
+
'else', 'except', 'finally', 'for', 'global', 'if', 'lambda',
|
| 216 |
+
'pass', 'raise', 'nonlocal', 'return', 'try', 'while', 'yield',
|
| 217 |
+
'yield from', 'as', 'with'), suffix=r'\b'),
|
| 218 |
+
Keyword),
|
| 219 |
+
(words(('True', 'False', 'None'), suffix=r'\b'), Keyword.Constant),
|
| 220 |
+
],
|
| 221 |
+
'soft-keywords': [
|
| 222 |
+
# `match`, `case` and `_` soft keywords
|
| 223 |
+
(r'(^[ \t]*)' # at beginning of line + possible indentation
|
| 224 |
+
r'(match|case)\b' # a possible keyword
|
| 225 |
+
r'(?![ \t]*(?:' # not followed by...
|
| 226 |
+
r'[:,;=^&|@~)\]}]|(?:' + # characters and keywords that mean this isn't
|
| 227 |
+
# pattern matching (but None/True/False is ok)
|
| 228 |
+
r'|'.join(k for k in keyword.kwlist if k[0].islower()) + r')\b))',
|
| 229 |
+
bygroups(Text, Keyword), 'soft-keywords-inner'),
|
| 230 |
+
],
|
| 231 |
+
'soft-keywords-inner': [
|
| 232 |
+
# optional `_` keyword
|
| 233 |
+
(r'(\s+)([^\n_]*)(_\b)', bygroups(Whitespace, using(this), Keyword)),
|
| 234 |
+
default('#pop')
|
| 235 |
+
],
|
| 236 |
+
'builtins': [
|
| 237 |
+
(words((
|
| 238 |
+
'__import__', 'abs', 'aiter', 'all', 'any', 'bin', 'bool', 'bytearray',
|
| 239 |
+
'breakpoint', 'bytes', 'callable', 'chr', 'classmethod', 'compile',
|
| 240 |
+
'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval',
|
| 241 |
+
'filter', 'float', 'format', 'frozenset', 'getattr', 'globals',
|
| 242 |
+
'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'isinstance',
|
| 243 |
+
'issubclass', 'iter', 'len', 'list', 'locals', 'map', 'max',
|
| 244 |
+
'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow',
|
| 245 |
+
'print', 'property', 'range', 'repr', 'reversed', 'round', 'set',
|
| 246 |
+
'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
|
| 247 |
+
'tuple', 'type', 'vars', 'zip'), prefix=r'(?<!\.)', suffix=r'\b'),
|
| 248 |
+
Name.Builtin),
|
| 249 |
+
(r'(?<!\.)(self|Ellipsis|NotImplemented|cls)\b', Name.Builtin.Pseudo),
|
| 250 |
+
(words((
|
| 251 |
+
'ArithmeticError', 'AssertionError', 'AttributeError',
|
| 252 |
+
'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning',
|
| 253 |
+
'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError',
|
| 254 |
+
'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',
|
| 255 |
+
'ImportWarning', 'IndentationError', 'IndexError', 'KeyError',
|
| 256 |
+
'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError',
|
| 257 |
+
'NotImplementedError', 'OSError', 'OverflowError',
|
| 258 |
+
'PendingDeprecationWarning', 'ReferenceError', 'ResourceWarning',
|
| 259 |
+
'RuntimeError', 'RuntimeWarning', 'StopIteration',
|
| 260 |
+
'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit',
|
| 261 |
+
'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError',
|
| 262 |
+
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
|
| 263 |
+
'UnicodeWarning', 'UserWarning', 'ValueError', 'VMSError',
|
| 264 |
+
'Warning', 'WindowsError', 'ZeroDivisionError',
|
| 265 |
+
# new builtin exceptions from PEP 3151
|
| 266 |
+
'BlockingIOError', 'ChildProcessError', 'ConnectionError',
|
| 267 |
+
'BrokenPipeError', 'ConnectionAbortedError', 'ConnectionRefusedError',
|
| 268 |
+
'ConnectionResetError', 'FileExistsError', 'FileNotFoundError',
|
| 269 |
+
'InterruptedError', 'IsADirectoryError', 'NotADirectoryError',
|
| 270 |
+
'PermissionError', 'ProcessLookupError', 'TimeoutError',
|
| 271 |
+
# others new in Python 3
|
| 272 |
+
'StopAsyncIteration', 'ModuleNotFoundError', 'RecursionError',
|
| 273 |
+
'EncodingWarning'),
|
| 274 |
+
prefix=r'(?<!\.)', suffix=r'\b'),
|
| 275 |
+
Name.Exception),
|
| 276 |
+
],
|
| 277 |
+
'magicfuncs': [
|
| 278 |
+
(words((
|
| 279 |
+
'__abs__', '__add__', '__aenter__', '__aexit__', '__aiter__',
|
| 280 |
+
'__and__', '__anext__', '__await__', '__bool__', '__bytes__',
|
| 281 |
+
'__call__', '__complex__', '__contains__', '__del__', '__delattr__',
|
| 282 |
+
'__delete__', '__delitem__', '__dir__', '__divmod__', '__enter__',
|
| 283 |
+
'__eq__', '__exit__', '__float__', '__floordiv__', '__format__',
|
| 284 |
+
'__ge__', '__get__', '__getattr__', '__getattribute__',
|
| 285 |
+
'__getitem__', '__gt__', '__hash__', '__iadd__', '__iand__',
|
| 286 |
+
'__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__',
|
| 287 |
+
'__imul__', '__index__', '__init__', '__instancecheck__',
|
| 288 |
+
'__int__', '__invert__', '__ior__', '__ipow__', '__irshift__',
|
| 289 |
+
'__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__',
|
| 290 |
+
'__len__', '__length_hint__', '__lshift__', '__lt__', '__matmul__',
|
| 291 |
+
'__missing__', '__mod__', '__mul__', '__ne__', '__neg__',
|
| 292 |
+
'__new__', '__next__', '__or__', '__pos__', '__pow__',
|
| 293 |
+
'__prepare__', '__radd__', '__rand__', '__rdivmod__', '__repr__',
|
| 294 |
+
'__reversed__', '__rfloordiv__', '__rlshift__', '__rmatmul__',
|
| 295 |
+
'__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__',
|
| 296 |
+
'__rrshift__', '__rshift__', '__rsub__', '__rtruediv__',
|
| 297 |
+
'__rxor__', '__set__', '__setattr__', '__setitem__', '__str__',
|
| 298 |
+
'__sub__', '__subclasscheck__', '__truediv__',
|
| 299 |
+
'__xor__'), suffix=r'\b'),
|
| 300 |
+
Name.Function.Magic),
|
| 301 |
+
],
|
| 302 |
+
'magicvars': [
|
| 303 |
+
(words((
|
| 304 |
+
'__annotations__', '__bases__', '__class__', '__closure__',
|
| 305 |
+
'__code__', '__defaults__', '__dict__', '__doc__', '__file__',
|
| 306 |
+
'__func__', '__globals__', '__kwdefaults__', '__module__',
|
| 307 |
+
'__mro__', '__name__', '__objclass__', '__qualname__',
|
| 308 |
+
'__self__', '__slots__', '__weakref__'), suffix=r'\b'),
|
| 309 |
+
Name.Variable.Magic),
|
| 310 |
+
],
|
| 311 |
+
'numbers': [
|
| 312 |
+
(r'(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)'
|
| 313 |
+
r'([eE][+-]?\d(?:_?\d)*)?', Number.Float),
|
| 314 |
+
(r'\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?', Number.Float),
|
| 315 |
+
(r'0[oO](?:_?[0-7])+', Number.Oct),
|
| 316 |
+
(r'0[bB](?:_?[01])+', Number.Bin),
|
| 317 |
+
(r'0[xX](?:_?[a-fA-F0-9])+', Number.Hex),
|
| 318 |
+
(r'\d(?:_?\d)*', Number.Integer),
|
| 319 |
+
],
|
| 320 |
+
'name': [
|
| 321 |
+
(r'@' + uni_name, Name.Decorator),
|
| 322 |
+
(r'@', Operator), # new matrix multiplication operator
|
| 323 |
+
(uni_name, Name),
|
| 324 |
+
],
|
| 325 |
+
'funcname': [
|
| 326 |
+
include('magicfuncs'),
|
| 327 |
+
(uni_name, Name.Function, '#pop'),
|
| 328 |
+
default('#pop'),
|
| 329 |
+
],
|
| 330 |
+
'classname': [
|
| 331 |
+
(uni_name, Name.Class, '#pop'),
|
| 332 |
+
],
|
| 333 |
+
'import': [
|
| 334 |
+
(r'(\s+)(as)(\s+)', bygroups(Whitespace, Keyword, Whitespace)),
|
| 335 |
+
(r'\.', Name.Namespace),
|
| 336 |
+
(uni_name, Name.Namespace),
|
| 337 |
+
(r'(\s*)(,)(\s*)', bygroups(Whitespace, Operator, Whitespace)),
|
| 338 |
+
default('#pop') # all else: go back
|
| 339 |
+
],
|
| 340 |
+
'fromimport': [
|
| 341 |
+
(r'(\s+)(import)\b', bygroups(Whitespace, Keyword.Namespace), '#pop'),
|
| 342 |
+
(r'\.', Name.Namespace),
|
| 343 |
+
# if None occurs here, it's "raise x from None", since None can
|
| 344 |
+
# never be a module name
|
| 345 |
+
(r'None\b', Keyword.Constant, '#pop'),
|
| 346 |
+
(uni_name, Name.Namespace),
|
| 347 |
+
default('#pop'),
|
| 348 |
+
],
|
| 349 |
+
'rfstringescape': [
|
| 350 |
+
(r'\{\{', String.Escape),
|
| 351 |
+
(r'\}\}', String.Escape),
|
| 352 |
+
],
|
| 353 |
+
'fstringescape': [
|
| 354 |
+
include('rfstringescape'),
|
| 355 |
+
include('stringescape'),
|
| 356 |
+
],
|
| 357 |
+
'bytesescape': [
|
| 358 |
+
(r'\\([\\abfnrtv"\']|\n|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
| 359 |
+
],
|
| 360 |
+
'stringescape': [
|
| 361 |
+
(r'\\(N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8})', String.Escape),
|
| 362 |
+
include('bytesescape')
|
| 363 |
+
],
|
| 364 |
+
'fstrings-single': fstring_rules(String.Single),
|
| 365 |
+
'fstrings-double': fstring_rules(String.Double),
|
| 366 |
+
'strings-single': innerstring_rules(String.Single),
|
| 367 |
+
'strings-double': innerstring_rules(String.Double),
|
| 368 |
+
'dqf': [
|
| 369 |
+
(r'"', String.Double, '#pop'),
|
| 370 |
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
| 371 |
+
include('fstrings-double')
|
| 372 |
+
],
|
| 373 |
+
'sqf': [
|
| 374 |
+
(r"'", String.Single, '#pop'),
|
| 375 |
+
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
| 376 |
+
include('fstrings-single')
|
| 377 |
+
],
|
| 378 |
+
'dqs': [
|
| 379 |
+
(r'"', String.Double, '#pop'),
|
| 380 |
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
| 381 |
+
include('strings-double')
|
| 382 |
+
],
|
| 383 |
+
'sqs': [
|
| 384 |
+
(r"'", String.Single, '#pop'),
|
| 385 |
+
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
| 386 |
+
include('strings-single')
|
| 387 |
+
],
|
| 388 |
+
'tdqf': [
|
| 389 |
+
(r'"""', String.Double, '#pop'),
|
| 390 |
+
include('fstrings-double'),
|
| 391 |
+
(r'\n', String.Double)
|
| 392 |
+
],
|
| 393 |
+
'tsqf': [
|
| 394 |
+
(r"'''", String.Single, '#pop'),
|
| 395 |
+
include('fstrings-single'),
|
| 396 |
+
(r'\n', String.Single)
|
| 397 |
+
],
|
| 398 |
+
'tdqs': [
|
| 399 |
+
(r'"""', String.Double, '#pop'),
|
| 400 |
+
include('strings-double'),
|
| 401 |
+
(r'\n', String.Double)
|
| 402 |
+
],
|
| 403 |
+
'tsqs': [
|
| 404 |
+
(r"'''", String.Single, '#pop'),
|
| 405 |
+
include('strings-single'),
|
| 406 |
+
(r'\n', String.Single)
|
| 407 |
+
],
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
def analyse_text(text):
|
| 411 |
+
return shebang_matches(text, r'pythonw?(3(\.\d)?)?') or \
|
| 412 |
+
'import ' in text[:1000]
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
Python3Lexer = PythonLexer
|
| 416 |
+
|
| 417 |
+
|
| 418 |
+
class Python2Lexer(RegexLexer):
|
| 419 |
+
"""
|
| 420 |
+
For Python 2.x source code.
|
| 421 |
+
|
| 422 |
+
.. versionchanged:: 2.5
|
| 423 |
+
This class has been renamed from ``PythonLexer``. ``PythonLexer`` now
|
| 424 |
+
refers to the Python 3 variant. File name patterns like ``*.py`` have
|
| 425 |
+
been moved to Python 3 as well.
|
| 426 |
+
"""
|
| 427 |
+
|
| 428 |
+
name = 'Python 2.x'
|
| 429 |
+
url = 'https://www.python.org'
|
| 430 |
+
aliases = ['python2', 'py2']
|
| 431 |
+
filenames = [] # now taken over by PythonLexer (3.x)
|
| 432 |
+
mimetypes = ['text/x-python2', 'application/x-python2']
|
| 433 |
+
version_added = ''
|
| 434 |
+
|
| 435 |
+
def innerstring_rules(ttype):
|
| 436 |
+
return [
|
| 437 |
+
# the old style '%s' % (...) string formatting
|
| 438 |
+
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
| 439 |
+
'[hlL]?[E-GXc-giorsux%]', String.Interpol),
|
| 440 |
+
# backslashes, quotes and formatting signs must be parsed one at a time
|
| 441 |
+
(r'[^\\\'"%\n]+', ttype),
|
| 442 |
+
(r'[\'"\\]', ttype),
|
| 443 |
+
# unhandled string formatting sign
|
| 444 |
+
(r'%', ttype),
|
| 445 |
+
# newlines are an error (use "nl" state)
|
| 446 |
+
]
|
| 447 |
+
|
| 448 |
+
tokens = {
|
| 449 |
+
'root': [
|
| 450 |
+
(r'\n', Whitespace),
|
| 451 |
+
(r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")',
|
| 452 |
+
bygroups(Whitespace, String.Affix, String.Doc)),
|
| 453 |
+
(r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')",
|
| 454 |
+
bygroups(Whitespace, String.Affix, String.Doc)),
|
| 455 |
+
(r'[^\S\n]+', Text),
|
| 456 |
+
(r'\A#!.+$', Comment.Hashbang),
|
| 457 |
+
(r'#.*$', Comment.Single),
|
| 458 |
+
(r'[]{}:(),;[]', Punctuation),
|
| 459 |
+
(r'\\\n', Text),
|
| 460 |
+
(r'\\', Text),
|
| 461 |
+
(r'(in|is|and|or|not)\b', Operator.Word),
|
| 462 |
+
(r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator),
|
| 463 |
+
include('keywords'),
|
| 464 |
+
(r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Whitespace), 'funcname'),
|
| 465 |
+
(r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Whitespace), 'classname'),
|
| 466 |
+
(r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Whitespace),
|
| 467 |
+
'fromimport'),
|
| 468 |
+
(r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Whitespace),
|
| 469 |
+
'import'),
|
| 470 |
+
include('builtins'),
|
| 471 |
+
include('magicfuncs'),
|
| 472 |
+
include('magicvars'),
|
| 473 |
+
include('backtick'),
|
| 474 |
+
('([rR]|[uUbB][rR]|[rR][uUbB])(""")',
|
| 475 |
+
bygroups(String.Affix, String.Double), 'tdqs'),
|
| 476 |
+
("([rR]|[uUbB][rR]|[rR][uUbB])(''')",
|
| 477 |
+
bygroups(String.Affix, String.Single), 'tsqs'),
|
| 478 |
+
('([rR]|[uUbB][rR]|[rR][uUbB])(")',
|
| 479 |
+
bygroups(String.Affix, String.Double), 'dqs'),
|
| 480 |
+
("([rR]|[uUbB][rR]|[rR][uUbB])(')",
|
| 481 |
+
bygroups(String.Affix, String.Single), 'sqs'),
|
| 482 |
+
('([uUbB]?)(""")', bygroups(String.Affix, String.Double),
|
| 483 |
+
combined('stringescape', 'tdqs')),
|
| 484 |
+
("([uUbB]?)(''')", bygroups(String.Affix, String.Single),
|
| 485 |
+
combined('stringescape', 'tsqs')),
|
| 486 |
+
('([uUbB]?)(")', bygroups(String.Affix, String.Double),
|
| 487 |
+
combined('stringescape', 'dqs')),
|
| 488 |
+
("([uUbB]?)(')", bygroups(String.Affix, String.Single),
|
| 489 |
+
combined('stringescape', 'sqs')),
|
| 490 |
+
include('name'),
|
| 491 |
+
include('numbers'),
|
| 492 |
+
],
|
| 493 |
+
'keywords': [
|
| 494 |
+
(words((
|
| 495 |
+
'assert', 'break', 'continue', 'del', 'elif', 'else', 'except',
|
| 496 |
+
'exec', 'finally', 'for', 'global', 'if', 'lambda', 'pass',
|
| 497 |
+
'print', 'raise', 'return', 'try', 'while', 'yield',
|
| 498 |
+
'yield from', 'as', 'with'), suffix=r'\b'),
|
| 499 |
+
Keyword),
|
| 500 |
+
],
|
| 501 |
+
'builtins': [
|
| 502 |
+
(words((
|
| 503 |
+
'__import__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin',
|
| 504 |
+
'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod',
|
| 505 |
+
'cmp', 'coerce', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod',
|
| 506 |
+
'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
|
| 507 |
+
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id',
|
| 508 |
+
'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len',
|
| 509 |
+
'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object',
|
| 510 |
+
'oct', 'open', 'ord', 'pow', 'property', 'range', 'raw_input', 'reduce',
|
| 511 |
+
'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice',
|
| 512 |
+
'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type',
|
| 513 |
+
'unichr', 'unicode', 'vars', 'xrange', 'zip'),
|
| 514 |
+
prefix=r'(?<!\.)', suffix=r'\b'),
|
| 515 |
+
Name.Builtin),
|
| 516 |
+
(r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|cls'
|
| 517 |
+
r')\b', Name.Builtin.Pseudo),
|
| 518 |
+
(words((
|
| 519 |
+
'ArithmeticError', 'AssertionError', 'AttributeError',
|
| 520 |
+
'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError',
|
| 521 |
+
'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit',
|
| 522 |
+
'IOError', 'ImportError', 'ImportWarning', 'IndentationError',
|
| 523 |
+
'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError',
|
| 524 |
+
'MemoryError', 'NameError',
|
| 525 |
+
'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning',
|
| 526 |
+
'PendingDeprecationWarning', 'ReferenceError',
|
| 527 |
+
'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration',
|
| 528 |
+
'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit',
|
| 529 |
+
'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError',
|
| 530 |
+
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
|
| 531 |
+
'UnicodeWarning', 'UserWarning', 'ValueError', 'VMSError', 'Warning',
|
| 532 |
+
'WindowsError', 'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'),
|
| 533 |
+
Name.Exception),
|
| 534 |
+
],
|
| 535 |
+
'magicfuncs': [
|
| 536 |
+
(words((
|
| 537 |
+
'__abs__', '__add__', '__and__', '__call__', '__cmp__', '__coerce__',
|
| 538 |
+
'__complex__', '__contains__', '__del__', '__delattr__', '__delete__',
|
| 539 |
+
'__delitem__', '__delslice__', '__div__', '__divmod__', '__enter__',
|
| 540 |
+
'__eq__', '__exit__', '__float__', '__floordiv__', '__ge__', '__get__',
|
| 541 |
+
'__getattr__', '__getattribute__', '__getitem__', '__getslice__', '__gt__',
|
| 542 |
+
'__hash__', '__hex__', '__iadd__', '__iand__', '__idiv__', '__ifloordiv__',
|
| 543 |
+
'__ilshift__', '__imod__', '__imul__', '__index__', '__init__',
|
| 544 |
+
'__instancecheck__', '__int__', '__invert__', '__iop__', '__ior__',
|
| 545 |
+
'__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__',
|
| 546 |
+
'__ixor__', '__le__', '__len__', '__long__', '__lshift__', '__lt__',
|
| 547 |
+
'__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__',
|
| 548 |
+
'__nonzero__', '__oct__', '__op__', '__or__', '__pos__', '__pow__',
|
| 549 |
+
'__radd__', '__rand__', '__rcmp__', '__rdiv__', '__rdivmod__', '__repr__',
|
| 550 |
+
'__reversed__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__',
|
| 551 |
+
'__rop__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__',
|
| 552 |
+
'__rtruediv__', '__rxor__', '__set__', '__setattr__', '__setitem__',
|
| 553 |
+
'__setslice__', '__str__', '__sub__', '__subclasscheck__', '__truediv__',
|
| 554 |
+
'__unicode__', '__xor__'), suffix=r'\b'),
|
| 555 |
+
Name.Function.Magic),
|
| 556 |
+
],
|
| 557 |
+
'magicvars': [
|
| 558 |
+
(words((
|
| 559 |
+
'__bases__', '__class__', '__closure__', '__code__', '__defaults__',
|
| 560 |
+
'__dict__', '__doc__', '__file__', '__func__', '__globals__',
|
| 561 |
+
'__metaclass__', '__module__', '__mro__', '__name__', '__self__',
|
| 562 |
+
'__slots__', '__weakref__'),
|
| 563 |
+
suffix=r'\b'),
|
| 564 |
+
Name.Variable.Magic),
|
| 565 |
+
],
|
| 566 |
+
'numbers': [
|
| 567 |
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
|
| 568 |
+
(r'\d+[eE][+-]?[0-9]+j?', Number.Float),
|
| 569 |
+
(r'0[0-7]+j?', Number.Oct),
|
| 570 |
+
(r'0[bB][01]+', Number.Bin),
|
| 571 |
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
| 572 |
+
(r'\d+L', Number.Integer.Long),
|
| 573 |
+
(r'\d+j?', Number.Integer)
|
| 574 |
+
],
|
| 575 |
+
'backtick': [
|
| 576 |
+
('`.*?`', String.Backtick),
|
| 577 |
+
],
|
| 578 |
+
'name': [
|
| 579 |
+
(r'@[\w.]+', Name.Decorator),
|
| 580 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 581 |
+
],
|
| 582 |
+
'funcname': [
|
| 583 |
+
include('magicfuncs'),
|
| 584 |
+
(r'[a-zA-Z_]\w*', Name.Function, '#pop'),
|
| 585 |
+
default('#pop'),
|
| 586 |
+
],
|
| 587 |
+
'classname': [
|
| 588 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
|
| 589 |
+
],
|
| 590 |
+
'import': [
|
| 591 |
+
(r'(?:[ \t]|\\\n)+', Text),
|
| 592 |
+
(r'as\b', Keyword.Namespace),
|
| 593 |
+
(r',', Operator),
|
| 594 |
+
(r'[a-zA-Z_][\w.]*', Name.Namespace),
|
| 595 |
+
default('#pop') # all else: go back
|
| 596 |
+
],
|
| 597 |
+
'fromimport': [
|
| 598 |
+
(r'(?:[ \t]|\\\n)+', Text),
|
| 599 |
+
(r'import\b', Keyword.Namespace, '#pop'),
|
| 600 |
+
# if None occurs here, it's "raise x from None", since None can
|
| 601 |
+
# never be a module name
|
| 602 |
+
(r'None\b', Name.Builtin.Pseudo, '#pop'),
|
| 603 |
+
# sadly, in "raise x from y" y will be highlighted as namespace too
|
| 604 |
+
(r'[a-zA-Z_.][\w.]*', Name.Namespace),
|
| 605 |
+
# anything else here also means "raise x from y" and is therefore
|
| 606 |
+
# not an error
|
| 607 |
+
default('#pop'),
|
| 608 |
+
],
|
| 609 |
+
'stringescape': [
|
| 610 |
+
(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
|
| 611 |
+
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
| 612 |
+
],
|
| 613 |
+
'strings-single': innerstring_rules(String.Single),
|
| 614 |
+
'strings-double': innerstring_rules(String.Double),
|
| 615 |
+
'dqs': [
|
| 616 |
+
(r'"', String.Double, '#pop'),
|
| 617 |
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
| 618 |
+
include('strings-double')
|
| 619 |
+
],
|
| 620 |
+
'sqs': [
|
| 621 |
+
(r"'", String.Single, '#pop'),
|
| 622 |
+
(r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
|
| 623 |
+
include('strings-single')
|
| 624 |
+
],
|
| 625 |
+
'tdqs': [
|
| 626 |
+
(r'"""', String.Double, '#pop'),
|
| 627 |
+
include('strings-double'),
|
| 628 |
+
(r'\n', String.Double)
|
| 629 |
+
],
|
| 630 |
+
'tsqs': [
|
| 631 |
+
(r"'''", String.Single, '#pop'),
|
| 632 |
+
include('strings-single'),
|
| 633 |
+
(r'\n', String.Single)
|
| 634 |
+
],
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
def analyse_text(text):
|
| 638 |
+
return shebang_matches(text, r'pythonw?2(\.\d)?')
|
| 639 |
+
|
| 640 |
+
|
| 641 |
+
class _PythonConsoleLexerBase(RegexLexer):
|
| 642 |
+
name = 'Python console session'
|
| 643 |
+
aliases = ['pycon', 'python-console']
|
| 644 |
+
mimetypes = ['text/x-python-doctest']
|
| 645 |
+
|
| 646 |
+
"""Auxiliary lexer for `PythonConsoleLexer`.
|
| 647 |
+
|
| 648 |
+
Code tokens are output as ``Token.Other.Code``, traceback tokens as
|
| 649 |
+
``Token.Other.Traceback``.
|
| 650 |
+
"""
|
| 651 |
+
tokens = {
|
| 652 |
+
'root': [
|
| 653 |
+
(r'(>>> )(.*\n)', bygroups(Generic.Prompt, Other.Code), 'continuations'),
|
| 654 |
+
# This happens, e.g., when tracebacks are embedded in documentation;
|
| 655 |
+
# trailing whitespaces are often stripped in such contexts.
|
| 656 |
+
(r'(>>>)(\n)', bygroups(Generic.Prompt, Whitespace)),
|
| 657 |
+
(r'(\^C)?Traceback \(most recent call last\):\n', Other.Traceback, 'traceback'),
|
| 658 |
+
# SyntaxError starts with this
|
| 659 |
+
(r' File "[^"]+", line \d+', Other.Traceback, 'traceback'),
|
| 660 |
+
(r'.*\n', Generic.Output),
|
| 661 |
+
],
|
| 662 |
+
'continuations': [
|
| 663 |
+
(r'(\.\.\. )(.*\n)', bygroups(Generic.Prompt, Other.Code)),
|
| 664 |
+
# See above.
|
| 665 |
+
(r'(\.\.\.)(\n)', bygroups(Generic.Prompt, Whitespace)),
|
| 666 |
+
default('#pop'),
|
| 667 |
+
],
|
| 668 |
+
'traceback': [
|
| 669 |
+
# As soon as we see a traceback, consume everything until the next
|
| 670 |
+
# >>> prompt.
|
| 671 |
+
(r'(?=>>>( |$))', Text, '#pop'),
|
| 672 |
+
(r'(KeyboardInterrupt)(\n)', bygroups(Name.Class, Whitespace)),
|
| 673 |
+
(r'.*\n', Other.Traceback),
|
| 674 |
+
],
|
| 675 |
+
}
|
| 676 |
+
|
| 677 |
+
|
| 678 |
+
class PythonConsoleLexer(DelegatingLexer):
|
| 679 |
+
"""
|
| 680 |
+
For Python console output or doctests, such as:
|
| 681 |
+
|
| 682 |
+
.. sourcecode:: pycon
|
| 683 |
+
|
| 684 |
+
>>> a = 'foo'
|
| 685 |
+
>>> print(a)
|
| 686 |
+
foo
|
| 687 |
+
>>> 1 / 0
|
| 688 |
+
Traceback (most recent call last):
|
| 689 |
+
File "<stdin>", line 1, in <module>
|
| 690 |
+
ZeroDivisionError: integer division or modulo by zero
|
| 691 |
+
|
| 692 |
+
Additional options:
|
| 693 |
+
|
| 694 |
+
`python3`
|
| 695 |
+
Use Python 3 lexer for code. Default is ``True``.
|
| 696 |
+
|
| 697 |
+
.. versionadded:: 1.0
|
| 698 |
+
.. versionchanged:: 2.5
|
| 699 |
+
Now defaults to ``True``.
|
| 700 |
+
"""
|
| 701 |
+
|
| 702 |
+
name = 'Python console session'
|
| 703 |
+
aliases = ['pycon', 'python-console']
|
| 704 |
+
mimetypes = ['text/x-python-doctest']
|
| 705 |
+
url = 'https://python.org'
|
| 706 |
+
version_added = ''
|
| 707 |
+
|
| 708 |
+
def __init__(self, **options):
|
| 709 |
+
python3 = get_bool_opt(options, 'python3', True)
|
| 710 |
+
if python3:
|
| 711 |
+
pylexer = PythonLexer
|
| 712 |
+
tblexer = PythonTracebackLexer
|
| 713 |
+
else:
|
| 714 |
+
pylexer = Python2Lexer
|
| 715 |
+
tblexer = Python2TracebackLexer
|
| 716 |
+
# We have two auxiliary lexers. Use DelegatingLexer twice with
|
| 717 |
+
# different tokens. TODO: DelegatingLexer should support this
|
| 718 |
+
# directly, by accepting a tuplet of auxiliary lexers and a tuple of
|
| 719 |
+
# distinguishing tokens. Then we wouldn't need this intermediary
|
| 720 |
+
# class.
|
| 721 |
+
class _ReplaceInnerCode(DelegatingLexer):
|
| 722 |
+
def __init__(self, **options):
|
| 723 |
+
super().__init__(pylexer, _PythonConsoleLexerBase, Other.Code, **options)
|
| 724 |
+
super().__init__(tblexer, _ReplaceInnerCode, Other.Traceback, **options)
|
| 725 |
+
|
| 726 |
+
|
| 727 |
+
class PythonTracebackLexer(RegexLexer):
|
| 728 |
+
"""
|
| 729 |
+
For Python 3.x tracebacks, with support for chained exceptions.
|
| 730 |
+
|
| 731 |
+
.. versionchanged:: 2.5
|
| 732 |
+
This is now the default ``PythonTracebackLexer``. It is still available
|
| 733 |
+
as the alias ``Python3TracebackLexer``.
|
| 734 |
+
"""
|
| 735 |
+
|
| 736 |
+
name = 'Python Traceback'
|
| 737 |
+
aliases = ['pytb', 'py3tb']
|
| 738 |
+
filenames = ['*.pytb', '*.py3tb']
|
| 739 |
+
mimetypes = ['text/x-python-traceback', 'text/x-python3-traceback']
|
| 740 |
+
url = 'https://python.org'
|
| 741 |
+
version_added = '1.0'
|
| 742 |
+
|
| 743 |
+
tokens = {
|
| 744 |
+
'root': [
|
| 745 |
+
(r'\n', Whitespace),
|
| 746 |
+
(r'^(\^C)?Traceback \(most recent call last\):\n', Generic.Traceback, 'intb'),
|
| 747 |
+
(r'^During handling of the above exception, another '
|
| 748 |
+
r'exception occurred:\n\n', Generic.Traceback),
|
| 749 |
+
(r'^The above exception was the direct cause of the '
|
| 750 |
+
r'following exception:\n\n', Generic.Traceback),
|
| 751 |
+
(r'^(?= File "[^"]+", line \d+)', Generic.Traceback, 'intb'),
|
| 752 |
+
(r'^.*\n', Other),
|
| 753 |
+
],
|
| 754 |
+
'intb': [
|
| 755 |
+
(r'^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)',
|
| 756 |
+
bygroups(Text, Name.Builtin, Text, Number, Text, Name, Whitespace)),
|
| 757 |
+
(r'^( File )("[^"]+")(, line )(\d+)(\n)',
|
| 758 |
+
bygroups(Text, Name.Builtin, Text, Number, Whitespace)),
|
| 759 |
+
(r'^( )(.+)(\n)',
|
| 760 |
+
bygroups(Whitespace, using(PythonLexer), Whitespace), 'markers'),
|
| 761 |
+
(r'^([ \t]*)(\.\.\.)(\n)',
|
| 762 |
+
bygroups(Whitespace, Comment, Whitespace)), # for doctests...
|
| 763 |
+
(r'^([^:]+)(: )(.+)(\n)',
|
| 764 |
+
bygroups(Generic.Error, Text, Name, Whitespace), '#pop'),
|
| 765 |
+
(r'^([a-zA-Z_][\w.]*)(:?\n)',
|
| 766 |
+
bygroups(Generic.Error, Whitespace), '#pop'),
|
| 767 |
+
default('#pop'),
|
| 768 |
+
],
|
| 769 |
+
'markers': [
|
| 770 |
+
# Either `PEP 657 <https://www.python.org/dev/peps/pep-0657/>`
|
| 771 |
+
# error locations in Python 3.11+, or single-caret markers
|
| 772 |
+
# for syntax errors before that.
|
| 773 |
+
(r'^( {4,})([~^]+)(\n)',
|
| 774 |
+
bygroups(Whitespace, Punctuation.Marker, Whitespace),
|
| 775 |
+
'#pop'),
|
| 776 |
+
default('#pop'),
|
| 777 |
+
],
|
| 778 |
+
}
|
| 779 |
+
|
| 780 |
+
|
| 781 |
+
Python3TracebackLexer = PythonTracebackLexer
|
| 782 |
+
|
| 783 |
+
|
| 784 |
+
class Python2TracebackLexer(RegexLexer):
|
| 785 |
+
"""
|
| 786 |
+
For Python tracebacks.
|
| 787 |
+
|
| 788 |
+
.. versionchanged:: 2.5
|
| 789 |
+
This class has been renamed from ``PythonTracebackLexer``.
|
| 790 |
+
``PythonTracebackLexer`` now refers to the Python 3 variant.
|
| 791 |
+
"""
|
| 792 |
+
|
| 793 |
+
name = 'Python 2.x Traceback'
|
| 794 |
+
aliases = ['py2tb']
|
| 795 |
+
filenames = ['*.py2tb']
|
| 796 |
+
mimetypes = ['text/x-python2-traceback']
|
| 797 |
+
url = 'https://python.org'
|
| 798 |
+
version_added = '0.7'
|
| 799 |
+
|
| 800 |
+
tokens = {
|
| 801 |
+
'root': [
|
| 802 |
+
# Cover both (most recent call last) and (innermost last)
|
| 803 |
+
# The optional ^C allows us to catch keyboard interrupt signals.
|
| 804 |
+
(r'^(\^C)?(Traceback.*\n)',
|
| 805 |
+
bygroups(Text, Generic.Traceback), 'intb'),
|
| 806 |
+
# SyntaxError starts with this.
|
| 807 |
+
(r'^(?= File "[^"]+", line \d+)', Generic.Traceback, 'intb'),
|
| 808 |
+
(r'^.*\n', Other),
|
| 809 |
+
],
|
| 810 |
+
'intb': [
|
| 811 |
+
(r'^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)',
|
| 812 |
+
bygroups(Text, Name.Builtin, Text, Number, Text, Name, Whitespace)),
|
| 813 |
+
(r'^( File )("[^"]+")(, line )(\d+)(\n)',
|
| 814 |
+
bygroups(Text, Name.Builtin, Text, Number, Whitespace)),
|
| 815 |
+
(r'^( )(.+)(\n)',
|
| 816 |
+
bygroups(Text, using(Python2Lexer), Whitespace), 'marker'),
|
| 817 |
+
(r'^([ \t]*)(\.\.\.)(\n)',
|
| 818 |
+
bygroups(Text, Comment, Whitespace)), # for doctests...
|
| 819 |
+
(r'^([^:]+)(: )(.+)(\n)',
|
| 820 |
+
bygroups(Generic.Error, Text, Name, Whitespace), '#pop'),
|
| 821 |
+
(r'^([a-zA-Z_]\w*)(:?\n)',
|
| 822 |
+
bygroups(Generic.Error, Whitespace), '#pop')
|
| 823 |
+
],
|
| 824 |
+
'marker': [
|
| 825 |
+
# For syntax errors.
|
| 826 |
+
(r'( {4,})(\^)', bygroups(Text, Punctuation.Marker), '#pop'),
|
| 827 |
+
default('#pop'),
|
| 828 |
+
],
|
| 829 |
+
}
|
| 830 |
+
|
| 831 |
+
|
| 832 |
+
class CythonLexer(RegexLexer):
|
| 833 |
+
"""
|
| 834 |
+
For Pyrex and Cython source code.
|
| 835 |
+
"""
|
| 836 |
+
|
| 837 |
+
name = 'Cython'
|
| 838 |
+
url = 'https://cython.org'
|
| 839 |
+
aliases = ['cython', 'pyx', 'pyrex']
|
| 840 |
+
filenames = ['*.pyx', '*.pxd', '*.pxi']
|
| 841 |
+
mimetypes = ['text/x-cython', 'application/x-cython']
|
| 842 |
+
version_added = '1.1'
|
| 843 |
+
|
| 844 |
+
tokens = {
|
| 845 |
+
'root': [
|
| 846 |
+
(r'\n', Whitespace),
|
| 847 |
+
(r'^(\s*)("""(?:.|\n)*?""")', bygroups(Whitespace, String.Doc)),
|
| 848 |
+
(r"^(\s*)('''(?:.|\n)*?''')", bygroups(Whitespace, String.Doc)),
|
| 849 |
+
(r'[^\S\n]+', Text),
|
| 850 |
+
(r'#.*$', Comment),
|
| 851 |
+
(r'[]{}:(),;[]', Punctuation),
|
| 852 |
+
(r'\\\n', Whitespace),
|
| 853 |
+
(r'\\', Text),
|
| 854 |
+
(r'(in|is|and|or|not)\b', Operator.Word),
|
| 855 |
+
(r'(<)([a-zA-Z0-9.?]+)(>)',
|
| 856 |
+
bygroups(Punctuation, Keyword.Type, Punctuation)),
|
| 857 |
+
(r'!=|==|<<|>>|[-~+/*%=<>&^|.?]', Operator),
|
| 858 |
+
(r'(from)(\d+)(<=)(\s+)(<)(\d+)(:)',
|
| 859 |
+
bygroups(Keyword, Number.Integer, Operator, Whitespace, Operator,
|
| 860 |
+
Name, Punctuation)),
|
| 861 |
+
include('keywords'),
|
| 862 |
+
(r'(def|property)(\s+)', bygroups(Keyword, Whitespace), 'funcname'),
|
| 863 |
+
(r'(cp?def)(\s+)', bygroups(Keyword, Whitespace), 'cdef'),
|
| 864 |
+
# (should actually start a block with only cdefs)
|
| 865 |
+
(r'(cdef)(:)', bygroups(Keyword, Punctuation)),
|
| 866 |
+
(r'(class|cppclass|struct)(\s+)', bygroups(Keyword, Whitespace), 'classname'),
|
| 867 |
+
(r'(from)(\s+)', bygroups(Keyword, Whitespace), 'fromimport'),
|
| 868 |
+
(r'(c?import)(\s+)', bygroups(Keyword, Whitespace), 'import'),
|
| 869 |
+
include('builtins'),
|
| 870 |
+
include('backtick'),
|
| 871 |
+
('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'),
|
| 872 |
+
("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'),
|
| 873 |
+
('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'),
|
| 874 |
+
("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'),
|
| 875 |
+
('[uU]?"""', String, combined('stringescape', 'tdqs')),
|
| 876 |
+
("[uU]?'''", String, combined('stringescape', 'tsqs')),
|
| 877 |
+
('[uU]?"', String, combined('stringescape', 'dqs')),
|
| 878 |
+
("[uU]?'", String, combined('stringescape', 'sqs')),
|
| 879 |
+
include('name'),
|
| 880 |
+
include('numbers'),
|
| 881 |
+
],
|
| 882 |
+
'keywords': [
|
| 883 |
+
(words((
|
| 884 |
+
'assert', 'async', 'await', 'break', 'by', 'continue', 'ctypedef', 'del',
|
| 885 |
+
'elif', 'else', 'except', 'except?', 'exec', 'finally', 'for', 'fused', 'gil',
|
| 886 |
+
'global', 'if', 'include', 'lambda', 'namespace', 'new', 'noexcept','nogil',
|
| 887 |
+
'pass', 'print', 'raise', 'return', 'try', 'while', 'yield', 'as', 'with'),
|
| 888 |
+
suffix=r'\b'),
|
| 889 |
+
Keyword),
|
| 890 |
+
(words(('True', 'False', 'None', 'NULL'), suffix=r'\b'), Keyword.Constant),
|
| 891 |
+
(r'(DEF|IF|ELIF|ELSE)\b', Comment.Preproc),
|
| 892 |
+
],
|
| 893 |
+
'builtins': [
|
| 894 |
+
(words((
|
| 895 |
+
'__import__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bint',
|
| 896 |
+
'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'char', 'chr',
|
| 897 |
+
'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'delattr',
|
| 898 |
+
'dict', 'dir', 'divmod', 'double', 'enumerate', 'eval', 'execfile', 'exit',
|
| 899 |
+
'file', 'filter', 'float', 'frozenset', 'getattr', 'globals',
|
| 900 |
+
'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance',
|
| 901 |
+
'issubclass', 'iter', 'len', 'list', 'locals', 'long', 'map', 'max',
|
| 902 |
+
'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'property',
|
| 903 |
+
'Py_ssize_t', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed',
|
| 904 |
+
'round', 'set', 'setattr', 'size_t', 'slice', 'sorted', 'staticmethod',
|
| 905 |
+
'ssize_t', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode',
|
| 906 |
+
'unsigned', 'vars', 'xrange', 'zip'), prefix=r'(?<!\.)', suffix=r'\b'),
|
| 907 |
+
Name.Builtin),
|
| 908 |
+
(r'(?<!\.)(self|cls|Ellipsis|NotImplemented)\b', Name.Builtin.Pseudo),
|
| 909 |
+
(words((
|
| 910 |
+
'ArithmeticError', 'AssertionError', 'AttributeError',
|
| 911 |
+
'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError',
|
| 912 |
+
'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit',
|
| 913 |
+
'IOError', 'ImportError', 'ImportWarning', 'IndentationError',
|
| 914 |
+
'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError',
|
| 915 |
+
'MemoryError', 'NameError', 'NotImplementedError',
|
| 916 |
+
'OSError', 'OverflowError', 'OverflowWarning',
|
| 917 |
+
'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError',
|
| 918 |
+
'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError',
|
| 919 |
+
'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError',
|
| 920 |
+
'TypeError', 'UnboundLocalError', 'UnicodeDecodeError',
|
| 921 |
+
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
|
| 922 |
+
'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning',
|
| 923 |
+
'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'),
|
| 924 |
+
Name.Exception),
|
| 925 |
+
],
|
| 926 |
+
'numbers': [
|
| 927 |
+
(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
| 928 |
+
(r'0\d+', Number.Oct),
|
| 929 |
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
| 930 |
+
(r'\d+L', Number.Integer.Long),
|
| 931 |
+
(r'\d+', Number.Integer)
|
| 932 |
+
],
|
| 933 |
+
'backtick': [
|
| 934 |
+
('`.*?`', String.Backtick),
|
| 935 |
+
],
|
| 936 |
+
'name': [
|
| 937 |
+
(r'@\w+', Name.Decorator),
|
| 938 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 939 |
+
],
|
| 940 |
+
'funcname': [
|
| 941 |
+
(r'[a-zA-Z_]\w*', Name.Function, '#pop')
|
| 942 |
+
],
|
| 943 |
+
'cdef': [
|
| 944 |
+
(r"(public|readonly|extern|api|inline|packed)\b", Keyword.Reserved),
|
| 945 |
+
(r"(struct|enum|union|class|cppclass)\b(\s+)([a-zA-Z_]\w*)",
|
| 946 |
+
bygroups(Keyword, Whitespace, Name.Class), "#pop",),
|
| 947 |
+
(r"([a-zA-Z_]\w*)(\s*)(?=\()", bygroups(Name.Function, Whitespace), "#pop"),
|
| 948 |
+
(r"([a-zA-Z_]\w*)(\s*)(?=[:,=#\n]|$)", bygroups(Name.Variable, Whitespace), "#pop"),
|
| 949 |
+
(r"([a-zA-Z_]\w*)(\s*)(,)", bygroups(Name.Variable, Whitespace, Punctuation)),
|
| 950 |
+
(r'from\b', Keyword, '#pop'),
|
| 951 |
+
(r'as\b', Keyword),
|
| 952 |
+
(r':', Punctuation, '#pop'),
|
| 953 |
+
(r'(?=["\'])', Text, '#pop'),
|
| 954 |
+
(r'[a-zA-Z_]\w*', Keyword.Type),
|
| 955 |
+
(r'.', Text),
|
| 956 |
+
],
|
| 957 |
+
'classname': [
|
| 958 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
|
| 959 |
+
],
|
| 960 |
+
'import': [
|
| 961 |
+
(r'(\s+)(as)(\s+)', bygroups(Whitespace, Keyword, Whitespace)),
|
| 962 |
+
(r'[a-zA-Z_][\w.]*', Name.Namespace),
|
| 963 |
+
(r'(\s*)(,)(\s*)', bygroups(Whitespace, Operator, Whitespace)),
|
| 964 |
+
default('#pop') # all else: go back
|
| 965 |
+
],
|
| 966 |
+
'fromimport': [
|
| 967 |
+
(r'(\s+)(c?import)\b', bygroups(Whitespace, Keyword), '#pop'),
|
| 968 |
+
(r'[a-zA-Z_.][\w.]*', Name.Namespace),
|
| 969 |
+
# ``cdef foo from "header"``, or ``for foo from 0 < i < 10``
|
| 970 |
+
default('#pop'),
|
| 971 |
+
],
|
| 972 |
+
'stringescape': [
|
| 973 |
+
(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
|
| 974 |
+
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
| 975 |
+
],
|
| 976 |
+
'strings': [
|
| 977 |
+
(r'%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
| 978 |
+
'[hlL]?[E-GXc-giorsux%]', String.Interpol),
|
| 979 |
+
(r'[^\\\'"%\n]+', String),
|
| 980 |
+
# quotes, percents and backslashes must be parsed one at a time
|
| 981 |
+
(r'[\'"\\]', String),
|
| 982 |
+
# unhandled string formatting sign
|
| 983 |
+
(r'%', String)
|
| 984 |
+
# newlines are an error (use "nl" state)
|
| 985 |
+
],
|
| 986 |
+
'nl': [
|
| 987 |
+
(r'\n', String)
|
| 988 |
+
],
|
| 989 |
+
'dqs': [
|
| 990 |
+
(r'"', String, '#pop'),
|
| 991 |
+
(r'\\\\|\\"|\\\n', String.Escape), # included here again for raw strings
|
| 992 |
+
include('strings')
|
| 993 |
+
],
|
| 994 |
+
'sqs': [
|
| 995 |
+
(r"'", String, '#pop'),
|
| 996 |
+
(r"\\\\|\\'|\\\n", String.Escape), # included here again for raw strings
|
| 997 |
+
include('strings')
|
| 998 |
+
],
|
| 999 |
+
'tdqs': [
|
| 1000 |
+
(r'"""', String, '#pop'),
|
| 1001 |
+
include('strings'),
|
| 1002 |
+
include('nl')
|
| 1003 |
+
],
|
| 1004 |
+
'tsqs': [
|
| 1005 |
+
(r"'''", String, '#pop'),
|
| 1006 |
+
include('strings'),
|
| 1007 |
+
include('nl')
|
| 1008 |
+
],
|
| 1009 |
+
}
|
| 1010 |
+
|
| 1011 |
+
|
| 1012 |
+
class DgLexer(RegexLexer):
|
| 1013 |
+
"""
|
| 1014 |
+
Lexer for dg,
|
| 1015 |
+
a functional and object-oriented programming language
|
| 1016 |
+
running on the CPython 3 VM.
|
| 1017 |
+
"""
|
| 1018 |
+
name = 'dg'
|
| 1019 |
+
aliases = ['dg']
|
| 1020 |
+
filenames = ['*.dg']
|
| 1021 |
+
mimetypes = ['text/x-dg']
|
| 1022 |
+
url = 'http://pyos.github.io/dg'
|
| 1023 |
+
version_added = '1.6'
|
| 1024 |
+
|
| 1025 |
+
tokens = {
|
| 1026 |
+
'root': [
|
| 1027 |
+
(r'\s+', Text),
|
| 1028 |
+
(r'#.*?$', Comment.Single),
|
| 1029 |
+
|
| 1030 |
+
(r'(?i)0b[01]+', Number.Bin),
|
| 1031 |
+
(r'(?i)0o[0-7]+', Number.Oct),
|
| 1032 |
+
(r'(?i)0x[0-9a-f]+', Number.Hex),
|
| 1033 |
+
(r'(?i)[+-]?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?j?', Number.Float),
|
| 1034 |
+
(r'(?i)[+-]?[0-9]+e[+-]?\d+j?', Number.Float),
|
| 1035 |
+
(r'(?i)[+-]?[0-9]+j?', Number.Integer),
|
| 1036 |
+
|
| 1037 |
+
(r"(?i)(br|r?b?)'''", String, combined('stringescape', 'tsqs', 'string')),
|
| 1038 |
+
(r'(?i)(br|r?b?)"""', String, combined('stringescape', 'tdqs', 'string')),
|
| 1039 |
+
(r"(?i)(br|r?b?)'", String, combined('stringescape', 'sqs', 'string')),
|
| 1040 |
+
(r'(?i)(br|r?b?)"', String, combined('stringescape', 'dqs', 'string')),
|
| 1041 |
+
|
| 1042 |
+
(r"`\w+'*`", Operator),
|
| 1043 |
+
(r'\b(and|in|is|or|where)\b', Operator.Word),
|
| 1044 |
+
(r'[!$%&*+\-./:<-@\\^|~;,]+', Operator),
|
| 1045 |
+
|
| 1046 |
+
(words((
|
| 1047 |
+
'bool', 'bytearray', 'bytes', 'classmethod', 'complex', 'dict', 'dict\'',
|
| 1048 |
+
'float', 'frozenset', 'int', 'list', 'list\'', 'memoryview', 'object',
|
| 1049 |
+
'property', 'range', 'set', 'set\'', 'slice', 'staticmethod', 'str',
|
| 1050 |
+
'super', 'tuple', 'tuple\'', 'type'),
|
| 1051 |
+
prefix=r'(?<!\.)', suffix=r'(?![\'\w])'),
|
| 1052 |
+
Name.Builtin),
|
| 1053 |
+
(words((
|
| 1054 |
+
'__import__', 'abs', 'all', 'any', 'bin', 'bind', 'chr', 'cmp', 'compile',
|
| 1055 |
+
'complex', 'delattr', 'dir', 'divmod', 'drop', 'dropwhile', 'enumerate',
|
| 1056 |
+
'eval', 'exhaust', 'filter', 'flip', 'foldl1?', 'format', 'fst',
|
| 1057 |
+
'getattr', 'globals', 'hasattr', 'hash', 'head', 'hex', 'id', 'init',
|
| 1058 |
+
'input', 'isinstance', 'issubclass', 'iter', 'iterate', 'last', 'len',
|
| 1059 |
+
'locals', 'map', 'max', 'min', 'next', 'oct', 'open', 'ord', 'pow',
|
| 1060 |
+
'print', 'repr', 'reversed', 'round', 'setattr', 'scanl1?', 'snd',
|
| 1061 |
+
'sorted', 'sum', 'tail', 'take', 'takewhile', 'vars', 'zip'),
|
| 1062 |
+
prefix=r'(?<!\.)', suffix=r'(?![\'\w])'),
|
| 1063 |
+
Name.Builtin),
|
| 1064 |
+
(r"(?<!\.)(self|Ellipsis|NotImplemented|None|True|False)(?!['\w])",
|
| 1065 |
+
Name.Builtin.Pseudo),
|
| 1066 |
+
|
| 1067 |
+
(r"(?<!\.)[A-Z]\w*(Error|Exception|Warning)'*(?!['\w])",
|
| 1068 |
+
Name.Exception),
|
| 1069 |
+
(r"(?<!\.)(Exception|GeneratorExit|KeyboardInterrupt|StopIteration|"
|
| 1070 |
+
r"SystemExit)(?!['\w])", Name.Exception),
|
| 1071 |
+
|
| 1072 |
+
(r"(?<![\w.])(except|finally|for|if|import|not|otherwise|raise|"
|
| 1073 |
+
r"subclass|while|with|yield)(?!['\w])", Keyword.Reserved),
|
| 1074 |
+
|
| 1075 |
+
(r"[A-Z_]+'*(?!['\w])", Name),
|
| 1076 |
+
(r"[A-Z]\w+'*(?!['\w])", Keyword.Type),
|
| 1077 |
+
(r"\w+'*", Name),
|
| 1078 |
+
|
| 1079 |
+
(r'[()]', Punctuation),
|
| 1080 |
+
(r'.', Error),
|
| 1081 |
+
],
|
| 1082 |
+
'stringescape': [
|
| 1083 |
+
(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
|
| 1084 |
+
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
| 1085 |
+
],
|
| 1086 |
+
'string': [
|
| 1087 |
+
(r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
|
| 1088 |
+
'[hlL]?[E-GXc-giorsux%]', String.Interpol),
|
| 1089 |
+
(r'[^\\\'"%\n]+', String),
|
| 1090 |
+
# quotes, percents and backslashes must be parsed one at a time
|
| 1091 |
+
(r'[\'"\\]', String),
|
| 1092 |
+
# unhandled string formatting sign
|
| 1093 |
+
(r'%', String),
|
| 1094 |
+
(r'\n', String)
|
| 1095 |
+
],
|
| 1096 |
+
'dqs': [
|
| 1097 |
+
(r'"', String, '#pop')
|
| 1098 |
+
],
|
| 1099 |
+
'sqs': [
|
| 1100 |
+
(r"'", String, '#pop')
|
| 1101 |
+
],
|
| 1102 |
+
'tdqs': [
|
| 1103 |
+
(r'"""', String, '#pop')
|
| 1104 |
+
],
|
| 1105 |
+
'tsqs': [
|
| 1106 |
+
(r"'''", String, '#pop')
|
| 1107 |
+
],
|
| 1108 |
+
}
|
| 1109 |
+
|
| 1110 |
+
|
| 1111 |
+
class NumPyLexer(PythonLexer):
|
| 1112 |
+
"""
|
| 1113 |
+
A Python lexer recognizing Numerical Python builtins.
|
| 1114 |
+
"""
|
| 1115 |
+
|
| 1116 |
+
name = 'NumPy'
|
| 1117 |
+
url = 'https://numpy.org/'
|
| 1118 |
+
aliases = ['numpy']
|
| 1119 |
+
version_added = '0.10'
|
| 1120 |
+
|
| 1121 |
+
# override the mimetypes to not inherit them from python
|
| 1122 |
+
mimetypes = []
|
| 1123 |
+
filenames = []
|
| 1124 |
+
|
| 1125 |
+
EXTRA_KEYWORDS = {
|
| 1126 |
+
'abs', 'absolute', 'accumulate', 'add', 'alen', 'all', 'allclose',
|
| 1127 |
+
'alltrue', 'alterdot', 'amax', 'amin', 'angle', 'any', 'append',
|
| 1128 |
+
'apply_along_axis', 'apply_over_axes', 'arange', 'arccos', 'arccosh',
|
| 1129 |
+
'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'argmax', 'argmin',
|
| 1130 |
+
'argsort', 'argwhere', 'around', 'array', 'array2string', 'array_equal',
|
| 1131 |
+
'array_equiv', 'array_repr', 'array_split', 'array_str', 'arrayrange',
|
| 1132 |
+
'asanyarray', 'asarray', 'asarray_chkfinite', 'ascontiguousarray',
|
| 1133 |
+
'asfarray', 'asfortranarray', 'asmatrix', 'asscalar', 'astype',
|
| 1134 |
+
'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', 'bartlett',
|
| 1135 |
+
'base_repr', 'beta', 'binary_repr', 'bincount', 'binomial',
|
| 1136 |
+
'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blackman',
|
| 1137 |
+
'bmat', 'broadcast', 'byte_bounds', 'bytes', 'byteswap', 'c_',
|
| 1138 |
+
'can_cast', 'ceil', 'choose', 'clip', 'column_stack', 'common_type',
|
| 1139 |
+
'compare_chararrays', 'compress', 'concatenate', 'conj', 'conjugate',
|
| 1140 |
+
'convolve', 'copy', 'corrcoef', 'correlate', 'cos', 'cosh', 'cov',
|
| 1141 |
+
'cross', 'cumprod', 'cumproduct', 'cumsum', 'delete', 'deprecate',
|
| 1142 |
+
'diag', 'diagflat', 'diagonal', 'diff', 'digitize', 'disp', 'divide',
|
| 1143 |
+
'dot', 'dsplit', 'dstack', 'dtype', 'dump', 'dumps', 'ediff1d', 'empty',
|
| 1144 |
+
'empty_like', 'equal', 'exp', 'expand_dims', 'expm1', 'extract', 'eye',
|
| 1145 |
+
'fabs', 'fastCopyAndTranspose', 'fft', 'fftfreq', 'fftshift', 'fill',
|
| 1146 |
+
'finfo', 'fix', 'flat', 'flatnonzero', 'flatten', 'fliplr', 'flipud',
|
| 1147 |
+
'floor', 'floor_divide', 'fmod', 'frexp', 'fromarrays', 'frombuffer',
|
| 1148 |
+
'fromfile', 'fromfunction', 'fromiter', 'frompyfunc', 'fromstring',
|
| 1149 |
+
'generic', 'get_array_wrap', 'get_include', 'get_numarray_include',
|
| 1150 |
+
'get_numpy_include', 'get_printoptions', 'getbuffer', 'getbufsize',
|
| 1151 |
+
'geterr', 'geterrcall', 'geterrobj', 'getfield', 'gradient', 'greater',
|
| 1152 |
+
'greater_equal', 'gumbel', 'hamming', 'hanning', 'histogram',
|
| 1153 |
+
'histogram2d', 'histogramdd', 'hsplit', 'hstack', 'hypot', 'i0',
|
| 1154 |
+
'identity', 'ifft', 'imag', 'index_exp', 'indices', 'inf', 'info',
|
| 1155 |
+
'inner', 'insert', 'int_asbuffer', 'interp', 'intersect1d',
|
| 1156 |
+
'intersect1d_nu', 'inv', 'invert', 'iscomplex', 'iscomplexobj',
|
| 1157 |
+
'isfinite', 'isfortran', 'isinf', 'isnan', 'isneginf', 'isposinf',
|
| 1158 |
+
'isreal', 'isrealobj', 'isscalar', 'issctype', 'issubclass_',
|
| 1159 |
+
'issubdtype', 'issubsctype', 'item', 'itemset', 'iterable', 'ix_',
|
| 1160 |
+
'kaiser', 'kron', 'ldexp', 'left_shift', 'less', 'less_equal', 'lexsort',
|
| 1161 |
+
'linspace', 'load', 'loads', 'loadtxt', 'log', 'log10', 'log1p', 'log2',
|
| 1162 |
+
'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logspace',
|
| 1163 |
+
'lstsq', 'mat', 'matrix', 'max', 'maximum', 'maximum_sctype',
|
| 1164 |
+
'may_share_memory', 'mean', 'median', 'meshgrid', 'mgrid', 'min',
|
| 1165 |
+
'minimum', 'mintypecode', 'mod', 'modf', 'msort', 'multiply', 'nan',
|
| 1166 |
+
'nan_to_num', 'nanargmax', 'nanargmin', 'nanmax', 'nanmin', 'nansum',
|
| 1167 |
+
'ndenumerate', 'ndim', 'ndindex', 'negative', 'newaxis', 'newbuffer',
|
| 1168 |
+
'newbyteorder', 'nonzero', 'not_equal', 'obj2sctype', 'ogrid', 'ones',
|
| 1169 |
+
'ones_like', 'outer', 'permutation', 'piecewise', 'pinv', 'pkgload',
|
| 1170 |
+
'place', 'poisson', 'poly', 'poly1d', 'polyadd', 'polyder', 'polydiv',
|
| 1171 |
+
'polyfit', 'polyint', 'polymul', 'polysub', 'polyval', 'power', 'prod',
|
| 1172 |
+
'product', 'ptp', 'put', 'putmask', 'r_', 'randint', 'random_integers',
|
| 1173 |
+
'random_sample', 'ranf', 'rank', 'ravel', 'real', 'real_if_close',
|
| 1174 |
+
'recarray', 'reciprocal', 'reduce', 'remainder', 'repeat', 'require',
|
| 1175 |
+
'reshape', 'resize', 'restoredot', 'right_shift', 'rint', 'roll',
|
| 1176 |
+
'rollaxis', 'roots', 'rot90', 'round', 'round_', 'row_stack', 's_',
|
| 1177 |
+
'sample', 'savetxt', 'sctype2char', 'searchsorted', 'seed', 'select',
|
| 1178 |
+
'set_numeric_ops', 'set_printoptions', 'set_string_function',
|
| 1179 |
+
'setbufsize', 'setdiff1d', 'seterr', 'seterrcall', 'seterrobj',
|
| 1180 |
+
'setfield', 'setflags', 'setmember1d', 'setxor1d', 'shape',
|
| 1181 |
+
'show_config', 'shuffle', 'sign', 'signbit', 'sin', 'sinc', 'sinh',
|
| 1182 |
+
'size', 'slice', 'solve', 'sometrue', 'sort', 'sort_complex', 'source',
|
| 1183 |
+
'split', 'sqrt', 'square', 'squeeze', 'standard_normal', 'std',
|
| 1184 |
+
'subtract', 'sum', 'svd', 'swapaxes', 'take', 'tan', 'tanh', 'tensordot',
|
| 1185 |
+
'test', 'tile', 'tofile', 'tolist', 'tostring', 'trace', 'transpose',
|
| 1186 |
+
'trapz', 'tri', 'tril', 'trim_zeros', 'triu', 'true_divide', 'typeDict',
|
| 1187 |
+
'typename', 'uniform', 'union1d', 'unique', 'unique1d', 'unravel_index',
|
| 1188 |
+
'unwrap', 'vander', 'var', 'vdot', 'vectorize', 'view', 'vonmises',
|
| 1189 |
+
'vsplit', 'vstack', 'weibull', 'where', 'who', 'zeros', 'zeros_like'
|
| 1190 |
+
}
|
| 1191 |
+
|
| 1192 |
+
def get_tokens_unprocessed(self, text):
|
| 1193 |
+
for index, token, value in \
|
| 1194 |
+
PythonLexer.get_tokens_unprocessed(self, text):
|
| 1195 |
+
if token is Name and value in self.EXTRA_KEYWORDS:
|
| 1196 |
+
yield index, Keyword.Pseudo, value
|
| 1197 |
+
else:
|
| 1198 |
+
yield index, token, value
|
| 1199 |
+
|
| 1200 |
+
def analyse_text(text):
|
| 1201 |
+
ltext = text[:1000]
|
| 1202 |
+
return (shebang_matches(text, r'pythonw?(3(\.\d)?)?') or
|
| 1203 |
+
'import ' in ltext) \
|
| 1204 |
+
and ('import numpy' in ltext or 'from numpy import' in ltext)
|
.cache/uv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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.q
|
| 3 |
+
~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Q programming language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words, include, bygroups, inherit
|
| 12 |
+
from pygments.token import Comment, Name, Number, Operator, Punctuation, \
|
| 13 |
+
String, Whitespace, Literal, Generic
|
| 14 |
+
|
| 15 |
+
__all__ = ["KLexer", "QLexer"]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class KLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For K source code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = "K"
|
| 24 |
+
aliases = ["k"]
|
| 25 |
+
filenames = ["*.k"]
|
| 26 |
+
url = "https://code.kx.com"
|
| 27 |
+
version_added = '2.12'
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
"whitespace": [
|
| 31 |
+
# hashbang script
|
| 32 |
+
(r"^#!.*", Comment.Hashbang),
|
| 33 |
+
# Comments
|
| 34 |
+
(r"^/\s*\n", Comment.Multiline, "comments"),
|
| 35 |
+
(r"(?<!\S)/.*", Comment.Single),
|
| 36 |
+
# Whitespace
|
| 37 |
+
(r"\s+", Whitespace),
|
| 38 |
+
# Strings
|
| 39 |
+
(r"\"", String.Double, "strings"),
|
| 40 |
+
],
|
| 41 |
+
"root": [
|
| 42 |
+
include("whitespace"),
|
| 43 |
+
include("keywords"),
|
| 44 |
+
include("declarations"),
|
| 45 |
+
],
|
| 46 |
+
"keywords": [
|
| 47 |
+
(words(("abs", "acos", "asin", "atan", "avg", "bin",
|
| 48 |
+
"binr", "by", "cor", "cos", "cov", "dev",
|
| 49 |
+
"delete", "div", "do", "enlist", "exec", "exit",
|
| 50 |
+
"exp", "from", "getenv", "hopen", "if", "in",
|
| 51 |
+
"insert", "last", "like", "log", "max", "min",
|
| 52 |
+
"prd", "select", "setenv", "sin", "sqrt", "ss",
|
| 53 |
+
"sum", "tan", "update", "var", "wavg", "while",
|
| 54 |
+
"within", "wsum", "xexp"),
|
| 55 |
+
suffix=r"\b"), Operator.Word),
|
| 56 |
+
],
|
| 57 |
+
"declarations": [
|
| 58 |
+
# Timing
|
| 59 |
+
(r"^\\ts?", Comment.Preproc),
|
| 60 |
+
(r"^(\\\w\s+[^/\n]*?)(/.*)",
|
| 61 |
+
bygroups(Comment.Preproc, Comment.Single)),
|
| 62 |
+
# Generic System Commands
|
| 63 |
+
(r"^\\\w.*", Comment.Preproc),
|
| 64 |
+
# Prompt
|
| 65 |
+
(r"^[a-zA-Z]\)", Generic.Prompt),
|
| 66 |
+
# Function Names
|
| 67 |
+
(r"([.]?[a-zA-Z][\w.]*)(\s*)([-.~=!@#$%^&*_+|,<>?/\\:']?:)(\s*)(\{)",
|
| 68 |
+
bygroups(Name.Function, Whitespace, Operator, Whitespace, Punctuation),
|
| 69 |
+
"functions"),
|
| 70 |
+
# Variable Names
|
| 71 |
+
(r"([.]?[a-zA-Z][\w.]*)(\s*)([-.~=!@#$%^&*_+|,<>?/\\:']?:)",
|
| 72 |
+
bygroups(Name.Variable, Whitespace, Operator)),
|
| 73 |
+
# Functions
|
| 74 |
+
(r"\{", Punctuation, "functions"),
|
| 75 |
+
# Parentheses
|
| 76 |
+
(r"\(", Punctuation, "parentheses"),
|
| 77 |
+
# Brackets
|
| 78 |
+
(r"\[", Punctuation, "brackets"),
|
| 79 |
+
# Errors
|
| 80 |
+
(r"'`([a-zA-Z][\w.]*)?", Name.Exception),
|
| 81 |
+
# File Symbols
|
| 82 |
+
(r"`:([a-zA-Z/][\w./]*)?", String.Symbol),
|
| 83 |
+
# Symbols
|
| 84 |
+
(r"`([a-zA-Z][\w.]*)?", String.Symbol),
|
| 85 |
+
# Numbers
|
| 86 |
+
include("numbers"),
|
| 87 |
+
# Variable Names
|
| 88 |
+
(r"[a-zA-Z][\w.]*", Name),
|
| 89 |
+
# Operators
|
| 90 |
+
(r"[-=+*#$%@!~^&:.,<>'\\|/?_]", Operator),
|
| 91 |
+
# Punctuation
|
| 92 |
+
(r";", Punctuation),
|
| 93 |
+
],
|
| 94 |
+
"functions": [
|
| 95 |
+
include("root"),
|
| 96 |
+
(r"\}", Punctuation, "#pop"),
|
| 97 |
+
],
|
| 98 |
+
"parentheses": [
|
| 99 |
+
include("root"),
|
| 100 |
+
(r"\)", Punctuation, "#pop"),
|
| 101 |
+
],
|
| 102 |
+
"brackets": [
|
| 103 |
+
include("root"),
|
| 104 |
+
(r"\]", Punctuation, "#pop"),
|
| 105 |
+
],
|
| 106 |
+
"numbers": [
|
| 107 |
+
# Binary Values
|
| 108 |
+
(r"[01]+b", Number.Bin),
|
| 109 |
+
# Nulls/Infinities
|
| 110 |
+
(r"0[nNwW][cefghijmndzuvtp]?", Number),
|
| 111 |
+
# Timestamps
|
| 112 |
+
((r"(?:[0-9]{4}[.][0-9]{2}[.][0-9]{2}|[0-9]+)"
|
| 113 |
+
"D(?:[0-9](?:[0-9](?::[0-9]{2}"
|
| 114 |
+
"(?::[0-9]{2}(?:[.][0-9]*)?)?)?)?)?"), Literal.Date),
|
| 115 |
+
# Datetimes
|
| 116 |
+
((r"[0-9]{4}[.][0-9]{2}"
|
| 117 |
+
"(?:m|[.][0-9]{2}(?:T(?:[0-9]{2}:[0-9]{2}"
|
| 118 |
+
"(?::[0-9]{2}(?:[.][0-9]*)?)?)?)?)"), Literal.Date),
|
| 119 |
+
# Times
|
| 120 |
+
(r"[0-9]{2}:[0-9]{2}(?::[0-9]{2}(?:[.][0-9]{1,3})?)?",
|
| 121 |
+
Literal.Date),
|
| 122 |
+
# GUIDs
|
| 123 |
+
(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",
|
| 124 |
+
Number.Hex),
|
| 125 |
+
# Byte Vectors
|
| 126 |
+
(r"0x[0-9a-fA-F]+", Number.Hex),
|
| 127 |
+
# Floats
|
| 128 |
+
(r"([0-9]*[.]?[0-9]+|[0-9]+[.]?[0-9]*)[eE][+-]?[0-9]+[ef]?",
|
| 129 |
+
Number.Float),
|
| 130 |
+
(r"([0-9]*[.][0-9]+|[0-9]+[.][0-9]*)[ef]?", Number.Float),
|
| 131 |
+
(r"[0-9]+[ef]", Number.Float),
|
| 132 |
+
# Characters
|
| 133 |
+
(r"[0-9]+c", Number),
|
| 134 |
+
# Integers
|
| 135 |
+
(r"[0-9]+[ihtuv]", Number.Integer),
|
| 136 |
+
# Long Integers
|
| 137 |
+
(r"[0-9]+[jnp]?", Number.Integer.Long),
|
| 138 |
+
],
|
| 139 |
+
"comments": [
|
| 140 |
+
(r"[^\\]+", Comment.Multiline),
|
| 141 |
+
(r"^\\", Comment.Multiline, "#pop"),
|
| 142 |
+
(r"\\", Comment.Multiline),
|
| 143 |
+
],
|
| 144 |
+
"strings": [
|
| 145 |
+
(r'[^"\\]+', String.Double),
|
| 146 |
+
(r"\\.", String.Escape),
|
| 147 |
+
(r'"', String.Double, "#pop"),
|
| 148 |
+
],
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
class QLexer(KLexer):
|
| 153 |
+
"""
|
| 154 |
+
For `Q <https://code.kx.com/>`_ source code.
|
| 155 |
+
"""
|
| 156 |
+
|
| 157 |
+
name = "Q"
|
| 158 |
+
aliases = ["q"]
|
| 159 |
+
filenames = ["*.q"]
|
| 160 |
+
version_added = '2.12'
|
| 161 |
+
|
| 162 |
+
tokens = {
|
| 163 |
+
"root": [
|
| 164 |
+
(words(("aj", "aj0", "ajf", "ajf0", "all", "and", "any", "asc",
|
| 165 |
+
"asof", "attr", "avgs", "ceiling", "cols", "count", "cross",
|
| 166 |
+
"csv", "cut", "deltas", "desc", "differ", "distinct", "dsave",
|
| 167 |
+
"each", "ej", "ema", "eval", "except", "fby", "fills", "first",
|
| 168 |
+
"fkeys", "flip", "floor", "get", "group", "gtime", "hclose",
|
| 169 |
+
"hcount", "hdel", "hsym", "iasc", "idesc", "ij", "ijf",
|
| 170 |
+
"inter", "inv", "key", "keys", "lj", "ljf", "load", "lower",
|
| 171 |
+
"lsq", "ltime", "ltrim", "mavg", "maxs", "mcount", "md5",
|
| 172 |
+
"mdev", "med", "meta", "mins", "mmax", "mmin", "mmu", "mod",
|
| 173 |
+
"msum", "neg", "next", "not", "null", "or", "over", "parse",
|
| 174 |
+
"peach", "pj", "prds", "prior", "prev", "rand", "rank", "ratios",
|
| 175 |
+
"raze", "read0", "read1", "reciprocal", "reval", "reverse",
|
| 176 |
+
"rload", "rotate", "rsave", "rtrim", "save", "scan", "scov",
|
| 177 |
+
"sdev", "set", "show", "signum", "ssr", "string", "sublist",
|
| 178 |
+
"sums", "sv", "svar", "system", "tables", "til", "trim", "txf",
|
| 179 |
+
"type", "uj", "ujf", "ungroup", "union", "upper", "upsert",
|
| 180 |
+
"value", "view", "views", "vs", "where", "wj", "wj1", "ww",
|
| 181 |
+
"xasc", "xbar", "xcol", "xcols", "xdesc", "xgroup", "xkey",
|
| 182 |
+
"xlog", "xprev", "xrank"),
|
| 183 |
+
suffix=r"\b"), Name.Builtin,
|
| 184 |
+
),
|
| 185 |
+
inherit,
|
| 186 |
+
],
|
| 187 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/qlik.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.qlik
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the qlik scripting language
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, words
|
| 14 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 15 |
+
Punctuation, String, Text
|
| 16 |
+
from pygments.lexers._qlik_builtins import OPERATORS_LIST, STATEMENT_LIST, \
|
| 17 |
+
SCRIPT_FUNCTIONS, CONSTANT_LIST
|
| 18 |
+
|
| 19 |
+
__all__ = ["QlikLexer"]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class QlikLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
Lexer for qlik code, including .qvs files
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = "Qlik"
|
| 28 |
+
aliases = ["qlik", "qlikview", "qliksense", "qlikscript"]
|
| 29 |
+
filenames = ["*.qvs", "*.qvw"]
|
| 30 |
+
url = "https://qlik.com"
|
| 31 |
+
version_added = '2.12'
|
| 32 |
+
|
| 33 |
+
flags = re.IGNORECASE
|
| 34 |
+
|
| 35 |
+
tokens = {
|
| 36 |
+
# Handle multi-line comments
|
| 37 |
+
"comment": [
|
| 38 |
+
(r"\*/", Comment.Multiline, "#pop"),
|
| 39 |
+
(r"[^*]+", Comment.Multiline),
|
| 40 |
+
],
|
| 41 |
+
# Handle numbers
|
| 42 |
+
"numerics": [
|
| 43 |
+
(r"\b\d+\.\d+(e\d+)?[fd]?\b", Number.Float),
|
| 44 |
+
(r"\b\d+\b", Number.Integer),
|
| 45 |
+
],
|
| 46 |
+
# Handle variable names in things
|
| 47 |
+
"interp": [
|
| 48 |
+
(
|
| 49 |
+
r"(\$\()(\w+)(\))",
|
| 50 |
+
bygroups(String.Interpol, Name.Variable, String.Interpol),
|
| 51 |
+
),
|
| 52 |
+
],
|
| 53 |
+
# Handle strings
|
| 54 |
+
"string": [
|
| 55 |
+
(r"'", String, "#pop"),
|
| 56 |
+
include("interp"),
|
| 57 |
+
(r"[^'$]+", String),
|
| 58 |
+
(r"\$", String),
|
| 59 |
+
],
|
| 60 |
+
#
|
| 61 |
+
"assignment": [
|
| 62 |
+
(r";", Punctuation, "#pop"),
|
| 63 |
+
include("root"),
|
| 64 |
+
],
|
| 65 |
+
"field_name_quote": [
|
| 66 |
+
(r'"', String.Symbol, "#pop"),
|
| 67 |
+
include("interp"),
|
| 68 |
+
(r"[^\"$]+", String.Symbol),
|
| 69 |
+
(r"\$", String.Symbol),
|
| 70 |
+
],
|
| 71 |
+
"field_name_bracket": [
|
| 72 |
+
(r"\]", String.Symbol, "#pop"),
|
| 73 |
+
include("interp"),
|
| 74 |
+
(r"[^\]$]+", String.Symbol),
|
| 75 |
+
(r"\$", String.Symbol),
|
| 76 |
+
],
|
| 77 |
+
"function": [(r"\)", Punctuation, "#pop"), include("root")],
|
| 78 |
+
"root": [
|
| 79 |
+
# Whitespace and comments
|
| 80 |
+
(r"\s+", Text.Whitespace),
|
| 81 |
+
(r"/\*", Comment.Multiline, "comment"),
|
| 82 |
+
(r"//.*\n", Comment.Single),
|
| 83 |
+
# variable assignment
|
| 84 |
+
(r"(let|set)(\s+)", bygroups(Keyword.Declaration, Text.Whitespace),
|
| 85 |
+
"assignment"),
|
| 86 |
+
# Word operators
|
| 87 |
+
(words(OPERATORS_LIST["words"], prefix=r"\b", suffix=r"\b"),
|
| 88 |
+
Operator.Word),
|
| 89 |
+
# Statements
|
| 90 |
+
(words(STATEMENT_LIST, suffix=r"\b"), Keyword),
|
| 91 |
+
# Table names
|
| 92 |
+
(r"[a-z]\w*:", Keyword.Declaration),
|
| 93 |
+
# Constants
|
| 94 |
+
(words(CONSTANT_LIST, suffix=r"\b"), Keyword.Constant),
|
| 95 |
+
# Functions
|
| 96 |
+
(words(SCRIPT_FUNCTIONS, suffix=r"(?=\s*\()"), Name.Builtin,
|
| 97 |
+
"function"),
|
| 98 |
+
# interpolation - e.g. $(variableName)
|
| 99 |
+
include("interp"),
|
| 100 |
+
# Quotes denote a field/file name
|
| 101 |
+
(r'"', String.Symbol, "field_name_quote"),
|
| 102 |
+
# Square brackets denote a field/file name
|
| 103 |
+
(r"\[", String.Symbol, "field_name_bracket"),
|
| 104 |
+
# Strings
|
| 105 |
+
(r"'", String, "string"),
|
| 106 |
+
# Numbers
|
| 107 |
+
include("numerics"),
|
| 108 |
+
# Operator symbols
|
| 109 |
+
(words(OPERATORS_LIST["symbols"]), Operator),
|
| 110 |
+
# Strings denoted by single quotes
|
| 111 |
+
(r"'.+?'", String),
|
| 112 |
+
# Words as text
|
| 113 |
+
(r"\b\w+\b", Text),
|
| 114 |
+
# Basic punctuation
|
| 115 |
+
(r"[,;.()\\/]", Punctuation),
|
| 116 |
+
],
|
| 117 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/qvt.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.qvt
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for QVT Operational language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, include, combined, default, \
|
| 12 |
+
words
|
| 13 |
+
from pygments.token import Text, Comment, Operator, Keyword, Punctuation, \
|
| 14 |
+
Name, String, Number
|
| 15 |
+
|
| 16 |
+
__all__ = ['QVToLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class QVToLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
For the QVT Operational Mapping language.
|
| 22 |
+
|
| 23 |
+
Reference for implementing this: «Meta Object Facility (MOF) 2.0
|
| 24 |
+
Query/View/Transformation Specification», Version 1.1 - January 2011
|
| 25 |
+
(https://www.omg.org/spec/QVT/1.1/), see §8.4, «Concrete Syntax» in
|
| 26 |
+
particular.
|
| 27 |
+
|
| 28 |
+
Notable tokens assignments:
|
| 29 |
+
|
| 30 |
+
- Name.Class is assigned to the identifier following any of the following
|
| 31 |
+
keywords: metamodel, class, exception, primitive, enum, transformation
|
| 32 |
+
or library
|
| 33 |
+
|
| 34 |
+
- Name.Function is assigned to the names of mappings and queries
|
| 35 |
+
|
| 36 |
+
- Name.Builtin.Pseudo is assigned to the pre-defined variables 'this',
|
| 37 |
+
'self' and 'result'.
|
| 38 |
+
"""
|
| 39 |
+
# With obvious borrowings & inspiration from the Java, Python and C lexers
|
| 40 |
+
|
| 41 |
+
name = 'QVTO'
|
| 42 |
+
aliases = ['qvto', 'qvt']
|
| 43 |
+
filenames = ['*.qvto']
|
| 44 |
+
url = 'https://www.omg.org/spec/QVT/1.1'
|
| 45 |
+
version_added = ''
|
| 46 |
+
|
| 47 |
+
tokens = {
|
| 48 |
+
'root': [
|
| 49 |
+
(r'\n', Text),
|
| 50 |
+
(r'[^\S\n]+', Text),
|
| 51 |
+
(r'(--|//)(\s*)(directive:)?(.*)$',
|
| 52 |
+
bygroups(Comment, Comment, Comment.Preproc, Comment)),
|
| 53 |
+
# Uncomment the following if you want to distinguish between
|
| 54 |
+
# '/*' and '/**', à la javadoc
|
| 55 |
+
# (r'/[*]{2}(.|\n)*?[*]/', Comment.Multiline),
|
| 56 |
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
| 57 |
+
(r'\\\n', Text),
|
| 58 |
+
(r'(and|not|or|xor|##?)\b', Operator.Word),
|
| 59 |
+
(r'(:{1,2}=|[-+]=)\b', Operator.Word),
|
| 60 |
+
(r'(@|<<|>>)\b', Keyword), # stereotypes
|
| 61 |
+
(r'!=|<>|==|=|!->|->|>=|<=|[.]{3}|[+/*%=<>&|.~]', Operator),
|
| 62 |
+
(r'[]{}:(),;[]', Punctuation),
|
| 63 |
+
(r'(true|false|unlimited|null)\b', Keyword.Constant),
|
| 64 |
+
(r'(this|self|result)\b', Name.Builtin.Pseudo),
|
| 65 |
+
(r'(var)\b', Keyword.Declaration),
|
| 66 |
+
(r'(from|import)\b', Keyword.Namespace, 'fromimport'),
|
| 67 |
+
(r'(metamodel|class|exception|primitive|enum|transformation|'
|
| 68 |
+
r'library)(\s+)(\w+)',
|
| 69 |
+
bygroups(Keyword.Word, Text, Name.Class)),
|
| 70 |
+
(r'(exception)(\s+)(\w+)',
|
| 71 |
+
bygroups(Keyword.Word, Text, Name.Exception)),
|
| 72 |
+
(r'(main)\b', Name.Function),
|
| 73 |
+
(r'(mapping|helper|query)(\s+)',
|
| 74 |
+
bygroups(Keyword.Declaration, Text), 'operation'),
|
| 75 |
+
(r'(assert)(\s+)\b', bygroups(Keyword, Text), 'assert'),
|
| 76 |
+
(r'(Bag|Collection|Dict|OrderedSet|Sequence|Set|Tuple|List)\b',
|
| 77 |
+
Keyword.Type),
|
| 78 |
+
include('keywords'),
|
| 79 |
+
('"', String, combined('stringescape', 'dqs')),
|
| 80 |
+
("'", String, combined('stringescape', 'sqs')),
|
| 81 |
+
include('name'),
|
| 82 |
+
include('numbers'),
|
| 83 |
+
# (r'([a-zA-Z_]\w*)(::)([a-zA-Z_]\w*)',
|
| 84 |
+
# bygroups(Text, Text, Text)),
|
| 85 |
+
],
|
| 86 |
+
|
| 87 |
+
'fromimport': [
|
| 88 |
+
(r'(?:[ \t]|\\\n)+', Text),
|
| 89 |
+
(r'[a-zA-Z_][\w.]*', Name.Namespace),
|
| 90 |
+
default('#pop'),
|
| 91 |
+
],
|
| 92 |
+
|
| 93 |
+
'operation': [
|
| 94 |
+
(r'::', Text),
|
| 95 |
+
(r'(.*::)([a-zA-Z_]\w*)([ \t]*)(\()',
|
| 96 |
+
bygroups(Text, Name.Function, Text, Punctuation), '#pop')
|
| 97 |
+
],
|
| 98 |
+
|
| 99 |
+
'assert': [
|
| 100 |
+
(r'(warning|error|fatal)\b', Keyword, '#pop'),
|
| 101 |
+
default('#pop'), # all else: go back
|
| 102 |
+
],
|
| 103 |
+
|
| 104 |
+
'keywords': [
|
| 105 |
+
(words((
|
| 106 |
+
'abstract', 'access', 'any', 'assert', 'blackbox', 'break',
|
| 107 |
+
'case', 'collect', 'collectNested', 'collectOne', 'collectselect',
|
| 108 |
+
'collectselectOne', 'composes', 'compute', 'configuration',
|
| 109 |
+
'constructor', 'continue', 'datatype', 'default', 'derived',
|
| 110 |
+
'disjuncts', 'do', 'elif', 'else', 'end', 'endif', 'except',
|
| 111 |
+
'exists', 'extends', 'forAll', 'forEach', 'forOne', 'from', 'if',
|
| 112 |
+
'implies', 'in', 'inherits', 'init', 'inout', 'intermediate',
|
| 113 |
+
'invresolve', 'invresolveIn', 'invresolveone', 'invresolveoneIn',
|
| 114 |
+
'isUnique', 'iterate', 'late', 'let', 'literal', 'log', 'map',
|
| 115 |
+
'merges', 'modeltype', 'new', 'object', 'one', 'ordered', 'out',
|
| 116 |
+
'package', 'population', 'property', 'raise', 'readonly',
|
| 117 |
+
'references', 'refines', 'reject', 'resolve', 'resolveIn',
|
| 118 |
+
'resolveone', 'resolveoneIn', 'return', 'select', 'selectOne',
|
| 119 |
+
'sortedBy', 'static', 'switch', 'tag', 'then', 'try', 'typedef',
|
| 120 |
+
'unlimited', 'uses', 'when', 'where', 'while', 'with', 'xcollect',
|
| 121 |
+
'xmap', 'xselect'), suffix=r'\b'), Keyword),
|
| 122 |
+
],
|
| 123 |
+
|
| 124 |
+
# There is no need to distinguish between String.Single and
|
| 125 |
+
# String.Double: 'strings' is factorised for 'dqs' and 'sqs'
|
| 126 |
+
'strings': [
|
| 127 |
+
(r'[^\\\'"\n]+', String),
|
| 128 |
+
# quotes, percents and backslashes must be parsed one at a time
|
| 129 |
+
(r'[\'"\\]', String),
|
| 130 |
+
],
|
| 131 |
+
'stringescape': [
|
| 132 |
+
(r'\\([\\btnfr"\']|u[0-3][0-7]{2}|u[0-7]{1,2})', String.Escape)
|
| 133 |
+
],
|
| 134 |
+
'dqs': [ # double-quoted string
|
| 135 |
+
(r'"', String, '#pop'),
|
| 136 |
+
(r'\\\\|\\"', String.Escape),
|
| 137 |
+
include('strings')
|
| 138 |
+
],
|
| 139 |
+
'sqs': [ # single-quoted string
|
| 140 |
+
(r"'", String, '#pop'),
|
| 141 |
+
(r"\\\\|\\'", String.Escape),
|
| 142 |
+
include('strings')
|
| 143 |
+
],
|
| 144 |
+
'name': [
|
| 145 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 146 |
+
],
|
| 147 |
+
# numbers: excerpt taken from the python lexer
|
| 148 |
+
'numbers': [
|
| 149 |
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
| 150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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.r
|
| 3 |
+
~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the R/S languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import Lexer, RegexLexer, include, do_insertions
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Generic, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['RConsoleLexer', 'SLexer', 'RdLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
line_re = re.compile('.*?\n')
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class RConsoleLexer(Lexer):
|
| 24 |
+
"""
|
| 25 |
+
For R console transcripts or R CMD BATCH output files.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
name = 'RConsole'
|
| 29 |
+
aliases = ['rconsole', 'rout']
|
| 30 |
+
filenames = ['*.Rout']
|
| 31 |
+
url = 'https://www.r-project.org'
|
| 32 |
+
version_added = ''
|
| 33 |
+
_example = "rconsole/r-console-transcript.Rout"
|
| 34 |
+
|
| 35 |
+
def get_tokens_unprocessed(self, text):
|
| 36 |
+
slexer = SLexer(**self.options)
|
| 37 |
+
|
| 38 |
+
current_code_block = ''
|
| 39 |
+
insertions = []
|
| 40 |
+
|
| 41 |
+
for match in line_re.finditer(text):
|
| 42 |
+
line = match.group()
|
| 43 |
+
if line.startswith('>') or line.startswith('+'):
|
| 44 |
+
# Colorize the prompt as such,
|
| 45 |
+
# then put rest of line into current_code_block
|
| 46 |
+
insertions.append((len(current_code_block),
|
| 47 |
+
[(0, Generic.Prompt, line[:2])]))
|
| 48 |
+
current_code_block += line[2:]
|
| 49 |
+
else:
|
| 50 |
+
# We have reached a non-prompt line!
|
| 51 |
+
# If we have stored prompt lines, need to process them first.
|
| 52 |
+
if current_code_block:
|
| 53 |
+
# Weave together the prompts and highlight code.
|
| 54 |
+
yield from do_insertions(
|
| 55 |
+
insertions, slexer.get_tokens_unprocessed(current_code_block))
|
| 56 |
+
# Reset vars for next code block.
|
| 57 |
+
current_code_block = ''
|
| 58 |
+
insertions = []
|
| 59 |
+
# Now process the actual line itself, this is output from R.
|
| 60 |
+
yield match.start(), Generic.Output, line
|
| 61 |
+
|
| 62 |
+
# If we happen to end on a code block with nothing after it, need to
|
| 63 |
+
# process the last code block. This is neither elegant nor DRY so
|
| 64 |
+
# should be changed.
|
| 65 |
+
if current_code_block:
|
| 66 |
+
yield from do_insertions(
|
| 67 |
+
insertions, slexer.get_tokens_unprocessed(current_code_block))
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class SLexer(RegexLexer):
|
| 71 |
+
"""
|
| 72 |
+
For S, S-plus, and R source code.
|
| 73 |
+
"""
|
| 74 |
+
|
| 75 |
+
name = 'S'
|
| 76 |
+
aliases = ['splus', 's', 'r']
|
| 77 |
+
filenames = ['*.S', '*.R', '.Rhistory', '.Rprofile', '.Renviron']
|
| 78 |
+
mimetypes = ['text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r',
|
| 79 |
+
'text/x-R', 'text/x-r-history', 'text/x-r-profile']
|
| 80 |
+
url = 'https://www.r-project.org'
|
| 81 |
+
version_added = '0.10'
|
| 82 |
+
|
| 83 |
+
valid_name = r'`[^`\\]*(?:\\.[^`\\]*)*`|(?:[a-zA-Z]|\.[A-Za-z_.])[\w.]*|\.'
|
| 84 |
+
tokens = {
|
| 85 |
+
'comments': [
|
| 86 |
+
(r'#.*$', Comment.Single),
|
| 87 |
+
],
|
| 88 |
+
'valid_name': [
|
| 89 |
+
(valid_name, Name),
|
| 90 |
+
],
|
| 91 |
+
'function_name': [
|
| 92 |
+
(rf'({valid_name})\s*(?=\()', Name.Function),
|
| 93 |
+
],
|
| 94 |
+
'punctuation': [
|
| 95 |
+
(r'\[{1,2}|\]{1,2}|\(|\)|;|,', Punctuation),
|
| 96 |
+
],
|
| 97 |
+
'keywords': [
|
| 98 |
+
(r'(if|else|for|while|repeat|in|next|break|return|switch|function)'
|
| 99 |
+
r'(?![\w.])',
|
| 100 |
+
Keyword.Reserved),
|
| 101 |
+
],
|
| 102 |
+
'operators': [
|
| 103 |
+
(r'<<?-|->>?|-|==|<=|>=|\|>|<|>|&&?|!=|\|\|?|\?', Operator),
|
| 104 |
+
(r'\*|\+|\^|/|!|%[^%]*%|=|~|\$|@|:{1,3}', Operator),
|
| 105 |
+
],
|
| 106 |
+
'builtin_symbols': [
|
| 107 |
+
(r'(NULL|NA(_(integer|real|complex|character)_)?|'
|
| 108 |
+
r'letters|LETTERS|Inf|TRUE|FALSE|NaN|pi|\.\.(\.|[0-9]+))'
|
| 109 |
+
r'(?![\w.])',
|
| 110 |
+
Keyword.Constant),
|
| 111 |
+
(r'(T|F)\b', Name.Builtin.Pseudo),
|
| 112 |
+
],
|
| 113 |
+
'numbers': [
|
| 114 |
+
# hex number
|
| 115 |
+
(r'0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?', Number.Hex),
|
| 116 |
+
# decimal number
|
| 117 |
+
(r'[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+|\.)([eE][+-]?[0-9]+)?[Li]?',
|
| 118 |
+
Number),
|
| 119 |
+
],
|
| 120 |
+
'statements': [
|
| 121 |
+
include('comments'),
|
| 122 |
+
# whitespaces
|
| 123 |
+
(r'\s+', Whitespace),
|
| 124 |
+
(r'\'', String, 'string_squote'),
|
| 125 |
+
(r'\"', String, 'string_dquote'),
|
| 126 |
+
include('builtin_symbols'),
|
| 127 |
+
include('keywords'),
|
| 128 |
+
include('function_name'),
|
| 129 |
+
include('valid_name'),
|
| 130 |
+
include('numbers'),
|
| 131 |
+
include('punctuation'),
|
| 132 |
+
include('operators'),
|
| 133 |
+
],
|
| 134 |
+
'root': [
|
| 135 |
+
# calls:
|
| 136 |
+
include('statements'),
|
| 137 |
+
# blocks:
|
| 138 |
+
(r'\{|\}', Punctuation),
|
| 139 |
+
# (r'\{', Punctuation, 'block'),
|
| 140 |
+
(r'.', Text),
|
| 141 |
+
],
|
| 142 |
+
# 'block': [
|
| 143 |
+
# include('statements'),
|
| 144 |
+
# ('\{', Punctuation, '#push'),
|
| 145 |
+
# ('\}', Punctuation, '#pop')
|
| 146 |
+
# ],
|
| 147 |
+
'string_squote': [
|
| 148 |
+
(r'([^\'\\]|\\.)*\'', String, '#pop'),
|
| 149 |
+
],
|
| 150 |
+
'string_dquote': [
|
| 151 |
+
(r'([^"\\]|\\.)*"', String, '#pop'),
|
| 152 |
+
],
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
def analyse_text(text):
|
| 156 |
+
if re.search(r'[a-z0-9_\])\s]<-(?!-)', text):
|
| 157 |
+
return 0.11
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
class RdLexer(RegexLexer):
|
| 161 |
+
"""
|
| 162 |
+
Pygments Lexer for R documentation (Rd) files
|
| 163 |
+
|
| 164 |
+
This is a very minimal implementation, highlighting little more
|
| 165 |
+
than the macros. A description of Rd syntax is found in `Writing R
|
| 166 |
+
Extensions <http://cran.r-project.org/doc/manuals/R-exts.html>`_
|
| 167 |
+
and `Parsing Rd files <http://developer.r-project.org/parseRd.pdf>`_.
|
| 168 |
+
"""
|
| 169 |
+
name = 'Rd'
|
| 170 |
+
aliases = ['rd']
|
| 171 |
+
filenames = ['*.Rd']
|
| 172 |
+
mimetypes = ['text/x-r-doc']
|
| 173 |
+
url = 'http://cran.r-project.org/doc/manuals/R-exts.html'
|
| 174 |
+
version_added = '1.6'
|
| 175 |
+
|
| 176 |
+
# To account for verbatim / LaTeX-like / and R-like areas
|
| 177 |
+
# would require parsing.
|
| 178 |
+
tokens = {
|
| 179 |
+
'root': [
|
| 180 |
+
# catch escaped brackets and percent sign
|
| 181 |
+
(r'\\[\\{}%]', String.Escape),
|
| 182 |
+
# comments
|
| 183 |
+
(r'%.*$', Comment),
|
| 184 |
+
# special macros with no arguments
|
| 185 |
+
(r'\\(?:cr|l?dots|R|tab)\b', Keyword.Constant),
|
| 186 |
+
# macros
|
| 187 |
+
(r'\\[a-zA-Z]+\b', Keyword),
|
| 188 |
+
# special preprocessor macros
|
| 189 |
+
(r'^\s*#(?:ifn?def|endif).*\b', Comment.Preproc),
|
| 190 |
+
# non-escaped brackets
|
| 191 |
+
(r'[{}]', Name.Builtin),
|
| 192 |
+
# everything else
|
| 193 |
+
(r'[^\\%\n{}]+', Text),
|
| 194 |
+
(r'.', Text),
|
| 195 |
+
]
|
| 196 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rdf.py
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.rdf
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for semantic web and RDF query languages and markup.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, bygroups, default
|
| 14 |
+
from pygments.token import Keyword, Punctuation, String, Number, Operator, \
|
| 15 |
+
Generic, Whitespace, Name, Literal, Comment, Text
|
| 16 |
+
|
| 17 |
+
__all__ = ['SparqlLexer', 'TurtleLexer', 'ShExCLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class SparqlLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Lexer for SPARQL query language.
|
| 23 |
+
"""
|
| 24 |
+
name = 'SPARQL'
|
| 25 |
+
aliases = ['sparql']
|
| 26 |
+
filenames = ['*.rq', '*.sparql']
|
| 27 |
+
mimetypes = ['application/sparql-query']
|
| 28 |
+
url = 'https://www.w3.org/TR/sparql11-query'
|
| 29 |
+
version_added = '2.0'
|
| 30 |
+
|
| 31 |
+
# character group definitions ::
|
| 32 |
+
|
| 33 |
+
PN_CHARS_BASE_GRP = ('a-zA-Z'
|
| 34 |
+
'\u00c0-\u00d6'
|
| 35 |
+
'\u00d8-\u00f6'
|
| 36 |
+
'\u00f8-\u02ff'
|
| 37 |
+
'\u0370-\u037d'
|
| 38 |
+
'\u037f-\u1fff'
|
| 39 |
+
'\u200c-\u200d'
|
| 40 |
+
'\u2070-\u218f'
|
| 41 |
+
'\u2c00-\u2fef'
|
| 42 |
+
'\u3001-\ud7ff'
|
| 43 |
+
'\uf900-\ufdcf'
|
| 44 |
+
'\ufdf0-\ufffd')
|
| 45 |
+
|
| 46 |
+
PN_CHARS_U_GRP = (PN_CHARS_BASE_GRP + '_')
|
| 47 |
+
|
| 48 |
+
PN_CHARS_GRP = (PN_CHARS_U_GRP +
|
| 49 |
+
r'\-' +
|
| 50 |
+
r'0-9' +
|
| 51 |
+
'\u00b7' +
|
| 52 |
+
'\u0300-\u036f' +
|
| 53 |
+
'\u203f-\u2040')
|
| 54 |
+
|
| 55 |
+
HEX_GRP = '0-9A-Fa-f'
|
| 56 |
+
|
| 57 |
+
PN_LOCAL_ESC_CHARS_GRP = r' _~.\-!$&"()*+,;=/?#@%'
|
| 58 |
+
|
| 59 |
+
# terminal productions ::
|
| 60 |
+
|
| 61 |
+
PN_CHARS_BASE = '[' + PN_CHARS_BASE_GRP + ']'
|
| 62 |
+
|
| 63 |
+
PN_CHARS_U = '[' + PN_CHARS_U_GRP + ']'
|
| 64 |
+
|
| 65 |
+
PN_CHARS = '[' + PN_CHARS_GRP + ']'
|
| 66 |
+
|
| 67 |
+
HEX = '[' + HEX_GRP + ']'
|
| 68 |
+
|
| 69 |
+
PN_LOCAL_ESC_CHARS = '[' + PN_LOCAL_ESC_CHARS_GRP + ']'
|
| 70 |
+
|
| 71 |
+
IRIREF = r'<(?:[^<>"{}|^`\\\x00-\x20])*>'
|
| 72 |
+
|
| 73 |
+
BLANK_NODE_LABEL = '_:[0-9' + PN_CHARS_U_GRP + '](?:[' + PN_CHARS_GRP + \
|
| 74 |
+
'.]*' + PN_CHARS + ')?'
|
| 75 |
+
|
| 76 |
+
PN_PREFIX = PN_CHARS_BASE + '(?:[' + PN_CHARS_GRP + '.]*' + PN_CHARS + ')?'
|
| 77 |
+
|
| 78 |
+
VARNAME = '[0-9' + PN_CHARS_U_GRP + '][' + PN_CHARS_U_GRP + \
|
| 79 |
+
'0-9\u00b7\u0300-\u036f\u203f-\u2040]*'
|
| 80 |
+
|
| 81 |
+
PERCENT = '%' + HEX + HEX
|
| 82 |
+
|
| 83 |
+
PN_LOCAL_ESC = r'\\' + PN_LOCAL_ESC_CHARS
|
| 84 |
+
|
| 85 |
+
PLX = '(?:' + PERCENT + ')|(?:' + PN_LOCAL_ESC + ')'
|
| 86 |
+
|
| 87 |
+
PN_LOCAL = ('(?:[' + PN_CHARS_U_GRP + ':0-9' + ']|' + PLX + ')' +
|
| 88 |
+
'(?:(?:[' + PN_CHARS_GRP + '.:]|' + PLX + ')*(?:[' +
|
| 89 |
+
PN_CHARS_GRP + ':]|' + PLX + '))?')
|
| 90 |
+
|
| 91 |
+
EXPONENT = r'[eE][+-]?\d+'
|
| 92 |
+
|
| 93 |
+
# Lexer token definitions ::
|
| 94 |
+
|
| 95 |
+
tokens = {
|
| 96 |
+
'root': [
|
| 97 |
+
(r'\s+', Text),
|
| 98 |
+
# keywords ::
|
| 99 |
+
(r'(?i)(select|construct|describe|ask|where|filter|group\s+by|minus|'
|
| 100 |
+
r'distinct|reduced|from\s+named|from|order\s+by|desc|asc|limit|'
|
| 101 |
+
r'offset|values|bindings|load|into|clear|drop|create|add|move|copy|'
|
| 102 |
+
r'insert\s+data|delete\s+data|delete\s+where|with|delete|insert|'
|
| 103 |
+
r'using\s+named|using|graph|default|named|all|optional|service|'
|
| 104 |
+
r'silent|bind|undef|union|not\s+in|in|as|having|to|prefix|base)\b', Keyword),
|
| 105 |
+
(r'(a)\b', Keyword),
|
| 106 |
+
# IRIs ::
|
| 107 |
+
('(' + IRIREF + ')', Name.Label),
|
| 108 |
+
# blank nodes ::
|
| 109 |
+
('(' + BLANK_NODE_LABEL + ')', Name.Label),
|
| 110 |
+
# # variables ::
|
| 111 |
+
('[?$]' + VARNAME, Name.Variable),
|
| 112 |
+
# prefixed names ::
|
| 113 |
+
(r'(' + PN_PREFIX + r')?(\:)(' + PN_LOCAL + r')?',
|
| 114 |
+
bygroups(Name.Namespace, Punctuation, Name.Tag)),
|
| 115 |
+
# function names ::
|
| 116 |
+
(r'(?i)(str|lang|langmatches|datatype|bound|iri|uri|bnode|rand|abs|'
|
| 117 |
+
r'ceil|floor|round|concat|strlen|ucase|lcase|encode_for_uri|'
|
| 118 |
+
r'contains|strstarts|strends|strbefore|strafter|year|month|day|'
|
| 119 |
+
r'hours|minutes|seconds|timezone|tz|now|uuid|struuid|md5|sha1|sha256|sha384|'
|
| 120 |
+
r'sha512|coalesce|if|strlang|strdt|sameterm|isiri|isuri|isblank|'
|
| 121 |
+
r'isliteral|isnumeric|regex|substr|replace|exists|not\s+exists|'
|
| 122 |
+
r'count|sum|min|max|avg|sample|group_concat|separator)\b',
|
| 123 |
+
Name.Function),
|
| 124 |
+
# boolean literals ::
|
| 125 |
+
(r'(true|false)', Keyword.Constant),
|
| 126 |
+
# double literals ::
|
| 127 |
+
(r'[+\-]?(\d+\.\d*' + EXPONENT + r'|\.?\d+' + EXPONENT + ')', Number.Float),
|
| 128 |
+
# decimal literals ::
|
| 129 |
+
(r'[+\-]?(\d+\.\d*|\.\d+)', Number.Float),
|
| 130 |
+
# integer literals ::
|
| 131 |
+
(r'[+\-]?\d+', Number.Integer),
|
| 132 |
+
# operators ::
|
| 133 |
+
(r'(\|\||&&|=|\*|\-|\+|/|!=|<=|>=|!|<|>)', Operator),
|
| 134 |
+
# punctuation characters ::
|
| 135 |
+
(r'[(){}.;,:^\[\]]', Punctuation),
|
| 136 |
+
# line comments ::
|
| 137 |
+
(r'#[^\n]*', Comment),
|
| 138 |
+
# strings ::
|
| 139 |
+
(r'"""', String, 'triple-double-quoted-string'),
|
| 140 |
+
(r'"', String, 'single-double-quoted-string'),
|
| 141 |
+
(r"'''", String, 'triple-single-quoted-string'),
|
| 142 |
+
(r"'", String, 'single-single-quoted-string'),
|
| 143 |
+
],
|
| 144 |
+
'triple-double-quoted-string': [
|
| 145 |
+
(r'"""', String, 'end-of-string'),
|
| 146 |
+
(r'[^\\]+', String),
|
| 147 |
+
(r'\\', String, 'string-escape'),
|
| 148 |
+
],
|
| 149 |
+
'single-double-quoted-string': [
|
| 150 |
+
(r'"', String, 'end-of-string'),
|
| 151 |
+
(r'[^"\\\n]+', String),
|
| 152 |
+
(r'\\', String, 'string-escape'),
|
| 153 |
+
],
|
| 154 |
+
'triple-single-quoted-string': [
|
| 155 |
+
(r"'''", String, 'end-of-string'),
|
| 156 |
+
(r'[^\\]+', String),
|
| 157 |
+
(r'\\', String.Escape, 'string-escape'),
|
| 158 |
+
],
|
| 159 |
+
'single-single-quoted-string': [
|
| 160 |
+
(r"'", String, 'end-of-string'),
|
| 161 |
+
(r"[^'\\\n]+", String),
|
| 162 |
+
(r'\\', String, 'string-escape'),
|
| 163 |
+
],
|
| 164 |
+
'string-escape': [
|
| 165 |
+
(r'u' + HEX + '{4}', String.Escape, '#pop'),
|
| 166 |
+
(r'U' + HEX + '{8}', String.Escape, '#pop'),
|
| 167 |
+
(r'.', String.Escape, '#pop'),
|
| 168 |
+
],
|
| 169 |
+
'end-of-string': [
|
| 170 |
+
(r'(@)([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)',
|
| 171 |
+
bygroups(Operator, Name.Function), '#pop:2'),
|
| 172 |
+
(r'\^\^', Operator, '#pop:2'),
|
| 173 |
+
default('#pop:2'),
|
| 174 |
+
],
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
class TurtleLexer(RegexLexer):
|
| 179 |
+
"""
|
| 180 |
+
Lexer for Turtle data language.
|
| 181 |
+
"""
|
| 182 |
+
name = 'Turtle'
|
| 183 |
+
aliases = ['turtle']
|
| 184 |
+
filenames = ['*.ttl']
|
| 185 |
+
mimetypes = ['text/turtle', 'application/x-turtle']
|
| 186 |
+
url = 'https://www.w3.org/TR/turtle'
|
| 187 |
+
version_added = '2.1'
|
| 188 |
+
|
| 189 |
+
# character group definitions ::
|
| 190 |
+
PN_CHARS_BASE_GRP = ('a-zA-Z'
|
| 191 |
+
'\u00c0-\u00d6'
|
| 192 |
+
'\u00d8-\u00f6'
|
| 193 |
+
'\u00f8-\u02ff'
|
| 194 |
+
'\u0370-\u037d'
|
| 195 |
+
'\u037f-\u1fff'
|
| 196 |
+
'\u200c-\u200d'
|
| 197 |
+
'\u2070-\u218f'
|
| 198 |
+
'\u2c00-\u2fef'
|
| 199 |
+
'\u3001-\ud7ff'
|
| 200 |
+
'\uf900-\ufdcf'
|
| 201 |
+
'\ufdf0-\ufffd')
|
| 202 |
+
|
| 203 |
+
PN_CHARS_U_GRP = (PN_CHARS_BASE_GRP + '_')
|
| 204 |
+
|
| 205 |
+
PN_CHARS_GRP = (PN_CHARS_U_GRP +
|
| 206 |
+
r'\-' +
|
| 207 |
+
r'0-9' +
|
| 208 |
+
'\u00b7' +
|
| 209 |
+
'\u0300-\u036f' +
|
| 210 |
+
'\u203f-\u2040')
|
| 211 |
+
|
| 212 |
+
PN_CHARS = '[' + PN_CHARS_GRP + ']'
|
| 213 |
+
|
| 214 |
+
PN_CHARS_BASE = '[' + PN_CHARS_BASE_GRP + ']'
|
| 215 |
+
|
| 216 |
+
PN_PREFIX = PN_CHARS_BASE + '(?:[' + PN_CHARS_GRP + '.]*' + PN_CHARS + ')?'
|
| 217 |
+
|
| 218 |
+
HEX_GRP = '0-9A-Fa-f'
|
| 219 |
+
|
| 220 |
+
HEX = '[' + HEX_GRP + ']'
|
| 221 |
+
|
| 222 |
+
PERCENT = '%' + HEX + HEX
|
| 223 |
+
|
| 224 |
+
PN_LOCAL_ESC_CHARS_GRP = r' _~.\-!$&"()*+,;=/?#@%'
|
| 225 |
+
|
| 226 |
+
PN_LOCAL_ESC_CHARS = '[' + PN_LOCAL_ESC_CHARS_GRP + ']'
|
| 227 |
+
|
| 228 |
+
PN_LOCAL_ESC = r'\\' + PN_LOCAL_ESC_CHARS
|
| 229 |
+
|
| 230 |
+
PLX = '(?:' + PERCENT + ')|(?:' + PN_LOCAL_ESC + ')'
|
| 231 |
+
|
| 232 |
+
PN_LOCAL = ('(?:[' + PN_CHARS_U_GRP + ':0-9' + ']|' + PLX + ')' +
|
| 233 |
+
'(?:(?:[' + PN_CHARS_GRP + '.:]|' + PLX + ')*(?:[' +
|
| 234 |
+
PN_CHARS_GRP + ':]|' + PLX + '))?')
|
| 235 |
+
|
| 236 |
+
patterns = {
|
| 237 |
+
'PNAME_NS': r'((?:[a-zA-Z][\w-]*)?\:)', # Simplified character range
|
| 238 |
+
'IRIREF': r'(<[^<>"{}|^`\\\x00-\x20]*>)'
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
tokens = {
|
| 242 |
+
'root': [
|
| 243 |
+
(r'\s+', Text),
|
| 244 |
+
|
| 245 |
+
# Base / prefix
|
| 246 |
+
(r'(@base|BASE)(\s+){IRIREF}(\s*)(\.?)'.format(**patterns),
|
| 247 |
+
bygroups(Keyword, Whitespace, Name.Variable, Whitespace,
|
| 248 |
+
Punctuation)),
|
| 249 |
+
(r'(@prefix|PREFIX)(\s+){PNAME_NS}(\s+){IRIREF}(\s*)(\.?)'.format(**patterns),
|
| 250 |
+
bygroups(Keyword, Whitespace, Name.Namespace, Whitespace,
|
| 251 |
+
Name.Variable, Whitespace, Punctuation)),
|
| 252 |
+
|
| 253 |
+
# The shorthand predicate 'a'
|
| 254 |
+
(r'(?<=\s)a(?=\s)', Keyword.Type),
|
| 255 |
+
|
| 256 |
+
# IRIREF
|
| 257 |
+
(r'{IRIREF}'.format(**patterns), Name.Variable),
|
| 258 |
+
|
| 259 |
+
# PrefixedName
|
| 260 |
+
(r'(' + PN_PREFIX + r')?(\:)(' + PN_LOCAL + r')?',
|
| 261 |
+
bygroups(Name.Namespace, Punctuation, Name.Tag)),
|
| 262 |
+
|
| 263 |
+
# BlankNodeLabel
|
| 264 |
+
(r'(_)(:)([' + PN_CHARS_U_GRP + r'0-9]([' + PN_CHARS_GRP + r'.]*' + PN_CHARS + ')?)',
|
| 265 |
+
bygroups(Name.Namespace, Punctuation, Name.Tag)),
|
| 266 |
+
|
| 267 |
+
# Comment
|
| 268 |
+
(r'#([^\n]+|$)', Comment),
|
| 269 |
+
|
| 270 |
+
(r'\b(true|false)\b', Literal),
|
| 271 |
+
(r'[+\-]?\d*\.\d+', Number.Float),
|
| 272 |
+
(r'[+\-]?\d*(:?\.\d+)?E[+\-]?\d+', Number.Float),
|
| 273 |
+
(r'[+\-]?\d+', Number.Integer),
|
| 274 |
+
(r'[\[\](){}.;,:^]', Punctuation),
|
| 275 |
+
|
| 276 |
+
(r'"""', String, 'triple-double-quoted-string'),
|
| 277 |
+
(r'"', String, 'single-double-quoted-string'),
|
| 278 |
+
(r"'''", String, 'triple-single-quoted-string'),
|
| 279 |
+
(r"'", String, 'single-single-quoted-string'),
|
| 280 |
+
],
|
| 281 |
+
'triple-double-quoted-string': [
|
| 282 |
+
(r'"""', String, 'end-of-string'),
|
| 283 |
+
(r'[^\\]+(?=""")', String),
|
| 284 |
+
(r'\\', String, 'string-escape'),
|
| 285 |
+
],
|
| 286 |
+
'single-double-quoted-string': [
|
| 287 |
+
(r'"', String, 'end-of-string'),
|
| 288 |
+
(r'[^"\\\n]+', String),
|
| 289 |
+
(r'\\', String, 'string-escape'),
|
| 290 |
+
],
|
| 291 |
+
'triple-single-quoted-string': [
|
| 292 |
+
(r"'''", String, 'end-of-string'),
|
| 293 |
+
(r"[^\\]+(?=''')", String),
|
| 294 |
+
(r'\\', String, 'string-escape'),
|
| 295 |
+
],
|
| 296 |
+
'single-single-quoted-string': [
|
| 297 |
+
(r"'", String, 'end-of-string'),
|
| 298 |
+
(r"[^'\\\n]+", String),
|
| 299 |
+
(r'\\', String, 'string-escape'),
|
| 300 |
+
],
|
| 301 |
+
'string-escape': [
|
| 302 |
+
(r'.', String, '#pop'),
|
| 303 |
+
],
|
| 304 |
+
'end-of-string': [
|
| 305 |
+
(r'(@)([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)',
|
| 306 |
+
bygroups(Operator, Generic.Emph), '#pop:2'),
|
| 307 |
+
|
| 308 |
+
(r'(\^\^){IRIREF}'.format(**patterns), bygroups(Operator, Generic.Emph), '#pop:2'),
|
| 309 |
+
|
| 310 |
+
default('#pop:2'),
|
| 311 |
+
|
| 312 |
+
],
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
# Turtle and Tera Term macro files share the same file extension
|
| 316 |
+
# but each has a recognizable and distinct syntax.
|
| 317 |
+
def analyse_text(text):
|
| 318 |
+
for t in ('@base ', 'BASE ', '@prefix ', 'PREFIX '):
|
| 319 |
+
if re.search(rf'^\s*{t}', text):
|
| 320 |
+
return 0.80
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
class ShExCLexer(RegexLexer):
|
| 324 |
+
"""
|
| 325 |
+
Lexer for ShExC shape expressions language syntax.
|
| 326 |
+
"""
|
| 327 |
+
name = 'ShExC'
|
| 328 |
+
aliases = ['shexc', 'shex']
|
| 329 |
+
filenames = ['*.shex']
|
| 330 |
+
mimetypes = ['text/shex']
|
| 331 |
+
url = 'https://shex.io/shex-semantics/#shexc'
|
| 332 |
+
version_added = ''
|
| 333 |
+
|
| 334 |
+
# character group definitions ::
|
| 335 |
+
|
| 336 |
+
PN_CHARS_BASE_GRP = ('a-zA-Z'
|
| 337 |
+
'\u00c0-\u00d6'
|
| 338 |
+
'\u00d8-\u00f6'
|
| 339 |
+
'\u00f8-\u02ff'
|
| 340 |
+
'\u0370-\u037d'
|
| 341 |
+
'\u037f-\u1fff'
|
| 342 |
+
'\u200c-\u200d'
|
| 343 |
+
'\u2070-\u218f'
|
| 344 |
+
'\u2c00-\u2fef'
|
| 345 |
+
'\u3001-\ud7ff'
|
| 346 |
+
'\uf900-\ufdcf'
|
| 347 |
+
'\ufdf0-\ufffd')
|
| 348 |
+
|
| 349 |
+
PN_CHARS_U_GRP = (PN_CHARS_BASE_GRP + '_')
|
| 350 |
+
|
| 351 |
+
PN_CHARS_GRP = (PN_CHARS_U_GRP +
|
| 352 |
+
r'\-' +
|
| 353 |
+
r'0-9' +
|
| 354 |
+
'\u00b7' +
|
| 355 |
+
'\u0300-\u036f' +
|
| 356 |
+
'\u203f-\u2040')
|
| 357 |
+
|
| 358 |
+
HEX_GRP = '0-9A-Fa-f'
|
| 359 |
+
|
| 360 |
+
PN_LOCAL_ESC_CHARS_GRP = r"_~.\-!$&'()*+,;=/?#@%"
|
| 361 |
+
|
| 362 |
+
# terminal productions ::
|
| 363 |
+
|
| 364 |
+
PN_CHARS_BASE = '[' + PN_CHARS_BASE_GRP + ']'
|
| 365 |
+
|
| 366 |
+
PN_CHARS_U = '[' + PN_CHARS_U_GRP + ']'
|
| 367 |
+
|
| 368 |
+
PN_CHARS = '[' + PN_CHARS_GRP + ']'
|
| 369 |
+
|
| 370 |
+
HEX = '[' + HEX_GRP + ']'
|
| 371 |
+
|
| 372 |
+
PN_LOCAL_ESC_CHARS = '[' + PN_LOCAL_ESC_CHARS_GRP + ']'
|
| 373 |
+
|
| 374 |
+
UCHAR_NO_BACKSLASH = '(?:u' + HEX + '{4}|U' + HEX + '{8})'
|
| 375 |
+
|
| 376 |
+
UCHAR = r'\\' + UCHAR_NO_BACKSLASH
|
| 377 |
+
|
| 378 |
+
IRIREF = r'<(?:[^\x00-\x20<>"{}|^`\\]|' + UCHAR + ')*>'
|
| 379 |
+
|
| 380 |
+
BLANK_NODE_LABEL = '_:[0-9' + PN_CHARS_U_GRP + '](?:[' + PN_CHARS_GRP + \
|
| 381 |
+
'.]*' + PN_CHARS + ')?'
|
| 382 |
+
|
| 383 |
+
PN_PREFIX = PN_CHARS_BASE + '(?:[' + PN_CHARS_GRP + '.]*' + PN_CHARS + ')?'
|
| 384 |
+
|
| 385 |
+
PERCENT = '%' + HEX + HEX
|
| 386 |
+
|
| 387 |
+
PN_LOCAL_ESC = r'\\' + PN_LOCAL_ESC_CHARS
|
| 388 |
+
|
| 389 |
+
PLX = '(?:' + PERCENT + ')|(?:' + PN_LOCAL_ESC + ')'
|
| 390 |
+
|
| 391 |
+
PN_LOCAL = ('(?:[' + PN_CHARS_U_GRP + ':0-9' + ']|' + PLX + ')' +
|
| 392 |
+
'(?:(?:[' + PN_CHARS_GRP + '.:]|' + PLX + ')*(?:[' +
|
| 393 |
+
PN_CHARS_GRP + ':]|' + PLX + '))?')
|
| 394 |
+
|
| 395 |
+
EXPONENT = r'[eE][+-]?\d+'
|
| 396 |
+
|
| 397 |
+
# Lexer token definitions ::
|
| 398 |
+
|
| 399 |
+
tokens = {
|
| 400 |
+
'root': [
|
| 401 |
+
(r'\s+', Text),
|
| 402 |
+
# keywords ::
|
| 403 |
+
(r'(?i)(base|prefix|start|external|'
|
| 404 |
+
r'literal|iri|bnode|nonliteral|length|minlength|maxlength|'
|
| 405 |
+
r'mininclusive|minexclusive|maxinclusive|maxexclusive|'
|
| 406 |
+
r'totaldigits|fractiondigits|'
|
| 407 |
+
r'closed|extra)\b', Keyword),
|
| 408 |
+
(r'(a)\b', Keyword),
|
| 409 |
+
# IRIs ::
|
| 410 |
+
('(' + IRIREF + ')', Name.Label),
|
| 411 |
+
# blank nodes ::
|
| 412 |
+
('(' + BLANK_NODE_LABEL + ')', Name.Label),
|
| 413 |
+
# prefixed names ::
|
| 414 |
+
(r'(' + PN_PREFIX + r')?(\:)(' + PN_LOCAL + ')?',
|
| 415 |
+
bygroups(Name.Namespace, Punctuation, Name.Tag)),
|
| 416 |
+
# boolean literals ::
|
| 417 |
+
(r'(true|false)', Keyword.Constant),
|
| 418 |
+
# double literals ::
|
| 419 |
+
(r'[+\-]?(\d+\.\d*' + EXPONENT + r'|\.?\d+' + EXPONENT + ')', Number.Float),
|
| 420 |
+
# decimal literals ::
|
| 421 |
+
(r'[+\-]?(\d+\.\d*|\.\d+)', Number.Float),
|
| 422 |
+
# integer literals ::
|
| 423 |
+
(r'[+\-]?\d+', Number.Integer),
|
| 424 |
+
# operators ::
|
| 425 |
+
(r'[@|$&=*+?^\-~]', Operator),
|
| 426 |
+
# operator keywords ::
|
| 427 |
+
(r'(?i)(and|or|not)\b', Operator.Word),
|
| 428 |
+
# punctuation characters ::
|
| 429 |
+
(r'[(){}.;,:^\[\]]', Punctuation),
|
| 430 |
+
# line comments ::
|
| 431 |
+
(r'#[^\n]*', Comment),
|
| 432 |
+
# strings ::
|
| 433 |
+
(r'"""', String, 'triple-double-quoted-string'),
|
| 434 |
+
(r'"', String, 'single-double-quoted-string'),
|
| 435 |
+
(r"'''", String, 'triple-single-quoted-string'),
|
| 436 |
+
(r"'", String, 'single-single-quoted-string'),
|
| 437 |
+
],
|
| 438 |
+
'triple-double-quoted-string': [
|
| 439 |
+
(r'"""', String, 'end-of-string'),
|
| 440 |
+
(r'[^\\]+', String),
|
| 441 |
+
(r'\\', String, 'string-escape'),
|
| 442 |
+
],
|
| 443 |
+
'single-double-quoted-string': [
|
| 444 |
+
(r'"', String, 'end-of-string'),
|
| 445 |
+
(r'[^"\\\n]+', String),
|
| 446 |
+
(r'\\', String, 'string-escape'),
|
| 447 |
+
],
|
| 448 |
+
'triple-single-quoted-string': [
|
| 449 |
+
(r"'''", String, 'end-of-string'),
|
| 450 |
+
(r'[^\\]+', String),
|
| 451 |
+
(r'\\', String.Escape, 'string-escape'),
|
| 452 |
+
],
|
| 453 |
+
'single-single-quoted-string': [
|
| 454 |
+
(r"'", String, 'end-of-string'),
|
| 455 |
+
(r"[^'\\\n]+", String),
|
| 456 |
+
(r'\\', String, 'string-escape'),
|
| 457 |
+
],
|
| 458 |
+
'string-escape': [
|
| 459 |
+
(UCHAR_NO_BACKSLASH, String.Escape, '#pop'),
|
| 460 |
+
(r'.', String.Escape, '#pop'),
|
| 461 |
+
],
|
| 462 |
+
'end-of-string': [
|
| 463 |
+
(r'(@)([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)',
|
| 464 |
+
bygroups(Operator, Name.Function), '#pop:2'),
|
| 465 |
+
(r'\^\^', Operator, '#pop:2'),
|
| 466 |
+
default('#pop:2'),
|
| 467 |
+
],
|
| 468 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rebol.py
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, bygroups
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Generic, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['RebolLexer', 'RedLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class RebolLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
A REBOL lexer.
|
| 23 |
+
"""
|
| 24 |
+
name = 'REBOL'
|
| 25 |
+
aliases = ['rebol']
|
| 26 |
+
filenames = ['*.r', '*.r3', '*.reb']
|
| 27 |
+
mimetypes = ['text/x-rebol']
|
| 28 |
+
url = 'http://www.rebol.com'
|
| 29 |
+
version_added = '1.1'
|
| 30 |
+
|
| 31 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 32 |
+
|
| 33 |
+
escape_re = r'(?:\^\([0-9a-f]{1,4}\)*)'
|
| 34 |
+
|
| 35 |
+
def word_callback(lexer, match):
|
| 36 |
+
word = match.group()
|
| 37 |
+
|
| 38 |
+
if re.match(".*:$", word):
|
| 39 |
+
yield match.start(), Generic.Subheading, word
|
| 40 |
+
elif re.match(
|
| 41 |
+
r'(native|alias|all|any|as-string|as-binary|bind|bound\?|case|'
|
| 42 |
+
r'catch|checksum|comment|debase|dehex|exclude|difference|disarm|'
|
| 43 |
+
r'either|else|enbase|foreach|remove-each|form|free|get|get-env|if|'
|
| 44 |
+
r'in|intersect|loop|minimum-of|maximum-of|mold|new-line|'
|
| 45 |
+
r'new-line\?|not|now|prin|print|reduce|compose|construct|repeat|'
|
| 46 |
+
r'reverse|save|script\?|set|shift|switch|throw|to-hex|trace|try|'
|
| 47 |
+
r'type\?|union|unique|unless|unprotect|unset|until|use|value\?|'
|
| 48 |
+
r'while|compress|decompress|secure|open|close|read|read-io|'
|
| 49 |
+
r'write-io|write|update|query|wait|input\?|exp|log-10|log-2|'
|
| 50 |
+
r'log-e|square-root|cosine|sine|tangent|arccosine|arcsine|'
|
| 51 |
+
r'arctangent|protect|lowercase|uppercase|entab|detab|connected\?|'
|
| 52 |
+
r'browse|launch|stats|get-modes|set-modes|to-local-file|'
|
| 53 |
+
r'to-rebol-file|encloak|decloak|create-link|do-browser|bind\?|'
|
| 54 |
+
r'hide|draw|show|size-text|textinfo|offset-to-caret|'
|
| 55 |
+
r'caret-to-offset|local-request-file|rgb-to-hsv|hsv-to-rgb|'
|
| 56 |
+
r'crypt-strength\?|dh-make-key|dh-generate-key|dh-compute-key|'
|
| 57 |
+
r'dsa-make-key|dsa-generate-key|dsa-make-signature|'
|
| 58 |
+
r'dsa-verify-signature|rsa-make-key|rsa-generate-key|'
|
| 59 |
+
r'rsa-encrypt)$', word):
|
| 60 |
+
yield match.start(), Name.Builtin, word
|
| 61 |
+
elif re.match(
|
| 62 |
+
r'(add|subtract|multiply|divide|remainder|power|and~|or~|xor~|'
|
| 63 |
+
r'minimum|maximum|negate|complement|absolute|random|head|tail|'
|
| 64 |
+
r'next|back|skip|at|pick|first|second|third|fourth|fifth|sixth|'
|
| 65 |
+
r'seventh|eighth|ninth|tenth|last|path|find|select|make|to|copy\*|'
|
| 66 |
+
r'insert|remove|change|poke|clear|trim|sort|min|max|abs|cp|'
|
| 67 |
+
r'copy)$', word):
|
| 68 |
+
yield match.start(), Name.Function, word
|
| 69 |
+
elif re.match(
|
| 70 |
+
r'(error|source|input|license|help|install|echo|Usage|with|func|'
|
| 71 |
+
r'throw-on-error|function|does|has|context|probe|\?\?|as-pair|'
|
| 72 |
+
r'mod|modulo|round|repend|about|set-net|append|join|rejoin|reform|'
|
| 73 |
+
r'remold|charset|array|replace|move|extract|forskip|forall|alter|'
|
| 74 |
+
r'first+|also|take|for|forever|dispatch|attempt|what-dir|'
|
| 75 |
+
r'change-dir|clean-path|list-dir|dirize|rename|split-path|delete|'
|
| 76 |
+
r'make-dir|delete-dir|in-dir|confirm|dump-obj|upgrade|what|'
|
| 77 |
+
r'build-tag|process-source|build-markup|decode-cgi|read-cgi|'
|
| 78 |
+
r'write-user|save-user|set-user-name|protect-system|parse-xml|'
|
| 79 |
+
r'cvs-date|cvs-version|do-boot|get-net-info|desktop|layout|'
|
| 80 |
+
r'scroll-para|get-face|alert|set-face|uninstall|unfocus|'
|
| 81 |
+
r'request-dir|center-face|do-events|net-error|decode-url|'
|
| 82 |
+
r'parse-header|parse-header-date|parse-email-addrs|import-email|'
|
| 83 |
+
r'send|build-attach-body|resend|show-popup|hide-popup|open-events|'
|
| 84 |
+
r'find-key-face|do-face|viewtop|confine|find-window|'
|
| 85 |
+
r'insert-event-func|remove-event-func|inform|dump-pane|dump-face|'
|
| 86 |
+
r'flag-face|deflag-face|clear-fields|read-net|vbug|path-thru|'
|
| 87 |
+
r'read-thru|load-thru|do-thru|launch-thru|load-image|'
|
| 88 |
+
r'request-download|do-face-alt|set-font|set-para|get-style|'
|
| 89 |
+
r'set-style|make-face|stylize|choose|hilight-text|hilight-all|'
|
| 90 |
+
r'unlight-text|focus|scroll-drag|clear-face|reset-face|scroll-face|'
|
| 91 |
+
r'resize-face|load-stock|load-stock-block|notify|request|flash|'
|
| 92 |
+
r'request-color|request-pass|request-text|request-list|'
|
| 93 |
+
r'request-date|request-file|dbug|editor|link-relative-path|'
|
| 94 |
+
r'emailer|parse-error)$', word):
|
| 95 |
+
yield match.start(), Keyword.Namespace, word
|
| 96 |
+
elif re.match(
|
| 97 |
+
r'(halt|quit|do|load|q|recycle|call|run|ask|parse|view|unview|'
|
| 98 |
+
r'return|exit|break)$', word):
|
| 99 |
+
yield match.start(), Name.Exception, word
|
| 100 |
+
elif re.match('REBOL$', word):
|
| 101 |
+
yield match.start(), Generic.Heading, word
|
| 102 |
+
elif re.match("to-.*", word):
|
| 103 |
+
yield match.start(), Keyword, word
|
| 104 |
+
elif re.match(r'(\+|-|\*|/|//|\*\*|and|or|xor|=\?|=|==|<>|<|>|<=|>=)$',
|
| 105 |
+
word):
|
| 106 |
+
yield match.start(), Operator, word
|
| 107 |
+
elif re.match(r".*\?$", word):
|
| 108 |
+
yield match.start(), Keyword, word
|
| 109 |
+
elif re.match(r".*\!$", word):
|
| 110 |
+
yield match.start(), Keyword.Type, word
|
| 111 |
+
elif re.match("'.*", word):
|
| 112 |
+
yield match.start(), Name.Variable.Instance, word # lit-word
|
| 113 |
+
elif re.match("#.*", word):
|
| 114 |
+
yield match.start(), Name.Label, word # issue
|
| 115 |
+
elif re.match("%.*", word):
|
| 116 |
+
yield match.start(), Name.Decorator, word # file
|
| 117 |
+
else:
|
| 118 |
+
yield match.start(), Name.Variable, word
|
| 119 |
+
|
| 120 |
+
tokens = {
|
| 121 |
+
'root': [
|
| 122 |
+
(r'\s+', Text),
|
| 123 |
+
(r'#"', String.Char, 'char'),
|
| 124 |
+
(r'#\{[0-9a-f]*\}', Number.Hex),
|
| 125 |
+
(r'2#\{', Number.Hex, 'bin2'),
|
| 126 |
+
(r'64#\{[0-9a-z+/=\s]*\}', Number.Hex),
|
| 127 |
+
(r'"', String, 'string'),
|
| 128 |
+
(r'\{', String, 'string2'),
|
| 129 |
+
(r';#+.*\n', Comment.Special),
|
| 130 |
+
(r';\*+.*\n', Comment.Preproc),
|
| 131 |
+
(r';.*\n', Comment),
|
| 132 |
+
(r'%"', Name.Decorator, 'stringFile'),
|
| 133 |
+
(r'%[^(^{")\s\[\]]+', Name.Decorator),
|
| 134 |
+
(r'[+-]?([a-z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
|
| 135 |
+
(r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
|
| 136 |
+
(r'\d+[\-/][0-9a-z]+[\-/]\d+(\/\d+\:\d+((\:\d+)?'
|
| 137 |
+
r'([.\d+]?([+-]?\d+:\d+)?)?)?)?', String.Other), # date
|
| 138 |
+
(r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
|
| 139 |
+
(r'\d+X\d+', Keyword.Constant), # pair
|
| 140 |
+
(r'[+-]?\d+(\'\d+)?([.,]\d*)?E[+-]?\d+', Number.Float),
|
| 141 |
+
(r'[+-]?\d+(\'\d+)?[.,]\d*', Number.Float),
|
| 142 |
+
(r'[+-]?\d+(\'\d+)?', Number),
|
| 143 |
+
(r'[\[\]()]', Generic.Strong),
|
| 144 |
+
(r'[a-z]+[^(^{"\s:)]*://[^(^{"\s)]*', Name.Decorator), # url
|
| 145 |
+
(r'mailto:[^(^{"@\s)]+@[^(^{"@\s)]+', Name.Decorator), # url
|
| 146 |
+
(r'[^(^{"@\s)]+@[^(^{"@\s)]+', Name.Decorator), # email
|
| 147 |
+
(r'comment\s"', Comment, 'commentString1'),
|
| 148 |
+
(r'comment\s\{', Comment, 'commentString2'),
|
| 149 |
+
(r'comment\s\[', Comment, 'commentBlock'),
|
| 150 |
+
(r'comment\s[^(\s{"\[]+', Comment),
|
| 151 |
+
(r'/[^(^{")\s/[\]]*', Name.Attribute),
|
| 152 |
+
(r'([^(^{")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
|
| 153 |
+
(r'<[\w:.-]*>', Name.Tag),
|
| 154 |
+
(r'<[^(<>\s")]+', Name.Tag, 'tag'),
|
| 155 |
+
(r'([^(^{")\s]+)', Text),
|
| 156 |
+
],
|
| 157 |
+
'string': [
|
| 158 |
+
(r'[^(^")]+', String),
|
| 159 |
+
(escape_re, String.Escape),
|
| 160 |
+
(r'[(|)]+', String),
|
| 161 |
+
(r'\^.', String.Escape),
|
| 162 |
+
(r'"', String, '#pop'),
|
| 163 |
+
],
|
| 164 |
+
'string2': [
|
| 165 |
+
(r'[^(^{})]+', String),
|
| 166 |
+
(escape_re, String.Escape),
|
| 167 |
+
(r'[(|)]+', String),
|
| 168 |
+
(r'\^.', String.Escape),
|
| 169 |
+
(r'\{', String, '#push'),
|
| 170 |
+
(r'\}', String, '#pop'),
|
| 171 |
+
],
|
| 172 |
+
'stringFile': [
|
| 173 |
+
(r'[^(^")]+', Name.Decorator),
|
| 174 |
+
(escape_re, Name.Decorator),
|
| 175 |
+
(r'\^.', Name.Decorator),
|
| 176 |
+
(r'"', Name.Decorator, '#pop'),
|
| 177 |
+
],
|
| 178 |
+
'char': [
|
| 179 |
+
(escape_re + '"', String.Char, '#pop'),
|
| 180 |
+
(r'\^."', String.Char, '#pop'),
|
| 181 |
+
(r'."', String.Char, '#pop'),
|
| 182 |
+
],
|
| 183 |
+
'tag': [
|
| 184 |
+
(escape_re, Name.Tag),
|
| 185 |
+
(r'"', Name.Tag, 'tagString'),
|
| 186 |
+
(r'[^(<>\r\n")]+', Name.Tag),
|
| 187 |
+
(r'>', Name.Tag, '#pop'),
|
| 188 |
+
],
|
| 189 |
+
'tagString': [
|
| 190 |
+
(r'[^(^")]+', Name.Tag),
|
| 191 |
+
(escape_re, Name.Tag),
|
| 192 |
+
(r'[(|)]+', Name.Tag),
|
| 193 |
+
(r'\^.', Name.Tag),
|
| 194 |
+
(r'"', Name.Tag, '#pop'),
|
| 195 |
+
],
|
| 196 |
+
'tuple': [
|
| 197 |
+
(r'(\d+\.)+', Keyword.Constant),
|
| 198 |
+
(r'\d+', Keyword.Constant, '#pop'),
|
| 199 |
+
],
|
| 200 |
+
'bin2': [
|
| 201 |
+
(r'\s+', Number.Hex),
|
| 202 |
+
(r'([01]\s*){8}', Number.Hex),
|
| 203 |
+
(r'\}', Number.Hex, '#pop'),
|
| 204 |
+
],
|
| 205 |
+
'commentString1': [
|
| 206 |
+
(r'[^(^")]+', Comment),
|
| 207 |
+
(escape_re, Comment),
|
| 208 |
+
(r'[(|)]+', Comment),
|
| 209 |
+
(r'\^.', Comment),
|
| 210 |
+
(r'"', Comment, '#pop'),
|
| 211 |
+
],
|
| 212 |
+
'commentString2': [
|
| 213 |
+
(r'[^(^{})]+', Comment),
|
| 214 |
+
(escape_re, Comment),
|
| 215 |
+
(r'[(|)]+', Comment),
|
| 216 |
+
(r'\^.', Comment),
|
| 217 |
+
(r'\{', Comment, '#push'),
|
| 218 |
+
(r'\}', Comment, '#pop'),
|
| 219 |
+
],
|
| 220 |
+
'commentBlock': [
|
| 221 |
+
(r'\[', Comment, '#push'),
|
| 222 |
+
(r'\]', Comment, '#pop'),
|
| 223 |
+
(r'"', Comment, "commentString1"),
|
| 224 |
+
(r'\{', Comment, "commentString2"),
|
| 225 |
+
(r'[^(\[\]"{)]+', Comment),
|
| 226 |
+
],
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
def analyse_text(text):
|
| 230 |
+
"""
|
| 231 |
+
Check if code contains REBOL header and so it probably not R code
|
| 232 |
+
"""
|
| 233 |
+
if re.match(r'^\s*REBOL\s*\[', text, re.IGNORECASE):
|
| 234 |
+
# The code starts with REBOL header
|
| 235 |
+
return 1.0
|
| 236 |
+
elif re.search(r'\s*REBOL\s*\[', text, re.IGNORECASE):
|
| 237 |
+
# The code contains REBOL header but also some text before it
|
| 238 |
+
return 0.5
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
class RedLexer(RegexLexer):
|
| 242 |
+
"""
|
| 243 |
+
A Red-language lexer.
|
| 244 |
+
"""
|
| 245 |
+
name = 'Red'
|
| 246 |
+
aliases = ['red', 'red/system']
|
| 247 |
+
filenames = ['*.red', '*.reds']
|
| 248 |
+
mimetypes = ['text/x-red', 'text/x-red-system']
|
| 249 |
+
url = 'https://www.red-lang.org'
|
| 250 |
+
version_added = '2.0'
|
| 251 |
+
|
| 252 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 253 |
+
|
| 254 |
+
escape_re = r'(?:\^\([0-9a-f]{1,4}\)*)'
|
| 255 |
+
|
| 256 |
+
def word_callback(lexer, match):
|
| 257 |
+
word = match.group()
|
| 258 |
+
|
| 259 |
+
if re.match(".*:$", word):
|
| 260 |
+
yield match.start(), Generic.Subheading, word
|
| 261 |
+
elif re.match(r'(if|unless|either|any|all|while|until|loop|repeat|'
|
| 262 |
+
r'foreach|forall|func|function|does|has|switch|'
|
| 263 |
+
r'case|reduce|compose|get|set|print|prin|equal\?|'
|
| 264 |
+
r'not-equal\?|strict-equal\?|lesser\?|greater\?|lesser-or-equal\?|'
|
| 265 |
+
r'greater-or-equal\?|same\?|not|type\?|stats|'
|
| 266 |
+
r'bind|union|replace|charset|routine)$', word):
|
| 267 |
+
yield match.start(), Name.Builtin, word
|
| 268 |
+
elif re.match(r'(make|random|reflect|to|form|mold|absolute|add|divide|multiply|negate|'
|
| 269 |
+
r'power|remainder|round|subtract|even\?|odd\?|and~|complement|or~|xor~|'
|
| 270 |
+
r'append|at|back|change|clear|copy|find|head|head\?|index\?|insert|'
|
| 271 |
+
r'length\?|next|pick|poke|remove|reverse|select|sort|skip|swap|tail|tail\?|'
|
| 272 |
+
r'take|trim|create|close|delete|modify|open|open\?|query|read|rename|'
|
| 273 |
+
r'update|write)$', word):
|
| 274 |
+
yield match.start(), Name.Function, word
|
| 275 |
+
elif re.match(r'(yes|on|no|off|true|false|tab|cr|lf|newline|escape|slash|sp|space|null|'
|
| 276 |
+
r'none|crlf|dot|null-byte)$', word):
|
| 277 |
+
yield match.start(), Name.Builtin.Pseudo, word
|
| 278 |
+
elif re.match(r'(#system-global|#include|#enum|#define|#either|#if|#import|#export|'
|
| 279 |
+
r'#switch|#default|#get-definition)$', word):
|
| 280 |
+
yield match.start(), Keyword.Namespace, word
|
| 281 |
+
elif re.match(r'(system|halt|quit|quit-return|do|load|q|recycle|call|run|ask|parse|'
|
| 282 |
+
r'raise-error|return|exit|break|alias|push|pop|probe|\?\?|spec-of|body-of|'
|
| 283 |
+
r'quote|forever)$', word):
|
| 284 |
+
yield match.start(), Name.Exception, word
|
| 285 |
+
elif re.match(r'(action\?|block\?|char\?|datatype\?|file\?|function\?|get-path\?|zero\?|'
|
| 286 |
+
r'get-word\?|integer\?|issue\?|lit-path\?|lit-word\?|logic\?|native\?|'
|
| 287 |
+
r'op\?|paren\?|path\?|refinement\?|set-path\?|set-word\?|string\?|unset\?|'
|
| 288 |
+
r'any-struct\?|none\?|word\?|any-series\?)$', word):
|
| 289 |
+
yield match.start(), Keyword, word
|
| 290 |
+
elif re.match(r'(JNICALL|stdcall|cdecl|infix)$', word):
|
| 291 |
+
yield match.start(), Keyword.Namespace, word
|
| 292 |
+
elif re.match("to-.*", word):
|
| 293 |
+
yield match.start(), Keyword, word
|
| 294 |
+
elif re.match(r'(\+|-\*\*|-|\*\*|//|/|\*|and|or|xor|=\?|===|==|=|<>|<=|>=|'
|
| 295 |
+
r'<<<|>>>|<<|>>|<|>%)$', word):
|
| 296 |
+
yield match.start(), Operator, word
|
| 297 |
+
elif re.match(r".*\!$", word):
|
| 298 |
+
yield match.start(), Keyword.Type, word
|
| 299 |
+
elif re.match("'.*", word):
|
| 300 |
+
yield match.start(), Name.Variable.Instance, word # lit-word
|
| 301 |
+
elif re.match("#.*", word):
|
| 302 |
+
yield match.start(), Name.Label, word # issue
|
| 303 |
+
elif re.match("%.*", word):
|
| 304 |
+
yield match.start(), Name.Decorator, word # file
|
| 305 |
+
elif re.match(":.*", word):
|
| 306 |
+
yield match.start(), Generic.Subheading, word # get-word
|
| 307 |
+
else:
|
| 308 |
+
yield match.start(), Name.Variable, word
|
| 309 |
+
|
| 310 |
+
tokens = {
|
| 311 |
+
'root': [
|
| 312 |
+
(r'\s+', Text),
|
| 313 |
+
(r'#"', String.Char, 'char'),
|
| 314 |
+
(r'#\{[0-9a-f\s]*\}', Number.Hex),
|
| 315 |
+
(r'2#\{', Number.Hex, 'bin2'),
|
| 316 |
+
(r'64#\{[0-9a-z+/=\s]*\}', Number.Hex),
|
| 317 |
+
(r'([0-9a-f]+)(h)((\s)|(?=[\[\]{}"()]))',
|
| 318 |
+
bygroups(Number.Hex, Name.Variable, Whitespace)),
|
| 319 |
+
(r'"', String, 'string'),
|
| 320 |
+
(r'\{', String, 'string2'),
|
| 321 |
+
(r';#+.*\n', Comment.Special),
|
| 322 |
+
(r';\*+.*\n', Comment.Preproc),
|
| 323 |
+
(r';.*\n', Comment),
|
| 324 |
+
(r'%"', Name.Decorator, 'stringFile'),
|
| 325 |
+
(r'%[^(^{")\s\[\]]+', Name.Decorator),
|
| 326 |
+
(r'[+-]?([a-z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
|
| 327 |
+
(r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
|
| 328 |
+
(r'\d+[\-/][0-9a-z]+[\-/]\d+(/\d+:\d+((:\d+)?'
|
| 329 |
+
r'([\.\d+]?([+-]?\d+:\d+)?)?)?)?', String.Other), # date
|
| 330 |
+
(r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
|
| 331 |
+
(r'\d+X\d+', Keyword.Constant), # pair
|
| 332 |
+
(r'[+-]?\d+(\'\d+)?([.,]\d*)?E[+-]?\d+', Number.Float),
|
| 333 |
+
(r'[+-]?\d+(\'\d+)?[.,]\d*', Number.Float),
|
| 334 |
+
(r'[+-]?\d+(\'\d+)?', Number),
|
| 335 |
+
(r'[\[\]()]', Generic.Strong),
|
| 336 |
+
(r'[a-z]+[^(^{"\s:)]*://[^(^{"\s)]*', Name.Decorator), # url
|
| 337 |
+
(r'mailto:[^(^{"@\s)]+@[^(^{"@\s)]+', Name.Decorator), # url
|
| 338 |
+
(r'[^(^{"@\s)]+@[^(^{"@\s)]+', Name.Decorator), # email
|
| 339 |
+
(r'comment\s"', Comment, 'commentString1'),
|
| 340 |
+
(r'comment\s\{', Comment, 'commentString2'),
|
| 341 |
+
(r'comment\s\[', Comment, 'commentBlock'),
|
| 342 |
+
(r'comment\s[^(\s{"\[]+', Comment),
|
| 343 |
+
(r'/[^(^{^")\s/[\]]*', Name.Attribute),
|
| 344 |
+
(r'([^(^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
|
| 345 |
+
(r'<[\w:.-]*>', Name.Tag),
|
| 346 |
+
(r'<[^(<>\s")]+', Name.Tag, 'tag'),
|
| 347 |
+
(r'([^(^{")\s]+)', Text),
|
| 348 |
+
],
|
| 349 |
+
'string': [
|
| 350 |
+
(r'[^(^")]+', String),
|
| 351 |
+
(escape_re, String.Escape),
|
| 352 |
+
(r'[(|)]+', String),
|
| 353 |
+
(r'\^.', String.Escape),
|
| 354 |
+
(r'"', String, '#pop'),
|
| 355 |
+
],
|
| 356 |
+
'string2': [
|
| 357 |
+
(r'[^(^{})]+', String),
|
| 358 |
+
(escape_re, String.Escape),
|
| 359 |
+
(r'[(|)]+', String),
|
| 360 |
+
(r'\^.', String.Escape),
|
| 361 |
+
(r'\{', String, '#push'),
|
| 362 |
+
(r'\}', String, '#pop'),
|
| 363 |
+
],
|
| 364 |
+
'stringFile': [
|
| 365 |
+
(r'[^(^")]+', Name.Decorator),
|
| 366 |
+
(escape_re, Name.Decorator),
|
| 367 |
+
(r'\^.', Name.Decorator),
|
| 368 |
+
(r'"', Name.Decorator, '#pop'),
|
| 369 |
+
],
|
| 370 |
+
'char': [
|
| 371 |
+
(escape_re + '"', String.Char, '#pop'),
|
| 372 |
+
(r'\^."', String.Char, '#pop'),
|
| 373 |
+
(r'."', String.Char, '#pop'),
|
| 374 |
+
],
|
| 375 |
+
'tag': [
|
| 376 |
+
(escape_re, Name.Tag),
|
| 377 |
+
(r'"', Name.Tag, 'tagString'),
|
| 378 |
+
(r'[^(<>\r\n")]+', Name.Tag),
|
| 379 |
+
(r'>', Name.Tag, '#pop'),
|
| 380 |
+
],
|
| 381 |
+
'tagString': [
|
| 382 |
+
(r'[^(^")]+', Name.Tag),
|
| 383 |
+
(escape_re, Name.Tag),
|
| 384 |
+
(r'[(|)]+', Name.Tag),
|
| 385 |
+
(r'\^.', Name.Tag),
|
| 386 |
+
(r'"', Name.Tag, '#pop'),
|
| 387 |
+
],
|
| 388 |
+
'tuple': [
|
| 389 |
+
(r'(\d+\.)+', Keyword.Constant),
|
| 390 |
+
(r'\d+', Keyword.Constant, '#pop'),
|
| 391 |
+
],
|
| 392 |
+
'bin2': [
|
| 393 |
+
(r'\s+', Number.Hex),
|
| 394 |
+
(r'([01]\s*){8}', Number.Hex),
|
| 395 |
+
(r'\}', Number.Hex, '#pop'),
|
| 396 |
+
],
|
| 397 |
+
'commentString1': [
|
| 398 |
+
(r'[^(^")]+', Comment),
|
| 399 |
+
(escape_re, Comment),
|
| 400 |
+
(r'[(|)]+', Comment),
|
| 401 |
+
(r'\^.', Comment),
|
| 402 |
+
(r'"', Comment, '#pop'),
|
| 403 |
+
],
|
| 404 |
+
'commentString2': [
|
| 405 |
+
(r'[^(^{})]+', Comment),
|
| 406 |
+
(escape_re, Comment),
|
| 407 |
+
(r'[(|)]+', Comment),
|
| 408 |
+
(r'\^.', Comment),
|
| 409 |
+
(r'\{', Comment, '#push'),
|
| 410 |
+
(r'\}', Comment, '#pop'),
|
| 411 |
+
],
|
| 412 |
+
'commentBlock': [
|
| 413 |
+
(r'\[', Comment, '#push'),
|
| 414 |
+
(r'\]', Comment, '#pop'),
|
| 415 |
+
(r'"', Comment, "commentString1"),
|
| 416 |
+
(r'\{', Comment, "commentString2"),
|
| 417 |
+
(r'[^(\[\]"{)]+', Comment),
|
| 418 |
+
],
|
| 419 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rego.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.rego
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Rego policy languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, Number, Punctuation, Whitespace
|
| 13 |
+
|
| 14 |
+
class RegoLexer(RegexLexer):
|
| 15 |
+
"""
|
| 16 |
+
For Rego source.
|
| 17 |
+
"""
|
| 18 |
+
name = 'Rego'
|
| 19 |
+
url = 'https://www.openpolicyagent.org/docs/latest/policy-language/'
|
| 20 |
+
filenames = ['*.rego']
|
| 21 |
+
aliases = ['rego']
|
| 22 |
+
mimetypes = ['text/x-rego']
|
| 23 |
+
version_added = '2.19'
|
| 24 |
+
|
| 25 |
+
reserved_words = (
|
| 26 |
+
'as', 'contains', 'data', 'default', 'else', 'every', 'false',
|
| 27 |
+
'if', 'in', 'import', 'package', 'not', 'null',
|
| 28 |
+
'some', 'true', 'with'
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
builtins = (
|
| 32 |
+
# https://www.openpolicyagent.org/docs/latest/philosophy/#the-opa-document-model
|
| 33 |
+
'data', # Global variable for accessing base and virtual documents
|
| 34 |
+
'input', # Represents synchronously pushed base documents
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
tokens = {
|
| 38 |
+
'root': [
|
| 39 |
+
(r'\n', Whitespace),
|
| 40 |
+
(r'\s+', Whitespace),
|
| 41 |
+
(r'#.*?$', Comment.Single),
|
| 42 |
+
(words(reserved_words, suffix=r'\b'), Keyword),
|
| 43 |
+
(words(builtins, suffix=r'\b'), Name.Builtin),
|
| 44 |
+
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
|
| 45 |
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
| 46 |
+
(r'`[^`]*`', String.Backtick),
|
| 47 |
+
(r'-?\d+(\.\d+)?', Number),
|
| 48 |
+
(r'(==|!=|<=|>=|:=)', Operator), # Compound operators
|
| 49 |
+
(r'[=<>+\-*/%&|]', Operator), # Single-character operators
|
| 50 |
+
(r'[\[\]{}(),.:;]', Punctuation),
|
| 51 |
+
]
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
__all__ = ['RegoLexer']
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rell.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.rell
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Rell language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, default, words
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, String, Number, \
|
| 13 |
+
Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['RellLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class RellLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
A Lexer for Rell.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Rell'
|
| 23 |
+
url = 'https://docs.chromia.com/rell/rell-intro'
|
| 24 |
+
aliases = ['rell']
|
| 25 |
+
filenames = ['*.rell']
|
| 26 |
+
mimetypes = ['text/x-rell']
|
| 27 |
+
version_added = '2.20'
|
| 28 |
+
|
| 29 |
+
ident = r'[a-zA-Z_][a-zA-Z0-9_]*'
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'root': [
|
| 33 |
+
(words((
|
| 34 |
+
'big_integer', 'boolean', 'byte_array', 'decimal', 'gtv',
|
| 35 |
+
'integer', 'json', 'list', 'map', 'mutable', 'set', 'text',
|
| 36 |
+
'virtual'), suffix=r'\b'),
|
| 37 |
+
Keyword.Type),
|
| 38 |
+
(r'(false|true|null)\b', Keyword.Constant),
|
| 39 |
+
(r'(entity|enum|namespace|object|struct)\b', Keyword.Declaration),
|
| 40 |
+
(r'(function|operation|query)\b', Keyword.Declaration, 'function'),
|
| 41 |
+
(words((
|
| 42 |
+
'abstract', 'and', 'break', 'continue', 'create', 'delete',
|
| 43 |
+
'else', 'for', 'if', 'import', 'in', 'index', 'key', 'limit',
|
| 44 |
+
'module', 'not', 'offset', 'or', 'override', 'return', 'update',
|
| 45 |
+
'val', 'var', 'when', 'while'), suffix=r'\b'),
|
| 46 |
+
Keyword.Reserved),
|
| 47 |
+
(r'//.*?$', Comment.Single),
|
| 48 |
+
(r'/\*(.|\n|\r)*?\*/', Comment.Multiline),
|
| 49 |
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
| 50 |
+
(r'\'(\\\\|\\\'|[^\\\'])*\'', String.Single),
|
| 51 |
+
(r'-?[0-9]*\.[0-9]+([eE][+-][0-9]+)?', Number.Float),
|
| 52 |
+
(r'-?[0-9]+([eE][+-][0-9]+|[lL])?', Number.Integer),
|
| 53 |
+
(r'x(\'[a-fA-F0-9]*\'|"[a-fA-F0-9]*")', String.Binary),
|
| 54 |
+
(r'(\.)([ \n\t\r]*)(' + ident + ')',
|
| 55 |
+
bygroups(Punctuation, Whitespace, Name.Attribute)),
|
| 56 |
+
(r'[{}():;,]+', Punctuation),
|
| 57 |
+
(r'[ \n\t\r]+', Whitespace),
|
| 58 |
+
(r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Decorator),
|
| 59 |
+
(r'[~^*!%&\[\]<>|+=/?\-@\$]', Punctuation.Marker),
|
| 60 |
+
(ident, Name),
|
| 61 |
+
(r'(\.)+', Punctuation),
|
| 62 |
+
],
|
| 63 |
+
'function': [
|
| 64 |
+
(r'[ \n\t\r]+', Whitespace),
|
| 65 |
+
(ident, Name.Function, '#pop'),
|
| 66 |
+
default('#pop'),
|
| 67 |
+
],
|
| 68 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/resource.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.resource
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for resource definition files.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, bygroups, words
|
| 14 |
+
from pygments.token import Comment, String, Number, Operator, Text, \
|
| 15 |
+
Keyword, Name
|
| 16 |
+
|
| 17 |
+
__all__ = ['ResourceLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class ResourceLexer(RegexLexer):
|
| 21 |
+
"""Lexer for ICU Resource bundles.
|
| 22 |
+
"""
|
| 23 |
+
name = 'ResourceBundle'
|
| 24 |
+
aliases = ['resourcebundle', 'resource']
|
| 25 |
+
filenames = []
|
| 26 |
+
url = 'https://unicode-org.github.io/icu/userguide/locale/resources.html'
|
| 27 |
+
version_added = '2.0'
|
| 28 |
+
|
| 29 |
+
_types = (':table', ':array', ':string', ':bin', ':import', ':intvector',
|
| 30 |
+
':int', ':alias')
|
| 31 |
+
|
| 32 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 33 |
+
tokens = {
|
| 34 |
+
'root': [
|
| 35 |
+
(r'//.*?$', Comment),
|
| 36 |
+
(r'"', String, 'string'),
|
| 37 |
+
(r'-?\d+', Number.Integer),
|
| 38 |
+
(r'[,{}]', Operator),
|
| 39 |
+
(r'([^\s{{:]+)(\s*)({}?)'.format('|'.join(_types)),
|
| 40 |
+
bygroups(Name, Text, Keyword)),
|
| 41 |
+
(r'\s+', Text),
|
| 42 |
+
(words(_types), Keyword),
|
| 43 |
+
],
|
| 44 |
+
'string': [
|
| 45 |
+
(r'(\\x[0-9a-f]{2}|\\u[0-9a-f]{4}|\\U00[0-9a-f]{6}|'
|
| 46 |
+
r'\\[0-7]{1,3}|\\c.|\\[abtnvfre\'"?\\]|\\\{|[^"{\\])+', String),
|
| 47 |
+
(r'\{', String.Escape, 'msgname'),
|
| 48 |
+
(r'"', String, '#pop')
|
| 49 |
+
],
|
| 50 |
+
'msgname': [
|
| 51 |
+
(r'([^{},]+)(\s*)', bygroups(Name, String.Escape), ('#pop', 'message'))
|
| 52 |
+
],
|
| 53 |
+
'message': [
|
| 54 |
+
(r'\{', String.Escape, 'msgname'),
|
| 55 |
+
(r'\}', String.Escape, '#pop'),
|
| 56 |
+
(r'(,)(\s*)([a-z]+)(\s*\})',
|
| 57 |
+
bygroups(Operator, String.Escape, Keyword, String.Escape), '#pop'),
|
| 58 |
+
(r'(,)(\s*)([a-z]+)(\s*)(,)(\s*)(offset)(\s*)(:)(\s*)(-?\d+)(\s*)',
|
| 59 |
+
bygroups(Operator, String.Escape, Keyword, String.Escape, Operator,
|
| 60 |
+
String.Escape, Operator.Word, String.Escape, Operator,
|
| 61 |
+
String.Escape, Number.Integer, String.Escape), 'choice'),
|
| 62 |
+
(r'(,)(\s*)([a-z]+)(\s*)(,)(\s*)',
|
| 63 |
+
bygroups(Operator, String.Escape, Keyword, String.Escape, Operator,
|
| 64 |
+
String.Escape), 'choice'),
|
| 65 |
+
(r'\s+', String.Escape)
|
| 66 |
+
],
|
| 67 |
+
'choice': [
|
| 68 |
+
(r'(=|<|>|<=|>=|!=)(-?\d+)(\s*\{)',
|
| 69 |
+
bygroups(Operator, Number.Integer, String.Escape), 'message'),
|
| 70 |
+
(r'([a-z]+)(\s*\{)', bygroups(Keyword.Type, String.Escape), 'str'),
|
| 71 |
+
(r'\}', String.Escape, ('#pop', '#pop')),
|
| 72 |
+
(r'\s+', String.Escape)
|
| 73 |
+
],
|
| 74 |
+
'str': [
|
| 75 |
+
(r'\}', String.Escape, '#pop'),
|
| 76 |
+
(r'\{', String.Escape, 'msgname'),
|
| 77 |
+
(r'[^{}]+', String)
|
| 78 |
+
]
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
def analyse_text(text):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| 5 |
+
Lexer for the Ride programming language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words, include
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Punctuation, \
|
| 13 |
+
String, Text
|
| 14 |
+
|
| 15 |
+
__all__ = ['RideLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class RideLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Ride source code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Ride'
|
| 24 |
+
aliases = ['ride']
|
| 25 |
+
filenames = ['*.ride']
|
| 26 |
+
mimetypes = ['text/x-ride']
|
| 27 |
+
url = 'https://docs.waves.tech/en/ride'
|
| 28 |
+
version_added = '2.6'
|
| 29 |
+
|
| 30 |
+
validName = r'[a-zA-Z_][a-zA-Z0-9_\']*'
|
| 31 |
+
|
| 32 |
+
builtinOps = (
|
| 33 |
+
'||', '|', '>=', '>', '==', '!',
|
| 34 |
+
'=', '<=', '<', '::', ':+', ':', '!=', '/',
|
| 35 |
+
'.', '=>', '-', '+', '*', '&&', '%', '++',
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
globalVariablesName = (
|
| 39 |
+
'NOALG', 'MD5', 'SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512',
|
| 40 |
+
'SHA3224', 'SHA3256', 'SHA3384', 'SHA3512', 'nil', 'this', 'unit',
|
| 41 |
+
'height', 'lastBlock', 'Buy', 'Sell', 'CEILING', 'FLOOR', 'DOWN',
|
| 42 |
+
'HALFDOWN', 'HALFEVEN', 'HALFUP', 'UP',
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
typesName = (
|
| 46 |
+
'Unit', 'Int', 'Boolean', 'ByteVector', 'String', 'Address', 'Alias',
|
| 47 |
+
'Transfer', 'AssetPair', 'DataEntry', 'Order', 'Transaction',
|
| 48 |
+
'GenesisTransaction', 'PaymentTransaction', 'ReissueTransaction',
|
| 49 |
+
'BurnTransaction', 'MassTransferTransaction', 'ExchangeTransaction',
|
| 50 |
+
'TransferTransaction', 'SetAssetScriptTransaction',
|
| 51 |
+
'InvokeScriptTransaction', 'IssueTransaction', 'LeaseTransaction',
|
| 52 |
+
'LeaseCancelTransaction', 'CreateAliasTransaction',
|
| 53 |
+
'SetScriptTransaction', 'SponsorFeeTransaction', 'DataTransaction',
|
| 54 |
+
'WriteSet', 'AttachedPayment', 'ScriptTransfer', 'TransferSet',
|
| 55 |
+
'ScriptResult', 'Invocation', 'Asset', 'BlockInfo', 'Issue', 'Reissue',
|
| 56 |
+
'Burn', 'NoAlg', 'Md5', 'Sha1', 'Sha224', 'Sha256', 'Sha384', 'Sha512',
|
| 57 |
+
'Sha3224', 'Sha3256', 'Sha3384', 'Sha3512', 'BinaryEntry',
|
| 58 |
+
'BooleanEntry', 'IntegerEntry', 'StringEntry', 'List', 'Ceiling',
|
| 59 |
+
'Down', 'Floor', 'HalfDown', 'HalfEven', 'HalfUp', 'Up',
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
functionsName = (
|
| 63 |
+
'fraction', 'size', 'toBytes', 'take', 'drop', 'takeRight', 'dropRight',
|
| 64 |
+
'toString', 'isDefined', 'extract', 'throw', 'getElement', 'value',
|
| 65 |
+
'cons', 'toUtf8String', 'toInt', 'indexOf', 'lastIndexOf', 'split',
|
| 66 |
+
'parseInt', 'parseIntValue', 'keccak256', 'blake2b256', 'sha256',
|
| 67 |
+
'sigVerify', 'toBase58String', 'fromBase58String', 'toBase64String',
|
| 68 |
+
'fromBase64String', 'transactionById', 'transactionHeightById',
|
| 69 |
+
'getInteger', 'getBoolean', 'getBinary', 'getString',
|
| 70 |
+
'addressFromPublicKey', 'addressFromString', 'addressFromRecipient',
|
| 71 |
+
'assetBalance', 'wavesBalance', 'getIntegerValue', 'getBooleanValue',
|
| 72 |
+
'getBinaryValue', 'getStringValue', 'addressFromStringValue',
|
| 73 |
+
'assetInfo', 'rsaVerify', 'checkMerkleProof', 'median',
|
| 74 |
+
'valueOrElse', 'valueOrErrorMessage', 'contains', 'log', 'pow',
|
| 75 |
+
'toBase16String', 'fromBase16String', 'blockInfoByHeight',
|
| 76 |
+
'transferTransactionById',
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
reservedWords = words((
|
| 80 |
+
'match', 'case', 'else', 'func', 'if',
|
| 81 |
+
'let', 'then', '@Callable', '@Verifier',
|
| 82 |
+
), suffix=r'\b')
|
| 83 |
+
|
| 84 |
+
tokens = {
|
| 85 |
+
'root': [
|
| 86 |
+
# Comments
|
| 87 |
+
(r'#.*', Comment.Single),
|
| 88 |
+
# Whitespace
|
| 89 |
+
(r'\s+', Text),
|
| 90 |
+
# Strings
|
| 91 |
+
(r'"', String, 'doublequote'),
|
| 92 |
+
(r'utf8\'', String, 'utf8quote'),
|
| 93 |
+
(r'base(58|64|16)\'', String, 'singlequote'),
|
| 94 |
+
# Keywords
|
| 95 |
+
(reservedWords, Keyword.Reserved),
|
| 96 |
+
(r'\{-#.*?#-\}', Keyword.Reserved),
|
| 97 |
+
(r'FOLD<\d+>', Keyword.Reserved),
|
| 98 |
+
# Types
|
| 99 |
+
(words(typesName), Keyword.Type),
|
| 100 |
+
# Main
|
| 101 |
+
# (specialName, Keyword.Reserved),
|
| 102 |
+
# Prefix Operators
|
| 103 |
+
(words(builtinOps, prefix=r'\(', suffix=r'\)'), Name.Function),
|
| 104 |
+
# Infix Operators
|
| 105 |
+
(words(builtinOps), Name.Function),
|
| 106 |
+
(words(globalVariablesName), Name.Function),
|
| 107 |
+
(words(functionsName), Name.Function),
|
| 108 |
+
# Numbers
|
| 109 |
+
include('numbers'),
|
| 110 |
+
# Variable Names
|
| 111 |
+
(validName, Name.Variable),
|
| 112 |
+
# Parens
|
| 113 |
+
(r'[,()\[\]{}]', Punctuation),
|
| 114 |
+
],
|
| 115 |
+
|
| 116 |
+
'doublequote': [
|
| 117 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 118 |
+
(r'\\[nrfvb\\"]', String.Escape),
|
| 119 |
+
(r'[^"]', String),
|
| 120 |
+
(r'"', String, '#pop'),
|
| 121 |
+
],
|
| 122 |
+
|
| 123 |
+
'utf8quote': [
|
| 124 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 125 |
+
(r'\\[nrfvb\\\']', String.Escape),
|
| 126 |
+
(r'[^\']', String),
|
| 127 |
+
(r'\'', String, '#pop'),
|
| 128 |
+
],
|
| 129 |
+
|
| 130 |
+
'singlequote': [
|
| 131 |
+
(r'[^\']', String),
|
| 132 |
+
(r'\'', String, '#pop'),
|
| 133 |
+
],
|
| 134 |
+
|
| 135 |
+
'numbers': [
|
| 136 |
+
(r'_?\d+', Number.Integer),
|
| 137 |
+
],
|
| 138 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rita.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.rita
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for RITA language
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, Literal, \
|
| 13 |
+
Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['RitaLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class RitaLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for RITA.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Rita'
|
| 23 |
+
url = 'https://github.com/zaibacu/rita-dsl'
|
| 24 |
+
filenames = ['*.rita']
|
| 25 |
+
aliases = ['rita']
|
| 26 |
+
mimetypes = ['text/rita']
|
| 27 |
+
version_added = '2.11'
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
'root': [
|
| 31 |
+
(r'\n', Whitespace),
|
| 32 |
+
(r'\s+', Whitespace),
|
| 33 |
+
(r'#(.*?)\n', Comment.Single),
|
| 34 |
+
(r'@(.*?)\n', Operator), # Yes, whole line as an operator
|
| 35 |
+
(r'"(\w|\d|\s|(\\")|[\'_\-./,\?\!])+?"', Literal),
|
| 36 |
+
(r'\'(\w|\d|\s|(\\\')|["_\-./,\?\!])+?\'', Literal),
|
| 37 |
+
(r'([A-Z_]+)', Keyword),
|
| 38 |
+
(r'([a-z0-9_]+)', Name),
|
| 39 |
+
(r'((->)|[!?+*|=])', Operator),
|
| 40 |
+
(r'[\(\),\{\}]', Punctuation)
|
| 41 |
+
]
|
| 42 |
+
}
|
.cache/uv/archive-v0/OfMJ6Jow23GMtj-2CxZC6/pygments/lexers/rnc.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.rnc
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Relax-NG Compact syntax
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['RNCCompactLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class RNCCompactLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For RelaxNG-compact syntax.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Relax-NG Compact'
|
| 24 |
+
url = 'http://relaxng.org'
|
| 25 |
+
aliases = ['rng-compact', 'rnc']
|
| 26 |
+
filenames = ['*.rnc']
|
| 27 |
+
version_added = '2.2'
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
'root': [
|
| 31 |
+
(r'namespace\b', Keyword.Namespace),
|
| 32 |
+
(r'(?:default|datatypes)\b', Keyword.Declaration),
|
| 33 |
+
(r'##.*$', Comment.Preproc),
|
| 34 |
+
(r'#.*$', Comment.Single),
|
| 35 |
+
(r'"[^"]*"', String.Double),
|
| 36 |
+
# TODO single quoted strings and escape sequences outside of
|
| 37 |
+
# double-quoted strings
|
| 38 |
+
(r'(?:element|attribute|mixed)\b', Keyword.Declaration, 'variable'),
|
| 39 |
+
(r'(text\b|xsd:[^ ]+)', Keyword.Type, 'maybe_xsdattributes'),
|
| 40 |
+
(r'[,?&*=|~]|>>', Operator),
|
| 41 |
+
(r'[(){}]', Punctuation),
|
| 42 |
+
(r'.', Text),
|
| 43 |
+
],
|
| 44 |
+
|
| 45 |
+
# a variable has been declared using `element` or `attribute`
|
| 46 |
+
'variable': [
|
| 47 |
+
(r'[^{]+', Name.Variable),
|
| 48 |
+
(r'\{', Punctuation, '#pop'),
|
| 49 |
+
],
|
| 50 |
+
|
| 51 |
+
# after an xsd:<datatype> declaration there may be attributes
|
| 52 |
+
'maybe_xsdattributes': [
|
| 53 |
+
(r'\{', Punctuation, 'xsdattributes'),
|
| 54 |
+
(r'\}', Punctuation, '#pop'),
|
| 55 |
+
(r'.', Text),
|
| 56 |
+
],
|
| 57 |
+
|
| 58 |
+
# attributes take the form { key1 = value1 key2 = value2 ... }
|
| 59 |
+
'xsdattributes': [
|
| 60 |
+
(r'[^ =}]', Name.Attribute),
|
| 61 |
+
(r'=', Operator),
|
| 62 |
+
(r'"[^"]*"', String.Double),
|
| 63 |
+
(r'\}', Punctuation, '#pop'),
|
| 64 |
+
(r'.', Text),
|
| 65 |
+
],
|
| 66 |
+
}
|