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/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/oberon.py +120 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/objective.py +513 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/ooc.py +84 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/openscad.py +96 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/other.py +41 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/parasail.py +78 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/parsers.py +798 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/pascal.py +644 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/pawn.py +202 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/pddl.py +82 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/perl.py +733 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/phix.py +363 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/php.py +335 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/pointless.py +70 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/pony.py +93 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/praat.py +303 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/procfile.py +41 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/prolog.py +318 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/promql.py +176 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/savi.py +171 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/scdoc.py +85 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/scripting.py +1638 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/sgf.py +59 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/shell.py +902 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/sieve.py +78 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/slash.py +183 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/smalltalk.py +194 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/smithy.py +77 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/smv.py +78 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/snobol.py +82 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/solidity.py +87 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/soong.py +78 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/sophia.py +102 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/special.py +122 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/spice.py +70 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/sql.py +1111 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/srcinfo.py +62 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/stata.py +170 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/supercollider.py +94 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/tablegen.py +177 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/tact.py +303 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/tal.py +77 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/tcl.py +148 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/teal.py +88 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/templates.py +2355 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/teraterm.py +335 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/testing.py +209 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/text.py +27 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/textedit.py +205 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/textfmts.py +436 -0
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/oberon.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.oberon
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Oberon 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, 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/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/objective.py
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.objective
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Objective-C 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, 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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/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_]*', # float exp
|
| 74 |
+
Number.Float),
|
| 75 |
+
(r'\d[0-9_]*\.\d[0-9_]*', Number.Float), # float
|
| 76 |
+
(r'\d[0-9_]*', Number.Integer), # integer
|
| 77 |
+
],
|
| 78 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/parsers.py
ADDED
|
@@ -0,0 +1,798 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.parsers
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for parser generators.
|
| 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, 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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/pawn.py
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/php.py
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
| 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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/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.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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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/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/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/promql.py
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.promql
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Prometheus 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 |
+
(r"[1-9][0-9]*[smhdwy]", String),
|
| 170 |
+
],
|
| 171 |
+
"function": [
|
| 172 |
+
(r"\)", Operator, "#pop"),
|
| 173 |
+
(r"\(", Operator, "#push"),
|
| 174 |
+
default("#pop"),
|
| 175 |
+
],
|
| 176 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/savi.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.savi
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Savi.
|
| 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
|
| 12 |
+
from pygments.token import Whitespace, Keyword, Name, String, Number, \
|
| 13 |
+
Operator, Punctuation, Comment, Generic, Error
|
| 14 |
+
|
| 15 |
+
__all__ = ['SaviLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# The canonical version of this file can be found in the following repository,
|
| 19 |
+
# where it is kept in sync with any language changes, as well as the other
|
| 20 |
+
# pygments-like lexers that are maintained for use with other tools:
|
| 21 |
+
# - https://github.com/savi-lang/savi/blob/main/tooling/pygments/lexers/savi.py
|
| 22 |
+
#
|
| 23 |
+
# If you're changing this file in the pygments repository, please ensure that
|
| 24 |
+
# any changes you make are also propagated to the official Savi repository,
|
| 25 |
+
# in order to avoid accidental clobbering of your changes later when an update
|
| 26 |
+
# from the Savi repository flows forward into the pygments repository.
|
| 27 |
+
#
|
| 28 |
+
# If you're changing this file in the Savi repository, please ensure that
|
| 29 |
+
# any changes you make are also reflected in the other pygments-like lexers
|
| 30 |
+
# (rouge, vscode, etc) so that all of the lexers can be kept cleanly in sync.
|
| 31 |
+
|
| 32 |
+
class SaviLexer(RegexLexer):
|
| 33 |
+
"""
|
| 34 |
+
For Savi source code.
|
| 35 |
+
|
| 36 |
+
.. versionadded: 2.10
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
name = 'Savi'
|
| 40 |
+
url = 'https://github.com/savi-lang/savi'
|
| 41 |
+
aliases = ['savi']
|
| 42 |
+
filenames = ['*.savi']
|
| 43 |
+
version_added = ''
|
| 44 |
+
|
| 45 |
+
tokens = {
|
| 46 |
+
"root": [
|
| 47 |
+
# Line Comment
|
| 48 |
+
(r'//.*?$', Comment.Single),
|
| 49 |
+
|
| 50 |
+
# Doc Comment
|
| 51 |
+
(r'::.*?$', Comment.Single),
|
| 52 |
+
|
| 53 |
+
# Capability Operator
|
| 54 |
+
(r'(\')(\w+)(?=[^\'])', bygroups(Operator, Name)),
|
| 55 |
+
|
| 56 |
+
# Double-Quote String
|
| 57 |
+
(r'\w?"', String.Double, "string.double"),
|
| 58 |
+
|
| 59 |
+
# Single-Char String
|
| 60 |
+
(r"'", String.Char, "string.char"),
|
| 61 |
+
|
| 62 |
+
# Type Name
|
| 63 |
+
(r'(_?[A-Z]\w*)', Name.Class),
|
| 64 |
+
|
| 65 |
+
# Nested Type Name
|
| 66 |
+
(r'(\.)(\s*)(_?[A-Z]\w*)', bygroups(Punctuation, Whitespace, Name.Class)),
|
| 67 |
+
|
| 68 |
+
# Declare
|
| 69 |
+
(r'^([ \t]*)(:\w+)',
|
| 70 |
+
bygroups(Whitespace, Name.Tag),
|
| 71 |
+
"decl"),
|
| 72 |
+
|
| 73 |
+
# Error-Raising Calls/Names
|
| 74 |
+
(r'((\w+|\+|\-|\*)\!)', Generic.Deleted),
|
| 75 |
+
|
| 76 |
+
# Numeric Values
|
| 77 |
+
(r'\b\d([\d_]*(\.[\d_]+)?)\b', Number),
|
| 78 |
+
|
| 79 |
+
# Hex Numeric Values
|
| 80 |
+
(r'\b0x([0-9a-fA-F_]+)\b', Number.Hex),
|
| 81 |
+
|
| 82 |
+
# Binary Numeric Values
|
| 83 |
+
(r'\b0b([01_]+)\b', Number.Bin),
|
| 84 |
+
|
| 85 |
+
# Function Call (with braces)
|
| 86 |
+
(r'\w+(?=\()', Name.Function),
|
| 87 |
+
|
| 88 |
+
# Function Call (with receiver)
|
| 89 |
+
(r'(\.)(\s*)(\w+)', bygroups(Punctuation, Whitespace, Name.Function)),
|
| 90 |
+
|
| 91 |
+
# Function Call (with self receiver)
|
| 92 |
+
(r'(@)(\w+)', bygroups(Punctuation, Name.Function)),
|
| 93 |
+
|
| 94 |
+
# Parenthesis
|
| 95 |
+
(r'\(', Punctuation, "root"),
|
| 96 |
+
(r'\)', Punctuation, "#pop"),
|
| 97 |
+
|
| 98 |
+
# Brace
|
| 99 |
+
(r'\{', Punctuation, "root"),
|
| 100 |
+
(r'\}', Punctuation, "#pop"),
|
| 101 |
+
|
| 102 |
+
# Bracket
|
| 103 |
+
(r'\[', Punctuation, "root"),
|
| 104 |
+
(r'(\])(\!)', bygroups(Punctuation, Generic.Deleted), "#pop"),
|
| 105 |
+
(r'\]', Punctuation, "#pop"),
|
| 106 |
+
|
| 107 |
+
# Punctuation
|
| 108 |
+
(r'[,;:\.@]', Punctuation),
|
| 109 |
+
|
| 110 |
+
# Piping Operators
|
| 111 |
+
(r'(\|\>)', Operator),
|
| 112 |
+
|
| 113 |
+
# Branching Operators
|
| 114 |
+
(r'(\&\&|\|\||\?\?|\&\?|\|\?|\.\?)', Operator),
|
| 115 |
+
|
| 116 |
+
# Comparison Operators
|
| 117 |
+
(r'(\<\=\>|\=\~|\=\=|\<\=|\>\=|\<|\>)', Operator),
|
| 118 |
+
|
| 119 |
+
# Arithmetic Operators
|
| 120 |
+
(r'(\+|\-|\/|\*|\%)', Operator),
|
| 121 |
+
|
| 122 |
+
# Assignment Operators
|
| 123 |
+
(r'(\=)', Operator),
|
| 124 |
+
|
| 125 |
+
# Other Operators
|
| 126 |
+
(r'(\!|\<\<|\<|\&|\|)', Operator),
|
| 127 |
+
|
| 128 |
+
# Identifiers
|
| 129 |
+
(r'\b\w+\b', Name),
|
| 130 |
+
|
| 131 |
+
# Whitespace
|
| 132 |
+
(r'[ \t\r]+\n*|\n+', Whitespace),
|
| 133 |
+
],
|
| 134 |
+
|
| 135 |
+
# Declare (nested rules)
|
| 136 |
+
"decl": [
|
| 137 |
+
(r'\b[a-z_]\w*\b(?!\!)', Keyword.Declaration),
|
| 138 |
+
(r':', Punctuation, "#pop"),
|
| 139 |
+
(r'\n', Whitespace, "#pop"),
|
| 140 |
+
include("root"),
|
| 141 |
+
],
|
| 142 |
+
|
| 143 |
+
# Double-Quote String (nested rules)
|
| 144 |
+
"string.double": [
|
| 145 |
+
(r'\\\(', String.Interpol, "string.interpolation"),
|
| 146 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 147 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 148 |
+
(r'\\[bfnrt\\\']', String.Escape),
|
| 149 |
+
(r'\\"', String.Escape),
|
| 150 |
+
(r'"', String.Double, "#pop"),
|
| 151 |
+
(r'[^\\"]+', String.Double),
|
| 152 |
+
(r'.', Error),
|
| 153 |
+
],
|
| 154 |
+
|
| 155 |
+
# Single-Char String (nested rules)
|
| 156 |
+
"string.char": [
|
| 157 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 158 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 159 |
+
(r'\\[bfnrt\\\']', String.Escape),
|
| 160 |
+
(r"\\'", String.Escape),
|
| 161 |
+
(r"'", String.Char, "#pop"),
|
| 162 |
+
(r"[^\\']+", String.Char),
|
| 163 |
+
(r'.', Error),
|
| 164 |
+
],
|
| 165 |
+
|
| 166 |
+
# Interpolation inside String (nested rules)
|
| 167 |
+
"string.interpolation": [
|
| 168 |
+
(r"\)", String.Interpol, "#pop"),
|
| 169 |
+
include("root"),
|
| 170 |
+
]
|
| 171 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/scdoc.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.scdoc
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for scdoc, a simple man page generator.
|
| 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, using, this
|
| 14 |
+
from pygments.token import Text, Comment, Keyword, String, Generic
|
| 15 |
+
|
| 16 |
+
__all__ = ['ScdocLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class ScdocLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
`scdoc` is a simple man page generator for POSIX systems written in C99.
|
| 22 |
+
"""
|
| 23 |
+
name = 'scdoc'
|
| 24 |
+
url = 'https://git.sr.ht/~sircmpwn/scdoc'
|
| 25 |
+
aliases = ['scdoc', 'scd']
|
| 26 |
+
filenames = ['*.scd', '*.scdoc']
|
| 27 |
+
version_added = '2.5'
|
| 28 |
+
flags = re.MULTILINE
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
# comment
|
| 33 |
+
(r'^(;.+\n)', bygroups(Comment)),
|
| 34 |
+
|
| 35 |
+
# heading with pound prefix
|
| 36 |
+
(r'^(#)([^#].+\n)', bygroups(Generic.Heading, Text)),
|
| 37 |
+
(r'^(#{2})(.+\n)', bygroups(Generic.Subheading, Text)),
|
| 38 |
+
# bulleted lists
|
| 39 |
+
(r'^(\s*)([*-])(\s)(.+\n)',
|
| 40 |
+
bygroups(Text, Keyword, Text, using(this, state='inline'))),
|
| 41 |
+
# numbered lists
|
| 42 |
+
(r'^(\s*)(\.+\.)( .+\n)',
|
| 43 |
+
bygroups(Text, Keyword, using(this, state='inline'))),
|
| 44 |
+
# quote
|
| 45 |
+
(r'^(\s*>\s)(.+\n)', bygroups(Keyword, Generic.Emph)),
|
| 46 |
+
# text block
|
| 47 |
+
(r'^(```\n)([\w\W]*?)(^```$)', bygroups(String, Text, String)),
|
| 48 |
+
|
| 49 |
+
include('inline'),
|
| 50 |
+
],
|
| 51 |
+
'inline': [
|
| 52 |
+
# escape
|
| 53 |
+
(r'\\.', Text),
|
| 54 |
+
# underlines
|
| 55 |
+
(r'(\s)(_[^_]+_)(\W|\n)', bygroups(Text, Generic.Emph, Text)),
|
| 56 |
+
# bold
|
| 57 |
+
(r'(\s)(\*[^*]+\*)(\W|\n)', bygroups(Text, Generic.Strong, Text)),
|
| 58 |
+
# inline code
|
| 59 |
+
(r'`[^`]+`', String.Backtick),
|
| 60 |
+
|
| 61 |
+
# general text, must come last!
|
| 62 |
+
(r'[^\\\s]+', Text),
|
| 63 |
+
(r'.', Text),
|
| 64 |
+
],
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
def analyse_text(text):
|
| 68 |
+
"""We checks for bold and underline text with * and _. Also
|
| 69 |
+
every scdoc file must start with a strictly defined first line."""
|
| 70 |
+
result = 0
|
| 71 |
+
|
| 72 |
+
if '*' in text:
|
| 73 |
+
result += 0.01
|
| 74 |
+
|
| 75 |
+
if '_' in text:
|
| 76 |
+
result += 0.01
|
| 77 |
+
|
| 78 |
+
# name(section) ["left_footer" ["center_header"]]
|
| 79 |
+
first_line = text.partition('\n')[0]
|
| 80 |
+
scdoc_preamble_pattern = r'^.*\([1-7]\)( "[^"]+"){0,2}$'
|
| 81 |
+
|
| 82 |
+
if re.search(scdoc_preamble_pattern, first_line):
|
| 83 |
+
result += 0.5
|
| 84 |
+
|
| 85 |
+
return result
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/scripting.py
ADDED
|
@@ -0,0 +1,1638 @@
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.scripting
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for scripting and embedded 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, combined, \
|
| 14 |
+
words
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Error, Whitespace, Other
|
| 17 |
+
from pygments.util import get_bool_opt, get_list_opt
|
| 18 |
+
|
| 19 |
+
__all__ = ['LuaLexer', 'LuauLexer', 'MoonScriptLexer', 'ChaiscriptLexer', 'LSLLexer',
|
| 20 |
+
'AppleScriptLexer', 'RexxLexer', 'MOOCodeLexer', 'HybrisLexer',
|
| 21 |
+
'EasytrieveLexer', 'JclLexer', 'MiniScriptLexer']
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def all_lua_builtins():
|
| 25 |
+
from pygments.lexers._lua_builtins import MODULES
|
| 26 |
+
return [w for values in MODULES.values() for w in values]
|
| 27 |
+
|
| 28 |
+
class LuaLexer(RegexLexer):
|
| 29 |
+
"""
|
| 30 |
+
For Lua source code.
|
| 31 |
+
|
| 32 |
+
Additional options accepted:
|
| 33 |
+
|
| 34 |
+
`func_name_highlighting`
|
| 35 |
+
If given and ``True``, highlight builtin function names
|
| 36 |
+
(default: ``True``).
|
| 37 |
+
`disabled_modules`
|
| 38 |
+
If given, must be a list of module names whose function names
|
| 39 |
+
should not be highlighted. By default all modules are highlighted.
|
| 40 |
+
|
| 41 |
+
To get a list of allowed modules have a look into the
|
| 42 |
+
`_lua_builtins` module:
|
| 43 |
+
|
| 44 |
+
.. sourcecode:: pycon
|
| 45 |
+
|
| 46 |
+
>>> from pygments.lexers._lua_builtins import MODULES
|
| 47 |
+
>>> MODULES.keys()
|
| 48 |
+
['string', 'coroutine', 'modules', 'io', 'basic', ...]
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
name = 'Lua'
|
| 52 |
+
url = 'https://www.lua.org/'
|
| 53 |
+
aliases = ['lua']
|
| 54 |
+
filenames = ['*.lua', '*.wlua']
|
| 55 |
+
mimetypes = ['text/x-lua', 'application/x-lua']
|
| 56 |
+
version_added = ''
|
| 57 |
+
|
| 58 |
+
_comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])'
|
| 59 |
+
_comment_single = r'(?:--.*$)'
|
| 60 |
+
_space = r'(?:\s+(?!\s))'
|
| 61 |
+
_s = rf'(?:{_comment_multiline}|{_comment_single}|{_space})'
|
| 62 |
+
# A lookahead-safe version of _s that avoids catastrophic backtracking.
|
| 63 |
+
# The _comment_multiline pattern contains [\w\W]*? which, when used
|
| 64 |
+
# inside a lookahead with a * quantifier, causes exponential blowup.
|
| 65 |
+
# This version skips only whitespace; comments between an identifier
|
| 66 |
+
# and a following [.:] or ( are rare enough to sacrifice.
|
| 67 |
+
_s_la = r'\s'
|
| 68 |
+
_name = r'(?:[^\W\d]\w*)'
|
| 69 |
+
|
| 70 |
+
tokens = {
|
| 71 |
+
'root': [
|
| 72 |
+
# Lua allows a file to start with a shebang.
|
| 73 |
+
(r'#!.*', Comment.Preproc),
|
| 74 |
+
default('base'),
|
| 75 |
+
],
|
| 76 |
+
'ws': [
|
| 77 |
+
(_comment_multiline, Comment.Multiline),
|
| 78 |
+
(_comment_single, Comment.Single),
|
| 79 |
+
(_space, Whitespace),
|
| 80 |
+
],
|
| 81 |
+
'base': [
|
| 82 |
+
include('ws'),
|
| 83 |
+
|
| 84 |
+
(r'(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?', Number.Hex),
|
| 85 |
+
(r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
|
| 86 |
+
(r'(?i)\d+e[+-]?\d+', Number.Float),
|
| 87 |
+
(r'\d+', Number.Integer),
|
| 88 |
+
|
| 89 |
+
# multiline strings
|
| 90 |
+
(r'(?s)\[(=*)\[.*?\]\1\]', String),
|
| 91 |
+
|
| 92 |
+
(r'::', Punctuation, 'label'),
|
| 93 |
+
(r'\.{3}', Punctuation),
|
| 94 |
+
(r'[=<>|~&+\-*/%#^]+|\.\.', Operator),
|
| 95 |
+
(r'[\[\]{}().,:;]+', Punctuation),
|
| 96 |
+
(r'(and|or|not)\b', Operator.Word),
|
| 97 |
+
|
| 98 |
+
(words([
|
| 99 |
+
'break', 'do', 'else', 'elseif', 'end', 'for', 'if', 'in',
|
| 100 |
+
'repeat', 'return', 'then', 'until', 'while'
|
| 101 |
+
], suffix=r'\b'), Keyword.Reserved),
|
| 102 |
+
(r'goto\b', Keyword.Reserved, 'goto'),
|
| 103 |
+
(r'(local)\b', Keyword.Declaration),
|
| 104 |
+
(r'(true|false|nil)\b', Keyword.Constant),
|
| 105 |
+
|
| 106 |
+
(r'(function)\b', Keyword.Reserved, 'funcname'),
|
| 107 |
+
|
| 108 |
+
(words(all_lua_builtins(), suffix=r"\b"), Name.Builtin),
|
| 109 |
+
(fr'[A-Za-z_]\w*(?={_s_la}*[.:])', Name.Variable, 'varname'),
|
| 110 |
+
(fr'[A-Za-z_]\w*(?={_s_la}*\()', Name.Function),
|
| 111 |
+
(r'[A-Za-z_]\w*', Name.Variable),
|
| 112 |
+
|
| 113 |
+
("'", String.Single, combined('stringescape', 'sqs')),
|
| 114 |
+
('"', String.Double, combined('stringescape', 'dqs'))
|
| 115 |
+
],
|
| 116 |
+
|
| 117 |
+
'varname': [
|
| 118 |
+
include('ws'),
|
| 119 |
+
(r'\.\.', Operator, '#pop'),
|
| 120 |
+
(r'[.:]', Punctuation),
|
| 121 |
+
(rf'{_name}(?={_s_la}*[.:])', Name.Property),
|
| 122 |
+
(rf'{_name}(?={_s_la}*\()', Name.Function, '#pop'),
|
| 123 |
+
(_name, Name.Property, '#pop'),
|
| 124 |
+
],
|
| 125 |
+
|
| 126 |
+
'funcname': [
|
| 127 |
+
include('ws'),
|
| 128 |
+
(r'[.:]', Punctuation),
|
| 129 |
+
(rf'{_name}(?={_s_la}*[.:])', Name.Class),
|
| 130 |
+
(_name, Name.Function, '#pop'),
|
| 131 |
+
# inline function
|
| 132 |
+
(r'\(', Punctuation, '#pop'),
|
| 133 |
+
],
|
| 134 |
+
|
| 135 |
+
'goto': [
|
| 136 |
+
include('ws'),
|
| 137 |
+
(_name, Name.Label, '#pop'),
|
| 138 |
+
],
|
| 139 |
+
|
| 140 |
+
'label': [
|
| 141 |
+
include('ws'),
|
| 142 |
+
(r'::', Punctuation, '#pop'),
|
| 143 |
+
(_name, Name.Label),
|
| 144 |
+
],
|
| 145 |
+
|
| 146 |
+
'stringescape': [
|
| 147 |
+
(r'\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|'
|
| 148 |
+
r'u\{[0-9a-fA-F]+\})', String.Escape),
|
| 149 |
+
],
|
| 150 |
+
|
| 151 |
+
'sqs': [
|
| 152 |
+
(r"'", String.Single, '#pop'),
|
| 153 |
+
(r"[^\\']+", String.Single),
|
| 154 |
+
],
|
| 155 |
+
|
| 156 |
+
'dqs': [
|
| 157 |
+
(r'"', String.Double, '#pop'),
|
| 158 |
+
(r'[^\\"]+', String.Double),
|
| 159 |
+
]
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
def __init__(self, **options):
|
| 163 |
+
self.func_name_highlighting = get_bool_opt(
|
| 164 |
+
options, 'func_name_highlighting', True)
|
| 165 |
+
self.disabled_modules = get_list_opt(options, 'disabled_modules', [])
|
| 166 |
+
|
| 167 |
+
self._functions = set()
|
| 168 |
+
if self.func_name_highlighting:
|
| 169 |
+
from pygments.lexers._lua_builtins import MODULES
|
| 170 |
+
for mod, func in MODULES.items():
|
| 171 |
+
if mod not in self.disabled_modules:
|
| 172 |
+
self._functions.update(func)
|
| 173 |
+
RegexLexer.__init__(self, **options)
|
| 174 |
+
|
| 175 |
+
def get_tokens_unprocessed(self, text):
|
| 176 |
+
for index, token, value in \
|
| 177 |
+
RegexLexer.get_tokens_unprocessed(self, text):
|
| 178 |
+
if token is Name.Builtin and value not in self._functions:
|
| 179 |
+
if '.' in value:
|
| 180 |
+
a, b = value.split('.')
|
| 181 |
+
yield index, Name, a
|
| 182 |
+
yield index + len(a), Punctuation, '.'
|
| 183 |
+
yield index + len(a) + 1, Name, b
|
| 184 |
+
else:
|
| 185 |
+
yield index, Name, value
|
| 186 |
+
continue
|
| 187 |
+
yield index, token, value
|
| 188 |
+
|
| 189 |
+
def _luau_make_expression(should_pop, _s, _s_la):
|
| 190 |
+
temp_list = [
|
| 191 |
+
(r'0[xX][\da-fA-F_]*', Number.Hex, '#pop'),
|
| 192 |
+
(r'0[bB][\d_]*', Number.Bin, '#pop'),
|
| 193 |
+
(r'\.?\d[\d_]*(?:\.[\d_]*)?(?:[eE][+-]?[\d_]+)?', Number.Float, '#pop'),
|
| 194 |
+
|
| 195 |
+
(words((
|
| 196 |
+
'true', 'false', 'nil'
|
| 197 |
+
), suffix=r'\b'), Keyword.Constant, '#pop'),
|
| 198 |
+
|
| 199 |
+
(r'\[(=*)\[[.\n]*?\]\1\]', String, '#pop'),
|
| 200 |
+
|
| 201 |
+
(r'(\.)([a-zA-Z_]\w*)(?=%s*[({"\'])', bygroups(Punctuation, Name.Function), '#pop'),
|
| 202 |
+
(r'(\.)([a-zA-Z_]\w*)', bygroups(Punctuation, Name.Variable), '#pop'),
|
| 203 |
+
|
| 204 |
+
(rf'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?={_s_la}*[({{"\'])', Name.Other, '#pop'),
|
| 205 |
+
(r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*', Name, '#pop'),
|
| 206 |
+
]
|
| 207 |
+
if should_pop:
|
| 208 |
+
return temp_list
|
| 209 |
+
return [entry[:2] for entry in temp_list]
|
| 210 |
+
|
| 211 |
+
def _luau_make_expression_special(should_pop):
|
| 212 |
+
temp_list = [
|
| 213 |
+
(r'\{', Punctuation, ('#pop', 'closing_brace_base', 'expression')),
|
| 214 |
+
(r'\(', Punctuation, ('#pop', 'closing_parenthesis_base', 'expression')),
|
| 215 |
+
|
| 216 |
+
(r'::?', Punctuation, ('#pop', 'type_end', 'type_start')),
|
| 217 |
+
|
| 218 |
+
(r"'", String.Single, ('#pop', 'string_single')),
|
| 219 |
+
(r'"', String.Double, ('#pop', 'string_double')),
|
| 220 |
+
(r'`', String.Backtick, ('#pop', 'string_interpolated')),
|
| 221 |
+
]
|
| 222 |
+
if should_pop:
|
| 223 |
+
return temp_list
|
| 224 |
+
return [(entry[0], entry[1], entry[2][1:]) for entry in temp_list]
|
| 225 |
+
|
| 226 |
+
class LuauLexer(RegexLexer):
|
| 227 |
+
"""
|
| 228 |
+
For Luau source code.
|
| 229 |
+
|
| 230 |
+
Additional options accepted:
|
| 231 |
+
|
| 232 |
+
`include_luau_builtins`
|
| 233 |
+
If given and ``True``, automatically highlight Luau builtins
|
| 234 |
+
(default: ``True``).
|
| 235 |
+
`include_roblox_builtins`
|
| 236 |
+
If given and ``True``, automatically highlight Roblox-specific builtins
|
| 237 |
+
(default: ``False``).
|
| 238 |
+
`additional_builtins`
|
| 239 |
+
If given, must be a list of additional builtins to highlight.
|
| 240 |
+
`disabled_builtins`
|
| 241 |
+
If given, must be a list of builtins that will not be highlighted.
|
| 242 |
+
"""
|
| 243 |
+
|
| 244 |
+
name = 'Luau'
|
| 245 |
+
url = 'https://luau-lang.org/'
|
| 246 |
+
aliases = ['luau']
|
| 247 |
+
filenames = ['*.luau']
|
| 248 |
+
version_added = '2.18'
|
| 249 |
+
|
| 250 |
+
_comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])'
|
| 251 |
+
_comment_single = r'(?:--.*$)'
|
| 252 |
+
_s = r'(?:{}|{}|{})'.format(_comment_multiline, _comment_single, r'\s+')
|
| 253 |
+
# Lookahead-safe version — avoids catastrophic backtracking from
|
| 254 |
+
# [\w\W]*? inside _comment_multiline when combined with * quantifier.
|
| 255 |
+
_s_la = r'\s'
|
| 256 |
+
|
| 257 |
+
tokens = {
|
| 258 |
+
'root': [
|
| 259 |
+
(r'#!.*', Comment.Hashbang, 'base'),
|
| 260 |
+
default('base'),
|
| 261 |
+
],
|
| 262 |
+
|
| 263 |
+
'ws': [
|
| 264 |
+
(_comment_multiline, Comment.Multiline),
|
| 265 |
+
(_comment_single, Comment.Single),
|
| 266 |
+
(r'\s+', Whitespace),
|
| 267 |
+
],
|
| 268 |
+
|
| 269 |
+
'base': [
|
| 270 |
+
include('ws'),
|
| 271 |
+
|
| 272 |
+
*_luau_make_expression_special(False),
|
| 273 |
+
(r'\.\.\.', Punctuation),
|
| 274 |
+
|
| 275 |
+
(rf'type\b(?={_s}+[a-zA-Z_])', Keyword.Reserved, 'type_declaration'),
|
| 276 |
+
(rf'export\b(?={_s}+[a-zA-Z_])', Keyword.Reserved),
|
| 277 |
+
|
| 278 |
+
(r'(?:\.\.|//|[+\-*\/%^<>=])=?', Operator, 'expression'),
|
| 279 |
+
(r'~=', Operator, 'expression'),
|
| 280 |
+
|
| 281 |
+
(words((
|
| 282 |
+
'and', 'or', 'not'
|
| 283 |
+
), suffix=r'\b'), Operator.Word, 'expression'),
|
| 284 |
+
|
| 285 |
+
(words((
|
| 286 |
+
'elseif', 'for', 'if', 'in', 'repeat', 'return', 'until',
|
| 287 |
+
'while'), suffix=r'\b'), Keyword.Reserved, 'expression'),
|
| 288 |
+
(r'local\b', Keyword.Declaration, 'expression'),
|
| 289 |
+
|
| 290 |
+
(r'function\b', Keyword.Reserved, ('expression', 'func_name')),
|
| 291 |
+
|
| 292 |
+
(r'[\])};]+', Punctuation),
|
| 293 |
+
|
| 294 |
+
include('expression_static'),
|
| 295 |
+
*_luau_make_expression(False, _s, _s_la),
|
| 296 |
+
|
| 297 |
+
(r'[\[.,]', Punctuation, 'expression'),
|
| 298 |
+
],
|
| 299 |
+
'expression_static': [
|
| 300 |
+
(words((
|
| 301 |
+
'break', 'continue', 'do', 'else', 'elseif', 'end', 'for',
|
| 302 |
+
'if', 'in', 'repeat', 'return', 'then', 'until', 'while'),
|
| 303 |
+
suffix=r'\b'), Keyword.Reserved),
|
| 304 |
+
],
|
| 305 |
+
'expression': [
|
| 306 |
+
include('ws'),
|
| 307 |
+
|
| 308 |
+
(r'if\b', Keyword.Reserved, ('ternary', 'expression')),
|
| 309 |
+
|
| 310 |
+
(r'local\b', Keyword.Declaration),
|
| 311 |
+
*_luau_make_expression_special(True),
|
| 312 |
+
(r'\.\.\.', Punctuation, '#pop'),
|
| 313 |
+
|
| 314 |
+
(r'function\b', Keyword.Reserved, 'func_name'),
|
| 315 |
+
|
| 316 |
+
include('expression_static'),
|
| 317 |
+
*_luau_make_expression(True, _s, _s_la),
|
| 318 |
+
|
| 319 |
+
default('#pop'),
|
| 320 |
+
],
|
| 321 |
+
'ternary': [
|
| 322 |
+
include('ws'),
|
| 323 |
+
|
| 324 |
+
(r'else\b', Keyword.Reserved, '#pop'),
|
| 325 |
+
(words((
|
| 326 |
+
'then', 'elseif',
|
| 327 |
+
), suffix=r'\b'), Operator.Reserved, 'expression'),
|
| 328 |
+
|
| 329 |
+
default('#pop'),
|
| 330 |
+
],
|
| 331 |
+
|
| 332 |
+
'closing_brace_pop': [
|
| 333 |
+
(r'\}', Punctuation, '#pop'),
|
| 334 |
+
],
|
| 335 |
+
'closing_parenthesis_pop': [
|
| 336 |
+
(r'\)', Punctuation, '#pop'),
|
| 337 |
+
],
|
| 338 |
+
'closing_gt_pop': [
|
| 339 |
+
(r'>', Punctuation, '#pop'),
|
| 340 |
+
],
|
| 341 |
+
|
| 342 |
+
'closing_parenthesis_base': [
|
| 343 |
+
include('closing_parenthesis_pop'),
|
| 344 |
+
include('base'),
|
| 345 |
+
],
|
| 346 |
+
'closing_parenthesis_type': [
|
| 347 |
+
include('closing_parenthesis_pop'),
|
| 348 |
+
include('type'),
|
| 349 |
+
],
|
| 350 |
+
'closing_brace_base': [
|
| 351 |
+
include('closing_brace_pop'),
|
| 352 |
+
include('base'),
|
| 353 |
+
],
|
| 354 |
+
'closing_brace_type': [
|
| 355 |
+
include('closing_brace_pop'),
|
| 356 |
+
include('type'),
|
| 357 |
+
],
|
| 358 |
+
'closing_gt_type': [
|
| 359 |
+
include('closing_gt_pop'),
|
| 360 |
+
include('type'),
|
| 361 |
+
],
|
| 362 |
+
|
| 363 |
+
'string_escape': [
|
| 364 |
+
(r'\\z\s*', String.Escape),
|
| 365 |
+
(r'\\(?:[abfnrtvz\\"\'`\{\n])|[\r\n]{1,2}|x[\da-fA-F]{2}|\d{1,3}|'
|
| 366 |
+
r'u\{\}[\da-fA-F]*\}', String.Escape),
|
| 367 |
+
],
|
| 368 |
+
'string_single': [
|
| 369 |
+
include('string_escape'),
|
| 370 |
+
|
| 371 |
+
(r"'", String.Single, "#pop"),
|
| 372 |
+
(r"[^\\']+", String.Single),
|
| 373 |
+
],
|
| 374 |
+
'string_double': [
|
| 375 |
+
include('string_escape'),
|
| 376 |
+
|
| 377 |
+
(r'"', String.Double, "#pop"),
|
| 378 |
+
(r'[^\\"]+', String.Double),
|
| 379 |
+
],
|
| 380 |
+
'string_interpolated': [
|
| 381 |
+
include('string_escape'),
|
| 382 |
+
|
| 383 |
+
(r'\{', Punctuation, ('closing_brace_base', 'expression')),
|
| 384 |
+
|
| 385 |
+
(r'`', String.Backtick, "#pop"),
|
| 386 |
+
(r'[^\\`\{]+', String.Backtick),
|
| 387 |
+
],
|
| 388 |
+
|
| 389 |
+
'func_name': [
|
| 390 |
+
include('ws'),
|
| 391 |
+
|
| 392 |
+
(r'[.:]', Punctuation),
|
| 393 |
+
(rf'[a-zA-Z_]\w*(?={_s_la}*[.:])', Name.Class),
|
| 394 |
+
(r'[a-zA-Z_]\w*', Name.Function),
|
| 395 |
+
|
| 396 |
+
(r'<', Punctuation, 'closing_gt_type'),
|
| 397 |
+
|
| 398 |
+
(r'\(', Punctuation, '#pop'),
|
| 399 |
+
],
|
| 400 |
+
|
| 401 |
+
'type': [
|
| 402 |
+
include('ws'),
|
| 403 |
+
|
| 404 |
+
(r'\(', Punctuation, 'closing_parenthesis_type'),
|
| 405 |
+
(r'\{', Punctuation, 'closing_brace_type'),
|
| 406 |
+
(r'<', Punctuation, 'closing_gt_type'),
|
| 407 |
+
|
| 408 |
+
(r"'", String.Single, 'string_single'),
|
| 409 |
+
(r'"', String.Double, 'string_double'),
|
| 410 |
+
|
| 411 |
+
(r'[|&\.,\[\]:=]+', Punctuation),
|
| 412 |
+
(r'->', Punctuation),
|
| 413 |
+
|
| 414 |
+
(r'typeof\(', Name.Builtin, ('closing_parenthesis_base',
|
| 415 |
+
'expression')),
|
| 416 |
+
(r'[a-zA-Z_]\w*', Name.Class),
|
| 417 |
+
],
|
| 418 |
+
'type_start': [
|
| 419 |
+
include('ws'),
|
| 420 |
+
|
| 421 |
+
(r'\(', Punctuation, ('#pop', 'closing_parenthesis_type')),
|
| 422 |
+
(r'\{', Punctuation, ('#pop', 'closing_brace_type')),
|
| 423 |
+
(r'<', Punctuation, ('#pop', 'closing_gt_type')),
|
| 424 |
+
|
| 425 |
+
(r"'", String.Single, ('#pop', 'string_single')),
|
| 426 |
+
(r'"', String.Double, ('#pop', 'string_double')),
|
| 427 |
+
|
| 428 |
+
(r'typeof\(', Name.Builtin, ('#pop', 'closing_parenthesis_base',
|
| 429 |
+
'expression')),
|
| 430 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop'),
|
| 431 |
+
],
|
| 432 |
+
'type_end': [
|
| 433 |
+
include('ws'),
|
| 434 |
+
|
| 435 |
+
(r'[|&\.]', Punctuation, 'type_start'),
|
| 436 |
+
(r'->', Punctuation, 'type_start'),
|
| 437 |
+
|
| 438 |
+
(r'<', Punctuation, 'closing_gt_type'),
|
| 439 |
+
|
| 440 |
+
default('#pop'),
|
| 441 |
+
],
|
| 442 |
+
'type_declaration': [
|
| 443 |
+
include('ws'),
|
| 444 |
+
|
| 445 |
+
(r'[a-zA-Z_]\w*', Name.Class),
|
| 446 |
+
(r'<', Punctuation, 'closing_gt_type'),
|
| 447 |
+
|
| 448 |
+
(r'=', Punctuation, ('#pop', 'type_end', 'type_start')),
|
| 449 |
+
],
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
def __init__(self, **options):
|
| 453 |
+
self.include_luau_builtins = get_bool_opt(
|
| 454 |
+
options, 'include_luau_builtins', True)
|
| 455 |
+
self.include_roblox_builtins = get_bool_opt(
|
| 456 |
+
options, 'include_roblox_builtins', False)
|
| 457 |
+
self.additional_builtins = get_list_opt(options, 'additional_builtins', [])
|
| 458 |
+
self.disabled_builtins = get_list_opt(options, 'disabled_builtins', [])
|
| 459 |
+
|
| 460 |
+
self._builtins = set(self.additional_builtins)
|
| 461 |
+
if self.include_luau_builtins:
|
| 462 |
+
from pygments.lexers._luau_builtins import LUAU_BUILTINS
|
| 463 |
+
self._builtins.update(LUAU_BUILTINS)
|
| 464 |
+
if self.include_roblox_builtins:
|
| 465 |
+
from pygments.lexers._luau_builtins import ROBLOX_BUILTINS
|
| 466 |
+
self._builtins.update(ROBLOX_BUILTINS)
|
| 467 |
+
if self.additional_builtins:
|
| 468 |
+
self._builtins.update(self.additional_builtins)
|
| 469 |
+
self._builtins.difference_update(self.disabled_builtins)
|
| 470 |
+
|
| 471 |
+
RegexLexer.__init__(self, **options)
|
| 472 |
+
|
| 473 |
+
def get_tokens_unprocessed(self, text):
|
| 474 |
+
for index, token, value in \
|
| 475 |
+
RegexLexer.get_tokens_unprocessed(self, text):
|
| 476 |
+
if token is Name or token is Name.Other:
|
| 477 |
+
split_value = value.split('.')
|
| 478 |
+
complete_value = []
|
| 479 |
+
new_index = index
|
| 480 |
+
for position in range(len(split_value), 0, -1):
|
| 481 |
+
potential_string = '.'.join(split_value[:position])
|
| 482 |
+
if potential_string in self._builtins:
|
| 483 |
+
yield index, Name.Builtin, potential_string
|
| 484 |
+
new_index += len(potential_string)
|
| 485 |
+
|
| 486 |
+
if complete_value:
|
| 487 |
+
yield new_index, Punctuation, '.'
|
| 488 |
+
new_index += 1
|
| 489 |
+
break
|
| 490 |
+
complete_value.insert(0, split_value[position - 1])
|
| 491 |
+
|
| 492 |
+
for position, substring in enumerate(complete_value):
|
| 493 |
+
if position + 1 == len(complete_value):
|
| 494 |
+
if token is Name:
|
| 495 |
+
yield new_index, Name.Variable, substring
|
| 496 |
+
continue
|
| 497 |
+
yield new_index, Name.Function, substring
|
| 498 |
+
continue
|
| 499 |
+
yield new_index, Name.Variable, substring
|
| 500 |
+
new_index += len(substring)
|
| 501 |
+
yield new_index, Punctuation, '.'
|
| 502 |
+
new_index += 1
|
| 503 |
+
|
| 504 |
+
continue
|
| 505 |
+
yield index, token, value
|
| 506 |
+
|
| 507 |
+
class MoonScriptLexer(LuaLexer):
|
| 508 |
+
"""
|
| 509 |
+
For MoonScript source code.
|
| 510 |
+
"""
|
| 511 |
+
|
| 512 |
+
name = 'MoonScript'
|
| 513 |
+
url = 'http://moonscript.org'
|
| 514 |
+
aliases = ['moonscript', 'moon']
|
| 515 |
+
filenames = ['*.moon']
|
| 516 |
+
mimetypes = ['text/x-moonscript', 'application/x-moonscript']
|
| 517 |
+
version_added = '1.5'
|
| 518 |
+
|
| 519 |
+
tokens = {
|
| 520 |
+
'root': [
|
| 521 |
+
(r'#!(.*?)$', Comment.Preproc),
|
| 522 |
+
default('base'),
|
| 523 |
+
],
|
| 524 |
+
'base': [
|
| 525 |
+
('--.*$', Comment.Single),
|
| 526 |
+
(r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
|
| 527 |
+
(r'(?i)\d+e[+-]?\d+', Number.Float),
|
| 528 |
+
(r'(?i)0x[0-9a-f]*', Number.Hex),
|
| 529 |
+
(r'\d+', Number.Integer),
|
| 530 |
+
(r'\n', Whitespace),
|
| 531 |
+
(r'[^\S\n]+', Text),
|
| 532 |
+
(r'(?s)\[(=*)\[.*?\]\1\]', String),
|
| 533 |
+
(r'(->|=>)', Name.Function),
|
| 534 |
+
(r':[a-zA-Z_]\w*', Name.Variable),
|
| 535 |
+
(r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),
|
| 536 |
+
(r'[;,]', Punctuation),
|
| 537 |
+
(r'[\[\]{}()]', Keyword.Type),
|
| 538 |
+
(r'[a-zA-Z_]\w*:', Name.Variable),
|
| 539 |
+
(words((
|
| 540 |
+
'class', 'extends', 'if', 'then', 'super', 'do', 'with',
|
| 541 |
+
'import', 'export', 'while', 'elseif', 'return', 'for', 'in',
|
| 542 |
+
'from', 'when', 'using', 'else', 'and', 'or', 'not', 'switch',
|
| 543 |
+
'break'), suffix=r'\b'),
|
| 544 |
+
Keyword),
|
| 545 |
+
(r'(true|false|nil)\b', Keyword.Constant),
|
| 546 |
+
(r'(and|or|not)\b', Operator.Word),
|
| 547 |
+
(r'(self)\b', Name.Builtin.Pseudo),
|
| 548 |
+
(r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class),
|
| 549 |
+
(r'[A-Z]\w*', Name.Class), # proper name
|
| 550 |
+
(words(all_lua_builtins(), suffix=r"\b"), Name.Builtin),
|
| 551 |
+
(r'[A-Za-z_]\w*', Name),
|
| 552 |
+
("'", String.Single, combined('stringescape', 'sqs')),
|
| 553 |
+
('"', String.Double, combined('stringescape', 'dqs'))
|
| 554 |
+
],
|
| 555 |
+
'stringescape': [
|
| 556 |
+
(r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)
|
| 557 |
+
],
|
| 558 |
+
'strings': [
|
| 559 |
+
(r'[^#\\\'"]+', String),
|
| 560 |
+
# note that strings are multi-line.
|
| 561 |
+
# hashmarks, quotes and backslashes must be parsed one at a time
|
| 562 |
+
],
|
| 563 |
+
'interpoling_string': [
|
| 564 |
+
(r'\}', String.Interpol, "#pop"),
|
| 565 |
+
include('base')
|
| 566 |
+
],
|
| 567 |
+
'dqs': [
|
| 568 |
+
(r'"', String.Double, '#pop'),
|
| 569 |
+
(r'\\.|\'', String), # double-quoted string don't need ' escapes
|
| 570 |
+
(r'#\{', String.Interpol, "interpoling_string"),
|
| 571 |
+
(r'#', String),
|
| 572 |
+
include('strings')
|
| 573 |
+
],
|
| 574 |
+
'sqs': [
|
| 575 |
+
(r"'", String.Single, '#pop'),
|
| 576 |
+
(r'#|\\.|"', String), # single quoted strings don't need " escapses
|
| 577 |
+
include('strings')
|
| 578 |
+
]
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
def get_tokens_unprocessed(self, text):
|
| 582 |
+
# set . as Operator instead of Punctuation
|
| 583 |
+
for index, token, value in LuaLexer.get_tokens_unprocessed(self, text):
|
| 584 |
+
if token == Punctuation and value == ".":
|
| 585 |
+
token = Operator
|
| 586 |
+
yield index, token, value
|
| 587 |
+
|
| 588 |
+
|
| 589 |
+
class ChaiscriptLexer(RegexLexer):
|
| 590 |
+
"""
|
| 591 |
+
For ChaiScript source code.
|
| 592 |
+
"""
|
| 593 |
+
|
| 594 |
+
name = 'ChaiScript'
|
| 595 |
+
url = 'http://chaiscript.com/'
|
| 596 |
+
aliases = ['chaiscript', 'chai']
|
| 597 |
+
filenames = ['*.chai']
|
| 598 |
+
mimetypes = ['text/x-chaiscript', 'application/x-chaiscript']
|
| 599 |
+
version_added = '2.0'
|
| 600 |
+
|
| 601 |
+
flags = re.DOTALL | re.MULTILINE
|
| 602 |
+
|
| 603 |
+
tokens = {
|
| 604 |
+
'commentsandwhitespace': [
|
| 605 |
+
(r'\s+', Text),
|
| 606 |
+
(r'//.*?\n', Comment.Single),
|
| 607 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 608 |
+
(r'^\#.*?\n', Comment.Single)
|
| 609 |
+
],
|
| 610 |
+
'slashstartsregex': [
|
| 611 |
+
include('commentsandwhitespace'),
|
| 612 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 613 |
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
| 614 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 615 |
+
default('#pop')
|
| 616 |
+
],
|
| 617 |
+
'badregex': [
|
| 618 |
+
(r'\n', Text, '#pop')
|
| 619 |
+
],
|
| 620 |
+
'root': [
|
| 621 |
+
include('commentsandwhitespace'),
|
| 622 |
+
(r'\n', Text),
|
| 623 |
+
(r'[^\S\n]+', Text),
|
| 624 |
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.'
|
| 625 |
+
r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
|
| 626 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 627 |
+
(r'[})\].]', Punctuation),
|
| 628 |
+
(r'[=+\-*/]', Operator),
|
| 629 |
+
(r'(for|in|while|do|break|return|continue|if|else|'
|
| 630 |
+
r'throw|try|catch'
|
| 631 |
+
r')\b', Keyword, 'slashstartsregex'),
|
| 632 |
+
(r'(var)\b', Keyword.Declaration, 'slashstartsregex'),
|
| 633 |
+
(r'(attr|def|fun)\b', Keyword.Reserved),
|
| 634 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 635 |
+
(r'(eval|throw)\b', Name.Builtin),
|
| 636 |
+
(r'`\S+`', Name.Builtin),
|
| 637 |
+
(r'[$a-zA-Z_]\w*', Name.Other),
|
| 638 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 639 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 640 |
+
(r'[0-9]+', Number.Integer),
|
| 641 |
+
(r'"', String.Double, 'dqstring'),
|
| 642 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 643 |
+
],
|
| 644 |
+
'dqstring': [
|
| 645 |
+
(r'\$\{[^"}]+?\}', String.Interpol),
|
| 646 |
+
(r'\$', String.Double),
|
| 647 |
+
(r'\\\\', String.Double),
|
| 648 |
+
(r'\\"', String.Double),
|
| 649 |
+
(r'[^\\"$]+', String.Double),
|
| 650 |
+
(r'"', String.Double, '#pop'),
|
| 651 |
+
],
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
class LSLLexer(RegexLexer):
|
| 656 |
+
"""
|
| 657 |
+
For Second Life's Linden Scripting Language source code.
|
| 658 |
+
"""
|
| 659 |
+
|
| 660 |
+
name = 'LSL'
|
| 661 |
+
aliases = ['lsl']
|
| 662 |
+
filenames = ['*.lsl']
|
| 663 |
+
mimetypes = ['text/x-lsl']
|
| 664 |
+
url = 'https://wiki.secondlife.com/wiki/Linden_Scripting_Language'
|
| 665 |
+
version_added = '2.0'
|
| 666 |
+
|
| 667 |
+
flags = re.MULTILINE
|
| 668 |
+
|
| 669 |
+
lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b'
|
| 670 |
+
lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b'
|
| 671 |
+
lsl_states = r'\b(?:(?:state)\s+\w+|default)\b'
|
| 672 |
+
lsl_events = r'\b(?:state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b'
|
| 673 |
+
lsl_functions_builtin = r'\b(?:ll(?:ReturnObjectsBy(?:ID|Owner)|Json(?:2List|[GS]etValue|ValueType)|Sin|Cos|Tan|Atan2|Sqrt|Pow|Abs|Fabs|Frand|Floor|Ceil|Round|Vec(?:Mag|Norm|Dist)|Rot(?:Between|2(?:Euler|Fwd|Left|Up))|(?:Euler|Axes)2Rot|Whisper|(?:Region|Owner)?Say|Shout|Listen(?:Control|Remove)?|Sensor(?:Repeat|Remove)?|Detected(?:Name|Key|Owner|Type|Pos|Vel|Grab|Rot|Group|LinkNumber)|Die|Ground|Wind|(?:[GS]et)(?:AnimationOverride|MemoryLimit|PrimMediaParams|ParcelMusicURL|Object(?:Desc|Name)|PhysicsMaterial|Status|Scale|Color|Alpha|Texture|Pos|Rot|Force|Torque)|ResetAnimationOverride|(?:Scale|Offset|Rotate)Texture|(?:Rot)?Target(?:Remove)?|(?:Stop)?MoveToTarget|Apply(?:Rotational)?Impulse|Set(?:KeyframedMotion|ContentType|RegionPos|(?:Angular)?Velocity|Buoyancy|HoverHeight|ForceAndTorque|TimerEvent|ScriptState|Damage|TextureAnim|Sound(?:Queueing|Radius)|Vehicle(?:Type|(?:Float|Vector|Rotation)Param)|(?:Touch|Sit)?Text|Camera(?:Eye|At)Offset|PrimitiveParams|ClickAction|Link(?:Alpha|Color|PrimitiveParams(?:Fast)?|Texture(?:Anim)?|Camera|Media)|RemoteScriptAccessPin|PayPrice|LocalRot)|ScaleByFactor|Get(?:(?:Max|Min)ScaleFactor|ClosestNavPoint|StaticPath|SimStats|Env|PrimitiveParams|Link(?:PrimitiveParams|Number(?:OfSides)?|Key|Name|Media)|HTTPHeader|FreeURLs|Object(?:Details|PermMask|PrimCount)|Parcel(?:MaxPrims|Details|Prim(?:Count|Owners))|Attached|(?:SPMax|Free|Used)Memory|Region(?:Name|TimeDilation|FPS|Corner|AgentCount)|Root(?:Position|Rotation)|UnixTime|(?:Parcel|Region)Flags|(?:Wall|GMT)clock|SimulatorHostname|BoundingBox|GeometricCenter|Creator|NumberOf(?:Prims|NotecardLines|Sides)|Animation(?:List)?|(?:Camera|Local)(?:Pos|Rot)|Vel|Accel|Omega|Time(?:stamp|OfDay)|(?:Object|CenterOf)?Mass|MassMKS|Energy|Owner|(?:Owner)?Key|SunDirection|Texture(?:Offset|Scale|Rot)|Inventory(?:Number|Name|Key|Type|Creator|PermMask)|Permissions(?:Key)?|StartParameter|List(?:Length|EntryType)|Date|Agent(?:Size|Info|Language|List)|LandOwnerAt|NotecardLine|Script(?:Name|State))|(?:Get|Reset|GetAndReset)Time|PlaySound(?:Slave)?|LoopSound(?:Master|Slave)?|(?:Trigger|Stop|Preload)Sound|(?:(?:Get|Delete)Sub|Insert)String|To(?:Upper|Lower)|Give(?:InventoryList|Money)|RezObject|(?:Stop)?LookAt|Sleep|CollisionFilter|(?:Take|Release)Controls|DetachFromAvatar|AttachToAvatar(?:Temp)?|InstantMessage|(?:GetNext)?Email|StopHover|MinEventDelay|RotLookAt|String(?:Length|Trim)|(?:Start|Stop)Animation|TargetOmega|RequestPermissions|(?:Create|Break)Link|BreakAllLinks|(?:Give|Remove)Inventory|Water|PassTouches|Request(?:Agent|Inventory)Data|TeleportAgent(?:Home|GlobalCoords)?|ModifyLand|CollisionSound|ResetScript|MessageLinked|PushObject|PassCollisions|AxisAngle2Rot|Rot2(?:Axis|Angle)|A(?:cos|sin)|AngleBetween|AllowInventoryDrop|SubStringIndex|List2(?:CSV|Integer|Json|Float|String|Key|Vector|Rot|List(?:Strided)?)|DeleteSubList|List(?:Statistics|Sort|Randomize|(?:Insert|Find|Replace)List)|EdgeOfWorld|AdjustSoundVolume|Key2Name|TriggerSoundLimited|EjectFromLand|(?:CSV|ParseString)2List|OverMyLand|SameGroup|UnSit|Ground(?:Slope|Normal|Contour)|GroundRepel|(?:Set|Remove)VehicleFlags|(?:AvatarOn)?(?:Link)?SitTarget|Script(?:Danger|Profiler)|Dialog|VolumeDetect|ResetOtherScript|RemoteLoadScriptPin|(?:Open|Close)RemoteDataChannel|SendRemoteData|RemoteDataReply|(?:Integer|String)ToBase64|XorBase64|Log(?:10)?|Base64To(?:String|Integer)|ParseStringKeepNulls|RezAtRoot|RequestSimulatorData|ForceMouselook|(?:Load|Release|(?:E|Une)scape)URL|ParcelMedia(?:CommandList|Query)|ModPow|MapDestination|(?:RemoveFrom|AddTo|Reset)Land(?:Pass|Ban)List|(?:Set|Clear)CameraParams|HTTP(?:Request|Response)|TextBox|DetectedTouch(?:UV|Face|Pos|(?:N|Bin)ormal|ST)|(?:MD5|SHA1|DumpList2)String|Request(?:Secure)?URL|Clear(?:Prim|Link)Media|(?:Link)?ParticleSystem|(?:Get|Request)(?:Username|DisplayName)|RegionSayTo|CastRay|GenerateKey|TransferLindenDollars|ManageEstateAccess|(?:Create|Delete)Character|ExecCharacterCmd|Evade|FleeFrom|NavigateTo|PatrolPoints|Pursue|UpdateCharacter|WanderWithin))\b'
|
| 674 |
+
lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b'
|
| 675 |
+
lsl_constants_integer = r'\b(?:JSON_APPEND|STATUS_(?:PHYSICS|ROTATE_[XYZ]|PHANTOM|SANDBOX|BLOCK_GRAB(?:_OBJECT)?|(?:DIE|RETURN)_AT_EDGE|CAST_SHADOWS|OK|MALFORMED_PARAMS|TYPE_MISMATCH|BOUNDS_ERROR|NOT_(?:FOUND|SUPPORTED)|INTERNAL_ERROR|WHITELIST_FAILED)|AGENT(?:_(?:BY_(?:LEGACY_|USER)NAME|FLYING|ATTACHMENTS|SCRIPTED|MOUSELOOK|SITTING|ON_OBJECT|AWAY|WALKING|IN_AIR|TYPING|CROUCHING|BUSY|ALWAYS_RUN|AUTOPILOT|LIST_(?:PARCEL(?:_OWNER)?|REGION)))?|CAMERA_(?:PITCH|DISTANCE|BEHINDNESS_(?:ANGLE|LAG)|(?:FOCUS|POSITION)(?:_(?:THRESHOLD|LOCKED|LAG))?|FOCUS_OFFSET|ACTIVE)|ANIM_ON|LOOP|REVERSE|PING_PONG|SMOOTH|ROTATE|SCALE|ALL_SIDES|LINK_(?:ROOT|SET|ALL_(?:OTHERS|CHILDREN)|THIS)|ACTIVE|PASSIVE|SCRIPTED|CONTROL_(?:FWD|BACK|(?:ROT_)?(?:LEFT|RIGHT)|UP|DOWN|(?:ML_)?LBUTTON)|PERMISSION_(?:RETURN_OBJECTS|DEBIT|OVERRIDE_ANIMATIONS|SILENT_ESTATE_MANAGEMENT|TAKE_CONTROLS|TRIGGER_ANIMATION|ATTACH|CHANGE_LINKS|(?:CONTROL|TRACK)_CAMERA|TELEPORT)|INVENTORY_(?:TEXTURE|SOUND|OBJECT|SCRIPT|LANDMARK|CLOTHING|NOTECARD|BODYPART|ANIMATION|GESTURE|ALL|NONE)|CHANGED_(?:INVENTORY|COLOR|SHAPE|SCALE|TEXTURE|LINK|ALLOWED_DROP|OWNER|REGION(?:_START)?|TELEPORT|MEDIA)|OBJECT_(?:(?:PHYSICS|SERVER|STREAMING)_COST|UNKNOWN_DETAIL|CHARACTER_TIME|PHANTOM|PHYSICS|TEMP_ON_REZ|NAME|DESC|POS|PRIM_EQUIVALENCE|RETURN_(?:PARCEL(?:_OWNER)?|REGION)|ROO?T|VELOCITY|OWNER|GROUP|CREATOR|ATTACHED_POINT|RENDER_WEIGHT|PATHFINDING_TYPE|(?:RUNNING|TOTAL)_SCRIPT_COUNT|SCRIPT_(?:MEMORY|TIME))|TYPE_(?:INTEGER|FLOAT|STRING|KEY|VECTOR|ROTATION|INVALID)|(?:DEBUG|PUBLIC)_CHANNEL|ATTACH_(?:AVATAR_CENTER|CHEST|HEAD|BACK|PELVIS|MOUTH|CHIN|NECK|NOSE|BELLY|[LR](?:SHOULDER|HAND|FOOT|EAR|EYE|[UL](?:ARM|LEG)|HIP)|(?:LEFT|RIGHT)_PEC|HUD_(?:CENTER_[12]|TOP_(?:RIGHT|CENTER|LEFT)|BOTTOM(?:_(?:RIGHT|LEFT))?))|LAND_(?:LEVEL|RAISE|LOWER|SMOOTH|NOISE|REVERT)|DATA_(?:ONLINE|NAME|BORN|SIM_(?:POS|STATUS|RATING)|PAYINFO)|PAYMENT_INFO_(?:ON_FILE|USED)|REMOTE_DATA_(?:CHANNEL|REQUEST|REPLY)|PSYS_(?:PART_(?:BF_(?:ZERO|ONE(?:_MINUS_(?:DEST_COLOR|SOURCE_(ALPHA|COLOR)))?|DEST_COLOR|SOURCE_(ALPHA|COLOR))|BLEND_FUNC_(DEST|SOURCE)|FLAGS|(?:START|END)_(?:COLOR|ALPHA|SCALE|GLOW)|MAX_AGE|(?:RIBBON|WIND|INTERP_(?:COLOR|SCALE)|BOUNCE|FOLLOW_(?:SRC|VELOCITY)|TARGET_(?:POS|LINEAR)|EMISSIVE)_MASK)|SRC_(?:MAX_AGE|PATTERN|ANGLE_(?:BEGIN|END)|BURST_(?:RATE|PART_COUNT|RADIUS|SPEED_(?:MIN|MAX))|ACCEL|TEXTURE|TARGET_KEY|OMEGA|PATTERN_(?:DROP|EXPLODE|ANGLE(?:_CONE(?:_EMPTY)?)?)))|VEHICLE_(?:REFERENCE_FRAME|TYPE_(?:NONE|SLED|CAR|BOAT|AIRPLANE|BALLOON)|(?:LINEAR|ANGULAR)_(?:FRICTION_TIMESCALE|MOTOR_DIRECTION)|LINEAR_MOTOR_OFFSET|HOVER_(?:HEIGHT|EFFICIENCY|TIMESCALE)|BUOYANCY|(?:LINEAR|ANGULAR)_(?:DEFLECTION_(?:EFFICIENCY|TIMESCALE)|MOTOR_(?:DECAY_)?TIMESCALE)|VERTICAL_ATTRACTION_(?:EFFICIENCY|TIMESCALE)|BANKING_(?:EFFICIENCY|MIX|TIMESCALE)|FLAG_(?:NO_DEFLECTION_UP|LIMIT_(?:ROLL_ONLY|MOTOR_UP)|HOVER_(?:(?:WATER|TERRAIN|UP)_ONLY|GLOBAL_HEIGHT)|MOUSELOOK_(?:STEER|BANK)|CAMERA_DECOUPLED))|PRIM_(?:TYPE(?:_(?:BOX|CYLINDER|PRISM|SPHERE|TORUS|TUBE|RING|SCULPT))?|HOLE_(?:DEFAULT|CIRCLE|SQUARE|TRIANGLE)|MATERIAL(?:_(?:STONE|METAL|GLASS|WOOD|FLESH|PLASTIC|RUBBER))?|SHINY_(?:NONE|LOW|MEDIUM|HIGH)|BUMP_(?:NONE|BRIGHT|DARK|WOOD|BARK|BRICKS|CHECKER|CONCRETE|TILE|STONE|DISKS|GRAVEL|BLOBS|SIDING|LARGETILE|STUCCO|SUCTION|WEAVE)|TEXGEN_(?:DEFAULT|PLANAR)|SCULPT_(?:TYPE_(?:SPHERE|TORUS|PLANE|CYLINDER|MASK)|FLAG_(?:MIRROR|INVERT))|PHYSICS(?:_(?:SHAPE_(?:CONVEX|NONE|PRIM|TYPE)))?|(?:POS|ROT)_LOCAL|SLICE|TEXT|FLEXIBLE|POINT_LIGHT|TEMP_ON_REZ|PHANTOM|POSITION|SIZE|ROTATION|TEXTURE|NAME|OMEGA|DESC|LINK_TARGET|COLOR|BUMP_SHINY|FULLBRIGHT|TEXGEN|GLOW|MEDIA_(?:ALT_IMAGE_ENABLE|CONTROLS|(?:CURRENT|HOME)_URL|AUTO_(?:LOOP|PLAY|SCALE|ZOOM)|FIRST_CLICK_INTERACT|(?:WIDTH|HEIGHT)_PIXELS|WHITELIST(?:_ENABLE)?|PERMS_(?:INTERACT|CONTROL)|PARAM_MAX|CONTROLS_(?:STANDARD|MINI)|PERM_(?:NONE|OWNER|GROUP|ANYONE)|MAX_(?:URL_LENGTH|WHITELIST_(?:SIZE|COUNT)|(?:WIDTH|HEIGHT)_PIXELS)))|MASK_(?:BASE|OWNER|GROUP|EVERYONE|NEXT)|PERM_(?:TRANSFER|MODIFY|COPY|MOVE|ALL)|PARCEL_(?:MEDIA_COMMAND_(?:STOP|PAUSE|PLAY|LOOP|TEXTURE|URL|TIME|AGENT|UNLOAD|AUTO_ALIGN|TYPE|SIZE|DESC|LOOP_SET)|FLAG_(?:ALLOW_(?:FLY|(?:GROUP_)?SCRIPTS|LANDMARK|TERRAFORM|DAMAGE|CREATE_(?:GROUP_)?OBJECTS)|USE_(?:ACCESS_(?:GROUP|LIST)|BAN_LIST|LAND_PASS_LIST)|LOCAL_SOUND_ONLY|RESTRICT_PUSHOBJECT|ALLOW_(?:GROUP|ALL)_OBJECT_ENTRY)|COUNT_(?:TOTAL|OWNER|GROUP|OTHER|SELECTED|TEMP)|DETAILS_(?:NAME|DESC|OWNER|GROUP|AREA|ID|SEE_AVATARS))|LIST_STAT_(?:MAX|MIN|MEAN|MEDIAN|STD_DEV|SUM(?:_SQUARES)?|NUM_COUNT|GEOMETRIC_MEAN|RANGE)|PAY_(?:HIDE|DEFAULT)|REGION_FLAG_(?:ALLOW_DAMAGE|FIXED_SUN|BLOCK_TERRAFORM|SANDBOX|DISABLE_(?:COLLISIONS|PHYSICS)|BLOCK_FLY|ALLOW_DIRECT_TELEPORT|RESTRICT_PUSHOBJECT)|HTTP_(?:METHOD|MIMETYPE|BODY_(?:MAXLENGTH|TRUNCATED)|CUSTOM_HEADER|PRAGMA_NO_CACHE|VERBOSE_THROTTLE|VERIFY_CERT)|STRING_(?:TRIM(?:_(?:HEAD|TAIL))?)|CLICK_ACTION_(?:NONE|TOUCH|SIT|BUY|PAY|OPEN(?:_MEDIA)?|PLAY|ZOOM)|TOUCH_INVALID_FACE|PROFILE_(?:NONE|SCRIPT_MEMORY)|RC_(?:DATA_FLAGS|DETECT_PHANTOM|GET_(?:LINK_NUM|NORMAL|ROOT_KEY)|MAX_HITS|REJECT_(?:TYPES|AGENTS|(?:NON)?PHYSICAL|LAND))|RCERR_(?:CAST_TIME_EXCEEDED|SIM_PERF_LOW|UNKNOWN)|ESTATE_ACCESS_(?:ALLOWED_(?:AGENT|GROUP)_(?:ADD|REMOVE)|BANNED_AGENT_(?:ADD|REMOVE))|DENSITY|FRICTION|RESTITUTION|GRAVITY_MULTIPLIER|KFM_(?:COMMAND|CMD_(?:PLAY|STOP|PAUSE|SET_MODE)|MODE|FORWARD|LOOP|PING_PONG|REVERSE|DATA|ROTATION|TRANSLATION)|ERR_(?:GENERIC|PARCEL_PERMISSIONS|MALFORMED_PARAMS|RUNTIME_PERMISSIONS|THROTTLED)|CHARACTER_(?:CMD_(?:(?:SMOOTH_)?STOP|JUMP)|DESIRED_(?:TURN_)?SPEED|RADIUS|STAY_WITHIN_PARCEL|LENGTH|ORIENTATION|ACCOUNT_FOR_SKIPPED_FRAMES|AVOIDANCE_MODE|TYPE(?:_(?:[A-D]|NONE))?|MAX_(?:DECEL|TURN_RADIUS|(?:ACCEL|SPEED)))|PURSUIT_(?:OFFSET|FUZZ_FACTOR|GOAL_TOLERANCE|INTERCEPT)|REQUIRE_LINE_OF_SIGHT|FORCE_DIRECT_PATH|VERTICAL|HORIZONTAL|AVOID_(?:CHARACTERS|DYNAMIC_OBSTACLES|NONE)|PU_(?:EVADE_(?:HIDDEN|SPOTTED)|FAILURE_(?:DYNAMIC_PATHFINDING_DISABLED|INVALID_(?:GOAL|START)|NO_(?:NAVMESH|VALID_DESTINATION)|OTHER|TARGET_GONE|(?:PARCEL_)?UNREACHABLE)|(?:GOAL|SLOWDOWN_DISTANCE)_REACHED)|TRAVERSAL_TYPE(?:_(?:FAST|NONE|SLOW))?|CONTENT_TYPE_(?:ATOM|FORM|HTML|JSON|LLSD|RSS|TEXT|XHTML|XML)|GCNP_(?:RADIUS|STATIC)|(?:PATROL|WANDER)_PAUSE_AT_WAYPOINTS|OPT_(?:AVATAR|CHARACTER|EXCLUSION_VOLUME|LEGACY_LINKSET|MATERIAL_VOLUME|OTHER|STATIC_OBSTACLE|WALKABLE)|SIM_STAT_PCT_CHARS_STEPPED)\b'
|
| 676 |
+
lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b'
|
| 677 |
+
lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b'
|
| 678 |
+
lsl_constants_string = r'\b(?:EOF|JSON_(?:ARRAY|DELETE|FALSE|INVALID|NULL|NUMBER|OBJECT|STRING|TRUE)|NULL_KEY|TEXTURE_(?:BLANK|DEFAULT|MEDIA|PLYWOOD|TRANSPARENT)|URL_REQUEST_(?:GRANTED|DENIED))\b'
|
| 679 |
+
lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b'
|
| 680 |
+
lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b'
|
| 681 |
+
lsl_invalid_deprecated = r'\b(?:ATTACH_[LR]PEC|DATA_RATING|OBJECT_ATTACHMENT_(?:GEOMETRY_BYTES|SURFACE_AREA)|PRIM_(?:CAST_SHADOWS|MATERIAL_LIGHT|TYPE_LEGACY)|PSYS_SRC_(?:INNER|OUTER)ANGLE|VEHICLE_FLAG_NO_FLY_UP|ll(?:Cloud|Make(?:Explosion|Fountain|Smoke|Fire)|RemoteDataSetRegion|Sound(?:Preload)?|XorBase64Strings(?:Correct)?))\b'
|
| 682 |
+
lsl_invalid_illegal = r'\b(?:event)\b'
|
| 683 |
+
lsl_invalid_unimplemented = r'\b(?:CHARACTER_(?:MAX_ANGULAR_(?:ACCEL|SPEED)|TURN_SPEED_MULTIPLIER)|PERMISSION_(?:CHANGE_(?:JOINTS|PERMISSIONS)|RELEASE_OWNERSHIP|REMAP_CONTROLS)|PRIM_PHYSICS_MATERIAL|PSYS_SRC_OBJ_REL_MASK|ll(?:CollisionSprite|(?:Stop)?PointAt|(?:(?:Refresh|Set)Prim)URL|(?:Take|Release)Camera|RemoteLoadScript))\b'
|
| 684 |
+
lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b'
|
| 685 |
+
lsl_reserved_log = r'\b(?:print)\b'
|
| 686 |
+
lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-/]=?'
|
| 687 |
+
|
| 688 |
+
tokens = {
|
| 689 |
+
'root':
|
| 690 |
+
[
|
| 691 |
+
(r'//.*?\n', Comment.Single),
|
| 692 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 693 |
+
(r'"', String.Double, 'string'),
|
| 694 |
+
(lsl_keywords, Keyword),
|
| 695 |
+
(lsl_types, Keyword.Type),
|
| 696 |
+
(lsl_states, Name.Class),
|
| 697 |
+
(lsl_events, Name.Builtin),
|
| 698 |
+
(lsl_functions_builtin, Name.Function),
|
| 699 |
+
(lsl_constants_float, Keyword.Constant),
|
| 700 |
+
(lsl_constants_integer, Keyword.Constant),
|
| 701 |
+
(lsl_constants_integer_boolean, Keyword.Constant),
|
| 702 |
+
(lsl_constants_rotation, Keyword.Constant),
|
| 703 |
+
(lsl_constants_string, Keyword.Constant),
|
| 704 |
+
(lsl_constants_vector, Keyword.Constant),
|
| 705 |
+
(lsl_invalid_broken, Error),
|
| 706 |
+
(lsl_invalid_deprecated, Error),
|
| 707 |
+
(lsl_invalid_illegal, Error),
|
| 708 |
+
(lsl_invalid_unimplemented, Error),
|
| 709 |
+
(lsl_reserved_godmode, Keyword.Reserved),
|
| 710 |
+
(lsl_reserved_log, Keyword.Reserved),
|
| 711 |
+
(r'\b([a-zA-Z_]\w*)\b', Name.Variable),
|
| 712 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),
|
| 713 |
+
(r'(\d+\.\d*|\.\d+)', Number.Float),
|
| 714 |
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
| 715 |
+
(r'\d+', Number.Integer),
|
| 716 |
+
(lsl_operators, Operator),
|
| 717 |
+
(r':=?', Error),
|
| 718 |
+
(r'[,;{}()\[\]]', Punctuation),
|
| 719 |
+
(r'\n+', Whitespace),
|
| 720 |
+
(r'\s+', Whitespace)
|
| 721 |
+
],
|
| 722 |
+
'comment':
|
| 723 |
+
[
|
| 724 |
+
(r'[^*/]+', Comment.Multiline),
|
| 725 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 726 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 727 |
+
(r'[*/]', Comment.Multiline)
|
| 728 |
+
],
|
| 729 |
+
'string':
|
| 730 |
+
[
|
| 731 |
+
(r'\\([nt"\\])', String.Escape),
|
| 732 |
+
(r'"', String.Double, '#pop'),
|
| 733 |
+
(r'\\.', Error),
|
| 734 |
+
(r'[^"\\]+', String.Double),
|
| 735 |
+
]
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
|
| 739 |
+
class AppleScriptLexer(RegexLexer):
|
| 740 |
+
"""
|
| 741 |
+
For AppleScript source code,
|
| 742 |
+
including `AppleScript Studio
|
| 743 |
+
<http://developer.apple.com/documentation/AppleScript/
|
| 744 |
+
Reference/StudioReference>`_.
|
| 745 |
+
Contributed by Andreas Amann <aamann@mac.com>.
|
| 746 |
+
"""
|
| 747 |
+
|
| 748 |
+
name = 'AppleScript'
|
| 749 |
+
url = 'https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html'
|
| 750 |
+
aliases = ['applescript']
|
| 751 |
+
filenames = ['*.applescript']
|
| 752 |
+
version_added = '1.0'
|
| 753 |
+
|
| 754 |
+
flags = re.MULTILINE | re.DOTALL
|
| 755 |
+
|
| 756 |
+
Identifiers = r'[a-zA-Z]\w*'
|
| 757 |
+
|
| 758 |
+
# XXX: use words() for all of these
|
| 759 |
+
Literals = ('AppleScript', 'current application', 'false', 'linefeed',
|
| 760 |
+
'missing value', 'pi', 'quote', 'result', 'return', 'space',
|
| 761 |
+
'tab', 'text item delimiters', 'true', 'version')
|
| 762 |
+
Classes = ('alias ', 'application ', 'boolean ', 'class ', 'constant ',
|
| 763 |
+
'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',
|
| 764 |
+
'real ', 'record ', 'reference ', 'RGB color ', 'script ',
|
| 765 |
+
'text ', 'unit types', '(?:Unicode )?text', 'string')
|
| 766 |
+
BuiltIn = ('attachment', 'attribute run', 'character', 'day', 'month',
|
| 767 |
+
'paragraph', 'word', 'year')
|
| 768 |
+
HandlerParams = ('about', 'above', 'against', 'apart from', 'around',
|
| 769 |
+
'aside from', 'at', 'below', 'beneath', 'beside',
|
| 770 |
+
'between', 'for', 'given', 'instead of', 'on', 'onto',
|
| 771 |
+
'out of', 'over', 'since')
|
| 772 |
+
Commands = ('ASCII (character|number)', 'activate', 'beep', 'choose URL',
|
| 773 |
+
'choose application', 'choose color', 'choose file( name)?',
|
| 774 |
+
'choose folder', 'choose from list',
|
| 775 |
+
'choose remote application', 'clipboard info',
|
| 776 |
+
'close( access)?', 'copy', 'count', 'current date', 'delay',
|
| 777 |
+
'delete', 'display (alert|dialog)', 'do shell script',
|
| 778 |
+
'duplicate', 'exists', 'get eof', 'get volume settings',
|
| 779 |
+
'info for', 'launch', 'list (disks|folder)', 'load script',
|
| 780 |
+
'log', 'make', 'mount volume', 'new', 'offset',
|
| 781 |
+
'open( (for access|location))?', 'path to', 'print', 'quit',
|
| 782 |
+
'random number', 'read', 'round', 'run( script)?',
|
| 783 |
+
'say', 'scripting components',
|
| 784 |
+
'set (eof|the clipboard to|volume)', 'store script',
|
| 785 |
+
'summarize', 'system attribute', 'system info',
|
| 786 |
+
'the clipboard', 'time to GMT', 'write', 'quoted form')
|
| 787 |
+
References = ('(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',
|
| 788 |
+
'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
|
| 789 |
+
'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',
|
| 790 |
+
'before', 'behind', 'every', 'front', 'index', 'last',
|
| 791 |
+
'middle', 'some', 'that', 'through', 'thru', 'where', 'whose')
|
| 792 |
+
Operators = ("and", "or", "is equal", "equals", "(is )?equal to", "is not",
|
| 793 |
+
"isn't", "isn't equal( to)?", "is not equal( to)?",
|
| 794 |
+
"doesn't equal", "does not equal", "(is )?greater than",
|
| 795 |
+
"comes after", "is not less than or equal( to)?",
|
| 796 |
+
"isn't less than or equal( to)?", "(is )?less than",
|
| 797 |
+
"comes before", "is not greater than or equal( to)?",
|
| 798 |
+
"isn't greater than or equal( to)?",
|
| 799 |
+
"(is )?greater than or equal( to)?", "is not less than",
|
| 800 |
+
"isn't less than", "does not come before",
|
| 801 |
+
"doesn't come before", "(is )?less than or equal( to)?",
|
| 802 |
+
"is not greater than", "isn't greater than",
|
| 803 |
+
"does not come after", "doesn't come after", "starts? with",
|
| 804 |
+
"begins? with", "ends? with", "contains?", "does not contain",
|
| 805 |
+
"doesn't contain", "is in", "is contained by", "is not in",
|
| 806 |
+
"is not contained by", "isn't contained by", "div", "mod",
|
| 807 |
+
"not", "(a )?(ref( to)?|reference to)", "is", "does")
|
| 808 |
+
Control = ('considering', 'else', 'error', 'exit', 'from', 'if',
|
| 809 |
+
'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',
|
| 810 |
+
'try', 'until', 'using terms from', 'while', 'whith',
|
| 811 |
+
'with timeout( of)?', 'with transaction', 'by', 'continue',
|
| 812 |
+
'end', 'its?', 'me', 'my', 'return', 'of', 'as')
|
| 813 |
+
Declarations = ('global', 'local', 'prop(erty)?', 'set', 'get')
|
| 814 |
+
Reserved = ('but', 'put', 'returning', 'the')
|
| 815 |
+
StudioClasses = ('action cell', 'alert reply', 'application', 'box',
|
| 816 |
+
'browser( cell)?', 'bundle', 'button( cell)?', 'cell',
|
| 817 |
+
'clip view', 'color well', 'color-panel',
|
| 818 |
+
'combo box( item)?', 'control',
|
| 819 |
+
'data( (cell|column|item|row|source))?', 'default entry',
|
| 820 |
+
'dialog reply', 'document', 'drag info', 'drawer',
|
| 821 |
+
'event', 'font(-panel)?', 'formatter',
|
| 822 |
+
'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',
|
| 823 |
+
'movie( view)?', 'open-panel', 'outline view', 'panel',
|
| 824 |
+
'pasteboard', 'plugin', 'popup button',
|
| 825 |
+
'progress indicator', 'responder', 'save-panel',
|
| 826 |
+
'scroll view', 'secure text field( cell)?', 'slider',
|
| 827 |
+
'sound', 'split view', 'stepper', 'tab view( item)?',
|
| 828 |
+
'table( (column|header cell|header view|view))',
|
| 829 |
+
'text( (field( cell)?|view))?', 'toolbar( item)?',
|
| 830 |
+
'user-defaults', 'view', 'window')
|
| 831 |
+
StudioEvents = ('accept outline drop', 'accept table drop', 'action',
|
| 832 |
+
'activated', 'alert ended', 'awake from nib', 'became key',
|
| 833 |
+
'became main', 'begin editing', 'bounds changed',
|
| 834 |
+
'cell value', 'cell value changed', 'change cell value',
|
| 835 |
+
'change item value', 'changed', 'child of item',
|
| 836 |
+
'choose menu item', 'clicked', 'clicked toolbar item',
|
| 837 |
+
'closed', 'column clicked', 'column moved',
|
| 838 |
+
'column resized', 'conclude drop', 'data representation',
|
| 839 |
+
'deminiaturized', 'dialog ended', 'document nib name',
|
| 840 |
+
'double clicked', 'drag( (entered|exited|updated))?',
|
| 841 |
+
'drop', 'end editing', 'exposed', 'idle', 'item expandable',
|
| 842 |
+
'item value', 'item value changed', 'items changed',
|
| 843 |
+
'keyboard down', 'keyboard up', 'launched',
|
| 844 |
+
'load data representation', 'miniaturized', 'mouse down',
|
| 845 |
+
'mouse dragged', 'mouse entered', 'mouse exited',
|
| 846 |
+
'mouse moved', 'mouse up', 'moved',
|
| 847 |
+
'number of browser rows', 'number of items',
|
| 848 |
+
'number of rows', 'open untitled', 'opened', 'panel ended',
|
| 849 |
+
'parameters updated', 'plugin loaded', 'prepare drop',
|
| 850 |
+
'prepare outline drag', 'prepare outline drop',
|
| 851 |
+
'prepare table drag', 'prepare table drop',
|
| 852 |
+
'read from file', 'resigned active', 'resigned key',
|
| 853 |
+
'resigned main', 'resized( sub views)?',
|
| 854 |
+
'right mouse down', 'right mouse dragged',
|
| 855 |
+
'right mouse up', 'rows changed', 'scroll wheel',
|
| 856 |
+
'selected tab view item', 'selection changed',
|
| 857 |
+
'selection changing', 'should begin editing',
|
| 858 |
+
'should close', 'should collapse item',
|
| 859 |
+
'should end editing', 'should expand item',
|
| 860 |
+
'should open( untitled)?',
|
| 861 |
+
'should quit( after last window closed)?',
|
| 862 |
+
'should select column', 'should select item',
|
| 863 |
+
'should select row', 'should select tab view item',
|
| 864 |
+
'should selection change', 'should zoom', 'shown',
|
| 865 |
+
'update menu item', 'update parameters',
|
| 866 |
+
'update toolbar item', 'was hidden', 'was miniaturized',
|
| 867 |
+
'will become active', 'will close', 'will dismiss',
|
| 868 |
+
'will display browser cell', 'will display cell',
|
| 869 |
+
'will display item cell', 'will display outline cell',
|
| 870 |
+
'will finish launching', 'will hide', 'will miniaturize',
|
| 871 |
+
'will move', 'will open', 'will pop up', 'will quit',
|
| 872 |
+
'will resign active', 'will resize( sub views)?',
|
| 873 |
+
'will select tab view item', 'will show', 'will zoom',
|
| 874 |
+
'write to file', 'zoomed')
|
| 875 |
+
StudioCommands = ('animate', 'append', 'call method', 'center',
|
| 876 |
+
'close drawer', 'close panel', 'display',
|
| 877 |
+
'display alert', 'display dialog', 'display panel', 'go',
|
| 878 |
+
'hide', 'highlight', 'increment', 'item for',
|
| 879 |
+
'load image', 'load movie', 'load nib', 'load panel',
|
| 880 |
+
'load sound', 'localized string', 'lock focus', 'log',
|
| 881 |
+
'open drawer', 'path for', 'pause', 'perform action',
|
| 882 |
+
'play', 'register', 'resume', 'scroll', 'select( all)?',
|
| 883 |
+
'show', 'size to fit', 'start', 'step back',
|
| 884 |
+
'step forward', 'stop', 'synchronize', 'unlock focus',
|
| 885 |
+
'update')
|
| 886 |
+
StudioProperties = ('accepts arrow key', 'action method', 'active',
|
| 887 |
+
'alignment', 'allowed identifiers',
|
| 888 |
+
'allows branch selection', 'allows column reordering',
|
| 889 |
+
'allows column resizing', 'allows column selection',
|
| 890 |
+
'allows customization',
|
| 891 |
+
'allows editing text attributes',
|
| 892 |
+
'allows empty selection', 'allows mixed state',
|
| 893 |
+
'allows multiple selection', 'allows reordering',
|
| 894 |
+
'allows undo', 'alpha( value)?', 'alternate image',
|
| 895 |
+
'alternate increment value', 'alternate title',
|
| 896 |
+
'animation delay', 'associated file name',
|
| 897 |
+
'associated object', 'auto completes', 'auto display',
|
| 898 |
+
'auto enables items', 'auto repeat',
|
| 899 |
+
'auto resizes( outline column)?',
|
| 900 |
+
'auto save expanded items', 'auto save name',
|
| 901 |
+
'auto save table columns', 'auto saves configuration',
|
| 902 |
+
'auto scroll', 'auto sizes all columns to fit',
|
| 903 |
+
'auto sizes cells', 'background color', 'bezel state',
|
| 904 |
+
'bezel style', 'bezeled', 'border rect', 'border type',
|
| 905 |
+
'bordered', 'bounds( rotation)?', 'box type',
|
| 906 |
+
'button returned', 'button type',
|
| 907 |
+
'can choose directories', 'can choose files',
|
| 908 |
+
'can draw', 'can hide',
|
| 909 |
+
'cell( (background color|size|type))?', 'characters',
|
| 910 |
+
'class', 'click count', 'clicked( data)? column',
|
| 911 |
+
'clicked data item', 'clicked( data)? row',
|
| 912 |
+
'closeable', 'collating', 'color( (mode|panel))',
|
| 913 |
+
'command key down', 'configuration',
|
| 914 |
+
'content(s| (size|view( margins)?))?', 'context',
|
| 915 |
+
'continuous', 'control key down', 'control size',
|
| 916 |
+
'control tint', 'control view',
|
| 917 |
+
'controller visible', 'coordinate system',
|
| 918 |
+
'copies( on scroll)?', 'corner view', 'current cell',
|
| 919 |
+
'current column', 'current( field)? editor',
|
| 920 |
+
'current( menu)? item', 'current row',
|
| 921 |
+
'current tab view item', 'data source',
|
| 922 |
+
'default identifiers', 'delta (x|y|z)',
|
| 923 |
+
'destination window', 'directory', 'display mode',
|
| 924 |
+
'displayed cell', 'document( (edited|rect|view))?',
|
| 925 |
+
'double value', 'dragged column', 'dragged distance',
|
| 926 |
+
'dragged items', 'draws( cell)? background',
|
| 927 |
+
'draws grid', 'dynamically scrolls', 'echos bullets',
|
| 928 |
+
'edge', 'editable', 'edited( data)? column',
|
| 929 |
+
'edited data item', 'edited( data)? row', 'enabled',
|
| 930 |
+
'enclosing scroll view', 'ending page',
|
| 931 |
+
'error handling', 'event number', 'event type',
|
| 932 |
+
'excluded from windows menu', 'executable path',
|
| 933 |
+
'expanded', 'fax number', 'field editor', 'file kind',
|
| 934 |
+
'file name', 'file type', 'first responder',
|
| 935 |
+
'first visible column', 'flipped', 'floating',
|
| 936 |
+
'font( panel)?', 'formatter', 'frameworks path',
|
| 937 |
+
'frontmost', 'gave up', 'grid color', 'has data items',
|
| 938 |
+
'has horizontal ruler', 'has horizontal scroller',
|
| 939 |
+
'has parent data item', 'has resize indicator',
|
| 940 |
+
'has shadow', 'has sub menu', 'has vertical ruler',
|
| 941 |
+
'has vertical scroller', 'header cell', 'header view',
|
| 942 |
+
'hidden', 'hides when deactivated', 'highlights by',
|
| 943 |
+
'horizontal line scroll', 'horizontal page scroll',
|
| 944 |
+
'horizontal ruler view', 'horizontally resizable',
|
| 945 |
+
'icon image', 'id', 'identifier',
|
| 946 |
+
'ignores multiple clicks',
|
| 947 |
+
'image( (alignment|dims when disabled|frame style|scaling))?',
|
| 948 |
+
'imports graphics', 'increment value',
|
| 949 |
+
'indentation per level', 'indeterminate', 'index',
|
| 950 |
+
'integer value', 'intercell spacing', 'item height',
|
| 951 |
+
'key( (code|equivalent( modifier)?|window))?',
|
| 952 |
+
'knob thickness', 'label', 'last( visible)? column',
|
| 953 |
+
'leading offset', 'leaf', 'level', 'line scroll',
|
| 954 |
+
'loaded', 'localized sort', 'location', 'loop mode',
|
| 955 |
+
'main( (bunde|menu|window))?', 'marker follows cell',
|
| 956 |
+
'matrix mode', 'maximum( content)? size',
|
| 957 |
+
'maximum visible columns',
|
| 958 |
+
'menu( form representation)?', 'miniaturizable',
|
| 959 |
+
'miniaturized', 'minimized image', 'minimized title',
|
| 960 |
+
'minimum column width', 'minimum( content)? size',
|
| 961 |
+
'modal', 'modified', 'mouse down state',
|
| 962 |
+
'movie( (controller|file|rect))?', 'muted', 'name',
|
| 963 |
+
'needs display', 'next state', 'next text',
|
| 964 |
+
'number of tick marks', 'only tick mark values',
|
| 965 |
+
'opaque', 'open panel', 'option key down',
|
| 966 |
+
'outline table column', 'page scroll', 'pages across',
|
| 967 |
+
'pages down', 'palette label', 'pane splitter',
|
| 968 |
+
'parent data item', 'parent window', 'pasteboard',
|
| 969 |
+
'path( (names|separator))?', 'playing',
|
| 970 |
+
'plays every frame', 'plays selection only', 'position',
|
| 971 |
+
'preferred edge', 'preferred type', 'pressure',
|
| 972 |
+
'previous text', 'prompt', 'properties',
|
| 973 |
+
'prototype cell', 'pulls down', 'rate',
|
| 974 |
+
'released when closed', 'repeated',
|
| 975 |
+
'requested print time', 'required file type',
|
| 976 |
+
'resizable', 'resized column', 'resource path',
|
| 977 |
+
'returns records', 'reuses columns', 'rich text',
|
| 978 |
+
'roll over', 'row height', 'rulers visible',
|
| 979 |
+
'save panel', 'scripts path', 'scrollable',
|
| 980 |
+
'selectable( identifiers)?', 'selected cell',
|
| 981 |
+
'selected( data)? columns?', 'selected data items?',
|
| 982 |
+
'selected( data)? rows?', 'selected item identifier',
|
| 983 |
+
'selection by rect', 'send action on arrow key',
|
| 984 |
+
'sends action when done editing', 'separates columns',
|
| 985 |
+
'separator item', 'sequence number', 'services menu',
|
| 986 |
+
'shared frameworks path', 'shared support path',
|
| 987 |
+
'sheet', 'shift key down', 'shows alpha',
|
| 988 |
+
'shows state by', 'size( mode)?',
|
| 989 |
+
'smart insert delete enabled', 'sort case sensitivity',
|
| 990 |
+
'sort column', 'sort order', 'sort type',
|
| 991 |
+
'sorted( data rows)?', 'sound', 'source( mask)?',
|
| 992 |
+
'spell checking enabled', 'starting page', 'state',
|
| 993 |
+
'string value', 'sub menu', 'super menu', 'super view',
|
| 994 |
+
'tab key traverses cells', 'tab state', 'tab type',
|
| 995 |
+
'tab view', 'table view', 'tag', 'target( printer)?',
|
| 996 |
+
'text color', 'text container insert',
|
| 997 |
+
'text container origin', 'text returned',
|
| 998 |
+
'tick mark position', 'time stamp',
|
| 999 |
+
'title(d| (cell|font|height|position|rect))?',
|
| 1000 |
+
'tool tip', 'toolbar', 'trailing offset', 'transparent',
|
| 1001 |
+
'treat packages as directories', 'truncated labels',
|
| 1002 |
+
'types', 'unmodified characters', 'update views',
|
| 1003 |
+
'use sort indicator', 'user defaults',
|
| 1004 |
+
'uses data source', 'uses ruler',
|
| 1005 |
+
'uses threaded animation',
|
| 1006 |
+
'uses title from previous column', 'value wraps',
|
| 1007 |
+
'version',
|
| 1008 |
+
'vertical( (line scroll|page scroll|ruler view))?',
|
| 1009 |
+
'vertically resizable', 'view',
|
| 1010 |
+
'visible( document rect)?', 'volume', 'width', 'window',
|
| 1011 |
+
'windows menu', 'wraps', 'zoomable', 'zoomed')
|
| 1012 |
+
|
| 1013 |
+
tokens = {
|
| 1014 |
+
'root': [
|
| 1015 |
+
(r'\s+', Text),
|
| 1016 |
+
(r'¬\n', String.Escape),
|
| 1017 |
+
(r"'s\s+", Text), # This is a possessive, consider moving
|
| 1018 |
+
(r'(--|#).*?$', Comment),
|
| 1019 |
+
(r'\(\*', Comment.Multiline, 'comment'),
|
| 1020 |
+
(r'[(){}!,.:]', Punctuation),
|
| 1021 |
+
(r'(«)([^»]+)(»)',
|
| 1022 |
+
bygroups(Text, Name.Builtin, Text)),
|
| 1023 |
+
(r'\b((?:considering|ignoring)\s*)'
|
| 1024 |
+
r'(application responses|case|diacriticals|hyphens|'
|
| 1025 |
+
r'numeric strings|punctuation|white space)',
|
| 1026 |
+
bygroups(Keyword, Name.Builtin)),
|
| 1027 |
+
(r'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator),
|
| 1028 |
+
(r"\b({})\b".format('|'.join(Operators)), Operator.Word),
|
| 1029 |
+
(r'^(\s*(?:on|end)\s+)'
|
| 1030 |
+
r'({})'.format('|'.join(StudioEvents[::-1])),
|
| 1031 |
+
bygroups(Keyword, Name.Function)),
|
| 1032 |
+
(r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)),
|
| 1033 |
+
(r'\b(as )({})\b'.format('|'.join(Classes)),
|
| 1034 |
+
bygroups(Keyword, Name.Class)),
|
| 1035 |
+
(r'\b({})\b'.format('|'.join(Literals)), Name.Constant),
|
| 1036 |
+
(r'\b({})\b'.format('|'.join(Commands)), Name.Builtin),
|
| 1037 |
+
(r'\b({})\b'.format('|'.join(Control)), Keyword),
|
| 1038 |
+
(r'\b({})\b'.format('|'.join(Declarations)), Keyword),
|
| 1039 |
+
(r'\b({})\b'.format('|'.join(Reserved)), Name.Builtin),
|
| 1040 |
+
(r'\b({})s?\b'.format('|'.join(BuiltIn)), Name.Builtin),
|
| 1041 |
+
(r'\b({})\b'.format('|'.join(HandlerParams)), Name.Builtin),
|
| 1042 |
+
(r'\b({})\b'.format('|'.join(StudioProperties)), Name.Attribute),
|
| 1043 |
+
(r'\b({})s?\b'.format('|'.join(StudioClasses)), Name.Builtin),
|
| 1044 |
+
(r'\b({})\b'.format('|'.join(StudioCommands)), Name.Builtin),
|
| 1045 |
+
(r'\b({})\b'.format('|'.join(References)), Name.Builtin),
|
| 1046 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 1047 |
+
(rf'\b({Identifiers})\b', Name.Variable),
|
| 1048 |
+
(r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float),
|
| 1049 |
+
(r'[-+]?\d+', Number.Integer),
|
| 1050 |
+
],
|
| 1051 |
+
'comment': [
|
| 1052 |
+
(r'\(\*', Comment.Multiline, '#push'),
|
| 1053 |
+
(r'\*\)', Comment.Multiline, '#pop'),
|
| 1054 |
+
('[^*(]+', Comment.Multiline),
|
| 1055 |
+
('[*(]', Comment.Multiline),
|
| 1056 |
+
],
|
| 1057 |
+
}
|
| 1058 |
+
|
| 1059 |
+
|
| 1060 |
+
class RexxLexer(RegexLexer):
|
| 1061 |
+
"""
|
| 1062 |
+
Rexx is a scripting language available for
|
| 1063 |
+
a wide range of different platforms with its roots found on mainframe
|
| 1064 |
+
systems. It is popular for I/O- and data based tasks and can act as glue
|
| 1065 |
+
language to bind different applications together.
|
| 1066 |
+
"""
|
| 1067 |
+
name = 'Rexx'
|
| 1068 |
+
url = 'http://www.rexxinfo.org/'
|
| 1069 |
+
aliases = ['rexx', 'arexx']
|
| 1070 |
+
filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx']
|
| 1071 |
+
mimetypes = ['text/x-rexx']
|
| 1072 |
+
version_added = '2.0'
|
| 1073 |
+
flags = re.IGNORECASE
|
| 1074 |
+
|
| 1075 |
+
tokens = {
|
| 1076 |
+
'root': [
|
| 1077 |
+
(r'\s+', Whitespace),
|
| 1078 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 1079 |
+
(r'"', String, 'string_double'),
|
| 1080 |
+
(r"'", String, 'string_single'),
|
| 1081 |
+
(r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number),
|
| 1082 |
+
(r'([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b',
|
| 1083 |
+
bygroups(Name.Function, Whitespace, Operator, Whitespace,
|
| 1084 |
+
Keyword.Declaration)),
|
| 1085 |
+
(r'([a-z_]\w*)(\s*)(:)',
|
| 1086 |
+
bygroups(Name.Label, Whitespace, Operator)),
|
| 1087 |
+
include('function'),
|
| 1088 |
+
include('keyword'),
|
| 1089 |
+
include('operator'),
|
| 1090 |
+
(r'[a-z_]\w*', Text),
|
| 1091 |
+
],
|
| 1092 |
+
'function': [
|
| 1093 |
+
(words((
|
| 1094 |
+
'abbrev', 'abs', 'address', 'arg', 'b2x', 'bitand', 'bitor', 'bitxor',
|
| 1095 |
+
'c2d', 'c2x', 'center', 'charin', 'charout', 'chars', 'compare',
|
| 1096 |
+
'condition', 'copies', 'd2c', 'd2x', 'datatype', 'date', 'delstr',
|
| 1097 |
+
'delword', 'digits', 'errortext', 'form', 'format', 'fuzz', 'insert',
|
| 1098 |
+
'lastpos', 'left', 'length', 'linein', 'lineout', 'lines', 'max',
|
| 1099 |
+
'min', 'overlay', 'pos', 'queued', 'random', 'reverse', 'right', 'sign',
|
| 1100 |
+
'sourceline', 'space', 'stream', 'strip', 'substr', 'subword', 'symbol',
|
| 1101 |
+
'time', 'trace', 'translate', 'trunc', 'value', 'verify', 'word',
|
| 1102 |
+
'wordindex', 'wordlength', 'wordpos', 'words', 'x2b', 'x2c', 'x2d',
|
| 1103 |
+
'xrange'), suffix=r'(\s*)(\()'),
|
| 1104 |
+
bygroups(Name.Builtin, Whitespace, Operator)),
|
| 1105 |
+
],
|
| 1106 |
+
'keyword': [
|
| 1107 |
+
(r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|'
|
| 1108 |
+
r'interpret|iterate|leave|nop|numeric|off|on|options|parse|'
|
| 1109 |
+
r'pull|push|queue|return|say|select|signal|to|then|trace|until|'
|
| 1110 |
+
r'while)\b', Keyword.Reserved),
|
| 1111 |
+
],
|
| 1112 |
+
'operator': [
|
| 1113 |
+
(r'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||'
|
| 1114 |
+
r'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|'
|
| 1115 |
+
r'¬>>|¬>|¬|\.|,)', Operator),
|
| 1116 |
+
],
|
| 1117 |
+
'string_double': [
|
| 1118 |
+
(r'[^"\n]+', String),
|
| 1119 |
+
(r'""', String),
|
| 1120 |
+
(r'"', String, '#pop'),
|
| 1121 |
+
(r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
|
| 1122 |
+
],
|
| 1123 |
+
'string_single': [
|
| 1124 |
+
(r'[^\'\n]+', String),
|
| 1125 |
+
(r'\'\'', String),
|
| 1126 |
+
(r'\'', String, '#pop'),
|
| 1127 |
+
(r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
|
| 1128 |
+
],
|
| 1129 |
+
'comment': [
|
| 1130 |
+
(r'[^*]+', Comment.Multiline),
|
| 1131 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 1132 |
+
(r'\*', Comment.Multiline),
|
| 1133 |
+
]
|
| 1134 |
+
}
|
| 1135 |
+
|
| 1136 |
+
def _c(s):
|
| 1137 |
+
return re.compile(s, re.MULTILINE)
|
| 1138 |
+
_ADDRESS_COMMAND_PATTERN = _c(r'^\s*address\s+command\b')
|
| 1139 |
+
_ADDRESS_PATTERN = _c(r'^\s*address\s+')
|
| 1140 |
+
_DO_WHILE_PATTERN = _c(r'^\s*do\s+while\b')
|
| 1141 |
+
_IF_THEN_DO_PATTERN = _c(r'^\s*if\b.+\bthen\s+do\s*$')
|
| 1142 |
+
_PROCEDURE_PATTERN = _c(r'^\s*([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b')
|
| 1143 |
+
_ELSE_DO_PATTERN = _c(r'\belse\s+do\s*$')
|
| 1144 |
+
_PARSE_ARG_PATTERN = _c(r'^\s*parse\s+(upper\s+)?(arg|value)\b')
|
| 1145 |
+
PATTERNS_AND_WEIGHTS = (
|
| 1146 |
+
(_ADDRESS_COMMAND_PATTERN, 0.2),
|
| 1147 |
+
(_ADDRESS_PATTERN, 0.05),
|
| 1148 |
+
(_DO_WHILE_PATTERN, 0.1),
|
| 1149 |
+
(_ELSE_DO_PATTERN, 0.1),
|
| 1150 |
+
(_IF_THEN_DO_PATTERN, 0.1),
|
| 1151 |
+
(_PROCEDURE_PATTERN, 0.5),
|
| 1152 |
+
(_PARSE_ARG_PATTERN, 0.2),
|
| 1153 |
+
)
|
| 1154 |
+
|
| 1155 |
+
def analyse_text(text):
|
| 1156 |
+
"""
|
| 1157 |
+
Check for initial comment and patterns that distinguish Rexx from other
|
| 1158 |
+
C-like languages.
|
| 1159 |
+
"""
|
| 1160 |
+
if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE):
|
| 1161 |
+
# Header matches MVS Rexx requirements, this is certainly a Rexx
|
| 1162 |
+
# script.
|
| 1163 |
+
return 1.0
|
| 1164 |
+
elif text.startswith('/*'):
|
| 1165 |
+
# Header matches general Rexx requirements; the source code might
|
| 1166 |
+
# still be any language using C comments such as C++, C# or Java.
|
| 1167 |
+
lowerText = text.lower()
|
| 1168 |
+
result = sum(weight
|
| 1169 |
+
for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS
|
| 1170 |
+
if pattern.search(lowerText)) + 0.01
|
| 1171 |
+
return min(result, 1.0)
|
| 1172 |
+
|
| 1173 |
+
|
| 1174 |
+
class MOOCodeLexer(RegexLexer):
|
| 1175 |
+
"""
|
| 1176 |
+
For MOOCode (the MOO scripting language).
|
| 1177 |
+
"""
|
| 1178 |
+
name = 'MOOCode'
|
| 1179 |
+
url = 'http://www.moo.mud.org/'
|
| 1180 |
+
filenames = ['*.moo']
|
| 1181 |
+
aliases = ['moocode', 'moo']
|
| 1182 |
+
mimetypes = ['text/x-moocode']
|
| 1183 |
+
version_added = '0.9'
|
| 1184 |
+
|
| 1185 |
+
tokens = {
|
| 1186 |
+
'root': [
|
| 1187 |
+
# Numbers
|
| 1188 |
+
(r'(0|[1-9][0-9_]*)', Number.Integer),
|
| 1189 |
+
# Strings
|
| 1190 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 1191 |
+
# exceptions
|
| 1192 |
+
(r'(E_PERM|E_DIV)', Name.Exception),
|
| 1193 |
+
# db-refs
|
| 1194 |
+
(r'((#[-0-9]+)|(\$\w+))', Name.Entity),
|
| 1195 |
+
# Keywords
|
| 1196 |
+
(r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while'
|
| 1197 |
+
r'|endwhile|break|continue|return|try'
|
| 1198 |
+
r'|except|endtry|finally|in)\b', Keyword),
|
| 1199 |
+
# builtins
|
| 1200 |
+
(r'(random|length)', Name.Builtin),
|
| 1201 |
+
# special variables
|
| 1202 |
+
(r'(player|caller|this|args)', Name.Variable.Instance),
|
| 1203 |
+
# skip whitespace
|
| 1204 |
+
(r'\s+', Text),
|
| 1205 |
+
(r'\n', Text),
|
| 1206 |
+
# other operators
|
| 1207 |
+
(r'([!;=,{}&|:.\[\]@()<>?]+)', Operator),
|
| 1208 |
+
# function call
|
| 1209 |
+
(r'(\w+)(\()', bygroups(Name.Function, Operator)),
|
| 1210 |
+
# variables
|
| 1211 |
+
(r'(\w+)', Text),
|
| 1212 |
+
]
|
| 1213 |
+
}
|
| 1214 |
+
|
| 1215 |
+
|
| 1216 |
+
class HybrisLexer(RegexLexer):
|
| 1217 |
+
"""
|
| 1218 |
+
For Hybris source code.
|
| 1219 |
+
"""
|
| 1220 |
+
|
| 1221 |
+
name = 'Hybris'
|
| 1222 |
+
aliases = ['hybris']
|
| 1223 |
+
filenames = ['*.hyb']
|
| 1224 |
+
mimetypes = ['text/x-hybris', 'application/x-hybris']
|
| 1225 |
+
url = 'https://github.com/evilsocket/hybris'
|
| 1226 |
+
version_added = '1.4'
|
| 1227 |
+
|
| 1228 |
+
flags = re.MULTILINE | re.DOTALL
|
| 1229 |
+
|
| 1230 |
+
tokens = {
|
| 1231 |
+
'root': [
|
| 1232 |
+
# method names
|
| 1233 |
+
(r'^(\s*(?:function|method|operator\s+)+?)'
|
| 1234 |
+
r'([a-zA-Z_]\w*)'
|
| 1235 |
+
r'(\s*)(\()', bygroups(Keyword, Name.Function, Text, Operator)),
|
| 1236 |
+
(r'[^\S\n]+', Text),
|
| 1237 |
+
(r'//.*?\n', Comment.Single),
|
| 1238 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 1239 |
+
(r'@[a-zA-Z_][\w.]*', Name.Decorator),
|
| 1240 |
+
(r'(break|case|catch|next|default|do|else|finally|for|foreach|of|'
|
| 1241 |
+
r'unless|if|new|return|switch|me|throw|try|while)\b', Keyword),
|
| 1242 |
+
(r'(extends|private|protected|public|static|throws|function|method|'
|
| 1243 |
+
r'operator)\b', Keyword.Declaration),
|
| 1244 |
+
(r'(true|false|null|__FILE__|__LINE__|__VERSION__|__LIB_PATH__|'
|
| 1245 |
+
r'__INC_PATH__)\b', Keyword.Constant),
|
| 1246 |
+
(r'(class|struct)(\s+)',
|
| 1247 |
+
bygroups(Keyword.Declaration, Text), 'class'),
|
| 1248 |
+
(r'(import|include)(\s+)',
|
| 1249 |
+
bygroups(Keyword.Namespace, Text), 'import'),
|
| 1250 |
+
(words((
|
| 1251 |
+
'gc_collect', 'gc_mm_items', 'gc_mm_usage', 'gc_collect_threshold',
|
| 1252 |
+
'urlencode', 'urldecode', 'base64encode', 'base64decode', 'sha1', 'crc32',
|
| 1253 |
+
'sha2', 'md5', 'md5_file', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos',
|
| 1254 |
+
'cosh', 'exp', 'fabs', 'floor', 'fmod', 'log', 'log10', 'pow', 'sin',
|
| 1255 |
+
'sinh', 'sqrt', 'tan', 'tanh', 'isint', 'isfloat', 'ischar', 'isstring',
|
| 1256 |
+
'isarray', 'ismap', 'isalias', 'typeof', 'sizeof', 'toint', 'tostring',
|
| 1257 |
+
'fromxml', 'toxml', 'binary', 'pack', 'load', 'eval', 'var_names',
|
| 1258 |
+
'var_values', 'user_functions', 'dyn_functions', 'methods', 'call',
|
| 1259 |
+
'call_method', 'mknod', 'mkfifo', 'mount', 'umount2', 'umount', 'ticks',
|
| 1260 |
+
'usleep', 'sleep', 'time', 'strtime', 'strdate', 'dllopen', 'dlllink',
|
| 1261 |
+
'dllcall', 'dllcall_argv', 'dllclose', 'env', 'exec', 'fork', 'getpid',
|
| 1262 |
+
'wait', 'popen', 'pclose', 'exit', 'kill', 'pthread_create',
|
| 1263 |
+
'pthread_create_argv', 'pthread_exit', 'pthread_join', 'pthread_kill',
|
| 1264 |
+
'smtp_send', 'http_get', 'http_post', 'http_download', 'socket', 'bind',
|
| 1265 |
+
'listen', 'accept', 'getsockname', 'getpeername', 'settimeout', 'connect',
|
| 1266 |
+
'server', 'recv', 'send', 'close', 'print', 'println', 'printf', 'input',
|
| 1267 |
+
'readline', 'serial_open', 'serial_fcntl', 'serial_get_attr',
|
| 1268 |
+
'serial_get_ispeed', 'serial_get_ospeed', 'serial_set_attr',
|
| 1269 |
+
'serial_set_ispeed', 'serial_set_ospeed', 'serial_write', 'serial_read',
|
| 1270 |
+
'serial_close', 'xml_load', 'xml_parse', 'fopen', 'fseek', 'ftell',
|
| 1271 |
+
'fsize', 'fread', 'fwrite', 'fgets', 'fclose', 'file', 'readdir',
|
| 1272 |
+
'pcre_replace', 'size', 'pop', 'unmap', 'has', 'keys', 'values',
|
| 1273 |
+
'length', 'find', 'substr', 'replace', 'split', 'trim', 'remove',
|
| 1274 |
+
'contains', 'join'), suffix=r'\b'),
|
| 1275 |
+
Name.Builtin),
|
| 1276 |
+
(words((
|
| 1277 |
+
'MethodReference', 'Runner', 'Dll', 'Thread', 'Pipe', 'Process',
|
| 1278 |
+
'Runnable', 'CGI', 'ClientSocket', 'Socket', 'ServerSocket',
|
| 1279 |
+
'File', 'Console', 'Directory', 'Exception'), suffix=r'\b'),
|
| 1280 |
+
Keyword.Type),
|
| 1281 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 1282 |
+
(r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
|
| 1283 |
+
(r'(\.)([a-zA-Z_]\w*)',
|
| 1284 |
+
bygroups(Operator, Name.Attribute)),
|
| 1285 |
+
(r'[a-zA-Z_]\w*:', Name.Label),
|
| 1286 |
+
(r'[a-zA-Z_$]\w*', Name),
|
| 1287 |
+
(r'[~^*!%&\[\](){}<>|+=:;,./?\-@]+', Operator),
|
| 1288 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 1289 |
+
(r'0x[0-9a-f]+', Number.Hex),
|
| 1290 |
+
(r'[0-9]+L?', Number.Integer),
|
| 1291 |
+
(r'\n', Text),
|
| 1292 |
+
],
|
| 1293 |
+
'class': [
|
| 1294 |
+
(r'[a-zA-Z_]\w*', Name.Class, '#pop')
|
| 1295 |
+
],
|
| 1296 |
+
'import': [
|
| 1297 |
+
(r'[\w.]+\*?', Name.Namespace, '#pop')
|
| 1298 |
+
],
|
| 1299 |
+
}
|
| 1300 |
+
|
| 1301 |
+
def analyse_text(text):
|
| 1302 |
+
"""public method and private method don't seem to be quite common
|
| 1303 |
+
elsewhere."""
|
| 1304 |
+
result = 0
|
| 1305 |
+
if re.search(r'\b(?:public|private)\s+method\b', text):
|
| 1306 |
+
result += 0.01
|
| 1307 |
+
return result
|
| 1308 |
+
|
| 1309 |
+
|
| 1310 |
+
|
| 1311 |
+
class EasytrieveLexer(RegexLexer):
|
| 1312 |
+
"""
|
| 1313 |
+
Easytrieve Plus is a programming language for extracting, filtering and
|
| 1314 |
+
converting sequential data. Furthermore it can layout data for reports.
|
| 1315 |
+
It is mainly used on mainframe platforms and can access several of the
|
| 1316 |
+
mainframe's native file formats. It is somewhat comparable to awk.
|
| 1317 |
+
"""
|
| 1318 |
+
name = 'Easytrieve'
|
| 1319 |
+
aliases = ['easytrieve']
|
| 1320 |
+
filenames = ['*.ezt', '*.mac']
|
| 1321 |
+
mimetypes = ['text/x-easytrieve']
|
| 1322 |
+
url = 'https://www.broadcom.com/products/mainframe/application-development/easytrieve-report-generator'
|
| 1323 |
+
version_added = '2.1'
|
| 1324 |
+
flags = 0
|
| 1325 |
+
|
| 1326 |
+
# Note: We cannot use r'\b' at the start and end of keywords because
|
| 1327 |
+
# Easytrieve Plus delimiter characters are:
|
| 1328 |
+
#
|
| 1329 |
+
# * space ( )
|
| 1330 |
+
# * apostrophe (')
|
| 1331 |
+
# * period (.)
|
| 1332 |
+
# * comma (,)
|
| 1333 |
+
# * parenthesis ( and )
|
| 1334 |
+
# * colon (:)
|
| 1335 |
+
#
|
| 1336 |
+
# Additionally words end once a '*' appears, indicatins a comment.
|
| 1337 |
+
_DELIMITERS = r' \'.,():\n'
|
| 1338 |
+
_DELIMITERS_OR_COMENT = _DELIMITERS + '*'
|
| 1339 |
+
_DELIMITER_PATTERN = '[' + _DELIMITERS + ']'
|
| 1340 |
+
_DELIMITER_PATTERN_CAPTURE = '(' + _DELIMITER_PATTERN + ')'
|
| 1341 |
+
_NON_DELIMITER_OR_COMMENT_PATTERN = '[^' + _DELIMITERS_OR_COMENT + ']'
|
| 1342 |
+
_OPERATORS_PATTERN = '[.+\\-/=\\[\\](){}<>;,&%¬]'
|
| 1343 |
+
_KEYWORDS = [
|
| 1344 |
+
'AFTER-BREAK', 'AFTER-LINE', 'AFTER-SCREEN', 'AIM', 'AND', 'ATTR',
|
| 1345 |
+
'BEFORE', 'BEFORE-BREAK', 'BEFORE-LINE', 'BEFORE-SCREEN', 'BUSHU',
|
| 1346 |
+
'BY', 'CALL', 'CASE', 'CHECKPOINT', 'CHKP', 'CHKP-STATUS', 'CLEAR',
|
| 1347 |
+
'CLOSE', 'COL', 'COLOR', 'COMMIT', 'CONTROL', 'COPY', 'CURSOR', 'D',
|
| 1348 |
+
'DECLARE', 'DEFAULT', 'DEFINE', 'DELETE', 'DENWA', 'DISPLAY', 'DLI',
|
| 1349 |
+
'DO', 'DUPLICATE', 'E', 'ELSE', 'ELSE-IF', 'END', 'END-CASE',
|
| 1350 |
+
'END-DO', 'END-IF', 'END-PROC', 'ENDPAGE', 'ENDTABLE', 'ENTER', 'EOF',
|
| 1351 |
+
'EQ', 'ERROR', 'EXIT', 'EXTERNAL', 'EZLIB', 'F1', 'F10', 'F11', 'F12',
|
| 1352 |
+
'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F2', 'F20', 'F21',
|
| 1353 |
+
'F22', 'F23', 'F24', 'F25', 'F26', 'F27', 'F28', 'F29', 'F3', 'F30',
|
| 1354 |
+
'F31', 'F32', 'F33', 'F34', 'F35', 'F36', 'F4', 'F5', 'F6', 'F7',
|
| 1355 |
+
'F8', 'F9', 'FETCH', 'FILE-STATUS', 'FILL', 'FINAL', 'FIRST',
|
| 1356 |
+
'FIRST-DUP', 'FOR', 'GE', 'GET', 'GO', 'GOTO', 'GQ', 'GR', 'GT',
|
| 1357 |
+
'HEADING', 'HEX', 'HIGH-VALUES', 'IDD', 'IDMS', 'IF', 'IN', 'INSERT',
|
| 1358 |
+
'JUSTIFY', 'KANJI-DATE', 'KANJI-DATE-LONG', 'KANJI-TIME', 'KEY',
|
| 1359 |
+
'KEY-PRESSED', 'KOKUGO', 'KUN', 'LAST-DUP', 'LE', 'LEVEL', 'LIKE',
|
| 1360 |
+
'LINE', 'LINE-COUNT', 'LINE-NUMBER', 'LINK', 'LIST', 'LOW-VALUES',
|
| 1361 |
+
'LQ', 'LS', 'LT', 'MACRO', 'MASK', 'MATCHED', 'MEND', 'MESSAGE',
|
| 1362 |
+
'MOVE', 'MSTART', 'NE', 'NEWPAGE', 'NOMASK', 'NOPRINT', 'NOT',
|
| 1363 |
+
'NOTE', 'NOVERIFY', 'NQ', 'NULL', 'OF', 'OR', 'OTHERWISE', 'PA1',
|
| 1364 |
+
'PA2', 'PA3', 'PAGE-COUNT', 'PAGE-NUMBER', 'PARM-REGISTER',
|
| 1365 |
+
'PATH-ID', 'PATTERN', 'PERFORM', 'POINT', 'POS', 'PRIMARY', 'PRINT',
|
| 1366 |
+
'PROCEDURE', 'PROGRAM', 'PUT', 'READ', 'RECORD', 'RECORD-COUNT',
|
| 1367 |
+
'RECORD-LENGTH', 'REFRESH', 'RELEASE', 'RENUM', 'REPEAT', 'REPORT',
|
| 1368 |
+
'REPORT-INPUT', 'RESHOW', 'RESTART', 'RETRIEVE', 'RETURN-CODE',
|
| 1369 |
+
'ROLLBACK', 'ROW', 'S', 'SCREEN', 'SEARCH', 'SECONDARY', 'SELECT',
|
| 1370 |
+
'SEQUENCE', 'SIZE', 'SKIP', 'SOKAKU', 'SORT', 'SQL', 'STOP', 'SUM',
|
| 1371 |
+
'SYSDATE', 'SYSDATE-LONG', 'SYSIN', 'SYSIPT', 'SYSLST', 'SYSPRINT',
|
| 1372 |
+
'SYSSNAP', 'SYSTIME', 'TALLY', 'TERM-COLUMNS', 'TERM-NAME',
|
| 1373 |
+
'TERM-ROWS', 'TERMINATION', 'TITLE', 'TO', 'TRANSFER', 'TRC',
|
| 1374 |
+
'UNIQUE', 'UNTIL', 'UPDATE', 'UPPERCASE', 'USER', 'USERID', 'VALUE',
|
| 1375 |
+
'VERIFY', 'W', 'WHEN', 'WHILE', 'WORK', 'WRITE', 'X', 'XDM', 'XRST'
|
| 1376 |
+
]
|
| 1377 |
+
|
| 1378 |
+
tokens = {
|
| 1379 |
+
'root': [
|
| 1380 |
+
(r'\*.*\n', Comment.Single),
|
| 1381 |
+
(r'\n+', Whitespace),
|
| 1382 |
+
# Macro argument
|
| 1383 |
+
(r'&' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+\.', Name.Variable,
|
| 1384 |
+
'after_macro_argument'),
|
| 1385 |
+
# Macro call
|
| 1386 |
+
(r'%' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Variable),
|
| 1387 |
+
(r'(FILE|MACRO|REPORT)(\s+)',
|
| 1388 |
+
bygroups(Keyword.Declaration, Whitespace), 'after_declaration'),
|
| 1389 |
+
(r'(JOB|PARM)' + r'(' + _DELIMITER_PATTERN + r')',
|
| 1390 |
+
bygroups(Keyword.Declaration, Operator)),
|
| 1391 |
+
(words(_KEYWORDS, suffix=_DELIMITER_PATTERN_CAPTURE),
|
| 1392 |
+
bygroups(Keyword.Reserved, Operator)),
|
| 1393 |
+
(_OPERATORS_PATTERN, Operator),
|
| 1394 |
+
# Procedure declaration
|
| 1395 |
+
(r'(' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+)(\s*)(\.?)(\s*)(PROC)(\s*\n)',
|
| 1396 |
+
bygroups(Name.Function, Whitespace, Operator, Whitespace,
|
| 1397 |
+
Keyword.Declaration, Whitespace)),
|
| 1398 |
+
(r'[0-9]+\.[0-9]*', Number.Float),
|
| 1399 |
+
(r'[0-9]+', Number.Integer),
|
| 1400 |
+
(r"'(''|[^'])*'", String),
|
| 1401 |
+
(r'\s+', Whitespace),
|
| 1402 |
+
# Everything else just belongs to a name
|
| 1403 |
+
(_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name),
|
| 1404 |
+
],
|
| 1405 |
+
'after_declaration': [
|
| 1406 |
+
(_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Function),
|
| 1407 |
+
default('#pop'),
|
| 1408 |
+
],
|
| 1409 |
+
'after_macro_argument': [
|
| 1410 |
+
(r'\*.*\n', Comment.Single, '#pop'),
|
| 1411 |
+
(r'\s+', Whitespace, '#pop'),
|
| 1412 |
+
(_OPERATORS_PATTERN, Operator, '#pop'),
|
| 1413 |
+
(r"'(''|[^'])*'", String, '#pop'),
|
| 1414 |
+
# Everything else just belongs to a name
|
| 1415 |
+
(_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name),
|
| 1416 |
+
],
|
| 1417 |
+
}
|
| 1418 |
+
_COMMENT_LINE_REGEX = re.compile(r'^\s*\*')
|
| 1419 |
+
_MACRO_HEADER_REGEX = re.compile(r'^\s*MACRO')
|
| 1420 |
+
|
| 1421 |
+
def analyse_text(text):
|
| 1422 |
+
"""
|
| 1423 |
+
Perform a structural analysis for basic Easytrieve constructs.
|
| 1424 |
+
"""
|
| 1425 |
+
result = 0.0
|
| 1426 |
+
lines = text.split('\n')
|
| 1427 |
+
hasEndProc = False
|
| 1428 |
+
hasHeaderComment = False
|
| 1429 |
+
hasFile = False
|
| 1430 |
+
hasJob = False
|
| 1431 |
+
hasProc = False
|
| 1432 |
+
hasParm = False
|
| 1433 |
+
hasReport = False
|
| 1434 |
+
|
| 1435 |
+
def isCommentLine(line):
|
| 1436 |
+
return EasytrieveLexer._COMMENT_LINE_REGEX.match(lines[0]) is not None
|
| 1437 |
+
|
| 1438 |
+
def isEmptyLine(line):
|
| 1439 |
+
return not bool(line.strip())
|
| 1440 |
+
|
| 1441 |
+
# Remove possible empty lines and header comments.
|
| 1442 |
+
while lines and (isEmptyLine(lines[0]) or isCommentLine(lines[0])):
|
| 1443 |
+
if not isEmptyLine(lines[0]):
|
| 1444 |
+
hasHeaderComment = True
|
| 1445 |
+
del lines[0]
|
| 1446 |
+
|
| 1447 |
+
if EasytrieveLexer._MACRO_HEADER_REGEX.match(lines[0]):
|
| 1448 |
+
# Looks like an Easytrieve macro.
|
| 1449 |
+
result = 0.4
|
| 1450 |
+
if hasHeaderComment:
|
| 1451 |
+
result += 0.4
|
| 1452 |
+
else:
|
| 1453 |
+
# Scan the source for lines starting with indicators.
|
| 1454 |
+
for line in lines:
|
| 1455 |
+
words = line.split()
|
| 1456 |
+
if (len(words) >= 2):
|
| 1457 |
+
firstWord = words[0]
|
| 1458 |
+
if not hasReport:
|
| 1459 |
+
if not hasJob:
|
| 1460 |
+
if not hasFile:
|
| 1461 |
+
if not hasParm:
|
| 1462 |
+
if firstWord == 'PARM':
|
| 1463 |
+
hasParm = True
|
| 1464 |
+
if firstWord == 'FILE':
|
| 1465 |
+
hasFile = True
|
| 1466 |
+
if firstWord == 'JOB':
|
| 1467 |
+
hasJob = True
|
| 1468 |
+
elif firstWord == 'PROC':
|
| 1469 |
+
hasProc = True
|
| 1470 |
+
elif firstWord == 'END-PROC':
|
| 1471 |
+
hasEndProc = True
|
| 1472 |
+
elif firstWord == 'REPORT':
|
| 1473 |
+
hasReport = True
|
| 1474 |
+
|
| 1475 |
+
# Weight the findings.
|
| 1476 |
+
if hasJob and (hasProc == hasEndProc):
|
| 1477 |
+
if hasHeaderComment:
|
| 1478 |
+
result += 0.1
|
| 1479 |
+
if hasParm:
|
| 1480 |
+
if hasProc:
|
| 1481 |
+
# Found PARM, JOB and PROC/END-PROC:
|
| 1482 |
+
# pretty sure this is Easytrieve.
|
| 1483 |
+
result += 0.8
|
| 1484 |
+
else:
|
| 1485 |
+
# Found PARAM and JOB: probably this is Easytrieve
|
| 1486 |
+
result += 0.5
|
| 1487 |
+
else:
|
| 1488 |
+
# Found JOB and possibly other keywords: might be Easytrieve
|
| 1489 |
+
result += 0.11
|
| 1490 |
+
if hasParm:
|
| 1491 |
+
# Note: PARAM is not a proper English word, so this is
|
| 1492 |
+
# regarded a much better indicator for Easytrieve than
|
| 1493 |
+
# the other words.
|
| 1494 |
+
result += 0.2
|
| 1495 |
+
if hasFile:
|
| 1496 |
+
result += 0.01
|
| 1497 |
+
if hasReport:
|
| 1498 |
+
result += 0.01
|
| 1499 |
+
assert 0.0 <= result <= 1.0
|
| 1500 |
+
return result
|
| 1501 |
+
|
| 1502 |
+
|
| 1503 |
+
class JclLexer(RegexLexer):
|
| 1504 |
+
"""
|
| 1505 |
+
Job Control Language (JCL)
|
| 1506 |
+
is a scripting language used on mainframe platforms to instruct the system
|
| 1507 |
+
on how to run a batch job or start a subsystem. It is somewhat
|
| 1508 |
+
comparable to MS DOS batch and Unix shell scripts.
|
| 1509 |
+
"""
|
| 1510 |
+
name = 'JCL'
|
| 1511 |
+
aliases = ['jcl']
|
| 1512 |
+
filenames = ['*.jcl']
|
| 1513 |
+
mimetypes = ['text/x-jcl']
|
| 1514 |
+
url = 'https://en.wikipedia.org/wiki/Job_Control_Language'
|
| 1515 |
+
version_added = '2.1'
|
| 1516 |
+
|
| 1517 |
+
flags = re.IGNORECASE
|
| 1518 |
+
|
| 1519 |
+
tokens = {
|
| 1520 |
+
'root': [
|
| 1521 |
+
(r'//\*.*\n', Comment.Single),
|
| 1522 |
+
(r'//', Keyword.Pseudo, 'statement'),
|
| 1523 |
+
(r'/\*', Keyword.Pseudo, 'jes2_statement'),
|
| 1524 |
+
# TODO: JES3 statement
|
| 1525 |
+
(r'.*\n', Other) # Input text or inline code in any language.
|
| 1526 |
+
],
|
| 1527 |
+
'statement': [
|
| 1528 |
+
(r'\s*\n', Whitespace, '#pop'),
|
| 1529 |
+
(r'([a-z]\w*)(\s+)(exec|job)(\s*)',
|
| 1530 |
+
bygroups(Name.Label, Whitespace, Keyword.Reserved, Whitespace),
|
| 1531 |
+
'option'),
|
| 1532 |
+
(r'[a-z]\w*', Name.Variable, 'statement_command'),
|
| 1533 |
+
(r'\s+', Whitespace, 'statement_command'),
|
| 1534 |
+
],
|
| 1535 |
+
'statement_command': [
|
| 1536 |
+
(r'\s+(command|cntl|dd|endctl|endif|else|include|jcllib|'
|
| 1537 |
+
r'output|pend|proc|set|then|xmit)\s+', Keyword.Reserved, 'option'),
|
| 1538 |
+
include('option')
|
| 1539 |
+
],
|
| 1540 |
+
'jes2_statement': [
|
| 1541 |
+
(r'\s*\n', Whitespace, '#pop'),
|
| 1542 |
+
(r'\$', Keyword, 'option'),
|
| 1543 |
+
(r'\b(jobparam|message|netacct|notify|output|priority|route|'
|
| 1544 |
+
r'setup|signoff|xeq|xmit)\b', Keyword, 'option'),
|
| 1545 |
+
],
|
| 1546 |
+
'option': [
|
| 1547 |
+
# (r'\n', Text, 'root'),
|
| 1548 |
+
(r'\*', Name.Builtin),
|
| 1549 |
+
(r'[\[\](){}<>;,]', Punctuation),
|
| 1550 |
+
(r'[-+*/=&%]', Operator),
|
| 1551 |
+
(r'[a-z_]\w*', Name),
|
| 1552 |
+
(r'\d+\.\d*', Number.Float),
|
| 1553 |
+
(r'\.\d+', Number.Float),
|
| 1554 |
+
(r'\d+', Number.Integer),
|
| 1555 |
+
(r"'", String, 'option_string'),
|
| 1556 |
+
(r'[ \t]+', Whitespace, 'option_comment'),
|
| 1557 |
+
(r'\.', Punctuation),
|
| 1558 |
+
],
|
| 1559 |
+
'option_string': [
|
| 1560 |
+
(r"(\n)(//)", bygroups(Text, Keyword.Pseudo)),
|
| 1561 |
+
(r"''", String),
|
| 1562 |
+
(r"[^']", String),
|
| 1563 |
+
(r"'", String, '#pop'),
|
| 1564 |
+
],
|
| 1565 |
+
'option_comment': [
|
| 1566 |
+
# (r'\n', Text, 'root'),
|
| 1567 |
+
(r'.+', Comment.Single),
|
| 1568 |
+
]
|
| 1569 |
+
}
|
| 1570 |
+
|
| 1571 |
+
_JOB_HEADER_PATTERN = re.compile(r'^//[a-z#$@][a-z0-9#$@]{0,7}\s+job(\s+.*)?$',
|
| 1572 |
+
re.IGNORECASE)
|
| 1573 |
+
|
| 1574 |
+
def analyse_text(text):
|
| 1575 |
+
"""
|
| 1576 |
+
Recognize JCL job by header.
|
| 1577 |
+
"""
|
| 1578 |
+
result = 0.0
|
| 1579 |
+
lines = text.split('\n')
|
| 1580 |
+
if len(lines) > 0:
|
| 1581 |
+
if JclLexer._JOB_HEADER_PATTERN.match(lines[0]):
|
| 1582 |
+
result = 1.0
|
| 1583 |
+
assert 0.0 <= result <= 1.0
|
| 1584 |
+
return result
|
| 1585 |
+
|
| 1586 |
+
|
| 1587 |
+
class MiniScriptLexer(RegexLexer):
|
| 1588 |
+
"""
|
| 1589 |
+
For MiniScript source code.
|
| 1590 |
+
"""
|
| 1591 |
+
|
| 1592 |
+
name = 'MiniScript'
|
| 1593 |
+
url = 'https://miniscript.org'
|
| 1594 |
+
aliases = ['miniscript', 'ms']
|
| 1595 |
+
filenames = ['*.ms']
|
| 1596 |
+
mimetypes = ['text/x-minicript', 'application/x-miniscript']
|
| 1597 |
+
version_added = '2.6'
|
| 1598 |
+
|
| 1599 |
+
tokens = {
|
| 1600 |
+
'root': [
|
| 1601 |
+
(r'#!(.*?)$', Comment.Preproc),
|
| 1602 |
+
default('base'),
|
| 1603 |
+
],
|
| 1604 |
+
'base': [
|
| 1605 |
+
('//.*$', Comment.Single),
|
| 1606 |
+
(r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number),
|
| 1607 |
+
(r'(?i)\d+e[+-]?\d+', Number),
|
| 1608 |
+
(r'\d+', Number),
|
| 1609 |
+
(r'\n', Text),
|
| 1610 |
+
(r'[^\S\n]+', Text),
|
| 1611 |
+
(r'"', String, 'string_double'),
|
| 1612 |
+
(r'(==|!=|<=|>=|[=+\-*/%^<>.:])', Operator),
|
| 1613 |
+
(r'[;,\[\]{}()]', Punctuation),
|
| 1614 |
+
(words((
|
| 1615 |
+
'break', 'continue', 'else', 'end', 'for', 'function', 'if',
|
| 1616 |
+
'in', 'isa', 'then', 'repeat', 'return', 'while'), suffix=r'\b'),
|
| 1617 |
+
Keyword),
|
| 1618 |
+
(words((
|
| 1619 |
+
'abs', 'acos', 'asin', 'atan', 'ceil', 'char', 'cos', 'floor',
|
| 1620 |
+
'log', 'round', 'rnd', 'pi', 'sign', 'sin', 'sqrt', 'str', 'tan',
|
| 1621 |
+
'hasIndex', 'indexOf', 'len', 'val', 'code', 'remove', 'lower',
|
| 1622 |
+
'upper', 'replace', 'split', 'indexes', 'values', 'join', 'sum',
|
| 1623 |
+
'sort', 'shuffle', 'push', 'pop', 'pull', 'range',
|
| 1624 |
+
'print', 'input', 'time', 'wait', 'locals', 'globals', 'outer',
|
| 1625 |
+
'yield'), suffix=r'\b'),
|
| 1626 |
+
Name.Builtin),
|
| 1627 |
+
(r'(true|false|null)\b', Keyword.Constant),
|
| 1628 |
+
(r'(and|or|not|new)\b', Operator.Word),
|
| 1629 |
+
(r'(self|super|__isa)\b', Name.Builtin.Pseudo),
|
| 1630 |
+
(r'[a-zA-Z_]\w*', Name.Variable)
|
| 1631 |
+
],
|
| 1632 |
+
'string_double': [
|
| 1633 |
+
(r'[^"\n]+', String),
|
| 1634 |
+
(r'""', String),
|
| 1635 |
+
(r'"', String, '#pop'),
|
| 1636 |
+
(r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
|
| 1637 |
+
]
|
| 1638 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/sgf.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.sgf
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Smart Game Format (sgf) 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, Literal, String, Punctuation, Whitespace
|
| 13 |
+
|
| 14 |
+
__all__ = ["SmartGameFormatLexer"]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class SmartGameFormatLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
Lexer for Smart Game Format (sgf) file format.
|
| 20 |
+
|
| 21 |
+
The format is used to store game records of board games for two players
|
| 22 |
+
(mainly Go game).
|
| 23 |
+
"""
|
| 24 |
+
name = 'SmartGameFormat'
|
| 25 |
+
url = 'https://www.red-bean.com/sgf/'
|
| 26 |
+
aliases = ['sgf']
|
| 27 |
+
filenames = ['*.sgf']
|
| 28 |
+
version_added = '2.4'
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
(r'[():;]+', Punctuation),
|
| 33 |
+
# tokens:
|
| 34 |
+
(r'(A[BW]|AE|AN|AP|AR|AS|[BW]L|BM|[BW]R|[BW]S|[BW]T|CA|CH|CP|CR|'
|
| 35 |
+
r'DD|DM|DO|DT|EL|EV|EX|FF|FG|G[BW]|GC|GM|GN|HA|HO|ID|IP|IT|IY|KM|'
|
| 36 |
+
r'KO|LB|LN|LT|L|MA|MN|M|N|OB|OM|ON|OP|OT|OV|P[BW]|PC|PL|PM|RE|RG|'
|
| 37 |
+
r'RO|RU|SO|SC|SE|SI|SL|SO|SQ|ST|SU|SZ|T[BW]|TC|TE|TM|TR|UC|US|VW|'
|
| 38 |
+
r'V|[BW]|C)',
|
| 39 |
+
Name.Builtin),
|
| 40 |
+
# number:
|
| 41 |
+
(r'(\[)([0-9.]+)(\])',
|
| 42 |
+
bygroups(Punctuation, Literal.Number, Punctuation)),
|
| 43 |
+
# date:
|
| 44 |
+
(r'(\[)([0-9]{4}-[0-9]{2}-[0-9]{2})(\])',
|
| 45 |
+
bygroups(Punctuation, Literal.Date, Punctuation)),
|
| 46 |
+
# point:
|
| 47 |
+
(r'(\[)([a-z]{2})(\])',
|
| 48 |
+
bygroups(Punctuation, String, Punctuation)),
|
| 49 |
+
# double points:
|
| 50 |
+
(r'(\[)([a-z]{2})(:)([a-z]{2})(\])',
|
| 51 |
+
bygroups(Punctuation, String, Punctuation, String, Punctuation)),
|
| 52 |
+
|
| 53 |
+
(r'(\[)([\w\s#()+,\-.:?]+)(\])',
|
| 54 |
+
bygroups(Punctuation, String, Punctuation)),
|
| 55 |
+
(r'(\[)(\s.*)(\])',
|
| 56 |
+
bygroups(Punctuation, Whitespace, Punctuation)),
|
| 57 |
+
(r'\s+', Whitespace)
|
| 58 |
+
],
|
| 59 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/shell.py
ADDED
|
@@ -0,0 +1,902 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.shell
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for various shells.
|
| 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, do_insertions, bygroups, \
|
| 14 |
+
include, default, this, using, words, line_re
|
| 15 |
+
from pygments.token import Punctuation, Whitespace, \
|
| 16 |
+
Text, Comment, Operator, Keyword, Name, String, Number, Generic
|
| 17 |
+
from pygments.util import shebang_matches
|
| 18 |
+
|
| 19 |
+
__all__ = ['BashLexer', 'BashSessionLexer', 'TcshLexer', 'BatchLexer',
|
| 20 |
+
'SlurmBashLexer', 'MSDOSSessionLexer', 'PowerShellLexer',
|
| 21 |
+
'PowerShellSessionLexer', 'TcshSessionLexer', 'FishShellLexer',
|
| 22 |
+
'ExeclineLexer']
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class BashLexer(RegexLexer):
|
| 26 |
+
"""
|
| 27 |
+
Lexer for (ba|k|z|)sh shell scripts.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
name = 'Bash'
|
| 31 |
+
aliases = ['bash', 'sh', 'ksh', 'zsh', 'shell', 'openrc']
|
| 32 |
+
filenames = ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass',
|
| 33 |
+
'*.exheres-0', '*.exlib', '*.zsh',
|
| 34 |
+
'.bashrc', 'bashrc', '.bash_*', 'bash_*', 'zshrc', '.zshrc',
|
| 35 |
+
'.kshrc', 'kshrc',
|
| 36 |
+
'PKGBUILD']
|
| 37 |
+
mimetypes = ['application/x-sh', 'application/x-shellscript', 'text/x-shellscript']
|
| 38 |
+
url = 'https://en.wikipedia.org/wiki/Unix_shell'
|
| 39 |
+
version_added = '0.6'
|
| 40 |
+
|
| 41 |
+
tokens = {
|
| 42 |
+
'root': [
|
| 43 |
+
include('basic'),
|
| 44 |
+
(r'`', String.Backtick, 'backticks'),
|
| 45 |
+
include('data'),
|
| 46 |
+
include('interp'),
|
| 47 |
+
],
|
| 48 |
+
'interp': [
|
| 49 |
+
(r'\$\(\(', Keyword, 'math'),
|
| 50 |
+
(r'\$\(', Keyword, 'paren'),
|
| 51 |
+
(r'\$\{#?', String.Interpol, 'curly'),
|
| 52 |
+
(r'\$[a-zA-Z_]\w*', Name.Variable), # user variable
|
| 53 |
+
(r'\$(?:\d+|[#$?!_*@-])', Name.Variable), # builtin
|
| 54 |
+
(r'\$', Text),
|
| 55 |
+
],
|
| 56 |
+
'basic': [
|
| 57 |
+
(r'\b(if|fi|else|while|in|do|done|for|then|return|function|case|'
|
| 58 |
+
r'select|break|continue|until|esac|elif)(\s*)\b',
|
| 59 |
+
bygroups(Keyword, Whitespace)),
|
| 60 |
+
(r'\b(alias|bg|bind|builtin|caller|cd|command|compgen|'
|
| 61 |
+
r'complete|declare|dirs|disown|echo|enable|eval|exec|exit|'
|
| 62 |
+
r'export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|'
|
| 63 |
+
r'local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|'
|
| 64 |
+
r'shopt|source|suspend|test|time|times|trap|true|type|typeset|'
|
| 65 |
+
r'ulimit|umask|unalias|unset|wait)(?=[\s)`])',
|
| 66 |
+
Name.Builtin),
|
| 67 |
+
(r'\A#!.+\n', Comment.Hashbang),
|
| 68 |
+
(r'#.*\n', Comment.Single),
|
| 69 |
+
(r'\\[\w\W]', String.Escape),
|
| 70 |
+
(r'(\b\w+)(\s*)(\+?=)', bygroups(Name.Variable, Whitespace, Operator)),
|
| 71 |
+
(r'[\[\]{}()=]', Operator),
|
| 72 |
+
(r'<<<', Operator), # here-string
|
| 73 |
+
(r'<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
|
| 74 |
+
(r'&&|\|\|', Operator),
|
| 75 |
+
],
|
| 76 |
+
'data': [
|
| 77 |
+
(r'(?s)\$?"(\\.|[^"\\$])*"', String.Double),
|
| 78 |
+
(r'"', String.Double, 'string'),
|
| 79 |
+
(r"(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
|
| 80 |
+
(r"(?s)'.*?'", String.Single),
|
| 81 |
+
(r';', Punctuation),
|
| 82 |
+
(r'&', Punctuation),
|
| 83 |
+
(r'\|', Punctuation),
|
| 84 |
+
(r'\s+', Whitespace),
|
| 85 |
+
(r'\d+\b', Number),
|
| 86 |
+
(r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
|
| 87 |
+
(r'<', Text),
|
| 88 |
+
],
|
| 89 |
+
'string': [
|
| 90 |
+
(r'"', String.Double, '#pop'),
|
| 91 |
+
(r'(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+', String.Double),
|
| 92 |
+
include('interp'),
|
| 93 |
+
],
|
| 94 |
+
'curly': [
|
| 95 |
+
(r'\}', String.Interpol, '#pop'),
|
| 96 |
+
(r':-', Keyword),
|
| 97 |
+
(r'\w+', Name.Variable),
|
| 98 |
+
(r'[^}:"\'`$\\]+', Punctuation),
|
| 99 |
+
(r':', Punctuation),
|
| 100 |
+
include('root'),
|
| 101 |
+
],
|
| 102 |
+
'paren': [
|
| 103 |
+
(r'\)', Keyword, '#pop'),
|
| 104 |
+
include('root'),
|
| 105 |
+
],
|
| 106 |
+
'math': [
|
| 107 |
+
(r'\)\)', Keyword, '#pop'),
|
| 108 |
+
(r'\*\*|\|\||<<|>>|[-+*/%^|&<>]', Operator),
|
| 109 |
+
(r'\d+#[\da-zA-Z]+', Number),
|
| 110 |
+
(r'\d+#(?! )', Number),
|
| 111 |
+
(r'0[xX][\da-fA-F]+', Number),
|
| 112 |
+
(r'\d+', Number),
|
| 113 |
+
(r'[a-zA-Z_]\w*', Name.Variable), # user variable
|
| 114 |
+
include('root'),
|
| 115 |
+
],
|
| 116 |
+
'backticks': [
|
| 117 |
+
(r'`', String.Backtick, '#pop'),
|
| 118 |
+
include('root'),
|
| 119 |
+
],
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
def analyse_text(text):
|
| 123 |
+
if shebang_matches(text, r'(ba|z|)sh'):
|
| 124 |
+
return 1
|
| 125 |
+
if text.startswith('$ '):
|
| 126 |
+
return 0.2
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
class SlurmBashLexer(BashLexer):
|
| 130 |
+
"""
|
| 131 |
+
Lexer for (ba|k|z|)sh Slurm scripts.
|
| 132 |
+
"""
|
| 133 |
+
|
| 134 |
+
name = 'Slurm'
|
| 135 |
+
aliases = ['slurm', 'sbatch']
|
| 136 |
+
filenames = ['*.sl']
|
| 137 |
+
mimetypes = []
|
| 138 |
+
version_added = '2.4'
|
| 139 |
+
EXTRA_KEYWORDS = {'srun'}
|
| 140 |
+
|
| 141 |
+
def get_tokens_unprocessed(self, text):
|
| 142 |
+
for index, token, value in BashLexer.get_tokens_unprocessed(self, text):
|
| 143 |
+
if token is Text and value in self.EXTRA_KEYWORDS:
|
| 144 |
+
yield index, Name.Builtin, value
|
| 145 |
+
elif token is Comment.Single and 'SBATCH' in value:
|
| 146 |
+
yield index, Keyword.Pseudo, value
|
| 147 |
+
else:
|
| 148 |
+
yield index, token, value
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
class ShellSessionBaseLexer(Lexer):
|
| 152 |
+
"""
|
| 153 |
+
Base lexer for shell sessions.
|
| 154 |
+
|
| 155 |
+
.. versionadded:: 2.1
|
| 156 |
+
"""
|
| 157 |
+
|
| 158 |
+
_bare_continuation = False
|
| 159 |
+
_venv = re.compile(r'^(\([^)]*\))(\s*)')
|
| 160 |
+
|
| 161 |
+
def get_tokens_unprocessed(self, text):
|
| 162 |
+
innerlexer = self._innerLexerCls(**self.options)
|
| 163 |
+
|
| 164 |
+
pos = 0
|
| 165 |
+
curcode = ''
|
| 166 |
+
insertions = []
|
| 167 |
+
backslash_continuation = False
|
| 168 |
+
|
| 169 |
+
for match in line_re.finditer(text):
|
| 170 |
+
line = match.group()
|
| 171 |
+
|
| 172 |
+
venv_match = self._venv.match(line)
|
| 173 |
+
if venv_match:
|
| 174 |
+
venv = venv_match.group(1)
|
| 175 |
+
venv_whitespace = venv_match.group(2)
|
| 176 |
+
insertions.append((len(curcode),
|
| 177 |
+
[(0, Generic.Prompt.VirtualEnv, venv)]))
|
| 178 |
+
if venv_whitespace:
|
| 179 |
+
insertions.append((len(curcode),
|
| 180 |
+
[(0, Text, venv_whitespace)]))
|
| 181 |
+
line = line[venv_match.end():]
|
| 182 |
+
|
| 183 |
+
m = self._ps1rgx.match(line)
|
| 184 |
+
if m:
|
| 185 |
+
# To support output lexers (say diff output), the output
|
| 186 |
+
# needs to be broken by prompts whenever the output lexer
|
| 187 |
+
# changes.
|
| 188 |
+
if not insertions:
|
| 189 |
+
pos = match.start()
|
| 190 |
+
|
| 191 |
+
insertions.append((len(curcode),
|
| 192 |
+
[(0, Generic.Prompt, m.group(1))]))
|
| 193 |
+
curcode += m.group(2)
|
| 194 |
+
backslash_continuation = curcode.endswith('\\\n')
|
| 195 |
+
elif backslash_continuation:
|
| 196 |
+
if line.startswith(self._ps2):
|
| 197 |
+
insertions.append((len(curcode),
|
| 198 |
+
[(0, Generic.Prompt,
|
| 199 |
+
line[:len(self._ps2)])]))
|
| 200 |
+
curcode += line[len(self._ps2):]
|
| 201 |
+
else:
|
| 202 |
+
curcode += line
|
| 203 |
+
backslash_continuation = curcode.endswith('\\\n')
|
| 204 |
+
elif self._bare_continuation and line.startswith(self._ps2):
|
| 205 |
+
insertions.append((len(curcode),
|
| 206 |
+
[(0, Generic.Prompt,
|
| 207 |
+
line[:len(self._ps2)])]))
|
| 208 |
+
curcode += line[len(self._ps2):]
|
| 209 |
+
else:
|
| 210 |
+
if insertions:
|
| 211 |
+
toks = innerlexer.get_tokens_unprocessed(curcode)
|
| 212 |
+
for i, t, v in do_insertions(insertions, toks):
|
| 213 |
+
yield pos+i, t, v
|
| 214 |
+
yield match.start(), Generic.Output, line
|
| 215 |
+
insertions = []
|
| 216 |
+
curcode = ''
|
| 217 |
+
if insertions:
|
| 218 |
+
for i, t, v in do_insertions(insertions,
|
| 219 |
+
innerlexer.get_tokens_unprocessed(curcode)):
|
| 220 |
+
yield pos+i, t, v
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
class BashSessionLexer(ShellSessionBaseLexer):
|
| 224 |
+
"""
|
| 225 |
+
Lexer for Bash shell sessions, i.e. command lines, including a
|
| 226 |
+
prompt, interspersed with output.
|
| 227 |
+
"""
|
| 228 |
+
|
| 229 |
+
name = 'Bash Session'
|
| 230 |
+
aliases = ['console', 'shell-session']
|
| 231 |
+
filenames = ['*.sh-session', '*.shell-session']
|
| 232 |
+
mimetypes = ['application/x-shell-session', 'application/x-sh-session']
|
| 233 |
+
url = 'https://en.wikipedia.org/wiki/Unix_shell'
|
| 234 |
+
version_added = '1.1'
|
| 235 |
+
_example = "console/example.sh-session"
|
| 236 |
+
|
| 237 |
+
_innerLexerCls = BashLexer
|
| 238 |
+
_ps1rgx = re.compile(
|
| 239 |
+
r'^((?:(?:\[.*?\])|(?:\(\S+\))?(?:| |sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)' \
|
| 240 |
+
r'?|\[\S+[@:][^\n]+\].+))\s*[$#%]\s*)(.*\n?)')
|
| 241 |
+
_ps2 = '> '
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
class BatchLexer(RegexLexer):
|
| 245 |
+
"""
|
| 246 |
+
Lexer for the DOS/Windows Batch file format.
|
| 247 |
+
"""
|
| 248 |
+
name = 'Batchfile'
|
| 249 |
+
aliases = ['batch', 'bat', 'dosbatch', 'winbatch']
|
| 250 |
+
filenames = ['*.bat', '*.cmd']
|
| 251 |
+
mimetypes = ['application/x-dos-batch']
|
| 252 |
+
url = 'https://en.wikipedia.org/wiki/Batch_file'
|
| 253 |
+
version_added = '0.7'
|
| 254 |
+
|
| 255 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 256 |
+
|
| 257 |
+
_nl = r'\n\x1a'
|
| 258 |
+
_punct = r'&<>|'
|
| 259 |
+
_ws = r'\t\v\f\r ,;=\xa0'
|
| 260 |
+
_nlws = r'\s\x1a\xa0,;='
|
| 261 |
+
_space = rf'(?:(?:(?:\^[{_nl}])?[{_ws}])+)'
|
| 262 |
+
_keyword_terminator = (rf'(?=(?:\^[{_nl}]?)?[{_ws}+./:[\\\]]|[{_nl}{_punct}(])')
|
| 263 |
+
_token_terminator = rf'(?=\^?[{_ws}]|[{_punct}{_nl}])'
|
| 264 |
+
_start_label = rf'((?:(?<=^[^:])|^[^:]?)[{_ws}]*)(:)'
|
| 265 |
+
_label = rf'(?:(?:[^{_nlws}{_punct}+:^]|\^[{_nl}]?[\w\W])*)'
|
| 266 |
+
_label_compound = rf'(?:(?:[^{_nlws}{_punct}+:^)]|\^[{_nl}]?[^)])*)'
|
| 267 |
+
_number = rf'(?:-?(?:0[0-7]+|0x[\da-f]+|\d+){_token_terminator})'
|
| 268 |
+
_opword = r'(?:equ|geq|gtr|leq|lss|neq)'
|
| 269 |
+
_string = rf'(?:"[^{_nl}"]*(?:"|(?=[{_nl}])))'
|
| 270 |
+
_variable = (r'(?:(?:%(?:\*|(?:~[a-z]*(?:\$[^:]+:)?)?\d|'
|
| 271 |
+
rf'[^%:{_nl}]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:[^%{_nl}^]|'
|
| 272 |
+
rf'\^[^%{_nl}])[^={_nl}]*=(?:[^%{_nl}^]|\^[^%{_nl}])*)?)?%))|'
|
| 273 |
+
rf'(?:\^?![^!:{_nl}]+(?::(?:~(?:-?\d+)?(?:,(?:-?\d+)?)?|(?:'
|
| 274 |
+
rf'[^!{_nl}^]|\^[^!{_nl}])[^={_nl}]*=(?:[^!{_nl}^]|\^[^!{_nl}])*)?)?\^?!))')
|
| 275 |
+
_core_token = rf'(?:(?:(?:\^[{_nl}]?)?[^"{_nlws}{_punct}])+)'
|
| 276 |
+
_core_token_compound = rf'(?:(?:(?:\^[{_nl}]?)?[^"{_nlws}{_punct})])+)'
|
| 277 |
+
_token = rf'(?:[{_punct}]+|{_core_token})'
|
| 278 |
+
_token_compound = rf'(?:[{_punct}]+|{_core_token_compound})'
|
| 279 |
+
_stoken = (rf'(?:[{_punct}]+|(?:{_string}|{_variable}|{_core_token})+)')
|
| 280 |
+
|
| 281 |
+
def _make_begin_state(compound, _core_token=_core_token,
|
| 282 |
+
_core_token_compound=_core_token_compound,
|
| 283 |
+
_keyword_terminator=_keyword_terminator,
|
| 284 |
+
_nl=_nl, _punct=_punct, _string=_string,
|
| 285 |
+
_space=_space, _start_label=_start_label,
|
| 286 |
+
_stoken=_stoken, _token_terminator=_token_terminator,
|
| 287 |
+
_variable=_variable, _ws=_ws):
|
| 288 |
+
rest = '(?:{}|{}|[^"%{}{}{}])*'.format(_string, _variable, _nl, _punct,
|
| 289 |
+
')' if compound else '')
|
| 290 |
+
rest_of_line = rf'(?:(?:[^{_nl}^]|\^[{_nl}]?[\w\W])*)'
|
| 291 |
+
rest_of_line_compound = rf'(?:(?:[^{_nl}^)]|\^[{_nl}]?[^)])*)'
|
| 292 |
+
set_space = rf'((?:(?:\^[{_nl}]?)?[^\S\n])*)'
|
| 293 |
+
suffix = ''
|
| 294 |
+
if compound:
|
| 295 |
+
_keyword_terminator = rf'(?:(?=\))|{_keyword_terminator})'
|
| 296 |
+
_token_terminator = rf'(?:(?=\))|{_token_terminator})'
|
| 297 |
+
suffix = '/compound'
|
| 298 |
+
return [
|
| 299 |
+
((r'\)', Punctuation, '#pop') if compound else
|
| 300 |
+
(rf'\)((?=\()|{_token_terminator}){rest_of_line}',
|
| 301 |
+
Comment.Single)),
|
| 302 |
+
(rf'(?={_start_label})', Text, f'follow{suffix}'),
|
| 303 |
+
(_space, using(this, state='text')),
|
| 304 |
+
include(f'redirect{suffix}'),
|
| 305 |
+
(rf'[{_nl}]+', Text),
|
| 306 |
+
(r'\(', Punctuation, 'root/compound'),
|
| 307 |
+
(r'@+', Punctuation),
|
| 308 |
+
(rf'((?:for|if|rem)(?:(?=(?:\^[{_nl}]?)?/)|(?:(?!\^)|'
|
| 309 |
+
rf'(?<=m))(?:(?=\()|{_token_terminator})))({_space}?{_core_token_compound if compound else _core_token}?(?:\^[{_nl}]?)?/(?:\^[{_nl}]?)?\?)',
|
| 310 |
+
bygroups(Keyword, using(this, state='text')),
|
| 311 |
+
f'follow{suffix}'),
|
| 312 |
+
(rf'(goto{_keyword_terminator})({rest}(?:\^[{_nl}]?)?/(?:\^[{_nl}]?)?\?{rest})',
|
| 313 |
+
bygroups(Keyword, using(this, state='text')),
|
| 314 |
+
f'follow{suffix}'),
|
| 315 |
+
(words(('assoc', 'break', 'cd', 'chdir', 'cls', 'color', 'copy',
|
| 316 |
+
'date', 'del', 'dir', 'dpath', 'echo', 'endlocal', 'erase',
|
| 317 |
+
'exit', 'ftype', 'keys', 'md', 'mkdir', 'mklink', 'move',
|
| 318 |
+
'path', 'pause', 'popd', 'prompt', 'pushd', 'rd', 'ren',
|
| 319 |
+
'rename', 'rmdir', 'setlocal', 'shift', 'start', 'time',
|
| 320 |
+
'title', 'type', 'ver', 'verify', 'vol'),
|
| 321 |
+
suffix=_keyword_terminator), Keyword, f'follow{suffix}'),
|
| 322 |
+
(rf'(call)({_space}?)(:)',
|
| 323 |
+
bygroups(Keyword, using(this, state='text'), Punctuation),
|
| 324 |
+
f'call{suffix}'),
|
| 325 |
+
(rf'call{_keyword_terminator}', Keyword),
|
| 326 |
+
(rf'(for{_token_terminator}(?!\^))({_space})(/f{_token_terminator})',
|
| 327 |
+
bygroups(Keyword, using(this, state='text'), Keyword),
|
| 328 |
+
('for/f', 'for')),
|
| 329 |
+
(rf'(for{_token_terminator}(?!\^))({_space})(/l{_token_terminator})',
|
| 330 |
+
bygroups(Keyword, using(this, state='text'), Keyword),
|
| 331 |
+
('for/l', 'for')),
|
| 332 |
+
(rf'for{_token_terminator}(?!\^)', Keyword, ('for2', 'for')),
|
| 333 |
+
(rf'(goto{_keyword_terminator})({_space}?)(:?)',
|
| 334 |
+
bygroups(Keyword, using(this, state='text'), Punctuation),
|
| 335 |
+
f'label{suffix}'),
|
| 336 |
+
(rf'(if(?:(?=\()|{_token_terminator})(?!\^))({_space}?)((?:/i{_token_terminator})?)({_space}?)((?:not{_token_terminator})?)({_space}?)',
|
| 337 |
+
bygroups(Keyword, using(this, state='text'), Keyword,
|
| 338 |
+
using(this, state='text'), Keyword,
|
| 339 |
+
using(this, state='text')), ('(?', 'if')),
|
| 340 |
+
(rf'rem(((?=\()|{_token_terminator}){_space}?{_stoken}?.*|{_keyword_terminator}{rest_of_line_compound if compound else rest_of_line})',
|
| 341 |
+
Comment.Single, f'follow{suffix}'),
|
| 342 |
+
(rf'(set{_keyword_terminator}){set_space}(/a)',
|
| 343 |
+
bygroups(Keyword, using(this, state='text'), Keyword),
|
| 344 |
+
f'arithmetic{suffix}'),
|
| 345 |
+
(r'(set{}){}((?:/p)?){}((?:(?:(?:\^[{}]?)?[^"{}{}^={}]|'
|
| 346 |
+
r'\^[{}]?[^"=])+)?)((?:(?:\^[{}]?)?=)?)'.format(_keyword_terminator, set_space, set_space, _nl, _nl, _punct,
|
| 347 |
+
')' if compound else '', _nl, _nl),
|
| 348 |
+
bygroups(Keyword, using(this, state='text'), Keyword,
|
| 349 |
+
using(this, state='text'), using(this, state='variable'),
|
| 350 |
+
Punctuation),
|
| 351 |
+
f'follow{suffix}'),
|
| 352 |
+
default(f'follow{suffix}')
|
| 353 |
+
]
|
| 354 |
+
|
| 355 |
+
def _make_follow_state(compound, _label=_label,
|
| 356 |
+
_label_compound=_label_compound, _nl=_nl,
|
| 357 |
+
_space=_space, _start_label=_start_label,
|
| 358 |
+
_token=_token, _token_compound=_token_compound,
|
| 359 |
+
_ws=_ws):
|
| 360 |
+
suffix = '/compound' if compound else ''
|
| 361 |
+
state = []
|
| 362 |
+
if compound:
|
| 363 |
+
state.append((r'(?=\))', Text, '#pop'))
|
| 364 |
+
state += [
|
| 365 |
+
(rf'{_start_label}([{_ws}]*)({_label_compound if compound else _label})(.*)',
|
| 366 |
+
bygroups(Text, Punctuation, Text, Name.Label, Comment.Single)),
|
| 367 |
+
include(f'redirect{suffix}'),
|
| 368 |
+
(rf'(?=[{_nl}])', Text, '#pop'),
|
| 369 |
+
(r'\|\|?|&&?', Punctuation, '#pop'),
|
| 370 |
+
include('text')
|
| 371 |
+
]
|
| 372 |
+
return state
|
| 373 |
+
|
| 374 |
+
def _make_arithmetic_state(compound, _nl=_nl, _punct=_punct,
|
| 375 |
+
_string=_string, _variable=_variable,
|
| 376 |
+
_ws=_ws, _nlws=_nlws):
|
| 377 |
+
op = r'=+\-*/!~'
|
| 378 |
+
state = []
|
| 379 |
+
if compound:
|
| 380 |
+
state.append((r'(?=\))', Text, '#pop'))
|
| 381 |
+
state += [
|
| 382 |
+
(r'0[0-7]+', Number.Oct),
|
| 383 |
+
(r'0x[\da-f]+', Number.Hex),
|
| 384 |
+
(r'\d+', Number.Integer),
|
| 385 |
+
(r'[(),]+', Punctuation),
|
| 386 |
+
(rf'([{op}]|%|\^\^)+', Operator),
|
| 387 |
+
(r'({}|{}|(\^[{}]?)?[^(){}%\^"{}{}]|\^[{}]?{})+'.format(_string, _variable, _nl, op, _nlws, _punct, _nlws,
|
| 388 |
+
r'[^)]' if compound else r'[\w\W]'),
|
| 389 |
+
using(this, state='variable')),
|
| 390 |
+
(r'(?=[\x00|&])', Text, '#pop'),
|
| 391 |
+
include('follow')
|
| 392 |
+
]
|
| 393 |
+
return state
|
| 394 |
+
|
| 395 |
+
def _make_call_state(compound, _label=_label,
|
| 396 |
+
_label_compound=_label_compound):
|
| 397 |
+
state = []
|
| 398 |
+
if compound:
|
| 399 |
+
state.append((r'(?=\))', Text, '#pop'))
|
| 400 |
+
state.append((r'(:?)(%s)' % (_label_compound if compound else _label),
|
| 401 |
+
bygroups(Punctuation, Name.Label), '#pop'))
|
| 402 |
+
return state
|
| 403 |
+
|
| 404 |
+
def _make_label_state(compound, _label=_label,
|
| 405 |
+
_label_compound=_label_compound, _nl=_nl,
|
| 406 |
+
_punct=_punct, _string=_string, _variable=_variable):
|
| 407 |
+
state = []
|
| 408 |
+
if compound:
|
| 409 |
+
state.append((r'(?=\))', Text, '#pop'))
|
| 410 |
+
state.append((r'({}?)((?:{}|{}|\^[{}]?{}|[^"%^{}{}{}])*)'.format(_label_compound if compound else _label, _string,
|
| 411 |
+
_variable, _nl, r'[^)]' if compound else r'[\w\W]', _nl,
|
| 412 |
+
_punct, r')' if compound else ''),
|
| 413 |
+
bygroups(Name.Label, Comment.Single), '#pop'))
|
| 414 |
+
return state
|
| 415 |
+
|
| 416 |
+
def _make_redirect_state(compound,
|
| 417 |
+
_core_token_compound=_core_token_compound,
|
| 418 |
+
_nl=_nl, _punct=_punct, _stoken=_stoken,
|
| 419 |
+
_string=_string, _space=_space,
|
| 420 |
+
_variable=_variable, _nlws=_nlws):
|
| 421 |
+
stoken_compound = (rf'(?:[{_punct}]+|(?:{_string}|{_variable}|{_core_token_compound})+)')
|
| 422 |
+
return [
|
| 423 |
+
(rf'((?:(?<=[{_nlws}])\d)?)(>>?&|<&)([{_nlws}]*)(\d)',
|
| 424 |
+
bygroups(Number.Integer, Punctuation, Text, Number.Integer)),
|
| 425 |
+
(rf'((?:(?<=[{_nlws}])(?<!\^[{_nl}])\d)?)(>>?|<)({_space}?{stoken_compound if compound else _stoken})',
|
| 426 |
+
bygroups(Number.Integer, Punctuation, using(this, state='text')))
|
| 427 |
+
]
|
| 428 |
+
|
| 429 |
+
tokens = {
|
| 430 |
+
'root': _make_begin_state(False),
|
| 431 |
+
'follow': _make_follow_state(False),
|
| 432 |
+
'arithmetic': _make_arithmetic_state(False),
|
| 433 |
+
'call': _make_call_state(False),
|
| 434 |
+
'label': _make_label_state(False),
|
| 435 |
+
'redirect': _make_redirect_state(False),
|
| 436 |
+
'root/compound': _make_begin_state(True),
|
| 437 |
+
'follow/compound': _make_follow_state(True),
|
| 438 |
+
'arithmetic/compound': _make_arithmetic_state(True),
|
| 439 |
+
'call/compound': _make_call_state(True),
|
| 440 |
+
'label/compound': _make_label_state(True),
|
| 441 |
+
'redirect/compound': _make_redirect_state(True),
|
| 442 |
+
'variable-or-escape': [
|
| 443 |
+
(_variable, Name.Variable),
|
| 444 |
+
(rf'%%|\^[{_nl}]?(\^!|[\w\W])', String.Escape)
|
| 445 |
+
],
|
| 446 |
+
'string': [
|
| 447 |
+
(r'"', String.Double, '#pop'),
|
| 448 |
+
(_variable, Name.Variable),
|
| 449 |
+
(r'\^!|%%', String.Escape),
|
| 450 |
+
(rf'[^"%^{_nl}]+|[%^]', String.Double),
|
| 451 |
+
default('#pop')
|
| 452 |
+
],
|
| 453 |
+
'sqstring': [
|
| 454 |
+
include('variable-or-escape'),
|
| 455 |
+
(r'[^%]+|%', String.Single)
|
| 456 |
+
],
|
| 457 |
+
'bqstring': [
|
| 458 |
+
include('variable-or-escape'),
|
| 459 |
+
(r'[^%]+|%', String.Backtick)
|
| 460 |
+
],
|
| 461 |
+
'text': [
|
| 462 |
+
(r'"', String.Double, 'string'),
|
| 463 |
+
include('variable-or-escape'),
|
| 464 |
+
(rf'[^"%^{_nlws}{_punct}\d)]+|.', Text)
|
| 465 |
+
],
|
| 466 |
+
'variable': [
|
| 467 |
+
(r'"', String.Double, 'string'),
|
| 468 |
+
include('variable-or-escape'),
|
| 469 |
+
(rf'[^"%^{_nl}]+|.', Name.Variable)
|
| 470 |
+
],
|
| 471 |
+
'for': [
|
| 472 |
+
(rf'({_space})(in)({_space})(\()',
|
| 473 |
+
bygroups(using(this, state='text'), Keyword,
|
| 474 |
+
using(this, state='text'), Punctuation), '#pop'),
|
| 475 |
+
include('follow')
|
| 476 |
+
],
|
| 477 |
+
'for2': [
|
| 478 |
+
(r'\)', Punctuation),
|
| 479 |
+
(rf'({_space})(do{_token_terminator})',
|
| 480 |
+
bygroups(using(this, state='text'), Keyword), '#pop'),
|
| 481 |
+
(rf'[{_nl}]+', Text),
|
| 482 |
+
include('follow')
|
| 483 |
+
],
|
| 484 |
+
'for/f': [
|
| 485 |
+
(rf'(")((?:{_variable}|[^"])*?")([{_nlws}]*)(\))',
|
| 486 |
+
bygroups(String.Double, using(this, state='string'), Text,
|
| 487 |
+
Punctuation)),
|
| 488 |
+
(r'"', String.Double, ('#pop', 'for2', 'string')),
|
| 489 |
+
(rf"('(?:%%|{_variable}|[\w\W])*?')([{_nlws}]*)(\))",
|
| 490 |
+
bygroups(using(this, state='sqstring'), Text, Punctuation)),
|
| 491 |
+
(rf'(`(?:%%|{_variable}|[\w\W])*?`)([{_nlws}]*)(\))',
|
| 492 |
+
bygroups(using(this, state='bqstring'), Text, Punctuation)),
|
| 493 |
+
include('for2')
|
| 494 |
+
],
|
| 495 |
+
'for/l': [
|
| 496 |
+
(r'-?\d+', Number.Integer),
|
| 497 |
+
include('for2')
|
| 498 |
+
],
|
| 499 |
+
'if': [
|
| 500 |
+
(rf'((?:cmdextversion|errorlevel){_token_terminator})({_space})(\d+)',
|
| 501 |
+
bygroups(Keyword, using(this, state='text'),
|
| 502 |
+
Number.Integer), '#pop'),
|
| 503 |
+
(rf'(defined{_token_terminator})({_space})({_stoken})',
|
| 504 |
+
bygroups(Keyword, using(this, state='text'),
|
| 505 |
+
using(this, state='variable')), '#pop'),
|
| 506 |
+
(rf'(exist{_token_terminator})({_space}{_stoken})',
|
| 507 |
+
bygroups(Keyword, using(this, state='text')), '#pop'),
|
| 508 |
+
(rf'({_number}{_space})({_opword})({_space}{_number})',
|
| 509 |
+
bygroups(using(this, state='arithmetic'), Operator.Word,
|
| 510 |
+
using(this, state='arithmetic')), '#pop'),
|
| 511 |
+
(_stoken, using(this, state='text'), ('#pop', 'if2')),
|
| 512 |
+
],
|
| 513 |
+
'if2': [
|
| 514 |
+
(rf'({_space}?)(==)({_space}?{_stoken})',
|
| 515 |
+
bygroups(using(this, state='text'), Operator,
|
| 516 |
+
using(this, state='text')), '#pop'),
|
| 517 |
+
(rf'({_space})({_opword})({_space}{_stoken})',
|
| 518 |
+
bygroups(using(this, state='text'), Operator.Word,
|
| 519 |
+
using(this, state='text')), '#pop')
|
| 520 |
+
],
|
| 521 |
+
'(?': [
|
| 522 |
+
(_space, using(this, state='text')),
|
| 523 |
+
(r'\(', Punctuation, ('#pop', 'else?', 'root/compound')),
|
| 524 |
+
default('#pop')
|
| 525 |
+
],
|
| 526 |
+
'else?': [
|
| 527 |
+
(_space, using(this, state='text')),
|
| 528 |
+
(rf'else{_token_terminator}', Keyword, '#pop'),
|
| 529 |
+
default('#pop')
|
| 530 |
+
]
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
class MSDOSSessionLexer(ShellSessionBaseLexer):
|
| 535 |
+
"""
|
| 536 |
+
Lexer for MS DOS shell sessions, i.e. command lines, including a
|
| 537 |
+
prompt, interspersed with output.
|
| 538 |
+
"""
|
| 539 |
+
|
| 540 |
+
name = 'MSDOS Session'
|
| 541 |
+
aliases = ['doscon']
|
| 542 |
+
filenames = []
|
| 543 |
+
mimetypes = []
|
| 544 |
+
url = 'https://en.wikipedia.org/wiki/MS-DOS'
|
| 545 |
+
version_added = '2.1'
|
| 546 |
+
_example = "doscon/session"
|
| 547 |
+
|
| 548 |
+
_innerLexerCls = BatchLexer
|
| 549 |
+
_ps1rgx = re.compile(r'^([^>]*>)(.*\n?)')
|
| 550 |
+
_ps2 = 'More? '
|
| 551 |
+
|
| 552 |
+
|
| 553 |
+
class TcshLexer(RegexLexer):
|
| 554 |
+
"""
|
| 555 |
+
Lexer for tcsh scripts.
|
| 556 |
+
"""
|
| 557 |
+
|
| 558 |
+
name = 'Tcsh'
|
| 559 |
+
aliases = ['tcsh', 'csh']
|
| 560 |
+
filenames = ['*.tcsh', '*.csh']
|
| 561 |
+
mimetypes = ['application/x-csh']
|
| 562 |
+
url = 'https://www.tcsh.org'
|
| 563 |
+
version_added = '0.10'
|
| 564 |
+
|
| 565 |
+
tokens = {
|
| 566 |
+
'root': [
|
| 567 |
+
include('basic'),
|
| 568 |
+
(r'\$\(', Keyword, 'paren'),
|
| 569 |
+
(r'\$\{#?', Keyword, 'curly'),
|
| 570 |
+
(r'`', String.Backtick, 'backticks'),
|
| 571 |
+
include('data'),
|
| 572 |
+
],
|
| 573 |
+
'basic': [
|
| 574 |
+
(r'\b(if|endif|else|while|then|foreach|case|default|'
|
| 575 |
+
r'break|continue|goto|breaksw|end|switch|endsw)\s*\b',
|
| 576 |
+
Keyword),
|
| 577 |
+
(r'\b(alias|alloc|bg|bindkey|builtins|bye|caller|cd|chdir|'
|
| 578 |
+
r'complete|dirs|echo|echotc|eval|exec|exit|fg|filetest|getxvers|'
|
| 579 |
+
r'glob|getspath|hashstat|history|hup|inlib|jobs|kill|'
|
| 580 |
+
r'limit|log|login|logout|ls-F|migrate|newgrp|nice|nohup|notify|'
|
| 581 |
+
r'onintr|popd|printenv|pushd|rehash|repeat|rootnode|popd|pushd|'
|
| 582 |
+
r'set|shift|sched|setenv|setpath|settc|setty|setxvers|shift|'
|
| 583 |
+
r'source|stop|suspend|source|suspend|telltc|time|'
|
| 584 |
+
r'umask|unalias|uncomplete|unhash|universe|unlimit|unset|unsetenv|'
|
| 585 |
+
r'ver|wait|warp|watchlog|where|which)\s*\b',
|
| 586 |
+
Name.Builtin),
|
| 587 |
+
(r'#.*', Comment),
|
| 588 |
+
(r'\\[\w\W]', String.Escape),
|
| 589 |
+
(r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
|
| 590 |
+
(r'[\[\]{}()=]+', Operator),
|
| 591 |
+
(r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
|
| 592 |
+
(r';', Punctuation),
|
| 593 |
+
],
|
| 594 |
+
'data': [
|
| 595 |
+
(r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
|
| 596 |
+
(r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
|
| 597 |
+
(r'\s+', Text),
|
| 598 |
+
(r'[^=\s\[\]{}()$"\'`\\;#]+', Text),
|
| 599 |
+
(r'\d+(?= |\Z)', Number),
|
| 600 |
+
(r'\$#?(\w+|.)', Name.Variable),
|
| 601 |
+
],
|
| 602 |
+
'curly': [
|
| 603 |
+
(r'\}', Keyword, '#pop'),
|
| 604 |
+
(r':-', Keyword),
|
| 605 |
+
(r'\w+', Name.Variable),
|
| 606 |
+
(r'[^}:"\'`$]+', Punctuation),
|
| 607 |
+
(r':', Punctuation),
|
| 608 |
+
include('root'),
|
| 609 |
+
],
|
| 610 |
+
'paren': [
|
| 611 |
+
(r'\)', Keyword, '#pop'),
|
| 612 |
+
include('root'),
|
| 613 |
+
],
|
| 614 |
+
'backticks': [
|
| 615 |
+
(r'`', String.Backtick, '#pop'),
|
| 616 |
+
include('root'),
|
| 617 |
+
],
|
| 618 |
+
}
|
| 619 |
+
|
| 620 |
+
|
| 621 |
+
class TcshSessionLexer(ShellSessionBaseLexer):
|
| 622 |
+
"""
|
| 623 |
+
Lexer for Tcsh sessions, i.e. command lines, including a
|
| 624 |
+
prompt, interspersed with output.
|
| 625 |
+
"""
|
| 626 |
+
|
| 627 |
+
name = 'Tcsh Session'
|
| 628 |
+
aliases = ['tcshcon']
|
| 629 |
+
filenames = []
|
| 630 |
+
mimetypes = []
|
| 631 |
+
url = 'https://www.tcsh.org'
|
| 632 |
+
version_added = '2.1'
|
| 633 |
+
_example = "tcshcon/session"
|
| 634 |
+
|
| 635 |
+
_innerLexerCls = TcshLexer
|
| 636 |
+
_ps1rgx = re.compile(r'^([^>]+>)(.*\n?)')
|
| 637 |
+
_ps2 = '? '
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
class PowerShellLexer(RegexLexer):
|
| 641 |
+
"""
|
| 642 |
+
For Windows PowerShell code.
|
| 643 |
+
"""
|
| 644 |
+
name = 'PowerShell'
|
| 645 |
+
aliases = ['powershell', 'pwsh', 'posh', 'ps1', 'psm1']
|
| 646 |
+
filenames = ['*.ps1', '*.psm1']
|
| 647 |
+
mimetypes = ['text/x-powershell']
|
| 648 |
+
url = 'https://learn.microsoft.com/en-us/powershell'
|
| 649 |
+
version_added = '1.5'
|
| 650 |
+
|
| 651 |
+
flags = re.DOTALL | re.IGNORECASE | re.MULTILINE
|
| 652 |
+
|
| 653 |
+
keywords = (
|
| 654 |
+
'while validateset validaterange validatepattern validatelength '
|
| 655 |
+
'validatecount until trap switch return ref process param parameter in '
|
| 656 |
+
'if global: local: function foreach for finally filter end elseif else '
|
| 657 |
+
'dynamicparam do default continue cmdletbinding break begin alias \\? '
|
| 658 |
+
'% #script #private #local #global mandatory parametersetname position '
|
| 659 |
+
'valuefrompipeline valuefrompipelinebypropertyname '
|
| 660 |
+
'valuefromremainingarguments helpmessage try catch throw').split()
|
| 661 |
+
|
| 662 |
+
operators = (
|
| 663 |
+
'and as band bnot bor bxor casesensitive ccontains ceq cge cgt cle '
|
| 664 |
+
'clike clt cmatch cne cnotcontains cnotlike cnotmatch contains '
|
| 665 |
+
'creplace eq exact f file ge gt icontains ieq ige igt ile ilike ilt '
|
| 666 |
+
'imatch ine inotcontains inotlike inotmatch ireplace is isnot le like '
|
| 667 |
+
'lt match ne not notcontains notlike notmatch or regex replace '
|
| 668 |
+
'wildcard').split()
|
| 669 |
+
|
| 670 |
+
verbs = (
|
| 671 |
+
'write where watch wait use update unregister unpublish unprotect '
|
| 672 |
+
'unlock uninstall undo unblock trace test tee take sync switch '
|
| 673 |
+
'suspend submit stop step start split sort skip show set send select '
|
| 674 |
+
'search scroll save revoke resume restore restart resolve resize '
|
| 675 |
+
'reset request repair rename remove register redo receive read push '
|
| 676 |
+
'publish protect pop ping out optimize open new move mount merge '
|
| 677 |
+
'measure lock limit join invoke install initialize import hide group '
|
| 678 |
+
'grant get format foreach find export expand exit enter enable edit '
|
| 679 |
+
'dismount disconnect disable deny debug cxnew copy convertto '
|
| 680 |
+
'convertfrom convert connect confirm compress complete compare close '
|
| 681 |
+
'clear checkpoint block backup assert approve aggregate add').split()
|
| 682 |
+
|
| 683 |
+
aliases_ = (
|
| 684 |
+
'ac asnp cat cd cfs chdir clc clear clhy cli clp cls clv cnsn '
|
| 685 |
+
'compare copy cp cpi cpp curl cvpa dbp del diff dir dnsn ebp echo epal '
|
| 686 |
+
'epcsv epsn erase etsn exsn fc fhx fl foreach ft fw gal gbp gc gci gcm '
|
| 687 |
+
'gcs gdr ghy gi gjb gl gm gmo gp gps gpv group gsn gsnp gsv gu gv gwmi '
|
| 688 |
+
'h history icm iex ihy ii ipal ipcsv ipmo ipsn irm ise iwmi iwr kill lp '
|
| 689 |
+
'ls man md measure mi mount move mp mv nal ndr ni nmo npssc nsn nv ogv '
|
| 690 |
+
'oh popd ps pushd pwd r rbp rcjb rcsn rd rdr ren ri rjb rm rmdir rmo '
|
| 691 |
+
'rni rnp rp rsn rsnp rujb rv rvpa rwmi sajb sal saps sasv sbp sc select '
|
| 692 |
+
'set shcm si sl sleep sls sort sp spjb spps spsv start sujb sv swmi tee '
|
| 693 |
+
'trcm type wget where wjb write').split()
|
| 694 |
+
|
| 695 |
+
commenthelp = (
|
| 696 |
+
'component description example externalhelp forwardhelpcategory '
|
| 697 |
+
'forwardhelptargetname functionality inputs link '
|
| 698 |
+
'notes outputs parameter remotehelprunspace role synopsis').split()
|
| 699 |
+
|
| 700 |
+
tokens = {
|
| 701 |
+
'root': [
|
| 702 |
+
# we need to count pairs of parentheses for correct highlight
|
| 703 |
+
# of '$(...)' blocks in strings
|
| 704 |
+
(r'\(', Punctuation, 'child'),
|
| 705 |
+
(r'\s+', Text),
|
| 706 |
+
(r'^(\s*#[#\s]*)(\.(?:{}))([^\n]*$)'.format('|'.join(commenthelp)),
|
| 707 |
+
bygroups(Comment, String.Doc, Comment)),
|
| 708 |
+
(r'#[^\n]*?$', Comment),
|
| 709 |
+
(r'(<|<)#', Comment.Multiline, 'multline'),
|
| 710 |
+
(r'@"\n', String.Heredoc, 'heredoc-double'),
|
| 711 |
+
(r"@'\n.*?\n'@", String.Heredoc),
|
| 712 |
+
# escaped syntax
|
| 713 |
+
(r'`[\'"$@-]', Punctuation),
|
| 714 |
+
(r'"', String.Double, 'string'),
|
| 715 |
+
(r"'([^']|'')*'", String.Single),
|
| 716 |
+
(r'(\$|@@|@)((global|script|private|env):)?\w+',
|
| 717 |
+
Name.Variable),
|
| 718 |
+
(r'({})\b'.format('|'.join(keywords)), Keyword),
|
| 719 |
+
(r'-({})\b'.format('|'.join(operators)), Operator),
|
| 720 |
+
(r'({})-[a-z_]\w*\b'.format('|'.join(verbs)), Name.Builtin),
|
| 721 |
+
(r'({})\s'.format('|'.join(aliases_)), Name.Builtin),
|
| 722 |
+
(r'\[[a-z_\[][\w. `,\[\]]*\]', Name.Constant), # .net [type]s
|
| 723 |
+
(r'-[a-z_]\w*', Name),
|
| 724 |
+
(r'\w+', Name),
|
| 725 |
+
(r'[.,;:@{}\[\]$()=+*/\\&%!~?^`|<>-]', Punctuation),
|
| 726 |
+
],
|
| 727 |
+
'child': [
|
| 728 |
+
(r'\)', Punctuation, '#pop'),
|
| 729 |
+
include('root'),
|
| 730 |
+
],
|
| 731 |
+
'multline': [
|
| 732 |
+
(r'[^#&.]+', Comment.Multiline),
|
| 733 |
+
(r'#(>|>)', Comment.Multiline, '#pop'),
|
| 734 |
+
(r'\.({})'.format('|'.join(commenthelp)), String.Doc),
|
| 735 |
+
(r'[#&.]', Comment.Multiline),
|
| 736 |
+
],
|
| 737 |
+
'string': [
|
| 738 |
+
(r"`[0abfnrtv'\"$`]", String.Escape),
|
| 739 |
+
(r'[^$`"]+', String.Double),
|
| 740 |
+
(r'\$\(', Punctuation, 'child'),
|
| 741 |
+
(r'""', String.Double),
|
| 742 |
+
(r'[`$]', String.Double),
|
| 743 |
+
(r'"', String.Double, '#pop'),
|
| 744 |
+
],
|
| 745 |
+
'heredoc-double': [
|
| 746 |
+
(r'\n"@', String.Heredoc, '#pop'),
|
| 747 |
+
(r'\$\(', Punctuation, 'child'),
|
| 748 |
+
(r'[^@\n]+"]', String.Heredoc),
|
| 749 |
+
(r".", String.Heredoc),
|
| 750 |
+
]
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
+
|
| 754 |
+
class PowerShellSessionLexer(ShellSessionBaseLexer):
|
| 755 |
+
"""
|
| 756 |
+
Lexer for PowerShell sessions, i.e. command lines, including a
|
| 757 |
+
prompt, interspersed with output.
|
| 758 |
+
"""
|
| 759 |
+
|
| 760 |
+
name = 'PowerShell Session'
|
| 761 |
+
aliases = ['pwsh-session', 'ps1con']
|
| 762 |
+
filenames = []
|
| 763 |
+
mimetypes = []
|
| 764 |
+
url = 'https://learn.microsoft.com/en-us/powershell'
|
| 765 |
+
version_added = '2.1'
|
| 766 |
+
_example = "pwsh-session/session"
|
| 767 |
+
|
| 768 |
+
_innerLexerCls = PowerShellLexer
|
| 769 |
+
_bare_continuation = True
|
| 770 |
+
_ps1rgx = re.compile(r'^((?:\[[^]]+\]: )?PS[^>]*> ?)(.*\n?)')
|
| 771 |
+
_ps2 = '> '
|
| 772 |
+
|
| 773 |
+
|
| 774 |
+
class FishShellLexer(RegexLexer):
|
| 775 |
+
"""
|
| 776 |
+
Lexer for Fish shell scripts.
|
| 777 |
+
"""
|
| 778 |
+
|
| 779 |
+
name = 'Fish'
|
| 780 |
+
aliases = ['fish', 'fishshell']
|
| 781 |
+
filenames = ['*.fish', '*.load']
|
| 782 |
+
mimetypes = ['application/x-fish']
|
| 783 |
+
url = 'https://fishshell.com'
|
| 784 |
+
version_added = '2.1'
|
| 785 |
+
|
| 786 |
+
tokens = {
|
| 787 |
+
'root': [
|
| 788 |
+
include('basic'),
|
| 789 |
+
include('data'),
|
| 790 |
+
include('interp'),
|
| 791 |
+
],
|
| 792 |
+
'interp': [
|
| 793 |
+
(r'\$\(\(', Keyword, 'math'),
|
| 794 |
+
(r'\(', Keyword, 'paren'),
|
| 795 |
+
(r'\$#?(\w+|.)', Name.Variable),
|
| 796 |
+
],
|
| 797 |
+
'basic': [
|
| 798 |
+
(r'\b(begin|end|if|else|while|break|for|in|return|function|block|'
|
| 799 |
+
r'case|continue|switch|not|and|or|set|echo|exit|pwd|true|false|'
|
| 800 |
+
r'cd|count|test)(\s*)\b',
|
| 801 |
+
bygroups(Keyword, Text)),
|
| 802 |
+
(r'\b(alias|bg|bind|breakpoint|builtin|command|commandline|'
|
| 803 |
+
r'complete|contains|dirh|dirs|emit|eval|exec|fg|fish|fish_config|'
|
| 804 |
+
r'fish_indent|fish_pager|fish_prompt|fish_right_prompt|'
|
| 805 |
+
r'fish_update_completions|fishd|funced|funcsave|functions|help|'
|
| 806 |
+
r'history|isatty|jobs|math|mimedb|nextd|open|popd|prevd|psub|'
|
| 807 |
+
r'pushd|random|read|set_color|source|status|trap|type|ulimit|'
|
| 808 |
+
r'umask|vared|fc|getopts|hash|kill|printf|time|wait)\s*\b(?!\.)',
|
| 809 |
+
Name.Builtin),
|
| 810 |
+
(r'#.*\n', Comment),
|
| 811 |
+
(r'\\[\w\W]', String.Escape),
|
| 812 |
+
(r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Whitespace, Operator)),
|
| 813 |
+
(r'[\[\]()=]', Operator),
|
| 814 |
+
(r'<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
|
| 815 |
+
],
|
| 816 |
+
'data': [
|
| 817 |
+
(r'(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"', String.Double),
|
| 818 |
+
(r'"', String.Double, 'string'),
|
| 819 |
+
(r"(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
|
| 820 |
+
(r"(?s)'.*?'", String.Single),
|
| 821 |
+
(r';', Punctuation),
|
| 822 |
+
(r'&|\||\^|<|>', Operator),
|
| 823 |
+
(r'\s+', Text),
|
| 824 |
+
(r'\d+(?= |\Z)', Number),
|
| 825 |
+
(r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
|
| 826 |
+
],
|
| 827 |
+
'string': [
|
| 828 |
+
(r'"', String.Double, '#pop'),
|
| 829 |
+
(r'(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+', String.Double),
|
| 830 |
+
include('interp'),
|
| 831 |
+
],
|
| 832 |
+
'paren': [
|
| 833 |
+
(r'\)', Keyword, '#pop'),
|
| 834 |
+
include('root'),
|
| 835 |
+
],
|
| 836 |
+
'math': [
|
| 837 |
+
(r'\)\)', Keyword, '#pop'),
|
| 838 |
+
(r'[-+*/%^|&]|\*\*|\|\|', Operator),
|
| 839 |
+
(r'\d+#\d+', Number),
|
| 840 |
+
(r'\d+#(?! )', Number),
|
| 841 |
+
(r'\d+', Number),
|
| 842 |
+
include('root'),
|
| 843 |
+
],
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
+
class ExeclineLexer(RegexLexer):
|
| 847 |
+
"""
|
| 848 |
+
Lexer for Laurent Bercot's execline language.
|
| 849 |
+
"""
|
| 850 |
+
|
| 851 |
+
name = 'execline'
|
| 852 |
+
aliases = ['execline']
|
| 853 |
+
filenames = ['*.exec']
|
| 854 |
+
url = 'https://skarnet.org/software/execline'
|
| 855 |
+
version_added = '2.7'
|
| 856 |
+
|
| 857 |
+
tokens = {
|
| 858 |
+
'root': [
|
| 859 |
+
include('basic'),
|
| 860 |
+
include('data'),
|
| 861 |
+
include('interp')
|
| 862 |
+
],
|
| 863 |
+
'interp': [
|
| 864 |
+
(r'\$\{', String.Interpol, 'curly'),
|
| 865 |
+
(r'\$[\w@#]+', Name.Variable), # user variable
|
| 866 |
+
(r'\$', Text),
|
| 867 |
+
],
|
| 868 |
+
'basic': [
|
| 869 |
+
(r'\b(background|backtick|cd|define|dollarat|elgetopt|'
|
| 870 |
+
r'elgetpositionals|elglob|emptyenv|envfile|exec|execlineb|'
|
| 871 |
+
r'exit|export|fdblock|fdclose|fdmove|fdreserve|fdswap|'
|
| 872 |
+
r'forbacktickx|foreground|forstdin|forx|getcwd|getpid|heredoc|'
|
| 873 |
+
r'homeof|if|ifelse|ifte|ifthenelse|importas|loopwhilex|'
|
| 874 |
+
r'multidefine|multisubstitute|pipeline|piperw|posix-cd|'
|
| 875 |
+
r'redirfd|runblock|shift|trap|tryexec|umask|unexport|wait|'
|
| 876 |
+
r'withstdinas)\b', Name.Builtin),
|
| 877 |
+
(r'\A#!.+\n', Comment.Hashbang),
|
| 878 |
+
(r'#.*\n', Comment.Single),
|
| 879 |
+
(r'[{}]', Operator)
|
| 880 |
+
],
|
| 881 |
+
'data': [
|
| 882 |
+
(r'(?s)"(\\.|[^"\\$])*"', String.Double),
|
| 883 |
+
(r'"', String.Double, 'string'),
|
| 884 |
+
(r'\s+', Text),
|
| 885 |
+
(r'[^\s{}$"\\]+', Text)
|
| 886 |
+
],
|
| 887 |
+
'string': [
|
| 888 |
+
(r'"', String.Double, '#pop'),
|
| 889 |
+
(r'(?s)(\\\\|\\.|[^"\\$])+', String.Double),
|
| 890 |
+
include('interp'),
|
| 891 |
+
],
|
| 892 |
+
'curly': [
|
| 893 |
+
(r'\}', String.Interpol, '#pop'),
|
| 894 |
+
(r'[\w#@]+', Name.Variable),
|
| 895 |
+
include('root')
|
| 896 |
+
]
|
| 897 |
+
|
| 898 |
+
}
|
| 899 |
+
|
| 900 |
+
def analyse_text(text):
|
| 901 |
+
if shebang_matches(text, r'execlineb'):
|
| 902 |
+
return 1
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/sieve.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.sieve
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Sieve file format.
|
| 6 |
+
|
| 7 |
+
https://tools.ietf.org/html/rfc5228
|
| 8 |
+
https://tools.ietf.org/html/rfc5173
|
| 9 |
+
https://tools.ietf.org/html/rfc5229
|
| 10 |
+
https://tools.ietf.org/html/rfc5230
|
| 11 |
+
https://tools.ietf.org/html/rfc5232
|
| 12 |
+
https://tools.ietf.org/html/rfc5235
|
| 13 |
+
https://tools.ietf.org/html/rfc5429
|
| 14 |
+
https://tools.ietf.org/html/rfc8580
|
| 15 |
+
|
| 16 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 17 |
+
:license: BSD, see LICENSE for details.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
from pygments.lexer import RegexLexer, bygroups
|
| 21 |
+
from pygments.token import Comment, Name, Literal, String, Text, Punctuation, \
|
| 22 |
+
Keyword
|
| 23 |
+
|
| 24 |
+
__all__ = ["SieveLexer"]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class SieveLexer(RegexLexer):
|
| 28 |
+
"""
|
| 29 |
+
Lexer for sieve format.
|
| 30 |
+
"""
|
| 31 |
+
name = 'Sieve'
|
| 32 |
+
filenames = ['*.siv', '*.sieve']
|
| 33 |
+
aliases = ['sieve']
|
| 34 |
+
url = 'https://en.wikipedia.org/wiki/Sieve_(mail_filtering_language)'
|
| 35 |
+
version_added = '2.6'
|
| 36 |
+
|
| 37 |
+
tokens = {
|
| 38 |
+
'root': [
|
| 39 |
+
(r'\s+', Text),
|
| 40 |
+
(r'[();,{}\[\]]', Punctuation),
|
| 41 |
+
# import:
|
| 42 |
+
(r'(?i)require',
|
| 43 |
+
Keyword.Namespace),
|
| 44 |
+
# tags:
|
| 45 |
+
(r'(?i)(:)(addresses|all|contains|content|create|copy|comparator|'
|
| 46 |
+
r'count|days|detail|domain|fcc|flags|from|handle|importance|is|'
|
| 47 |
+
r'localpart|length|lowerfirst|lower|matches|message|mime|options|'
|
| 48 |
+
r'over|percent|quotewildcard|raw|regex|specialuse|subject|text|'
|
| 49 |
+
r'under|upperfirst|upper|value)',
|
| 50 |
+
bygroups(Name.Tag, Name.Tag)),
|
| 51 |
+
# tokens:
|
| 52 |
+
(r'(?i)(address|addflag|allof|anyof|body|discard|elsif|else|envelope|'
|
| 53 |
+
r'ereject|exists|false|fileinto|if|hasflag|header|keep|'
|
| 54 |
+
r'notify_method_capability|notify|not|redirect|reject|removeflag|'
|
| 55 |
+
r'setflag|size|spamtest|stop|string|true|vacation|virustest)',
|
| 56 |
+
Name.Builtin),
|
| 57 |
+
(r'(?i)set',
|
| 58 |
+
Keyword.Declaration),
|
| 59 |
+
# number:
|
| 60 |
+
(r'([0-9.]+)([kmgKMG])?',
|
| 61 |
+
bygroups(Literal.Number, Literal.Number)),
|
| 62 |
+
# comment:
|
| 63 |
+
(r'#.*$',
|
| 64 |
+
Comment.Single),
|
| 65 |
+
(r'/\*.*\*/',
|
| 66 |
+
Comment.Multiline),
|
| 67 |
+
# string:
|
| 68 |
+
(r'"[^"]*?"',
|
| 69 |
+
String),
|
| 70 |
+
# text block:
|
| 71 |
+
(r'text:',
|
| 72 |
+
Name.Tag, 'text'),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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.slash
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the Slash 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 ExtendedRegexLexer, bygroups, DelegatingLexer
|
| 12 |
+
from pygments.token import Name, Number, String, Comment, Punctuation, \
|
| 13 |
+
Other, Keyword, Operator, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['SlashLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class SlashLanguageLexer(ExtendedRegexLexer):
|
| 19 |
+
_nkw = r'(?=[^a-zA-Z_0-9])'
|
| 20 |
+
|
| 21 |
+
def move_state(new_state):
|
| 22 |
+
return ("#pop", new_state)
|
| 23 |
+
|
| 24 |
+
def right_angle_bracket(lexer, match, ctx):
|
| 25 |
+
if len(ctx.stack) > 1 and ctx.stack[-2] == "string":
|
| 26 |
+
ctx.stack.pop()
|
| 27 |
+
yield match.start(), String.Interpol, '}'
|
| 28 |
+
ctx.pos = match.end()
|
| 29 |
+
pass
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
"root": [
|
| 33 |
+
(r"<%=", Comment.Preproc, move_state("slash")),
|
| 34 |
+
(r"<%!!", Comment.Preproc, move_state("slash")),
|
| 35 |
+
(r"<%#.*?%>", Comment.Multiline),
|
| 36 |
+
(r"<%", Comment.Preproc, move_state("slash")),
|
| 37 |
+
(r".|\n", Other),
|
| 38 |
+
],
|
| 39 |
+
"string": [
|
| 40 |
+
(r"\\", String.Escape, move_state("string_e")),
|
| 41 |
+
(r"\"", String, move_state("slash")),
|
| 42 |
+
(r"#\{", String.Interpol, "slash"),
|
| 43 |
+
(r'.|\n', String),
|
| 44 |
+
],
|
| 45 |
+
"string_e": [
|
| 46 |
+
(r'n', String.Escape, move_state("string")),
|
| 47 |
+
(r't', String.Escape, move_state("string")),
|
| 48 |
+
(r'r', String.Escape, move_state("string")),
|
| 49 |
+
(r'e', String.Escape, move_state("string")),
|
| 50 |
+
(r'x[a-fA-F0-9]{2}', String.Escape, move_state("string")),
|
| 51 |
+
(r'.', String.Escape, move_state("string")),
|
| 52 |
+
],
|
| 53 |
+
"regexp": [
|
| 54 |
+
(r'}[a-z]*', String.Regex, move_state("slash")),
|
| 55 |
+
(r'\\(.|\n)', String.Regex),
|
| 56 |
+
(r'{', String.Regex, "regexp_r"),
|
| 57 |
+
(r'.|\n', String.Regex),
|
| 58 |
+
],
|
| 59 |
+
"regexp_r": [
|
| 60 |
+
(r'}[a-z]*', String.Regex, "#pop"),
|
| 61 |
+
(r'\\(.|\n)', String.Regex),
|
| 62 |
+
(r'{', String.Regex, "regexp_r"),
|
| 63 |
+
],
|
| 64 |
+
"slash": [
|
| 65 |
+
(r"%>", Comment.Preproc, move_state("root")),
|
| 66 |
+
(r"\"", String, move_state("string")),
|
| 67 |
+
(r"'[a-zA-Z0-9_]+", String),
|
| 68 |
+
(r'%r{', String.Regex, move_state("regexp")),
|
| 69 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 70 |
+
(r"(#|//).*?\n", Comment.Single),
|
| 71 |
+
(r'-?[0-9]+e[+-]?[0-9]+', Number.Float),
|
| 72 |
+
(r'-?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?', Number.Float),
|
| 73 |
+
(r'-?[0-9]+', Number.Integer),
|
| 74 |
+
(r'nil'+_nkw, Name.Builtin),
|
| 75 |
+
(r'true'+_nkw, Name.Builtin),
|
| 76 |
+
(r'false'+_nkw, Name.Builtin),
|
| 77 |
+
(r'self'+_nkw, Name.Builtin),
|
| 78 |
+
(r'(class)(\s+)([A-Z][a-zA-Z0-9_\']*)',
|
| 79 |
+
bygroups(Keyword, Whitespace, Name.Class)),
|
| 80 |
+
(r'class'+_nkw, Keyword),
|
| 81 |
+
(r'extends'+_nkw, Keyword),
|
| 82 |
+
(r'(def)(\s+)(self)(\s*)(\.)(\s*)([a-z_][a-zA-Z0-9_\']*=?|<<|>>|==|<=>|<=|<|>=|>|\+|-(self)?|~(self)?|\*|/|%|^|&&|&|\||\[\]=?)',
|
| 83 |
+
bygroups(Keyword, Whitespace, Name.Builtin, Whitespace, Punctuation, Whitespace, Name.Function)),
|
| 84 |
+
(r'(def)(\s+)([a-z_][a-zA-Z0-9_\']*=?|<<|>>|==|<=>|<=|<|>=|>|\+|-(self)?|~(self)?|\*|/|%|^|&&|&|\||\[\]=?)',
|
| 85 |
+
bygroups(Keyword, Whitespace, Name.Function)),
|
| 86 |
+
(r'def'+_nkw, Keyword),
|
| 87 |
+
(r'if'+_nkw, Keyword),
|
| 88 |
+
(r'elsif'+_nkw, Keyword),
|
| 89 |
+
(r'else'+_nkw, Keyword),
|
| 90 |
+
(r'unless'+_nkw, Keyword),
|
| 91 |
+
(r'for'+_nkw, Keyword),
|
| 92 |
+
(r'in'+_nkw, Keyword),
|
| 93 |
+
(r'while'+_nkw, Keyword),
|
| 94 |
+
(r'until'+_nkw, Keyword),
|
| 95 |
+
(r'and'+_nkw, Keyword),
|
| 96 |
+
(r'or'+_nkw, Keyword),
|
| 97 |
+
(r'not'+_nkw, Keyword),
|
| 98 |
+
(r'lambda'+_nkw, Keyword),
|
| 99 |
+
(r'try'+_nkw, Keyword),
|
| 100 |
+
(r'catch'+_nkw, Keyword),
|
| 101 |
+
(r'return'+_nkw, Keyword),
|
| 102 |
+
(r'next'+_nkw, Keyword),
|
| 103 |
+
(r'last'+_nkw, Keyword),
|
| 104 |
+
(r'throw'+_nkw, Keyword),
|
| 105 |
+
(r'use'+_nkw, Keyword),
|
| 106 |
+
(r'switch'+_nkw, Keyword),
|
| 107 |
+
(r'\\', Keyword),
|
| 108 |
+
(r'λ', Keyword),
|
| 109 |
+
(r'__FILE__'+_nkw, Name.Builtin.Pseudo),
|
| 110 |
+
(r'__LINE__'+_nkw, Name.Builtin.Pseudo),
|
| 111 |
+
(r'[A-Z][a-zA-Z0-9_\']*'+_nkw, Name.Constant),
|
| 112 |
+
(r'[a-z_][a-zA-Z0-9_\']*'+_nkw, Name),
|
| 113 |
+
(r'@[a-z_][a-zA-Z0-9_\']*'+_nkw, Name.Variable.Instance),
|
| 114 |
+
(r'@@[a-z_][a-zA-Z0-9_\']*'+_nkw, Name.Variable.Class),
|
| 115 |
+
(r'\(', Punctuation),
|
| 116 |
+
(r'\)', Punctuation),
|
| 117 |
+
(r'\[', Punctuation),
|
| 118 |
+
(r'\]', Punctuation),
|
| 119 |
+
(r'\{', Punctuation),
|
| 120 |
+
(r'\}', right_angle_bracket),
|
| 121 |
+
(r';', Punctuation),
|
| 122 |
+
(r',', Punctuation),
|
| 123 |
+
(r'<<=', Operator),
|
| 124 |
+
(r'>>=', Operator),
|
| 125 |
+
(r'<<', Operator),
|
| 126 |
+
(r'>>', Operator),
|
| 127 |
+
(r'==', Operator),
|
| 128 |
+
(r'!=', Operator),
|
| 129 |
+
(r'=>', Operator),
|
| 130 |
+
(r'=', Operator),
|
| 131 |
+
(r'<=>', Operator),
|
| 132 |
+
(r'<=', Operator),
|
| 133 |
+
(r'>=', Operator),
|
| 134 |
+
(r'<', Operator),
|
| 135 |
+
(r'>', Operator),
|
| 136 |
+
(r'\+\+', Operator),
|
| 137 |
+
(r'\+=', Operator),
|
| 138 |
+
(r'-=', Operator),
|
| 139 |
+
(r'\*\*=', Operator),
|
| 140 |
+
(r'\*=', Operator),
|
| 141 |
+
(r'\*\*', Operator),
|
| 142 |
+
(r'\*', Operator),
|
| 143 |
+
(r'/=', Operator),
|
| 144 |
+
(r'\+', Operator),
|
| 145 |
+
(r'-', Operator),
|
| 146 |
+
(r'/', Operator),
|
| 147 |
+
(r'%=', Operator),
|
| 148 |
+
(r'%', Operator),
|
| 149 |
+
(r'^=', Operator),
|
| 150 |
+
(r'&&=', Operator),
|
| 151 |
+
(r'&=', Operator),
|
| 152 |
+
(r'&&', Operator),
|
| 153 |
+
(r'&', Operator),
|
| 154 |
+
(r'\|\|=', Operator),
|
| 155 |
+
(r'\|=', Operator),
|
| 156 |
+
(r'\|\|', Operator),
|
| 157 |
+
(r'\|', Operator),
|
| 158 |
+
(r'!', Operator),
|
| 159 |
+
(r'\.\.\.', Operator),
|
| 160 |
+
(r'\.\.', Operator),
|
| 161 |
+
(r'\.', Operator),
|
| 162 |
+
(r'::', Operator),
|
| 163 |
+
(r':', Operator),
|
| 164 |
+
(r'(\s|\n)+', Whitespace),
|
| 165 |
+
(r'[a-z_][a-zA-Z0-9_\']*', Name.Variable),
|
| 166 |
+
],
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
class SlashLexer(DelegatingLexer):
|
| 171 |
+
"""
|
| 172 |
+
Lexer for the Slash programming language.
|
| 173 |
+
"""
|
| 174 |
+
|
| 175 |
+
name = 'Slash'
|
| 176 |
+
aliases = ['slash']
|
| 177 |
+
filenames = ['*.sla']
|
| 178 |
+
url = 'https://github.com/arturadib/Slash-A'
|
| 179 |
+
version_added = '2.4'
|
| 180 |
+
|
| 181 |
+
def __init__(self, **options):
|
| 182 |
+
from pygments.lexers.web import HtmlLexer
|
| 183 |
+
super().__init__(HtmlLexer, SlashLanguageLexer, **options)
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/smalltalk.py
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.smalltalk
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Smalltalk 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, include, bygroups, default
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['SmalltalkLexer', 'NewspeakLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class SmalltalkLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Smalltalk syntax.
|
| 21 |
+
Contributed by Stefan Matthias Aust.
|
| 22 |
+
Rewritten by Nils Winter.
|
| 23 |
+
"""
|
| 24 |
+
name = 'Smalltalk'
|
| 25 |
+
url = 'http://www.smalltalk.org/'
|
| 26 |
+
filenames = ['*.st']
|
| 27 |
+
aliases = ['smalltalk', 'squeak', 'st']
|
| 28 |
+
mimetypes = ['text/x-smalltalk']
|
| 29 |
+
version_added = '0.10'
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'root': [
|
| 33 |
+
(r'(<)(\w+:)(.*?)(>)', bygroups(Text, Keyword, Text, Text)),
|
| 34 |
+
include('squeak fileout'),
|
| 35 |
+
include('whitespaces'),
|
| 36 |
+
include('method definition'),
|
| 37 |
+
(r'(\|)([\w\s]*)(\|)', bygroups(Operator, Name.Variable, Operator)),
|
| 38 |
+
include('objects'),
|
| 39 |
+
(r'\^|\:=|\_', Operator),
|
| 40 |
+
# temporaries
|
| 41 |
+
(r'[\]({}.;!]', Text),
|
| 42 |
+
],
|
| 43 |
+
'method definition': [
|
| 44 |
+
# Not perfect can't allow whitespaces at the beginning and the
|
| 45 |
+
# without breaking everything
|
| 46 |
+
(r'([a-zA-Z]+\w*:)(\s*)(\w+)',
|
| 47 |
+
bygroups(Name.Function, Text, Name.Variable)),
|
| 48 |
+
(r'^(\b[a-zA-Z]+\w*\b)(\s*)$', bygroups(Name.Function, Text)),
|
| 49 |
+
(r'^([-+*/\\~<>=|&!?,@%]+)(\s*)(\w+)(\s*)$',
|
| 50 |
+
bygroups(Name.Function, Text, Name.Variable, Text)),
|
| 51 |
+
],
|
| 52 |
+
'blockvariables': [
|
| 53 |
+
include('whitespaces'),
|
| 54 |
+
(r'(:)(\s*)(\w+)',
|
| 55 |
+
bygroups(Operator, Text, Name.Variable)),
|
| 56 |
+
(r'\|', Operator, '#pop'),
|
| 57 |
+
default('#pop'), # else pop
|
| 58 |
+
],
|
| 59 |
+
'literals': [
|
| 60 |
+
(r"'(''|[^'])*'", String, 'afterobject'),
|
| 61 |
+
(r'\$.', String.Char, 'afterobject'),
|
| 62 |
+
(r'#\(', String.Symbol, 'parenth'),
|
| 63 |
+
(r'\)', Text, 'afterobject'),
|
| 64 |
+
(r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number, 'afterobject'),
|
| 65 |
+
],
|
| 66 |
+
'_parenth_helper': [
|
| 67 |
+
include('whitespaces'),
|
| 68 |
+
(r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number),
|
| 69 |
+
(r'[-+*/\\~<>=|&#!?,@%\w:]+', String.Symbol),
|
| 70 |
+
# literals
|
| 71 |
+
(r"'(''|[^'])*'", String),
|
| 72 |
+
(r'\$.', String.Char),
|
| 73 |
+
(r'#*\(', String.Symbol, 'inner_parenth'),
|
| 74 |
+
],
|
| 75 |
+
'parenth': [
|
| 76 |
+
# This state is a bit tricky since
|
| 77 |
+
# we can't just pop this state
|
| 78 |
+
(r'\)', String.Symbol, ('root', 'afterobject')),
|
| 79 |
+
include('_parenth_helper'),
|
| 80 |
+
],
|
| 81 |
+
'inner_parenth': [
|
| 82 |
+
(r'\)', String.Symbol, '#pop'),
|
| 83 |
+
include('_parenth_helper'),
|
| 84 |
+
],
|
| 85 |
+
'whitespaces': [
|
| 86 |
+
# skip whitespace and comments
|
| 87 |
+
(r'\s+', Text),
|
| 88 |
+
(r'"(""|[^"])*"', Comment),
|
| 89 |
+
],
|
| 90 |
+
'objects': [
|
| 91 |
+
(r'\[', Text, 'blockvariables'),
|
| 92 |
+
(r'\]', Text, 'afterobject'),
|
| 93 |
+
(r'\b(self|super|true|false|nil|thisContext)\b',
|
| 94 |
+
Name.Builtin.Pseudo, 'afterobject'),
|
| 95 |
+
(r'\b[A-Z]\w*(?!:)\b', Name.Class, 'afterobject'),
|
| 96 |
+
(r'\b[a-z]\w*(?!:)\b', Name.Variable, 'afterobject'),
|
| 97 |
+
(r'#("(""|[^"])*"|[-+*/\\~<>=|&!?,@%]+|[\w:]+)',
|
| 98 |
+
String.Symbol, 'afterobject'),
|
| 99 |
+
include('literals'),
|
| 100 |
+
],
|
| 101 |
+
'afterobject': [
|
| 102 |
+
(r'! !$', Keyword, '#pop'), # squeak chunk delimiter
|
| 103 |
+
include('whitespaces'),
|
| 104 |
+
(r'\b(ifTrue:|ifFalse:|whileTrue:|whileFalse:|timesRepeat:)',
|
| 105 |
+
Name.Builtin, '#pop'),
|
| 106 |
+
(r'\b(new\b(?!:))', Name.Builtin),
|
| 107 |
+
(r'\:=|\_', Operator, '#pop'),
|
| 108 |
+
(r'\b[a-zA-Z]+\w*:', Name.Function, '#pop'),
|
| 109 |
+
(r'\b[a-zA-Z]+\w*', Name.Function),
|
| 110 |
+
(r'\w+:?|[-+*/\\~<>=|&!?,@%]+', Name.Function, '#pop'),
|
| 111 |
+
(r'\.', Punctuation, '#pop'),
|
| 112 |
+
(r';', Punctuation),
|
| 113 |
+
(r'[\])}]', Text),
|
| 114 |
+
(r'[\[({]', Text, '#pop'),
|
| 115 |
+
],
|
| 116 |
+
'squeak fileout': [
|
| 117 |
+
# Squeak fileout format (optional)
|
| 118 |
+
(r'^"(""|[^"])*"!', Keyword),
|
| 119 |
+
(r"^'(''|[^'])*'!", Keyword),
|
| 120 |
+
(r'^(!)(\w+)( commentStamp: )(.*?)( prior: .*?!\n)(.*?)(!)',
|
| 121 |
+
bygroups(Keyword, Name.Class, Keyword, String, Keyword, Text, Keyword)),
|
| 122 |
+
(r"^(!)(\w+(?: class)?)( methodsFor: )('(?:''|[^'])*')(.*?!)",
|
| 123 |
+
bygroups(Keyword, Name.Class, Keyword, String, Keyword)),
|
| 124 |
+
(r'^(\w+)( subclass: )(#\w+)'
|
| 125 |
+
r'(\s+instanceVariableNames: )(.*?)'
|
| 126 |
+
r'(\s+classVariableNames: )(.*?)'
|
| 127 |
+
r'(\s+poolDictionaries: )(.*?)'
|
| 128 |
+
r'(\s+category: )(.*?)(!)',
|
| 129 |
+
bygroups(Name.Class, Keyword, String.Symbol, Keyword, String, Keyword,
|
| 130 |
+
String, Keyword, String, Keyword, String, Keyword)),
|
| 131 |
+
(r'^(\w+(?: class)?)(\s+instanceVariableNames: )(.*?)(!)',
|
| 132 |
+
bygroups(Name.Class, Keyword, String, Keyword)),
|
| 133 |
+
(r'(!\n)(\].*)(! !)$', bygroups(Keyword, Text, Keyword)),
|
| 134 |
+
(r'! !$', Keyword),
|
| 135 |
+
],
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
class NewspeakLexer(RegexLexer):
|
| 140 |
+
"""
|
| 141 |
+
For Newspeak syntax.
|
| 142 |
+
"""
|
| 143 |
+
name = 'Newspeak'
|
| 144 |
+
url = 'http://newspeaklanguage.org/'
|
| 145 |
+
filenames = ['*.ns2']
|
| 146 |
+
aliases = ['newspeak', ]
|
| 147 |
+
mimetypes = ['text/x-newspeak']
|
| 148 |
+
version_added = '1.1'
|
| 149 |
+
|
| 150 |
+
tokens = {
|
| 151 |
+
'root': [
|
| 152 |
+
(r'\b(Newsqueak2)\b', Keyword.Declaration),
|
| 153 |
+
(r"'[^']*'", String),
|
| 154 |
+
(r'\b(class)(\s+)(\w+)(\s*)',
|
| 155 |
+
bygroups(Keyword.Declaration, Text, Name.Class, Text)),
|
| 156 |
+
(r'\b(mixin|self|super|private|public|protected|nil|true|false)\b',
|
| 157 |
+
Keyword),
|
| 158 |
+
(r'(\w+\:)(\s*)([a-zA-Z_]\w+)',
|
| 159 |
+
bygroups(Name.Function, Text, Name.Variable)),
|
| 160 |
+
(r'(\w+)(\s*)(=)',
|
| 161 |
+
bygroups(Name.Attribute, Text, Operator)),
|
| 162 |
+
(r'<\w+>', Comment.Special),
|
| 163 |
+
include('expressionstat'),
|
| 164 |
+
include('whitespace')
|
| 165 |
+
],
|
| 166 |
+
|
| 167 |
+
'expressionstat': [
|
| 168 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 169 |
+
(r'\d+', Number.Integer),
|
| 170 |
+
(r':\w+', Name.Variable),
|
| 171 |
+
(r'(\w+)(::)', bygroups(Name.Variable, Operator)),
|
| 172 |
+
(r'\w+:', Name.Function),
|
| 173 |
+
(r'\w+', Name.Variable),
|
| 174 |
+
(r'\(|\)', Punctuation),
|
| 175 |
+
(r'\[|\]', Punctuation),
|
| 176 |
+
(r'\{|\}', Punctuation),
|
| 177 |
+
|
| 178 |
+
(r'(\^|\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-|:)', Operator),
|
| 179 |
+
(r'\.|;', Punctuation),
|
| 180 |
+
include('whitespace'),
|
| 181 |
+
include('literals'),
|
| 182 |
+
],
|
| 183 |
+
'literals': [
|
| 184 |
+
(r'\$.', String),
|
| 185 |
+
(r"'[^']*'", String),
|
| 186 |
+
(r"#'[^']*'", String.Symbol),
|
| 187 |
+
(r"#\w+:?", String.Symbol),
|
| 188 |
+
(r"#(\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-)+", String.Symbol)
|
| 189 |
+
],
|
| 190 |
+
'whitespace': [
|
| 191 |
+
(r'\s+', Text),
|
| 192 |
+
(r'"[^"]*"', Comment)
|
| 193 |
+
],
|
| 194 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/smithy.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.smithy
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Smithy IDL.
|
| 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, Keyword, Name, String, \
|
| 13 |
+
Number, Whitespace, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['SmithyLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class SmithyLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Smithy IDL
|
| 21 |
+
"""
|
| 22 |
+
name = 'Smithy'
|
| 23 |
+
url = 'https://awslabs.github.io/smithy/'
|
| 24 |
+
filenames = ['*.smithy']
|
| 25 |
+
aliases = ['smithy']
|
| 26 |
+
version_added = '2.10'
|
| 27 |
+
|
| 28 |
+
unquoted = r'[A-Za-z0-9_\.#$-]+'
|
| 29 |
+
identifier = r"[A-Za-z0-9_\.#$-]+"
|
| 30 |
+
|
| 31 |
+
simple_shapes = (
|
| 32 |
+
'use', 'byte', 'short', 'integer', 'long', 'float', 'document',
|
| 33 |
+
'double', 'bigInteger', 'bigDecimal', 'boolean', 'blob', 'string',
|
| 34 |
+
'timestamp',
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
aggregate_shapes = (
|
| 38 |
+
'apply', 'list', 'map', 'set', 'structure', 'union', 'resource',
|
| 39 |
+
'operation', 'service', 'trait'
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
tokens = {
|
| 43 |
+
'root': [
|
| 44 |
+
(r'///.*$', Comment.Multiline),
|
| 45 |
+
(r'//.*$', Comment),
|
| 46 |
+
(r'@[0-9a-zA-Z\.#-]*', Name.Decorator),
|
| 47 |
+
(r'(=)', Name.Decorator),
|
| 48 |
+
(r'^(\$version)(:)(.+)',
|
| 49 |
+
bygroups(Keyword.Declaration, Name.Decorator, Name.Class)),
|
| 50 |
+
(r'^(namespace)(\s+' + identifier + r')\b',
|
| 51 |
+
bygroups(Keyword.Declaration, Name.Class)),
|
| 52 |
+
(words(simple_shapes,
|
| 53 |
+
prefix=r'^', suffix=r'(\s+' + identifier + r')\b'),
|
| 54 |
+
bygroups(Keyword.Declaration, Name.Class)),
|
| 55 |
+
(words(aggregate_shapes,
|
| 56 |
+
prefix=r'^', suffix=r'(\s+' + identifier + r')'),
|
| 57 |
+
bygroups(Keyword.Declaration, Name.Class)),
|
| 58 |
+
(r'^(metadata)(\s+)((?:\S+)|(?:\"[^"]+\"))(\s*)(=)',
|
| 59 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Class,
|
| 60 |
+
Whitespace, Name.Decorator)),
|
| 61 |
+
(r"(true|false|null)", Keyword.Constant),
|
| 62 |
+
(r"(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)", Number),
|
| 63 |
+
(identifier + ":", Name.Label),
|
| 64 |
+
(identifier, Name.Variable.Class),
|
| 65 |
+
(r'\[', Text, "#push"),
|
| 66 |
+
(r'\]', Text, "#pop"),
|
| 67 |
+
(r'\(', Text, "#push"),
|
| 68 |
+
(r'\)', Text, "#pop"),
|
| 69 |
+
(r'\{', Text, "#push"),
|
| 70 |
+
(r'\}', Text, "#pop"),
|
| 71 |
+
(r'"{3}(\\\\|\n|\\")*"{3}', String.Doc),
|
| 72 |
+
(r'"(\\\\|\n|\\"|[^"])*"', String.Double),
|
| 73 |
+
(r"'(\\\\|\n|\\'|[^'])*'", String.Single),
|
| 74 |
+
(r'[:,]+', Punctuation),
|
| 75 |
+
(r'\s+', Whitespace),
|
| 76 |
+
]
|
| 77 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/smv.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.smv
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the SMV 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, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, Text
|
| 14 |
+
|
| 15 |
+
__all__ = ['NuSMVLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class NuSMVLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for the NuSMV language.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'NuSMV'
|
| 24 |
+
aliases = ['nusmv']
|
| 25 |
+
filenames = ['*.smv']
|
| 26 |
+
mimetypes = []
|
| 27 |
+
url = 'https://nusmv.fbk.eu'
|
| 28 |
+
version_added = '2.2'
|
| 29 |
+
|
| 30 |
+
tokens = {
|
| 31 |
+
'root': [
|
| 32 |
+
# Comments
|
| 33 |
+
(r'(?s)\/\-\-.*?\-\-/', Comment),
|
| 34 |
+
(r'--.*\n', Comment),
|
| 35 |
+
|
| 36 |
+
# Reserved
|
| 37 |
+
(words(('MODULE', 'DEFINE', 'MDEFINE', 'CONSTANTS', 'VAR', 'IVAR',
|
| 38 |
+
'FROZENVAR', 'INIT', 'TRANS', 'INVAR', 'SPEC', 'CTLSPEC',
|
| 39 |
+
'LTLSPEC', 'PSLSPEC', 'COMPUTE', 'NAME', 'INVARSPEC',
|
| 40 |
+
'FAIRNESS', 'JUSTICE', 'COMPASSION', 'ISA', 'ASSIGN',
|
| 41 |
+
'CONSTRAINT', 'SIMPWFF', 'CTLWFF', 'LTLWFF', 'PSLWFF',
|
| 42 |
+
'COMPWFF', 'IN', 'MIN', 'MAX', 'MIRROR', 'PRED',
|
| 43 |
+
'PREDICATES'), suffix=r'(?![\w$#-])'),
|
| 44 |
+
Keyword.Declaration),
|
| 45 |
+
(r'process(?![\w$#-])', Keyword),
|
| 46 |
+
(words(('array', 'of', 'boolean', 'integer', 'real', 'word'),
|
| 47 |
+
suffix=r'(?![\w$#-])'), Keyword.Type),
|
| 48 |
+
(words(('case', 'esac'), suffix=r'(?![\w$#-])'), Keyword),
|
| 49 |
+
(words(('word1', 'bool', 'signed', 'unsigned', 'extend', 'resize',
|
| 50 |
+
'sizeof', 'uwconst', 'swconst', 'init', 'self', 'count',
|
| 51 |
+
'abs', 'max', 'min'), suffix=r'(?![\w$#-])'),
|
| 52 |
+
Name.Builtin),
|
| 53 |
+
(words(('EX', 'AX', 'EF', 'AF', 'EG', 'AG', 'E', 'F', 'O', 'G',
|
| 54 |
+
'H', 'X', 'Y', 'Z', 'A', 'U', 'S', 'V', 'T', 'BU', 'EBF',
|
| 55 |
+
'ABF', 'EBG', 'ABG', 'next', 'mod', 'union', 'in', 'xor',
|
| 56 |
+
'xnor'), suffix=r'(?![\w$#-])'),
|
| 57 |
+
Operator.Word),
|
| 58 |
+
(words(('TRUE', 'FALSE'), suffix=r'(?![\w$#-])'), Keyword.Constant),
|
| 59 |
+
|
| 60 |
+
# Names
|
| 61 |
+
(r'[a-zA-Z_][\w$#-]*', Name.Variable),
|
| 62 |
+
|
| 63 |
+
# Operators
|
| 64 |
+
(r':=', Operator),
|
| 65 |
+
(r'[-&|+*/<>!=]', Operator),
|
| 66 |
+
|
| 67 |
+
# Literals
|
| 68 |
+
(r'\-?\d+\b', Number.Integer),
|
| 69 |
+
(r'0[su][bB]\d*_[01_]+', Number.Bin),
|
| 70 |
+
(r'0[su][oO]\d*_[0-7_]+', Number.Oct),
|
| 71 |
+
(r'0[su][dD]\d*_[\d_]+', Number.Decimal),
|
| 72 |
+
(r'0[su][hH]\d*_[\da-fA-F_]+', Number.Hex),
|
| 73 |
+
|
| 74 |
+
# Whitespace, punctuation and the rest
|
| 75 |
+
(r'\s+', Text.Whitespace),
|
| 76 |
+
(r'[()\[\]{};?:.,]', Punctuation),
|
| 77 |
+
],
|
| 78 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/snobol.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.snobol
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the SNOBOL 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
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['SnobolLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class SnobolLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
Lexer for the SNOBOL4 programming language.
|
| 21 |
+
|
| 22 |
+
Recognizes the common ASCII equivalents of the original SNOBOL4 operators.
|
| 23 |
+
Does not require spaces around binary operators.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = "Snobol"
|
| 27 |
+
aliases = ["snobol"]
|
| 28 |
+
filenames = ['*.snobol']
|
| 29 |
+
mimetypes = ['text/x-snobol']
|
| 30 |
+
url = 'https://www.regressive.org/snobol4'
|
| 31 |
+
version_added = '1.5'
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
# root state, start of line
|
| 35 |
+
# comments, continuation lines, and directives start in column 1
|
| 36 |
+
# as do labels
|
| 37 |
+
'root': [
|
| 38 |
+
(r'\*.*\n', Comment),
|
| 39 |
+
(r'[+.] ', Punctuation, 'statement'),
|
| 40 |
+
(r'-.*\n', Comment),
|
| 41 |
+
(r'END\s*\n', Name.Label, 'heredoc'),
|
| 42 |
+
(r'[A-Za-z$][\w$]*', Name.Label, 'statement'),
|
| 43 |
+
(r'\s+', Text, 'statement'),
|
| 44 |
+
],
|
| 45 |
+
# statement state, line after continuation or label
|
| 46 |
+
'statement': [
|
| 47 |
+
(r'\s*\n', Text, '#pop'),
|
| 48 |
+
(r'\s+', Text),
|
| 49 |
+
(r'(?<=[^\w.])(LT|LE|EQ|NE|GE|GT|INTEGER|IDENT|DIFFER|LGT|SIZE|'
|
| 50 |
+
r'REPLACE|TRIM|DUPL|REMDR|DATE|TIME|EVAL|APPLY|OPSYN|LOAD|UNLOAD|'
|
| 51 |
+
r'LEN|SPAN|BREAK|ANY|NOTANY|TAB|RTAB|REM|POS|RPOS|FAIL|FENCE|'
|
| 52 |
+
r'ABORT|ARB|ARBNO|BAL|SUCCEED|INPUT|OUTPUT|TERMINAL)(?=[^\w.])',
|
| 53 |
+
Name.Builtin),
|
| 54 |
+
(r'[A-Za-z][\w.]*', Name),
|
| 55 |
+
# ASCII equivalents of original operators
|
| 56 |
+
# | for the EBCDIC equivalent, ! likewise
|
| 57 |
+
# \ for EBCDIC negation
|
| 58 |
+
(r'\*\*|[?$.!%*/#+\-@|&\\=]', Operator),
|
| 59 |
+
(r'"[^"]*"', String),
|
| 60 |
+
(r"'[^']*'", String),
|
| 61 |
+
# Accept SPITBOL syntax for real numbers
|
| 62 |
+
# as well as Macro SNOBOL4
|
| 63 |
+
(r'[0-9]+(?=[^.EeDd])', Number.Integer),
|
| 64 |
+
(r'[0-9]+(\.[0-9]*)?([EDed][-+]?[0-9]+)?', Number.Float),
|
| 65 |
+
# Goto
|
| 66 |
+
(r':', Punctuation, 'goto'),
|
| 67 |
+
(r'[()<>,;]', Punctuation),
|
| 68 |
+
],
|
| 69 |
+
# Goto block
|
| 70 |
+
'goto': [
|
| 71 |
+
(r'\s*\n', Text, "#pop:2"),
|
| 72 |
+
(r'\s+', Text),
|
| 73 |
+
(r'F|S', Keyword),
|
| 74 |
+
(r'(\()([A-Za-z][\w.]*)(\))',
|
| 75 |
+
bygroups(Punctuation, Name.Label, Punctuation))
|
| 76 |
+
],
|
| 77 |
+
# everything after the END statement is basically one
|
| 78 |
+
# big heredoc.
|
| 79 |
+
'heredoc': [
|
| 80 |
+
(r'.*\n', String.Heredoc)
|
| 81 |
+
]
|
| 82 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/solidity.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.solidity
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Solidity.
|
| 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, words
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['SolidityLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class SolidityLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Solidity source code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'Solidity'
|
| 24 |
+
aliases = ['solidity']
|
| 25 |
+
filenames = ['*.sol']
|
| 26 |
+
mimetypes = []
|
| 27 |
+
url = 'https://soliditylang.org'
|
| 28 |
+
version_added = '2.5'
|
| 29 |
+
|
| 30 |
+
datatype = (
|
| 31 |
+
r'\b(address|bool|(?:(?:bytes|hash|int|string|uint)(?:8|16|24|32|40|48|56|64'
|
| 32 |
+
r'|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208'
|
| 33 |
+
r'|216|224|232|240|248|256)?))\b'
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
tokens = {
|
| 37 |
+
'root': [
|
| 38 |
+
include('whitespace'),
|
| 39 |
+
include('comments'),
|
| 40 |
+
(r'\bpragma\s+solidity\b', Keyword, 'pragma'),
|
| 41 |
+
(r'\b(contract)(\s+)([a-zA-Z_]\w*)',
|
| 42 |
+
bygroups(Keyword, Whitespace, Name.Entity)),
|
| 43 |
+
(datatype + r'(\s+)((?:external|public|internal|private)\s+)?' +
|
| 44 |
+
r'([a-zA-Z_]\w*)',
|
| 45 |
+
bygroups(Keyword.Type, Whitespace, Keyword, Name.Variable)),
|
| 46 |
+
(r'\b(enum|event|function|struct)(\s+)([a-zA-Z_]\w*)',
|
| 47 |
+
bygroups(Keyword.Type, Whitespace, Name.Variable)),
|
| 48 |
+
(r'\b(msg|block|tx)\.([A-Za-z_][a-zA-Z0-9_]*)\b', Keyword),
|
| 49 |
+
(words((
|
| 50 |
+
'block', 'break', 'constant', 'constructor', 'continue',
|
| 51 |
+
'contract', 'do', 'else', 'external', 'false', 'for',
|
| 52 |
+
'function', 'if', 'import', 'inherited', 'internal', 'is',
|
| 53 |
+
'library', 'mapping', 'memory', 'modifier', 'msg', 'new',
|
| 54 |
+
'payable', 'private', 'public', 'require', 'return',
|
| 55 |
+
'returns', 'struct', 'suicide', 'throw', 'this', 'true',
|
| 56 |
+
'tx', 'var', 'while'), prefix=r'\b', suffix=r'\b'),
|
| 57 |
+
Keyword.Type),
|
| 58 |
+
(words(('keccak256',), prefix=r'\b', suffix=r'\b'), Name.Builtin),
|
| 59 |
+
(datatype, Keyword.Type),
|
| 60 |
+
include('constants'),
|
| 61 |
+
(r'[a-zA-Z_]\w*', Text),
|
| 62 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 63 |
+
(r'[.;{}(),\[\]]', Punctuation)
|
| 64 |
+
],
|
| 65 |
+
'comments': [
|
| 66 |
+
(r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single),
|
| 67 |
+
(r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline),
|
| 68 |
+
(r'/(\\\n)?[*][\w\W]*', Comment.Multiline)
|
| 69 |
+
],
|
| 70 |
+
'constants': [
|
| 71 |
+
(r'("(\\"|.)*?")', String.Double),
|
| 72 |
+
(r"('(\\'|.)*?')", String.Single),
|
| 73 |
+
(r'\b0[xX][0-9a-fA-F]+\b', Number.Hex),
|
| 74 |
+
(r'\b\d+\b', Number.Decimal),
|
| 75 |
+
],
|
| 76 |
+
'pragma': [
|
| 77 |
+
include('whitespace'),
|
| 78 |
+
include('comments'),
|
| 79 |
+
(r'(\^|>=|<)(\s*)(\d+\.\d+\.\d+)',
|
| 80 |
+
bygroups(Operator, Whitespace, Keyword)),
|
| 81 |
+
(r';', Punctuation, '#pop')
|
| 82 |
+
],
|
| 83 |
+
'whitespace': [
|
| 84 |
+
(r'\s+', Whitespace),
|
| 85 |
+
(r'\n', Whitespace)
|
| 86 |
+
]
|
| 87 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/soong.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.soong
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Soong (Android.bp Blueprint) files.
|
| 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
|
| 12 |
+
from pygments.token import Comment, Name, Number, Operator, Punctuation, \
|
| 13 |
+
String, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['SoongLexer']
|
| 16 |
+
|
| 17 |
+
class SoongLexer(RegexLexer):
|
| 18 |
+
name = 'Soong'
|
| 19 |
+
version_added = '2.18'
|
| 20 |
+
url = 'https://source.android.com/docs/setup/reference/androidbp'
|
| 21 |
+
aliases = ['androidbp', 'bp', 'soong']
|
| 22 |
+
filenames = ['Android.bp']
|
| 23 |
+
|
| 24 |
+
tokens = {
|
| 25 |
+
'root': [
|
| 26 |
+
# A variable assignment
|
| 27 |
+
(r'(\w*)(\s*)(\+?=)(\s*)',
|
| 28 |
+
bygroups(Name.Variable, Whitespace, Operator, Whitespace),
|
| 29 |
+
'assign-rhs'),
|
| 30 |
+
|
| 31 |
+
# A top-level module
|
| 32 |
+
(r'(\w*)(\s*)(\{)',
|
| 33 |
+
bygroups(Name.Function, Whitespace, Punctuation),
|
| 34 |
+
'in-rule'),
|
| 35 |
+
|
| 36 |
+
# Everything else
|
| 37 |
+
include('comments'),
|
| 38 |
+
(r'\s+', Whitespace), # newlines okay
|
| 39 |
+
],
|
| 40 |
+
'assign-rhs': [
|
| 41 |
+
include('expr'),
|
| 42 |
+
(r'\n', Whitespace, '#pop'),
|
| 43 |
+
],
|
| 44 |
+
'in-list': [
|
| 45 |
+
include('expr'),
|
| 46 |
+
include('comments'),
|
| 47 |
+
(r'\s+', Whitespace), # newlines okay in a list
|
| 48 |
+
(r',', Punctuation),
|
| 49 |
+
(r'\]', Punctuation, '#pop'),
|
| 50 |
+
],
|
| 51 |
+
'in-map': [
|
| 52 |
+
# A map key
|
| 53 |
+
(r'(\w+)(:)(\s*)', bygroups(Name, Punctuation, Whitespace)),
|
| 54 |
+
|
| 55 |
+
include('expr'),
|
| 56 |
+
include('comments'),
|
| 57 |
+
(r'\s+', Whitespace), # newlines okay in a map
|
| 58 |
+
(r',', Punctuation),
|
| 59 |
+
(r'\}', Punctuation, '#pop'),
|
| 60 |
+
],
|
| 61 |
+
'in-rule': [
|
| 62 |
+
# Just re-use map syntax
|
| 63 |
+
include('in-map'),
|
| 64 |
+
],
|
| 65 |
+
'comments': [
|
| 66 |
+
(r'//.*', Comment.Single),
|
| 67 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 68 |
+
],
|
| 69 |
+
'expr': [
|
| 70 |
+
(r'(true|false)\b', Name.Builtin),
|
| 71 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 72 |
+
(r'\d+', Number.Integer),
|
| 73 |
+
(r'".*?"', String),
|
| 74 |
+
(r'\{', Punctuation, 'in-map'),
|
| 75 |
+
(r'\[', Punctuation, 'in-list'),
|
| 76 |
+
(r'\w+', Name),
|
| 77 |
+
],
|
| 78 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/sophia.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.sophia
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Sophia.
|
| 6 |
+
|
| 7 |
+
Derived from pygments/lexers/reason.py.
|
| 8 |
+
|
| 9 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 10 |
+
:license: BSD, see LICENSE for details.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, default, words
|
| 14 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 15 |
+
Punctuation, String, Text
|
| 16 |
+
|
| 17 |
+
__all__ = ['SophiaLexer']
|
| 18 |
+
|
| 19 |
+
class SophiaLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
A Sophia lexer.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
name = 'Sophia'
|
| 25 |
+
aliases = ['sophia']
|
| 26 |
+
filenames = ['*.aes']
|
| 27 |
+
mimetypes = []
|
| 28 |
+
url = 'https://docs.aeternity.com/aesophia'
|
| 29 |
+
version_added = '2.11'
|
| 30 |
+
|
| 31 |
+
keywords = (
|
| 32 |
+
'contract', 'include', 'let', 'switch', 'type', 'record', 'datatype',
|
| 33 |
+
'if', 'elif', 'else', 'function', 'stateful', 'payable', 'public',
|
| 34 |
+
'entrypoint', 'private', 'indexed', 'namespace', 'interface', 'main',
|
| 35 |
+
'using', 'as', 'for', 'hiding',
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
builtins = ('state', 'put', 'abort', 'require')
|
| 39 |
+
|
| 40 |
+
word_operators = ('mod', 'band', 'bor', 'bxor', 'bnot')
|
| 41 |
+
|
| 42 |
+
primitive_types = ('int', 'address', 'bool', 'bits', 'bytes', 'string',
|
| 43 |
+
'list', 'option', 'char', 'unit', 'map', 'event',
|
| 44 |
+
'hash', 'signature', 'oracle', 'oracle_query')
|
| 45 |
+
|
| 46 |
+
tokens = {
|
| 47 |
+
'escape-sequence': [
|
| 48 |
+
(r'\\[\\"\'ntbr]', String.Escape),
|
| 49 |
+
(r'\\[0-9]{3}', String.Escape),
|
| 50 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 51 |
+
],
|
| 52 |
+
'root': [
|
| 53 |
+
(r'\s+', Text.Whitespace),
|
| 54 |
+
(r'(true|false)\b', Keyword.Constant),
|
| 55 |
+
(r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Class, 'dotted'),
|
| 56 |
+
(r'\b([A-Z][\w\']*)', Name.Function),
|
| 57 |
+
(r'//.*?\n', Comment.Single),
|
| 58 |
+
(r'\/\*(?!/)', Comment.Multiline, 'comment'),
|
| 59 |
+
|
| 60 |
+
(r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
|
| 61 |
+
(r'#[\da-fA-F][\da-fA-F_]*', Name.Label),
|
| 62 |
+
(r'\d[\d_]*', Number.Integer),
|
| 63 |
+
|
| 64 |
+
(words(keywords, suffix=r'\b'), Keyword),
|
| 65 |
+
(words(builtins, suffix=r'\b'), Name.Builtin),
|
| 66 |
+
(words(word_operators, prefix=r'\b', suffix=r'\b'), Operator.Word),
|
| 67 |
+
(words(primitive_types, prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
| 68 |
+
|
| 69 |
+
(r'[=!<>+\\*/:&|?~@^-]', Operator.Word),
|
| 70 |
+
(r'[.;:{}(),\[\]]', Punctuation),
|
| 71 |
+
|
| 72 |
+
(r"(ak_|ok_|oq_|ct_)[\w']*", Name.Label),
|
| 73 |
+
(r"[^\W\d][\w']*", Name),
|
| 74 |
+
|
| 75 |
+
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
|
| 76 |
+
String.Char),
|
| 77 |
+
(r"'.'", String.Char),
|
| 78 |
+
(r"'[a-z][\w]*", Name.Variable),
|
| 79 |
+
|
| 80 |
+
(r'"', String.Double, 'string')
|
| 81 |
+
],
|
| 82 |
+
'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.Double),
|
| 90 |
+
include('escape-sequence'),
|
| 91 |
+
(r'\\\n', String.Double),
|
| 92 |
+
(r'"', String.Double, '#pop'),
|
| 93 |
+
],
|
| 94 |
+
'dotted': [
|
| 95 |
+
(r'\s+', Text),
|
| 96 |
+
(r'\.', Punctuation),
|
| 97 |
+
(r'[A-Z][\w\']*(?=\s*\.)', Name.Function),
|
| 98 |
+
(r'[A-Z][\w\']*', Name.Function, '#pop'),
|
| 99 |
+
(r'[a-z_][\w\']*', Name, '#pop'),
|
| 100 |
+
default('#pop'),
|
| 101 |
+
],
|
| 102 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/special.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.special
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Special lexers.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import ast
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import Lexer, line_re
|
| 14 |
+
from pygments.token import Token, Error, Text, Generic
|
| 15 |
+
from pygments.util import get_choice_opt
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
__all__ = ['TextLexer', 'OutputLexer', 'RawTokenLexer']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class TextLexer(Lexer):
|
| 22 |
+
"""
|
| 23 |
+
"Null" lexer, doesn't highlight anything.
|
| 24 |
+
"""
|
| 25 |
+
name = 'Text only'
|
| 26 |
+
aliases = ['text']
|
| 27 |
+
filenames = ['*.txt']
|
| 28 |
+
mimetypes = ['text/plain']
|
| 29 |
+
url = ""
|
| 30 |
+
version_added = ''
|
| 31 |
+
|
| 32 |
+
priority = 0.01
|
| 33 |
+
|
| 34 |
+
def get_tokens_unprocessed(self, text):
|
| 35 |
+
yield 0, Text, text
|
| 36 |
+
|
| 37 |
+
def analyse_text(text):
|
| 38 |
+
return TextLexer.priority
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class OutputLexer(Lexer):
|
| 42 |
+
"""
|
| 43 |
+
Simple lexer that highlights everything as ``Token.Generic.Output``.
|
| 44 |
+
"""
|
| 45 |
+
name = 'Text output'
|
| 46 |
+
aliases = ['output']
|
| 47 |
+
url = ""
|
| 48 |
+
version_added = '2.10'
|
| 49 |
+
_example = "output/output"
|
| 50 |
+
|
| 51 |
+
def get_tokens_unprocessed(self, text):
|
| 52 |
+
yield 0, Generic.Output, text
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
_ttype_cache = {}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class RawTokenLexer(Lexer):
|
| 59 |
+
"""
|
| 60 |
+
Recreate a token stream formatted with the `RawTokenFormatter`.
|
| 61 |
+
|
| 62 |
+
Additional options accepted:
|
| 63 |
+
|
| 64 |
+
`compress`
|
| 65 |
+
If set to ``"gz"`` or ``"bz2"``, decompress the token stream with
|
| 66 |
+
the given compression algorithm before lexing (default: ``""``).
|
| 67 |
+
"""
|
| 68 |
+
name = 'Raw token data'
|
| 69 |
+
aliases = []
|
| 70 |
+
filenames = []
|
| 71 |
+
mimetypes = ['application/x-pygments-tokens']
|
| 72 |
+
url = 'https://pygments.org/docs/formatters/#RawTokenFormatter'
|
| 73 |
+
version_added = ''
|
| 74 |
+
|
| 75 |
+
def __init__(self, **options):
|
| 76 |
+
self.compress = get_choice_opt(options, 'compress',
|
| 77 |
+
['', 'none', 'gz', 'bz2'], '')
|
| 78 |
+
Lexer.__init__(self, **options)
|
| 79 |
+
|
| 80 |
+
def get_tokens(self, text):
|
| 81 |
+
if self.compress:
|
| 82 |
+
if isinstance(text, str):
|
| 83 |
+
text = text.encode('latin1')
|
| 84 |
+
try:
|
| 85 |
+
if self.compress == 'gz':
|
| 86 |
+
import gzip
|
| 87 |
+
text = gzip.decompress(text)
|
| 88 |
+
elif self.compress == 'bz2':
|
| 89 |
+
import bz2
|
| 90 |
+
text = bz2.decompress(text)
|
| 91 |
+
except OSError:
|
| 92 |
+
yield Error, text.decode('latin1')
|
| 93 |
+
if isinstance(text, bytes):
|
| 94 |
+
text = text.decode('latin1')
|
| 95 |
+
|
| 96 |
+
# do not call Lexer.get_tokens() because stripping is not optional.
|
| 97 |
+
text = text.strip('\n') + '\n'
|
| 98 |
+
for i, t, v in self.get_tokens_unprocessed(text):
|
| 99 |
+
yield t, v
|
| 100 |
+
|
| 101 |
+
def get_tokens_unprocessed(self, text):
|
| 102 |
+
length = 0
|
| 103 |
+
for match in line_re.finditer(text):
|
| 104 |
+
try:
|
| 105 |
+
ttypestr, val = match.group().rstrip().split('\t', 1)
|
| 106 |
+
ttype = _ttype_cache.get(ttypestr)
|
| 107 |
+
if not ttype:
|
| 108 |
+
ttype = Token
|
| 109 |
+
ttypes = ttypestr.split('.')[1:]
|
| 110 |
+
for ttype_ in ttypes:
|
| 111 |
+
if not ttype_ or not ttype_[0].isupper():
|
| 112 |
+
raise ValueError('malformed token name')
|
| 113 |
+
ttype = getattr(ttype, ttype_)
|
| 114 |
+
_ttype_cache[ttypestr] = ttype
|
| 115 |
+
val = ast.literal_eval(val)
|
| 116 |
+
if not isinstance(val, str):
|
| 117 |
+
raise ValueError('expected str')
|
| 118 |
+
except (SyntaxError, ValueError):
|
| 119 |
+
val = match.group()
|
| 120 |
+
ttype = Error
|
| 121 |
+
yield length, ttype, val
|
| 122 |
+
length += len(val)
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/spice.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.spice
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Spice 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, bygroups, words
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['SpiceLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class SpiceLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Spice source.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Spice'
|
| 23 |
+
url = 'https://www.spicelang.com'
|
| 24 |
+
filenames = ['*.spice']
|
| 25 |
+
aliases = ['spice', 'spicelang']
|
| 26 |
+
mimetypes = ['text/x-spice']
|
| 27 |
+
version_added = '2.11'
|
| 28 |
+
|
| 29 |
+
tokens = {
|
| 30 |
+
'root': [
|
| 31 |
+
(r'\n', Whitespace),
|
| 32 |
+
(r'\s+', Whitespace),
|
| 33 |
+
(r'\\\n', Text),
|
| 34 |
+
# comments
|
| 35 |
+
(r'//(.*?)\n', Comment.Single),
|
| 36 |
+
(r'/(\\\n)?[*]{2}(.|\n)*?[*](\\\n)?/', String.Doc),
|
| 37 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 38 |
+
# keywords
|
| 39 |
+
(r'(import|as)\b', Keyword.Namespace),
|
| 40 |
+
(r'(f|p|type|struct|interface|enum|alias|operator)\b', Keyword.Declaration),
|
| 41 |
+
(words(('if', 'else', 'switch', 'case', 'default', 'for', 'foreach', 'do',
|
| 42 |
+
'while', 'break', 'continue', 'fallthrough', 'return', 'assert',
|
| 43 |
+
'unsafe', 'ext', 'cast'), suffix=r'\b'), Keyword),
|
| 44 |
+
(words(('const', 'signed', 'unsigned', 'inline', 'public', 'heap', 'compose'),
|
| 45 |
+
suffix=r'\b'), Keyword.Pseudo),
|
| 46 |
+
(words(('new', 'yield', 'stash', 'pick', 'sync', 'class'), suffix=r'\b'),
|
| 47 |
+
Keyword.Reserved),
|
| 48 |
+
(r'(true|false|nil)\b', Keyword.Constant),
|
| 49 |
+
(words(('double', 'int', 'short', 'long', 'byte', 'char', 'string',
|
| 50 |
+
'bool', 'dyn'), suffix=r'\b'), Keyword.Type),
|
| 51 |
+
(words(('printf', 'sizeof', 'alignof', 'len', 'panic'), suffix=r'\b(\()'),
|
| 52 |
+
bygroups(Name.Builtin, Punctuation)),
|
| 53 |
+
# numeric literals
|
| 54 |
+
(r'[-]?[0-9]*[.][0-9]+([eE][+-]?[0-9]+)?', Number.Double),
|
| 55 |
+
(r'0[bB][01]+[slu]?', Number.Bin),
|
| 56 |
+
(r'0[oO][0-7]+[slu]?', Number.Oct),
|
| 57 |
+
(r'0[xXhH][0-9a-fA-F]+[slu]?', Number.Hex),
|
| 58 |
+
(r'(0[dD])?[0-9]+[slu]?', Number.Integer),
|
| 59 |
+
# string literal
|
| 60 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 61 |
+
# char literal
|
| 62 |
+
(r'\'(\\\\|\\[^\\]|[^\'\\])\'', String.Char),
|
| 63 |
+
# tokens
|
| 64 |
+
(r'<<=|>>=|<<|>>|<=|>=|\+=|-=|\*=|/=|\%=|\|=|&=|\^=|&&|\|\||&|\||'
|
| 65 |
+
r'\+\+|--|\%|\^|\~|==|!=|->|::|[.]{3}|#!|#|[+\-*/&]', Operator),
|
| 66 |
+
(r'[|<>=!()\[\]{}.,;:\?]', Punctuation),
|
| 67 |
+
# identifiers
|
| 68 |
+
(r'[^\W\d]\w*', Name.Other),
|
| 69 |
+
]
|
| 70 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/sql.py
ADDED
|
@@ -0,0 +1,1111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.sql
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for various SQL dialects and related interactive sessions.
|
| 6 |
+
|
| 7 |
+
Postgres specific lexers:
|
| 8 |
+
|
| 9 |
+
`PostgresLexer`
|
| 10 |
+
A SQL lexer for the PostgreSQL dialect. Differences w.r.t. the SQL
|
| 11 |
+
lexer are:
|
| 12 |
+
|
| 13 |
+
- keywords and data types list parsed from the PG docs (run the
|
| 14 |
+
`_postgres_builtins` module to update them);
|
| 15 |
+
- Content of $-strings parsed using a specific lexer, e.g. the content
|
| 16 |
+
of a PL/Python function is parsed using the Python lexer;
|
| 17 |
+
- parse PG specific constructs: E-strings, $-strings, U&-strings,
|
| 18 |
+
different operators and punctuation.
|
| 19 |
+
|
| 20 |
+
`PlPgsqlLexer`
|
| 21 |
+
A lexer for the PL/pgSQL language. Adds a few specific construct on
|
| 22 |
+
top of the PG SQL lexer (such as <<label>>).
|
| 23 |
+
|
| 24 |
+
`PostgresConsoleLexer`
|
| 25 |
+
A lexer to highlight an interactive psql session:
|
| 26 |
+
|
| 27 |
+
- identifies the prompt and does its best to detect the end of command
|
| 28 |
+
in multiline statement where not all the lines are prefixed by a
|
| 29 |
+
prompt, telling them apart from the output;
|
| 30 |
+
- highlights errors in the output and notification levels;
|
| 31 |
+
- handles psql backslash commands.
|
| 32 |
+
|
| 33 |
+
`PostgresExplainLexer`
|
| 34 |
+
A lexer to highlight Postgres execution plan.
|
| 35 |
+
|
| 36 |
+
The ``tests/examplefiles`` contains a few test files with data to be
|
| 37 |
+
parsed by these lexers.
|
| 38 |
+
|
| 39 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 40 |
+
:license: BSD, see LICENSE for details.
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
import collections
|
| 44 |
+
import re
|
| 45 |
+
|
| 46 |
+
from pygments.lexer import Lexer, RegexLexer, do_insertions, bygroups, words
|
| 47 |
+
from pygments.lexers import _googlesql_builtins
|
| 48 |
+
from pygments.lexers import _mysql_builtins
|
| 49 |
+
from pygments.lexers import _postgres_builtins
|
| 50 |
+
from pygments.lexers import _sql_builtins
|
| 51 |
+
from pygments.lexers import _tsql_builtins
|
| 52 |
+
from pygments.lexers import get_lexer_by_name, ClassNotFound
|
| 53 |
+
from pygments.token import Punctuation, Whitespace, Text, Comment, Operator, \
|
| 54 |
+
Keyword, Name, String, Number, Generic, Literal
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
__all__ = ['GoogleSqlLexer', 'PostgresLexer', 'PlPgsqlLexer',
|
| 58 |
+
'PostgresConsoleLexer', 'PostgresExplainLexer', 'SqlLexer',
|
| 59 |
+
'TransactSqlLexer', 'MySqlLexer', 'SqliteConsoleLexer', 'RqlLexer']
|
| 60 |
+
|
| 61 |
+
line_re = re.compile('.*?\n')
|
| 62 |
+
sqlite_prompt_re = re.compile(r'^(?:sqlite| ...)>(?= )')
|
| 63 |
+
|
| 64 |
+
language_re = re.compile(r"\s+LANGUAGE\s+'?(\w+)'?", re.IGNORECASE)
|
| 65 |
+
|
| 66 |
+
do_re = re.compile(r'\bDO\b', re.IGNORECASE)
|
| 67 |
+
|
| 68 |
+
# Regular expressions for analyse_text()
|
| 69 |
+
name_between_bracket_re = re.compile(r'\[[a-zA-Z_]\w*\]')
|
| 70 |
+
name_between_backtick_re = re.compile(r'`[a-zA-Z_]\w*`')
|
| 71 |
+
tsql_go_re = re.compile(r'\bgo\b', re.IGNORECASE)
|
| 72 |
+
tsql_declare_re = re.compile(r'\bdeclare\s+@', re.IGNORECASE)
|
| 73 |
+
tsql_variable_re = re.compile(r'@[a-zA-Z_]\w*\b')
|
| 74 |
+
|
| 75 |
+
# Identifiers for analyse_text()
|
| 76 |
+
googlesql_identifiers = (
|
| 77 |
+
_googlesql_builtins.functionnames
|
| 78 |
+
+ _googlesql_builtins.keywords
|
| 79 |
+
+ _googlesql_builtins.types)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def language_callback(lexer, match):
|
| 83 |
+
"""Parse the content of a $-string using a lexer
|
| 84 |
+
|
| 85 |
+
The lexer is chosen looking for a nearby LANGUAGE or assumed as
|
| 86 |
+
plpgsql if inside a DO statement and no LANGUAGE has been found.
|
| 87 |
+
"""
|
| 88 |
+
lx = None
|
| 89 |
+
m = language_re.match(lexer.text[match.end():match.end()+100])
|
| 90 |
+
if m is not None:
|
| 91 |
+
lx = lexer._get_lexer(m.group(1))
|
| 92 |
+
else:
|
| 93 |
+
m = list(language_re.finditer(
|
| 94 |
+
lexer.text[max(0, match.start()-100):match.start()]))
|
| 95 |
+
if m:
|
| 96 |
+
lx = lexer._get_lexer(m[-1].group(1))
|
| 97 |
+
else:
|
| 98 |
+
m = list(do_re.finditer(
|
| 99 |
+
lexer.text[max(0, match.start()-25):match.start()]))
|
| 100 |
+
if m:
|
| 101 |
+
lx = lexer._get_lexer('plpgsql')
|
| 102 |
+
|
| 103 |
+
# 1 = $, 2 = delimiter, 3 = $
|
| 104 |
+
yield (match.start(1), String, match.group(1))
|
| 105 |
+
yield (match.start(2), String.Delimiter, match.group(2))
|
| 106 |
+
yield (match.start(3), String, match.group(3))
|
| 107 |
+
# 4 = string contents
|
| 108 |
+
if lx:
|
| 109 |
+
yield from lx.get_tokens_unprocessed(match.group(4))
|
| 110 |
+
else:
|
| 111 |
+
yield (match.start(4), String, match.group(4))
|
| 112 |
+
# 5 = $, 6 = delimiter, 7 = $
|
| 113 |
+
yield (match.start(5), String, match.group(5))
|
| 114 |
+
yield (match.start(6), String.Delimiter, match.group(6))
|
| 115 |
+
yield (match.start(7), String, match.group(7))
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
class PostgresBase:
|
| 119 |
+
"""Base class for Postgres-related lexers.
|
| 120 |
+
|
| 121 |
+
This is implemented as a mixin to avoid the Lexer metaclass kicking in.
|
| 122 |
+
this way the different lexer don't have a common Lexer ancestor. If they
|
| 123 |
+
had, _tokens could be created on this ancestor and not updated for the
|
| 124 |
+
other classes, resulting e.g. in PL/pgSQL parsed as SQL. This shortcoming
|
| 125 |
+
seem to suggest that regexp lexers are not really subclassable.
|
| 126 |
+
"""
|
| 127 |
+
def get_tokens_unprocessed(self, text, *args):
|
| 128 |
+
# Have a copy of the entire text to be used by `language_callback`.
|
| 129 |
+
self.text = text
|
| 130 |
+
yield from super().get_tokens_unprocessed(text, *args)
|
| 131 |
+
|
| 132 |
+
def _get_lexer(self, lang):
|
| 133 |
+
if lang.lower() == 'sql':
|
| 134 |
+
return get_lexer_by_name('postgresql', **self.options)
|
| 135 |
+
|
| 136 |
+
tries = [lang]
|
| 137 |
+
if lang.startswith('pl'):
|
| 138 |
+
tries.append(lang[2:])
|
| 139 |
+
if lang.endswith('u'):
|
| 140 |
+
tries.append(lang[:-1])
|
| 141 |
+
if lang.startswith('pl') and lang.endswith('u'):
|
| 142 |
+
tries.append(lang[2:-1])
|
| 143 |
+
|
| 144 |
+
for lx in tries:
|
| 145 |
+
try:
|
| 146 |
+
return get_lexer_by_name(lx, **self.options)
|
| 147 |
+
except ClassNotFound:
|
| 148 |
+
pass
|
| 149 |
+
else:
|
| 150 |
+
# TODO: better logging
|
| 151 |
+
# print >>sys.stderr, "language not found:", lang
|
| 152 |
+
return None
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
class PostgresLexer(PostgresBase, RegexLexer):
|
| 156 |
+
"""
|
| 157 |
+
Lexer for the PostgreSQL dialect of SQL.
|
| 158 |
+
"""
|
| 159 |
+
|
| 160 |
+
name = 'PostgreSQL SQL dialect'
|
| 161 |
+
aliases = ['postgresql', 'postgres']
|
| 162 |
+
mimetypes = ['text/x-postgresql']
|
| 163 |
+
url = 'https://www.postgresql.org'
|
| 164 |
+
version_added = '1.5'
|
| 165 |
+
|
| 166 |
+
flags = re.IGNORECASE
|
| 167 |
+
tokens = {
|
| 168 |
+
'root': [
|
| 169 |
+
(r'\s+', Whitespace),
|
| 170 |
+
(r'--.*\n?', Comment.Single),
|
| 171 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 172 |
+
(r'(' + '|'.join(s.replace(" ", r"\s+")
|
| 173 |
+
for s in _postgres_builtins.DATATYPES +
|
| 174 |
+
_postgres_builtins.PSEUDO_TYPES) + r')\b',
|
| 175 |
+
Name.Builtin),
|
| 176 |
+
(words(_postgres_builtins.KEYWORDS, suffix=r'\b'), Keyword),
|
| 177 |
+
(r'[+*/<>=~!@#%^&|`?-]+', Operator),
|
| 178 |
+
(r'::', Operator), # cast
|
| 179 |
+
(r'\$\d+', Name.Variable),
|
| 180 |
+
(r'([0-9]*\.[0-9]*|[0-9]+)(e[+-]?[0-9]+)?', Number.Float),
|
| 181 |
+
(r'[0-9]+', Number.Integer),
|
| 182 |
+
(r"((?:E|U&)?)(')", bygroups(String.Affix, String.Single), 'string'),
|
| 183 |
+
# quoted identifier
|
| 184 |
+
(r'((?:U&)?)(")', bygroups(String.Affix, String.Name), 'quoted-ident'),
|
| 185 |
+
(r'(?s)(\$)([^$]*)(\$)(.*?)(\$)(\2)(\$)', language_callback),
|
| 186 |
+
(r'[a-z_]\w*', Name),
|
| 187 |
+
|
| 188 |
+
# psql variable in SQL
|
| 189 |
+
(r""":(['"]?)[a-z]\w*\b\1""", Name.Variable),
|
| 190 |
+
|
| 191 |
+
(r'[;:()\[\]{},.]', Punctuation),
|
| 192 |
+
],
|
| 193 |
+
'multiline-comments': [
|
| 194 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 195 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 196 |
+
(r'[^/*]+', Comment.Multiline),
|
| 197 |
+
(r'[/*]', Comment.Multiline)
|
| 198 |
+
],
|
| 199 |
+
'string': [
|
| 200 |
+
(r"[^']+", String.Single),
|
| 201 |
+
(r"''", String.Single),
|
| 202 |
+
(r"'", String.Single, '#pop'),
|
| 203 |
+
],
|
| 204 |
+
'quoted-ident': [
|
| 205 |
+
(r'[^"]+', String.Name),
|
| 206 |
+
(r'""', String.Name),
|
| 207 |
+
(r'"', String.Name, '#pop'),
|
| 208 |
+
],
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
class PlPgsqlLexer(PostgresBase, RegexLexer):
|
| 213 |
+
"""
|
| 214 |
+
Handle the extra syntax in Pl/pgSQL language.
|
| 215 |
+
"""
|
| 216 |
+
name = 'PL/pgSQL'
|
| 217 |
+
aliases = ['plpgsql']
|
| 218 |
+
mimetypes = ['text/x-plpgsql']
|
| 219 |
+
url = 'https://www.postgresql.org/docs/current/plpgsql.html'
|
| 220 |
+
version_added = '1.5'
|
| 221 |
+
|
| 222 |
+
flags = re.IGNORECASE
|
| 223 |
+
# FIXME: use inheritance
|
| 224 |
+
tokens = {name: state[:] for (name, state) in PostgresLexer.tokens.items()}
|
| 225 |
+
|
| 226 |
+
# extend the keywords list
|
| 227 |
+
for i, pattern in enumerate(tokens['root']):
|
| 228 |
+
if pattern[1] == Keyword:
|
| 229 |
+
tokens['root'][i] = (
|
| 230 |
+
words(_postgres_builtins.KEYWORDS +
|
| 231 |
+
_postgres_builtins.PLPGSQL_KEYWORDS, suffix=r'\b'),
|
| 232 |
+
Keyword)
|
| 233 |
+
del i
|
| 234 |
+
break
|
| 235 |
+
else:
|
| 236 |
+
assert 0, "SQL keywords not found"
|
| 237 |
+
|
| 238 |
+
# Add specific PL/pgSQL rules (before the SQL ones)
|
| 239 |
+
tokens['root'][:0] = [
|
| 240 |
+
(r'\%[a-z]\w*\b', Name.Builtin), # actually, a datatype
|
| 241 |
+
(r':=', Operator),
|
| 242 |
+
(r'\<\<[a-z]\w*\>\>', Name.Label),
|
| 243 |
+
(r'\#[a-z]\w*\b', Keyword.Pseudo), # #variable_conflict
|
| 244 |
+
]
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
class PsqlRegexLexer(PostgresBase, RegexLexer):
|
| 248 |
+
"""
|
| 249 |
+
Extend the PostgresLexer adding support specific for psql commands.
|
| 250 |
+
|
| 251 |
+
This is not a complete psql lexer yet as it lacks prompt support
|
| 252 |
+
and output rendering.
|
| 253 |
+
"""
|
| 254 |
+
|
| 255 |
+
name = 'PostgreSQL console - regexp based lexer'
|
| 256 |
+
aliases = [] # not public
|
| 257 |
+
|
| 258 |
+
flags = re.IGNORECASE
|
| 259 |
+
tokens = {name: state[:] for (name, state) in PostgresLexer.tokens.items()}
|
| 260 |
+
|
| 261 |
+
tokens['root'].append(
|
| 262 |
+
(r'\\[^\s]+', Keyword.Pseudo, 'psql-command'))
|
| 263 |
+
tokens['psql-command'] = [
|
| 264 |
+
(r'\n', Text, 'root'),
|
| 265 |
+
(r'\s+', Whitespace),
|
| 266 |
+
(r'\\[^\s]+', Keyword.Pseudo),
|
| 267 |
+
(r""":(['"]?)[a-z]\w*\b\1""", Name.Variable),
|
| 268 |
+
(r"'(''|[^'])*'", String.Single),
|
| 269 |
+
(r"`([^`])*`", String.Backtick),
|
| 270 |
+
(r"[^\s]+", String.Symbol),
|
| 271 |
+
]
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
re_prompt = re.compile(r'^(\S.*?)??[=\-\(\$\'\"][#>]')
|
| 275 |
+
re_psql_command = re.compile(r'\s*\\')
|
| 276 |
+
re_end_command = re.compile(r';\s*(--.*?)?$')
|
| 277 |
+
re_psql_command = re.compile(r'(\s*)(\\.+?)(\s+)$')
|
| 278 |
+
re_error = re.compile(r'(ERROR|FATAL):')
|
| 279 |
+
re_message = re.compile(
|
| 280 |
+
r'((?:DEBUG|INFO|NOTICE|WARNING|ERROR|'
|
| 281 |
+
r'FATAL|HINT|DETAIL|CONTEXT|LINE [0-9]+):)(.*?\n)')
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
class lookahead:
|
| 285 |
+
"""Wrap an iterator and allow pushing back an item."""
|
| 286 |
+
def __init__(self, x):
|
| 287 |
+
self.iter = iter(x)
|
| 288 |
+
self._nextitem = None
|
| 289 |
+
|
| 290 |
+
def __iter__(self):
|
| 291 |
+
return self
|
| 292 |
+
|
| 293 |
+
def send(self, i):
|
| 294 |
+
self._nextitem = i
|
| 295 |
+
return i
|
| 296 |
+
|
| 297 |
+
def __next__(self):
|
| 298 |
+
if self._nextitem is not None:
|
| 299 |
+
ni = self._nextitem
|
| 300 |
+
self._nextitem = None
|
| 301 |
+
return ni
|
| 302 |
+
return next(self.iter)
|
| 303 |
+
next = __next__
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
class PostgresConsoleLexer(Lexer):
|
| 307 |
+
"""
|
| 308 |
+
Lexer for psql sessions.
|
| 309 |
+
"""
|
| 310 |
+
|
| 311 |
+
name = 'PostgreSQL console (psql)'
|
| 312 |
+
aliases = ['psql', 'postgresql-console', 'postgres-console']
|
| 313 |
+
mimetypes = ['text/x-postgresql-psql']
|
| 314 |
+
url = 'https://www.postgresql.org'
|
| 315 |
+
version_added = '1.5'
|
| 316 |
+
_example = "psql/psql_session.txt"
|
| 317 |
+
|
| 318 |
+
def get_tokens_unprocessed(self, data):
|
| 319 |
+
sql = PsqlRegexLexer(**self.options)
|
| 320 |
+
|
| 321 |
+
lines = lookahead(line_re.findall(data))
|
| 322 |
+
|
| 323 |
+
# prompt-output cycle
|
| 324 |
+
while 1:
|
| 325 |
+
|
| 326 |
+
# consume the lines of the command: start with an optional prompt
|
| 327 |
+
# and continue until the end of command is detected
|
| 328 |
+
curcode = ''
|
| 329 |
+
insertions = []
|
| 330 |
+
for line in lines:
|
| 331 |
+
# Identify a shell prompt in case of psql commandline example
|
| 332 |
+
if line.startswith('$') and not curcode:
|
| 333 |
+
lexer = get_lexer_by_name('console', **self.options)
|
| 334 |
+
yield from lexer.get_tokens_unprocessed(line)
|
| 335 |
+
break
|
| 336 |
+
|
| 337 |
+
# Identify a psql prompt
|
| 338 |
+
mprompt = re_prompt.match(line)
|
| 339 |
+
if mprompt is not None:
|
| 340 |
+
insertions.append((len(curcode),
|
| 341 |
+
[(0, Generic.Prompt, mprompt.group())]))
|
| 342 |
+
curcode += line[len(mprompt.group()):]
|
| 343 |
+
else:
|
| 344 |
+
curcode += line
|
| 345 |
+
|
| 346 |
+
# Check if this is the end of the command
|
| 347 |
+
# TODO: better handle multiline comments at the end with
|
| 348 |
+
# a lexer with an external state?
|
| 349 |
+
if re_psql_command.match(curcode) \
|
| 350 |
+
or re_end_command.search(curcode):
|
| 351 |
+
break
|
| 352 |
+
|
| 353 |
+
# Emit the combined stream of command and prompt(s)
|
| 354 |
+
yield from do_insertions(insertions,
|
| 355 |
+
sql.get_tokens_unprocessed(curcode))
|
| 356 |
+
|
| 357 |
+
# Emit the output lines
|
| 358 |
+
out_token = Generic.Output
|
| 359 |
+
for line in lines:
|
| 360 |
+
mprompt = re_prompt.match(line)
|
| 361 |
+
if mprompt is not None:
|
| 362 |
+
# push the line back to have it processed by the prompt
|
| 363 |
+
lines.send(line)
|
| 364 |
+
break
|
| 365 |
+
|
| 366 |
+
mmsg = re_message.match(line)
|
| 367 |
+
if mmsg is not None:
|
| 368 |
+
if mmsg.group(1).startswith("ERROR") \
|
| 369 |
+
or mmsg.group(1).startswith("FATAL"):
|
| 370 |
+
out_token = Generic.Error
|
| 371 |
+
yield (mmsg.start(1), Generic.Strong, mmsg.group(1))
|
| 372 |
+
yield (mmsg.start(2), out_token, mmsg.group(2))
|
| 373 |
+
else:
|
| 374 |
+
yield (0, out_token, line)
|
| 375 |
+
else:
|
| 376 |
+
return
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
class PostgresExplainLexer(RegexLexer):
|
| 380 |
+
"""
|
| 381 |
+
Handle PostgreSQL EXPLAIN output
|
| 382 |
+
"""
|
| 383 |
+
|
| 384 |
+
name = 'PostgreSQL EXPLAIN dialect'
|
| 385 |
+
aliases = ['postgres-explain']
|
| 386 |
+
filenames = ['*.explain']
|
| 387 |
+
mimetypes = ['text/x-postgresql-explain']
|
| 388 |
+
url = 'https://www.postgresql.org/docs/current/using-explain.html'
|
| 389 |
+
version_added = '2.15'
|
| 390 |
+
|
| 391 |
+
tokens = {
|
| 392 |
+
'root': [
|
| 393 |
+
(r'(:|\(|\)|ms|kB|->|\.\.|\,|\/|=|%)', Punctuation),
|
| 394 |
+
(r'(\s+)', Whitespace),
|
| 395 |
+
|
| 396 |
+
# This match estimated cost and effectively measured counters with ANALYZE
|
| 397 |
+
# Then, we move to instrumentation state
|
| 398 |
+
(r'(cost)(=?)', bygroups(Name.Class, Punctuation), 'instrumentation'),
|
| 399 |
+
(r'(actual)( )(=?)', bygroups(Name.Class, Whitespace, Punctuation), 'instrumentation'),
|
| 400 |
+
|
| 401 |
+
# Misc keywords
|
| 402 |
+
(words(('actual', 'Memory Usage', 'Disk Usage', 'Memory', 'Buckets',
|
| 403 |
+
'Batches', 'originally', 'row', 'rows', 'Hits', 'Misses',
|
| 404 |
+
'Evictions', 'Overflows', 'Planned Partitions', 'Estimates',
|
| 405 |
+
'capacity', 'distinct keys', 'lookups', 'hit percent',
|
| 406 |
+
'Index Searches', 'Storage', 'Disk Maximum Storage'), suffix=r'\b'),
|
| 407 |
+
Comment.Single),
|
| 408 |
+
|
| 409 |
+
(r'(hit|read|dirtied|written|write|time|calls)(=)', bygroups(Comment.Single, Operator)),
|
| 410 |
+
(r'(shared|temp|local)', Keyword.Pseudo),
|
| 411 |
+
|
| 412 |
+
# We move to sort state in order to emphasize specific keywords (especially disk access)
|
| 413 |
+
(r'(Sort Method)(: )', bygroups(Comment.Preproc, Punctuation), 'sort'),
|
| 414 |
+
|
| 415 |
+
# These keywords can be followed by an object, like a table
|
| 416 |
+
(r'(Sort Key|Group Key|Presorted Key|Hash Key)(:)( )',
|
| 417 |
+
bygroups(Comment.Preproc, Punctuation, Whitespace), 'object_name'),
|
| 418 |
+
(r'(Cache Key|Cache Mode)(:)( )', bygroups(Comment, Punctuation, Whitespace), 'object_name'),
|
| 419 |
+
|
| 420 |
+
# These keywords can be followed by a predicate
|
| 421 |
+
(words(('Join Filter', 'Subplans Removed', 'Filter', 'Merge Cond',
|
| 422 |
+
'Hash Cond', 'Index Cond', 'Recheck Cond', 'Heap Blocks',
|
| 423 |
+
'TID Cond', 'Run Condition', 'Order By', 'Function Call',
|
| 424 |
+
'Table Function Call', 'Inner Unique', 'Params Evaluated',
|
| 425 |
+
'Single Copy', 'Sampling', 'One-Time Filter', 'Output',
|
| 426 |
+
'Relations', 'Remote SQL', 'Disabled'), suffix=r'\b'),
|
| 427 |
+
Comment.Preproc, 'predicate'),
|
| 428 |
+
|
| 429 |
+
# Special keyword to handle ON CONFLICT
|
| 430 |
+
(r'Conflict ', Comment.Preproc, 'conflict'),
|
| 431 |
+
|
| 432 |
+
# Special keyword for InitPlan or SubPlan
|
| 433 |
+
(r'(InitPlan|SubPlan)( )(\d+)( )',
|
| 434 |
+
bygroups(Keyword, Whitespace, Number.Integer, Whitespace),
|
| 435 |
+
'init_plan'),
|
| 436 |
+
|
| 437 |
+
(words(('Sort Method', 'Join Filter', 'Planning time',
|
| 438 |
+
'Planning Time', 'Execution time', 'Execution Time',
|
| 439 |
+
'Workers Planned', 'Workers Launched', 'Buffers',
|
| 440 |
+
'Planning', 'Worker', 'Query Identifier', 'Time',
|
| 441 |
+
'Full-sort Groups', 'Pre-sorted Groups'), suffix=r'\b'), Comment.Preproc),
|
| 442 |
+
|
| 443 |
+
# Emphasize these keywords
|
| 444 |
+
|
| 445 |
+
(words(('Rows Removed by Join Filter', 'Rows Removed by Filter',
|
| 446 |
+
'Rows Removed by Index Recheck',
|
| 447 |
+
'Heap Fetches', 'never executed'),
|
| 448 |
+
suffix=r'\b'), Name.Exception),
|
| 449 |
+
(r'(I/O Timings)(:)( )', bygroups(Name.Exception, Punctuation, Whitespace)),
|
| 450 |
+
|
| 451 |
+
(words(_postgres_builtins.EXPLAIN_KEYWORDS, suffix=r'\b'), Keyword),
|
| 452 |
+
|
| 453 |
+
# join keywords
|
| 454 |
+
(r'((Right|Left|Full|Semi|Anti) Join)', Keyword.Type),
|
| 455 |
+
(r'(Parallel |Async |Finalize |Partial )', Comment.Preproc),
|
| 456 |
+
(r'Backward', Comment.Preproc),
|
| 457 |
+
(r'(Intersect|Except|Hash)', Comment.Preproc),
|
| 458 |
+
|
| 459 |
+
(r'(CTE)( )(\w*)?', bygroups(Comment, Whitespace, Name.Variable)),
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
# Treat "on" and "using" as a punctuation
|
| 463 |
+
(r'(on|using)', Punctuation, 'object_name'),
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
# strings
|
| 467 |
+
(r"'(''|[^'])*'", String.Single),
|
| 468 |
+
# numbers
|
| 469 |
+
(r'-?\d+\.\d+', Number.Float),
|
| 470 |
+
(r'(-?\d+)', Number.Integer),
|
| 471 |
+
|
| 472 |
+
# boolean
|
| 473 |
+
(r'(true|false)', Name.Constant),
|
| 474 |
+
# explain header
|
| 475 |
+
(r'\s*QUERY PLAN\s*\n\s*-+', Comment.Single),
|
| 476 |
+
# Settings
|
| 477 |
+
(r'(Settings)(:)( )', bygroups(Comment.Preproc, Punctuation, Whitespace), 'setting'),
|
| 478 |
+
|
| 479 |
+
# Handle JIT counters
|
| 480 |
+
(r'(JIT|Functions|Options|Timing)(:)', bygroups(Comment.Preproc, Punctuation)),
|
| 481 |
+
(r'(Inlining|Optimization|Expressions|Deforming|Generation|Emission|Total)', Keyword.Pseudo),
|
| 482 |
+
|
| 483 |
+
# Handle Triggers counters
|
| 484 |
+
(r'(Trigger)( )(\S*)(:)( )',
|
| 485 |
+
bygroups(Comment.Preproc, Whitespace, Name.Variable, Punctuation, Whitespace)),
|
| 486 |
+
|
| 487 |
+
],
|
| 488 |
+
'expression': [
|
| 489 |
+
# matches any kind of parenthesized expression
|
| 490 |
+
# the first opening paren is matched by the 'caller'
|
| 491 |
+
(r'\(', Punctuation, '#push'),
|
| 492 |
+
(r'\)', Punctuation, '#pop'),
|
| 493 |
+
(r'(never executed)', Name.Exception),
|
| 494 |
+
(r'[^)(]+', Comment),
|
| 495 |
+
],
|
| 496 |
+
'object_name': [
|
| 497 |
+
|
| 498 |
+
# This is a cost or analyze measure
|
| 499 |
+
(r'(\(cost)(=?)', bygroups(Name.Class, Punctuation), 'instrumentation'),
|
| 500 |
+
(r'(\(actual)( )(=?)', bygroups(Name.Class, Whitespace, Punctuation), 'instrumentation'),
|
| 501 |
+
|
| 502 |
+
# if object_name is parenthesized, mark opening paren as
|
| 503 |
+
# punctuation, call 'expression', and exit state
|
| 504 |
+
(r'\(', Punctuation, 'expression'),
|
| 505 |
+
(r'(on)', Punctuation),
|
| 506 |
+
# matches possibly schema-qualified table and column names
|
| 507 |
+
(r'\w+(\.\w+)*( USING \S+| \w+ USING \S+)', Name.Variable),
|
| 508 |
+
(r'\"?\w+\"?(?:\.\"?\w+\"?)?', Name.Variable),
|
| 509 |
+
(r'\'\S*\'', Name.Variable),
|
| 510 |
+
|
| 511 |
+
# if we encounter a comma, another object is listed
|
| 512 |
+
(r',\n', Punctuation, 'object_name'),
|
| 513 |
+
(r',', Punctuation, 'object_name'),
|
| 514 |
+
|
| 515 |
+
# special case: "*SELECT*"
|
| 516 |
+
(r'"\*SELECT\*( \d+)?"(.\w+)?', Name.Variable),
|
| 517 |
+
(r'"\*VALUES\*(_\d+)?"(.\w+)?', Name.Variable),
|
| 518 |
+
(r'"ANY_subquery"', Name.Variable),
|
| 519 |
+
|
| 520 |
+
# Variable $1 ...
|
| 521 |
+
(r'\$\d+', Name.Variable),
|
| 522 |
+
# cast
|
| 523 |
+
(r'::\w+', Name.Variable),
|
| 524 |
+
(r' +', Whitespace),
|
| 525 |
+
(r'"', Punctuation),
|
| 526 |
+
(r'\[\.\.\.\]', Punctuation),
|
| 527 |
+
(r'\)', Punctuation, '#pop'),
|
| 528 |
+
],
|
| 529 |
+
'predicate': [
|
| 530 |
+
# if predicate is parenthesized, mark paren as punctuation
|
| 531 |
+
(r'(\()([^\n]*)(\))', bygroups(Punctuation, Name.Variable, Punctuation), '#pop'),
|
| 532 |
+
# otherwise color until newline
|
| 533 |
+
(r'[^\n]*', Name.Variable, '#pop'),
|
| 534 |
+
],
|
| 535 |
+
'instrumentation': [
|
| 536 |
+
(r'=|\.\.', Punctuation),
|
| 537 |
+
(r' +', Whitespace),
|
| 538 |
+
(r'(rows|width|time|loops)', Name.Class),
|
| 539 |
+
(r'\d+\.\d+', Number.Float),
|
| 540 |
+
(r'(\d+)', Number.Integer),
|
| 541 |
+
(r'\)', Punctuation, '#pop'),
|
| 542 |
+
],
|
| 543 |
+
'conflict': [
|
| 544 |
+
(r'(Resolution: )(\w+)', bygroups(Comment.Preproc, Name.Variable)),
|
| 545 |
+
(r'(Arbiter \w+:)', Comment.Preproc, 'object_name'),
|
| 546 |
+
(r'(Filter: )', Comment.Preproc, 'predicate'),
|
| 547 |
+
],
|
| 548 |
+
'setting': [
|
| 549 |
+
(r'([a-z_]*?)(\s*)(=)(\s*)(\'.*?\')', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String)),
|
| 550 |
+
(r'\, ', Punctuation),
|
| 551 |
+
],
|
| 552 |
+
'init_plan': [
|
| 553 |
+
(r'\(', Punctuation),
|
| 554 |
+
(r'returns \$\d+(,\$\d+)?', Name.Variable),
|
| 555 |
+
(r'\)', Punctuation, '#pop'),
|
| 556 |
+
],
|
| 557 |
+
'sort': [
|
| 558 |
+
(r':|kB', Punctuation),
|
| 559 |
+
(r'(quicksort|top-N|heapsort|Average|Memory|Peak)', Comment.Prepoc),
|
| 560 |
+
(r'(external|merge|Disk|sort)', Name.Exception),
|
| 561 |
+
(r'(\d+)', Number.Integer),
|
| 562 |
+
(r' +', Whitespace),
|
| 563 |
+
],
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
|
| 567 |
+
class SqlLexer(RegexLexer):
|
| 568 |
+
"""
|
| 569 |
+
Lexer for Structured Query Language. Currently, this lexer does
|
| 570 |
+
not recognize any special syntax except ANSI SQL.
|
| 571 |
+
"""
|
| 572 |
+
|
| 573 |
+
name = 'SQL'
|
| 574 |
+
aliases = ['sql']
|
| 575 |
+
filenames = ['*.sql']
|
| 576 |
+
mimetypes = ['text/x-sql']
|
| 577 |
+
url = 'https://en.wikipedia.org/wiki/SQL'
|
| 578 |
+
version_added = ''
|
| 579 |
+
|
| 580 |
+
flags = re.IGNORECASE
|
| 581 |
+
tokens = {
|
| 582 |
+
'root': [
|
| 583 |
+
(r'\s+', Whitespace),
|
| 584 |
+
(r'--.*\n?', Comment.Single),
|
| 585 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 586 |
+
(words(_sql_builtins.KEYWORDS, suffix=r'\b'), Keyword),
|
| 587 |
+
(words(_sql_builtins.DATATYPES, suffix=r'\b'), Name.Builtin),
|
| 588 |
+
(r'[+*/<>=~!@#%^&|`?-]', Operator),
|
| 589 |
+
(r'[0-9]+', Number.Integer),
|
| 590 |
+
# TODO: Backslash escapes?
|
| 591 |
+
(r"'(''|[^'])*'", String.Single),
|
| 592 |
+
(r'"(""|[^"])*"', String.Symbol), # not a real string literal in ANSI SQL
|
| 593 |
+
(r'[a-z_][\w$]*', Name), # allow $s in strings for Oracle
|
| 594 |
+
(r'[;:()\[\],.]', Punctuation)
|
| 595 |
+
],
|
| 596 |
+
'multiline-comments': [
|
| 597 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 598 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 599 |
+
(r'[^/*]+', Comment.Multiline),
|
| 600 |
+
(r'[/*]', Comment.Multiline)
|
| 601 |
+
]
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
def analyse_text(self, text):
|
| 605 |
+
return
|
| 606 |
+
|
| 607 |
+
|
| 608 |
+
class TransactSqlLexer(RegexLexer):
|
| 609 |
+
"""
|
| 610 |
+
Transact-SQL (T-SQL) is Microsoft's and Sybase's proprietary extension to
|
| 611 |
+
SQL.
|
| 612 |
+
|
| 613 |
+
The list of keywords includes ODBC and keywords reserved for future use.
|
| 614 |
+
"""
|
| 615 |
+
|
| 616 |
+
name = 'Transact-SQL'
|
| 617 |
+
aliases = ['tsql', 't-sql']
|
| 618 |
+
filenames = ['*.sql']
|
| 619 |
+
mimetypes = ['text/x-tsql']
|
| 620 |
+
url = 'https://www.tsql.info'
|
| 621 |
+
version_added = ''
|
| 622 |
+
|
| 623 |
+
flags = re.IGNORECASE
|
| 624 |
+
|
| 625 |
+
tokens = {
|
| 626 |
+
'root': [
|
| 627 |
+
(r'\s+', Whitespace),
|
| 628 |
+
(r'--.*[$|\n]?', Comment.Single),
|
| 629 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 630 |
+
(words(_tsql_builtins.OPERATORS), Operator),
|
| 631 |
+
(words(_tsql_builtins.OPERATOR_WORDS, suffix=r'\b'), Operator.Word),
|
| 632 |
+
(words(_tsql_builtins.TYPES, suffix=r'\b'), Name.Class),
|
| 633 |
+
(words(_tsql_builtins.FUNCTIONS, suffix=r'\b'), Name.Function),
|
| 634 |
+
(r'(goto)(\s+)(\w+\b)', bygroups(Keyword, Whitespace, Name.Label)),
|
| 635 |
+
(words(_tsql_builtins.KEYWORDS, suffix=r'\b'), Keyword),
|
| 636 |
+
(r'(\[)([^]]+)(\])', bygroups(Operator, Name, Operator)),
|
| 637 |
+
(r'0x[0-9a-f]+', Number.Hex),
|
| 638 |
+
# Float variant 1, for example: 1., 1.e2, 1.2e3
|
| 639 |
+
(r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float),
|
| 640 |
+
# Float variant 2, for example: .1, .1e2
|
| 641 |
+
(r'\.[0-9]+(e[+-]?[0-9]+)?', Number.Float),
|
| 642 |
+
# Float variant 3, for example: 123e45
|
| 643 |
+
(r'[0-9]+e[+-]?[0-9]+', Number.Float),
|
| 644 |
+
(r'[0-9]+', Number.Integer),
|
| 645 |
+
(r"'(''|[^'])*'", String.Single),
|
| 646 |
+
(r'"(""|[^"])*"', String.Symbol),
|
| 647 |
+
(r'[;(),.]', Punctuation),
|
| 648 |
+
# Below we use \w even for the first "real" character because
|
| 649 |
+
# tokens starting with a digit have already been recognized
|
| 650 |
+
# as Number above.
|
| 651 |
+
(r'@@\w+', Name.Builtin),
|
| 652 |
+
(r'@\w+', Name.Variable),
|
| 653 |
+
(r'(\w+)(:)', bygroups(Name.Label, Punctuation)),
|
| 654 |
+
(r'#?#?\w+', Name), # names for temp tables and anything else
|
| 655 |
+
(r'\?', Name.Variable.Magic), # parameter for prepared statements
|
| 656 |
+
],
|
| 657 |
+
'multiline-comments': [
|
| 658 |
+
(r'/\*', Comment.Multiline, 'multiline-comments'),
|
| 659 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 660 |
+
(r'[^/*]+', Comment.Multiline),
|
| 661 |
+
(r'[/*]', Comment.Multiline)
|
| 662 |
+
]
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
def analyse_text(text):
|
| 666 |
+
rating = 0
|
| 667 |
+
if tsql_declare_re.search(text):
|
| 668 |
+
# Found T-SQL variable declaration.
|
| 669 |
+
rating = 1.0
|
| 670 |
+
else:
|
| 671 |
+
name_between_backtick_count = len(
|
| 672 |
+
name_between_backtick_re.findall(text))
|
| 673 |
+
name_between_bracket_count = len(
|
| 674 |
+
name_between_bracket_re.findall(text))
|
| 675 |
+
# We need to check if there are any names using
|
| 676 |
+
# backticks or brackets, as otherwise both are 0
|
| 677 |
+
# and 0 >= 2 * 0, so we would always assume it's true
|
| 678 |
+
dialect_name_count = name_between_backtick_count + name_between_bracket_count
|
| 679 |
+
if dialect_name_count >= 1 and \
|
| 680 |
+
name_between_bracket_count >= 2 * name_between_backtick_count:
|
| 681 |
+
# Found at least twice as many [name] as `name`.
|
| 682 |
+
rating += 0.5
|
| 683 |
+
elif name_between_bracket_count > name_between_backtick_count:
|
| 684 |
+
rating += 0.2
|
| 685 |
+
elif name_between_bracket_count > 0:
|
| 686 |
+
rating += 0.1
|
| 687 |
+
if tsql_variable_re.search(text) is not None:
|
| 688 |
+
rating += 0.1
|
| 689 |
+
if tsql_go_re.search(text) is not None:
|
| 690 |
+
rating += 0.1
|
| 691 |
+
return rating
|
| 692 |
+
|
| 693 |
+
|
| 694 |
+
class MySqlLexer(RegexLexer):
|
| 695 |
+
"""The Oracle MySQL lexer.
|
| 696 |
+
|
| 697 |
+
This lexer does not attempt to maintain strict compatibility with
|
| 698 |
+
MariaDB syntax or keywords. Although MySQL and MariaDB's common code
|
| 699 |
+
history suggests there may be significant overlap between the two,
|
| 700 |
+
compatibility between the two is not a target for this lexer.
|
| 701 |
+
"""
|
| 702 |
+
|
| 703 |
+
name = 'MySQL'
|
| 704 |
+
aliases = ['mysql']
|
| 705 |
+
mimetypes = ['text/x-mysql']
|
| 706 |
+
url = 'https://www.mysql.com'
|
| 707 |
+
version_added = ''
|
| 708 |
+
|
| 709 |
+
flags = re.IGNORECASE
|
| 710 |
+
tokens = {
|
| 711 |
+
'root': [
|
| 712 |
+
(r'\s+', Whitespace),
|
| 713 |
+
|
| 714 |
+
# Comments
|
| 715 |
+
(r'(?:#|--\s+).*', Comment.Single),
|
| 716 |
+
(r'/\*\+', Comment.Special, 'optimizer-hints'),
|
| 717 |
+
(r'/\*', Comment.Multiline, 'multiline-comment'),
|
| 718 |
+
|
| 719 |
+
# Hexadecimal literals
|
| 720 |
+
(r"x'([0-9a-f]{2})+'", Number.Hex), # MySQL requires paired hex characters in this form.
|
| 721 |
+
(r'0x[0-9a-f]+', Number.Hex),
|
| 722 |
+
|
| 723 |
+
# Binary literals
|
| 724 |
+
(r"b'[01]+'", Number.Bin),
|
| 725 |
+
(r'0b[01]+', Number.Bin),
|
| 726 |
+
|
| 727 |
+
# Numeric literals
|
| 728 |
+
(r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float), # Mandatory integer, optional fraction and exponent
|
| 729 |
+
(r'[0-9]*\.[0-9]+(e[+-]?[0-9]+)?', Number.Float), # Mandatory fraction, optional integer and exponent
|
| 730 |
+
(r'[0-9]+e[+-]?[0-9]+', Number.Float), # Exponents with integer significands are still floats
|
| 731 |
+
(r'[0-9]+(?=[^0-9a-z$_\u0080-\uffff])', Number.Integer), # Integers that are not in a schema object name
|
| 732 |
+
|
| 733 |
+
# Date literals
|
| 734 |
+
(r"\{\s*d\s*(?P<quote>['\"])\s*\d{2}(\d{2})?.?\d{2}.?\d{2}\s*(?P=quote)\s*\}",
|
| 735 |
+
Literal.Date),
|
| 736 |
+
|
| 737 |
+
# Time literals
|
| 738 |
+
(r"\{\s*t\s*(?P<quote>['\"])\s*(?:\d+\s+)?\d{1,2}.?\d{1,2}.?\d{1,2}(\.\d*)?\s*(?P=quote)\s*\}",
|
| 739 |
+
Literal.Date),
|
| 740 |
+
|
| 741 |
+
# Timestamp literals
|
| 742 |
+
(
|
| 743 |
+
r"\{\s*ts\s*(?P<quote>['\"])\s*"
|
| 744 |
+
r"\d{2}(?:\d{2})?.?\d{2}.?\d{2}" # Date part
|
| 745 |
+
r"\s+" # Whitespace between date and time
|
| 746 |
+
r"\d{1,2}.?\d{1,2}.?\d{1,2}(\.\d*)?" # Time part
|
| 747 |
+
r"\s*(?P=quote)\s*\}",
|
| 748 |
+
Literal.Date
|
| 749 |
+
),
|
| 750 |
+
|
| 751 |
+
# String literals
|
| 752 |
+
(r"'", String.Single, 'single-quoted-string'),
|
| 753 |
+
(r'"', String.Double, 'double-quoted-string'),
|
| 754 |
+
|
| 755 |
+
# Variables
|
| 756 |
+
(r'@@(?:global\.|persist\.|persist_only\.|session\.)?[a-z_]+', Name.Variable),
|
| 757 |
+
(r'@[a-z0-9_$.]+', Name.Variable),
|
| 758 |
+
(r"@'", Name.Variable, 'single-quoted-variable'),
|
| 759 |
+
(r'@"', Name.Variable, 'double-quoted-variable'),
|
| 760 |
+
(r"@`", Name.Variable, 'backtick-quoted-variable'),
|
| 761 |
+
(r'\?', Name.Variable), # For demonstrating prepared statements
|
| 762 |
+
|
| 763 |
+
# Operators
|
| 764 |
+
(r'[!%&*+/:<=>^|~-]+', Operator),
|
| 765 |
+
|
| 766 |
+
# Exceptions; these words tokenize differently in different contexts.
|
| 767 |
+
(r'\b(set)(?!\s*\()', Keyword),
|
| 768 |
+
(r'\b(character)(\s+)(set)\b', bygroups(Keyword, Whitespace, Keyword)),
|
| 769 |
+
# In all other known cases, "SET" is tokenized by MYSQL_DATATYPES.
|
| 770 |
+
|
| 771 |
+
(words(_mysql_builtins.MYSQL_CONSTANTS, prefix=r'\b', suffix=r'\b'),
|
| 772 |
+
Name.Constant),
|
| 773 |
+
(words(_mysql_builtins.MYSQL_DATATYPES, prefix=r'\b', suffix=r'\b'),
|
| 774 |
+
Keyword.Type),
|
| 775 |
+
(words(_mysql_builtins.MYSQL_KEYWORDS, prefix=r'\b', suffix=r'\b'),
|
| 776 |
+
Keyword),
|
| 777 |
+
(words(_mysql_builtins.MYSQL_FUNCTIONS, prefix=r'\b', suffix=r'\b(\s*)(\()'),
|
| 778 |
+
bygroups(Name.Function, Whitespace, Punctuation)),
|
| 779 |
+
|
| 780 |
+
# Schema object names
|
| 781 |
+
#
|
| 782 |
+
# Note: Although the first regex supports unquoted all-numeric
|
| 783 |
+
# identifiers, this will not be a problem in practice because
|
| 784 |
+
# numeric literals have already been handled above.
|
| 785 |
+
#
|
| 786 |
+
('[0-9a-z$_\u0080-\uffff]+', Name),
|
| 787 |
+
(r'`', Name.Quoted, 'schema-object-name'),
|
| 788 |
+
|
| 789 |
+
# Punctuation
|
| 790 |
+
(r'[(),.;]', Punctuation),
|
| 791 |
+
],
|
| 792 |
+
|
| 793 |
+
# Multiline comment substates
|
| 794 |
+
# ---------------------------
|
| 795 |
+
|
| 796 |
+
'optimizer-hints': [
|
| 797 |
+
(r'[^*a-z]+', Comment.Special),
|
| 798 |
+
(r'\*/', Comment.Special, '#pop'),
|
| 799 |
+
(words(_mysql_builtins.MYSQL_OPTIMIZER_HINTS, suffix=r'\b'),
|
| 800 |
+
Comment.Preproc),
|
| 801 |
+
('[a-z]+', Comment.Special),
|
| 802 |
+
(r'\*', Comment.Special),
|
| 803 |
+
],
|
| 804 |
+
|
| 805 |
+
'multiline-comment': [
|
| 806 |
+
(r'[^*]+', Comment.Multiline),
|
| 807 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 808 |
+
(r'\*', Comment.Multiline),
|
| 809 |
+
],
|
| 810 |
+
|
| 811 |
+
# String substates
|
| 812 |
+
# ----------------
|
| 813 |
+
|
| 814 |
+
'single-quoted-string': [
|
| 815 |
+
(r"[^'\\]+", String.Single),
|
| 816 |
+
(r"''", String.Escape),
|
| 817 |
+
(r"""\\[0'"bnrtZ\\%_]""", String.Escape),
|
| 818 |
+
(r"'", String.Single, '#pop'),
|
| 819 |
+
],
|
| 820 |
+
|
| 821 |
+
'double-quoted-string': [
|
| 822 |
+
(r'[^"\\]+', String.Double),
|
| 823 |
+
(r'""', String.Escape),
|
| 824 |
+
(r"""\\[0'"bnrtZ\\%_]""", String.Escape),
|
| 825 |
+
(r'"', String.Double, '#pop'),
|
| 826 |
+
],
|
| 827 |
+
|
| 828 |
+
# Variable substates
|
| 829 |
+
# ------------------
|
| 830 |
+
|
| 831 |
+
'single-quoted-variable': [
|
| 832 |
+
(r"[^']+", Name.Variable),
|
| 833 |
+
(r"''", Name.Variable),
|
| 834 |
+
(r"'", Name.Variable, '#pop'),
|
| 835 |
+
],
|
| 836 |
+
|
| 837 |
+
'double-quoted-variable': [
|
| 838 |
+
(r'[^"]+', Name.Variable),
|
| 839 |
+
(r'""', Name.Variable),
|
| 840 |
+
(r'"', Name.Variable, '#pop'),
|
| 841 |
+
],
|
| 842 |
+
|
| 843 |
+
'backtick-quoted-variable': [
|
| 844 |
+
(r'[^`]+', Name.Variable),
|
| 845 |
+
(r'``', Name.Variable),
|
| 846 |
+
(r'`', Name.Variable, '#pop'),
|
| 847 |
+
],
|
| 848 |
+
|
| 849 |
+
# Schema object name substates
|
| 850 |
+
# ----------------------------
|
| 851 |
+
#
|
| 852 |
+
# "Name.Quoted" and "Name.Quoted.Escape" are non-standard but
|
| 853 |
+
# formatters will style them as "Name" by default but add
|
| 854 |
+
# additional styles based on the token name. This gives users
|
| 855 |
+
# flexibility to add custom styles as desired.
|
| 856 |
+
#
|
| 857 |
+
'schema-object-name': [
|
| 858 |
+
(r'[^`]+', Name.Quoted),
|
| 859 |
+
(r'``', Name.Quoted.Escape),
|
| 860 |
+
(r'`', Name.Quoted, '#pop'),
|
| 861 |
+
],
|
| 862 |
+
}
|
| 863 |
+
|
| 864 |
+
def analyse_text(text):
|
| 865 |
+
rating = 0
|
| 866 |
+
name_between_backtick_count = len(
|
| 867 |
+
name_between_backtick_re.findall(text))
|
| 868 |
+
name_between_bracket_count = len(
|
| 869 |
+
name_between_bracket_re.findall(text))
|
| 870 |
+
# Same logic as above in the TSQL analysis
|
| 871 |
+
dialect_name_count = name_between_backtick_count + name_between_bracket_count
|
| 872 |
+
if dialect_name_count >= 1 and \
|
| 873 |
+
name_between_backtick_count >= 2 * name_between_bracket_count:
|
| 874 |
+
# Found at least twice as many `name` as [name].
|
| 875 |
+
rating += 0.5
|
| 876 |
+
elif name_between_backtick_count > name_between_bracket_count:
|
| 877 |
+
rating += 0.2
|
| 878 |
+
elif name_between_backtick_count > 0:
|
| 879 |
+
rating += 0.1
|
| 880 |
+
return rating
|
| 881 |
+
|
| 882 |
+
|
| 883 |
+
class GoogleSqlLexer(RegexLexer):
|
| 884 |
+
"""
|
| 885 |
+
GoogleSQL is Google's standard SQL dialect, formerly known as ZetaSQL.
|
| 886 |
+
|
| 887 |
+
The list of keywords includes reserved words for future use.
|
| 888 |
+
"""
|
| 889 |
+
|
| 890 |
+
name = 'GoogleSQL'
|
| 891 |
+
aliases = ['googlesql', 'zetasql']
|
| 892 |
+
filenames = ['*.googlesql', '*.googlesql.sql']
|
| 893 |
+
mimetypes = ['text/x-google-sql', 'text/x-google-sql-aux']
|
| 894 |
+
url = 'https://cloud.google.com/bigquery/googlesql'
|
| 895 |
+
version_added = '2.19'
|
| 896 |
+
|
| 897 |
+
flags = re.IGNORECASE
|
| 898 |
+
tokens = {
|
| 899 |
+
'root': [
|
| 900 |
+
(r'\s+', Whitespace),
|
| 901 |
+
|
| 902 |
+
# Comments
|
| 903 |
+
(r'(?:#|--\s+).*', Comment.Single),
|
| 904 |
+
(r'/\*', Comment.Multiline, 'multiline-comment'),
|
| 905 |
+
|
| 906 |
+
# Hexadecimal literals
|
| 907 |
+
(r"x'([0-9a-f]{2})+'", Number.Hex),
|
| 908 |
+
(r'0x[0-9a-f]+', Number.Hex),
|
| 909 |
+
|
| 910 |
+
# Binary literals
|
| 911 |
+
(r"b'[01]+'", Number.Bin),
|
| 912 |
+
(r'0b[01]+', Number.Bin),
|
| 913 |
+
|
| 914 |
+
# Numeric literals
|
| 915 |
+
(r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float), # Mandatory integer, optional fraction and exponent
|
| 916 |
+
(r'[0-9]*\.[0-9]+(e[+-]?[0-9]+)?', Number.Float), # Mandatory fraction, optional integer and exponent
|
| 917 |
+
(r'[0-9]+e[+-]?[0-9]+', Number.Float), # Exponents with integer significands are still floats
|
| 918 |
+
(r'[0-9]+(?=[^0-9a-z$_\u0080-\uffff])', Number.Integer), # Integers that are not in a schema object name
|
| 919 |
+
|
| 920 |
+
# Date literals
|
| 921 |
+
(r"\{\s*d\s*(?P<quote>['\"])\s*\d{2}(\d{2})?.?\d{2}.?\d{2}\s*(?P=quote)\s*\}",
|
| 922 |
+
Literal.Date),
|
| 923 |
+
|
| 924 |
+
# Time literals
|
| 925 |
+
(r"\{\s*t\s*(?P<quote>['\"])\s*(?:\d+\s+)?\d{1,2}.?\d{1,2}.?\d{1,2}(\.\d*)?\s*(?P=quote)\s*\}",
|
| 926 |
+
Literal.Date),
|
| 927 |
+
|
| 928 |
+
# Timestamp literals
|
| 929 |
+
(
|
| 930 |
+
r"\{\s*ts\s*(?P<quote>['\"])\s*"
|
| 931 |
+
r"\d{2}(?:\d{2})?.?\d{2}.?\d{2}" # Date part
|
| 932 |
+
r"\s+" # Whitespace between date and time
|
| 933 |
+
r"\d{1,2}.?\d{1,2}.?\d{1,2}(\.\d*)?" # Time part
|
| 934 |
+
r"\s*(?P=quote)\s*\}",
|
| 935 |
+
Literal.Date
|
| 936 |
+
),
|
| 937 |
+
|
| 938 |
+
# String literals
|
| 939 |
+
(r"'", String.Single, 'single-quoted-string'),
|
| 940 |
+
(r'"', String.Double, 'double-quoted-string'),
|
| 941 |
+
|
| 942 |
+
# Variables
|
| 943 |
+
(r'@@(?:global\.|persist\.|persist_only\.|session\.)?[a-z_]+', Name.Variable),
|
| 944 |
+
(r'@[a-z0-9_$.]+', Name.Variable),
|
| 945 |
+
(r"@'", Name.Variable, 'single-quoted-variable'),
|
| 946 |
+
(r'@"', Name.Variable, 'double-quoted-variable'),
|
| 947 |
+
(r"@`", Name.Variable, 'backtick-quoted-variable'),
|
| 948 |
+
(r'\?', Name.Variable), # For demonstrating prepared statements
|
| 949 |
+
|
| 950 |
+
# Exceptions; these words tokenize differently in different contexts.
|
| 951 |
+
(r'\b(set)(?!\s*\()', Keyword),
|
| 952 |
+
(r'\b(character)(\s+)(set)\b', bygroups(Keyword, Whitespace, Keyword)),
|
| 953 |
+
|
| 954 |
+
# Constants, types, keywords, functions, operators
|
| 955 |
+
(words(_googlesql_builtins.constants, prefix=r'\b', suffix=r'\b'), Name.Constant),
|
| 956 |
+
(words(_googlesql_builtins.types, prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
| 957 |
+
(words(_googlesql_builtins.keywords, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 958 |
+
(words(_googlesql_builtins.functionnames, prefix=r'\b', suffix=r'\b(\s*)(\()'),
|
| 959 |
+
bygroups(Name.Function, Whitespace, Punctuation)),
|
| 960 |
+
(words(_googlesql_builtins.operators, prefix=r'\b', suffix=r'\b'), Operator),
|
| 961 |
+
|
| 962 |
+
# Schema object names
|
| 963 |
+
#
|
| 964 |
+
# Note: Although the first regex supports unquoted all-numeric
|
| 965 |
+
# identifiers, this will not be a problem in practice because
|
| 966 |
+
# numeric literals have already been handled above.
|
| 967 |
+
#
|
| 968 |
+
('[0-9a-z$_\u0080-\uffff]+', Name),
|
| 969 |
+
(r'`', Name.Quoted, 'schema-object-name'),
|
| 970 |
+
|
| 971 |
+
# Punctuation
|
| 972 |
+
(r'[(),.;]', Punctuation),
|
| 973 |
+
],
|
| 974 |
+
|
| 975 |
+
# Multiline comment substates
|
| 976 |
+
# ---------------------------
|
| 977 |
+
|
| 978 |
+
'multiline-comment': [
|
| 979 |
+
(r'[^*]+', Comment.Multiline),
|
| 980 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 981 |
+
(r'\*', Comment.Multiline),
|
| 982 |
+
],
|
| 983 |
+
|
| 984 |
+
# String substates
|
| 985 |
+
# ----------------
|
| 986 |
+
|
| 987 |
+
'single-quoted-string': [
|
| 988 |
+
(r"[^'\\]+", String.Single),
|
| 989 |
+
(r"''", String.Escape),
|
| 990 |
+
(r"""\\[0'"bnrtZ\\%_]""", String.Escape),
|
| 991 |
+
(r"'", String.Single, '#pop'),
|
| 992 |
+
],
|
| 993 |
+
|
| 994 |
+
'double-quoted-string': [
|
| 995 |
+
(r'[^"\\]+', String.Double),
|
| 996 |
+
(r'""', String.Escape),
|
| 997 |
+
(r"""\\[0'"bnrtZ\\%_]""", String.Escape),
|
| 998 |
+
(r'"', String.Double, '#pop'),
|
| 999 |
+
],
|
| 1000 |
+
|
| 1001 |
+
# Variable substates
|
| 1002 |
+
# ------------------
|
| 1003 |
+
|
| 1004 |
+
'single-quoted-variable': [
|
| 1005 |
+
(r"[^']+", Name.Variable),
|
| 1006 |
+
(r"''", Name.Variable),
|
| 1007 |
+
(r"'", Name.Variable, '#pop'),
|
| 1008 |
+
],
|
| 1009 |
+
|
| 1010 |
+
'double-quoted-variable': [
|
| 1011 |
+
(r'[^"]+', Name.Variable),
|
| 1012 |
+
(r'""', Name.Variable),
|
| 1013 |
+
(r'"', Name.Variable, '#pop'),
|
| 1014 |
+
],
|
| 1015 |
+
|
| 1016 |
+
'backtick-quoted-variable': [
|
| 1017 |
+
(r'[^`]+', Name.Variable),
|
| 1018 |
+
(r'``', Name.Variable),
|
| 1019 |
+
(r'`', Name.Variable, '#pop'),
|
| 1020 |
+
],
|
| 1021 |
+
|
| 1022 |
+
# Schema object name substates
|
| 1023 |
+
# ----------------------------
|
| 1024 |
+
#
|
| 1025 |
+
# "Name.Quoted" and "Name.Quoted.Escape" are non-standard but
|
| 1026 |
+
# formatters will style them as "Name" by default but add
|
| 1027 |
+
# additional styles based on the token name. This gives users
|
| 1028 |
+
# flexibility to add custom styles as desired.
|
| 1029 |
+
#
|
| 1030 |
+
'schema-object-name': [
|
| 1031 |
+
(r'[^`]+', Name.Quoted),
|
| 1032 |
+
(r'``', Name.Quoted.Escape),
|
| 1033 |
+
(r'`', Name.Quoted, '#pop'),
|
| 1034 |
+
],
|
| 1035 |
+
}
|
| 1036 |
+
|
| 1037 |
+
def analyse_text(text):
|
| 1038 |
+
tokens = collections.Counter(text.split())
|
| 1039 |
+
return 0.001 * sum(count for t, count in tokens.items()
|
| 1040 |
+
if t in googlesql_identifiers)
|
| 1041 |
+
|
| 1042 |
+
|
| 1043 |
+
class SqliteConsoleLexer(Lexer):
|
| 1044 |
+
"""
|
| 1045 |
+
Lexer for example sessions using sqlite3.
|
| 1046 |
+
"""
|
| 1047 |
+
|
| 1048 |
+
name = 'sqlite3con'
|
| 1049 |
+
aliases = ['sqlite3']
|
| 1050 |
+
filenames = ['*.sqlite3-console']
|
| 1051 |
+
mimetypes = ['text/x-sqlite3-console']
|
| 1052 |
+
url = 'https://www.sqlite.org'
|
| 1053 |
+
version_added = '0.11'
|
| 1054 |
+
_example = "sqlite3/sqlite3.sqlite3-console"
|
| 1055 |
+
|
| 1056 |
+
def get_tokens_unprocessed(self, data):
|
| 1057 |
+
sql = SqlLexer(**self.options)
|
| 1058 |
+
|
| 1059 |
+
curcode = ''
|
| 1060 |
+
insertions = []
|
| 1061 |
+
for match in line_re.finditer(data):
|
| 1062 |
+
line = match.group()
|
| 1063 |
+
prompt_match = sqlite_prompt_re.match(line)
|
| 1064 |
+
if prompt_match is not None:
|
| 1065 |
+
insertions.append((len(curcode),
|
| 1066 |
+
[(0, Generic.Prompt, line[:7])]))
|
| 1067 |
+
insertions.append((len(curcode),
|
| 1068 |
+
[(7, Whitespace, ' ')]))
|
| 1069 |
+
curcode += line[8:]
|
| 1070 |
+
else:
|
| 1071 |
+
if curcode:
|
| 1072 |
+
yield from do_insertions(insertions,
|
| 1073 |
+
sql.get_tokens_unprocessed(curcode))
|
| 1074 |
+
curcode = ''
|
| 1075 |
+
insertions = []
|
| 1076 |
+
if line.startswith('SQL error: '):
|
| 1077 |
+
yield (match.start(), Generic.Traceback, line)
|
| 1078 |
+
else:
|
| 1079 |
+
yield (match.start(), Generic.Output, line)
|
| 1080 |
+
if curcode:
|
| 1081 |
+
yield from do_insertions(insertions,
|
| 1082 |
+
sql.get_tokens_unprocessed(curcode))
|
| 1083 |
+
|
| 1084 |
+
|
| 1085 |
+
class RqlLexer(RegexLexer):
|
| 1086 |
+
"""
|
| 1087 |
+
Lexer for Relation Query Language.
|
| 1088 |
+
"""
|
| 1089 |
+
name = 'RQL'
|
| 1090 |
+
url = 'http://www.logilab.org/project/rql'
|
| 1091 |
+
aliases = ['rql']
|
| 1092 |
+
filenames = ['*.rql']
|
| 1093 |
+
mimetypes = ['text/x-rql']
|
| 1094 |
+
version_added = '2.0'
|
| 1095 |
+
|
| 1096 |
+
flags = re.IGNORECASE
|
| 1097 |
+
tokens = {
|
| 1098 |
+
'root': [
|
| 1099 |
+
(r'\s+', Whitespace),
|
| 1100 |
+
(r'(DELETE|SET|INSERT|UNION|DISTINCT|WITH|WHERE|BEING|OR'
|
| 1101 |
+
r'|AND|NOT|GROUPBY|HAVING|ORDERBY|ASC|DESC|LIMIT|OFFSET'
|
| 1102 |
+
r'|TODAY|NOW|TRUE|FALSE|NULL|EXISTS)\b', Keyword),
|
| 1103 |
+
(r'[+*/<>=%-]', Operator),
|
| 1104 |
+
(r'(Any|is|instance_of|CWEType|CWRelation)\b', Name.Builtin),
|
| 1105 |
+
(r'[0-9]+', Number.Integer),
|
| 1106 |
+
(r'[A-Z_]\w*\??', Name),
|
| 1107 |
+
(r"'(''|[^'])*'", String.Single),
|
| 1108 |
+
(r'"(""|[^"])*"', String.Single),
|
| 1109 |
+
(r'[;:()\[\],.]', Punctuation)
|
| 1110 |
+
],
|
| 1111 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/srcinfo.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.srcinfo
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for .SRCINFO files used by Arch Linux Packages.
|
| 6 |
+
|
| 7 |
+
The description of the format can be found in the wiki:
|
| 8 |
+
https://wiki.archlinux.org/title/.SRCINFO
|
| 9 |
+
|
| 10 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 11 |
+
:license: BSD, see LICENSE for details.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from pygments.lexer import RegexLexer, words
|
| 15 |
+
from pygments.token import Text, Comment, Keyword, Name, Operator, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['SrcinfoLexer']
|
| 18 |
+
|
| 19 |
+
keywords = (
|
| 20 |
+
'pkgbase', 'pkgname',
|
| 21 |
+
'pkgver', 'pkgrel', 'epoch',
|
| 22 |
+
'pkgdesc', 'url', 'install', 'changelog',
|
| 23 |
+
'arch', 'groups', 'license', 'noextract', 'options', 'backup',
|
| 24 |
+
'validpgpkeys',
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
architecture_dependent_keywords = (
|
| 28 |
+
'source', 'depends', 'checkdepends', 'makedepends', 'optdepends',
|
| 29 |
+
'provides', 'conflicts', 'replaces',
|
| 30 |
+
'md5sums', 'sha1sums', 'sha224sums', 'sha256sums', 'sha384sums',
|
| 31 |
+
'sha512sums',
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class SrcinfoLexer(RegexLexer):
|
| 36 |
+
"""Lexer for .SRCINFO files used by Arch Linux Packages.
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
name = 'Srcinfo'
|
| 40 |
+
aliases = ['srcinfo']
|
| 41 |
+
filenames = ['.SRCINFO']
|
| 42 |
+
url = 'https://wiki.archlinux.org/title/.SRCINFO'
|
| 43 |
+
version_added = '2.11'
|
| 44 |
+
|
| 45 |
+
tokens = {
|
| 46 |
+
'root': [
|
| 47 |
+
(r'\s+', Whitespace),
|
| 48 |
+
(r'#.*', Comment.Single),
|
| 49 |
+
(words(keywords), Keyword, 'assignment'),
|
| 50 |
+
(words(architecture_dependent_keywords, suffix=r'_\w+'),
|
| 51 |
+
Keyword, 'assignment'),
|
| 52 |
+
(r'\w+', Name.Variable, 'assignment'),
|
| 53 |
+
],
|
| 54 |
+
'assignment': [
|
| 55 |
+
(r' +', Whitespace),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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.stata
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Stata
|
| 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 |
+
from pygments.lexer import RegexLexer, default, include, words
|
| 13 |
+
from pygments.token import Comment, Keyword, Name, Number, \
|
| 14 |
+
String, Text, Operator
|
| 15 |
+
|
| 16 |
+
from pygments.lexers._stata_builtins import builtins_base, builtins_functions
|
| 17 |
+
|
| 18 |
+
__all__ = ['StataLexer']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class StataLexer(RegexLexer):
|
| 22 |
+
"""
|
| 23 |
+
For Stata do files.
|
| 24 |
+
"""
|
| 25 |
+
# Syntax based on
|
| 26 |
+
# - http://fmwww.bc.edu/RePEc/bocode/s/synlightlist.ado
|
| 27 |
+
# - https://github.com/isagalaev/highlight.js/blob/master/src/languages/stata.js
|
| 28 |
+
# - https://github.com/jpitblado/vim-stata/blob/master/syntax/stata.vim
|
| 29 |
+
|
| 30 |
+
name = 'Stata'
|
| 31 |
+
url = 'http://www.stata.com/'
|
| 32 |
+
version_added = '2.2'
|
| 33 |
+
aliases = ['stata', 'do']
|
| 34 |
+
filenames = ['*.do', '*.ado']
|
| 35 |
+
mimetypes = ['text/x-stata', 'text/stata', 'application/x-stata']
|
| 36 |
+
flags = re.MULTILINE | re.DOTALL
|
| 37 |
+
|
| 38 |
+
tokens = {
|
| 39 |
+
'root': [
|
| 40 |
+
include('comments'),
|
| 41 |
+
include('strings'),
|
| 42 |
+
include('macros'),
|
| 43 |
+
include('numbers'),
|
| 44 |
+
include('keywords'),
|
| 45 |
+
include('operators'),
|
| 46 |
+
include('format'),
|
| 47 |
+
(r'.', Text),
|
| 48 |
+
],
|
| 49 |
+
# Comments are a complicated beast in Stata because they can be
|
| 50 |
+
# nested and there are a few corner cases with that. See:
|
| 51 |
+
# - github.com/kylebarron/language-stata/issues/90
|
| 52 |
+
# - statalist.org/forums/forum/general-stata-discussion/general/1448244
|
| 53 |
+
'comments': [
|
| 54 |
+
(r'(^//|(?<=\s)//)(?!/)', Comment.Single, 'comments-double-slash'),
|
| 55 |
+
(r'^\s*\*', Comment.Single, 'comments-star'),
|
| 56 |
+
(r'/\*', Comment.Multiline, 'comments-block'),
|
| 57 |
+
(r'(^///|(?<=\s)///)', Comment.Special, 'comments-triple-slash')
|
| 58 |
+
],
|
| 59 |
+
'comments-block': [
|
| 60 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 61 |
+
# this ends and restarts a comment block. but need to catch this so
|
| 62 |
+
# that it doesn\'t start _another_ level of comment blocks
|
| 63 |
+
(r'\*/\*', Comment.Multiline),
|
| 64 |
+
(r'(\*/\s+\*(?!/)[^\n]*)|(\*/)', Comment.Multiline, '#pop'),
|
| 65 |
+
# Match anything else as a character inside the comment
|
| 66 |
+
(r'.', Comment.Multiline),
|
| 67 |
+
],
|
| 68 |
+
'comments-star': [
|
| 69 |
+
(r'///.*?\n', Comment.Single,
|
| 70 |
+
('#pop', 'comments-triple-slash')),
|
| 71 |
+
(r'(^//|(?<=\s)//)(?!/)', Comment.Single,
|
| 72 |
+
('#pop', 'comments-double-slash')),
|
| 73 |
+
(r'/\*', Comment.Multiline, 'comments-block'),
|
| 74 |
+
(r'.(?=\n)', Comment.Single, '#pop'),
|
| 75 |
+
(r'.', Comment.Single),
|
| 76 |
+
],
|
| 77 |
+
'comments-triple-slash': [
|
| 78 |
+
(r'\n', Comment.Special, '#pop'),
|
| 79 |
+
# A // breaks out of a comment for the rest of the line
|
| 80 |
+
(r'//.*?(?=\n)', Comment.Single, '#pop'),
|
| 81 |
+
(r'.', Comment.Special),
|
| 82 |
+
],
|
| 83 |
+
'comments-double-slash': [
|
| 84 |
+
(r'\n', Text, '#pop'),
|
| 85 |
+
(r'.', Comment.Single),
|
| 86 |
+
],
|
| 87 |
+
# `"compound string"' and regular "string"; note the former are
|
| 88 |
+
# nested.
|
| 89 |
+
'strings': [
|
| 90 |
+
(r'`"', String, 'string-compound'),
|
| 91 |
+
(r'(?<!`)"', String, 'string-regular'),
|
| 92 |
+
],
|
| 93 |
+
'string-compound': [
|
| 94 |
+
(r'`"', String, '#push'),
|
| 95 |
+
(r'"\'', String, '#pop'),
|
| 96 |
+
(r'\\\\|\\"|\\\$|\\`|\\\n', String.Escape),
|
| 97 |
+
include('macros'),
|
| 98 |
+
(r'.', String)
|
| 99 |
+
],
|
| 100 |
+
'string-regular': [
|
| 101 |
+
(r'(")(?!\')|(?=\n)', String, '#pop'),
|
| 102 |
+
(r'\\\\|\\"|\\\$|\\`|\\\n', String.Escape),
|
| 103 |
+
include('macros'),
|
| 104 |
+
(r'.', String)
|
| 105 |
+
],
|
| 106 |
+
# A local is usually
|
| 107 |
+
# `\w{0,31}'
|
| 108 |
+
# `:extended macro'
|
| 109 |
+
# `=expression'
|
| 110 |
+
# `[rsen](results)'
|
| 111 |
+
# `(++--)scalar(++--)'
|
| 112 |
+
#
|
| 113 |
+
# However, there are all sorts of weird rules wrt edge
|
| 114 |
+
# cases. Instead of writing 27 exceptions, anything inside
|
| 115 |
+
# `' is a local.
|
| 116 |
+
#
|
| 117 |
+
# A global is more restricted, so we do follow rules. Note only
|
| 118 |
+
# locals explicitly enclosed ${} can be nested.
|
| 119 |
+
'macros': [
|
| 120 |
+
(r'\$(\{|(?=[$`]))', Name.Variable.Global, 'macro-global-nested'),
|
| 121 |
+
(r'\$', Name.Variable.Global, 'macro-global-name'),
|
| 122 |
+
(r'`', Name.Variable, 'macro-local'),
|
| 123 |
+
],
|
| 124 |
+
'macro-local': [
|
| 125 |
+
(r'`', Name.Variable, '#push'),
|
| 126 |
+
(r"'", Name.Variable, '#pop'),
|
| 127 |
+
(r'\$(\{|(?=[$`]))', Name.Variable.Global, 'macro-global-nested'),
|
| 128 |
+
(r'\$', Name.Variable.Global, 'macro-global-name'),
|
| 129 |
+
(r'.', Name.Variable), # fallback
|
| 130 |
+
],
|
| 131 |
+
'macro-global-nested': [
|
| 132 |
+
(r'\$(\{|(?=[$`]))', Name.Variable.Global, '#push'),
|
| 133 |
+
(r'\}', Name.Variable.Global, '#pop'),
|
| 134 |
+
(r'\$', Name.Variable.Global, 'macro-global-name'),
|
| 135 |
+
(r'`', Name.Variable, 'macro-local'),
|
| 136 |
+
(r'\w', Name.Variable.Global), # fallback
|
| 137 |
+
default('#pop'),
|
| 138 |
+
],
|
| 139 |
+
'macro-global-name': [
|
| 140 |
+
(r'\$(\{|(?=[$`]))', Name.Variable.Global, 'macro-global-nested', '#pop'),
|
| 141 |
+
(r'\$', Name.Variable.Global, 'macro-global-name', '#pop'),
|
| 142 |
+
(r'`', Name.Variable, 'macro-local', '#pop'),
|
| 143 |
+
(r'\w{1,32}', Name.Variable.Global, '#pop'),
|
| 144 |
+
],
|
| 145 |
+
# Built in functions and statements
|
| 146 |
+
'keywords': [
|
| 147 |
+
(words(builtins_functions, prefix = r'\b', suffix = r'(?=\()'),
|
| 148 |
+
Name.Function),
|
| 149 |
+
(words(builtins_base, prefix = r'(^\s*|\s)', suffix = r'\b'),
|
| 150 |
+
Keyword),
|
| 151 |
+
],
|
| 152 |
+
# http://www.stata.com/help.cgi?operators
|
| 153 |
+
'operators': [
|
| 154 |
+
(r'-|==|<=|>=|<|>|&|!=', Operator),
|
| 155 |
+
(r'\*|\+|\^|/|!|~|==|~=', Operator)
|
| 156 |
+
],
|
| 157 |
+
# Stata numbers
|
| 158 |
+
'numbers': [
|
| 159 |
+
# decimal number
|
| 160 |
+
(r'\b[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+|\.)([eE][+-]?[0-9]+)?[i]?\b',
|
| 161 |
+
Number),
|
| 162 |
+
],
|
| 163 |
+
# Stata formats
|
| 164 |
+
'format': [
|
| 165 |
+
(r'%-?\d{1,2}(\.\d{1,2})?[gfe]c?', Name.Other),
|
| 166 |
+
(r'%(21x|16H|16L|8H|8L)', Name.Other),
|
| 167 |
+
(r'%-?(tc|tC|td|tw|tm|tq|th|ty|tg)\S{0,32}', Name.Other),
|
| 168 |
+
(r'%[-~]?\d{1,4}s', Name.Other),
|
| 169 |
+
]
|
| 170 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/supercollider.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.supercollider
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for SuperCollider
|
| 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, default
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation
|
| 16 |
+
|
| 17 |
+
__all__ = ['SuperColliderLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class SuperColliderLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For SuperCollider source code.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'SuperCollider'
|
| 26 |
+
url = 'http://supercollider.github.io/'
|
| 27 |
+
aliases = ['supercollider', 'sc']
|
| 28 |
+
filenames = ['*.sc', '*.scd']
|
| 29 |
+
mimetypes = ['application/supercollider', 'text/supercollider']
|
| 30 |
+
version_added = '2.1'
|
| 31 |
+
|
| 32 |
+
flags = re.DOTALL | re.MULTILINE
|
| 33 |
+
tokens = {
|
| 34 |
+
'commentsandwhitespace': [
|
| 35 |
+
(r'\s+', Text),
|
| 36 |
+
(r'<!--', Comment),
|
| 37 |
+
(r'//.*?\n', Comment.Single),
|
| 38 |
+
(r'/\*.*?\*/', Comment.Multiline)
|
| 39 |
+
],
|
| 40 |
+
'slashstartsregex': [
|
| 41 |
+
include('commentsandwhitespace'),
|
| 42 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 43 |
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
| 44 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 45 |
+
default('#pop'),
|
| 46 |
+
],
|
| 47 |
+
'badregex': [
|
| 48 |
+
(r'\n', Text, '#pop')
|
| 49 |
+
],
|
| 50 |
+
'root': [
|
| 51 |
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
| 52 |
+
include('commentsandwhitespace'),
|
| 53 |
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
| 54 |
+
r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
|
| 55 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 56 |
+
(r'[})\].]', Punctuation),
|
| 57 |
+
(words((
|
| 58 |
+
'for', 'in', 'while', 'do', 'break', 'return', 'continue',
|
| 59 |
+
'switch', 'case', 'default', 'if', 'else', 'throw', 'try',
|
| 60 |
+
'catch', 'finally', 'new', 'delete', 'typeof', 'instanceof',
|
| 61 |
+
'void'), suffix=r'\b'),
|
| 62 |
+
Keyword, 'slashstartsregex'),
|
| 63 |
+
(words(('var', 'let', 'with', 'function', 'arg'), suffix=r'\b'),
|
| 64 |
+
Keyword.Declaration, 'slashstartsregex'),
|
| 65 |
+
(words((
|
| 66 |
+
'(abstract', 'boolean', 'byte', 'char', 'class', 'const',
|
| 67 |
+
'debugger', 'double', 'enum', 'export', 'extends', 'final',
|
| 68 |
+
'float', 'goto', 'implements', 'import', 'int', 'interface',
|
| 69 |
+
'long', 'native', 'package', 'private', 'protected', 'public',
|
| 70 |
+
'short', 'static', 'super', 'synchronized', 'throws',
|
| 71 |
+
'transient', 'volatile'), suffix=r'\b'),
|
| 72 |
+
Keyword.Reserved),
|
| 73 |
+
(words(('true', 'false', 'nil', 'inf'), suffix=r'\b'), Keyword.Constant),
|
| 74 |
+
(words((
|
| 75 |
+
'Array', 'Boolean', 'Date', 'Error', 'Function', 'Number',
|
| 76 |
+
'Object', 'Packages', 'RegExp', 'String',
|
| 77 |
+
'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'super',
|
| 78 |
+
'thisFunctionDef', 'thisFunction', 'thisMethod', 'thisProcess',
|
| 79 |
+
'thisThread', 'this'), suffix=r'\b'),
|
| 80 |
+
Name.Builtin),
|
| 81 |
+
(r'[$a-zA-Z_]\w*', Name.Other),
|
| 82 |
+
(r'\\?[$a-zA-Z_]\w*', String.Symbol),
|
| 83 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 84 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 85 |
+
(r'[0-9]+', Number.Integer),
|
| 86 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 87 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 88 |
+
]
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
def analyse_text(text):
|
| 92 |
+
"""We're searching for a common function and a unique keyword here."""
|
| 93 |
+
if 'SinOsc' in text or 'thisFunctionDef' in text:
|
| 94 |
+
return 0.1
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/tablegen.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.tablegen
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for LLVM's TableGen DSL.
|
| 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, using
|
| 12 |
+
from pygments.lexers.c_cpp import CppLexer
|
| 13 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 14 |
+
Punctuation, String, Text, Whitespace, Error
|
| 15 |
+
|
| 16 |
+
__all__ = ['TableGenLexer']
|
| 17 |
+
|
| 18 |
+
KEYWORDS = (
|
| 19 |
+
'assert',
|
| 20 |
+
'class',
|
| 21 |
+
'code',
|
| 22 |
+
'def',
|
| 23 |
+
'dump',
|
| 24 |
+
'else',
|
| 25 |
+
'foreach',
|
| 26 |
+
'defm',
|
| 27 |
+
'defset',
|
| 28 |
+
'defvar',
|
| 29 |
+
'field',
|
| 30 |
+
'if',
|
| 31 |
+
'in',
|
| 32 |
+
'include',
|
| 33 |
+
'let',
|
| 34 |
+
'multiclass',
|
| 35 |
+
'then',
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
KEYWORDS_CONST = (
|
| 39 |
+
'false',
|
| 40 |
+
'true',
|
| 41 |
+
)
|
| 42 |
+
KEYWORDS_TYPE = (
|
| 43 |
+
'bit',
|
| 44 |
+
'bits',
|
| 45 |
+
'dag',
|
| 46 |
+
'int',
|
| 47 |
+
'list',
|
| 48 |
+
'string',
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
BANG_OPERATORS = (
|
| 52 |
+
'add',
|
| 53 |
+
'and',
|
| 54 |
+
'cast',
|
| 55 |
+
'con',
|
| 56 |
+
'cond',
|
| 57 |
+
'dag',
|
| 58 |
+
'div',
|
| 59 |
+
'empty',
|
| 60 |
+
'eq',
|
| 61 |
+
'exists',
|
| 62 |
+
'filter',
|
| 63 |
+
'find',
|
| 64 |
+
'foldl',
|
| 65 |
+
'foreach',
|
| 66 |
+
'ge',
|
| 67 |
+
'getdagarg',
|
| 68 |
+
'getdagname',
|
| 69 |
+
'getdagop',
|
| 70 |
+
'gt',
|
| 71 |
+
'head',
|
| 72 |
+
'if',
|
| 73 |
+
'interleave',
|
| 74 |
+
'isa',
|
| 75 |
+
'le',
|
| 76 |
+
'listconcat',
|
| 77 |
+
'listremove',
|
| 78 |
+
'listsplat',
|
| 79 |
+
'logtwo',
|
| 80 |
+
'lt',
|
| 81 |
+
'mul',
|
| 82 |
+
'ne',
|
| 83 |
+
'not',
|
| 84 |
+
'or',
|
| 85 |
+
'range',
|
| 86 |
+
'repr',
|
| 87 |
+
'setdagarg',
|
| 88 |
+
'setdagname',
|
| 89 |
+
'setdagop',
|
| 90 |
+
'shl',
|
| 91 |
+
'size',
|
| 92 |
+
'sra',
|
| 93 |
+
'srl',
|
| 94 |
+
'strconcat',
|
| 95 |
+
'sub',
|
| 96 |
+
'subst',
|
| 97 |
+
'substr',
|
| 98 |
+
'tail',
|
| 99 |
+
'tolower',
|
| 100 |
+
'toupper',
|
| 101 |
+
'xor',
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
class TableGenLexer(RegexLexer):
|
| 105 |
+
"""
|
| 106 |
+
Lexer for TableGen
|
| 107 |
+
"""
|
| 108 |
+
|
| 109 |
+
name = 'TableGen'
|
| 110 |
+
url = 'https://llvm.org/docs/TableGen/ProgRef.html'
|
| 111 |
+
aliases = ['tablegen', 'td']
|
| 112 |
+
filenames = ['*.td']
|
| 113 |
+
|
| 114 |
+
version_added = '2.19'
|
| 115 |
+
|
| 116 |
+
tokens = {
|
| 117 |
+
'root': [
|
| 118 |
+
(r'\s+', Whitespace),
|
| 119 |
+
|
| 120 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 121 |
+
(r'//.*?$', Comment.Single),
|
| 122 |
+
(r'#(define|ifdef|ifndef|else|endif)', Comment.Preproc),
|
| 123 |
+
|
| 124 |
+
# Binary/hex numbers. Note that these take priority over names,
|
| 125 |
+
# which may begin with numbers.
|
| 126 |
+
(r'0b[10]+', Number.Bin),
|
| 127 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 128 |
+
|
| 129 |
+
# Keywords
|
| 130 |
+
(words(KEYWORDS, suffix=r'\b'), Keyword),
|
| 131 |
+
(words(KEYWORDS_CONST, suffix=r'\b'), Keyword.Constant),
|
| 132 |
+
(words(KEYWORDS_TYPE, suffix=r'\b'), Keyword.Type),
|
| 133 |
+
|
| 134 |
+
# Bang operators
|
| 135 |
+
(words(BANG_OPERATORS, prefix=r'\!', suffix=r'\b'), Operator),
|
| 136 |
+
# Unknown bang operators are an error
|
| 137 |
+
(r'![a-zA-Z]+', Error),
|
| 138 |
+
|
| 139 |
+
# Names and identifiers
|
| 140 |
+
(r'[0-9]*[a-zA-Z_][a-zA-Z_0-9]*', Name),
|
| 141 |
+
(r'\$[a-zA-Z_][a-zA-Z_0-9]*', Name.Variable),
|
| 142 |
+
|
| 143 |
+
# Place numbers after keywords. Names/identifiers may begin with
|
| 144 |
+
# numbers, and we want to parse 1X as one name token as opposed to
|
| 145 |
+
# a number and a name.
|
| 146 |
+
(r'[-\+]?[0-9]+', Number.Integer),
|
| 147 |
+
|
| 148 |
+
# String literals
|
| 149 |
+
(r'"', String, 'dqs'),
|
| 150 |
+
(r'\[\{', Punctuation, 'codeblock'),
|
| 151 |
+
|
| 152 |
+
# Misc. punctuation
|
| 153 |
+
(r'[-+\[\]{}()<>\.,;:=?#]+', Punctuation),
|
| 154 |
+
],
|
| 155 |
+
'comment': [
|
| 156 |
+
(r'[^*/]+', Comment.Multiline),
|
| 157 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 158 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 159 |
+
(r'[*/]', Comment.Multiline)
|
| 160 |
+
],
|
| 161 |
+
'strings': [
|
| 162 |
+
(r'\\[\\\'"tn]', String.Escape),
|
| 163 |
+
(r'[^\\"]+', String),
|
| 164 |
+
],
|
| 165 |
+
# Double-quoted string, a la C
|
| 166 |
+
'dqs': [
|
| 167 |
+
(r'"', String, '#pop'),
|
| 168 |
+
include('strings'),
|
| 169 |
+
],
|
| 170 |
+
# NOTE: Must escape (pop Cpplexer) codeblock to avoid infinite loop.
|
| 171 |
+
# Assume that the code inside a code block is C++. This isn't always
|
| 172 |
+
# true in TableGen, but is the far most common scenario.
|
| 173 |
+
'codeblock': [
|
| 174 |
+
(r'\}\]', Text, '#pop'),
|
| 175 |
+
(r'([^}]+|\}[^]])*', using(CppLexer), "#pop"),
|
| 176 |
+
],
|
| 177 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/tact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| 11 |
+
from pygments.lexer import RegexLexer, include, bygroups, words
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Whitespace, Punctuation
|
| 14 |
+
|
| 15 |
+
__all__ = ['TactLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class TactLexer(RegexLexer):
|
| 19 |
+
"""For Tact source code."""
|
| 20 |
+
|
| 21 |
+
name = 'Tact'
|
| 22 |
+
aliases = ['tact']
|
| 23 |
+
filenames = ['*.tact']
|
| 24 |
+
url = "https://tact-lang.org"
|
| 25 |
+
version_added = '2.18'
|
| 26 |
+
|
| 27 |
+
tokens = {
|
| 28 |
+
'root': [
|
| 29 |
+
(r'\s+', Whitespace),
|
| 30 |
+
(r'[.;(),\[\]{}]', Punctuation),
|
| 31 |
+
(r'\?|!!', Operator),
|
| 32 |
+
include('comments'),
|
| 33 |
+
include('import-in'),
|
| 34 |
+
include('struct-in'),
|
| 35 |
+
include('contract-or-trait-in'),
|
| 36 |
+
include('annotation-in'),
|
| 37 |
+
include('fun-declaration-in'),
|
| 38 |
+
include('const-declaration-in'),
|
| 39 |
+
include('statements'),
|
| 40 |
+
],
|
| 41 |
+
'import-in': [
|
| 42 |
+
(r'((?<=\.\.\.)|(?<![.$]))\b(import)\b(\s*)', bygroups(Punctuation, Keyword, Whitespace), 'import'),
|
| 43 |
+
],
|
| 44 |
+
'import': [
|
| 45 |
+
(r';', Punctuation, '#pop'),
|
| 46 |
+
include('comments'),
|
| 47 |
+
include('string-in'),
|
| 48 |
+
(r'\s+', Whitespace),
|
| 49 |
+
],
|
| 50 |
+
'struct-in': [
|
| 51 |
+
(r'((?<=\.\.\.)|(?<![.$]))\b(struct|message)\b', bygroups(Punctuation, Keyword), 'struct'),
|
| 52 |
+
],
|
| 53 |
+
'struct': [
|
| 54 |
+
include('comments'),
|
| 55 |
+
include('struct-header'),
|
| 56 |
+
include('struct-body-in'),
|
| 57 |
+
(r'\s+', Whitespace),
|
| 58 |
+
],
|
| 59 |
+
'struct-header': [
|
| 60 |
+
include('comments'),
|
| 61 |
+
(r'\b\w+', Name.Class),
|
| 62 |
+
(r'(\()((?:\b0[xX])[0-9a-fA-F][0-9a-fA-F_]*\b)(\))', bygroups(Punctuation, Number.Hex, Punctuation)),
|
| 63 |
+
(r'(\()((?:\b[0-9]+\b))(\))', bygroups(Punctuation, Number.Integer, Punctuation)),
|
| 64 |
+
],
|
| 65 |
+
'struct-body-in': [
|
| 66 |
+
(r'\{', Punctuation, 'struct-body'),
|
| 67 |
+
],
|
| 68 |
+
'struct-body': [
|
| 69 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 70 |
+
include('comments'),
|
| 71 |
+
include('field-declaration-in'),
|
| 72 |
+
],
|
| 73 |
+
'contract-or-trait-in': [
|
| 74 |
+
(r'((?<=\.\.\.)|(?<![.$]))\b(contract|trait)\b', Keyword, 'contract-or-trait'),
|
| 75 |
+
],
|
| 76 |
+
'contract-or-trait': [
|
| 77 |
+
include('comments'),
|
| 78 |
+
(r'with', Keyword),
|
| 79 |
+
(r'\b\w+', Name.Class),
|
| 80 |
+
include('contract-or-trait-body-in'),
|
| 81 |
+
(r'\s+', Whitespace),
|
| 82 |
+
(r',', Punctuation),
|
| 83 |
+
],
|
| 84 |
+
'contract-or-trait-body-in': [
|
| 85 |
+
(r'\{', Punctuation, 'contract-or-trait-body'),
|
| 86 |
+
],
|
| 87 |
+
'contract-or-trait-body': [
|
| 88 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 89 |
+
include('comments'),
|
| 90 |
+
include('init-declaration-in'),
|
| 91 |
+
include('receive-declaration-in'),
|
| 92 |
+
include('bounce-declaration-in'),
|
| 93 |
+
include('fun-declaration-in'),
|
| 94 |
+
include('const-declaration-in'),
|
| 95 |
+
include('field-declaration-in'),
|
| 96 |
+
(r'\s+', Whitespace),
|
| 97 |
+
],
|
| 98 |
+
'field-declaration-in': [
|
| 99 |
+
(r'\b\w+', Name.Property, 'field-declaration'),
|
| 100 |
+
],
|
| 101 |
+
'field-declaration': [
|
| 102 |
+
(r';', Punctuation, '#pop'),
|
| 103 |
+
include('comments'),
|
| 104 |
+
include('type-annotation-in'),
|
| 105 |
+
include('variable-init-in'),
|
| 106 |
+
],
|
| 107 |
+
'const-declaration-in': [
|
| 108 |
+
(r'(?=\b(?:(?:get|native|extends|mutates|virtual|override|inline|abstract)\s*)*const\b)', Keyword, 'const-declaration'),
|
| 109 |
+
],
|
| 110 |
+
'const-declaration': [
|
| 111 |
+
(r'(;)', Punctuation, '#pop'),
|
| 112 |
+
(r'const', Keyword),
|
| 113 |
+
(words(('get', 'native', 'extends', 'mutates', 'virtual', 'override', 'inline', 'abstract'), suffix=r'\b'), Keyword),
|
| 114 |
+
(r'\b\w+\b', Name.Constant),
|
| 115 |
+
include('comments'),
|
| 116 |
+
include('type-annotation-in'),
|
| 117 |
+
include('variable-init-in'),
|
| 118 |
+
(r'\s+', Whitespace),
|
| 119 |
+
],
|
| 120 |
+
'init-declaration-in': [
|
| 121 |
+
(r'(init)', Keyword, 'init-declaration')
|
| 122 |
+
],
|
| 123 |
+
'init-declaration': [
|
| 124 |
+
(r'(?<=\})', Punctuation, '#pop'),
|
| 125 |
+
include('comments'),
|
| 126 |
+
include('fun-arguments-in'),
|
| 127 |
+
include('block-declaration-in'),
|
| 128 |
+
(r'\s+', Whitespace),
|
| 129 |
+
],
|
| 130 |
+
'receive-declaration-in': [
|
| 131 |
+
(r'(receive|exernal)', Keyword, 'receive-declaration')
|
| 132 |
+
],
|
| 133 |
+
'receive-declaration': [
|
| 134 |
+
(r'(?<=\})', Punctuation, '#pop'),
|
| 135 |
+
include('comments'),
|
| 136 |
+
include('fun-arguments-in'),
|
| 137 |
+
include('block-declaration-in'),
|
| 138 |
+
],
|
| 139 |
+
'bounce-declaration-in': [
|
| 140 |
+
(r'(bounced)', Keyword, 'bounce-declaration')
|
| 141 |
+
],
|
| 142 |
+
'bounce-declaration': [
|
| 143 |
+
(r'(?<=\})', Punctuation, '#pop'),
|
| 144 |
+
include('comments'),
|
| 145 |
+
include('fun-arguments-in'),
|
| 146 |
+
include('block-declaration-in'),
|
| 147 |
+
],
|
| 148 |
+
'fun-declaration-in': [
|
| 149 |
+
(r'(?=\b(?:(?:get|native|extends|mutates|virtual|override|inline|abstract)\s*)*fun\b)', Keyword, 'fun-declaration')
|
| 150 |
+
],
|
| 151 |
+
'fun-declaration': [
|
| 152 |
+
(r'(?<=\}|\;)', Punctuation, '#pop'),
|
| 153 |
+
(r'fun', Keyword),
|
| 154 |
+
(r'\b(get|native|extends|mutates|virtual|override|inline|abstract)\b', Keyword),
|
| 155 |
+
(r'\b[\w]+', Name.Function),
|
| 156 |
+
include('fun-declaration-body'),
|
| 157 |
+
(r'[,;]', Punctuation),
|
| 158 |
+
],
|
| 159 |
+
'fun-declaration-body': [
|
| 160 |
+
include('comments'),
|
| 161 |
+
include('fun-arguments-in'),
|
| 162 |
+
include('type-annotation-in'),
|
| 163 |
+
include('block-declaration-in'),
|
| 164 |
+
(r'\s+', Whitespace),
|
| 165 |
+
],
|
| 166 |
+
'fun-arguments-in': [
|
| 167 |
+
(r'\(', Punctuation, 'fun-arguments'),
|
| 168 |
+
],
|
| 169 |
+
'fun-arguments': [
|
| 170 |
+
(r'\)', Punctuation, '#pop'),
|
| 171 |
+
include('comments'),
|
| 172 |
+
include('string-in'),
|
| 173 |
+
include('type-annotation-in'),
|
| 174 |
+
(r'(self)|(\b[\w]+\b)', bygroups(Name.Variable.Instance, Name.Variable)),
|
| 175 |
+
(r',', Punctuation),
|
| 176 |
+
(r'\s+', Whitespace),
|
| 177 |
+
],
|
| 178 |
+
'block-declaration-in': [
|
| 179 |
+
(r'\{', Punctuation, 'block-declaration')
|
| 180 |
+
],
|
| 181 |
+
'block-declaration': [
|
| 182 |
+
(r'\}', Punctuation, '#pop'),
|
| 183 |
+
include('statements'),
|
| 184 |
+
],
|
| 185 |
+
'statements': [
|
| 186 |
+
include('comments'),
|
| 187 |
+
include('block-declaration-in'),
|
| 188 |
+
include('expressions'),
|
| 189 |
+
],
|
| 190 |
+
'annotation-in': [
|
| 191 |
+
(r'(@)(\w+)(\()', bygroups(Keyword.Pseudo, Keyword, Punctuation), 'annotation')
|
| 192 |
+
],
|
| 193 |
+
'annotation': [
|
| 194 |
+
(r'\)', Punctuation, '#pop'),
|
| 195 |
+
include('annotation-argument'),
|
| 196 |
+
(r'\s+', Whitespace),
|
| 197 |
+
],
|
| 198 |
+
'annotation-argument': [
|
| 199 |
+
(r'\w+', Name.Function.Magic),
|
| 200 |
+
],
|
| 201 |
+
'expressions': [
|
| 202 |
+
include('comments'),
|
| 203 |
+
include('type-annotation-in'),
|
| 204 |
+
include('keywords'),
|
| 205 |
+
include('numeric'),
|
| 206 |
+
include('string-in'),
|
| 207 |
+
include('variable'),
|
| 208 |
+
include('function-call'),
|
| 209 |
+
include('struct-init-in'),
|
| 210 |
+
],
|
| 211 |
+
'struct-init-in': [
|
| 212 |
+
(r'(\b\w+)(\s*)(\{)', bygroups(Name.Class, Whitespace, Punctuation), 'struct-init')
|
| 213 |
+
],
|
| 214 |
+
'struct-init': [
|
| 215 |
+
(r'(\})', Punctuation, '#pop'),
|
| 216 |
+
include('comments'),
|
| 217 |
+
include('struct-property-in'),
|
| 218 |
+
(r'\s+', Whitespace),
|
| 219 |
+
(r',', Punctuation),
|
| 220 |
+
],
|
| 221 |
+
'struct-property-in': [
|
| 222 |
+
(r'(\b[\w]+)(\s*)(:)', bygroups(Name.Property, Whitespace, Punctuation), 'struct-property')
|
| 223 |
+
],
|
| 224 |
+
'struct-property': [
|
| 225 |
+
(r'(?=\}|\,)', Punctuation, '#pop'),
|
| 226 |
+
include('comments'),
|
| 227 |
+
include('expressions'),
|
| 228 |
+
(r'\s+', Whitespace),
|
| 229 |
+
],
|
| 230 |
+
'variable-init-in': [
|
| 231 |
+
(r'(=)', Operator, 'variable-init')
|
| 232 |
+
],
|
| 233 |
+
'variable-init': [
|
| 234 |
+
(r'(?=\}|\{|\,|\;)',Punctuation, '#pop'),
|
| 235 |
+
include('comments'),
|
| 236 |
+
include('expressions'),
|
| 237 |
+
(r'\s+', Whitespace),
|
| 238 |
+
],
|
| 239 |
+
'type-annotation-in': [
|
| 240 |
+
(r'(:)(\s+)', bygroups(Punctuation, Whitespace), 'type-annotation')
|
| 241 |
+
],
|
| 242 |
+
'type-annotation': [
|
| 243 |
+
(r'(?=\{|\;|\=|\,|\))', Punctuation, '#pop'),
|
| 244 |
+
include('comments'),
|
| 245 |
+
include('type-as-in'),
|
| 246 |
+
include('type-generic-in'),
|
| 247 |
+
(r'\?', Operator),
|
| 248 |
+
(r'\b\w+', Keyword.Type),
|
| 249 |
+
(r'\s+', Whitespace),
|
| 250 |
+
],
|
| 251 |
+
'type-generic-in': [
|
| 252 |
+
(r'<', Punctuation, 'type-generic'),
|
| 253 |
+
],
|
| 254 |
+
'type-generic': [
|
| 255 |
+
(r'>', Punctuation, '#pop'),
|
| 256 |
+
include('comments'),
|
| 257 |
+
include('type-as-in'),
|
| 258 |
+
(r'\b\w+', Keyword.Type),
|
| 259 |
+
(r'\s+', Whitespace),
|
| 260 |
+
(r',', Punctuation),
|
| 261 |
+
],
|
| 262 |
+
'type-as-in': [
|
| 263 |
+
(r'\b(as)(\s+)', bygroups(Keyword, Whitespace), 'type-as'),
|
| 264 |
+
],
|
| 265 |
+
'type-as': [
|
| 266 |
+
(r'(?=\{|\;|\=|\,|\)|\>)', Punctuation, '#pop'),
|
| 267 |
+
include('comments'),
|
| 268 |
+
(r'\b\w+', Keyword.Type),
|
| 269 |
+
(r'\s+', Whitespace),
|
| 270 |
+
],
|
| 271 |
+
'keywords': [
|
| 272 |
+
(words(('if', 'else', 'while', 'do', 'until', 'repeat', 'return', 'extends', 'mutates', 'virtual', 'override', 'inline', 'native', 'let', 'const', 'fun', 'self', 'is', 'initOf', 'map', 'bounced', 'get', 'as'), prefix=r'\b', suffix=r'\b'), Keyword),
|
| 273 |
+
(r'(<=>|>=|<=|!=|==|\^>>|~>>|>>|<<|\/%|\^%|~%|\^\/|~\/|\+=|-=|\*=|\/=|~\/=|\^\/=|%=|\^%=|<<=|>>=|~>>=|\^>>=|&=|\|=|\^=|\^|=|~|\/|%|-|\*|\+|>|<|&|\||:|\?)', Operator),
|
| 274 |
+
(words(('true', 'false'), prefix=r'\b', suffix=r'\b'), Keyword.Constant),
|
| 275 |
+
],
|
| 276 |
+
'string-in': [
|
| 277 |
+
(r'"', String, 'string'),
|
| 278 |
+
],
|
| 279 |
+
'string': [
|
| 280 |
+
(r'"', String, '#pop'),
|
| 281 |
+
(r'\\.', String.Escape),
|
| 282 |
+
(r'[^\\"]+', String.Double),
|
| 283 |
+
],
|
| 284 |
+
'numeric': [
|
| 285 |
+
(r'(?:\b0[xX])[0-9a-fA-F][0-9a-fA-F_]*\b', Number.Hex),
|
| 286 |
+
(r'(?:\b[0-9]+\b)', Number.Integer),
|
| 287 |
+
],
|
| 288 |
+
'comments': [
|
| 289 |
+
(r'//.*', Comment.Single),
|
| 290 |
+
(r'/\*', Comment.Multiline, 'comments-multiline'),
|
| 291 |
+
],
|
| 292 |
+
'comments-multiline': [
|
| 293 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 294 |
+
(r'[^*]+', Comment.Multiline),
|
| 295 |
+
(r'[*]', Comment.Multiline),
|
| 296 |
+
],
|
| 297 |
+
'variable': [
|
| 298 |
+
(r'\b\w+\b(?!\s*\()(?!\s*\{)', Name.Variable)
|
| 299 |
+
],
|
| 300 |
+
'function-call': [
|
| 301 |
+
(r'\b\w+\b(?=\s*\()(?!\s*\{)', Name.Function)
|
| 302 |
+
],
|
| 303 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/tal.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.tal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Uxntal
|
| 6 |
+
|
| 7 |
+
.. versionadded:: 2.12
|
| 8 |
+
|
| 9 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 10 |
+
:license: BSD, see LICENSE for details.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, words
|
| 14 |
+
from pygments.token import Comment, Keyword, Name, String, Number, \
|
| 15 |
+
Punctuation, Whitespace, Literal
|
| 16 |
+
|
| 17 |
+
__all__ = ['TalLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class TalLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For Uxntal source code.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
name = 'Tal'
|
| 26 |
+
aliases = ['tal', 'uxntal']
|
| 27 |
+
filenames = ['*.tal']
|
| 28 |
+
mimetypes = ['text/x-uxntal']
|
| 29 |
+
url = 'https://wiki.xxiivv.com/site/uxntal.html'
|
| 30 |
+
version_added = '2.12'
|
| 31 |
+
|
| 32 |
+
instructions = [
|
| 33 |
+
'BRK', 'LIT', 'INC', 'POP', 'DUP', 'NIP', 'SWP', 'OVR', 'ROT',
|
| 34 |
+
'EQU', 'NEQ', 'GTH', 'LTH', 'JMP', 'JCN', 'JSR', 'STH',
|
| 35 |
+
'LDZ', 'STZ', 'LDR', 'STR', 'LDA', 'STA', 'DEI', 'DEO',
|
| 36 |
+
'ADD', 'SUB', 'MUL', 'DIV', 'AND', 'ORA', 'EOR', 'SFT'
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
tokens = {
|
| 40 |
+
# the comment delimiters must not be adjacent to non-space characters.
|
| 41 |
+
# this means ( foo ) is a valid comment but (foo) is not. this also
|
| 42 |
+
# applies to nested comments.
|
| 43 |
+
'comment': [
|
| 44 |
+
(r'(?<!\S)\((?!\S)', Comment.Multiline, '#push'), # nested comments
|
| 45 |
+
(r'(?<!\S)\)(?!\S)', Comment.Multiline, '#pop'), # nested comments
|
| 46 |
+
(r'[^()]+', Comment.Multiline), # comments
|
| 47 |
+
(r'[()]+', Comment.Multiline), # comments
|
| 48 |
+
],
|
| 49 |
+
'root': [
|
| 50 |
+
(r'\s+', Whitespace), # spaces
|
| 51 |
+
(r'(?<!\S)\((?!\S)', Comment.Multiline, 'comment'), # comments
|
| 52 |
+
(words(instructions, prefix=r'(?<!\S)', suffix=r'2?k?r?(?!\S)'),
|
| 53 |
+
Keyword.Reserved), # instructions
|
| 54 |
+
(r'[][{}](?!\S)', Punctuation), # delimiters
|
| 55 |
+
(r'#([0-9a-f]{2}){1,2}(?!\S)', Number.Hex), # integer
|
| 56 |
+
(r'"\S+', String), # raw string
|
| 57 |
+
(r'([0-9a-f]{2}){1,2}(?!\S)', Literal), # raw integer
|
| 58 |
+
(r'[|$][0-9a-f]{1,4}(?!\S)', Keyword.Declaration), # abs/rel pad
|
| 59 |
+
(r'%\S+', Name.Decorator), # macro
|
| 60 |
+
(r'@\S+', Name.Function), # label
|
| 61 |
+
(r'&\S+', Name.Label), # sublabel
|
| 62 |
+
(r'/\S+', Name.Tag), # spacer
|
| 63 |
+
(r'\.\S+', Name.Variable.Magic), # literal zero page addr
|
| 64 |
+
(r',\S+', Name.Variable.Instance), # literal rel addr
|
| 65 |
+
(r';\S+', Name.Variable.Global), # literal abs addr
|
| 66 |
+
(r'-\S+', Literal), # raw zero page addr
|
| 67 |
+
(r'_\S+', Literal), # raw relative addr
|
| 68 |
+
(r'=\S+', Literal), # raw absolute addr
|
| 69 |
+
(r'!\S+', Name.Function), # immediate jump
|
| 70 |
+
(r'\?\S+', Name.Function), # conditional immediate jump
|
| 71 |
+
(r'~\S+', Keyword.Namespace), # include
|
| 72 |
+
(r'\S+', Name.Function), # macro invocation, immediate subroutine
|
| 73 |
+
]
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
def analyse_text(text):
|
| 77 |
+
return '|0100' in text[:500]
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/tcl.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.tcl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Tcl 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, include, words
|
| 12 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Whitespace
|
| 14 |
+
from pygments.util import shebang_matches
|
| 15 |
+
|
| 16 |
+
__all__ = ['TclLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class TclLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
For Tcl source code.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
keyword_cmds_re = words((
|
| 25 |
+
'after', 'apply', 'array', 'break', 'catch', 'continue', 'elseif',
|
| 26 |
+
'else', 'error', 'eval', 'expr', 'for', 'foreach', 'global', 'if',
|
| 27 |
+
'namespace', 'proc', 'rename', 'return', 'set', 'switch', 'then',
|
| 28 |
+
'trace', 'unset', 'update', 'uplevel', 'upvar', 'variable', 'vwait',
|
| 29 |
+
'while'), prefix=r'\b', suffix=r'\b')
|
| 30 |
+
|
| 31 |
+
builtin_cmds_re = words((
|
| 32 |
+
'append', 'bgerror', 'binary', 'cd', 'chan', 'clock', 'close',
|
| 33 |
+
'concat', 'dde', 'dict', 'encoding', 'eof', 'exec', 'exit', 'fblocked',
|
| 34 |
+
'fconfigure', 'fcopy', 'file', 'fileevent', 'flush', 'format', 'gets',
|
| 35 |
+
'glob', 'history', 'http', 'incr', 'info', 'interp', 'join', 'lappend',
|
| 36 |
+
'lassign', 'lindex', 'linsert', 'list', 'llength', 'load', 'loadTk',
|
| 37 |
+
'lrange', 'lrepeat', 'lreplace', 'lreverse', 'lsearch', 'lset', 'lsort',
|
| 38 |
+
'mathfunc', 'mathop', 'memory', 'msgcat', 'open', 'package', 'pid',
|
| 39 |
+
'pkg::create', 'pkg_mkIndex', 'platform', 'platform::shell', 'puts',
|
| 40 |
+
'pwd', 're_syntax', 'read', 'refchan', 'regexp', 'registry', 'regsub',
|
| 41 |
+
'scan', 'seek', 'socket', 'source', 'split', 'string', 'subst', 'tell',
|
| 42 |
+
'time', 'tm', 'unknown', 'unload'), prefix=r'\b', suffix=r'\b')
|
| 43 |
+
|
| 44 |
+
name = 'Tcl'
|
| 45 |
+
url = 'https://www.tcl.tk/about/language.html'
|
| 46 |
+
aliases = ['tcl']
|
| 47 |
+
filenames = ['*.tcl', '*.rvt']
|
| 48 |
+
mimetypes = ['text/x-tcl', 'text/x-script.tcl', 'application/x-tcl']
|
| 49 |
+
version_added = '0.10'
|
| 50 |
+
|
| 51 |
+
def _gen_command_rules(keyword_cmds_re, builtin_cmds_re, context=""):
|
| 52 |
+
return [
|
| 53 |
+
(keyword_cmds_re, Keyword, 'params' + context),
|
| 54 |
+
(builtin_cmds_re, Name.Builtin, 'params' + context),
|
| 55 |
+
(r'([\w.-]+)', Name.Variable, 'params' + context),
|
| 56 |
+
(r'#', Comment, 'comment'),
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
+
tokens = {
|
| 60 |
+
'root': [
|
| 61 |
+
include('command'),
|
| 62 |
+
include('basic'),
|
| 63 |
+
include('data'),
|
| 64 |
+
(r'\}', Keyword), # HACK: somehow we miscounted our braces
|
| 65 |
+
],
|
| 66 |
+
'command': _gen_command_rules(keyword_cmds_re, builtin_cmds_re),
|
| 67 |
+
'command-in-brace': _gen_command_rules(keyword_cmds_re,
|
| 68 |
+
builtin_cmds_re,
|
| 69 |
+
"-in-brace"),
|
| 70 |
+
'command-in-bracket': _gen_command_rules(keyword_cmds_re,
|
| 71 |
+
builtin_cmds_re,
|
| 72 |
+
"-in-bracket"),
|
| 73 |
+
'command-in-paren': _gen_command_rules(keyword_cmds_re,
|
| 74 |
+
builtin_cmds_re,
|
| 75 |
+
"-in-paren"),
|
| 76 |
+
'basic': [
|
| 77 |
+
(r'\(', Keyword, 'paren'),
|
| 78 |
+
(r'\[', Keyword, 'bracket'),
|
| 79 |
+
(r'\{', Keyword, 'brace'),
|
| 80 |
+
(r'"', String.Double, 'string'),
|
| 81 |
+
(r'(eq|ne|in|ni)\b', Operator.Word),
|
| 82 |
+
(r'!=|==|<<|>>|<=|>=|&&|\|\||\*\*|[-+~!*/%<>&^|?:]', Operator),
|
| 83 |
+
],
|
| 84 |
+
'data': [
|
| 85 |
+
(r'\s+', Whitespace),
|
| 86 |
+
(r'0x[a-fA-F0-9]+', Number.Hex),
|
| 87 |
+
(r'0[0-7]+', Number.Oct),
|
| 88 |
+
(r'\d+\.\d+', Number.Float),
|
| 89 |
+
(r'\d+', Number.Integer),
|
| 90 |
+
(r'\$[\w.:-]+', Name.Variable),
|
| 91 |
+
(r'\$\{[\w.:-]+\}', Name.Variable),
|
| 92 |
+
(r'[\w.,@:-]+', Text),
|
| 93 |
+
],
|
| 94 |
+
'params': [
|
| 95 |
+
(r';', Keyword, '#pop'),
|
| 96 |
+
(r'\n', Text, '#pop'),
|
| 97 |
+
(r'(else|elseif|then)\b', Keyword),
|
| 98 |
+
include('basic'),
|
| 99 |
+
include('data'),
|
| 100 |
+
],
|
| 101 |
+
'params-in-brace': [
|
| 102 |
+
(r'\}', Keyword, ('#pop', '#pop')),
|
| 103 |
+
include('params')
|
| 104 |
+
],
|
| 105 |
+
'params-in-paren': [
|
| 106 |
+
(r'\)', Keyword, ('#pop', '#pop')),
|
| 107 |
+
include('params')
|
| 108 |
+
],
|
| 109 |
+
'params-in-bracket': [
|
| 110 |
+
(r'\]', Keyword, ('#pop', '#pop')),
|
| 111 |
+
include('params')
|
| 112 |
+
],
|
| 113 |
+
'string': [
|
| 114 |
+
(r'\[', String.Double, 'string-square'),
|
| 115 |
+
(r'(?s)(\\\\|\\[0-7]+|\\.|[^"\\])', String.Double),
|
| 116 |
+
(r'"', String.Double, '#pop')
|
| 117 |
+
],
|
| 118 |
+
'string-square': [
|
| 119 |
+
(r'\[', String.Double, 'string-square'),
|
| 120 |
+
(r'(?s)(\\\\|\\[0-7]+|\\.|\\\n|[^\]\\])', String.Double),
|
| 121 |
+
(r'\]', String.Double, '#pop')
|
| 122 |
+
],
|
| 123 |
+
'brace': [
|
| 124 |
+
(r'\}', Keyword, '#pop'),
|
| 125 |
+
include('command-in-brace'),
|
| 126 |
+
include('basic'),
|
| 127 |
+
include('data'),
|
| 128 |
+
],
|
| 129 |
+
'paren': [
|
| 130 |
+
(r'\)', Keyword, '#pop'),
|
| 131 |
+
include('command-in-paren'),
|
| 132 |
+
include('basic'),
|
| 133 |
+
include('data'),
|
| 134 |
+
],
|
| 135 |
+
'bracket': [
|
| 136 |
+
(r'\]', Keyword, '#pop'),
|
| 137 |
+
include('command-in-bracket'),
|
| 138 |
+
include('basic'),
|
| 139 |
+
include('data'),
|
| 140 |
+
],
|
| 141 |
+
'comment': [
|
| 142 |
+
(r'.*[^\\]\n', Comment, '#pop'),
|
| 143 |
+
(r'.*\\\n', Comment),
|
| 144 |
+
],
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
def analyse_text(text):
|
| 148 |
+
return shebang_matches(text, r'(tcl)')
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/teal.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.teal
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for TEAL.
|
| 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, words
|
| 12 |
+
from pygments.token import Comment, Name, Number, String, Text, Keyword, \
|
| 13 |
+
Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['TealLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class TealLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For the Transaction Execution Approval Language (TEAL)
|
| 21 |
+
|
| 22 |
+
For more information about the grammar, see:
|
| 23 |
+
https://github.com/algorand/go-algorand/blob/master/data/transactions/logic/assembler.go
|
| 24 |
+
"""
|
| 25 |
+
name = 'teal'
|
| 26 |
+
url = 'https://developer.algorand.org/docs/reference/teal/specification/'
|
| 27 |
+
aliases = ['teal']
|
| 28 |
+
filenames = ['*.teal']
|
| 29 |
+
version_added = '2.9'
|
| 30 |
+
|
| 31 |
+
keywords = words({
|
| 32 |
+
'Sender', 'Fee', 'FirstValid', 'FirstValidTime', 'LastValid', 'Note',
|
| 33 |
+
'Lease', 'Receiver', 'Amount', 'CloseRemainderTo', 'VotePK',
|
| 34 |
+
'SelectionPK', 'VoteFirst', 'VoteLast', 'VoteKeyDilution', 'Type',
|
| 35 |
+
'TypeEnum', 'XferAsset', 'AssetAmount', 'AssetSender', 'AssetReceiver',
|
| 36 |
+
'AssetCloseTo', 'GroupIndex', 'TxID', 'ApplicationID', 'OnCompletion',
|
| 37 |
+
'ApplicationArgs', 'NumAppArgs', 'Accounts', 'NumAccounts',
|
| 38 |
+
'ApprovalProgram', 'ClearStateProgram', 'RekeyTo', 'ConfigAsset',
|
| 39 |
+
'ConfigAssetTotal', 'ConfigAssetDecimals', 'ConfigAssetDefaultFrozen',
|
| 40 |
+
'ConfigAssetUnitName', 'ConfigAssetName', 'ConfigAssetURL',
|
| 41 |
+
'ConfigAssetMetadataHash', 'ConfigAssetManager', 'ConfigAssetReserve',
|
| 42 |
+
'ConfigAssetFreeze', 'ConfigAssetClawback', 'FreezeAsset',
|
| 43 |
+
'FreezeAssetAccount', 'FreezeAssetFrozen',
|
| 44 |
+
'NoOp', 'OptIn', 'CloseOut', 'ClearState', 'UpdateApplication',
|
| 45 |
+
'DeleteApplication',
|
| 46 |
+
'MinTxnFee', 'MinBalance', 'MaxTxnLife', 'ZeroAddress', 'GroupSize',
|
| 47 |
+
'LogicSigVersion', 'Round', 'LatestTimestamp', 'CurrentApplicationID',
|
| 48 |
+
'AssetBalance', 'AssetFrozen',
|
| 49 |
+
'AssetTotal', 'AssetDecimals', 'AssetDefaultFrozen', 'AssetUnitName',
|
| 50 |
+
'AssetName', 'AssetURL', 'AssetMetadataHash', 'AssetManager',
|
| 51 |
+
'AssetReserve', 'AssetFreeze', 'AssetClawback',
|
| 52 |
+
}, suffix=r'\b')
|
| 53 |
+
|
| 54 |
+
identifier = r'[^ \t\n]+(?=\/\/)|[^ \t\n]+'
|
| 55 |
+
newline = r'\r?\n'
|
| 56 |
+
tokens = {
|
| 57 |
+
'root': [
|
| 58 |
+
include('whitespace'),
|
| 59 |
+
# pragmas match specifically on the space character
|
| 60 |
+
(r'^#pragma .*' + newline, Comment.Directive),
|
| 61 |
+
# labels must be followed by a space,
|
| 62 |
+
# but anything after that is ignored
|
| 63 |
+
('(' + identifier + ':' + ')' + '([ \t].*)',
|
| 64 |
+
bygroups(Name.Label, Comment.Single)),
|
| 65 |
+
(identifier, Name.Function, 'function-args'),
|
| 66 |
+
],
|
| 67 |
+
'function-args': [
|
| 68 |
+
include('whitespace'),
|
| 69 |
+
(r'"', String, 'string'),
|
| 70 |
+
(r'(b(?:ase)?(?:32|64) ?)(\(?[a-zA-Z0-9+/=]+\)?)',
|
| 71 |
+
bygroups(String.Affix, String.Other)),
|
| 72 |
+
(r'[A-Z2-7]{58}', Number), # address
|
| 73 |
+
(r'0x[\da-fA-F]+', Number.Hex),
|
| 74 |
+
(r'\d+', Number.Integer),
|
| 75 |
+
(keywords, Keyword),
|
| 76 |
+
(identifier, Name.Attributes), # branch targets
|
| 77 |
+
(newline, Text, '#pop'),
|
| 78 |
+
],
|
| 79 |
+
'string': [
|
| 80 |
+
(r'\\(?:["nrt\\]|x\d\d)', String.Escape),
|
| 81 |
+
(r'[^\\\"\n]+', String),
|
| 82 |
+
(r'"', String, '#pop'),
|
| 83 |
+
],
|
| 84 |
+
'whitespace': [
|
| 85 |
+
(r'[ \t]+', Whitespace),
|
| 86 |
+
(r'//[^\n]+', Comment.Single),
|
| 87 |
+
],
|
| 88 |
+
}
|
.cache/uv/archive-v0/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ygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexers.html import HtmlLexer, XmlLexer
|
| 14 |
+
from pygments.lexers.javascript import JavascriptLexer, LassoLexer
|
| 15 |
+
from pygments.lexers.css import CssLexer
|
| 16 |
+
from pygments.lexers.php import PhpLexer
|
| 17 |
+
from pygments.lexers.python import PythonLexer
|
| 18 |
+
from pygments.lexers.perl import PerlLexer
|
| 19 |
+
from pygments.lexers.jvm import JavaLexer, TeaLangLexer
|
| 20 |
+
from pygments.lexers.data import YamlLexer
|
| 21 |
+
from pygments.lexers.sql import SqlLexer
|
| 22 |
+
from pygments.lexer import Lexer, DelegatingLexer, RegexLexer, bygroups, \
|
| 23 |
+
include, using, this, default, combined
|
| 24 |
+
from pygments.token import Error, Punctuation, Whitespace, \
|
| 25 |
+
Text, Comment, Operator, Keyword, Name, String, Number, Other, Token
|
| 26 |
+
from pygments.util import html_doctype_matches, looks_like_xml
|
| 27 |
+
|
| 28 |
+
__all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer',
|
| 29 |
+
'JavascriptPhpLexer', 'ErbLexer', 'RhtmlLexer',
|
| 30 |
+
'XmlErbLexer', 'CssErbLexer', 'JavascriptErbLexer',
|
| 31 |
+
'SmartyLexer', 'HtmlSmartyLexer', 'XmlSmartyLexer',
|
| 32 |
+
'CssSmartyLexer', 'JavascriptSmartyLexer', 'DjangoLexer',
|
| 33 |
+
'HtmlDjangoLexer', 'CssDjangoLexer', 'XmlDjangoLexer',
|
| 34 |
+
'JavascriptDjangoLexer', 'GenshiLexer', 'HtmlGenshiLexer',
|
| 35 |
+
'GenshiTextLexer', 'CssGenshiLexer', 'JavascriptGenshiLexer',
|
| 36 |
+
'MyghtyLexer', 'MyghtyHtmlLexer', 'MyghtyXmlLexer',
|
| 37 |
+
'MyghtyCssLexer', 'MyghtyJavascriptLexer', 'MasonLexer', 'MakoLexer',
|
| 38 |
+
'MakoHtmlLexer', 'MakoXmlLexer', 'MakoJavascriptLexer',
|
| 39 |
+
'MakoCssLexer', 'JspLexer', 'CheetahLexer', 'CheetahHtmlLexer',
|
| 40 |
+
'CheetahXmlLexer', 'CheetahJavascriptLexer', 'EvoqueLexer',
|
| 41 |
+
'EvoqueHtmlLexer', 'EvoqueXmlLexer', 'ColdfusionLexer',
|
| 42 |
+
'ColdfusionHtmlLexer', 'ColdfusionCFCLexer', 'VelocityLexer',
|
| 43 |
+
'VelocityHtmlLexer', 'VelocityXmlLexer', 'SspLexer',
|
| 44 |
+
'TeaTemplateLexer', 'LassoHtmlLexer', 'LassoXmlLexer',
|
| 45 |
+
'LassoCssLexer', 'LassoJavascriptLexer', 'HandlebarsLexer',
|
| 46 |
+
'HandlebarsHtmlLexer', 'YamlJinjaLexer', 'LiquidLexer',
|
| 47 |
+
'TwigLexer', 'TwigHtmlLexer', 'Angular2Lexer', 'Angular2HtmlLexer',
|
| 48 |
+
'SqlJinjaLexer']
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class ErbLexer(Lexer):
|
| 52 |
+
"""
|
| 53 |
+
Generic ERB (Ruby Templating) lexer.
|
| 54 |
+
|
| 55 |
+
Just highlights ruby code between the preprocessor directives, other data
|
| 56 |
+
is left untouched by the lexer.
|
| 57 |
+
|
| 58 |
+
All options are also forwarded to the `RubyLexer`.
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
name = 'ERB'
|
| 62 |
+
url = 'https://github.com/ruby/erb'
|
| 63 |
+
aliases = ['erb']
|
| 64 |
+
mimetypes = ['application/x-ruby-templating']
|
| 65 |
+
version_added = ''
|
| 66 |
+
|
| 67 |
+
_block_re = re.compile(r'(<%%|%%>|<%=|<%#|<%-|<%|-%>|%>|^%[^%].*?$)', re.M)
|
| 68 |
+
|
| 69 |
+
def __init__(self, **options):
|
| 70 |
+
from pygments.lexers.ruby import RubyLexer
|
| 71 |
+
self.ruby_lexer = RubyLexer(**options)
|
| 72 |
+
Lexer.__init__(self, **options)
|
| 73 |
+
|
| 74 |
+
def get_tokens_unprocessed(self, text):
|
| 75 |
+
"""
|
| 76 |
+
Since ERB doesn't allow "<%" and other tags inside of ruby
|
| 77 |
+
blocks we have to use a split approach here that fails for
|
| 78 |
+
that too.
|
| 79 |
+
"""
|
| 80 |
+
tokens = self._block_re.split(text)
|
| 81 |
+
tokens.reverse()
|
| 82 |
+
state = idx = 0
|
| 83 |
+
try:
|
| 84 |
+
while True:
|
| 85 |
+
# text
|
| 86 |
+
if state == 0:
|
| 87 |
+
val = tokens.pop()
|
| 88 |
+
yield idx, Other, val
|
| 89 |
+
idx += len(val)
|
| 90 |
+
state = 1
|
| 91 |
+
# block starts
|
| 92 |
+
elif state == 1:
|
| 93 |
+
tag = tokens.pop()
|
| 94 |
+
# literals
|
| 95 |
+
if tag in ('<%%', '%%>'):
|
| 96 |
+
yield idx, Other, tag
|
| 97 |
+
idx += 3
|
| 98 |
+
state = 0
|
| 99 |
+
# comment
|
| 100 |
+
elif tag == '<%#':
|
| 101 |
+
yield idx, Comment.Preproc, tag
|
| 102 |
+
val = tokens.pop()
|
| 103 |
+
yield idx + 3, Comment, val
|
| 104 |
+
idx += 3 + len(val)
|
| 105 |
+
state = 2
|
| 106 |
+
# blocks or output
|
| 107 |
+
elif tag in ('<%', '<%=', '<%-'):
|
| 108 |
+
yield idx, Comment.Preproc, tag
|
| 109 |
+
idx += len(tag)
|
| 110 |
+
data = tokens.pop()
|
| 111 |
+
r_idx = 0
|
| 112 |
+
for r_idx, r_token, r_value in \
|
| 113 |
+
self.ruby_lexer.get_tokens_unprocessed(data):
|
| 114 |
+
yield r_idx + idx, r_token, r_value
|
| 115 |
+
idx += len(data)
|
| 116 |
+
state = 2
|
| 117 |
+
elif tag in ('%>', '-%>'):
|
| 118 |
+
yield idx, Error, tag
|
| 119 |
+
idx += len(tag)
|
| 120 |
+
state = 0
|
| 121 |
+
# % raw ruby statements
|
| 122 |
+
else:
|
| 123 |
+
yield idx, Comment.Preproc, tag[0]
|
| 124 |
+
r_idx = 0
|
| 125 |
+
for r_idx, r_token, r_value in \
|
| 126 |
+
self.ruby_lexer.get_tokens_unprocessed(tag[1:]):
|
| 127 |
+
yield idx + 1 + r_idx, r_token, r_value
|
| 128 |
+
idx += len(tag)
|
| 129 |
+
state = 0
|
| 130 |
+
# block ends
|
| 131 |
+
elif state == 2:
|
| 132 |
+
tag = tokens.pop()
|
| 133 |
+
if tag not in ('%>', '-%>'):
|
| 134 |
+
yield idx, Other, tag
|
| 135 |
+
else:
|
| 136 |
+
yield idx, Comment.Preproc, tag
|
| 137 |
+
idx += len(tag)
|
| 138 |
+
state = 0
|
| 139 |
+
except IndexError:
|
| 140 |
+
return
|
| 141 |
+
|
| 142 |
+
def analyse_text(text):
|
| 143 |
+
if '<%' in text and '%>' in text:
|
| 144 |
+
return 0.4
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class SmartyLexer(RegexLexer):
|
| 148 |
+
"""
|
| 149 |
+
Generic Smarty template lexer.
|
| 150 |
+
|
| 151 |
+
Just highlights smarty code between the preprocessor directives, other
|
| 152 |
+
data is left untouched by the lexer.
|
| 153 |
+
"""
|
| 154 |
+
|
| 155 |
+
name = 'Smarty'
|
| 156 |
+
url = 'https://www.smarty.net/'
|
| 157 |
+
aliases = ['smarty']
|
| 158 |
+
filenames = ['*.tpl']
|
| 159 |
+
mimetypes = ['application/x-smarty']
|
| 160 |
+
version_added = ''
|
| 161 |
+
|
| 162 |
+
flags = re.MULTILINE | re.DOTALL
|
| 163 |
+
|
| 164 |
+
tokens = {
|
| 165 |
+
'root': [
|
| 166 |
+
(r'[^{]+', Other),
|
| 167 |
+
(r'(\{)(\*.*?\*)(\})',
|
| 168 |
+
bygroups(Comment.Preproc, Comment, Comment.Preproc)),
|
| 169 |
+
(r'(\{php\})(.*?)(\{/php\})',
|
| 170 |
+
bygroups(Comment.Preproc, using(PhpLexer, startinline=True),
|
| 171 |
+
Comment.Preproc)),
|
| 172 |
+
(r'(\{)(/?[a-zA-Z_]\w*)(\s*)',
|
| 173 |
+
bygroups(Comment.Preproc, Name.Function, Text), 'smarty'),
|
| 174 |
+
(r'\{', Comment.Preproc, 'smarty')
|
| 175 |
+
],
|
| 176 |
+
'smarty': [
|
| 177 |
+
(r'\s+', Text),
|
| 178 |
+
(r'\{', Comment.Preproc, '#push'),
|
| 179 |
+
(r'\}', Comment.Preproc, '#pop'),
|
| 180 |
+
(r'#[a-zA-Z_]\w*#', Name.Variable),
|
| 181 |
+
(r'\$[a-zA-Z_]\w*(\.\w+)*', Name.Variable),
|
| 182 |
+
(r'[~!%^&*()+=|\[\]:;,.<>/?@-]', Operator),
|
| 183 |
+
(r'(true|false|null)\b', Keyword.Constant),
|
| 184 |
+
(r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
|
| 185 |
+
r"0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 186 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 187 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 188 |
+
(r'[a-zA-Z_]\w*', Name.Attribute)
|
| 189 |
+
]
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
def analyse_text(text):
|
| 193 |
+
rv = 0.0
|
| 194 |
+
if re.search(r'\{if\s+.*?\}.*?\{/if\}', text):
|
| 195 |
+
rv += 0.15
|
| 196 |
+
if re.search(r'\{include\s+file=.*?\}', text):
|
| 197 |
+
rv += 0.15
|
| 198 |
+
if re.search(r'\{foreach\s+.*?\}.*?\{/foreach\}', text):
|
| 199 |
+
rv += 0.15
|
| 200 |
+
if re.search(r'\{\$.*?\}', text):
|
| 201 |
+
rv += 0.01
|
| 202 |
+
return rv
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
class VelocityLexer(RegexLexer):
|
| 206 |
+
"""
|
| 207 |
+
Generic Velocity template lexer.
|
| 208 |
+
|
| 209 |
+
Just highlights velocity directives and variable references, other
|
| 210 |
+
data is left untouched by the lexer.
|
| 211 |
+
"""
|
| 212 |
+
|
| 213 |
+
name = 'Velocity'
|
| 214 |
+
url = 'https://velocity.apache.org/'
|
| 215 |
+
aliases = ['velocity']
|
| 216 |
+
filenames = ['*.vm', '*.fhtml']
|
| 217 |
+
version_added = ''
|
| 218 |
+
|
| 219 |
+
flags = re.MULTILINE | re.DOTALL
|
| 220 |
+
|
| 221 |
+
identifier = r'[a-zA-Z_]\w*'
|
| 222 |
+
|
| 223 |
+
tokens = {
|
| 224 |
+
'root': [
|
| 225 |
+
(r'[^{#$]+', Other),
|
| 226 |
+
(r'(#)(\*.*?\*)(#)',
|
| 227 |
+
bygroups(Comment.Preproc, Comment, Comment.Preproc)),
|
| 228 |
+
(r'(##)(.*?$)',
|
| 229 |
+
bygroups(Comment.Preproc, Comment)),
|
| 230 |
+
(r'(#\{?)(' + identifier + r')(\}?)(\s?\()',
|
| 231 |
+
bygroups(Comment.Preproc, Name.Function, Comment.Preproc, Punctuation),
|
| 232 |
+
'directiveparams'),
|
| 233 |
+
(r'(#\{?)(' + identifier + r')(\}|\b)',
|
| 234 |
+
bygroups(Comment.Preproc, Name.Function, Comment.Preproc)),
|
| 235 |
+
(r'\$!?\{?', Punctuation, 'variable')
|
| 236 |
+
],
|
| 237 |
+
'variable': [
|
| 238 |
+
(identifier, Name.Variable),
|
| 239 |
+
(r'\(', Punctuation, 'funcparams'),
|
| 240 |
+
(r'(\.)(' + identifier + r')',
|
| 241 |
+
bygroups(Punctuation, Name.Variable), '#push'),
|
| 242 |
+
(r'\}', Punctuation, '#pop'),
|
| 243 |
+
default('#pop')
|
| 244 |
+
],
|
| 245 |
+
'directiveparams': [
|
| 246 |
+
(r'(&&|\|\||==?|!=?|[-<>+*%&|^/])|\b(eq|ne|gt|lt|ge|le|not|in)\b',
|
| 247 |
+
Operator),
|
| 248 |
+
(r'\[', Operator, 'rangeoperator'),
|
| 249 |
+
(r'\b' + identifier + r'\b', Name.Function),
|
| 250 |
+
include('funcparams')
|
| 251 |
+
],
|
| 252 |
+
'rangeoperator': [
|
| 253 |
+
(r'\.\.', Operator),
|
| 254 |
+
include('funcparams'),
|
| 255 |
+
(r'\]', Operator, '#pop')
|
| 256 |
+
],
|
| 257 |
+
'funcparams': [
|
| 258 |
+
(r'\$!?\{?', Punctuation, 'variable'),
|
| 259 |
+
(r'\s+', Text),
|
| 260 |
+
(r'[,:]', Punctuation),
|
| 261 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 262 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 263 |
+
(r"0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 264 |
+
(r"\b[0-9]+\b", Number),
|
| 265 |
+
(r'(true|false|null)\b', Keyword.Constant),
|
| 266 |
+
(r'\(', Punctuation, '#push'),
|
| 267 |
+
(r'\)', Punctuation, '#pop'),
|
| 268 |
+
(r'\{', Punctuation, '#push'),
|
| 269 |
+
(r'\}', Punctuation, '#pop'),
|
| 270 |
+
(r'\[', Punctuation, '#push'),
|
| 271 |
+
(r'\]', Punctuation, '#pop'),
|
| 272 |
+
]
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
def analyse_text(text):
|
| 276 |
+
rv = 0.0
|
| 277 |
+
if re.search(r'#\{?macro\}?\(.*?\).*?#\{?end\}?', text, re.DOTALL):
|
| 278 |
+
rv += 0.25
|
| 279 |
+
if re.search(r'#\{?if\}?\(.+?\).*?#\{?end\}?', text, re.DOTALL):
|
| 280 |
+
rv += 0.15
|
| 281 |
+
if re.search(r'#\{?foreach\}?\(.+?\).*?#\{?end\}?', text, re.DOTALL):
|
| 282 |
+
rv += 0.15
|
| 283 |
+
if re.search(r'\$!?\{?[a-zA-Z_]\w*(\([^)]*\))?'
|
| 284 |
+
r'(\.\w+(\([^)]*\))?)*\}?', text):
|
| 285 |
+
rv += 0.01
|
| 286 |
+
return rv
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
class VelocityHtmlLexer(DelegatingLexer):
|
| 290 |
+
"""
|
| 291 |
+
Subclass of the `VelocityLexer` that highlights unlexed data
|
| 292 |
+
with the `HtmlLexer`.
|
| 293 |
+
|
| 294 |
+
"""
|
| 295 |
+
|
| 296 |
+
name = 'HTML+Velocity'
|
| 297 |
+
aliases = ['html+velocity']
|
| 298 |
+
version_added = ''
|
| 299 |
+
alias_filenames = ['*.html', '*.fhtml']
|
| 300 |
+
mimetypes = ['text/html+velocity']
|
| 301 |
+
url = 'https://velocity.apache.org/'
|
| 302 |
+
|
| 303 |
+
def __init__(self, **options):
|
| 304 |
+
super().__init__(HtmlLexer, VelocityLexer, **options)
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
class VelocityXmlLexer(DelegatingLexer):
|
| 308 |
+
"""
|
| 309 |
+
Subclass of the `VelocityLexer` that highlights unlexed data
|
| 310 |
+
with the `XmlLexer`.
|
| 311 |
+
|
| 312 |
+
"""
|
| 313 |
+
|
| 314 |
+
name = 'XML+Velocity'
|
| 315 |
+
aliases = ['xml+velocity']
|
| 316 |
+
version_added = ''
|
| 317 |
+
alias_filenames = ['*.xml', '*.vm']
|
| 318 |
+
mimetypes = ['application/xml+velocity']
|
| 319 |
+
url = 'https://velocity.apache.org/'
|
| 320 |
+
|
| 321 |
+
def __init__(self, **options):
|
| 322 |
+
super().__init__(XmlLexer, VelocityLexer, **options)
|
| 323 |
+
|
| 324 |
+
def analyse_text(text):
|
| 325 |
+
rv = VelocityLexer.analyse_text(text) - 0.01
|
| 326 |
+
if looks_like_xml(text):
|
| 327 |
+
rv += 0.4
|
| 328 |
+
return rv
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
class DjangoLexer(RegexLexer):
|
| 332 |
+
"""
|
| 333 |
+
Generic `Django <https://www.djangoproject.com/documentation/templates/>`_
|
| 334 |
+
and `Jinja <https://jinja.palletsprojects.com>`_ template lexer.
|
| 335 |
+
|
| 336 |
+
It just highlights django/jinja code between the preprocessor directives,
|
| 337 |
+
other data is left untouched by the lexer.
|
| 338 |
+
"""
|
| 339 |
+
|
| 340 |
+
name = 'Django/Jinja'
|
| 341 |
+
aliases = ['django', 'jinja']
|
| 342 |
+
mimetypes = ['application/x-django-templating', 'application/x-jinja']
|
| 343 |
+
url = 'https://www.djangoproject.com/documentation/templates'
|
| 344 |
+
version_added = ''
|
| 345 |
+
|
| 346 |
+
flags = re.M | re.S
|
| 347 |
+
|
| 348 |
+
tokens = {
|
| 349 |
+
'root': [
|
| 350 |
+
(r'[^{]+', Other),
|
| 351 |
+
(r'\{\{', Comment.Preproc, 'var'),
|
| 352 |
+
# jinja/django comments
|
| 353 |
+
(r'\{#.*?#\}', Comment),
|
| 354 |
+
# django comments
|
| 355 |
+
(r'(\{%)(-?\s*)(comment)(\s*-?)(%\})(.*?)'
|
| 356 |
+
r'(\{%)(-?\s*)(endcomment)(\s*-?)(%\})',
|
| 357 |
+
bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc,
|
| 358 |
+
Comment, Comment.Preproc, Text, Keyword, Text,
|
| 359 |
+
Comment.Preproc)),
|
| 360 |
+
# raw jinja blocks
|
| 361 |
+
(r'(\{%)(-?\s*)(raw)(\s*-?)(%\})(.*?)'
|
| 362 |
+
r'(\{%)(-?\s*)(endraw)(\s*-?)(%\})',
|
| 363 |
+
bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc,
|
| 364 |
+
Text, Comment.Preproc, Text, Keyword, Text,
|
| 365 |
+
Comment.Preproc)),
|
| 366 |
+
# filter blocks
|
| 367 |
+
(r'(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_]\w*)',
|
| 368 |
+
bygroups(Comment.Preproc, Text, Keyword, Text, Name.Function),
|
| 369 |
+
'block'),
|
| 370 |
+
(r'(\{%)(-?\s*)([a-zA-Z_]\w*)',
|
| 371 |
+
bygroups(Comment.Preproc, Text, Keyword), 'block'),
|
| 372 |
+
(r'\{', Other)
|
| 373 |
+
],
|
| 374 |
+
'varnames': [
|
| 375 |
+
(r'(\|)(\s*)([a-zA-Z_]\w*)',
|
| 376 |
+
bygroups(Operator, Text, Name.Function)),
|
| 377 |
+
(r'(is)(\s+)(not)?(\s+)?([a-zA-Z_]\w*)',
|
| 378 |
+
bygroups(Keyword, Text, Keyword, Text, Name.Function)),
|
| 379 |
+
(r'(_|true|false|none|True|False|None)\b', Keyword.Pseudo),
|
| 380 |
+
(r'(in|as|reversed|recursive|not|and|or|is|if|else|import|'
|
| 381 |
+
r'with(?:(?:out)?\s*context)?|scoped|ignore\s+missing)\b',
|
| 382 |
+
Keyword),
|
| 383 |
+
(r'(loop|block|super|forloop)\b', Name.Builtin),
|
| 384 |
+
(r'[a-zA-Z_][\w-]*', Name.Variable),
|
| 385 |
+
(r'\.\w+', Name.Variable),
|
| 386 |
+
(r':?"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 387 |
+
(r":?'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 388 |
+
(r'([{}()\[\]+\-*/%,:~]|[><=]=?|!=)', Operator),
|
| 389 |
+
(r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
|
| 390 |
+
r"0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 391 |
+
],
|
| 392 |
+
'var': [
|
| 393 |
+
(r'\s+', Text),
|
| 394 |
+
(r'(-?)(\}\})', bygroups(Text, Comment.Preproc), '#pop'),
|
| 395 |
+
include('varnames')
|
| 396 |
+
],
|
| 397 |
+
'block': [
|
| 398 |
+
(r'\s+', Text),
|
| 399 |
+
(r'(-?)(%\})', bygroups(Text, Comment.Preproc), '#pop'),
|
| 400 |
+
include('varnames'),
|
| 401 |
+
(r'.', Punctuation)
|
| 402 |
+
]
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
def analyse_text(text):
|
| 406 |
+
rv = 0.0
|
| 407 |
+
if re.search(r'\{%\s*(block|extends)', text) is not None:
|
| 408 |
+
rv += 0.4
|
| 409 |
+
if re.search(r'\{%\s*if\s*.*?%\}', text) is not None:
|
| 410 |
+
rv += 0.1
|
| 411 |
+
if re.search(r'\{\{.*?\}\}', text) is not None:
|
| 412 |
+
rv += 0.1
|
| 413 |
+
return rv
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
class MyghtyLexer(RegexLexer):
|
| 417 |
+
"""
|
| 418 |
+
Generic myghty templates lexer. Code that isn't Myghty
|
| 419 |
+
markup is yielded as `Token.Other`.
|
| 420 |
+
"""
|
| 421 |
+
|
| 422 |
+
name = 'Myghty'
|
| 423 |
+
url = 'http://www.myghty.org/'
|
| 424 |
+
aliases = ['myghty']
|
| 425 |
+
filenames = ['*.myt', 'autodelegate']
|
| 426 |
+
mimetypes = ['application/x-myghty']
|
| 427 |
+
version_added = '0.6'
|
| 428 |
+
|
| 429 |
+
tokens = {
|
| 430 |
+
'root': [
|
| 431 |
+
(r'\s+', Text),
|
| 432 |
+
(r'(?s)(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)',
|
| 433 |
+
bygroups(Name.Tag, Text, Name.Function, Name.Tag,
|
| 434 |
+
using(this), Name.Tag)),
|
| 435 |
+
(r'(?s)(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)',
|
| 436 |
+
bygroups(Name.Tag, Name.Function, Name.Tag,
|
| 437 |
+
using(PythonLexer), Name.Tag)),
|
| 438 |
+
(r'(<&[^|])(.*?)(,.*?)?(&>)',
|
| 439 |
+
bygroups(Name.Tag, Name.Function, using(PythonLexer), Name.Tag)),
|
| 440 |
+
(r'(?s)(<&\|)(.*?)(,.*?)?(&>)',
|
| 441 |
+
bygroups(Name.Tag, Name.Function, using(PythonLexer), Name.Tag)),
|
| 442 |
+
(r'</&>', Name.Tag),
|
| 443 |
+
(r'(?s)(<%!?)(.*?)(%>)',
|
| 444 |
+
bygroups(Name.Tag, using(PythonLexer), Name.Tag)),
|
| 445 |
+
(r'(?<=^)#[^\n]*(\n|\Z)', Comment),
|
| 446 |
+
(r'(?<=^)(%)([^\n]*)(\n|\Z)',
|
| 447 |
+
bygroups(Name.Tag, using(PythonLexer), Other)),
|
| 448 |
+
(r"""(?sx)
|
| 449 |
+
(.+?) # anything, followed by:
|
| 450 |
+
(?:
|
| 451 |
+
(?<=\n)(?=[%#]) | # an eval or comment line
|
| 452 |
+
(?=</?[%&]) | # a substitution or block or
|
| 453 |
+
# call start or end
|
| 454 |
+
# - don't consume
|
| 455 |
+
(\\\n) | # an escaped newline
|
| 456 |
+
\Z # end of string
|
| 457 |
+
)""", bygroups(Other, Operator)),
|
| 458 |
+
]
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
class MyghtyHtmlLexer(DelegatingLexer):
|
| 463 |
+
"""
|
| 464 |
+
Subclass of the `MyghtyLexer` that highlights unlexed data
|
| 465 |
+
with the `HtmlLexer`.
|
| 466 |
+
"""
|
| 467 |
+
|
| 468 |
+
name = 'HTML+Myghty'
|
| 469 |
+
aliases = ['html+myghty']
|
| 470 |
+
mimetypes = ['text/html+myghty']
|
| 471 |
+
url = 'http://www.myghty.org/'
|
| 472 |
+
version_added = '0.6'
|
| 473 |
+
|
| 474 |
+
def __init__(self, **options):
|
| 475 |
+
super().__init__(HtmlLexer, MyghtyLexer, **options)
|
| 476 |
+
|
| 477 |
+
|
| 478 |
+
class MyghtyXmlLexer(DelegatingLexer):
|
| 479 |
+
"""
|
| 480 |
+
Subclass of the `MyghtyLexer` that highlights unlexed data
|
| 481 |
+
with the `XmlLexer`.
|
| 482 |
+
"""
|
| 483 |
+
|
| 484 |
+
name = 'XML+Myghty'
|
| 485 |
+
aliases = ['xml+myghty']
|
| 486 |
+
mimetypes = ['application/xml+myghty']
|
| 487 |
+
url = 'http://www.myghty.org/'
|
| 488 |
+
version_added = '0.6'
|
| 489 |
+
|
| 490 |
+
def __init__(self, **options):
|
| 491 |
+
super().__init__(XmlLexer, MyghtyLexer, **options)
|
| 492 |
+
|
| 493 |
+
|
| 494 |
+
class MyghtyJavascriptLexer(DelegatingLexer):
|
| 495 |
+
"""
|
| 496 |
+
Subclass of the `MyghtyLexer` that highlights unlexed data
|
| 497 |
+
with the `JavascriptLexer`.
|
| 498 |
+
"""
|
| 499 |
+
|
| 500 |
+
name = 'JavaScript+Myghty'
|
| 501 |
+
aliases = ['javascript+myghty', 'js+myghty']
|
| 502 |
+
mimetypes = ['application/x-javascript+myghty',
|
| 503 |
+
'text/x-javascript+myghty',
|
| 504 |
+
'text/javascript+mygthy']
|
| 505 |
+
url = 'http://www.myghty.org/'
|
| 506 |
+
version_added = '0.6'
|
| 507 |
+
|
| 508 |
+
def __init__(self, **options):
|
| 509 |
+
super().__init__(JavascriptLexer, MyghtyLexer, **options)
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
class MyghtyCssLexer(DelegatingLexer):
|
| 513 |
+
"""
|
| 514 |
+
Subclass of the `MyghtyLexer` that highlights unlexed data
|
| 515 |
+
with the `CssLexer`.
|
| 516 |
+
"""
|
| 517 |
+
|
| 518 |
+
name = 'CSS+Myghty'
|
| 519 |
+
aliases = ['css+myghty']
|
| 520 |
+
mimetypes = ['text/css+myghty']
|
| 521 |
+
url = 'http://www.myghty.org/'
|
| 522 |
+
version_added = '0.6'
|
| 523 |
+
|
| 524 |
+
def __init__(self, **options):
|
| 525 |
+
super().__init__(CssLexer, MyghtyLexer, **options)
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
class MasonLexer(RegexLexer):
|
| 529 |
+
"""
|
| 530 |
+
Generic mason templates lexer. Stolen from Myghty lexer. Code that isn't
|
| 531 |
+
Mason markup is HTML.
|
| 532 |
+
"""
|
| 533 |
+
name = 'Mason'
|
| 534 |
+
url = 'http://www.masonhq.com/'
|
| 535 |
+
aliases = ['mason']
|
| 536 |
+
filenames = ['*.m', '*.mhtml', '*.mc', '*.mi', 'autohandler', 'dhandler']
|
| 537 |
+
mimetypes = ['application/x-mason']
|
| 538 |
+
version_added = '1.4'
|
| 539 |
+
|
| 540 |
+
tokens = {
|
| 541 |
+
'root': [
|
| 542 |
+
(r'\s+', Whitespace),
|
| 543 |
+
(r'(?s)(<%doc>)(.*?)(</%doc>)',
|
| 544 |
+
bygroups(Name.Tag, Comment.Multiline, Name.Tag)),
|
| 545 |
+
(r'(?s)(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)',
|
| 546 |
+
bygroups(Name.Tag, Whitespace, Name.Function, Name.Tag,
|
| 547 |
+
using(this), Name.Tag)),
|
| 548 |
+
(r'(?s)(<%(\w+)(.*?)(>))(.*?)(</%\2\s*>)',
|
| 549 |
+
bygroups(Name.Tag, None, None, None, using(PerlLexer), Name.Tag)),
|
| 550 |
+
(r'(?s)(<&[^|])(.*?)(,.*?)?(&>)',
|
| 551 |
+
bygroups(Name.Tag, Name.Function, using(PerlLexer), Name.Tag)),
|
| 552 |
+
(r'(?s)(<&\|)(.*?)(,.*?)?(&>)',
|
| 553 |
+
bygroups(Name.Tag, Name.Function, using(PerlLexer), Name.Tag)),
|
| 554 |
+
(r'</&>', Name.Tag),
|
| 555 |
+
(r'(?s)(<%!?)(.*?)(%>)',
|
| 556 |
+
bygroups(Name.Tag, using(PerlLexer), Name.Tag)),
|
| 557 |
+
(r'(?<=^)#[^\n]*(\n|\Z)', Comment),
|
| 558 |
+
(r'(?<=^)(%)([^\n]*)(\n|\Z)',
|
| 559 |
+
bygroups(Name.Tag, using(PerlLexer), Other)),
|
| 560 |
+
(r"""(?sx)
|
| 561 |
+
(.+?) # anything, followed by:
|
| 562 |
+
(?:
|
| 563 |
+
(?<=\n)(?=[%#]) | # an eval or comment line
|
| 564 |
+
(?=</?[%&]) | # a substitution or block or
|
| 565 |
+
# call start or end
|
| 566 |
+
# - don't consume
|
| 567 |
+
(\\\n) | # an escaped newline
|
| 568 |
+
\Z # end of string
|
| 569 |
+
)""", bygroups(using(HtmlLexer), Operator)),
|
| 570 |
+
]
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
def analyse_text(text):
|
| 574 |
+
result = 0.0
|
| 575 |
+
if re.search(r'</%(class|doc|init)>', text) is not None:
|
| 576 |
+
result = 1.0
|
| 577 |
+
elif re.search(r'<&.+&>', text, re.DOTALL) is not None:
|
| 578 |
+
result = 0.11
|
| 579 |
+
return result
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
class MakoLexer(RegexLexer):
|
| 583 |
+
"""
|
| 584 |
+
Generic mako templates lexer. Code that isn't Mako
|
| 585 |
+
markup is yielded as `Token.Other`.
|
| 586 |
+
"""
|
| 587 |
+
|
| 588 |
+
name = 'Mako'
|
| 589 |
+
url = 'http://www.makotemplates.org/'
|
| 590 |
+
aliases = ['mako']
|
| 591 |
+
filenames = ['*.mao']
|
| 592 |
+
mimetypes = ['application/x-mako']
|
| 593 |
+
version_added = '0.7'
|
| 594 |
+
|
| 595 |
+
tokens = {
|
| 596 |
+
'root': [
|
| 597 |
+
(r'(\s*)(%)(\s*end(?:\w+))(\n|\Z)',
|
| 598 |
+
bygroups(Text.Whitespace, Comment.Preproc, Keyword, Other)),
|
| 599 |
+
(r'(\s*)(%)([^\n]*)(\n|\Z)',
|
| 600 |
+
bygroups(Text.Whitespace, Comment.Preproc, using(PythonLexer), Other)),
|
| 601 |
+
(r'(\s*)(##[^\n]*)(\n|\Z)',
|
| 602 |
+
bygroups(Text.Whitespace, Comment.Single, Text.Whitespace)),
|
| 603 |
+
(r'(?s)<%doc>.*?</%doc>', Comment.Multiline),
|
| 604 |
+
(r'(<%)([\w.:]+)',
|
| 605 |
+
bygroups(Comment.Preproc, Name.Builtin), 'tag'),
|
| 606 |
+
(r'(</%)([\w.:]+)(>)',
|
| 607 |
+
bygroups(Comment.Preproc, Name.Builtin, Comment.Preproc)),
|
| 608 |
+
(r'<%(?=([\w.:]+))', Comment.Preproc, 'ondeftags'),
|
| 609 |
+
(r'(?s)(<%(?:!?))(.*?)(%>)',
|
| 610 |
+
bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
|
| 611 |
+
(r'(\$\{)(.*?)(\})',
|
| 612 |
+
bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
|
| 613 |
+
(r'''(?sx)
|
| 614 |
+
(.+?) # anything, followed by:
|
| 615 |
+
(?:
|
| 616 |
+
(?<=\n)(?=%|\#\#) | # an eval or comment line
|
| 617 |
+
(?=\#\*) | # multiline comment
|
| 618 |
+
(?=</?%) | # a python block
|
| 619 |
+
# call start or end
|
| 620 |
+
(?=\$\{) | # a substitution
|
| 621 |
+
(?<=\n)(?=\s*%) |
|
| 622 |
+
# - don't consume
|
| 623 |
+
(\\\n) | # an escaped newline
|
| 624 |
+
\Z # end of string
|
| 625 |
+
)
|
| 626 |
+
''', bygroups(Other, Operator)),
|
| 627 |
+
(r'\s+', Text),
|
| 628 |
+
],
|
| 629 |
+
'ondeftags': [
|
| 630 |
+
(r'<%', Comment.Preproc),
|
| 631 |
+
(r'(?<=<%)(include|inherit|namespace|page)', Name.Builtin),
|
| 632 |
+
include('tag'),
|
| 633 |
+
],
|
| 634 |
+
'tag': [
|
| 635 |
+
(r'((?:\w+)\s*=)(\s*)(".*?")',
|
| 636 |
+
bygroups(Name.Attribute, Text, String)),
|
| 637 |
+
(r'/?\s*>', Comment.Preproc, '#pop'),
|
| 638 |
+
(r'\s+', Text),
|
| 639 |
+
],
|
| 640 |
+
'attr': [
|
| 641 |
+
('".*?"', String, '#pop'),
|
| 642 |
+
("'.*?'", String, '#pop'),
|
| 643 |
+
(r'[^\s>]+', String, '#pop'),
|
| 644 |
+
],
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
|
| 648 |
+
class MakoHtmlLexer(DelegatingLexer):
|
| 649 |
+
"""
|
| 650 |
+
Subclass of the `MakoLexer` that highlights unlexed data
|
| 651 |
+
with the `HtmlLexer`.
|
| 652 |
+
"""
|
| 653 |
+
|
| 654 |
+
name = 'HTML+Mako'
|
| 655 |
+
aliases = ['html+mako']
|
| 656 |
+
mimetypes = ['text/html+mako']
|
| 657 |
+
url = 'http://www.makotemplates.org/'
|
| 658 |
+
version_added = '0.7'
|
| 659 |
+
|
| 660 |
+
def __init__(self, **options):
|
| 661 |
+
super().__init__(HtmlLexer, MakoLexer, **options)
|
| 662 |
+
|
| 663 |
+
|
| 664 |
+
class MakoXmlLexer(DelegatingLexer):
|
| 665 |
+
"""
|
| 666 |
+
Subclass of the `MakoLexer` that highlights unlexed data
|
| 667 |
+
with the `XmlLexer`.
|
| 668 |
+
"""
|
| 669 |
+
|
| 670 |
+
name = 'XML+Mako'
|
| 671 |
+
aliases = ['xml+mako']
|
| 672 |
+
mimetypes = ['application/xml+mako']
|
| 673 |
+
url = 'http://www.makotemplates.org/'
|
| 674 |
+
version_added = '0.7'
|
| 675 |
+
|
| 676 |
+
def __init__(self, **options):
|
| 677 |
+
super().__init__(XmlLexer, MakoLexer, **options)
|
| 678 |
+
|
| 679 |
+
|
| 680 |
+
class MakoJavascriptLexer(DelegatingLexer):
|
| 681 |
+
"""
|
| 682 |
+
Subclass of the `MakoLexer` that highlights unlexed data
|
| 683 |
+
with the `JavascriptLexer`.
|
| 684 |
+
"""
|
| 685 |
+
|
| 686 |
+
name = 'JavaScript+Mako'
|
| 687 |
+
aliases = ['javascript+mako', 'js+mako']
|
| 688 |
+
mimetypes = ['application/x-javascript+mako',
|
| 689 |
+
'text/x-javascript+mako',
|
| 690 |
+
'text/javascript+mako']
|
| 691 |
+
url = 'http://www.makotemplates.org/'
|
| 692 |
+
version_added = '0.7'
|
| 693 |
+
|
| 694 |
+
def __init__(self, **options):
|
| 695 |
+
super().__init__(JavascriptLexer, MakoLexer, **options)
|
| 696 |
+
|
| 697 |
+
|
| 698 |
+
class MakoCssLexer(DelegatingLexer):
|
| 699 |
+
"""
|
| 700 |
+
Subclass of the `MakoLexer` that highlights unlexed data
|
| 701 |
+
with the `CssLexer`.
|
| 702 |
+
"""
|
| 703 |
+
|
| 704 |
+
name = 'CSS+Mako'
|
| 705 |
+
aliases = ['css+mako']
|
| 706 |
+
mimetypes = ['text/css+mako']
|
| 707 |
+
url = 'http://www.makotemplates.org/'
|
| 708 |
+
version_added = '0.7'
|
| 709 |
+
|
| 710 |
+
def __init__(self, **options):
|
| 711 |
+
super().__init__(CssLexer, MakoLexer, **options)
|
| 712 |
+
|
| 713 |
+
|
| 714 |
+
# Genshi and Cheetah lexers courtesy of Matt Good.
|
| 715 |
+
|
| 716 |
+
class CheetahPythonLexer(Lexer):
|
| 717 |
+
"""
|
| 718 |
+
Lexer for handling Cheetah's special $ tokens in Python syntax.
|
| 719 |
+
"""
|
| 720 |
+
|
| 721 |
+
def get_tokens_unprocessed(self, text):
|
| 722 |
+
pylexer = PythonLexer(**self.options)
|
| 723 |
+
for pos, type_, value in pylexer.get_tokens_unprocessed(text):
|
| 724 |
+
if type_ == Token.Error and value == '$':
|
| 725 |
+
type_ = Comment.Preproc
|
| 726 |
+
yield pos, type_, value
|
| 727 |
+
|
| 728 |
+
|
| 729 |
+
class CheetahLexer(RegexLexer):
|
| 730 |
+
"""
|
| 731 |
+
Generic cheetah templates lexer. Code that isn't Cheetah
|
| 732 |
+
markup is yielded as `Token.Other`. This also works for
|
| 733 |
+
`spitfire templates`_ which use the same syntax.
|
| 734 |
+
|
| 735 |
+
.. _spitfire templates: http://code.google.com/p/spitfire/
|
| 736 |
+
"""
|
| 737 |
+
|
| 738 |
+
name = 'Cheetah'
|
| 739 |
+
url = 'http://www.cheetahtemplate.org/'
|
| 740 |
+
aliases = ['cheetah', 'spitfire']
|
| 741 |
+
filenames = ['*.tmpl', '*.spt']
|
| 742 |
+
mimetypes = ['application/x-cheetah', 'application/x-spitfire']
|
| 743 |
+
version_added = ''
|
| 744 |
+
|
| 745 |
+
tokens = {
|
| 746 |
+
'root': [
|
| 747 |
+
(r'(##[^\n]*)$',
|
| 748 |
+
(bygroups(Comment))),
|
| 749 |
+
(r'#[*](.|\n)*?[*]#', Comment),
|
| 750 |
+
(r'#end[^#\n]*(?:#|$)', Comment.Preproc),
|
| 751 |
+
(r'#slurp$', Comment.Preproc),
|
| 752 |
+
(r'(#[a-zA-Z]+)([^#\n]*)(#|$)',
|
| 753 |
+
(bygroups(Comment.Preproc, using(CheetahPythonLexer),
|
| 754 |
+
Comment.Preproc))),
|
| 755 |
+
# TODO support other Python syntax like $foo['bar']
|
| 756 |
+
(r'(\$)([a-zA-Z_][\w.]*\w)',
|
| 757 |
+
bygroups(Comment.Preproc, using(CheetahPythonLexer))),
|
| 758 |
+
(r'(?s)(\$\{!?)(.*?)(\})',
|
| 759 |
+
bygroups(Comment.Preproc, using(CheetahPythonLexer),
|
| 760 |
+
Comment.Preproc)),
|
| 761 |
+
(r'''(?sx)
|
| 762 |
+
(.+?) # anything, followed by:
|
| 763 |
+
(?:
|
| 764 |
+
(?=\#[#a-zA-Z]*) | # an eval comment
|
| 765 |
+
(?=\$[a-zA-Z_{]) | # a substitution
|
| 766 |
+
\Z # end of string
|
| 767 |
+
)
|
| 768 |
+
''', Other),
|
| 769 |
+
(r'\s+', Text),
|
| 770 |
+
],
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
|
| 774 |
+
class CheetahHtmlLexer(DelegatingLexer):
|
| 775 |
+
"""
|
| 776 |
+
Subclass of the `CheetahLexer` that highlights unlexed data
|
| 777 |
+
with the `HtmlLexer`.
|
| 778 |
+
"""
|
| 779 |
+
|
| 780 |
+
name = 'HTML+Cheetah'
|
| 781 |
+
aliases = ['html+cheetah', 'html+spitfire', 'htmlcheetah']
|
| 782 |
+
mimetypes = ['text/html+cheetah', 'text/html+spitfire']
|
| 783 |
+
url = 'http://www.cheetahtemplate.org/'
|
| 784 |
+
version_added = ''
|
| 785 |
+
|
| 786 |
+
def __init__(self, **options):
|
| 787 |
+
super().__init__(HtmlLexer, CheetahLexer, **options)
|
| 788 |
+
|
| 789 |
+
|
| 790 |
+
class CheetahXmlLexer(DelegatingLexer):
|
| 791 |
+
"""
|
| 792 |
+
Subclass of the `CheetahLexer` that highlights unlexed data
|
| 793 |
+
with the `XmlLexer`.
|
| 794 |
+
"""
|
| 795 |
+
|
| 796 |
+
name = 'XML+Cheetah'
|
| 797 |
+
aliases = ['xml+cheetah', 'xml+spitfire']
|
| 798 |
+
mimetypes = ['application/xml+cheetah', 'application/xml+spitfire']
|
| 799 |
+
url = 'http://www.cheetahtemplate.org/'
|
| 800 |
+
version_added = ''
|
| 801 |
+
|
| 802 |
+
def __init__(self, **options):
|
| 803 |
+
super().__init__(XmlLexer, CheetahLexer, **options)
|
| 804 |
+
|
| 805 |
+
|
| 806 |
+
class CheetahJavascriptLexer(DelegatingLexer):
|
| 807 |
+
"""
|
| 808 |
+
Subclass of the `CheetahLexer` that highlights unlexed data
|
| 809 |
+
with the `JavascriptLexer`.
|
| 810 |
+
"""
|
| 811 |
+
|
| 812 |
+
name = 'JavaScript+Cheetah'
|
| 813 |
+
aliases = ['javascript+cheetah', 'js+cheetah',
|
| 814 |
+
'javascript+spitfire', 'js+spitfire']
|
| 815 |
+
mimetypes = ['application/x-javascript+cheetah',
|
| 816 |
+
'text/x-javascript+cheetah',
|
| 817 |
+
'text/javascript+cheetah',
|
| 818 |
+
'application/x-javascript+spitfire',
|
| 819 |
+
'text/x-javascript+spitfire',
|
| 820 |
+
'text/javascript+spitfire']
|
| 821 |
+
url = 'http://www.cheetahtemplate.org/'
|
| 822 |
+
version_added = ''
|
| 823 |
+
|
| 824 |
+
def __init__(self, **options):
|
| 825 |
+
super().__init__(JavascriptLexer, CheetahLexer, **options)
|
| 826 |
+
|
| 827 |
+
|
| 828 |
+
class GenshiTextLexer(RegexLexer):
|
| 829 |
+
"""
|
| 830 |
+
A lexer that highlights genshi text templates.
|
| 831 |
+
"""
|
| 832 |
+
|
| 833 |
+
name = 'Genshi Text'
|
| 834 |
+
url = 'https://genshi.edgewall.org/'
|
| 835 |
+
aliases = ['genshitext']
|
| 836 |
+
mimetypes = ['application/x-genshi-text', 'text/x-genshi']
|
| 837 |
+
version_added = ''
|
| 838 |
+
|
| 839 |
+
tokens = {
|
| 840 |
+
'root': [
|
| 841 |
+
(r'[^#$\s]+', Other),
|
| 842 |
+
(r'^(\s*)(##.*)$', bygroups(Text, Comment)),
|
| 843 |
+
(r'^(\s*)(#)', bygroups(Text, Comment.Preproc), 'directive'),
|
| 844 |
+
include('variable'),
|
| 845 |
+
(r'[#$\s]', Other),
|
| 846 |
+
],
|
| 847 |
+
'directive': [
|
| 848 |
+
(r'\n', Text, '#pop'),
|
| 849 |
+
(r'(?:def|for|if)\s+.*', using(PythonLexer), '#pop'),
|
| 850 |
+
(r'(choose|when|with)([^\S\n]+)(.*)',
|
| 851 |
+
bygroups(Keyword, Text, using(PythonLexer)), '#pop'),
|
| 852 |
+
(r'(choose|otherwise)\b', Keyword, '#pop'),
|
| 853 |
+
(r'(end\w*)([^\S\n]*)(.*)', bygroups(Keyword, Text, Comment), '#pop'),
|
| 854 |
+
],
|
| 855 |
+
'variable': [
|
| 856 |
+
(r'(?<!\$)(\$\{)(.+?)(\})',
|
| 857 |
+
bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
|
| 858 |
+
(r'(?<!\$)(\$)([a-zA-Z_][\w.]*)',
|
| 859 |
+
Name.Variable),
|
| 860 |
+
]
|
| 861 |
+
}
|
| 862 |
+
|
| 863 |
+
|
| 864 |
+
class GenshiMarkupLexer(RegexLexer):
|
| 865 |
+
"""
|
| 866 |
+
Base lexer for Genshi markup, used by `HtmlGenshiLexer` and
|
| 867 |
+
`GenshiLexer`.
|
| 868 |
+
"""
|
| 869 |
+
|
| 870 |
+
flags = re.DOTALL
|
| 871 |
+
|
| 872 |
+
tokens = {
|
| 873 |
+
'root': [
|
| 874 |
+
(r'[^<$]+', Other),
|
| 875 |
+
(r'(<\?python)(.*?)(\?>)',
|
| 876 |
+
bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
|
| 877 |
+
# yield style and script blocks as Other
|
| 878 |
+
(r'<\s*(script|style)\s*.*?>.*?<\s*/\1\s*>', Other),
|
| 879 |
+
(r'<\s*py:[a-zA-Z0-9]+', Name.Tag, 'pytag'),
|
| 880 |
+
(r'<\s*[a-zA-Z0-9:.]+', Name.Tag, 'tag'),
|
| 881 |
+
include('variable'),
|
| 882 |
+
(r'[<$]', Other),
|
| 883 |
+
],
|
| 884 |
+
'pytag': [
|
| 885 |
+
(r'\s+', Text),
|
| 886 |
+
(r'[\w:-]+\s*=', Name.Attribute, 'pyattr'),
|
| 887 |
+
(r'/?\s*>', Name.Tag, '#pop'),
|
| 888 |
+
],
|
| 889 |
+
'pyattr': [
|
| 890 |
+
('(")(.*?)(")', bygroups(String, using(PythonLexer), String), '#pop'),
|
| 891 |
+
("(')(.*?)(')", bygroups(String, using(PythonLexer), String), '#pop'),
|
| 892 |
+
(r'[^\s>]+', String, '#pop'),
|
| 893 |
+
],
|
| 894 |
+
'tag': [
|
| 895 |
+
(r'\s+', Text),
|
| 896 |
+
(r'py:[\w-]+\s*=', Name.Attribute, 'pyattr'),
|
| 897 |
+
(r'[\w:-]+\s*=', Name.Attribute, 'attr'),
|
| 898 |
+
(r'/?\s*>', Name.Tag, '#pop'),
|
| 899 |
+
],
|
| 900 |
+
'attr': [
|
| 901 |
+
('"', String, 'attr-dstring'),
|
| 902 |
+
("'", String, 'attr-sstring'),
|
| 903 |
+
(r'[^\s>]*', String, '#pop')
|
| 904 |
+
],
|
| 905 |
+
'attr-dstring': [
|
| 906 |
+
('"', String, '#pop'),
|
| 907 |
+
include('strings'),
|
| 908 |
+
("'", String)
|
| 909 |
+
],
|
| 910 |
+
'attr-sstring': [
|
| 911 |
+
("'", String, '#pop'),
|
| 912 |
+
include('strings'),
|
| 913 |
+
("'", String)
|
| 914 |
+
],
|
| 915 |
+
'strings': [
|
| 916 |
+
('[^"\'$]+', String),
|
| 917 |
+
include('variable')
|
| 918 |
+
],
|
| 919 |
+
'variable': [
|
| 920 |
+
(r'(?<!\$)(\$\{)(.+?)(\})',
|
| 921 |
+
bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
|
| 922 |
+
(r'(?<!\$)(\$)([a-zA-Z_][\w\.]*)',
|
| 923 |
+
Name.Variable),
|
| 924 |
+
]
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
|
| 928 |
+
class HtmlGenshiLexer(DelegatingLexer):
|
| 929 |
+
"""
|
| 930 |
+
A lexer that highlights `genshi <https://genshi.edgewall.org/>`_ and
|
| 931 |
+
`kid <http://kid-templating.org/>`_ kid HTML templates.
|
| 932 |
+
"""
|
| 933 |
+
|
| 934 |
+
name = 'HTML+Genshi'
|
| 935 |
+
aliases = ['html+genshi', 'html+kid']
|
| 936 |
+
version_added = ''
|
| 937 |
+
alias_filenames = ['*.html', '*.htm', '*.xhtml']
|
| 938 |
+
mimetypes = ['text/html+genshi']
|
| 939 |
+
url = 'https://genshi.edgewall.org/'
|
| 940 |
+
|
| 941 |
+
def __init__(self, **options):
|
| 942 |
+
super().__init__(HtmlLexer, GenshiMarkupLexer, **options)
|
| 943 |
+
|
| 944 |
+
def analyse_text(text):
|
| 945 |
+
rv = 0.0
|
| 946 |
+
if re.search(r'\$\{.*?\}', text) is not None:
|
| 947 |
+
rv += 0.2
|
| 948 |
+
if re.search(r'py:(.*?)=["\']', text) is not None:
|
| 949 |
+
rv += 0.2
|
| 950 |
+
return rv + HtmlLexer.analyse_text(text) - 0.01
|
| 951 |
+
|
| 952 |
+
|
| 953 |
+
class GenshiLexer(DelegatingLexer):
|
| 954 |
+
"""
|
| 955 |
+
A lexer that highlights `genshi <https://genshi.edgewall.org/>`_ and
|
| 956 |
+
`kid <http://kid-templating.org/>`_ kid XML templates.
|
| 957 |
+
"""
|
| 958 |
+
|
| 959 |
+
name = 'Genshi'
|
| 960 |
+
aliases = ['genshi', 'kid', 'xml+genshi', 'xml+kid']
|
| 961 |
+
filenames = ['*.kid']
|
| 962 |
+
version_added = ''
|
| 963 |
+
alias_filenames = ['*.xml']
|
| 964 |
+
mimetypes = ['application/x-genshi', 'application/x-kid']
|
| 965 |
+
url = 'https://genshi.edgewall.org/'
|
| 966 |
+
|
| 967 |
+
def __init__(self, **options):
|
| 968 |
+
super().__init__(XmlLexer, GenshiMarkupLexer, **options)
|
| 969 |
+
|
| 970 |
+
def analyse_text(text):
|
| 971 |
+
rv = 0.0
|
| 972 |
+
if re.search(r'\$\{.*?\}', text) is not None:
|
| 973 |
+
rv += 0.2
|
| 974 |
+
if re.search(r'py:(.*?)=["\']', text) is not None:
|
| 975 |
+
rv += 0.2
|
| 976 |
+
return rv + XmlLexer.analyse_text(text) - 0.01
|
| 977 |
+
|
| 978 |
+
|
| 979 |
+
class JavascriptGenshiLexer(DelegatingLexer):
|
| 980 |
+
"""
|
| 981 |
+
A lexer that highlights javascript code in genshi text templates.
|
| 982 |
+
"""
|
| 983 |
+
|
| 984 |
+
name = 'JavaScript+Genshi Text'
|
| 985 |
+
aliases = ['js+genshitext', 'js+genshi', 'javascript+genshitext',
|
| 986 |
+
'javascript+genshi']
|
| 987 |
+
version_added = ''
|
| 988 |
+
alias_filenames = ['*.js']
|
| 989 |
+
mimetypes = ['application/x-javascript+genshi',
|
| 990 |
+
'text/x-javascript+genshi',
|
| 991 |
+
'text/javascript+genshi']
|
| 992 |
+
url = 'https://genshi.edgewall.org'
|
| 993 |
+
|
| 994 |
+
def __init__(self, **options):
|
| 995 |
+
super().__init__(JavascriptLexer, GenshiTextLexer, **options)
|
| 996 |
+
|
| 997 |
+
def analyse_text(text):
|
| 998 |
+
return GenshiLexer.analyse_text(text) - 0.05
|
| 999 |
+
|
| 1000 |
+
|
| 1001 |
+
class CssGenshiLexer(DelegatingLexer):
|
| 1002 |
+
"""
|
| 1003 |
+
A lexer that highlights CSS definitions in genshi text templates.
|
| 1004 |
+
"""
|
| 1005 |
+
|
| 1006 |
+
name = 'CSS+Genshi Text'
|
| 1007 |
+
aliases = ['css+genshitext', 'css+genshi']
|
| 1008 |
+
version_added = ''
|
| 1009 |
+
alias_filenames = ['*.css']
|
| 1010 |
+
mimetypes = ['text/css+genshi']
|
| 1011 |
+
url = 'https://genshi.edgewall.org'
|
| 1012 |
+
|
| 1013 |
+
def __init__(self, **options):
|
| 1014 |
+
super().__init__(CssLexer, GenshiTextLexer, **options)
|
| 1015 |
+
|
| 1016 |
+
def analyse_text(text):
|
| 1017 |
+
return GenshiLexer.analyse_text(text) - 0.05
|
| 1018 |
+
|
| 1019 |
+
|
| 1020 |
+
class RhtmlLexer(DelegatingLexer):
|
| 1021 |
+
"""
|
| 1022 |
+
Subclass of the ERB lexer that highlights the unlexed data with the
|
| 1023 |
+
html lexer.
|
| 1024 |
+
|
| 1025 |
+
Nested Javascript and CSS is highlighted too.
|
| 1026 |
+
"""
|
| 1027 |
+
|
| 1028 |
+
name = 'RHTML'
|
| 1029 |
+
aliases = ['rhtml', 'html+erb', 'html+ruby']
|
| 1030 |
+
filenames = ['*.rhtml']
|
| 1031 |
+
version_added = ''
|
| 1032 |
+
alias_filenames = ['*.html', '*.htm', '*.xhtml']
|
| 1033 |
+
mimetypes = ['text/html+ruby']
|
| 1034 |
+
url = 'https://github.com/ruby/erb'
|
| 1035 |
+
|
| 1036 |
+
|
| 1037 |
+
def __init__(self, **options):
|
| 1038 |
+
super().__init__(HtmlLexer, ErbLexer, **options)
|
| 1039 |
+
|
| 1040 |
+
def analyse_text(text):
|
| 1041 |
+
rv = ErbLexer.analyse_text(text) - 0.01
|
| 1042 |
+
if html_doctype_matches(text):
|
| 1043 |
+
# one more than the XmlErbLexer returns
|
| 1044 |
+
rv += 0.5
|
| 1045 |
+
return rv
|
| 1046 |
+
|
| 1047 |
+
|
| 1048 |
+
class XmlErbLexer(DelegatingLexer):
|
| 1049 |
+
"""
|
| 1050 |
+
Subclass of `ErbLexer` which highlights data outside preprocessor
|
| 1051 |
+
directives with the `XmlLexer`.
|
| 1052 |
+
"""
|
| 1053 |
+
|
| 1054 |
+
name = 'XML+Ruby'
|
| 1055 |
+
aliases = ['xml+ruby', 'xml+erb']
|
| 1056 |
+
version_added = ''
|
| 1057 |
+
alias_filenames = ['*.xml']
|
| 1058 |
+
mimetypes = ['application/xml+ruby']
|
| 1059 |
+
url = 'https://github.com/ruby/erb'
|
| 1060 |
+
|
| 1061 |
+
def __init__(self, **options):
|
| 1062 |
+
super().__init__(XmlLexer, ErbLexer, **options)
|
| 1063 |
+
|
| 1064 |
+
def analyse_text(text):
|
| 1065 |
+
rv = ErbLexer.analyse_text(text) - 0.01
|
| 1066 |
+
if looks_like_xml(text):
|
| 1067 |
+
rv += 0.4
|
| 1068 |
+
return rv
|
| 1069 |
+
|
| 1070 |
+
|
| 1071 |
+
class CssErbLexer(DelegatingLexer):
|
| 1072 |
+
"""
|
| 1073 |
+
Subclass of `ErbLexer` which highlights unlexed data with the `CssLexer`.
|
| 1074 |
+
"""
|
| 1075 |
+
|
| 1076 |
+
name = 'CSS+Ruby'
|
| 1077 |
+
aliases = ['css+ruby', 'css+erb']
|
| 1078 |
+
version_added = ''
|
| 1079 |
+
alias_filenames = ['*.css']
|
| 1080 |
+
mimetypes = ['text/css+ruby']
|
| 1081 |
+
url = 'https://github.com/ruby/erb'
|
| 1082 |
+
|
| 1083 |
+
def __init__(self, **options):
|
| 1084 |
+
super().__init__(CssLexer, ErbLexer, **options)
|
| 1085 |
+
|
| 1086 |
+
def analyse_text(text):
|
| 1087 |
+
return ErbLexer.analyse_text(text) - 0.05
|
| 1088 |
+
|
| 1089 |
+
|
| 1090 |
+
class JavascriptErbLexer(DelegatingLexer):
|
| 1091 |
+
"""
|
| 1092 |
+
Subclass of `ErbLexer` which highlights unlexed data with the
|
| 1093 |
+
`JavascriptLexer`.
|
| 1094 |
+
"""
|
| 1095 |
+
|
| 1096 |
+
name = 'JavaScript+Ruby'
|
| 1097 |
+
aliases = ['javascript+ruby', 'js+ruby', 'javascript+erb', 'js+erb']
|
| 1098 |
+
version_added = ''
|
| 1099 |
+
alias_filenames = ['*.js']
|
| 1100 |
+
mimetypes = ['application/x-javascript+ruby',
|
| 1101 |
+
'text/x-javascript+ruby',
|
| 1102 |
+
'text/javascript+ruby']
|
| 1103 |
+
url = 'https://github.com/ruby/erb'
|
| 1104 |
+
|
| 1105 |
+
def __init__(self, **options):
|
| 1106 |
+
super().__init__(JavascriptLexer, ErbLexer, **options)
|
| 1107 |
+
|
| 1108 |
+
def analyse_text(text):
|
| 1109 |
+
return ErbLexer.analyse_text(text) - 0.05
|
| 1110 |
+
|
| 1111 |
+
|
| 1112 |
+
class HtmlPhpLexer(DelegatingLexer):
|
| 1113 |
+
"""
|
| 1114 |
+
Subclass of `PhpLexer` that highlights unhandled data with the `HtmlLexer`.
|
| 1115 |
+
|
| 1116 |
+
Nested Javascript and CSS is highlighted too.
|
| 1117 |
+
"""
|
| 1118 |
+
|
| 1119 |
+
name = 'HTML+PHP'
|
| 1120 |
+
aliases = ['html+php']
|
| 1121 |
+
filenames = ['*.phtml']
|
| 1122 |
+
version_added = ''
|
| 1123 |
+
alias_filenames = ['*.php', '*.html', '*.htm', '*.xhtml',
|
| 1124 |
+
'*.php[345]']
|
| 1125 |
+
mimetypes = ['application/x-php',
|
| 1126 |
+
'application/x-httpd-php', 'application/x-httpd-php3',
|
| 1127 |
+
'application/x-httpd-php4', 'application/x-httpd-php5']
|
| 1128 |
+
url = 'https://www.php.net'
|
| 1129 |
+
|
| 1130 |
+
|
| 1131 |
+
def __init__(self, **options):
|
| 1132 |
+
super().__init__(HtmlLexer, PhpLexer, **options)
|
| 1133 |
+
|
| 1134 |
+
def analyse_text(text):
|
| 1135 |
+
rv = PhpLexer.analyse_text(text) - 0.01
|
| 1136 |
+
if html_doctype_matches(text):
|
| 1137 |
+
rv += 0.5
|
| 1138 |
+
return rv
|
| 1139 |
+
|
| 1140 |
+
|
| 1141 |
+
class XmlPhpLexer(DelegatingLexer):
|
| 1142 |
+
"""
|
| 1143 |
+
Subclass of `PhpLexer` that highlights unhandled data with the `XmlLexer`.
|
| 1144 |
+
"""
|
| 1145 |
+
|
| 1146 |
+
name = 'XML+PHP'
|
| 1147 |
+
aliases = ['xml+php']
|
| 1148 |
+
version_added = ''
|
| 1149 |
+
alias_filenames = ['*.xml', '*.php', '*.php[345]']
|
| 1150 |
+
mimetypes = ['application/xml+php']
|
| 1151 |
+
url = 'https://www.php.net'
|
| 1152 |
+
|
| 1153 |
+
def __init__(self, **options):
|
| 1154 |
+
super().__init__(XmlLexer, PhpLexer, **options)
|
| 1155 |
+
|
| 1156 |
+
def analyse_text(text):
|
| 1157 |
+
rv = PhpLexer.analyse_text(text) - 0.01
|
| 1158 |
+
if looks_like_xml(text):
|
| 1159 |
+
rv += 0.4
|
| 1160 |
+
return rv
|
| 1161 |
+
|
| 1162 |
+
|
| 1163 |
+
class CssPhpLexer(DelegatingLexer):
|
| 1164 |
+
"""
|
| 1165 |
+
Subclass of `PhpLexer` which highlights unmatched data with the `CssLexer`.
|
| 1166 |
+
"""
|
| 1167 |
+
|
| 1168 |
+
name = 'CSS+PHP'
|
| 1169 |
+
aliases = ['css+php']
|
| 1170 |
+
version_added = ''
|
| 1171 |
+
alias_filenames = ['*.css']
|
| 1172 |
+
mimetypes = ['text/css+php']
|
| 1173 |
+
url = 'https://www.php.net'
|
| 1174 |
+
|
| 1175 |
+
def __init__(self, **options):
|
| 1176 |
+
super().__init__(CssLexer, PhpLexer, **options)
|
| 1177 |
+
|
| 1178 |
+
def analyse_text(text):
|
| 1179 |
+
return PhpLexer.analyse_text(text) - 0.05
|
| 1180 |
+
|
| 1181 |
+
|
| 1182 |
+
class JavascriptPhpLexer(DelegatingLexer):
|
| 1183 |
+
"""
|
| 1184 |
+
Subclass of `PhpLexer` which highlights unmatched data with the
|
| 1185 |
+
`JavascriptLexer`.
|
| 1186 |
+
"""
|
| 1187 |
+
|
| 1188 |
+
name = 'JavaScript+PHP'
|
| 1189 |
+
aliases = ['javascript+php', 'js+php']
|
| 1190 |
+
version_added = ''
|
| 1191 |
+
alias_filenames = ['*.js']
|
| 1192 |
+
mimetypes = ['application/x-javascript+php',
|
| 1193 |
+
'text/x-javascript+php',
|
| 1194 |
+
'text/javascript+php']
|
| 1195 |
+
url = 'https://www.php.net'
|
| 1196 |
+
|
| 1197 |
+
def __init__(self, **options):
|
| 1198 |
+
super().__init__(JavascriptLexer, PhpLexer, **options)
|
| 1199 |
+
|
| 1200 |
+
def analyse_text(text):
|
| 1201 |
+
return PhpLexer.analyse_text(text)
|
| 1202 |
+
|
| 1203 |
+
|
| 1204 |
+
class HtmlSmartyLexer(DelegatingLexer):
|
| 1205 |
+
"""
|
| 1206 |
+
Subclass of the `SmartyLexer` that highlights unlexed data with the
|
| 1207 |
+
`HtmlLexer`.
|
| 1208 |
+
|
| 1209 |
+
Nested Javascript and CSS is highlighted too.
|
| 1210 |
+
"""
|
| 1211 |
+
|
| 1212 |
+
name = 'HTML+Smarty'
|
| 1213 |
+
aliases = ['html+smarty']
|
| 1214 |
+
version_added = ''
|
| 1215 |
+
alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.tpl']
|
| 1216 |
+
mimetypes = ['text/html+smarty']
|
| 1217 |
+
url = 'https://www.smarty.net/'
|
| 1218 |
+
|
| 1219 |
+
def __init__(self, **options):
|
| 1220 |
+
super().__init__(HtmlLexer, SmartyLexer, **options)
|
| 1221 |
+
|
| 1222 |
+
def analyse_text(text):
|
| 1223 |
+
rv = SmartyLexer.analyse_text(text) - 0.01
|
| 1224 |
+
if html_doctype_matches(text):
|
| 1225 |
+
rv += 0.5
|
| 1226 |
+
return rv
|
| 1227 |
+
|
| 1228 |
+
|
| 1229 |
+
class XmlSmartyLexer(DelegatingLexer):
|
| 1230 |
+
"""
|
| 1231 |
+
Subclass of the `SmartyLexer` that highlights unlexed data with the
|
| 1232 |
+
`XmlLexer`.
|
| 1233 |
+
"""
|
| 1234 |
+
|
| 1235 |
+
name = 'XML+Smarty'
|
| 1236 |
+
aliases = ['xml+smarty']
|
| 1237 |
+
version_added = ''
|
| 1238 |
+
alias_filenames = ['*.xml', '*.tpl']
|
| 1239 |
+
mimetypes = ['application/xml+smarty']
|
| 1240 |
+
url = 'https://www.smarty.net/'
|
| 1241 |
+
|
| 1242 |
+
def __init__(self, **options):
|
| 1243 |
+
super().__init__(XmlLexer, SmartyLexer, **options)
|
| 1244 |
+
|
| 1245 |
+
def analyse_text(text):
|
| 1246 |
+
rv = SmartyLexer.analyse_text(text) - 0.01
|
| 1247 |
+
if looks_like_xml(text):
|
| 1248 |
+
rv += 0.4
|
| 1249 |
+
return rv
|
| 1250 |
+
|
| 1251 |
+
|
| 1252 |
+
class CssSmartyLexer(DelegatingLexer):
|
| 1253 |
+
"""
|
| 1254 |
+
Subclass of the `SmartyLexer` that highlights unlexed data with the
|
| 1255 |
+
`CssLexer`.
|
| 1256 |
+
"""
|
| 1257 |
+
|
| 1258 |
+
name = 'CSS+Smarty'
|
| 1259 |
+
aliases = ['css+smarty']
|
| 1260 |
+
version_added = ''
|
| 1261 |
+
alias_filenames = ['*.css', '*.tpl']
|
| 1262 |
+
mimetypes = ['text/css+smarty']
|
| 1263 |
+
url = 'https://www.smarty.net/'
|
| 1264 |
+
|
| 1265 |
+
def __init__(self, **options):
|
| 1266 |
+
super().__init__(CssLexer, SmartyLexer, **options)
|
| 1267 |
+
|
| 1268 |
+
def analyse_text(text):
|
| 1269 |
+
return SmartyLexer.analyse_text(text) - 0.05
|
| 1270 |
+
|
| 1271 |
+
|
| 1272 |
+
class JavascriptSmartyLexer(DelegatingLexer):
|
| 1273 |
+
"""
|
| 1274 |
+
Subclass of the `SmartyLexer` that highlights unlexed data with the
|
| 1275 |
+
`JavascriptLexer`.
|
| 1276 |
+
"""
|
| 1277 |
+
|
| 1278 |
+
name = 'JavaScript+Smarty'
|
| 1279 |
+
aliases = ['javascript+smarty', 'js+smarty']
|
| 1280 |
+
version_added = ''
|
| 1281 |
+
alias_filenames = ['*.js', '*.tpl']
|
| 1282 |
+
mimetypes = ['application/x-javascript+smarty',
|
| 1283 |
+
'text/x-javascript+smarty',
|
| 1284 |
+
'text/javascript+smarty']
|
| 1285 |
+
url = 'https://www.smarty.net/'
|
| 1286 |
+
|
| 1287 |
+
def __init__(self, **options):
|
| 1288 |
+
super().__init__(JavascriptLexer, SmartyLexer, **options)
|
| 1289 |
+
|
| 1290 |
+
def analyse_text(text):
|
| 1291 |
+
return SmartyLexer.analyse_text(text) - 0.05
|
| 1292 |
+
|
| 1293 |
+
|
| 1294 |
+
class HtmlDjangoLexer(DelegatingLexer):
|
| 1295 |
+
"""
|
| 1296 |
+
Subclass of the `DjangoLexer` that highlights unlexed data with the
|
| 1297 |
+
`HtmlLexer`.
|
| 1298 |
+
|
| 1299 |
+
Nested Javascript and CSS is highlighted too.
|
| 1300 |
+
"""
|
| 1301 |
+
|
| 1302 |
+
name = 'HTML+Django/Jinja'
|
| 1303 |
+
aliases = ['html+django', 'html+jinja', 'htmldjango']
|
| 1304 |
+
filenames = ['*.html.j2', '*.htm.j2', '*.xhtml.j2', '*.html.jinja2', '*.htm.jinja2', '*.xhtml.jinja2']
|
| 1305 |
+
version_added = ''
|
| 1306 |
+
alias_filenames = ['*.html', '*.htm', '*.xhtml']
|
| 1307 |
+
mimetypes = ['text/html+django', 'text/html+jinja']
|
| 1308 |
+
url = 'https://www.djangoproject.com/documentation/templates'
|
| 1309 |
+
|
| 1310 |
+
def __init__(self, **options):
|
| 1311 |
+
super().__init__(HtmlLexer, DjangoLexer, **options)
|
| 1312 |
+
|
| 1313 |
+
def analyse_text(text):
|
| 1314 |
+
rv = DjangoLexer.analyse_text(text) - 0.01
|
| 1315 |
+
if html_doctype_matches(text):
|
| 1316 |
+
rv += 0.5
|
| 1317 |
+
return rv
|
| 1318 |
+
|
| 1319 |
+
|
| 1320 |
+
class XmlDjangoLexer(DelegatingLexer):
|
| 1321 |
+
"""
|
| 1322 |
+
Subclass of the `DjangoLexer` that highlights unlexed data with the
|
| 1323 |
+
`XmlLexer`.
|
| 1324 |
+
"""
|
| 1325 |
+
|
| 1326 |
+
name = 'XML+Django/Jinja'
|
| 1327 |
+
aliases = ['xml+django', 'xml+jinja']
|
| 1328 |
+
filenames = ['*.xml.j2', '*.xml.jinja2']
|
| 1329 |
+
version_added = ''
|
| 1330 |
+
alias_filenames = ['*.xml']
|
| 1331 |
+
mimetypes = ['application/xml+django', 'application/xml+jinja']
|
| 1332 |
+
url = 'https://www.djangoproject.com/documentation/templates'
|
| 1333 |
+
|
| 1334 |
+
def __init__(self, **options):
|
| 1335 |
+
super().__init__(XmlLexer, DjangoLexer, **options)
|
| 1336 |
+
|
| 1337 |
+
def analyse_text(text):
|
| 1338 |
+
rv = DjangoLexer.analyse_text(text) - 0.01
|
| 1339 |
+
if looks_like_xml(text):
|
| 1340 |
+
rv += 0.4
|
| 1341 |
+
return rv
|
| 1342 |
+
|
| 1343 |
+
|
| 1344 |
+
class CssDjangoLexer(DelegatingLexer):
|
| 1345 |
+
"""
|
| 1346 |
+
Subclass of the `DjangoLexer` that highlights unlexed data with the
|
| 1347 |
+
`CssLexer`.
|
| 1348 |
+
"""
|
| 1349 |
+
|
| 1350 |
+
name = 'CSS+Django/Jinja'
|
| 1351 |
+
aliases = ['css+django', 'css+jinja']
|
| 1352 |
+
filenames = ['*.css.j2', '*.css.jinja2']
|
| 1353 |
+
version_added = ''
|
| 1354 |
+
alias_filenames = ['*.css']
|
| 1355 |
+
mimetypes = ['text/css+django', 'text/css+jinja']
|
| 1356 |
+
url = 'https://www.djangoproject.com/documentation/templates'
|
| 1357 |
+
|
| 1358 |
+
def __init__(self, **options):
|
| 1359 |
+
super().__init__(CssLexer, DjangoLexer, **options)
|
| 1360 |
+
|
| 1361 |
+
def analyse_text(text):
|
| 1362 |
+
return DjangoLexer.analyse_text(text) - 0.05
|
| 1363 |
+
|
| 1364 |
+
|
| 1365 |
+
class JavascriptDjangoLexer(DelegatingLexer):
|
| 1366 |
+
"""
|
| 1367 |
+
Subclass of the `DjangoLexer` that highlights unlexed data with the
|
| 1368 |
+
`JavascriptLexer`.
|
| 1369 |
+
"""
|
| 1370 |
+
|
| 1371 |
+
name = 'JavaScript+Django/Jinja'
|
| 1372 |
+
aliases = ['javascript+django', 'js+django',
|
| 1373 |
+
'javascript+jinja', 'js+jinja']
|
| 1374 |
+
filenames = ['*.js.j2', '*.js.jinja2']
|
| 1375 |
+
version_added = ''
|
| 1376 |
+
alias_filenames = ['*.js']
|
| 1377 |
+
mimetypes = ['application/x-javascript+django',
|
| 1378 |
+
'application/x-javascript+jinja',
|
| 1379 |
+
'text/x-javascript+django',
|
| 1380 |
+
'text/x-javascript+jinja',
|
| 1381 |
+
'text/javascript+django',
|
| 1382 |
+
'text/javascript+jinja']
|
| 1383 |
+
url = 'https://www.djangoproject.com/documentation/templates'
|
| 1384 |
+
|
| 1385 |
+
def __init__(self, **options):
|
| 1386 |
+
super().__init__(JavascriptLexer, DjangoLexer, **options)
|
| 1387 |
+
|
| 1388 |
+
def analyse_text(text):
|
| 1389 |
+
return DjangoLexer.analyse_text(text) - 0.05
|
| 1390 |
+
|
| 1391 |
+
|
| 1392 |
+
class JspRootLexer(RegexLexer):
|
| 1393 |
+
"""
|
| 1394 |
+
Base for the `JspLexer`. Yields `Token.Other` for area outside of
|
| 1395 |
+
JSP tags.
|
| 1396 |
+
|
| 1397 |
+
.. versionadded:: 0.7
|
| 1398 |
+
"""
|
| 1399 |
+
|
| 1400 |
+
tokens = {
|
| 1401 |
+
'root': [
|
| 1402 |
+
(r'<%\S?', Keyword, 'sec'),
|
| 1403 |
+
# FIXME: I want to make these keywords but still parse attributes.
|
| 1404 |
+
(r'</?jsp:(forward|getProperty|include|plugin|setProperty|useBean).*?>',
|
| 1405 |
+
Keyword),
|
| 1406 |
+
(r'[^<]+', Other),
|
| 1407 |
+
(r'<', Other),
|
| 1408 |
+
],
|
| 1409 |
+
'sec': [
|
| 1410 |
+
(r'%>', Keyword, '#pop'),
|
| 1411 |
+
# note: '\w\W' != '.' without DOTALL.
|
| 1412 |
+
(r'[\w\W]+?(?=%>|\Z)', using(JavaLexer)),
|
| 1413 |
+
],
|
| 1414 |
+
}
|
| 1415 |
+
|
| 1416 |
+
|
| 1417 |
+
class JspLexer(DelegatingLexer):
|
| 1418 |
+
"""
|
| 1419 |
+
Lexer for Java Server Pages.
|
| 1420 |
+
"""
|
| 1421 |
+
name = 'Java Server Page'
|
| 1422 |
+
aliases = ['jsp']
|
| 1423 |
+
filenames = ['*.jsp']
|
| 1424 |
+
mimetypes = ['application/x-jsp']
|
| 1425 |
+
url = 'https://projects.eclipse.org/projects/ee4j.jsp'
|
| 1426 |
+
version_added = '0.7'
|
| 1427 |
+
|
| 1428 |
+
def __init__(self, **options):
|
| 1429 |
+
super().__init__(XmlLexer, JspRootLexer, **options)
|
| 1430 |
+
|
| 1431 |
+
def analyse_text(text):
|
| 1432 |
+
rv = JavaLexer.analyse_text(text) - 0.01
|
| 1433 |
+
if looks_like_xml(text):
|
| 1434 |
+
rv += 0.4
|
| 1435 |
+
if '<%' in text and '%>' in text:
|
| 1436 |
+
rv += 0.1
|
| 1437 |
+
return rv
|
| 1438 |
+
|
| 1439 |
+
|
| 1440 |
+
class EvoqueLexer(RegexLexer):
|
| 1441 |
+
"""
|
| 1442 |
+
For files using the Evoque templating system.
|
| 1443 |
+
"""
|
| 1444 |
+
name = 'Evoque'
|
| 1445 |
+
aliases = ['evoque']
|
| 1446 |
+
filenames = ['*.evoque']
|
| 1447 |
+
mimetypes = ['application/x-evoque']
|
| 1448 |
+
url = 'https://gizmojo.org/templating'
|
| 1449 |
+
version_added = '1.1'
|
| 1450 |
+
|
| 1451 |
+
flags = re.DOTALL
|
| 1452 |
+
|
| 1453 |
+
tokens = {
|
| 1454 |
+
'root': [
|
| 1455 |
+
(r'[^#$]+', Other),
|
| 1456 |
+
(r'#\[', Comment.Multiline, 'comment'),
|
| 1457 |
+
(r'\$\$', Other),
|
| 1458 |
+
# svn keywords
|
| 1459 |
+
(r'\$\w+:[^$\n]*\$', Comment.Multiline),
|
| 1460 |
+
# directives: begin, end
|
| 1461 |
+
(r'(\$)(begin|end)(\{(%)?)(.*?)((?(4)%)\})',
|
| 1462 |
+
bygroups(Punctuation, Name.Builtin, Punctuation, None,
|
| 1463 |
+
String, Punctuation)),
|
| 1464 |
+
# directives: evoque, overlay
|
| 1465 |
+
# see doc for handling first name arg: /directives/evoque/
|
| 1466 |
+
# + minor inconsistency: the "name" in e.g. $overlay{name=site_base}
|
| 1467 |
+
# should be using(PythonLexer), not passed out as String
|
| 1468 |
+
(r'(\$)(evoque|overlay)(\{(%)?)(\s*[#\w\-"\'.]+)?'
|
| 1469 |
+
r'(.*?)((?(4)%)\})',
|
| 1470 |
+
bygroups(Punctuation, Name.Builtin, Punctuation, None,
|
| 1471 |
+
String, using(PythonLexer), Punctuation)),
|
| 1472 |
+
# directives: if, for, prefer, test
|
| 1473 |
+
(r'(\$)(\w+)(\{(%)?)(.*?)((?(4)%)\})',
|
| 1474 |
+
bygroups(Punctuation, Name.Builtin, Punctuation, None,
|
| 1475 |
+
using(PythonLexer), Punctuation)),
|
| 1476 |
+
# directive clauses (no {} expression)
|
| 1477 |
+
(r'(\$)(else|rof|fi)', bygroups(Punctuation, Name.Builtin)),
|
| 1478 |
+
# expressions
|
| 1479 |
+
(r'(\$\{(%)?)(.*?)((!)(.*?))?((?(2)%)\})',
|
| 1480 |
+
bygroups(Punctuation, None, using(PythonLexer),
|
| 1481 |
+
Name.Builtin, None, None, Punctuation)),
|
| 1482 |
+
(r'#', Other),
|
| 1483 |
+
],
|
| 1484 |
+
'comment': [
|
| 1485 |
+
(r'[^\]#]', Comment.Multiline),
|
| 1486 |
+
(r'#\[', Comment.Multiline, '#push'),
|
| 1487 |
+
(r'\]#', Comment.Multiline, '#pop'),
|
| 1488 |
+
(r'[\]#]', Comment.Multiline)
|
| 1489 |
+
],
|
| 1490 |
+
}
|
| 1491 |
+
|
| 1492 |
+
def analyse_text(text):
|
| 1493 |
+
"""Evoque templates use $evoque, which is unique."""
|
| 1494 |
+
if '$evoque' in text:
|
| 1495 |
+
return 1
|
| 1496 |
+
|
| 1497 |
+
class EvoqueHtmlLexer(DelegatingLexer):
|
| 1498 |
+
"""
|
| 1499 |
+
Subclass of the `EvoqueLexer` that highlights unlexed data with the
|
| 1500 |
+
`HtmlLexer`.
|
| 1501 |
+
"""
|
| 1502 |
+
name = 'HTML+Evoque'
|
| 1503 |
+
aliases = ['html+evoque']
|
| 1504 |
+
alias_filenames = ['*.html']
|
| 1505 |
+
mimetypes = ['text/html+evoque']
|
| 1506 |
+
url = 'https://gizmojo.org/templating'
|
| 1507 |
+
version_added = '1.1'
|
| 1508 |
+
|
| 1509 |
+
def __init__(self, **options):
|
| 1510 |
+
super().__init__(HtmlLexer, EvoqueLexer, **options)
|
| 1511 |
+
|
| 1512 |
+
def analyse_text(text):
|
| 1513 |
+
return EvoqueLexer.analyse_text(text)
|
| 1514 |
+
|
| 1515 |
+
|
| 1516 |
+
class EvoqueXmlLexer(DelegatingLexer):
|
| 1517 |
+
"""
|
| 1518 |
+
Subclass of the `EvoqueLexer` that highlights unlexed data with the
|
| 1519 |
+
`XmlLexer`.
|
| 1520 |
+
"""
|
| 1521 |
+
name = 'XML+Evoque'
|
| 1522 |
+
aliases = ['xml+evoque']
|
| 1523 |
+
alias_filenames = ['*.xml']
|
| 1524 |
+
mimetypes = ['application/xml+evoque']
|
| 1525 |
+
url = 'https://gizmojo.org/templating'
|
| 1526 |
+
version_added = '1.1'
|
| 1527 |
+
|
| 1528 |
+
def __init__(self, **options):
|
| 1529 |
+
super().__init__(XmlLexer, EvoqueLexer, **options)
|
| 1530 |
+
|
| 1531 |
+
def analyse_text(text):
|
| 1532 |
+
return EvoqueLexer.analyse_text(text)
|
| 1533 |
+
|
| 1534 |
+
|
| 1535 |
+
class ColdfusionLexer(RegexLexer):
|
| 1536 |
+
"""
|
| 1537 |
+
Coldfusion statements
|
| 1538 |
+
"""
|
| 1539 |
+
name = 'cfstatement'
|
| 1540 |
+
aliases = ['cfs']
|
| 1541 |
+
filenames = []
|
| 1542 |
+
mimetypes = []
|
| 1543 |
+
url = 'https://www.adobe.com/products/coldfusion-family.html'
|
| 1544 |
+
version_added = ''
|
| 1545 |
+
|
| 1546 |
+
flags = re.IGNORECASE
|
| 1547 |
+
|
| 1548 |
+
tokens = {
|
| 1549 |
+
'root': [
|
| 1550 |
+
(r'//.*?\n', Comment.Single),
|
| 1551 |
+
(r'/\*(?:.|\n)*?\*/', Comment.Multiline),
|
| 1552 |
+
(r'\+\+|--', Operator),
|
| 1553 |
+
(r'[-+*/^&=!]', Operator),
|
| 1554 |
+
(r'<=|>=|<|>|==', Operator),
|
| 1555 |
+
(r'mod\b', Operator),
|
| 1556 |
+
(r'(eq|lt|gt|lte|gte|not|is|and|or)\b', Operator),
|
| 1557 |
+
(r'\|\||&&', Operator),
|
| 1558 |
+
(r'\?', Operator),
|
| 1559 |
+
(r'"', String.Double, 'string'),
|
| 1560 |
+
# There is a special rule for allowing html in single quoted
|
| 1561 |
+
# strings, evidently.
|
| 1562 |
+
(r"'.*?'", String.Single),
|
| 1563 |
+
(r'\d+', Number),
|
| 1564 |
+
(r'(if|else|len|var|xml|default|break|switch|component|property|function|do|'
|
| 1565 |
+
r'try|catch|in|continue|for|return|while|required|any|array|binary|boolean|'
|
| 1566 |
+
r'component|date|guid|numeric|query|string|struct|uuid|case)\b', Keyword),
|
| 1567 |
+
(r'(true|false|null)\b', Keyword.Constant),
|
| 1568 |
+
(r'(application|session|client|cookie|super|this|variables|arguments)\b',
|
| 1569 |
+
Name.Constant),
|
| 1570 |
+
(r'([a-z_$][\w.]*)(\s*)(\()',
|
| 1571 |
+
bygroups(Name.Function, Text, Punctuation)),
|
| 1572 |
+
(r'[a-z_$][\w.]*', Name.Variable),
|
| 1573 |
+
(r'[()\[\]{};:,.\\]', Punctuation),
|
| 1574 |
+
(r'\s+', Text),
|
| 1575 |
+
],
|
| 1576 |
+
'string': [
|
| 1577 |
+
(r'""', String.Double),
|
| 1578 |
+
(r'#.+?#', String.Interp),
|
| 1579 |
+
(r'[^"#]+', String.Double),
|
| 1580 |
+
(r'#', String.Double),
|
| 1581 |
+
(r'"', String.Double, '#pop'),
|
| 1582 |
+
],
|
| 1583 |
+
}
|
| 1584 |
+
|
| 1585 |
+
|
| 1586 |
+
class ColdfusionMarkupLexer(RegexLexer):
|
| 1587 |
+
"""
|
| 1588 |
+
Coldfusion markup only
|
| 1589 |
+
"""
|
| 1590 |
+
name = 'Coldfusion'
|
| 1591 |
+
aliases = ['cf']
|
| 1592 |
+
filenames = []
|
| 1593 |
+
mimetypes = []
|
| 1594 |
+
url = 'https://www.adobe.com/products/coldfusion-family.html'
|
| 1595 |
+
|
| 1596 |
+
tokens = {
|
| 1597 |
+
'root': [
|
| 1598 |
+
(r'[^<]+', Other),
|
| 1599 |
+
include('tags'),
|
| 1600 |
+
(r'<[^<>]*', Other),
|
| 1601 |
+
],
|
| 1602 |
+
'tags': [
|
| 1603 |
+
(r'<!---', Comment.Multiline, 'cfcomment'),
|
| 1604 |
+
(r'(?s)<!--.*?-->', Comment),
|
| 1605 |
+
(r'<cfoutput.*?>', Name.Builtin, 'cfoutput'),
|
| 1606 |
+
(r'(?s)(<cfscript.*?>)(.+?)(</cfscript.*?>)',
|
| 1607 |
+
bygroups(Name.Builtin, using(ColdfusionLexer), Name.Builtin)),
|
| 1608 |
+
# negative lookbehind is for strings with embedded >
|
| 1609 |
+
(r'(?s)(</?cf(?:component|include|if|else|elseif|loop|return|'
|
| 1610 |
+
r'dbinfo|dump|abort|location|invoke|throw|file|savecontent|'
|
| 1611 |
+
r'mailpart|mail|header|content|zip|image|lock|argument|try|'
|
| 1612 |
+
r'catch|break|directory|http|set|function|param)\b)(.*?)((?<!\\)>)',
|
| 1613 |
+
bygroups(Name.Builtin, using(ColdfusionLexer), Name.Builtin)),
|
| 1614 |
+
],
|
| 1615 |
+
'cfoutput': [
|
| 1616 |
+
(r'[^#<]+', Other),
|
| 1617 |
+
(r'(#)(.*?)(#)', bygroups(Punctuation, using(ColdfusionLexer),
|
| 1618 |
+
Punctuation)),
|
| 1619 |
+
# (r'<cfoutput.*?>', Name.Builtin, '#push'),
|
| 1620 |
+
(r'</cfoutput.*?>', Name.Builtin, '#pop'),
|
| 1621 |
+
include('tags'),
|
| 1622 |
+
(r'(?s)<[^<>]*', Other),
|
| 1623 |
+
(r'#', Other),
|
| 1624 |
+
],
|
| 1625 |
+
'cfcomment': [
|
| 1626 |
+
(r'<!---', Comment.Multiline, '#push'),
|
| 1627 |
+
(r'--->', Comment.Multiline, '#pop'),
|
| 1628 |
+
(r'([^<-]|<(?!!---)|-(?!-->))+', Comment.Multiline),
|
| 1629 |
+
],
|
| 1630 |
+
}
|
| 1631 |
+
|
| 1632 |
+
|
| 1633 |
+
class ColdfusionHtmlLexer(DelegatingLexer):
|
| 1634 |
+
"""
|
| 1635 |
+
Coldfusion markup in html
|
| 1636 |
+
"""
|
| 1637 |
+
name = 'Coldfusion HTML'
|
| 1638 |
+
aliases = ['cfm']
|
| 1639 |
+
filenames = ['*.cfm', '*.cfml']
|
| 1640 |
+
mimetypes = ['application/x-coldfusion']
|
| 1641 |
+
url = 'https://www.adobe.com/products/coldfusion-family.html'
|
| 1642 |
+
version_added = ''
|
| 1643 |
+
|
| 1644 |
+
def __init__(self, **options):
|
| 1645 |
+
super().__init__(HtmlLexer, ColdfusionMarkupLexer, **options)
|
| 1646 |
+
|
| 1647 |
+
|
| 1648 |
+
class ColdfusionCFCLexer(DelegatingLexer):
|
| 1649 |
+
"""
|
| 1650 |
+
Coldfusion markup/script components
|
| 1651 |
+
"""
|
| 1652 |
+
name = 'Coldfusion CFC'
|
| 1653 |
+
aliases = ['cfc']
|
| 1654 |
+
filenames = ['*.cfc']
|
| 1655 |
+
mimetypes = []
|
| 1656 |
+
url = 'https://www.adobe.com/products/coldfusion-family.html'
|
| 1657 |
+
version_added = '2.0'
|
| 1658 |
+
|
| 1659 |
+
def __init__(self, **options):
|
| 1660 |
+
super().__init__(ColdfusionHtmlLexer, ColdfusionLexer, **options)
|
| 1661 |
+
|
| 1662 |
+
|
| 1663 |
+
class SspLexer(DelegatingLexer):
|
| 1664 |
+
"""
|
| 1665 |
+
Lexer for Scalate Server Pages.
|
| 1666 |
+
"""
|
| 1667 |
+
name = 'Scalate Server Page'
|
| 1668 |
+
aliases = ['ssp']
|
| 1669 |
+
filenames = ['*.ssp']
|
| 1670 |
+
mimetypes = ['application/x-ssp']
|
| 1671 |
+
url = 'https://scalate.github.io/scalate/'
|
| 1672 |
+
version_added = '1.4'
|
| 1673 |
+
|
| 1674 |
+
def __init__(self, **options):
|
| 1675 |
+
super().__init__(XmlLexer, JspRootLexer, **options)
|
| 1676 |
+
|
| 1677 |
+
def analyse_text(text):
|
| 1678 |
+
rv = 0.0
|
| 1679 |
+
if re.search(r'val \w+\s*:', text):
|
| 1680 |
+
rv += 0.6
|
| 1681 |
+
if looks_like_xml(text):
|
| 1682 |
+
rv += 0.2
|
| 1683 |
+
if '<%' in text and '%>' in text:
|
| 1684 |
+
rv += 0.1
|
| 1685 |
+
return rv
|
| 1686 |
+
|
| 1687 |
+
|
| 1688 |
+
class TeaTemplateRootLexer(RegexLexer):
|
| 1689 |
+
"""
|
| 1690 |
+
Base for the `TeaTemplateLexer`. Yields `Token.Other` for area outside of
|
| 1691 |
+
code blocks.
|
| 1692 |
+
|
| 1693 |
+
.. versionadded:: 1.5
|
| 1694 |
+
"""
|
| 1695 |
+
|
| 1696 |
+
tokens = {
|
| 1697 |
+
'root': [
|
| 1698 |
+
(r'<%\S?', Keyword, 'sec'),
|
| 1699 |
+
(r'[^<]+', Other),
|
| 1700 |
+
(r'<', Other),
|
| 1701 |
+
],
|
| 1702 |
+
'sec': [
|
| 1703 |
+
(r'%>', Keyword, '#pop'),
|
| 1704 |
+
# note: '\w\W' != '.' without DOTALL.
|
| 1705 |
+
(r'[\w\W]+?(?=%>|\Z)', using(TeaLangLexer)),
|
| 1706 |
+
],
|
| 1707 |
+
}
|
| 1708 |
+
|
| 1709 |
+
|
| 1710 |
+
class TeaTemplateLexer(DelegatingLexer):
|
| 1711 |
+
"""
|
| 1712 |
+
Lexer for Tea Templates.
|
| 1713 |
+
"""
|
| 1714 |
+
name = 'Tea'
|
| 1715 |
+
aliases = ['tea']
|
| 1716 |
+
filenames = ['*.tea']
|
| 1717 |
+
mimetypes = ['text/x-tea']
|
| 1718 |
+
url = 'https://github.com/teatrove/teatrove'
|
| 1719 |
+
version_added = '1.5'
|
| 1720 |
+
|
| 1721 |
+
def __init__(self, **options):
|
| 1722 |
+
super().__init__(XmlLexer, TeaTemplateRootLexer, **options)
|
| 1723 |
+
|
| 1724 |
+
def analyse_text(text):
|
| 1725 |
+
rv = TeaLangLexer.analyse_text(text) - 0.01
|
| 1726 |
+
if looks_like_xml(text):
|
| 1727 |
+
rv += 0.4
|
| 1728 |
+
if '<%' in text and '%>' in text:
|
| 1729 |
+
rv += 0.1
|
| 1730 |
+
return rv
|
| 1731 |
+
|
| 1732 |
+
|
| 1733 |
+
class LassoHtmlLexer(DelegatingLexer):
|
| 1734 |
+
"""
|
| 1735 |
+
Subclass of the `LassoLexer` which highlights unhandled data with the
|
| 1736 |
+
`HtmlLexer`.
|
| 1737 |
+
|
| 1738 |
+
Nested JavaScript and CSS is also highlighted.
|
| 1739 |
+
"""
|
| 1740 |
+
|
| 1741 |
+
name = 'HTML+Lasso'
|
| 1742 |
+
aliases = ['html+lasso']
|
| 1743 |
+
version_added = '1.6'
|
| 1744 |
+
alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.lasso', '*.lasso[89]',
|
| 1745 |
+
'*.incl', '*.inc', '*.las']
|
| 1746 |
+
mimetypes = ['text/html+lasso',
|
| 1747 |
+
'application/x-httpd-lasso',
|
| 1748 |
+
'application/x-httpd-lasso[89]']
|
| 1749 |
+
url = 'https://www.lassosoft.com'
|
| 1750 |
+
|
| 1751 |
+
def __init__(self, **options):
|
| 1752 |
+
super().__init__(HtmlLexer, LassoLexer, **options)
|
| 1753 |
+
|
| 1754 |
+
def analyse_text(text):
|
| 1755 |
+
rv = LassoLexer.analyse_text(text) - 0.01
|
| 1756 |
+
if html_doctype_matches(text): # same as HTML lexer
|
| 1757 |
+
rv += 0.5
|
| 1758 |
+
return rv
|
| 1759 |
+
|
| 1760 |
+
|
| 1761 |
+
class LassoXmlLexer(DelegatingLexer):
|
| 1762 |
+
"""
|
| 1763 |
+
Subclass of the `LassoLexer` which highlights unhandled data with the
|
| 1764 |
+
`XmlLexer`.
|
| 1765 |
+
"""
|
| 1766 |
+
|
| 1767 |
+
name = 'XML+Lasso'
|
| 1768 |
+
aliases = ['xml+lasso']
|
| 1769 |
+
version_added = '1.6'
|
| 1770 |
+
alias_filenames = ['*.xml', '*.lasso', '*.lasso[89]',
|
| 1771 |
+
'*.incl', '*.inc', '*.las']
|
| 1772 |
+
mimetypes = ['application/xml+lasso']
|
| 1773 |
+
url = 'https://www.lassosoft.com'
|
| 1774 |
+
|
| 1775 |
+
def __init__(self, **options):
|
| 1776 |
+
super().__init__(XmlLexer, LassoLexer, **options)
|
| 1777 |
+
|
| 1778 |
+
def analyse_text(text):
|
| 1779 |
+
rv = LassoLexer.analyse_text(text) - 0.01
|
| 1780 |
+
if looks_like_xml(text):
|
| 1781 |
+
rv += 0.4
|
| 1782 |
+
return rv
|
| 1783 |
+
|
| 1784 |
+
|
| 1785 |
+
class LassoCssLexer(DelegatingLexer):
|
| 1786 |
+
"""
|
| 1787 |
+
Subclass of the `LassoLexer` which highlights unhandled data with the
|
| 1788 |
+
`CssLexer`.
|
| 1789 |
+
"""
|
| 1790 |
+
|
| 1791 |
+
name = 'CSS+Lasso'
|
| 1792 |
+
aliases = ['css+lasso']
|
| 1793 |
+
version_added = '1.6'
|
| 1794 |
+
alias_filenames = ['*.css']
|
| 1795 |
+
mimetypes = ['text/css+lasso']
|
| 1796 |
+
url = 'https://www.lassosoft.com'
|
| 1797 |
+
|
| 1798 |
+
def __init__(self, **options):
|
| 1799 |
+
options['requiredelimiters'] = True
|
| 1800 |
+
super().__init__(CssLexer, LassoLexer, **options)
|
| 1801 |
+
|
| 1802 |
+
def analyse_text(text):
|
| 1803 |
+
rv = LassoLexer.analyse_text(text) - 0.05
|
| 1804 |
+
if re.search(r'\w+:[^;]+;', text):
|
| 1805 |
+
rv += 0.1
|
| 1806 |
+
if 'padding:' in text:
|
| 1807 |
+
rv += 0.1
|
| 1808 |
+
return rv
|
| 1809 |
+
|
| 1810 |
+
|
| 1811 |
+
class LassoJavascriptLexer(DelegatingLexer):
|
| 1812 |
+
"""
|
| 1813 |
+
Subclass of the `LassoLexer` which highlights unhandled data with the
|
| 1814 |
+
`JavascriptLexer`.
|
| 1815 |
+
"""
|
| 1816 |
+
|
| 1817 |
+
name = 'JavaScript+Lasso'
|
| 1818 |
+
aliases = ['javascript+lasso', 'js+lasso']
|
| 1819 |
+
version_added = '1.6'
|
| 1820 |
+
alias_filenames = ['*.js']
|
| 1821 |
+
mimetypes = ['application/x-javascript+lasso',
|
| 1822 |
+
'text/x-javascript+lasso',
|
| 1823 |
+
'text/javascript+lasso']
|
| 1824 |
+
url = 'https://www.lassosoft.com'
|
| 1825 |
+
|
| 1826 |
+
def __init__(self, **options):
|
| 1827 |
+
options['requiredelimiters'] = True
|
| 1828 |
+
super().__init__(JavascriptLexer, LassoLexer, **options)
|
| 1829 |
+
|
| 1830 |
+
def analyse_text(text):
|
| 1831 |
+
rv = LassoLexer.analyse_text(text) - 0.05
|
| 1832 |
+
return rv
|
| 1833 |
+
|
| 1834 |
+
|
| 1835 |
+
class HandlebarsLexer(RegexLexer):
|
| 1836 |
+
"""
|
| 1837 |
+
Generic handlebars template lexer.
|
| 1838 |
+
|
| 1839 |
+
Highlights only the Handlebars template tags (stuff between `{{` and `}}`).
|
| 1840 |
+
Everything else is left for a delegating lexer.
|
| 1841 |
+
"""
|
| 1842 |
+
|
| 1843 |
+
name = "Handlebars"
|
| 1844 |
+
url = 'https://handlebarsjs.com/'
|
| 1845 |
+
aliases = ['handlebars']
|
| 1846 |
+
version_added = '2.0'
|
| 1847 |
+
|
| 1848 |
+
tokens = {
|
| 1849 |
+
'root': [
|
| 1850 |
+
(r'[^{]+', Other),
|
| 1851 |
+
|
| 1852 |
+
# Comment start {{! }} or {{!--
|
| 1853 |
+
(r'\{\{!.*\}\}', Comment),
|
| 1854 |
+
|
| 1855 |
+
# HTML Escaping open {{{expression
|
| 1856 |
+
(r'(\{\{\{)(\s*)', bygroups(Comment.Special, Text), 'tag'),
|
| 1857 |
+
|
| 1858 |
+
# {{blockOpen {{#blockOpen {{/blockClose with optional tilde ~
|
| 1859 |
+
(r'(\{\{)([#~/]+)([^\s}]*)',
|
| 1860 |
+
bygroups(Comment.Preproc, Number.Attribute, Number.Attribute), 'tag'),
|
| 1861 |
+
(r'(\{\{)(\s*)', bygroups(Comment.Preproc, Text), 'tag'),
|
| 1862 |
+
],
|
| 1863 |
+
|
| 1864 |
+
'tag': [
|
| 1865 |
+
(r'\s+', Text),
|
| 1866 |
+
# HTML Escaping close }}}
|
| 1867 |
+
(r'\}\}\}', Comment.Special, '#pop'),
|
| 1868 |
+
# blockClose}}, includes optional tilde ~
|
| 1869 |
+
(r'(~?)(\}\})', bygroups(Number, Comment.Preproc), '#pop'),
|
| 1870 |
+
|
| 1871 |
+
# {{opt=something}}
|
| 1872 |
+
(r'([^\s}]+)(=)', bygroups(Name.Attribute, Operator)),
|
| 1873 |
+
|
| 1874 |
+
# Partials {{> ...}}
|
| 1875 |
+
(r'(>)(\s*)(@partial-block)', bygroups(Keyword, Text, Keyword)),
|
| 1876 |
+
(r'(#?>)(\s*)([\w-]+)', bygroups(Keyword, Text, Name.Variable)),
|
| 1877 |
+
(r'(>)(\s*)(\()', bygroups(Keyword, Text, Punctuation),
|
| 1878 |
+
'dynamic-partial'),
|
| 1879 |
+
|
| 1880 |
+
include('generic'),
|
| 1881 |
+
],
|
| 1882 |
+
'dynamic-partial': [
|
| 1883 |
+
(r'\s+', Text),
|
| 1884 |
+
(r'\)', Punctuation, '#pop'),
|
| 1885 |
+
|
| 1886 |
+
(r'(lookup)(\s+)(\.|this)(\s+)', bygroups(Keyword, Text,
|
| 1887 |
+
Name.Variable, Text)),
|
| 1888 |
+
(r'(lookup)(\s+)(\S+)', bygroups(Keyword, Text,
|
| 1889 |
+
using(this, state='variable'))),
|
| 1890 |
+
(r'[\w-]+', Name.Function),
|
| 1891 |
+
|
| 1892 |
+
include('generic'),
|
| 1893 |
+
],
|
| 1894 |
+
'variable': [
|
| 1895 |
+
(r'[()/@a-zA-Z][\w-]*', Name.Variable),
|
| 1896 |
+
(r'\.[\w-]+', Name.Variable),
|
| 1897 |
+
(r'(this\/|\.\/|(\.\.\/)+)[\w-]+', Name.Variable),
|
| 1898 |
+
],
|
| 1899 |
+
'generic': [
|
| 1900 |
+
include('variable'),
|
| 1901 |
+
|
| 1902 |
+
# borrowed from DjangoLexer
|
| 1903 |
+
(r':?"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 1904 |
+
(r":?'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 1905 |
+
(r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
|
| 1906 |
+
r"0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 1907 |
+
]
|
| 1908 |
+
}
|
| 1909 |
+
|
| 1910 |
+
|
| 1911 |
+
class HandlebarsHtmlLexer(DelegatingLexer):
|
| 1912 |
+
"""
|
| 1913 |
+
Subclass of the `HandlebarsLexer` that highlights unlexed data with the
|
| 1914 |
+
`HtmlLexer`.
|
| 1915 |
+
"""
|
| 1916 |
+
|
| 1917 |
+
name = "HTML+Handlebars"
|
| 1918 |
+
aliases = ["html+handlebars"]
|
| 1919 |
+
filenames = ['*.handlebars', '*.hbs']
|
| 1920 |
+
mimetypes = ['text/html+handlebars', 'text/x-handlebars-template']
|
| 1921 |
+
url = 'https://handlebarsjs.com/'
|
| 1922 |
+
version_added = '2.0'
|
| 1923 |
+
|
| 1924 |
+
def __init__(self, **options):
|
| 1925 |
+
super().__init__(HtmlLexer, HandlebarsLexer, **options)
|
| 1926 |
+
|
| 1927 |
+
|
| 1928 |
+
class YamlJinjaLexer(DelegatingLexer):
|
| 1929 |
+
"""
|
| 1930 |
+
Subclass of the `DjangoLexer` that highlights unlexed data with the
|
| 1931 |
+
`YamlLexer`.
|
| 1932 |
+
|
| 1933 |
+
Commonly used in Saltstack salt states.
|
| 1934 |
+
"""
|
| 1935 |
+
|
| 1936 |
+
name = 'YAML+Jinja'
|
| 1937 |
+
aliases = ['yaml+jinja', 'salt', 'sls']
|
| 1938 |
+
filenames = ['*.sls', '*.yaml.j2', '*.yml.j2', '*.yaml.jinja2', '*.yml.jinja2']
|
| 1939 |
+
mimetypes = ['text/x-yaml+jinja', 'text/x-sls']
|
| 1940 |
+
url = 'https://jinja.palletsprojects.com'
|
| 1941 |
+
version_added = '2.0'
|
| 1942 |
+
|
| 1943 |
+
def __init__(self, **options):
|
| 1944 |
+
super().__init__(YamlLexer, DjangoLexer, **options)
|
| 1945 |
+
|
| 1946 |
+
|
| 1947 |
+
class LiquidLexer(RegexLexer):
|
| 1948 |
+
"""
|
| 1949 |
+
Lexer for Liquid templates.
|
| 1950 |
+
"""
|
| 1951 |
+
name = 'liquid'
|
| 1952 |
+
url = 'https://www.rubydoc.info/github/Shopify/liquid'
|
| 1953 |
+
aliases = ['liquid']
|
| 1954 |
+
filenames = ['*.liquid']
|
| 1955 |
+
version_added = '2.0'
|
| 1956 |
+
|
| 1957 |
+
tokens = {
|
| 1958 |
+
'root': [
|
| 1959 |
+
(r'[^{]+', Text),
|
| 1960 |
+
# tags and block tags
|
| 1961 |
+
(r'(\{%)(\s*)', bygroups(Punctuation, Whitespace), 'tag-or-block'),
|
| 1962 |
+
# output tags
|
| 1963 |
+
(r'(\{\{)(\s*)([^\s}]+)',
|
| 1964 |
+
bygroups(Punctuation, Whitespace, using(this, state = 'generic')),
|
| 1965 |
+
'output'),
|
| 1966 |
+
(r'\{', Text)
|
| 1967 |
+
],
|
| 1968 |
+
|
| 1969 |
+
'tag-or-block': [
|
| 1970 |
+
# builtin logic blocks
|
| 1971 |
+
(r'(if|unless|elsif|case)(?=\s+)', Keyword.Reserved, 'condition'),
|
| 1972 |
+
(r'(when)(\s+)', bygroups(Keyword.Reserved, Whitespace),
|
| 1973 |
+
combined('end-of-block', 'whitespace', 'generic')),
|
| 1974 |
+
(r'(else)(\s*)(%\})',
|
| 1975 |
+
bygroups(Keyword.Reserved, Whitespace, Punctuation), '#pop'),
|
| 1976 |
+
|
| 1977 |
+
# other builtin blocks
|
| 1978 |
+
(r'(capture)(\s+)([^\s%]+)(\s*)(%\})',
|
| 1979 |
+
bygroups(Name.Tag, Whitespace, using(this, state = 'variable'),
|
| 1980 |
+
Whitespace, Punctuation), '#pop'),
|
| 1981 |
+
(r'(comment)(\s*)(%\})',
|
| 1982 |
+
bygroups(Name.Tag, Whitespace, Punctuation), 'comment'),
|
| 1983 |
+
(r'(raw)(\s*)(%\})',
|
| 1984 |
+
bygroups(Name.Tag, Whitespace, Punctuation), 'raw'),
|
| 1985 |
+
|
| 1986 |
+
# end of block
|
| 1987 |
+
(r'(end(case|unless|if))(\s*)(%\})',
|
| 1988 |
+
bygroups(Keyword.Reserved, None, Whitespace, Punctuation), '#pop'),
|
| 1989 |
+
(r'(end([^\s%]+))(\s*)(%\})',
|
| 1990 |
+
bygroups(Name.Tag, None, Whitespace, Punctuation), '#pop'),
|
| 1991 |
+
|
| 1992 |
+
# builtin tags (assign and include are handled together with usual tags)
|
| 1993 |
+
(r'(cycle)(\s+)(?:([^\s:]*)(:))?(\s*)',
|
| 1994 |
+
bygroups(Name.Tag, Whitespace,
|
| 1995 |
+
using(this, state='generic'), Punctuation, Whitespace),
|
| 1996 |
+
'variable-tag-markup'),
|
| 1997 |
+
|
| 1998 |
+
# other tags or blocks
|
| 1999 |
+
(r'([^\s%]+)(\s*)', bygroups(Name.Tag, Whitespace), 'tag-markup')
|
| 2000 |
+
],
|
| 2001 |
+
|
| 2002 |
+
'output': [
|
| 2003 |
+
include('whitespace'),
|
| 2004 |
+
(r'\}\}', Punctuation, '#pop'), # end of output
|
| 2005 |
+
|
| 2006 |
+
(r'\|', Punctuation, 'filters')
|
| 2007 |
+
],
|
| 2008 |
+
|
| 2009 |
+
'filters': [
|
| 2010 |
+
include('whitespace'),
|
| 2011 |
+
(r'\}\}', Punctuation, ('#pop', '#pop')), # end of filters and output
|
| 2012 |
+
|
| 2013 |
+
(r'([^\s|:]+)(:?)(\s*)',
|
| 2014 |
+
bygroups(Name.Function, Punctuation, Whitespace), 'filter-markup')
|
| 2015 |
+
],
|
| 2016 |
+
|
| 2017 |
+
'filter-markup': [
|
| 2018 |
+
(r'\|', Punctuation, '#pop'),
|
| 2019 |
+
include('end-of-tag'),
|
| 2020 |
+
include('default-param-markup')
|
| 2021 |
+
],
|
| 2022 |
+
|
| 2023 |
+
'condition': [
|
| 2024 |
+
include('end-of-block'),
|
| 2025 |
+
include('whitespace'),
|
| 2026 |
+
|
| 2027 |
+
(r'([^\s=!><]+)(\s*)([=!><]=?)(\s*)(\S+)(\s*)(%\})',
|
| 2028 |
+
bygroups(using(this, state = 'generic'), Whitespace, Operator,
|
| 2029 |
+
Whitespace, using(this, state = 'generic'), Whitespace,
|
| 2030 |
+
Punctuation)),
|
| 2031 |
+
(r'\b!', Operator),
|
| 2032 |
+
(r'\bnot\b', Operator.Word),
|
| 2033 |
+
(r'([\w.\'"]+)(\s+)(contains)(\s+)([\w.\'"]+)',
|
| 2034 |
+
bygroups(using(this, state = 'generic'), Whitespace, Operator.Word,
|
| 2035 |
+
Whitespace, using(this, state = 'generic'))),
|
| 2036 |
+
|
| 2037 |
+
include('generic'),
|
| 2038 |
+
include('whitespace')
|
| 2039 |
+
],
|
| 2040 |
+
|
| 2041 |
+
'generic-value': [
|
| 2042 |
+
include('generic'),
|
| 2043 |
+
include('end-at-whitespace')
|
| 2044 |
+
],
|
| 2045 |
+
|
| 2046 |
+
'operator': [
|
| 2047 |
+
(r'(\s*)((=|!|>|<)=?)(\s*)',
|
| 2048 |
+
bygroups(Whitespace, Operator, None, Whitespace), '#pop'),
|
| 2049 |
+
(r'(\s*)(\bcontains\b)(\s*)',
|
| 2050 |
+
bygroups(Whitespace, Operator.Word, Whitespace), '#pop'),
|
| 2051 |
+
],
|
| 2052 |
+
|
| 2053 |
+
'end-of-tag': [
|
| 2054 |
+
(r'\}\}', Punctuation, '#pop')
|
| 2055 |
+
],
|
| 2056 |
+
|
| 2057 |
+
'end-of-block': [
|
| 2058 |
+
(r'%\}', Punctuation, ('#pop', '#pop'))
|
| 2059 |
+
],
|
| 2060 |
+
|
| 2061 |
+
'end-at-whitespace': [
|
| 2062 |
+
(r'\s+', Whitespace, '#pop')
|
| 2063 |
+
],
|
| 2064 |
+
|
| 2065 |
+
# states for unknown markup
|
| 2066 |
+
'param-markup': [
|
| 2067 |
+
include('whitespace'),
|
| 2068 |
+
# params with colons or equals
|
| 2069 |
+
(r'([^\s=:]+)(\s*)(=|:)',
|
| 2070 |
+
bygroups(Name.Attribute, Whitespace, Operator)),
|
| 2071 |
+
# explicit variables
|
| 2072 |
+
(r'(\{\{)(\s*)([^\s}])(\s*)(\}\})',
|
| 2073 |
+
bygroups(Punctuation, Whitespace, using(this, state = 'variable'),
|
| 2074 |
+
Whitespace, Punctuation)),
|
| 2075 |
+
|
| 2076 |
+
include('string'),
|
| 2077 |
+
include('number'),
|
| 2078 |
+
include('keyword'),
|
| 2079 |
+
(r',', Punctuation)
|
| 2080 |
+
],
|
| 2081 |
+
|
| 2082 |
+
'default-param-markup': [
|
| 2083 |
+
include('param-markup'),
|
| 2084 |
+
(r'.', Text) # fallback for switches / variables / un-quoted strings / ...
|
| 2085 |
+
],
|
| 2086 |
+
|
| 2087 |
+
'variable-param-markup': [
|
| 2088 |
+
include('param-markup'),
|
| 2089 |
+
include('variable'),
|
| 2090 |
+
(r'.', Text) # fallback
|
| 2091 |
+
],
|
| 2092 |
+
|
| 2093 |
+
'tag-markup': [
|
| 2094 |
+
(r'%\}', Punctuation, ('#pop', '#pop')), # end of tag
|
| 2095 |
+
include('default-param-markup')
|
| 2096 |
+
],
|
| 2097 |
+
|
| 2098 |
+
'variable-tag-markup': [
|
| 2099 |
+
(r'%\}', Punctuation, ('#pop', '#pop')), # end of tag
|
| 2100 |
+
include('variable-param-markup')
|
| 2101 |
+
],
|
| 2102 |
+
|
| 2103 |
+
# states for different values types
|
| 2104 |
+
'keyword': [
|
| 2105 |
+
(r'\b(false|true)\b', Keyword.Constant)
|
| 2106 |
+
],
|
| 2107 |
+
|
| 2108 |
+
'variable': [
|
| 2109 |
+
(r'[a-zA-Z_]\w*', Name.Variable),
|
| 2110 |
+
(r'(?<=\w)\.(?=\w)', Punctuation)
|
| 2111 |
+
],
|
| 2112 |
+
|
| 2113 |
+
'string': [
|
| 2114 |
+
(r"'[^']*'", String.Single),
|
| 2115 |
+
(r'"[^"]*"', String.Double)
|
| 2116 |
+
],
|
| 2117 |
+
|
| 2118 |
+
'number': [
|
| 2119 |
+
(r'\d+\.\d+', Number.Float),
|
| 2120 |
+
(r'\d+', Number.Integer)
|
| 2121 |
+
],
|
| 2122 |
+
|
| 2123 |
+
'generic': [ # decides for variable, string, keyword or number
|
| 2124 |
+
include('keyword'),
|
| 2125 |
+
include('string'),
|
| 2126 |
+
include('number'),
|
| 2127 |
+
include('variable')
|
| 2128 |
+
],
|
| 2129 |
+
|
| 2130 |
+
'whitespace': [
|
| 2131 |
+
(r'[ \t]+', Whitespace)
|
| 2132 |
+
],
|
| 2133 |
+
|
| 2134 |
+
# states for builtin blocks
|
| 2135 |
+
'comment': [
|
| 2136 |
+
(r'(\{%)(\s*)(endcomment)(\s*)(%\})',
|
| 2137 |
+
bygroups(Punctuation, Whitespace, Name.Tag, Whitespace,
|
| 2138 |
+
Punctuation), ('#pop', '#pop')),
|
| 2139 |
+
(r'.', Comment)
|
| 2140 |
+
],
|
| 2141 |
+
|
| 2142 |
+
'raw': [
|
| 2143 |
+
(r'[^{]+', Text),
|
| 2144 |
+
(r'(\{%)(\s*)(endraw)(\s*)(%\})',
|
| 2145 |
+
bygroups(Punctuation, Whitespace, Name.Tag, Whitespace,
|
| 2146 |
+
Punctuation), '#pop'),
|
| 2147 |
+
(r'\{', Text)
|
| 2148 |
+
],
|
| 2149 |
+
}
|
| 2150 |
+
|
| 2151 |
+
|
| 2152 |
+
class TwigLexer(RegexLexer):
|
| 2153 |
+
"""
|
| 2154 |
+
Twig template lexer.
|
| 2155 |
+
|
| 2156 |
+
It just highlights Twig code between the preprocessor directives,
|
| 2157 |
+
other data is left untouched by the lexer.
|
| 2158 |
+
"""
|
| 2159 |
+
|
| 2160 |
+
name = 'Twig'
|
| 2161 |
+
aliases = ['twig']
|
| 2162 |
+
mimetypes = ['application/x-twig']
|
| 2163 |
+
url = 'https://twig.symfony.com'
|
| 2164 |
+
version_added = '2.0'
|
| 2165 |
+
|
| 2166 |
+
flags = re.M | re.S
|
| 2167 |
+
|
| 2168 |
+
# Note that a backslash is included in the following two patterns
|
| 2169 |
+
# PHP uses a backslash as a namespace separator
|
| 2170 |
+
_ident_char = r'[\\\w-]|[^\x00-\x7f]'
|
| 2171 |
+
_ident_begin = r'(?:[\\_a-z]|[^\x00-\x7f])'
|
| 2172 |
+
_ident_end = r'(?:' + _ident_char + ')*'
|
| 2173 |
+
_ident_inner = _ident_begin + _ident_end
|
| 2174 |
+
|
| 2175 |
+
tokens = {
|
| 2176 |
+
'root': [
|
| 2177 |
+
(r'[^{]+', Other),
|
| 2178 |
+
(r'\{\{', Comment.Preproc, 'var'),
|
| 2179 |
+
# twig comments
|
| 2180 |
+
(r'\{\#.*?\#\}', Comment),
|
| 2181 |
+
# raw twig blocks
|
| 2182 |
+
(r'(\{%)(-?\s*)(raw)(\s*-?)(%\})(.*?)'
|
| 2183 |
+
r'(\{%)(-?\s*)(endraw)(\s*-?)(%\})',
|
| 2184 |
+
bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc,
|
| 2185 |
+
Other, Comment.Preproc, Text, Keyword, Text,
|
| 2186 |
+
Comment.Preproc)),
|
| 2187 |
+
(r'(\{%)(-?\s*)(verbatim)(\s*-?)(%\})(.*?)'
|
| 2188 |
+
r'(\{%)(-?\s*)(endverbatim)(\s*-?)(%\})',
|
| 2189 |
+
bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc,
|
| 2190 |
+
Other, Comment.Preproc, Text, Keyword, Text,
|
| 2191 |
+
Comment.Preproc)),
|
| 2192 |
+
# filter blocks
|
| 2193 |
+
(rf'(\{{%)(-?\s*)(filter)(\s+)({_ident_inner})',
|
| 2194 |
+
bygroups(Comment.Preproc, Text, Keyword, Text, Name.Function),
|
| 2195 |
+
'tag'),
|
| 2196 |
+
(r'(\{%)(-?\s*)([a-zA-Z_]\w*)',
|
| 2197 |
+
bygroups(Comment.Preproc, Text, Keyword), 'tag'),
|
| 2198 |
+
(r'\{', Other),
|
| 2199 |
+
],
|
| 2200 |
+
'varnames': [
|
| 2201 |
+
(rf'(\|)(\s*)({_ident_inner})',
|
| 2202 |
+
bygroups(Operator, Text, Name.Function)),
|
| 2203 |
+
(rf'(is)(\s+)(not)?(\s*)({_ident_inner})',
|
| 2204 |
+
bygroups(Keyword, Text, Keyword, Text, Name.Function)),
|
| 2205 |
+
(r'(?i)(true|false|none|null)\b', Keyword.Pseudo),
|
| 2206 |
+
(r'(in|not|and|b-and|or|b-or|b-xor|is'
|
| 2207 |
+
r'if|elseif|else|import'
|
| 2208 |
+
r'constant|defined|divisibleby|empty|even|iterable|odd|sameas'
|
| 2209 |
+
r'matches|starts\s+with|ends\s+with)\b',
|
| 2210 |
+
Keyword),
|
| 2211 |
+
(r'(loop|block|parent)\b', Name.Builtin),
|
| 2212 |
+
(_ident_inner, Name.Variable),
|
| 2213 |
+
(r'\.' + _ident_inner, Name.Variable),
|
| 2214 |
+
(r'\.[0-9]+', Number),
|
| 2215 |
+
(r':?"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 2216 |
+
(r":?'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 2217 |
+
(r'([{}()\[\]+\-*/,:~%]|\.\.|\?|:|\*\*|\/\/|!=|[><=]=?)', Operator),
|
| 2218 |
+
(r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
|
| 2219 |
+
r"0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 2220 |
+
],
|
| 2221 |
+
'var': [
|
| 2222 |
+
(r'\s+', Text),
|
| 2223 |
+
(r'(-?)(\}\})', bygroups(Text, Comment.Preproc), '#pop'),
|
| 2224 |
+
include('varnames')
|
| 2225 |
+
],
|
| 2226 |
+
'tag': [
|
| 2227 |
+
(r'\s+', Text),
|
| 2228 |
+
(r'(-?)(%\})', bygroups(Text, Comment.Preproc), '#pop'),
|
| 2229 |
+
include('varnames'),
|
| 2230 |
+
(r'.', Punctuation),
|
| 2231 |
+
],
|
| 2232 |
+
}
|
| 2233 |
+
|
| 2234 |
+
|
| 2235 |
+
class TwigHtmlLexer(DelegatingLexer):
|
| 2236 |
+
"""
|
| 2237 |
+
Subclass of the `TwigLexer` that highlights unlexed data with the
|
| 2238 |
+
`HtmlLexer`.
|
| 2239 |
+
"""
|
| 2240 |
+
|
| 2241 |
+
name = "HTML+Twig"
|
| 2242 |
+
aliases = ["html+twig"]
|
| 2243 |
+
filenames = ['*.twig']
|
| 2244 |
+
mimetypes = ['text/html+twig']
|
| 2245 |
+
url = 'https://twig.symfony.com'
|
| 2246 |
+
version_added = '2.0'
|
| 2247 |
+
|
| 2248 |
+
def __init__(self, **options):
|
| 2249 |
+
super().__init__(HtmlLexer, TwigLexer, **options)
|
| 2250 |
+
|
| 2251 |
+
|
| 2252 |
+
class Angular2Lexer(RegexLexer):
|
| 2253 |
+
"""
|
| 2254 |
+
Generic angular2 template lexer.
|
| 2255 |
+
|
| 2256 |
+
Highlights only the Angular template tags (stuff between `{{` and `}}` and
|
| 2257 |
+
special attributes: '(event)=', '[property]=', '[(twoWayBinding)]=').
|
| 2258 |
+
Everything else is left for a delegating lexer.
|
| 2259 |
+
"""
|
| 2260 |
+
|
| 2261 |
+
name = "Angular2"
|
| 2262 |
+
url = 'https://angular.io/guide/template-syntax'
|
| 2263 |
+
aliases = ['ng2']
|
| 2264 |
+
version_added = '2.1'
|
| 2265 |
+
|
| 2266 |
+
tokens = {
|
| 2267 |
+
'root': [
|
| 2268 |
+
(r'[^{([*#]+', Other),
|
| 2269 |
+
|
| 2270 |
+
# {{meal.name}}
|
| 2271 |
+
(r'(\{\{)(\s*)', bygroups(Comment.Preproc, Text), 'ngExpression'),
|
| 2272 |
+
|
| 2273 |
+
# (click)="deleteOrder()"; [value]="test"; [(twoWayTest)]="foo.bar"
|
| 2274 |
+
(r'([([]+)([\w:.-]+)([\])]+)(\s*)(=)(\s*)',
|
| 2275 |
+
bygroups(Punctuation, Name.Attribute, Punctuation, Text, Operator, Text),
|
| 2276 |
+
'attr'),
|
| 2277 |
+
(r'([([]+)([\w:.-]+)([\])]+)(\s*)',
|
| 2278 |
+
bygroups(Punctuation, Name.Attribute, Punctuation, Text)),
|
| 2279 |
+
|
| 2280 |
+
# *ngIf="..."; #f="ngForm"
|
| 2281 |
+
(r'([*#])([\w:.-]+)(\s*)(=)(\s*)',
|
| 2282 |
+
bygroups(Punctuation, Name.Attribute, Text, Operator, Text), 'attr'),
|
| 2283 |
+
(r'([*#])([\w:.-]+)(\s*)',
|
| 2284 |
+
bygroups(Punctuation, Name.Attribute, Text)),
|
| 2285 |
+
],
|
| 2286 |
+
|
| 2287 |
+
'ngExpression': [
|
| 2288 |
+
(r'\s+(\|\s+)?', Text),
|
| 2289 |
+
(r'\}\}', Comment.Preproc, '#pop'),
|
| 2290 |
+
|
| 2291 |
+
# Literals
|
| 2292 |
+
(r':?(true|false)', String.Boolean),
|
| 2293 |
+
(r':?"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 2294 |
+
(r":?'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 2295 |
+
(r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
|
| 2296 |
+
r"0[xX][0-9a-fA-F]+[Ll]?", Number),
|
| 2297 |
+
|
| 2298 |
+
# Variabletext
|
| 2299 |
+
(r'[a-zA-Z][\w-]*(\(.*\))?', Name.Variable),
|
| 2300 |
+
(r'\.[\w-]+(\(.*\))?', Name.Variable),
|
| 2301 |
+
|
| 2302 |
+
# inline If
|
| 2303 |
+
(r'(\?)(\s*)([^}\s]+)(\s*)(:)(\s*)([^}\s]+)(\s*)',
|
| 2304 |
+
bygroups(Operator, Text, String, Text, Operator, Text, String, Text)),
|
| 2305 |
+
],
|
| 2306 |
+
'attr': [
|
| 2307 |
+
('".*?"', String, '#pop'),
|
| 2308 |
+
("'.*?'", String, '#pop'),
|
| 2309 |
+
(r'[^\s>]+', String, '#pop'),
|
| 2310 |
+
],
|
| 2311 |
+
}
|
| 2312 |
+
|
| 2313 |
+
|
| 2314 |
+
class Angular2HtmlLexer(DelegatingLexer):
|
| 2315 |
+
"""
|
| 2316 |
+
Subclass of the `Angular2Lexer` that highlights unlexed data with the
|
| 2317 |
+
`HtmlLexer`.
|
| 2318 |
+
"""
|
| 2319 |
+
|
| 2320 |
+
name = "HTML + Angular2"
|
| 2321 |
+
aliases = ["html+ng2"]
|
| 2322 |
+
filenames = ['*.ng2']
|
| 2323 |
+
url = 'https://angular.io/guide/template-syntax'
|
| 2324 |
+
version_added = '2.0'
|
| 2325 |
+
|
| 2326 |
+
def __init__(self, **options):
|
| 2327 |
+
super().__init__(HtmlLexer, Angular2Lexer, **options)
|
| 2328 |
+
|
| 2329 |
+
|
| 2330 |
+
class SqlJinjaLexer(DelegatingLexer):
|
| 2331 |
+
"""
|
| 2332 |
+
Templated SQL lexer.
|
| 2333 |
+
"""
|
| 2334 |
+
|
| 2335 |
+
name = 'SQL+Jinja'
|
| 2336 |
+
aliases = ['sql+jinja']
|
| 2337 |
+
filenames = ['*.sql', '*.sql.j2', '*.sql.jinja2']
|
| 2338 |
+
url = 'https://jinja.palletsprojects.com'
|
| 2339 |
+
version_added = '2.13'
|
| 2340 |
+
|
| 2341 |
+
def __init__(self, **options):
|
| 2342 |
+
super().__init__(SqlLexer, DjangoLexer, **options)
|
| 2343 |
+
|
| 2344 |
+
def analyse_text(text):
|
| 2345 |
+
rv = 0.0
|
| 2346 |
+
# dbt's ref function
|
| 2347 |
+
if re.search(r'\{\{\s*ref\(.*\)\s*\}\}', text):
|
| 2348 |
+
rv += 0.4
|
| 2349 |
+
# dbt's source function
|
| 2350 |
+
if re.search(r'\{\{\s*source\(.*\)\s*\}\}', text):
|
| 2351 |
+
rv += 0.25
|
| 2352 |
+
# Jinja macro
|
| 2353 |
+
if re.search(r'\{%-?\s*macro \w+\(.*\)\s*-?%\}', text):
|
| 2354 |
+
rv += 0.15
|
| 2355 |
+
return rv
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/teraterm.py
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.teraterm
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Tera Term macro 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, include, bygroups
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Name, String, \
|
| 15 |
+
Number, Keyword, Error
|
| 16 |
+
|
| 17 |
+
__all__ = ['TeraTermLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class TeraTermLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For Tera Term macro source code.
|
| 23 |
+
"""
|
| 24 |
+
name = 'Tera Term macro'
|
| 25 |
+
url = 'https://ttssh2.osdn.jp/'
|
| 26 |
+
aliases = ['teratermmacro', 'teraterm', 'ttl']
|
| 27 |
+
filenames = ['*.ttl']
|
| 28 |
+
mimetypes = ['text/x-teratermmacro']
|
| 29 |
+
version_added = '2.4'
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'root': [
|
| 33 |
+
include('comments'),
|
| 34 |
+
include('labels'),
|
| 35 |
+
include('commands'),
|
| 36 |
+
include('builtin-variables'),
|
| 37 |
+
include('user-variables'),
|
| 38 |
+
include('operators'),
|
| 39 |
+
include('numeric-literals'),
|
| 40 |
+
include('string-literals'),
|
| 41 |
+
include('all-whitespace'),
|
| 42 |
+
(r'\S', Text),
|
| 43 |
+
],
|
| 44 |
+
'comments': [
|
| 45 |
+
(r';[^\r\n]*', Comment.Single),
|
| 46 |
+
(r'/\*', Comment.Multiline, 'in-comment'),
|
| 47 |
+
],
|
| 48 |
+
'in-comment': [
|
| 49 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 50 |
+
(r'[^*/]+', Comment.Multiline),
|
| 51 |
+
(r'[*/]', Comment.Multiline)
|
| 52 |
+
],
|
| 53 |
+
'labels': [
|
| 54 |
+
(r'(?i)^(\s*)(:[a-z0-9_]+)', bygroups(Text.Whitespace, Name.Label)),
|
| 55 |
+
],
|
| 56 |
+
'commands': [
|
| 57 |
+
(
|
| 58 |
+
r'(?i)\b('
|
| 59 |
+
r'basename|'
|
| 60 |
+
r'beep|'
|
| 61 |
+
r'bplusrecv|'
|
| 62 |
+
r'bplussend|'
|
| 63 |
+
r'break|'
|
| 64 |
+
r'bringupbox|'
|
| 65 |
+
# 'call' is handled separately.
|
| 66 |
+
r'callmenu|'
|
| 67 |
+
r'changedir|'
|
| 68 |
+
r'checksum16|'
|
| 69 |
+
r'checksum16file|'
|
| 70 |
+
r'checksum32|'
|
| 71 |
+
r'checksum32file|'
|
| 72 |
+
r'checksum8|'
|
| 73 |
+
r'checksum8file|'
|
| 74 |
+
r'clearscreen|'
|
| 75 |
+
r'clipb2var|'
|
| 76 |
+
r'closesbox|'
|
| 77 |
+
r'closett|'
|
| 78 |
+
r'code2str|'
|
| 79 |
+
r'connect|'
|
| 80 |
+
r'continue|'
|
| 81 |
+
r'crc16|'
|
| 82 |
+
r'crc16file|'
|
| 83 |
+
r'crc32|'
|
| 84 |
+
r'crc32file|'
|
| 85 |
+
r'cygconnect|'
|
| 86 |
+
r'delpassword|'
|
| 87 |
+
r'delpassword2|'
|
| 88 |
+
r'dirname|'
|
| 89 |
+
r'dirnamebox|'
|
| 90 |
+
r'disconnect|'
|
| 91 |
+
r'dispstr|'
|
| 92 |
+
r'do|'
|
| 93 |
+
r'else|'
|
| 94 |
+
r'elseif|'
|
| 95 |
+
r'enablekeyb|'
|
| 96 |
+
r'end|'
|
| 97 |
+
r'endif|'
|
| 98 |
+
r'enduntil|'
|
| 99 |
+
r'endwhile|'
|
| 100 |
+
r'exec|'
|
| 101 |
+
r'execcmnd|'
|
| 102 |
+
r'exit|'
|
| 103 |
+
r'expandenv|'
|
| 104 |
+
r'fileclose|'
|
| 105 |
+
r'fileconcat|'
|
| 106 |
+
r'filecopy|'
|
| 107 |
+
r'filecreate|'
|
| 108 |
+
r'filedelete|'
|
| 109 |
+
r'filelock|'
|
| 110 |
+
r'filemarkptr|'
|
| 111 |
+
r'filenamebox|'
|
| 112 |
+
r'fileopen|'
|
| 113 |
+
r'fileread|'
|
| 114 |
+
r'filereadln|'
|
| 115 |
+
r'filerename|'
|
| 116 |
+
r'filesearch|'
|
| 117 |
+
r'fileseek|'
|
| 118 |
+
r'fileseekback|'
|
| 119 |
+
r'filestat|'
|
| 120 |
+
r'filestrseek|'
|
| 121 |
+
r'filestrseek2|'
|
| 122 |
+
r'filetruncate|'
|
| 123 |
+
r'fileunlock|'
|
| 124 |
+
r'filewrite|'
|
| 125 |
+
r'filewriteln|'
|
| 126 |
+
r'findclose|'
|
| 127 |
+
r'findfirst|'
|
| 128 |
+
r'findnext|'
|
| 129 |
+
r'flushrecv|'
|
| 130 |
+
r'foldercreate|'
|
| 131 |
+
r'folderdelete|'
|
| 132 |
+
r'foldersearch|'
|
| 133 |
+
r'for|'
|
| 134 |
+
r'getdate|'
|
| 135 |
+
r'getdir|'
|
| 136 |
+
r'getenv|'
|
| 137 |
+
r'getfileattr|'
|
| 138 |
+
r'gethostname|'
|
| 139 |
+
r'getipv4addr|'
|
| 140 |
+
r'getipv6addr|'
|
| 141 |
+
r'getmodemstatus|'
|
| 142 |
+
r'getpassword|'
|
| 143 |
+
r'getpassword2|'
|
| 144 |
+
r'getspecialfolder|'
|
| 145 |
+
r'gettime|'
|
| 146 |
+
r'gettitle|'
|
| 147 |
+
r'getttdir|'
|
| 148 |
+
r'getttpos|'
|
| 149 |
+
r'getver|'
|
| 150 |
+
# 'goto' is handled separately.
|
| 151 |
+
r'if|'
|
| 152 |
+
r'ifdefined|'
|
| 153 |
+
r'include|'
|
| 154 |
+
r'inputbox|'
|
| 155 |
+
r'int2str|'
|
| 156 |
+
r'intdim|'
|
| 157 |
+
r'ispassword|'
|
| 158 |
+
r'ispassword2|'
|
| 159 |
+
r'kmtfinish|'
|
| 160 |
+
r'kmtget|'
|
| 161 |
+
r'kmtrecv|'
|
| 162 |
+
r'kmtsend|'
|
| 163 |
+
r'listbox|'
|
| 164 |
+
r'loadkeymap|'
|
| 165 |
+
r'logautoclosemode|'
|
| 166 |
+
r'logclose|'
|
| 167 |
+
r'loginfo|'
|
| 168 |
+
r'logopen|'
|
| 169 |
+
r'logpause|'
|
| 170 |
+
r'logrotate|'
|
| 171 |
+
r'logstart|'
|
| 172 |
+
r'logwrite|'
|
| 173 |
+
r'loop|'
|
| 174 |
+
r'makepath|'
|
| 175 |
+
r'messagebox|'
|
| 176 |
+
r'mpause|'
|
| 177 |
+
r'next|'
|
| 178 |
+
r'passwordbox|'
|
| 179 |
+
r'pause|'
|
| 180 |
+
r'quickvanrecv|'
|
| 181 |
+
r'quickvansend|'
|
| 182 |
+
r'random|'
|
| 183 |
+
r'recvfile'
|
| 184 |
+
r'recvln|'
|
| 185 |
+
r'regexoption|'
|
| 186 |
+
r'restoresetup|'
|
| 187 |
+
r'return|'
|
| 188 |
+
r'rotateleft|'
|
| 189 |
+
r'rotateright|'
|
| 190 |
+
r'scprecv|'
|
| 191 |
+
r'scpsend|'
|
| 192 |
+
r'send|'
|
| 193 |
+
r'sendbinary|'
|
| 194 |
+
r'sendbreak|'
|
| 195 |
+
r'sendbroadcast|'
|
| 196 |
+
r'sendfile|'
|
| 197 |
+
r'sendkcode|'
|
| 198 |
+
r'sendln|'
|
| 199 |
+
r'sendlnbroadcast|'
|
| 200 |
+
r'sendlnmulticast|'
|
| 201 |
+
r'sendmulticast|'
|
| 202 |
+
r'sendtext|'
|
| 203 |
+
r'setbaud|'
|
| 204 |
+
r'setdate|'
|
| 205 |
+
r'setdebug|'
|
| 206 |
+
r'setdir|'
|
| 207 |
+
r'setdlgpos|'
|
| 208 |
+
r'setdtr|'
|
| 209 |
+
r'setecho|'
|
| 210 |
+
r'setenv|'
|
| 211 |
+
r'setexitcode|'
|
| 212 |
+
r'setfileattr|'
|
| 213 |
+
r'setflowctrl|'
|
| 214 |
+
r'setmulticastname|'
|
| 215 |
+
r'setpassword|'
|
| 216 |
+
r'setpassword2|'
|
| 217 |
+
r'setrts|'
|
| 218 |
+
r'setserialdelaychar'
|
| 219 |
+
r'setserialdelayline'
|
| 220 |
+
r'setspeed|'
|
| 221 |
+
r'setsync|'
|
| 222 |
+
r'settime|'
|
| 223 |
+
r'settitle|'
|
| 224 |
+
r'show|'
|
| 225 |
+
r'showtt|'
|
| 226 |
+
r'sprintf|'
|
| 227 |
+
r'sprintf2|'
|
| 228 |
+
r'statusbox|'
|
| 229 |
+
r'str2code|'
|
| 230 |
+
r'str2int|'
|
| 231 |
+
r'strcompare|'
|
| 232 |
+
r'strconcat|'
|
| 233 |
+
r'strcopy|'
|
| 234 |
+
r'strdim|'
|
| 235 |
+
r'strinsert|'
|
| 236 |
+
r'strjoin|'
|
| 237 |
+
r'strlen|'
|
| 238 |
+
r'strmatch|'
|
| 239 |
+
r'strremove|'
|
| 240 |
+
r'strreplace|'
|
| 241 |
+
r'strscan|'
|
| 242 |
+
r'strspecial|'
|
| 243 |
+
r'strsplit|'
|
| 244 |
+
r'strtrim|'
|
| 245 |
+
r'testlink|'
|
| 246 |
+
r'then|'
|
| 247 |
+
r'tolower|'
|
| 248 |
+
r'toupper|'
|
| 249 |
+
r'unlink|'
|
| 250 |
+
r'until|'
|
| 251 |
+
r'uptime|'
|
| 252 |
+
r'var2clipb|'
|
| 253 |
+
r'wait|'
|
| 254 |
+
r'wait4all|'
|
| 255 |
+
r'waitevent|'
|
| 256 |
+
r'waitln|'
|
| 257 |
+
r'waitn|'
|
| 258 |
+
r'waitrecv|'
|
| 259 |
+
r'waitregex|'
|
| 260 |
+
r'while|'
|
| 261 |
+
r'xmodemrecv|'
|
| 262 |
+
r'xmodemsend|'
|
| 263 |
+
r'yesnobox|'
|
| 264 |
+
r'ymodemrecv|'
|
| 265 |
+
r'ymodemsend|'
|
| 266 |
+
r'zmodemrecv|'
|
| 267 |
+
r'zmodemsend'
|
| 268 |
+
r')\b',
|
| 269 |
+
Keyword,
|
| 270 |
+
),
|
| 271 |
+
(r'(?i)(call|goto)([ \t]+)([a-z0-9_]+)',
|
| 272 |
+
bygroups(Keyword, Text.Whitespace, Name.Label)),
|
| 273 |
+
],
|
| 274 |
+
'builtin-variables': [
|
| 275 |
+
(
|
| 276 |
+
r'(?i)('
|
| 277 |
+
r'groupmatchstr1|'
|
| 278 |
+
r'groupmatchstr2|'
|
| 279 |
+
r'groupmatchstr3|'
|
| 280 |
+
r'groupmatchstr4|'
|
| 281 |
+
r'groupmatchstr5|'
|
| 282 |
+
r'groupmatchstr6|'
|
| 283 |
+
r'groupmatchstr7|'
|
| 284 |
+
r'groupmatchstr8|'
|
| 285 |
+
r'groupmatchstr9|'
|
| 286 |
+
r'inputstr|'
|
| 287 |
+
r'matchstr|'
|
| 288 |
+
r'mtimeout|'
|
| 289 |
+
r'param1|'
|
| 290 |
+
r'param2|'
|
| 291 |
+
r'param3|'
|
| 292 |
+
r'param4|'
|
| 293 |
+
r'param5|'
|
| 294 |
+
r'param6|'
|
| 295 |
+
r'param7|'
|
| 296 |
+
r'param8|'
|
| 297 |
+
r'param9|'
|
| 298 |
+
r'paramcnt|'
|
| 299 |
+
r'params|'
|
| 300 |
+
r'result|'
|
| 301 |
+
r'timeout'
|
| 302 |
+
r')\b',
|
| 303 |
+
Name.Builtin
|
| 304 |
+
),
|
| 305 |
+
],
|
| 306 |
+
'user-variables': [
|
| 307 |
+
(r'(?i)[a-z_][a-z0-9_]*', Name.Variable),
|
| 308 |
+
],
|
| 309 |
+
'numeric-literals': [
|
| 310 |
+
(r'(-?)([0-9]+)', bygroups(Operator, Number.Integer)),
|
| 311 |
+
(r'(?i)\$[0-9a-f]+', Number.Hex),
|
| 312 |
+
],
|
| 313 |
+
'string-literals': [
|
| 314 |
+
(r'(?i)#(?:[0-9]+|\$[0-9a-f]+)', String.Char),
|
| 315 |
+
(r"'[^'\n]*'", String.Single),
|
| 316 |
+
(r'"[^"\n]*"', String.Double),
|
| 317 |
+
# Opening quotes without a closing quote on the same line are errors.
|
| 318 |
+
(r"('[^']*)(\n)", bygroups(Error, Text.Whitespace)),
|
| 319 |
+
(r'("[^"]*)(\n)', bygroups(Error, Text.Whitespace)),
|
| 320 |
+
],
|
| 321 |
+
'operators': [
|
| 322 |
+
(r'and|not|or|xor', Operator.Word),
|
| 323 |
+
(r'[!%&*+<=>^~\|\/-]+', Operator),
|
| 324 |
+
(r'[()]', String.Symbol),
|
| 325 |
+
],
|
| 326 |
+
'all-whitespace': [
|
| 327 |
+
(r'\s+', Text.Whitespace),
|
| 328 |
+
],
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
# Turtle and Tera Term macro files share the same file extension
|
| 332 |
+
# but each has a recognizable and distinct syntax.
|
| 333 |
+
def analyse_text(text):
|
| 334 |
+
if re.search(TeraTermLexer.tokens['commands'][0][0], text):
|
| 335 |
+
return 0.01
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/testing.py
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.testing
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for testing 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, include, bygroups
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, String, Number, Generic, Text
|
| 13 |
+
|
| 14 |
+
__all__ = ['GherkinLexer', 'TAPLexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class GherkinLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
For Gherkin syntax.
|
| 20 |
+
"""
|
| 21 |
+
name = 'Gherkin'
|
| 22 |
+
aliases = ['gherkin', 'cucumber']
|
| 23 |
+
filenames = ['*.feature']
|
| 24 |
+
mimetypes = ['text/x-gherkin']
|
| 25 |
+
url = 'https://cucumber.io/docs/gherkin'
|
| 26 |
+
version_added = '1.2'
|
| 27 |
+
|
| 28 |
+
feature_keywords = '^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Özellik|Właściwość|Tính năng|Trajto|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$'
|
| 29 |
+
feature_element_keywords = '^(\\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|剧本大纲|剧本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y\'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$'
|
| 30 |
+
examples_keywords = '^(\\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Приклади|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$'
|
| 31 |
+
step_keywords = '^(\\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假设|假如|假定|但是|但し|並且|并且|同時|同时|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y\'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y\'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\\* )'
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
'comments': [
|
| 35 |
+
(r'^\s*#.*$', Comment),
|
| 36 |
+
],
|
| 37 |
+
'feature_elements': [
|
| 38 |
+
(step_keywords, Keyword, "step_content_stack"),
|
| 39 |
+
include('comments'),
|
| 40 |
+
(r"(\s|.)", Name.Function),
|
| 41 |
+
],
|
| 42 |
+
'feature_elements_on_stack': [
|
| 43 |
+
(step_keywords, Keyword, "#pop:2"),
|
| 44 |
+
include('comments'),
|
| 45 |
+
(r"(\s|.)", Name.Function),
|
| 46 |
+
],
|
| 47 |
+
'examples_table': [
|
| 48 |
+
(r"\s+\|", Keyword, 'examples_table_header'),
|
| 49 |
+
include('comments'),
|
| 50 |
+
(r"(\s|.)", Name.Function),
|
| 51 |
+
],
|
| 52 |
+
'examples_table_header': [
|
| 53 |
+
(r"\s+\|\s*$", Keyword, "#pop:2"),
|
| 54 |
+
include('comments'),
|
| 55 |
+
(r"\\\|", Name.Variable),
|
| 56 |
+
(r"\s*\|", Keyword),
|
| 57 |
+
(r"[^|]", Name.Variable),
|
| 58 |
+
],
|
| 59 |
+
'scenario_sections_on_stack': [
|
| 60 |
+
(feature_element_keywords,
|
| 61 |
+
bygroups(Name.Function, Keyword, Keyword, Name.Function),
|
| 62 |
+
"feature_elements_on_stack"),
|
| 63 |
+
],
|
| 64 |
+
'narrative': [
|
| 65 |
+
include('scenario_sections_on_stack'),
|
| 66 |
+
include('comments'),
|
| 67 |
+
(r"(\s|.)", Name.Function),
|
| 68 |
+
],
|
| 69 |
+
'table_vars': [
|
| 70 |
+
(r'(<[^>]+>)', Name.Variable),
|
| 71 |
+
],
|
| 72 |
+
'numbers': [
|
| 73 |
+
(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', String),
|
| 74 |
+
],
|
| 75 |
+
'string': [
|
| 76 |
+
include('table_vars'),
|
| 77 |
+
(r'(\s|.)', String),
|
| 78 |
+
],
|
| 79 |
+
'py_string': [
|
| 80 |
+
(r'"""', Keyword, "#pop"),
|
| 81 |
+
include('string'),
|
| 82 |
+
],
|
| 83 |
+
'step_content_root': [
|
| 84 |
+
(r"$", Keyword, "#pop"),
|
| 85 |
+
include('step_content'),
|
| 86 |
+
],
|
| 87 |
+
'step_content_stack': [
|
| 88 |
+
(r"$", Keyword, "#pop:2"),
|
| 89 |
+
include('step_content'),
|
| 90 |
+
],
|
| 91 |
+
'step_content': [
|
| 92 |
+
(r'"', Name.Function, "double_string"),
|
| 93 |
+
include('table_vars'),
|
| 94 |
+
include('numbers'),
|
| 95 |
+
include('comments'),
|
| 96 |
+
(r'(\s|.)', Name.Function),
|
| 97 |
+
],
|
| 98 |
+
'table_content': [
|
| 99 |
+
(r"\s+\|\s*$", Keyword, "#pop"),
|
| 100 |
+
include('comments'),
|
| 101 |
+
(r"\\\|", String),
|
| 102 |
+
(r"\s*\|", Keyword),
|
| 103 |
+
include('string'),
|
| 104 |
+
],
|
| 105 |
+
'double_string': [
|
| 106 |
+
(r'"', Name.Function, "#pop"),
|
| 107 |
+
include('string'),
|
| 108 |
+
],
|
| 109 |
+
'root': [
|
| 110 |
+
(r'\n', Name.Function),
|
| 111 |
+
include('comments'),
|
| 112 |
+
(r'"""', Keyword, "py_string"),
|
| 113 |
+
(r'\s+\|', Keyword, 'table_content'),
|
| 114 |
+
(r'"', Name.Function, "double_string"),
|
| 115 |
+
include('table_vars'),
|
| 116 |
+
include('numbers'),
|
| 117 |
+
(r'(\s*)(@[^@\r\n\t ]+)', bygroups(Name.Function, Name.Tag)),
|
| 118 |
+
(step_keywords, bygroups(Name.Function, Keyword),
|
| 119 |
+
'step_content_root'),
|
| 120 |
+
(feature_keywords, bygroups(Keyword, Keyword, Name.Function),
|
| 121 |
+
'narrative'),
|
| 122 |
+
(feature_element_keywords,
|
| 123 |
+
bygroups(Name.Function, Keyword, Keyword, Name.Function),
|
| 124 |
+
'feature_elements'),
|
| 125 |
+
(examples_keywords,
|
| 126 |
+
bygroups(Name.Function, Keyword, Keyword, Name.Function),
|
| 127 |
+
'examples_table'),
|
| 128 |
+
(r'(\s|.)', Name.Function),
|
| 129 |
+
]
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
def analyse_text(self, text):
|
| 133 |
+
return
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
class TAPLexer(RegexLexer):
|
| 137 |
+
"""
|
| 138 |
+
For Test Anything Protocol (TAP) output.
|
| 139 |
+
"""
|
| 140 |
+
name = 'TAP'
|
| 141 |
+
url = 'https://testanything.org/'
|
| 142 |
+
aliases = ['tap']
|
| 143 |
+
filenames = ['*.tap']
|
| 144 |
+
version_added = '2.1'
|
| 145 |
+
|
| 146 |
+
tokens = {
|
| 147 |
+
'root': [
|
| 148 |
+
# A TAP version may be specified.
|
| 149 |
+
(r'^TAP version \d+\n', Name.Namespace),
|
| 150 |
+
|
| 151 |
+
# Specify a plan with a plan line.
|
| 152 |
+
(r'^1\.\.\d+', Keyword.Declaration, 'plan'),
|
| 153 |
+
|
| 154 |
+
# A test failure
|
| 155 |
+
(r'^(not ok)([^\S\n]*)(\d*)',
|
| 156 |
+
bygroups(Generic.Error, Text, Number.Integer), 'test'),
|
| 157 |
+
|
| 158 |
+
# A test success
|
| 159 |
+
(r'^(ok)([^\S\n]*)(\d*)',
|
| 160 |
+
bygroups(Keyword.Reserved, Text, Number.Integer), 'test'),
|
| 161 |
+
|
| 162 |
+
# Diagnostics start with a hash.
|
| 163 |
+
(r'^#.*\n', Comment),
|
| 164 |
+
|
| 165 |
+
# TAP's version of an abort statement.
|
| 166 |
+
(r'^Bail out!.*\n', Generic.Error),
|
| 167 |
+
|
| 168 |
+
# TAP ignores any unrecognized lines.
|
| 169 |
+
(r'^.*\n', Text),
|
| 170 |
+
],
|
| 171 |
+
'plan': [
|
| 172 |
+
# Consume whitespace (but not newline).
|
| 173 |
+
(r'[^\S\n]+', Text),
|
| 174 |
+
|
| 175 |
+
# A plan may have a directive with it.
|
| 176 |
+
(r'#', Comment, 'directive'),
|
| 177 |
+
|
| 178 |
+
# Or it could just end.
|
| 179 |
+
(r'\n', Comment, '#pop'),
|
| 180 |
+
|
| 181 |
+
# Anything else is wrong.
|
| 182 |
+
(r'.*\n', Generic.Error, '#pop'),
|
| 183 |
+
],
|
| 184 |
+
'test': [
|
| 185 |
+
# Consume whitespace (but not newline).
|
| 186 |
+
(r'[^\S\n]+', Text),
|
| 187 |
+
|
| 188 |
+
# A test may have a directive with it.
|
| 189 |
+
(r'#', Comment, 'directive'),
|
| 190 |
+
|
| 191 |
+
(r'\S+', Text),
|
| 192 |
+
|
| 193 |
+
(r'\n', Text, '#pop'),
|
| 194 |
+
],
|
| 195 |
+
'directive': [
|
| 196 |
+
# Consume whitespace (but not newline).
|
| 197 |
+
(r'[^\S\n]+', Comment),
|
| 198 |
+
|
| 199 |
+
# Extract todo items.
|
| 200 |
+
(r'(?i)\bTODO\b', Comment.Preproc),
|
| 201 |
+
|
| 202 |
+
# Extract skip items.
|
| 203 |
+
(r'(?i)\bSKIP\S*', Comment.Preproc),
|
| 204 |
+
|
| 205 |
+
(r'\S+', Comment),
|
| 206 |
+
|
| 207 |
+
(r'\n', Comment, '#pop:2'),
|
| 208 |
+
],
|
| 209 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/text.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.text
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for non-source code file types.
|
| 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.configs import ApacheConfLexer, NginxConfLexer, \
|
| 13 |
+
SquidConfLexer, LighttpdConfLexer, IniLexer, RegeditLexer, PropertiesLexer, \
|
| 14 |
+
UnixConfigLexer
|
| 15 |
+
from pygments.lexers.console import PyPyLogLexer
|
| 16 |
+
from pygments.lexers.textedit import VimLexer
|
| 17 |
+
from pygments.lexers.markup import BBCodeLexer, MoinWikiLexer, RstLexer, \
|
| 18 |
+
TexLexer, GroffLexer
|
| 19 |
+
from pygments.lexers.installers import DebianControlLexer, DebianSourcesLexer, SourcesListLexer
|
| 20 |
+
from pygments.lexers.make import MakefileLexer, BaseMakefileLexer, CMakeLexer
|
| 21 |
+
from pygments.lexers.haxe import HxmlLexer
|
| 22 |
+
from pygments.lexers.sgf import SmartGameFormatLexer
|
| 23 |
+
from pygments.lexers.diff import DiffLexer, DarcsPatchLexer
|
| 24 |
+
from pygments.lexers.data import YamlLexer
|
| 25 |
+
from pygments.lexers.textfmts import IrcLogsLexer, GettextLexer, HttpLexer
|
| 26 |
+
|
| 27 |
+
__all__ = []
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/textedit.py
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.textedit
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for languages related to text processing.
|
| 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 |
+
from bisect import bisect
|
| 13 |
+
|
| 14 |
+
from pygments.lexer import RegexLexer, bygroups, default, include, this, using
|
| 15 |
+
from pygments.lexers.python import PythonLexer
|
| 16 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 17 |
+
Punctuation, String, Text, Whitespace
|
| 18 |
+
|
| 19 |
+
__all__ = ['AwkLexer', 'SedLexer', 'VimLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class AwkLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For Awk scripts.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'Awk'
|
| 28 |
+
aliases = ['awk', 'gawk', 'mawk', 'nawk']
|
| 29 |
+
filenames = ['*.awk']
|
| 30 |
+
mimetypes = ['application/x-awk']
|
| 31 |
+
url = 'https://en.wikipedia.org/wiki/AWK'
|
| 32 |
+
version_added = '1.5'
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'commentsandwhitespace': [
|
| 36 |
+
(r'\s+', Text),
|
| 37 |
+
(r'#.*$', Comment.Single)
|
| 38 |
+
],
|
| 39 |
+
'slashstartsregex': [
|
| 40 |
+
include('commentsandwhitespace'),
|
| 41 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 42 |
+
r'\B', String.Regex, '#pop'),
|
| 43 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 44 |
+
default('#pop')
|
| 45 |
+
],
|
| 46 |
+
'badregex': [
|
| 47 |
+
(r'\n', Text, '#pop')
|
| 48 |
+
],
|
| 49 |
+
'root': [
|
| 50 |
+
(r'^(?=\s|/)', Text, 'slashstartsregex'),
|
| 51 |
+
include('commentsandwhitespace'),
|
| 52 |
+
(r'\+\+|--|\|\||&&|in\b|\$|!?~|\?|:|'
|
| 53 |
+
r'(\*\*|[-<>+*%\^/!=|])=?', Operator, 'slashstartsregex'),
|
| 54 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 55 |
+
(r'[})\].]', Punctuation),
|
| 56 |
+
(r'(break|continue|do|while|exit|for|if|else|'
|
| 57 |
+
r'return)\b', Keyword, 'slashstartsregex'),
|
| 58 |
+
(r'function\b', Keyword.Declaration, 'slashstartsregex'),
|
| 59 |
+
(r'(atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|'
|
| 60 |
+
r'length|match|split|sprintf|sub|substr|tolower|toupper|close|'
|
| 61 |
+
r'fflush|getline|next|nextfile|print|printf|strftime|systime|'
|
| 62 |
+
r'delete|system)\b', Keyword.Reserved),
|
| 63 |
+
(r'(ARGC|ARGIND|ARGV|BEGIN|CONVFMT|ENVIRON|END|ERRNO|FIELDWIDTHS|'
|
| 64 |
+
r'FILENAME|FNR|FS|IGNORECASE|NF|NR|OFMT|OFS|ORFS|RLENGTH|RS|'
|
| 65 |
+
r'RSTART|RT|SUBSEP)\b', Name.Builtin),
|
| 66 |
+
(r'[$a-zA-Z_]\w*', Name.Other),
|
| 67 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 68 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 69 |
+
(r'[0-9]+', Number.Integer),
|
| 70 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 71 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 72 |
+
]
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class SedLexer(RegexLexer):
|
| 77 |
+
"""
|
| 78 |
+
Lexer for Sed script files.
|
| 79 |
+
"""
|
| 80 |
+
name = 'Sed'
|
| 81 |
+
aliases = ['sed', 'gsed', 'ssed']
|
| 82 |
+
filenames = ['*.sed', '*.[gs]sed']
|
| 83 |
+
mimetypes = ['text/x-sed']
|
| 84 |
+
url = 'https://en.wikipedia.org/wiki/Sed'
|
| 85 |
+
version_added = ''
|
| 86 |
+
flags = re.MULTILINE
|
| 87 |
+
|
| 88 |
+
# Match the contents within delimiters such as /<contents>/
|
| 89 |
+
_inside_delims = r'((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)'
|
| 90 |
+
|
| 91 |
+
tokens = {
|
| 92 |
+
'root': [
|
| 93 |
+
(r'\s+', Whitespace),
|
| 94 |
+
(r'#.*$', Comment.Single),
|
| 95 |
+
(r'[0-9]+', Number.Integer),
|
| 96 |
+
(r'\$', Operator),
|
| 97 |
+
(r'[{};,!]', Punctuation),
|
| 98 |
+
(r'[dDFgGhHlnNpPqQxz=]', Keyword),
|
| 99 |
+
(r'([berRtTvwW:])([^;\n]*)', bygroups(Keyword, String.Single)),
|
| 100 |
+
(r'([aci])((?:.*?\\\n)*(?:.*?[^\\]$))', bygroups(Keyword, String.Double)),
|
| 101 |
+
(r'([qQ])([0-9]*)', bygroups(Keyword, Number.Integer)),
|
| 102 |
+
(r'(/)' + _inside_delims + r'(/)', bygroups(Punctuation, String.Regex, Punctuation)),
|
| 103 |
+
(r'(\\(.))' + _inside_delims + r'(\2)',
|
| 104 |
+
bygroups(Punctuation, None, String.Regex, Punctuation)),
|
| 105 |
+
(r'(y)(.)' + _inside_delims + r'(\2)' + _inside_delims + r'(\2)',
|
| 106 |
+
bygroups(Keyword, Punctuation, String.Single, Punctuation, String.Single, Punctuation)),
|
| 107 |
+
(r'(s)(.)' + _inside_delims + r'(\2)' + _inside_delims + r'(\2)((?:[gpeIiMm]|[0-9])*)',
|
| 108 |
+
bygroups(Keyword, Punctuation, String.Regex, Punctuation, String.Single, Punctuation,
|
| 109 |
+
Keyword))
|
| 110 |
+
]
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
class VimLexer(RegexLexer):
|
| 114 |
+
"""
|
| 115 |
+
Lexer for VimL script files.
|
| 116 |
+
"""
|
| 117 |
+
name = 'VimL'
|
| 118 |
+
aliases = ['vim']
|
| 119 |
+
filenames = ['*.vim', '.vimrc', '.exrc', '.gvimrc',
|
| 120 |
+
'_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc']
|
| 121 |
+
mimetypes = ['text/x-vim']
|
| 122 |
+
url = 'https://www.vim.org'
|
| 123 |
+
version_added = '0.8'
|
| 124 |
+
|
| 125 |
+
flags = re.MULTILINE
|
| 126 |
+
|
| 127 |
+
_python = r'py(?:t(?:h(?:o(?:n)?)?)?)?'
|
| 128 |
+
|
| 129 |
+
tokens = {
|
| 130 |
+
'root': [
|
| 131 |
+
(r'^([ \t:]*)(' + _python + r')([ \t]*)(<<)([ \t]*)(.*)((?:\n|.)*)(\6)',
|
| 132 |
+
bygroups(using(this), Keyword, Text, Operator, Text, Text,
|
| 133 |
+
using(PythonLexer), Text)),
|
| 134 |
+
(r'^([ \t:]*)(' + _python + r')([ \t])(.*)',
|
| 135 |
+
bygroups(using(this), Keyword, Text, using(PythonLexer))),
|
| 136 |
+
|
| 137 |
+
(r'^\s*".*', Comment),
|
| 138 |
+
|
| 139 |
+
(r'[ \t]+', Text),
|
| 140 |
+
# TODO: regexes can have other delims
|
| 141 |
+
(r'/[^/\\\n]*(?:\\[\s\S][^/\\\n]*)*/', String.Regex),
|
| 142 |
+
(r'"[^"\\\n]*(?:\\[\s\S][^"\\\n]*)*"', String.Double),
|
| 143 |
+
(r"'[^\n']*(?:''[^\n']*)*'", String.Single),
|
| 144 |
+
|
| 145 |
+
# Who decided that doublequote was a good comment character??
|
| 146 |
+
(r'(?<=\s)"[^\-:.%#=*].*', Comment),
|
| 147 |
+
(r'-?\d+', Number),
|
| 148 |
+
(r'#[0-9a-f]{6}', Number.Hex),
|
| 149 |
+
(r'^:', Punctuation),
|
| 150 |
+
(r'[()<>+=!|,~-]', Punctuation), # Inexact list. Looks decent.
|
| 151 |
+
(r'\b(let|if|else|endif|elseif|fun|function|endfunction)\b',
|
| 152 |
+
Keyword),
|
| 153 |
+
(r'\b(NONE|bold|italic|underline|dark|light)\b', Name.Builtin),
|
| 154 |
+
(r'\b\w+\b', Name.Other), # These are postprocessed below
|
| 155 |
+
(r'.', Text),
|
| 156 |
+
],
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
def __init__(self, **options):
|
| 160 |
+
from pygments.lexers._vim_builtins import auto, command, option
|
| 161 |
+
self._cmd = command
|
| 162 |
+
self._opt = option
|
| 163 |
+
self._aut = auto
|
| 164 |
+
|
| 165 |
+
RegexLexer.__init__(self, **options)
|
| 166 |
+
|
| 167 |
+
def is_in(self, w, mapping):
|
| 168 |
+
r"""
|
| 169 |
+
It's kind of difficult to decide if something might be a keyword
|
| 170 |
+
in VimL because it allows you to abbreviate them. In fact,
|
| 171 |
+
'ab[breviate]' is a good example. :ab, :abbre, or :abbreviate are
|
| 172 |
+
valid ways to call it so rather than making really awful regexps
|
| 173 |
+
like::
|
| 174 |
+
|
| 175 |
+
\bab(?:b(?:r(?:e(?:v(?:i(?:a(?:t(?:e)?)?)?)?)?)?)?)?\b
|
| 176 |
+
|
| 177 |
+
we match `\b\w+\b` and then call is_in() on those tokens. See
|
| 178 |
+
`scripts/get_vimkw.py` for how the lists are extracted.
|
| 179 |
+
"""
|
| 180 |
+
p = bisect(mapping, (w,))
|
| 181 |
+
if p > 0:
|
| 182 |
+
if mapping[p-1][0] == w[:len(mapping[p-1][0])] and \
|
| 183 |
+
mapping[p-1][1][:len(w)] == w:
|
| 184 |
+
return True
|
| 185 |
+
if p < len(mapping):
|
| 186 |
+
return mapping[p][0] == w[:len(mapping[p][0])] and \
|
| 187 |
+
mapping[p][1][:len(w)] == w
|
| 188 |
+
return False
|
| 189 |
+
|
| 190 |
+
def get_tokens_unprocessed(self, text):
|
| 191 |
+
# TODO: builtins are only subsequent tokens on lines
|
| 192 |
+
# and 'keywords' only happen at the beginning except
|
| 193 |
+
# for :au ones
|
| 194 |
+
for index, token, value in \
|
| 195 |
+
RegexLexer.get_tokens_unprocessed(self, text):
|
| 196 |
+
if token is Name.Other:
|
| 197 |
+
if self.is_in(value, self._cmd):
|
| 198 |
+
yield index, Keyword, value
|
| 199 |
+
elif self.is_in(value, self._opt) or \
|
| 200 |
+
self.is_in(value, self._aut):
|
| 201 |
+
yield index, Name.Builtin, value
|
| 202 |
+
else:
|
| 203 |
+
yield index, Text, value
|
| 204 |
+
else:
|
| 205 |
+
yield index, token, value
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/textfmts.py
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.textfmts
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for various text formats.
|
| 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 import guess_lexer, get_lexer_by_name
|
| 14 |
+
from pygments.lexer import RegexLexer, bygroups, default, include
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Generic, Literal, Punctuation
|
| 17 |
+
from pygments.util import ClassNotFound
|
| 18 |
+
|
| 19 |
+
__all__ = ['IrcLogsLexer', 'TodotxtLexer', 'HttpLexer', 'GettextLexer',
|
| 20 |
+
'NotmuchLexer', 'KernelLogLexer']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class IrcLogsLexer(RegexLexer):
|
| 24 |
+
"""
|
| 25 |
+
Lexer for IRC logs in *irssi*, *xchat* or *weechat* style.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
name = 'IRC logs'
|
| 29 |
+
aliases = ['irc']
|
| 30 |
+
filenames = ['*.weechatlog']
|
| 31 |
+
mimetypes = ['text/x-irclog']
|
| 32 |
+
url = 'https://en.wikipedia.org/wiki/Internet_Relay_Chat'
|
| 33 |
+
version_added = ''
|
| 34 |
+
|
| 35 |
+
flags = re.VERBOSE | re.MULTILINE
|
| 36 |
+
timestamp = r"""
|
| 37 |
+
(
|
| 38 |
+
# irssi / xchat and others
|
| 39 |
+
(?: \[|\()? # Opening bracket or paren for the timestamp
|
| 40 |
+
(?: # Timestamp
|
| 41 |
+
(?: (?:\d{1,4} [-/])* # Date as - or /-separated groups of digits
|
| 42 |
+
(?:\d{1,4})
|
| 43 |
+
[T ])? # Date/time separator: T or space
|
| 44 |
+
(?: \d?\d [:.])* # Time as :/.-separated groups of 1 or 2 digits
|
| 45 |
+
(?: \d?\d)
|
| 46 |
+
)
|
| 47 |
+
(?: \]|\))?\s+ # Closing bracket or paren for the timestamp
|
| 48 |
+
|
|
| 49 |
+
# weechat
|
| 50 |
+
\d{4}\s\w{3}\s\d{2}\s # Date
|
| 51 |
+
\d{2}:\d{2}:\d{2}\s+ # Time + Whitespace
|
| 52 |
+
|
|
| 53 |
+
# xchat
|
| 54 |
+
\w{3}\s\d{2}\s # Date
|
| 55 |
+
\d{2}:\d{2}:\d{2}\s+ # Time + Whitespace
|
| 56 |
+
)?
|
| 57 |
+
"""
|
| 58 |
+
tokens = {
|
| 59 |
+
'root': [
|
| 60 |
+
# log start/end
|
| 61 |
+
(r'^\*\*\*\*(.*)\*\*\*\*$', Comment),
|
| 62 |
+
# hack
|
| 63 |
+
("^" + timestamp + r'(\s*<[^>]*>\s*)$', bygroups(Comment.Preproc, Name.Tag)),
|
| 64 |
+
# normal msgs
|
| 65 |
+
("^" + timestamp + r"""
|
| 66 |
+
(\s*<.*?>\s*) # Nick """,
|
| 67 |
+
bygroups(Comment.Preproc, Name.Tag), 'msg'),
|
| 68 |
+
# /me msgs
|
| 69 |
+
("^" + timestamp + r"""
|
| 70 |
+
(\s*[*]\s+) # Star
|
| 71 |
+
(\S+\s+.*?\n) # Nick + rest of message """,
|
| 72 |
+
bygroups(Comment.Preproc, Keyword, Generic.Inserted)),
|
| 73 |
+
# join/part msgs
|
| 74 |
+
("^" + timestamp + r"""
|
| 75 |
+
(\s*(?:\*{3}|<?-[!@=P]?->?)\s*) # Star(s) or symbols
|
| 76 |
+
(\S+\s+) # Nick + Space
|
| 77 |
+
(.*?\n) # Rest of message """,
|
| 78 |
+
bygroups(Comment.Preproc, Keyword, String, Comment)),
|
| 79 |
+
(r"^.*?\n", Text),
|
| 80 |
+
],
|
| 81 |
+
'msg': [
|
| 82 |
+
(r"\S+:(?!//)", Name.Attribute), # Prefix
|
| 83 |
+
(r".*\n", Text, '#pop'),
|
| 84 |
+
],
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class GettextLexer(RegexLexer):
|
| 89 |
+
"""
|
| 90 |
+
Lexer for Gettext catalog files.
|
| 91 |
+
"""
|
| 92 |
+
name = 'Gettext Catalog'
|
| 93 |
+
aliases = ['pot', 'po']
|
| 94 |
+
filenames = ['*.pot', '*.po']
|
| 95 |
+
mimetypes = ['application/x-gettext', 'text/x-gettext', 'text/gettext']
|
| 96 |
+
url = 'https://www.gnu.org/software/gettext'
|
| 97 |
+
version_added = '0.9'
|
| 98 |
+
|
| 99 |
+
tokens = {
|
| 100 |
+
'root': [
|
| 101 |
+
(r'^#,\s.*?$', Keyword.Type),
|
| 102 |
+
(r'^#:\s.*?$', Keyword.Declaration),
|
| 103 |
+
# (r'^#$', Comment),
|
| 104 |
+
(r'^(#|#\.\s|#\|\s|#~\s|#\s).*$', Comment.Single),
|
| 105 |
+
(r'^(")([A-Za-z-]+:)(.*")$',
|
| 106 |
+
bygroups(String, Name.Property, String)),
|
| 107 |
+
(r'^".*"$', String),
|
| 108 |
+
(r'^(msgid|msgid_plural|msgstr|msgctxt)(\s+)(".*")$',
|
| 109 |
+
bygroups(Name.Variable, Text, String)),
|
| 110 |
+
(r'^(msgstr\[)(\d)(\])(\s+)(".*")$',
|
| 111 |
+
bygroups(Name.Variable, Number.Integer, Name.Variable, Text, String)),
|
| 112 |
+
]
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class HttpLexer(RegexLexer):
|
| 117 |
+
"""
|
| 118 |
+
Lexer for HTTP sessions.
|
| 119 |
+
"""
|
| 120 |
+
|
| 121 |
+
name = 'HTTP'
|
| 122 |
+
aliases = ['http']
|
| 123 |
+
url = 'https://httpwg.org/specs'
|
| 124 |
+
version_added = '1.5'
|
| 125 |
+
|
| 126 |
+
flags = re.DOTALL
|
| 127 |
+
|
| 128 |
+
def get_tokens_unprocessed(self, text, stack=('root',)):
|
| 129 |
+
"""Reset the content-type state."""
|
| 130 |
+
self.content_type = None
|
| 131 |
+
return RegexLexer.get_tokens_unprocessed(self, text, stack)
|
| 132 |
+
|
| 133 |
+
def header_callback(self, match):
|
| 134 |
+
if match.group(1).lower() == 'content-type':
|
| 135 |
+
content_type = match.group(5).strip()
|
| 136 |
+
if ';' in content_type:
|
| 137 |
+
content_type = content_type[:content_type.find(';')].strip()
|
| 138 |
+
self.content_type = content_type
|
| 139 |
+
yield match.start(1), Name.Attribute, match.group(1)
|
| 140 |
+
yield match.start(2), Text, match.group(2)
|
| 141 |
+
yield match.start(3), Operator, match.group(3)
|
| 142 |
+
yield match.start(4), Text, match.group(4)
|
| 143 |
+
yield match.start(5), Literal, match.group(5)
|
| 144 |
+
yield match.start(6), Text, match.group(6)
|
| 145 |
+
|
| 146 |
+
def continuous_header_callback(self, match):
|
| 147 |
+
yield match.start(1), Text, match.group(1)
|
| 148 |
+
yield match.start(2), Literal, match.group(2)
|
| 149 |
+
yield match.start(3), Text, match.group(3)
|
| 150 |
+
|
| 151 |
+
def content_callback(self, match):
|
| 152 |
+
content_type = getattr(self, 'content_type', None)
|
| 153 |
+
content = match.group()
|
| 154 |
+
offset = match.start()
|
| 155 |
+
if content_type:
|
| 156 |
+
from pygments.lexers import get_lexer_for_mimetype
|
| 157 |
+
possible_lexer_mimetypes = [content_type]
|
| 158 |
+
if '+' in content_type:
|
| 159 |
+
# application/calendar+xml can be treated as application/xml
|
| 160 |
+
# if there's not a better match.
|
| 161 |
+
general_type = re.sub(r'^(.*)/.*\+(.*)$', r'\1/\2',
|
| 162 |
+
content_type)
|
| 163 |
+
possible_lexer_mimetypes.append(general_type)
|
| 164 |
+
|
| 165 |
+
for i in possible_lexer_mimetypes:
|
| 166 |
+
try:
|
| 167 |
+
lexer = get_lexer_for_mimetype(i)
|
| 168 |
+
except ClassNotFound:
|
| 169 |
+
pass
|
| 170 |
+
else:
|
| 171 |
+
for idx, token, value in lexer.get_tokens_unprocessed(content):
|
| 172 |
+
yield offset + idx, token, value
|
| 173 |
+
return
|
| 174 |
+
yield offset, Text, content
|
| 175 |
+
|
| 176 |
+
tokens = {
|
| 177 |
+
'root': [
|
| 178 |
+
(r'([a-zA-Z][-_a-zA-Z]+)( +)([^ ]+)( +)'
|
| 179 |
+
r'(HTTP)(/)(1\.[01]|2(?:\.0)?|3)(\r?\n|\Z)',
|
| 180 |
+
bygroups(Name.Function, Text, Name.Namespace, Text,
|
| 181 |
+
Keyword.Reserved, Operator, Number, Text),
|
| 182 |
+
'headers'),
|
| 183 |
+
(r'(HTTP)(/)(1\.[01]|2(?:\.0)?|3)( +)(\d{3})(?:( +)([^\r\n]*))?(\r?\n|\Z)',
|
| 184 |
+
bygroups(Keyword.Reserved, Operator, Number, Text, Number, Text,
|
| 185 |
+
Name.Exception, Text),
|
| 186 |
+
'headers'),
|
| 187 |
+
],
|
| 188 |
+
'headers': [
|
| 189 |
+
(r'([^\s:]+)( *)(:)( *)([^\r\n]*)(\r?\n|\Z)', header_callback),
|
| 190 |
+
(r'([\t ]+)([^\r\n]+)(\r?\n|\Z)', continuous_header_callback),
|
| 191 |
+
(r'\r?\n', Text, 'content')
|
| 192 |
+
],
|
| 193 |
+
'content': [
|
| 194 |
+
(r'.+', content_callback)
|
| 195 |
+
]
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
def analyse_text(text):
|
| 199 |
+
return any (
|
| 200 |
+
re.search(pattern, text) is not None
|
| 201 |
+
for pattern in (
|
| 202 |
+
r'^([a-zA-Z][-_a-zA-Z]+)( +)([^ ]+)( +)(HTTP)(/)(1\.[01]|2(?:\.0)?|3)(\r?\n|\Z)',
|
| 203 |
+
r'^(HTTP)(/)(1\.[01]|2(?:\.0)?|3)( +)(\d{3})(?:( +)([^\r\n]*))?(\r?\n|\Z)',
|
| 204 |
+
)
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
class TodotxtLexer(RegexLexer):
|
| 209 |
+
"""
|
| 210 |
+
Lexer for Todo.txt todo list format.
|
| 211 |
+
"""
|
| 212 |
+
|
| 213 |
+
name = 'Todotxt'
|
| 214 |
+
url = 'http://todotxt.com/'
|
| 215 |
+
aliases = ['todotxt']
|
| 216 |
+
version_added = '2.0'
|
| 217 |
+
# *.todotxt is not a standard extension for Todo.txt files; including it
|
| 218 |
+
# makes testing easier, and also makes autodetecting file type easier.
|
| 219 |
+
filenames = ['todo.txt', '*.todotxt']
|
| 220 |
+
mimetypes = ['text/x-todo']
|
| 221 |
+
|
| 222 |
+
# Aliases mapping standard token types of Todo.txt format concepts
|
| 223 |
+
CompleteTaskText = Operator # Chosen to de-emphasize complete tasks
|
| 224 |
+
IncompleteTaskText = Text # Incomplete tasks should look like plain text
|
| 225 |
+
|
| 226 |
+
# Priority should have most emphasis to indicate importance of tasks
|
| 227 |
+
Priority = Generic.Heading
|
| 228 |
+
# Dates should have next most emphasis because time is important
|
| 229 |
+
Date = Generic.Subheading
|
| 230 |
+
|
| 231 |
+
# Project and context should have equal weight, and be in different colors
|
| 232 |
+
Project = Generic.Error
|
| 233 |
+
Context = String
|
| 234 |
+
|
| 235 |
+
# If tag functionality is added, it should have the same weight as Project
|
| 236 |
+
# and Context, and a different color. Generic.Traceback would work well.
|
| 237 |
+
|
| 238 |
+
# Regex patterns for building up rules; dates, priorities, projects, and
|
| 239 |
+
# contexts are all atomic
|
| 240 |
+
# TODO: Make date regex more ISO 8601 compliant
|
| 241 |
+
date_regex = r'\d{4,}-\d{2}-\d{2}'
|
| 242 |
+
priority_regex = r'\([A-Z]\)'
|
| 243 |
+
project_regex = r'\+\S+'
|
| 244 |
+
context_regex = r'@\S+'
|
| 245 |
+
|
| 246 |
+
# Compound regex expressions
|
| 247 |
+
complete_one_date_regex = r'(x )(' + date_regex + r')'
|
| 248 |
+
complete_two_date_regex = (complete_one_date_regex + r'( )(' +
|
| 249 |
+
date_regex + r')')
|
| 250 |
+
priority_date_regex = r'(' + priority_regex + r')( )(' + date_regex + r')'
|
| 251 |
+
|
| 252 |
+
tokens = {
|
| 253 |
+
# Should parse starting at beginning of line; each line is a task
|
| 254 |
+
'root': [
|
| 255 |
+
# Complete task entry points: two total:
|
| 256 |
+
# 1. Complete task with two dates
|
| 257 |
+
(complete_two_date_regex, bygroups(CompleteTaskText, Date,
|
| 258 |
+
CompleteTaskText, Date),
|
| 259 |
+
'complete'),
|
| 260 |
+
# 2. Complete task with one date
|
| 261 |
+
(complete_one_date_regex, bygroups(CompleteTaskText, Date),
|
| 262 |
+
'complete'),
|
| 263 |
+
|
| 264 |
+
# Incomplete task entry points: six total:
|
| 265 |
+
# 1. Priority plus date
|
| 266 |
+
(priority_date_regex, bygroups(Priority, IncompleteTaskText, Date),
|
| 267 |
+
'incomplete'),
|
| 268 |
+
# 2. Priority only
|
| 269 |
+
(priority_regex, Priority, 'incomplete'),
|
| 270 |
+
# 3. Leading date
|
| 271 |
+
(date_regex, Date, 'incomplete'),
|
| 272 |
+
# 4. Leading context
|
| 273 |
+
(context_regex, Context, 'incomplete'),
|
| 274 |
+
# 5. Leading project
|
| 275 |
+
(project_regex, Project, 'incomplete'),
|
| 276 |
+
# 6. Non-whitespace catch-all
|
| 277 |
+
(r'\S+', IncompleteTaskText, 'incomplete'),
|
| 278 |
+
],
|
| 279 |
+
|
| 280 |
+
# Parse a complete task
|
| 281 |
+
'complete': [
|
| 282 |
+
# Newline indicates end of task, should return to root
|
| 283 |
+
(r'\s*\n', CompleteTaskText, '#pop'),
|
| 284 |
+
# Tokenize contexts and projects
|
| 285 |
+
(context_regex, Context),
|
| 286 |
+
(project_regex, Project),
|
| 287 |
+
# Tokenize non-whitespace text
|
| 288 |
+
(r'\S+', CompleteTaskText),
|
| 289 |
+
# Tokenize whitespace not containing a newline
|
| 290 |
+
(r'\s+', CompleteTaskText),
|
| 291 |
+
],
|
| 292 |
+
|
| 293 |
+
# Parse an incomplete task
|
| 294 |
+
'incomplete': [
|
| 295 |
+
# Newline indicates end of task, should return to root
|
| 296 |
+
(r'\s*\n', IncompleteTaskText, '#pop'),
|
| 297 |
+
# Tokenize contexts and projects
|
| 298 |
+
(context_regex, Context),
|
| 299 |
+
(project_regex, Project),
|
| 300 |
+
# Tokenize non-whitespace text
|
| 301 |
+
(r'\S+', IncompleteTaskText),
|
| 302 |
+
# Tokenize whitespace not containing a newline
|
| 303 |
+
(r'\s+', IncompleteTaskText),
|
| 304 |
+
],
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
class NotmuchLexer(RegexLexer):
|
| 309 |
+
"""
|
| 310 |
+
For Notmuch email text format.
|
| 311 |
+
|
| 312 |
+
Additional options accepted:
|
| 313 |
+
|
| 314 |
+
`body_lexer`
|
| 315 |
+
If given, highlight the contents of the message body with the specified
|
| 316 |
+
lexer, else guess it according to the body content (default: ``None``).
|
| 317 |
+
"""
|
| 318 |
+
|
| 319 |
+
name = 'Notmuch'
|
| 320 |
+
url = 'https://notmuchmail.org/'
|
| 321 |
+
aliases = ['notmuch']
|
| 322 |
+
version_added = '2.5'
|
| 323 |
+
|
| 324 |
+
def _highlight_code(self, match):
|
| 325 |
+
code = match.group(1)
|
| 326 |
+
|
| 327 |
+
try:
|
| 328 |
+
if self.body_lexer:
|
| 329 |
+
lexer = get_lexer_by_name(self.body_lexer)
|
| 330 |
+
else:
|
| 331 |
+
lexer = guess_lexer(code.strip())
|
| 332 |
+
except ClassNotFound:
|
| 333 |
+
lexer = get_lexer_by_name('text')
|
| 334 |
+
|
| 335 |
+
yield from lexer.get_tokens_unprocessed(code)
|
| 336 |
+
|
| 337 |
+
tokens = {
|
| 338 |
+
'root': [
|
| 339 |
+
(r'\fmessage\{\s*', Keyword, ('message', 'message-attr')),
|
| 340 |
+
],
|
| 341 |
+
'message-attr': [
|
| 342 |
+
(r'(\s*id:\s*)(\S+)', bygroups(Name.Attribute, String)),
|
| 343 |
+
(r'(\s*(?:depth|match|excluded):\s*)(\d+)',
|
| 344 |
+
bygroups(Name.Attribute, Number.Integer)),
|
| 345 |
+
(r'(\s*filename:\s*)(.+\n)',
|
| 346 |
+
bygroups(Name.Attribute, String)),
|
| 347 |
+
default('#pop'),
|
| 348 |
+
],
|
| 349 |
+
'message': [
|
| 350 |
+
(r'\fmessage\}\n', Keyword, '#pop'),
|
| 351 |
+
(r'\fheader\{\n', Keyword, 'header'),
|
| 352 |
+
(r'\fbody\{\n', Keyword, 'body'),
|
| 353 |
+
],
|
| 354 |
+
'header': [
|
| 355 |
+
(r'\fheader\}\n', Keyword, '#pop'),
|
| 356 |
+
(r'((?:Subject|From|To|Cc|Date):\s*)(.*\n)',
|
| 357 |
+
bygroups(Name.Attribute, String)),
|
| 358 |
+
(r'(.*)(\s*\(.*\))(\s*\(.*\)\n)',
|
| 359 |
+
bygroups(Generic.Strong, Literal, Name.Tag)),
|
| 360 |
+
],
|
| 361 |
+
'body': [
|
| 362 |
+
(r'\fpart\{\n', Keyword, 'part'),
|
| 363 |
+
(r'\f(part|attachment)\{\s*', Keyword, ('part', 'part-attr')),
|
| 364 |
+
(r'\fbody\}\n', Keyword, '#pop'),
|
| 365 |
+
],
|
| 366 |
+
'part-attr': [
|
| 367 |
+
(r'(ID:\s*)(\d+)', bygroups(Name.Attribute, Number.Integer)),
|
| 368 |
+
(r'(,\s*)((?:Filename|Content-id):\s*)([^,]+)',
|
| 369 |
+
bygroups(Punctuation, Name.Attribute, String)),
|
| 370 |
+
(r'(,\s*)(Content-type:\s*)(.+\n)',
|
| 371 |
+
bygroups(Punctuation, Name.Attribute, String)),
|
| 372 |
+
default('#pop'),
|
| 373 |
+
],
|
| 374 |
+
'part': [
|
| 375 |
+
(r'\f(?:part|attachment)\}\n', Keyword, '#pop'),
|
| 376 |
+
(r'\f(?:part|attachment)\{\s*', Keyword, ('#push', 'part-attr')),
|
| 377 |
+
(r'^Non-text part: .*\n', Comment),
|
| 378 |
+
(r'(?s)(.*?(?=\f(?:part|attachment)\}\n))', _highlight_code),
|
| 379 |
+
],
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
def analyse_text(text):
|
| 383 |
+
return 1.0 if text.startswith('\fmessage{') else 0.0
|
| 384 |
+
|
| 385 |
+
def __init__(self, **options):
|
| 386 |
+
self.body_lexer = options.get('body_lexer', None)
|
| 387 |
+
RegexLexer.__init__(self, **options)
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
class KernelLogLexer(RegexLexer):
|
| 391 |
+
"""
|
| 392 |
+
For Linux Kernel log ("dmesg") output.
|
| 393 |
+
"""
|
| 394 |
+
name = 'Kernel log'
|
| 395 |
+
aliases = ['kmsg', 'dmesg']
|
| 396 |
+
filenames = ['*.kmsg', '*.dmesg']
|
| 397 |
+
url = 'https://fr.wikipedia.org/wiki/Dmesg'
|
| 398 |
+
version_added = '2.6'
|
| 399 |
+
|
| 400 |
+
tokens = {
|
| 401 |
+
'root': [
|
| 402 |
+
(r'^[^:]+:debug : (?=\[)', Text, 'debug'),
|
| 403 |
+
(r'^[^:]+:info : (?=\[)', Text, 'info'),
|
| 404 |
+
(r'^[^:]+:warn : (?=\[)', Text, 'warn'),
|
| 405 |
+
(r'^[^:]+:notice: (?=\[)', Text, 'warn'),
|
| 406 |
+
(r'^[^:]+:err : (?=\[)', Text, 'error'),
|
| 407 |
+
(r'^[^:]+:crit : (?=\[)', Text, 'error'),
|
| 408 |
+
(r'^(?=\[)', Text, 'unknown'),
|
| 409 |
+
],
|
| 410 |
+
'unknown': [
|
| 411 |
+
(r'^(?=.+(warning|notice|audit|deprecated))', Text, 'warn'),
|
| 412 |
+
(r'^(?=.+(error|critical|fail|Bug))', Text, 'error'),
|
| 413 |
+
default('info'),
|
| 414 |
+
],
|
| 415 |
+
'base': [
|
| 416 |
+
(r'\[[0-9. ]+\] ', Number),
|
| 417 |
+
(r'(?<=\] ).+?:', Keyword),
|
| 418 |
+
(r'\n', Text, '#pop'),
|
| 419 |
+
],
|
| 420 |
+
'debug': [
|
| 421 |
+
include('base'),
|
| 422 |
+
(r'.+\n', Comment, '#pop')
|
| 423 |
+
],
|
| 424 |
+
'info': [
|
| 425 |
+
include('base'),
|
| 426 |
+
(r'.+\n', Text, '#pop')
|
| 427 |
+
],
|
| 428 |
+
'warn': [
|
| 429 |
+
include('base'),
|
| 430 |
+
(r'.+\n', Generic.Strong, '#pop')
|
| 431 |
+
],
|
| 432 |
+
'error': [
|
| 433 |
+
include('base'),
|
| 434 |
+
(r'.+\n', Generic.Error, '#pop')
|
| 435 |
+
]
|
| 436 |
+
}
|