Add files using upload-large-folder tool
Browse files- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/graphviz.py +58 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/gsql.py +103 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/hare.py +73 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/haskell.py +867 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/haxe.py +941 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/hdl.py +466 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/hexdump.py +102 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/html.py +670 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/idl.py +284 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/igor.py +435 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/inferno.py +95 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/installers.py +352 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/int_fiction.py +1370 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/iolang.py +61 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/j.py +151 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/javascript.py +1591 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/jmespath.py +69 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/jslt.py +94 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/json5.py +83 -0
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/jsonnet.py +169 -0
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/graphviz.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.graphviz
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the DOT language (graphviz).
|
| 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 Comment, Keyword, Operator, Name, String, Number, \
|
| 13 |
+
Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
__all__ = ['GraphvizLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class GraphvizLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
For graphviz DOT graph description language.
|
| 22 |
+
"""
|
| 23 |
+
name = 'Graphviz'
|
| 24 |
+
url = 'https://www.graphviz.org/doc/info/lang.html'
|
| 25 |
+
aliases = ['graphviz', 'dot']
|
| 26 |
+
filenames = ['*.gv', '*.dot']
|
| 27 |
+
mimetypes = ['text/x-graphviz', 'text/vnd.graphviz']
|
| 28 |
+
version_added = '2.8'
|
| 29 |
+
tokens = {
|
| 30 |
+
'root': [
|
| 31 |
+
(r'\s+', Whitespace),
|
| 32 |
+
(r'(#|//).*?$', Comment.Single),
|
| 33 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 34 |
+
(r'(?i)(node|edge|graph|digraph|subgraph|strict)\b', Keyword),
|
| 35 |
+
(r'--|->', Operator),
|
| 36 |
+
(r'[{}[\]:;,]', Punctuation),
|
| 37 |
+
(r'(\b\D\w*)(\s*)(=)(\s*)',
|
| 38 |
+
bygroups(Name.Attribute, Whitespace, Punctuation, Whitespace),
|
| 39 |
+
'attr_id'),
|
| 40 |
+
(r'\b(n|ne|e|se|s|sw|w|nw|c|_)\b', Name.Builtin),
|
| 41 |
+
(r'\b\D\w*', Name.Tag), # node
|
| 42 |
+
(r'[-]?((\.[0-9]+)|([0-9]+(\.[0-9]*)?))', Number),
|
| 43 |
+
(r'"(\\"|[^"])*?"', Name.Tag), # quoted node
|
| 44 |
+
(r'<', Punctuation, 'xml'),
|
| 45 |
+
],
|
| 46 |
+
'attr_id': [
|
| 47 |
+
(r'\b\D\w*', String, '#pop'),
|
| 48 |
+
(r'[-]?((\.[0-9]+)|([0-9]+(\.[0-9]*)?))', Number, '#pop'),
|
| 49 |
+
(r'"(\\"|[^"])*?"', String.Double, '#pop'),
|
| 50 |
+
(r'<', Punctuation, ('#pop', 'xml')),
|
| 51 |
+
],
|
| 52 |
+
'xml': [
|
| 53 |
+
(r'<', Punctuation, '#push'),
|
| 54 |
+
(r'>', Punctuation, '#pop'),
|
| 55 |
+
(r'\s+', Whitespace),
|
| 56 |
+
(r'[^<>\s]', Name.Tag),
|
| 57 |
+
]
|
| 58 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/gsql.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.gsql
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for TigerGraph GSQL graph query language
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, include, bygroups, using, this, words
|
| 14 |
+
from pygments.token import Keyword, Punctuation, Comment, Operator, Name, \
|
| 15 |
+
String, Number, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ["GSQLLexer"]
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class GSQLLexer(RegexLexer):
|
| 21 |
+
|
| 22 |
+
"""
|
| 23 |
+
For GSQL queries (version 3.x).
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = 'GSQL'
|
| 27 |
+
url = 'https://docs.tigergraph.com/dev/gsql-ref'
|
| 28 |
+
aliases = ['gsql']
|
| 29 |
+
filenames = ['*.gsql']
|
| 30 |
+
version_added = '2.10'
|
| 31 |
+
|
| 32 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'root': [
|
| 36 |
+
include('comment'),
|
| 37 |
+
include('keywords'),
|
| 38 |
+
include('clauses'),
|
| 39 |
+
include('accums'),
|
| 40 |
+
include('relations'),
|
| 41 |
+
include('strings'),
|
| 42 |
+
include('whitespace'),
|
| 43 |
+
include('barewords'),
|
| 44 |
+
include('operators'),
|
| 45 |
+
],
|
| 46 |
+
'comment': [
|
| 47 |
+
(r'\#.*', Comment.Single),
|
| 48 |
+
(r'/\*(.|\n)*?\*/', Comment.Multiline),
|
| 49 |
+
],
|
| 50 |
+
'keywords': [
|
| 51 |
+
(words((
|
| 52 |
+
'ACCUM', 'AND', 'ANY', 'API', 'AS', 'ASC', 'AVG', 'BAG', 'BATCH',
|
| 53 |
+
'BETWEEN', 'BOOL', 'BOTH', 'BREAK', 'BY', 'CASE', 'CATCH', 'COALESCE',
|
| 54 |
+
'COMPRESS', 'CONTINUE', 'COUNT', 'CREATE', 'DATETIME', 'DATETIME_ADD',
|
| 55 |
+
'DATETIME_SUB', 'DELETE', 'DESC', 'DISTRIBUTED', 'DO', 'DOUBLE',
|
| 56 |
+
'EDGE', 'ELSE', 'END', 'ESCAPE', 'EXCEPTION', 'FALSE', 'FILE',
|
| 57 |
+
'FILTER', 'FLOAT', 'FOREACH', 'FOR', 'FROM', 'GRAPH', 'GROUP',
|
| 58 |
+
'GSQL_INT_MAX', 'GSQL_INT_MIN', 'GSQL_UINT_MAX', 'HAVING', 'IF',
|
| 59 |
+
'IN', 'INSERT', 'INT', 'INTERPRET', 'INTERSECT', 'INTERVAL', 'INTO',
|
| 60 |
+
'IS', 'ISEMPTY', 'JSONARRAY', 'JSONOBJECT', 'LASTHOP', 'LEADING',
|
| 61 |
+
'LIKE', 'LIMIT', 'LIST', 'LOAD_ACCUM', 'LOG', 'MAP', 'MATCH', 'MAX',
|
| 62 |
+
'MIN', 'MINUS', 'NOT', 'NOW', 'NULL', 'OFFSET', 'OR', 'ORDER', 'PATH',
|
| 63 |
+
'PER', 'PINNED', 'POST_ACCUM', 'POST-ACCUM', 'PRIMARY_ID', 'PRINT',
|
| 64 |
+
'QUERY', 'RAISE', 'RANGE', 'REPLACE', 'RESET_COLLECTION_ACCUM',
|
| 65 |
+
'RETURN', 'RETURNS', 'RUN', 'SAMPLE', 'SELECT', 'SELECT_VERTEX',
|
| 66 |
+
'SET', 'SRC', 'STATIC', 'STRING', 'SUM', 'SYNTAX', 'TARGET',
|
| 67 |
+
'TAGSTGT', 'THEN', 'TO', 'TO_CSV', 'TO_DATETIME', 'TRAILING',
|
| 68 |
+
'TRIM', 'TRUE', 'TRY', 'TUPLE', 'TYPEDEF', 'UINT', 'UNION', 'UPDATE',
|
| 69 |
+
'VALUES', 'VERTEX', 'WHEN', 'WHERE', 'WHILE', 'WITH'),
|
| 70 |
+
prefix=r'(?<!\.)', suffix=r'\b'), Keyword),
|
| 71 |
+
],
|
| 72 |
+
'clauses': [
|
| 73 |
+
(words(('accum', 'having', 'limit', 'order', 'postAccum', 'sample', 'where')),
|
| 74 |
+
Name.Builtin),
|
| 75 |
+
],
|
| 76 |
+
'accums': [
|
| 77 |
+
(words(('andaccum', 'arrayaccum', 'avgaccum', 'bagaccum', 'bitwiseandaccum',
|
| 78 |
+
'bitwiseoraccum', 'groupbyaccum', 'heapaccum', 'listaccum',
|
| 79 |
+
'MapAccum', 'maxaccum', 'minaccum', 'oraccum', 'setaccum',
|
| 80 |
+
'sumaccum')), Name.Builtin),
|
| 81 |
+
],
|
| 82 |
+
'relations': [
|
| 83 |
+
(r'(-\s?)(\(.*\:\w?\))(\s?-)', bygroups(Operator, using(this), Operator)),
|
| 84 |
+
(r'->|<-', Operator),
|
| 85 |
+
(r'[.*{}\[\]\<\>\_]', Punctuation),
|
| 86 |
+
],
|
| 87 |
+
'strings': [
|
| 88 |
+
(r'"([^"\\]|\\.)*"', String),
|
| 89 |
+
(r'@{1,2}\w+', Name.Variable),
|
| 90 |
+
],
|
| 91 |
+
'whitespace': [
|
| 92 |
+
(r'\s+', Whitespace),
|
| 93 |
+
],
|
| 94 |
+
'barewords': [
|
| 95 |
+
(r'[a-z]\w*', Name),
|
| 96 |
+
(r'(\d+\.\d+|\d+)', Number),
|
| 97 |
+
],
|
| 98 |
+
'operators': [
|
| 99 |
+
(r'\$|[^0-9|\/|\-](\-\=|\+\=|\*\=|\\\=|\=|\=\=|\=\=\=|'
|
| 100 |
+
r'\+|\-|\*|\\|\+\=|\>|\<)[^\>|\/]', Operator),
|
| 101 |
+
(r'(\||\(|\)|\,|\;|\=|\-|\+|\*|\/|\>|\<|\:)', Operator),
|
| 102 |
+
],
|
| 103 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/hare.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.hare
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Hare language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, include, words
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
| 13 |
+
Number, Punctuation, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['HareLexer']
|
| 16 |
+
|
| 17 |
+
class HareLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
Lexer for the Hare programming language.
|
| 20 |
+
"""
|
| 21 |
+
name = 'Hare'
|
| 22 |
+
url = 'https://harelang.org/'
|
| 23 |
+
aliases = ['hare']
|
| 24 |
+
filenames = ['*.ha']
|
| 25 |
+
mimetypes = ['text/x-hare']
|
| 26 |
+
version_added = '2.19'
|
| 27 |
+
|
| 28 |
+
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
|
| 29 |
+
_ws1 = r'\s*(?:/[*].*?[*]/\s*)?'
|
| 30 |
+
|
| 31 |
+
tokens = {
|
| 32 |
+
'whitespace': [
|
| 33 |
+
(r'^use.*;', Comment.Preproc),
|
| 34 |
+
(r'@[a-z]+', Comment.Preproc),
|
| 35 |
+
(r'\n', Whitespace),
|
| 36 |
+
(r'\s+', Whitespace),
|
| 37 |
+
(r'//.*?$', Comment.Single),
|
| 38 |
+
],
|
| 39 |
+
'statements': [
|
| 40 |
+
(r'"', String, 'string'),
|
| 41 |
+
(r'`[^`]*`', String),
|
| 42 |
+
(r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
| 43 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
|
| 44 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 45 |
+
(r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
|
| 46 |
+
(r'0o[0-7]+[LlUu]*', Number.Oct),
|
| 47 |
+
(r'\d+[zui]?(\d+)?', Number.Integer),
|
| 48 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 49 |
+
(words(('as', 'is', '=>', '..', '...')), Operator),
|
| 50 |
+
(r'[()\[\],.{};]+', Punctuation),
|
| 51 |
+
(words(('abort', 'align', 'alloc', 'append', 'assert', 'case',
|
| 52 |
+
'const', 'def', 'defer', 'delete', 'else', 'enum', 'export',
|
| 53 |
+
'fn', 'for', 'free', 'if', 'let', 'len', 'match', 'offset',
|
| 54 |
+
'return', 'static', 'struct', 'switch', 'type', 'union',
|
| 55 |
+
'yield', 'vastart', 'vaarg', 'vaend'),
|
| 56 |
+
suffix=r'\b'), Keyword),
|
| 57 |
+
(r'(bool|int|uint|uintptr|u8|u16|u32|u64|i8|i16|i32|i64|f32|f64|null|done|never|void|nullable|rune|size|valist)\b',
|
| 58 |
+
Keyword.Type),
|
| 59 |
+
(r'(true|false|null)\b', Name.Builtin),
|
| 60 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 61 |
+
],
|
| 62 |
+
'string': [
|
| 63 |
+
(r'"', String, '#pop'),
|
| 64 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
|
| 65 |
+
r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
|
| 66 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 67 |
+
(r'\\', String), # stray backslash
|
| 68 |
+
],
|
| 69 |
+
'root': [
|
| 70 |
+
include('whitespace'),
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.haskell
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Haskell and related languages.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, \
|
| 14 |
+
default, include, inherit, line_re
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Generic, Whitespace
|
| 17 |
+
from pygments import unistring as uni
|
| 18 |
+
|
| 19 |
+
__all__ = ['HaskellLexer', 'HspecLexer', 'IdrisLexer', 'AgdaLexer', 'CryptolLexer',
|
| 20 |
+
'LiterateHaskellLexer', 'LiterateIdrisLexer', 'LiterateAgdaLexer',
|
| 21 |
+
'LiterateCryptolLexer', 'KokaLexer']
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class HaskellLexer(RegexLexer):
|
| 25 |
+
"""
|
| 26 |
+
A Haskell lexer based on the lexemes defined in the Haskell 98 Report.
|
| 27 |
+
"""
|
| 28 |
+
name = 'Haskell'
|
| 29 |
+
url = 'https://www.haskell.org/'
|
| 30 |
+
aliases = ['haskell', 'hs']
|
| 31 |
+
filenames = ['*.hs']
|
| 32 |
+
mimetypes = ['text/x-haskell']
|
| 33 |
+
version_added = '0.8'
|
| 34 |
+
|
| 35 |
+
reserved = ('case', 'class', 'data', 'default', 'deriving', 'do', 'else',
|
| 36 |
+
'family', 'if', 'in', 'infix[lr]?', 'instance',
|
| 37 |
+
'let', 'newtype', 'of', 'then', 'type', 'where', '_')
|
| 38 |
+
ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
|
| 39 |
+
'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
|
| 40 |
+
'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN',
|
| 41 |
+
'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL')
|
| 42 |
+
|
| 43 |
+
tokens = {
|
| 44 |
+
'root': [
|
| 45 |
+
# Whitespace:
|
| 46 |
+
(r'\s+', Whitespace),
|
| 47 |
+
# (r'--\s*|.*$', Comment.Doc),
|
| 48 |
+
(r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
|
| 49 |
+
(r'\{-', Comment.Multiline, 'comment'),
|
| 50 |
+
# Lexemes:
|
| 51 |
+
# Identifiers
|
| 52 |
+
(r'\bimport\b', Keyword.Reserved, 'import'),
|
| 53 |
+
(r'\bmodule\b', Keyword.Reserved, 'module'),
|
| 54 |
+
(r'\berror\b', Name.Exception),
|
| 55 |
+
(r'\b({})(?!\')\b'.format('|'.join(reserved)), Keyword.Reserved),
|
| 56 |
+
(r"'[^\\]'", String.Char), # character literal
|
| 57 |
+
(r"'\\.'", String.Char), # escape character literal (e.g. '\n')
|
| 58 |
+
(r'^[_' + uni.Ll + r'][\w\']*', Name.Function),
|
| 59 |
+
(r"'?[_" + uni.Ll + r"][\w']*", Name),
|
| 60 |
+
(r"('')?[" + uni.Lu + r"][\w\']*", Keyword.Type),
|
| 61 |
+
(r"(')[" + uni.Lu + r"][\w\']*", Keyword.Type),
|
| 62 |
+
(r"(')\[[^\]]*\]", Keyword.Type), # tuples and lists get special treatment in GHC
|
| 63 |
+
(r"(')\([^)]*\)", Keyword.Type), # ..
|
| 64 |
+
(r"(')[:!#$%&*+.\\/<=>?@^|~-]+", Keyword.Type), # promoted type operators
|
| 65 |
+
# Operators
|
| 66 |
+
(r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
|
| 67 |
+
(r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
|
| 68 |
+
(r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators
|
| 69 |
+
(r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators
|
| 70 |
+
# Numbers
|
| 71 |
+
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*_*[pP][+-]?\d(_*\d)*', Number.Float),
|
| 72 |
+
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*\.[\da-fA-F](_*[\da-fA-F])*'
|
| 73 |
+
r'(_*[pP][+-]?\d(_*\d)*)?', Number.Float),
|
| 74 |
+
(r'\d(_*\d)*_*[eE][+-]?\d(_*\d)*', Number.Float),
|
| 75 |
+
(r'\d(_*\d)*\.\d(_*\d)*(_*[eE][+-]?\d(_*\d)*)?', Number.Float),
|
| 76 |
+
(r'0[bB]_*[01](_*[01])*', Number.Bin),
|
| 77 |
+
(r'0[oO]_*[0-7](_*[0-7])*', Number.Oct),
|
| 78 |
+
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*', Number.Hex),
|
| 79 |
+
(r'\d(_*\d)*', Number.Integer),
|
| 80 |
+
# Character/String Literals
|
| 81 |
+
(r"'", String.Char, 'character'),
|
| 82 |
+
(r'"', String, 'string'),
|
| 83 |
+
# Special
|
| 84 |
+
(r'\[\]', Keyword.Type),
|
| 85 |
+
(r'\(\)', Name.Builtin),
|
| 86 |
+
(r'[][(),;`{}]', Punctuation),
|
| 87 |
+
],
|
| 88 |
+
'import': [
|
| 89 |
+
# Import statements
|
| 90 |
+
(r'\s+', Whitespace),
|
| 91 |
+
(r'"', String, 'string'),
|
| 92 |
+
# after "funclist" state
|
| 93 |
+
(r'\)', Punctuation, '#pop'),
|
| 94 |
+
(r'qualified\b', Keyword),
|
| 95 |
+
# import X as Y
|
| 96 |
+
(r'([' + uni.Lu + r'][\w.]*)(\s+)(as)(\s+)([' + uni.Lu + r'][\w.]*)',
|
| 97 |
+
bygroups(Name.Namespace, Whitespace, Keyword, Whitespace, Name), '#pop'),
|
| 98 |
+
# import X hiding (functions)
|
| 99 |
+
(r'([' + uni.Lu + r'][\w.]*)(\s+)(hiding)(\s+)(\()',
|
| 100 |
+
bygroups(Name.Namespace, Whitespace, Keyword, Whitespace, Punctuation), 'funclist'),
|
| 101 |
+
# import X (functions)
|
| 102 |
+
(r'([' + uni.Lu + r'][\w.]*)(\s+)(\()',
|
| 103 |
+
bygroups(Name.Namespace, Whitespace, Punctuation), 'funclist'),
|
| 104 |
+
# import X
|
| 105 |
+
(r'[\w.]+', Name.Namespace, '#pop'),
|
| 106 |
+
],
|
| 107 |
+
'module': [
|
| 108 |
+
(r'\s+', Whitespace),
|
| 109 |
+
(r'([' + uni.Lu + r'][\w.]*)(\s+)(\()',
|
| 110 |
+
bygroups(Name.Namespace, Whitespace, Punctuation), 'funclist'),
|
| 111 |
+
(r'[' + uni.Lu + r'][\w.]*', Name.Namespace, '#pop'),
|
| 112 |
+
],
|
| 113 |
+
'funclist': [
|
| 114 |
+
(r'\s+', Whitespace),
|
| 115 |
+
(r'[' + uni.Lu + r']\w*', Keyword.Type),
|
| 116 |
+
(r'(_[\w\']+|[' + uni.Ll + r'][\w\']*)', Name.Function),
|
| 117 |
+
(r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
|
| 118 |
+
(r'\{-', Comment.Multiline, 'comment'),
|
| 119 |
+
(r',', Punctuation),
|
| 120 |
+
(r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
|
| 121 |
+
# (HACK, but it makes sense to push two instances, believe me)
|
| 122 |
+
(r'\(', Punctuation, ('funclist', 'funclist')),
|
| 123 |
+
(r'\)', Punctuation, '#pop:2'),
|
| 124 |
+
],
|
| 125 |
+
# NOTE: the next four states are shared in the AgdaLexer; make sure
|
| 126 |
+
# any change is compatible with Agda as well or copy over and change
|
| 127 |
+
'comment': [
|
| 128 |
+
# Multiline Comments
|
| 129 |
+
(r'[^-{}]+', Comment.Multiline),
|
| 130 |
+
(r'\{-', Comment.Multiline, '#push'),
|
| 131 |
+
(r'-\}', Comment.Multiline, '#pop'),
|
| 132 |
+
(r'[-{}]', Comment.Multiline),
|
| 133 |
+
],
|
| 134 |
+
'character': [
|
| 135 |
+
# Allows multi-chars, incorrectly.
|
| 136 |
+
(r"[^\\']'", String.Char, '#pop'),
|
| 137 |
+
(r"\\", String.Escape, 'escape'),
|
| 138 |
+
("'", String.Char, '#pop'),
|
| 139 |
+
],
|
| 140 |
+
'string': [
|
| 141 |
+
(r'[^\\"]+', String),
|
| 142 |
+
(r"\\", String.Escape, 'escape'),
|
| 143 |
+
('"', String, '#pop'),
|
| 144 |
+
],
|
| 145 |
+
'escape': [
|
| 146 |
+
(r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
|
| 147 |
+
(r'\^[][' + uni.Lu + r'@^_]', String.Escape, '#pop'),
|
| 148 |
+
('|'.join(ascii), String.Escape, '#pop'),
|
| 149 |
+
(r'o[0-7]+', String.Escape, '#pop'),
|
| 150 |
+
(r'x[\da-fA-F]+', String.Escape, '#pop'),
|
| 151 |
+
(r'\d+', String.Escape, '#pop'),
|
| 152 |
+
(r'(\s+)(\\)', bygroups(Whitespace, String.Escape), '#pop'),
|
| 153 |
+
],
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class HspecLexer(HaskellLexer):
|
| 158 |
+
"""
|
| 159 |
+
A Haskell lexer with support for Hspec constructs.
|
| 160 |
+
"""
|
| 161 |
+
|
| 162 |
+
name = 'Hspec'
|
| 163 |
+
aliases = ['hspec']
|
| 164 |
+
filenames = ['*Spec.hs']
|
| 165 |
+
mimetypes = []
|
| 166 |
+
version_added = '2.4'
|
| 167 |
+
|
| 168 |
+
tokens = {
|
| 169 |
+
'root': [
|
| 170 |
+
(r'(it)(\s*)("[^"]*")', bygroups(Text, Whitespace, String.Doc)),
|
| 171 |
+
(r'(describe)(\s*)("[^"]*")', bygroups(Text, Whitespace, String.Doc)),
|
| 172 |
+
(r'(context)(\s*)("[^"]*")', bygroups(Text, Whitespace, String.Doc)),
|
| 173 |
+
inherit,
|
| 174 |
+
],
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
class IdrisLexer(RegexLexer):
|
| 179 |
+
"""
|
| 180 |
+
A lexer for the dependently typed programming language Idris.
|
| 181 |
+
|
| 182 |
+
Based on the Haskell and Agda Lexer.
|
| 183 |
+
"""
|
| 184 |
+
name = 'Idris'
|
| 185 |
+
url = 'https://www.idris-lang.org/'
|
| 186 |
+
aliases = ['idris', 'idr']
|
| 187 |
+
filenames = ['*.idr']
|
| 188 |
+
mimetypes = ['text/x-idris']
|
| 189 |
+
version_added = '2.0'
|
| 190 |
+
|
| 191 |
+
reserved = ('case', 'class', 'data', 'default', 'using', 'do', 'else',
|
| 192 |
+
'if', 'in', 'infix[lr]?', 'instance', 'rewrite', 'auto',
|
| 193 |
+
'namespace', 'codata', 'mutual', 'private', 'public', 'abstract',
|
| 194 |
+
'total', 'partial',
|
| 195 |
+
'interface', 'implementation', 'export', 'covering', 'constructor',
|
| 196 |
+
'let', 'proof', 'of', 'then', 'static', 'where', '_', 'with',
|
| 197 |
+
'pattern', 'term', 'syntax', 'prefix',
|
| 198 |
+
'postulate', 'parameters', 'record', 'dsl', 'impossible', 'implicit',
|
| 199 |
+
'tactics', 'intros', 'intro', 'compute', 'refine', 'exact', 'trivial')
|
| 200 |
+
|
| 201 |
+
ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
|
| 202 |
+
'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
|
| 203 |
+
'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN',
|
| 204 |
+
'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL')
|
| 205 |
+
|
| 206 |
+
directives = ('lib', 'link', 'flag', 'include', 'hide', 'freeze', 'access',
|
| 207 |
+
'default', 'logging', 'dynamic', 'name', 'error_handlers', 'language')
|
| 208 |
+
|
| 209 |
+
tokens = {
|
| 210 |
+
'root': [
|
| 211 |
+
# Comments
|
| 212 |
+
(r'^(\s*)(%({}))'.format('|'.join(directives)),
|
| 213 |
+
bygroups(Whitespace, Keyword.Reserved)),
|
| 214 |
+
(r'(\s*)(--(?![!#$%&*+./<=>?@^|_~:\\]).*?)$', bygroups(Whitespace, Comment.Single)),
|
| 215 |
+
(r'(\s*)(\|{3}.*?)$', bygroups(Whitespace, Comment.Single)),
|
| 216 |
+
(r'(\s*)(\{-)', bygroups(Whitespace, Comment.Multiline), 'comment'),
|
| 217 |
+
# Declaration
|
| 218 |
+
(r'^(\s*)([^\s(){}]+)(\s*)(:)(\s*)',
|
| 219 |
+
bygroups(Whitespace, Name.Function, Whitespace, Operator.Word, Whitespace)),
|
| 220 |
+
# Identifiers
|
| 221 |
+
(r'\b({})(?!\')\b'.format('|'.join(reserved)), Keyword.Reserved),
|
| 222 |
+
(r'(import|module)(\s+)', bygroups(Keyword.Reserved, Whitespace), 'module'),
|
| 223 |
+
(r"('')?[A-Z][\w\']*", Keyword.Type),
|
| 224 |
+
(r'[a-z][\w\']*', Text),
|
| 225 |
+
# Special Symbols
|
| 226 |
+
(r'(<-|::|->|=>|=)', Operator.Word), # specials
|
| 227 |
+
(r'([(){}\[\]:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
|
| 228 |
+
# Numbers
|
| 229 |
+
(r'\d+[eE][+-]?\d+', Number.Float),
|
| 230 |
+
(r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
|
| 231 |
+
(r'0[xX][\da-fA-F]+', Number.Hex),
|
| 232 |
+
(r'\d+', Number.Integer),
|
| 233 |
+
# Strings
|
| 234 |
+
(r"'", String.Char, 'character'),
|
| 235 |
+
(r'"', String, 'string'),
|
| 236 |
+
(r'[^\s(){}]+', Text),
|
| 237 |
+
(r'\s+?', Whitespace), # Whitespace
|
| 238 |
+
],
|
| 239 |
+
'module': [
|
| 240 |
+
(r'\s+', Whitespace),
|
| 241 |
+
(r'([A-Z][\w.]*)(\s+)(\()',
|
| 242 |
+
bygroups(Name.Namespace, Whitespace, Punctuation), 'funclist'),
|
| 243 |
+
(r'[A-Z][\w.]*', Name.Namespace, '#pop'),
|
| 244 |
+
],
|
| 245 |
+
'funclist': [
|
| 246 |
+
(r'\s+', Whitespace),
|
| 247 |
+
(r'[A-Z]\w*', Keyword.Type),
|
| 248 |
+
(r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
|
| 249 |
+
(r'--.*$', Comment.Single),
|
| 250 |
+
(r'\{-', Comment.Multiline, 'comment'),
|
| 251 |
+
(r',', Punctuation),
|
| 252 |
+
(r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
|
| 253 |
+
# (HACK, but it makes sense to push two instances, believe me)
|
| 254 |
+
(r'\(', Punctuation, ('funclist', 'funclist')),
|
| 255 |
+
(r'\)', Punctuation, '#pop:2'),
|
| 256 |
+
],
|
| 257 |
+
# NOTE: the next four states are shared in the AgdaLexer; make sure
|
| 258 |
+
# any change is compatible with Agda as well or copy over and change
|
| 259 |
+
'comment': [
|
| 260 |
+
# Multiline Comments
|
| 261 |
+
(r'[^-{}]+', Comment.Multiline),
|
| 262 |
+
(r'\{-', Comment.Multiline, '#push'),
|
| 263 |
+
(r'-\}', Comment.Multiline, '#pop'),
|
| 264 |
+
(r'[-{}]', Comment.Multiline),
|
| 265 |
+
],
|
| 266 |
+
'character': [
|
| 267 |
+
# Allows multi-chars, incorrectly.
|
| 268 |
+
(r"[^\\']", String.Char),
|
| 269 |
+
(r"\\", String.Escape, 'escape'),
|
| 270 |
+
("'", String.Char, '#pop'),
|
| 271 |
+
],
|
| 272 |
+
'string': [
|
| 273 |
+
(r'[^\\"]+', String),
|
| 274 |
+
(r"\\", String.Escape, 'escape'),
|
| 275 |
+
('"', String, '#pop'),
|
| 276 |
+
],
|
| 277 |
+
'escape': [
|
| 278 |
+
(r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
|
| 279 |
+
(r'\^[][A-Z@^_]', String.Escape, '#pop'),
|
| 280 |
+
('|'.join(ascii), String.Escape, '#pop'),
|
| 281 |
+
(r'o[0-7]+', String.Escape, '#pop'),
|
| 282 |
+
(r'x[\da-fA-F]+', String.Escape, '#pop'),
|
| 283 |
+
(r'\d+', String.Escape, '#pop'),
|
| 284 |
+
(r'(\s+)(\\)', bygroups(Whitespace, String.Escape), '#pop')
|
| 285 |
+
],
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
class AgdaLexer(RegexLexer):
|
| 290 |
+
"""
|
| 291 |
+
For the Agda dependently typed functional programming language and
|
| 292 |
+
proof assistant.
|
| 293 |
+
"""
|
| 294 |
+
|
| 295 |
+
name = 'Agda'
|
| 296 |
+
url = 'http://wiki.portal.chalmers.se/agda/pmwiki.php'
|
| 297 |
+
aliases = ['agda']
|
| 298 |
+
filenames = ['*.agda']
|
| 299 |
+
mimetypes = ['text/x-agda']
|
| 300 |
+
version_added = '2.0'
|
| 301 |
+
|
| 302 |
+
reserved = (
|
| 303 |
+
'abstract', 'codata', 'coinductive', 'constructor', 'data', 'do',
|
| 304 |
+
'eta-equality', 'field', 'forall', 'hiding', 'in', 'inductive', 'infix',
|
| 305 |
+
'infixl', 'infixr', 'instance', 'interleaved', 'let', 'macro', 'mutual',
|
| 306 |
+
'no-eta-equality', 'opaque', 'open', 'overlap', 'pattern', 'postulate', 'primitive',
|
| 307 |
+
'private', 'quote', 'quoteTerm', 'record', 'renaming', 'rewrite',
|
| 308 |
+
'syntax', 'tactic', 'unfolding', 'unquote', 'unquoteDecl', 'unquoteDef', 'using',
|
| 309 |
+
'variable', 'where', 'with',
|
| 310 |
+
)
|
| 311 |
+
|
| 312 |
+
tokens = {
|
| 313 |
+
'root': [
|
| 314 |
+
# Declaration
|
| 315 |
+
(r'^(\s*)([^\s(){}]+)(\s*)(:)(\s*)',
|
| 316 |
+
bygroups(Whitespace, Name.Function, Whitespace,
|
| 317 |
+
Operator.Word, Whitespace)),
|
| 318 |
+
# Comments
|
| 319 |
+
(r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
|
| 320 |
+
(r'\{-', Comment.Multiline, 'comment'),
|
| 321 |
+
# Holes
|
| 322 |
+
(r'\{!', Comment.Directive, 'hole'),
|
| 323 |
+
# Lexemes:
|
| 324 |
+
# Identifiers
|
| 325 |
+
(r'\b({})(?!\')\b'.format('|'.join(reserved)), Keyword.Reserved),
|
| 326 |
+
(r'(import|module)(\s+)', bygroups(Keyword.Reserved, Whitespace),
|
| 327 |
+
'module'),
|
| 328 |
+
(r'\b(Set|Prop)[\u2080-\u2089]*\b', Keyword.Type),
|
| 329 |
+
# Special Symbols
|
| 330 |
+
(r'(\(|\)|\{|\})', Operator),
|
| 331 |
+
(r'(\.{1,3}|\||\u03BB|\u2200|\u2192|:|=|->)', Operator.Word),
|
| 332 |
+
# Numbers
|
| 333 |
+
(r'\d+[eE][+-]?\d+', Number.Float),
|
| 334 |
+
(r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
|
| 335 |
+
(r'0[xX][\da-fA-F]+', Number.Hex),
|
| 336 |
+
(r'\d+', Number.Integer),
|
| 337 |
+
# Strings
|
| 338 |
+
(r"'", String.Char, 'character'),
|
| 339 |
+
(r'"', String, 'string'),
|
| 340 |
+
(r'[^\s(){}]+', Text),
|
| 341 |
+
(r'\s+?', Whitespace), # Whitespace
|
| 342 |
+
],
|
| 343 |
+
'hole': [
|
| 344 |
+
# Holes
|
| 345 |
+
(r'[^!{}]+', Comment.Directive),
|
| 346 |
+
(r'\{!', Comment.Directive, '#push'),
|
| 347 |
+
(r'!\}', Comment.Directive, '#pop'),
|
| 348 |
+
(r'[!{}]', Comment.Directive),
|
| 349 |
+
],
|
| 350 |
+
'module': [
|
| 351 |
+
(r'\{-', Comment.Multiline, 'comment'),
|
| 352 |
+
(r'[a-zA-Z][\w.\']*', Name, '#pop'),
|
| 353 |
+
(r'[\W0-9_]+', Text)
|
| 354 |
+
],
|
| 355 |
+
'comment': HaskellLexer.tokens['comment'],
|
| 356 |
+
'character': HaskellLexer.tokens['character'],
|
| 357 |
+
'string': HaskellLexer.tokens['string'],
|
| 358 |
+
'escape': HaskellLexer.tokens['escape']
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
class CryptolLexer(RegexLexer):
|
| 363 |
+
"""
|
| 364 |
+
FIXME: A Cryptol2 lexer based on the lexemes defined in the Haskell 98 Report.
|
| 365 |
+
"""
|
| 366 |
+
name = 'Cryptol'
|
| 367 |
+
aliases = ['cryptol', 'cry']
|
| 368 |
+
filenames = ['*.cry']
|
| 369 |
+
mimetypes = ['text/x-cryptol']
|
| 370 |
+
url = 'https://www.cryptol.net'
|
| 371 |
+
version_added = '2.0'
|
| 372 |
+
|
| 373 |
+
reserved = ('Arith', 'Bit', 'Cmp', 'False', 'Inf', 'True', 'else',
|
| 374 |
+
'export', 'extern', 'fin', 'if', 'import', 'inf', 'lg2',
|
| 375 |
+
'max', 'min', 'module', 'newtype', 'pragma', 'property',
|
| 376 |
+
'then', 'type', 'where', 'width')
|
| 377 |
+
ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
|
| 378 |
+
'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
|
| 379 |
+
'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN',
|
| 380 |
+
'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL')
|
| 381 |
+
|
| 382 |
+
tokens = {
|
| 383 |
+
'root': [
|
| 384 |
+
# Whitespace:
|
| 385 |
+
(r'\s+', Whitespace),
|
| 386 |
+
# (r'--\s*|.*$', Comment.Doc),
|
| 387 |
+
(r'//.*$', Comment.Single),
|
| 388 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 389 |
+
# Lexemes:
|
| 390 |
+
# Identifiers
|
| 391 |
+
(r'\bimport\b', Keyword.Reserved, 'import'),
|
| 392 |
+
(r'\bmodule\b', Keyword.Reserved, 'module'),
|
| 393 |
+
(r'\berror\b', Name.Exception),
|
| 394 |
+
(r'\b({})(?!\')\b'.format('|'.join(reserved)), Keyword.Reserved),
|
| 395 |
+
(r'^[_a-z][\w\']*', Name.Function),
|
| 396 |
+
(r"'?[_a-z][\w']*", Name),
|
| 397 |
+
(r"('')?[A-Z][\w\']*", Keyword.Type),
|
| 398 |
+
# Operators
|
| 399 |
+
(r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
|
| 400 |
+
(r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
|
| 401 |
+
(r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators
|
| 402 |
+
(r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators
|
| 403 |
+
# Numbers
|
| 404 |
+
(r'\d+[eE][+-]?\d+', Number.Float),
|
| 405 |
+
(r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
|
| 406 |
+
(r'0[oO][0-7]+', Number.Oct),
|
| 407 |
+
(r'0[xX][\da-fA-F]+', Number.Hex),
|
| 408 |
+
(r'\d+', Number.Integer),
|
| 409 |
+
# Character/String Literals
|
| 410 |
+
(r"'", String.Char, 'character'),
|
| 411 |
+
(r'"', String, 'string'),
|
| 412 |
+
# Special
|
| 413 |
+
(r'\[\]', Keyword.Type),
|
| 414 |
+
(r'\(\)', Name.Builtin),
|
| 415 |
+
(r'[][(),;`{}]', Punctuation),
|
| 416 |
+
],
|
| 417 |
+
'import': [
|
| 418 |
+
# Import statements
|
| 419 |
+
(r'\s+', Whitespace),
|
| 420 |
+
(r'"', String, 'string'),
|
| 421 |
+
# after "funclist" state
|
| 422 |
+
(r'\)', Punctuation, '#pop'),
|
| 423 |
+
(r'qualified\b', Keyword),
|
| 424 |
+
# import X as Y
|
| 425 |
+
(r'([A-Z][\w.]*)(\s+)(as)(\s+)([A-Z][\w.]*)',
|
| 426 |
+
bygroups(Name.Namespace, Whitespace, Keyword, Whitespace, Name), '#pop'),
|
| 427 |
+
# import X hiding (functions)
|
| 428 |
+
(r'([A-Z][\w.]*)(\s+)(hiding)(\s+)(\()',
|
| 429 |
+
bygroups(Name.Namespace, Whitespace, Keyword, Whitespace, Punctuation), 'funclist'),
|
| 430 |
+
# import X (functions)
|
| 431 |
+
(r'([A-Z][\w.]*)(\s+)(\()',
|
| 432 |
+
bygroups(Name.Namespace, Whitespace, Punctuation), 'funclist'),
|
| 433 |
+
# import X
|
| 434 |
+
(r'[\w.]+', Name.Namespace, '#pop'),
|
| 435 |
+
],
|
| 436 |
+
'module': [
|
| 437 |
+
(r'\s+', Whitespace),
|
| 438 |
+
(r'([A-Z][\w.]*)(\s+)(\()',
|
| 439 |
+
bygroups(Name.Namespace, Whitespace, Punctuation), 'funclist'),
|
| 440 |
+
(r'[A-Z][\w.]*', Name.Namespace, '#pop'),
|
| 441 |
+
],
|
| 442 |
+
'funclist': [
|
| 443 |
+
(r'\s+', Whitespace),
|
| 444 |
+
(r'[A-Z]\w*', Keyword.Type),
|
| 445 |
+
(r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
|
| 446 |
+
# TODO: these don't match the comments in docs, remove.
|
| 447 |
+
# (r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
|
| 448 |
+
# (r'{-', Comment.Multiline, 'comment'),
|
| 449 |
+
(r',', Punctuation),
|
| 450 |
+
(r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
|
| 451 |
+
# (HACK, but it makes sense to push two instances, believe me)
|
| 452 |
+
(r'\(', Punctuation, ('funclist', 'funclist')),
|
| 453 |
+
(r'\)', Punctuation, '#pop:2'),
|
| 454 |
+
],
|
| 455 |
+
'comment': [
|
| 456 |
+
# Multiline Comments
|
| 457 |
+
(r'[^/*]+', Comment.Multiline),
|
| 458 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 459 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 460 |
+
(r'[*/]', Comment.Multiline),
|
| 461 |
+
],
|
| 462 |
+
'character': [
|
| 463 |
+
# Allows multi-chars, incorrectly.
|
| 464 |
+
(r"[^\\']'", String.Char, '#pop'),
|
| 465 |
+
(r"\\", String.Escape, 'escape'),
|
| 466 |
+
("'", String.Char, '#pop'),
|
| 467 |
+
],
|
| 468 |
+
'string': [
|
| 469 |
+
(r'[^\\"]+', String),
|
| 470 |
+
(r"\\", String.Escape, 'escape'),
|
| 471 |
+
('"', String, '#pop'),
|
| 472 |
+
],
|
| 473 |
+
'escape': [
|
| 474 |
+
(r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
|
| 475 |
+
(r'\^[][A-Z@^_]', String.Escape, '#pop'),
|
| 476 |
+
('|'.join(ascii), String.Escape, '#pop'),
|
| 477 |
+
(r'o[0-7]+', String.Escape, '#pop'),
|
| 478 |
+
(r'x[\da-fA-F]+', String.Escape, '#pop'),
|
| 479 |
+
(r'\d+', String.Escape, '#pop'),
|
| 480 |
+
(r'(\s+)(\\)', bygroups(Whitespace, String.Escape), '#pop'),
|
| 481 |
+
],
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
EXTRA_KEYWORDS = {'join', 'split', 'reverse', 'transpose', 'width',
|
| 485 |
+
'length', 'tail', '<<', '>>', '<<<', '>>>', 'const',
|
| 486 |
+
'reg', 'par', 'seq', 'ASSERT', 'undefined', 'error',
|
| 487 |
+
'trace'}
|
| 488 |
+
|
| 489 |
+
def get_tokens_unprocessed(self, text):
|
| 490 |
+
stack = ['root']
|
| 491 |
+
for index, token, value in \
|
| 492 |
+
RegexLexer.get_tokens_unprocessed(self, text, stack):
|
| 493 |
+
if token is Name and value in self.EXTRA_KEYWORDS:
|
| 494 |
+
yield index, Name.Builtin, value
|
| 495 |
+
else:
|
| 496 |
+
yield index, token, value
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
class LiterateLexer(Lexer):
|
| 500 |
+
"""
|
| 501 |
+
Base class for lexers of literate file formats based on LaTeX or Bird-style
|
| 502 |
+
(prefixing each code line with ">").
|
| 503 |
+
|
| 504 |
+
Additional options accepted:
|
| 505 |
+
|
| 506 |
+
`litstyle`
|
| 507 |
+
If given, must be ``"bird"`` or ``"latex"``. If not given, the style
|
| 508 |
+
is autodetected: if the first non-whitespace character in the source
|
| 509 |
+
is a backslash or percent character, LaTeX is assumed, else Bird.
|
| 510 |
+
"""
|
| 511 |
+
|
| 512 |
+
bird_re = re.compile(r'(>[ \t]*)(.*\n)')
|
| 513 |
+
|
| 514 |
+
def __init__(self, baselexer, **options):
|
| 515 |
+
self.baselexer = baselexer
|
| 516 |
+
Lexer.__init__(self, **options)
|
| 517 |
+
|
| 518 |
+
def get_tokens_unprocessed(self, text):
|
| 519 |
+
style = self.options.get('litstyle')
|
| 520 |
+
if style is None:
|
| 521 |
+
style = (text.lstrip()[0:1] in '%\\') and 'latex' or 'bird'
|
| 522 |
+
|
| 523 |
+
code = ''
|
| 524 |
+
insertions = []
|
| 525 |
+
if style == 'bird':
|
| 526 |
+
# bird-style
|
| 527 |
+
for match in line_re.finditer(text):
|
| 528 |
+
line = match.group()
|
| 529 |
+
m = self.bird_re.match(line)
|
| 530 |
+
if m:
|
| 531 |
+
insertions.append((len(code),
|
| 532 |
+
[(0, Comment.Special, m.group(1))]))
|
| 533 |
+
code += m.group(2)
|
| 534 |
+
else:
|
| 535 |
+
insertions.append((len(code), [(0, Text, line)]))
|
| 536 |
+
else:
|
| 537 |
+
# latex-style
|
| 538 |
+
from pygments.lexers.markup import TexLexer
|
| 539 |
+
lxlexer = TexLexer(**self.options)
|
| 540 |
+
codelines = 0
|
| 541 |
+
latex = ''
|
| 542 |
+
for match in line_re.finditer(text):
|
| 543 |
+
line = match.group()
|
| 544 |
+
if codelines:
|
| 545 |
+
if line.lstrip().startswith('\\end{code}'):
|
| 546 |
+
codelines = 0
|
| 547 |
+
latex += line
|
| 548 |
+
else:
|
| 549 |
+
code += line
|
| 550 |
+
elif line.lstrip().startswith('\\begin{code}'):
|
| 551 |
+
codelines = 1
|
| 552 |
+
latex += line
|
| 553 |
+
insertions.append((len(code),
|
| 554 |
+
list(lxlexer.get_tokens_unprocessed(latex))))
|
| 555 |
+
latex = ''
|
| 556 |
+
else:
|
| 557 |
+
latex += line
|
| 558 |
+
insertions.append((len(code),
|
| 559 |
+
list(lxlexer.get_tokens_unprocessed(latex))))
|
| 560 |
+
yield from do_insertions(insertions, self.baselexer.get_tokens_unprocessed(code))
|
| 561 |
+
|
| 562 |
+
|
| 563 |
+
class LiterateHaskellLexer(LiterateLexer):
|
| 564 |
+
"""
|
| 565 |
+
For Literate Haskell (Bird-style or LaTeX) source.
|
| 566 |
+
|
| 567 |
+
Additional options accepted:
|
| 568 |
+
|
| 569 |
+
`litstyle`
|
| 570 |
+
If given, must be ``"bird"`` or ``"latex"``. If not given, the style
|
| 571 |
+
is autodetected: if the first non-whitespace character in the source
|
| 572 |
+
is a backslash or percent character, LaTeX is assumed, else Bird.
|
| 573 |
+
"""
|
| 574 |
+
name = 'Literate Haskell'
|
| 575 |
+
aliases = ['literate-haskell', 'lhaskell', 'lhs']
|
| 576 |
+
filenames = ['*.lhs']
|
| 577 |
+
mimetypes = ['text/x-literate-haskell']
|
| 578 |
+
url = 'https://wiki.haskell.org/Literate_programming'
|
| 579 |
+
version_added = '0.9'
|
| 580 |
+
|
| 581 |
+
def __init__(self, **options):
|
| 582 |
+
hslexer = HaskellLexer(**options)
|
| 583 |
+
LiterateLexer.__init__(self, hslexer, **options)
|
| 584 |
+
|
| 585 |
+
|
| 586 |
+
class LiterateIdrisLexer(LiterateLexer):
|
| 587 |
+
"""
|
| 588 |
+
For Literate Idris (Bird-style or LaTeX) source.
|
| 589 |
+
|
| 590 |
+
Additional options accepted:
|
| 591 |
+
|
| 592 |
+
`litstyle`
|
| 593 |
+
If given, must be ``"bird"`` or ``"latex"``. If not given, the style
|
| 594 |
+
is autodetected: if the first non-whitespace character in the source
|
| 595 |
+
is a backslash or percent character, LaTeX is assumed, else Bird.
|
| 596 |
+
"""
|
| 597 |
+
name = 'Literate Idris'
|
| 598 |
+
aliases = ['literate-idris', 'lidris', 'lidr']
|
| 599 |
+
filenames = ['*.lidr']
|
| 600 |
+
mimetypes = ['text/x-literate-idris']
|
| 601 |
+
url = 'https://idris2.readthedocs.io/en/latest/reference/literate.html'
|
| 602 |
+
version_added = '2.0'
|
| 603 |
+
|
| 604 |
+
def __init__(self, **options):
|
| 605 |
+
hslexer = IdrisLexer(**options)
|
| 606 |
+
LiterateLexer.__init__(self, hslexer, **options)
|
| 607 |
+
|
| 608 |
+
|
| 609 |
+
class LiterateAgdaLexer(LiterateLexer):
|
| 610 |
+
"""
|
| 611 |
+
For Literate Agda source.
|
| 612 |
+
|
| 613 |
+
Additional options accepted:
|
| 614 |
+
|
| 615 |
+
`litstyle`
|
| 616 |
+
If given, must be ``"bird"`` or ``"latex"``. If not given, the style
|
| 617 |
+
is autodetected: if the first non-whitespace character in the source
|
| 618 |
+
is a backslash or percent character, LaTeX is assumed, else Bird.
|
| 619 |
+
"""
|
| 620 |
+
name = 'Literate Agda'
|
| 621 |
+
aliases = ['literate-agda', 'lagda']
|
| 622 |
+
filenames = ['*.lagda']
|
| 623 |
+
mimetypes = ['text/x-literate-agda']
|
| 624 |
+
url = 'https://agda.readthedocs.io/en/latest/tools/literate-programming.html'
|
| 625 |
+
version_added = '2.0'
|
| 626 |
+
|
| 627 |
+
def __init__(self, **options):
|
| 628 |
+
agdalexer = AgdaLexer(**options)
|
| 629 |
+
LiterateLexer.__init__(self, agdalexer, litstyle='latex', **options)
|
| 630 |
+
|
| 631 |
+
|
| 632 |
+
class LiterateCryptolLexer(LiterateLexer):
|
| 633 |
+
"""
|
| 634 |
+
For Literate Cryptol (Bird-style or LaTeX) source.
|
| 635 |
+
|
| 636 |
+
Additional options accepted:
|
| 637 |
+
|
| 638 |
+
`litstyle`
|
| 639 |
+
If given, must be ``"bird"`` or ``"latex"``. If not given, the style
|
| 640 |
+
is autodetected: if the first non-whitespace character in the source
|
| 641 |
+
is a backslash or percent character, LaTeX is assumed, else Bird.
|
| 642 |
+
"""
|
| 643 |
+
name = 'Literate Cryptol'
|
| 644 |
+
aliases = ['literate-cryptol', 'lcryptol', 'lcry']
|
| 645 |
+
filenames = ['*.lcry']
|
| 646 |
+
mimetypes = ['text/x-literate-cryptol']
|
| 647 |
+
url = 'https://www.cryptol.net'
|
| 648 |
+
version_added = '2.0'
|
| 649 |
+
|
| 650 |
+
def __init__(self, **options):
|
| 651 |
+
crylexer = CryptolLexer(**options)
|
| 652 |
+
LiterateLexer.__init__(self, crylexer, **options)
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
class KokaLexer(RegexLexer):
|
| 656 |
+
"""
|
| 657 |
+
Lexer for the Koka language.
|
| 658 |
+
"""
|
| 659 |
+
|
| 660 |
+
name = 'Koka'
|
| 661 |
+
url = 'https://koka-lang.github.io/koka/doc/index.html'
|
| 662 |
+
aliases = ['koka']
|
| 663 |
+
filenames = ['*.kk', '*.kki']
|
| 664 |
+
mimetypes = ['text/x-koka']
|
| 665 |
+
version_added = '1.6'
|
| 666 |
+
|
| 667 |
+
keywords = [
|
| 668 |
+
'infix', 'infixr', 'infixl',
|
| 669 |
+
'type', 'cotype', 'rectype', 'alias',
|
| 670 |
+
'struct', 'con',
|
| 671 |
+
'fun', 'function', 'val', 'var',
|
| 672 |
+
'external',
|
| 673 |
+
'if', 'then', 'else', 'elif', 'return', 'match',
|
| 674 |
+
'private', 'public', 'private',
|
| 675 |
+
'module', 'import', 'as',
|
| 676 |
+
'include', 'inline',
|
| 677 |
+
'rec',
|
| 678 |
+
'try', 'yield', 'enum',
|
| 679 |
+
'interface', 'instance',
|
| 680 |
+
]
|
| 681 |
+
|
| 682 |
+
# keywords that are followed by a type
|
| 683 |
+
typeStartKeywords = [
|
| 684 |
+
'type', 'cotype', 'rectype', 'alias', 'struct', 'enum',
|
| 685 |
+
]
|
| 686 |
+
|
| 687 |
+
# keywords valid in a type
|
| 688 |
+
typekeywords = [
|
| 689 |
+
'forall', 'exists', 'some', 'with',
|
| 690 |
+
]
|
| 691 |
+
|
| 692 |
+
# builtin names and special names
|
| 693 |
+
builtin = [
|
| 694 |
+
'for', 'while', 'repeat',
|
| 695 |
+
'foreach', 'foreach-indexed',
|
| 696 |
+
'error', 'catch', 'finally',
|
| 697 |
+
'cs', 'js', 'file', 'ref', 'assigned',
|
| 698 |
+
]
|
| 699 |
+
|
| 700 |
+
# symbols that can be in an operator
|
| 701 |
+
symbols = r'[$%&*+@!/\\^~=.:\-?|<>]+'
|
| 702 |
+
|
| 703 |
+
# symbol boundary: an operator keyword should not be followed by any of these
|
| 704 |
+
sboundary = '(?!' + symbols + ')'
|
| 705 |
+
|
| 706 |
+
# name boundary: a keyword should not be followed by any of these
|
| 707 |
+
boundary = r'(?![\w/])'
|
| 708 |
+
|
| 709 |
+
# koka token abstractions
|
| 710 |
+
tokenType = Name.Attribute
|
| 711 |
+
tokenTypeDef = Name.Class
|
| 712 |
+
tokenConstructor = Generic.Emph
|
| 713 |
+
|
| 714 |
+
# main lexer
|
| 715 |
+
tokens = {
|
| 716 |
+
'root': [
|
| 717 |
+
include('whitespace'),
|
| 718 |
+
|
| 719 |
+
# go into type mode
|
| 720 |
+
(r'::?' + sboundary, tokenType, 'type'),
|
| 721 |
+
(r'(alias)(\s+)([a-z]\w*)?', bygroups(Keyword, Whitespace, tokenTypeDef),
|
| 722 |
+
'alias-type'),
|
| 723 |
+
(r'(struct)(\s+)([a-z]\w*)?', bygroups(Keyword, Whitespace, tokenTypeDef),
|
| 724 |
+
'struct-type'),
|
| 725 |
+
((r'({})'.format('|'.join(typeStartKeywords))) +
|
| 726 |
+
r'(\s+)([a-z]\w*)?', bygroups(Keyword, Whitespace, tokenTypeDef),
|
| 727 |
+
'type'),
|
| 728 |
+
|
| 729 |
+
# special sequences of tokens (we use ?: for non-capturing group as
|
| 730 |
+
# required by 'bygroups')
|
| 731 |
+
(r'(module)(\s+)(interface(?=\s))?(\s+)?((?:[a-z]\w*/)*[a-z]\w*)',
|
| 732 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Namespace)),
|
| 733 |
+
(r'(import)(\s+)((?:[a-z]\w*/)*[a-z]\w*)'
|
| 734 |
+
r'(?:(\s*)(=)(\s*)(qualified)?(\s*)'
|
| 735 |
+
r'((?:[a-z]\w*/)*[a-z]\w*))?',
|
| 736 |
+
bygroups(Keyword, Whitespace, Name.Namespace, Whitespace, Keyword, Whitespace,
|
| 737 |
+
Keyword, Whitespace, Name.Namespace)),
|
| 738 |
+
|
| 739 |
+
(r'^(public|private)?(\s+)?(function|fun|val)'
|
| 740 |
+
r'(\s+)([a-z]\w*|\((?:' + symbols + r'|/)\))',
|
| 741 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Function)),
|
| 742 |
+
(r'^(?:(public|private)(?=\s+external))?((?<!^)\s+)?(external)(\s+)(inline(?=\s))?(\s+)?'
|
| 743 |
+
r'([a-z]\w*|\((?:' + symbols + r'|/)\))',
|
| 744 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Name.Function)),
|
| 745 |
+
|
| 746 |
+
# keywords
|
| 747 |
+
(r'({})'.format('|'.join(typekeywords)) + boundary, Keyword.Type),
|
| 748 |
+
(r'({})'.format('|'.join(keywords)) + boundary, Keyword),
|
| 749 |
+
(r'({})'.format('|'.join(builtin)) + boundary, Keyword.Pseudo),
|
| 750 |
+
(r'::?|:=|\->|[=.]' + sboundary, Keyword),
|
| 751 |
+
|
| 752 |
+
# names
|
| 753 |
+
(r'((?:[a-z]\w*/)*)([A-Z]\w*)',
|
| 754 |
+
bygroups(Name.Namespace, tokenConstructor)),
|
| 755 |
+
(r'((?:[a-z]\w*/)*)([a-z]\w*)', bygroups(Name.Namespace, Name)),
|
| 756 |
+
(r'((?:[a-z]\w*/)*)(\((?:' + symbols + r'|/)\))',
|
| 757 |
+
bygroups(Name.Namespace, Name)),
|
| 758 |
+
(r'_\w*', Name.Variable),
|
| 759 |
+
|
| 760 |
+
# literal string
|
| 761 |
+
(r'@"', String.Double, 'litstring'),
|
| 762 |
+
|
| 763 |
+
# operators
|
| 764 |
+
(symbols + "|/(?![*/])", Operator),
|
| 765 |
+
(r'`', Operator),
|
| 766 |
+
(r'[{}()\[\];,]', Punctuation),
|
| 767 |
+
|
| 768 |
+
# literals. No check for literal characters with len > 1
|
| 769 |
+
(r'[0-9]+\.[0-9]+([eE][\-+]?[0-9]+)?', Number.Float),
|
| 770 |
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
| 771 |
+
(r'[0-9]+', Number.Integer),
|
| 772 |
+
|
| 773 |
+
(r"'", String.Char, 'char'),
|
| 774 |
+
(r'"', String.Double, 'string'),
|
| 775 |
+
],
|
| 776 |
+
|
| 777 |
+
# type started by alias
|
| 778 |
+
'alias-type': [
|
| 779 |
+
(r'=', Keyword),
|
| 780 |
+
include('type')
|
| 781 |
+
],
|
| 782 |
+
|
| 783 |
+
# type started by struct
|
| 784 |
+
'struct-type': [
|
| 785 |
+
(r'(?=\((?!,*\)))', Punctuation, '#pop'),
|
| 786 |
+
include('type')
|
| 787 |
+
],
|
| 788 |
+
|
| 789 |
+
# type started by colon
|
| 790 |
+
'type': [
|
| 791 |
+
(r'[(\[<]', tokenType, 'type-nested'),
|
| 792 |
+
include('type-content')
|
| 793 |
+
],
|
| 794 |
+
|
| 795 |
+
# type nested in brackets: can contain parameters, comma etc.
|
| 796 |
+
'type-nested': [
|
| 797 |
+
(r'[)\]>]', tokenType, '#pop'),
|
| 798 |
+
(r'[(\[<]', tokenType, 'type-nested'),
|
| 799 |
+
(r',', tokenType),
|
| 800 |
+
(r'([a-z]\w*)(\s*)(:)(?!:)',
|
| 801 |
+
bygroups(Name, Whitespace, tokenType)), # parameter name
|
| 802 |
+
include('type-content')
|
| 803 |
+
],
|
| 804 |
+
|
| 805 |
+
# shared contents of a type
|
| 806 |
+
'type-content': [
|
| 807 |
+
include('whitespace'),
|
| 808 |
+
|
| 809 |
+
# keywords
|
| 810 |
+
(r'({})'.format('|'.join(typekeywords)) + boundary, Keyword),
|
| 811 |
+
(r'(?=(({})'.format('|'.join(keywords)) + boundary + '))',
|
| 812 |
+
Keyword, '#pop'), # need to match because names overlap...
|
| 813 |
+
|
| 814 |
+
# kinds
|
| 815 |
+
(r'[EPHVX]' + boundary, tokenType),
|
| 816 |
+
|
| 817 |
+
# type names
|
| 818 |
+
(r'[a-z][0-9]*(?![\w/])', tokenType),
|
| 819 |
+
(r'_\w*', tokenType.Variable), # Generic.Emph
|
| 820 |
+
(r'((?:[a-z]\w*/)*)([A-Z]\w*)',
|
| 821 |
+
bygroups(Name.Namespace, tokenType)),
|
| 822 |
+
(r'((?:[a-z]\w*/)*)([a-z]\w+)',
|
| 823 |
+
bygroups(Name.Namespace, tokenType)),
|
| 824 |
+
|
| 825 |
+
# type keyword operators
|
| 826 |
+
(r'::|->|[.:|]', tokenType),
|
| 827 |
+
|
| 828 |
+
# catchall
|
| 829 |
+
default('#pop')
|
| 830 |
+
],
|
| 831 |
+
|
| 832 |
+
# comments and literals
|
| 833 |
+
'whitespace': [
|
| 834 |
+
(r'(\n\s*)(#.*)$', bygroups(Whitespace, Comment.Preproc)),
|
| 835 |
+
(r'\s+', Whitespace),
|
| 836 |
+
(r'/\*', Comment.Multiline, 'comment'),
|
| 837 |
+
(r'//.*$', Comment.Single)
|
| 838 |
+
],
|
| 839 |
+
'comment': [
|
| 840 |
+
(r'[^/*]+', Comment.Multiline),
|
| 841 |
+
(r'/\*', Comment.Multiline, '#push'),
|
| 842 |
+
(r'\*/', Comment.Multiline, '#pop'),
|
| 843 |
+
(r'[*/]', Comment.Multiline),
|
| 844 |
+
],
|
| 845 |
+
'litstring': [
|
| 846 |
+
(r'[^"]+', String.Double),
|
| 847 |
+
(r'""', String.Escape),
|
| 848 |
+
(r'"', String.Double, '#pop'),
|
| 849 |
+
],
|
| 850 |
+
'string': [
|
| 851 |
+
(r'[^\\"\n]+', String.Double),
|
| 852 |
+
include('escape-sequence'),
|
| 853 |
+
(r'["\n]', String.Double, '#pop'),
|
| 854 |
+
],
|
| 855 |
+
'char': [
|
| 856 |
+
(r'[^\\\'\n]+', String.Char),
|
| 857 |
+
include('escape-sequence'),
|
| 858 |
+
(r'[\'\n]', String.Char, '#pop'),
|
| 859 |
+
],
|
| 860 |
+
'escape-sequence': [
|
| 861 |
+
(r'\\[nrt\\"\']', String.Escape),
|
| 862 |
+
(r'\\x[0-9a-fA-F]{2}', String.Escape),
|
| 863 |
+
(r'\\u[0-9a-fA-F]{4}', String.Escape),
|
| 864 |
+
# Yes, \U literals are 6 hex digits.
|
| 865 |
+
(r'\\U[0-9a-fA-F]{6}', String.Escape)
|
| 866 |
+
]
|
| 867 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/haxe.py
ADDED
|
@@ -0,0 +1,941 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.haxe
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Haxe and related stuff.
|
| 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 ExtendedRegexLexer, RegexLexer, include, bygroups, \
|
| 14 |
+
default
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Generic, Whitespace
|
| 17 |
+
|
| 18 |
+
__all__ = ['HaxeLexer', 'HxmlLexer']
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class HaxeLexer(ExtendedRegexLexer):
|
| 22 |
+
"""
|
| 23 |
+
For Haxe source code.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
name = 'Haxe'
|
| 27 |
+
url = 'http://haxe.org/'
|
| 28 |
+
aliases = ['haxe', 'hxsl', 'hx']
|
| 29 |
+
filenames = ['*.hx', '*.hxsl']
|
| 30 |
+
mimetypes = ['text/haxe', 'text/x-haxe', 'text/x-hx']
|
| 31 |
+
version_added = '1.3'
|
| 32 |
+
|
| 33 |
+
# keywords extracted from lexer.mll in the haxe compiler source
|
| 34 |
+
keyword = (r'(?:function|class|static|var|if|else|while|do|for|'
|
| 35 |
+
r'break|return|continue|extends|implements|import|'
|
| 36 |
+
r'switch|case|default|public|private|try|untyped|'
|
| 37 |
+
r'catch|new|this|throw|extern|enum|in|interface|'
|
| 38 |
+
r'cast|override|dynamic|typedef|package|'
|
| 39 |
+
r'inline|using|null|true|false|abstract)\b')
|
| 40 |
+
|
| 41 |
+
# idtype in lexer.mll
|
| 42 |
+
typeid = r'_*[A-Z]\w*'
|
| 43 |
+
|
| 44 |
+
# combined ident and dollar and idtype
|
| 45 |
+
ident = r'(?:_*[a-z]\w*|_+[0-9]\w*|' + typeid + r'|_+|\$\w+)'
|
| 46 |
+
|
| 47 |
+
binop = (r'(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>\s*>\s*=|>\s*>\s*>\s*=|==|'
|
| 48 |
+
r'!=|<=|>\s*=|&&|\|\||<<|>>>|>\s*>|\.\.\.|<|>|%|&|\||\^|\+|\*|'
|
| 49 |
+
r'/|\-|=>|=)')
|
| 50 |
+
|
| 51 |
+
# ident except keywords
|
| 52 |
+
ident_no_keyword = r'(?!' + keyword + ')' + ident
|
| 53 |
+
|
| 54 |
+
flags = re.DOTALL | re.MULTILINE
|
| 55 |
+
|
| 56 |
+
preproc_stack = []
|
| 57 |
+
|
| 58 |
+
def preproc_callback(self, match, ctx):
|
| 59 |
+
proc = match.group(2)
|
| 60 |
+
|
| 61 |
+
if proc == 'if':
|
| 62 |
+
# store the current stack
|
| 63 |
+
self.preproc_stack.append(ctx.stack[:])
|
| 64 |
+
elif proc in ['else', 'elseif']:
|
| 65 |
+
# restore the stack back to right before #if
|
| 66 |
+
if self.preproc_stack:
|
| 67 |
+
ctx.stack = self.preproc_stack[-1][:]
|
| 68 |
+
elif proc == 'end':
|
| 69 |
+
# remove the saved stack of previous #if
|
| 70 |
+
if self.preproc_stack:
|
| 71 |
+
self.preproc_stack.pop()
|
| 72 |
+
|
| 73 |
+
# #if and #elseif should follow by an expr
|
| 74 |
+
if proc in ['if', 'elseif']:
|
| 75 |
+
ctx.stack.append('preproc-expr')
|
| 76 |
+
|
| 77 |
+
# #error can be optionally follow by the error msg
|
| 78 |
+
if proc in ['error']:
|
| 79 |
+
ctx.stack.append('preproc-error')
|
| 80 |
+
|
| 81 |
+
yield match.start(), Comment.Preproc, '#' + proc
|
| 82 |
+
ctx.pos = match.end()
|
| 83 |
+
|
| 84 |
+
tokens = {
|
| 85 |
+
'root': [
|
| 86 |
+
include('spaces'),
|
| 87 |
+
include('meta'),
|
| 88 |
+
(r'(?:package)\b', Keyword.Namespace, ('semicolon', 'package')),
|
| 89 |
+
(r'(?:import)\b', Keyword.Namespace, ('semicolon', 'import')),
|
| 90 |
+
(r'(?:using)\b', Keyword.Namespace, ('semicolon', 'using')),
|
| 91 |
+
(r'(?:extern|private)\b', Keyword.Declaration),
|
| 92 |
+
(r'(?:abstract)\b', Keyword.Declaration, 'abstract'),
|
| 93 |
+
(r'(?:class|interface)\b', Keyword.Declaration, 'class'),
|
| 94 |
+
(r'(?:enum)\b', Keyword.Declaration, 'enum'),
|
| 95 |
+
(r'(?:typedef)\b', Keyword.Declaration, 'typedef'),
|
| 96 |
+
|
| 97 |
+
# top-level expression
|
| 98 |
+
# although it is not supported in haxe, but it is common to write
|
| 99 |
+
# expression in web pages the positive lookahead here is to prevent
|
| 100 |
+
# an infinite loop at the EOF
|
| 101 |
+
(r'(?=.)', Text, 'expr-statement'),
|
| 102 |
+
],
|
| 103 |
+
|
| 104 |
+
# space/tab/comment/preproc
|
| 105 |
+
'spaces': [
|
| 106 |
+
(r'\s+', Whitespace),
|
| 107 |
+
(r'//[^\n\r]*', Comment.Single),
|
| 108 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 109 |
+
(r'(#)(if|elseif|else|end|error)\b', preproc_callback),
|
| 110 |
+
],
|
| 111 |
+
|
| 112 |
+
'string-single-interpol': [
|
| 113 |
+
(r'\$\{', String.Interpol, ('string-interpol-close', 'expr')),
|
| 114 |
+
(r'\$\$', String.Escape),
|
| 115 |
+
(r'\$(?=' + ident + ')', String.Interpol, 'ident'),
|
| 116 |
+
include('string-single'),
|
| 117 |
+
],
|
| 118 |
+
|
| 119 |
+
'string-single': [
|
| 120 |
+
(r"'", String.Single, '#pop'),
|
| 121 |
+
(r'\\.', String.Escape),
|
| 122 |
+
(r'.', String.Single),
|
| 123 |
+
],
|
| 124 |
+
|
| 125 |
+
'string-double': [
|
| 126 |
+
(r'"', String.Double, '#pop'),
|
| 127 |
+
(r'\\.', String.Escape),
|
| 128 |
+
(r'.', String.Double),
|
| 129 |
+
],
|
| 130 |
+
|
| 131 |
+
'string-interpol-close': [
|
| 132 |
+
(r'\$'+ident, String.Interpol),
|
| 133 |
+
(r'\}', String.Interpol, '#pop'),
|
| 134 |
+
],
|
| 135 |
+
|
| 136 |
+
'package': [
|
| 137 |
+
include('spaces'),
|
| 138 |
+
(ident, Name.Namespace),
|
| 139 |
+
(r'\.', Punctuation, 'import-ident'),
|
| 140 |
+
default('#pop'),
|
| 141 |
+
],
|
| 142 |
+
|
| 143 |
+
'import': [
|
| 144 |
+
include('spaces'),
|
| 145 |
+
(ident, Name.Namespace),
|
| 146 |
+
(r'\*', Keyword), # wildcard import
|
| 147 |
+
(r'\.', Punctuation, 'import-ident'),
|
| 148 |
+
(r'in', Keyword.Namespace, 'ident'),
|
| 149 |
+
default('#pop'),
|
| 150 |
+
],
|
| 151 |
+
|
| 152 |
+
'import-ident': [
|
| 153 |
+
include('spaces'),
|
| 154 |
+
(r'\*', Keyword, '#pop'), # wildcard import
|
| 155 |
+
(ident, Name.Namespace, '#pop'),
|
| 156 |
+
],
|
| 157 |
+
|
| 158 |
+
'using': [
|
| 159 |
+
include('spaces'),
|
| 160 |
+
(ident, Name.Namespace),
|
| 161 |
+
(r'\.', Punctuation, 'import-ident'),
|
| 162 |
+
default('#pop'),
|
| 163 |
+
],
|
| 164 |
+
|
| 165 |
+
'preproc-error': [
|
| 166 |
+
(r'\s+', Whitespace),
|
| 167 |
+
(r"'", String.Single, ('#pop', 'string-single')),
|
| 168 |
+
(r'"', String.Double, ('#pop', 'string-double')),
|
| 169 |
+
default('#pop'),
|
| 170 |
+
],
|
| 171 |
+
|
| 172 |
+
'preproc-expr': [
|
| 173 |
+
(r'\s+', Whitespace),
|
| 174 |
+
(r'\!', Comment.Preproc),
|
| 175 |
+
(r'\(', Comment.Preproc, ('#pop', 'preproc-parenthesis')),
|
| 176 |
+
|
| 177 |
+
(ident, Comment.Preproc, '#pop'),
|
| 178 |
+
|
| 179 |
+
# Float
|
| 180 |
+
(r'\.[0-9]+', Number.Float),
|
| 181 |
+
(r'[0-9]+[eE][+\-]?[0-9]+', Number.Float),
|
| 182 |
+
(r'[0-9]+\.[0-9]*[eE][+\-]?[0-9]+', Number.Float),
|
| 183 |
+
(r'[0-9]+\.[0-9]+', Number.Float),
|
| 184 |
+
(r'[0-9]+\.(?!' + ident + r'|\.\.)', Number.Float),
|
| 185 |
+
|
| 186 |
+
# Int
|
| 187 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 188 |
+
(r'[0-9]+', Number.Integer),
|
| 189 |
+
|
| 190 |
+
# String
|
| 191 |
+
(r"'", String.Single, ('#pop', 'string-single')),
|
| 192 |
+
(r'"', String.Double, ('#pop', 'string-double')),
|
| 193 |
+
],
|
| 194 |
+
|
| 195 |
+
'preproc-parenthesis': [
|
| 196 |
+
(r'\s+', Whitespace),
|
| 197 |
+
(r'\)', Comment.Preproc, '#pop'),
|
| 198 |
+
default('preproc-expr-in-parenthesis'),
|
| 199 |
+
],
|
| 200 |
+
|
| 201 |
+
'preproc-expr-chain': [
|
| 202 |
+
(r'\s+', Whitespace),
|
| 203 |
+
(binop, Comment.Preproc, ('#pop', 'preproc-expr-in-parenthesis')),
|
| 204 |
+
default('#pop'),
|
| 205 |
+
],
|
| 206 |
+
|
| 207 |
+
# same as 'preproc-expr' but able to chain 'preproc-expr-chain'
|
| 208 |
+
'preproc-expr-in-parenthesis': [
|
| 209 |
+
(r'\s+', Whitespace),
|
| 210 |
+
(r'\!', Comment.Preproc),
|
| 211 |
+
(r'\(', Comment.Preproc,
|
| 212 |
+
('#pop', 'preproc-expr-chain', 'preproc-parenthesis')),
|
| 213 |
+
|
| 214 |
+
(ident, Comment.Preproc, ('#pop', 'preproc-expr-chain')),
|
| 215 |
+
|
| 216 |
+
# Float
|
| 217 |
+
(r'\.[0-9]+', Number.Float, ('#pop', 'preproc-expr-chain')),
|
| 218 |
+
(r'[0-9]+[eE][+\-]?[0-9]+', Number.Float, ('#pop', 'preproc-expr-chain')),
|
| 219 |
+
(r'[0-9]+\.[0-9]*[eE][+\-]?[0-9]+', Number.Float, ('#pop', 'preproc-expr-chain')),
|
| 220 |
+
(r'[0-9]+\.[0-9]+', Number.Float, ('#pop', 'preproc-expr-chain')),
|
| 221 |
+
(r'[0-9]+\.(?!' + ident + r'|\.\.)', Number.Float, ('#pop', 'preproc-expr-chain')),
|
| 222 |
+
|
| 223 |
+
# Int
|
| 224 |
+
(r'0x[0-9a-fA-F]+', Number.Hex, ('#pop', 'preproc-expr-chain')),
|
| 225 |
+
(r'[0-9]+', Number.Integer, ('#pop', 'preproc-expr-chain')),
|
| 226 |
+
|
| 227 |
+
# String
|
| 228 |
+
(r"'", String.Single,
|
| 229 |
+
('#pop', 'preproc-expr-chain', 'string-single')),
|
| 230 |
+
(r'"', String.Double,
|
| 231 |
+
('#pop', 'preproc-expr-chain', 'string-double')),
|
| 232 |
+
],
|
| 233 |
+
|
| 234 |
+
'abstract': [
|
| 235 |
+
include('spaces'),
|
| 236 |
+
default(('#pop', 'abstract-body', 'abstract-relation',
|
| 237 |
+
'abstract-opaque', 'type-param-constraint', 'type-name')),
|
| 238 |
+
],
|
| 239 |
+
|
| 240 |
+
'abstract-body': [
|
| 241 |
+
include('spaces'),
|
| 242 |
+
(r'\{', Punctuation, ('#pop', 'class-body')),
|
| 243 |
+
],
|
| 244 |
+
|
| 245 |
+
'abstract-opaque': [
|
| 246 |
+
include('spaces'),
|
| 247 |
+
(r'\(', Punctuation, ('#pop', 'parenthesis-close', 'type')),
|
| 248 |
+
default('#pop'),
|
| 249 |
+
],
|
| 250 |
+
|
| 251 |
+
'abstract-relation': [
|
| 252 |
+
include('spaces'),
|
| 253 |
+
(r'(?:to|from)', Keyword.Declaration, 'type'),
|
| 254 |
+
(r',', Punctuation),
|
| 255 |
+
default('#pop'),
|
| 256 |
+
],
|
| 257 |
+
|
| 258 |
+
'meta': [
|
| 259 |
+
include('spaces'),
|
| 260 |
+
(r'@', Name.Decorator, ('meta-body', 'meta-ident', 'meta-colon')),
|
| 261 |
+
],
|
| 262 |
+
|
| 263 |
+
# optional colon
|
| 264 |
+
'meta-colon': [
|
| 265 |
+
include('spaces'),
|
| 266 |
+
(r':', Name.Decorator, '#pop'),
|
| 267 |
+
default('#pop'),
|
| 268 |
+
],
|
| 269 |
+
|
| 270 |
+
# same as 'ident' but set token as Name.Decorator instead of Name
|
| 271 |
+
'meta-ident': [
|
| 272 |
+
include('spaces'),
|
| 273 |
+
(ident, Name.Decorator, '#pop'),
|
| 274 |
+
],
|
| 275 |
+
|
| 276 |
+
'meta-body': [
|
| 277 |
+
include('spaces'),
|
| 278 |
+
(r'\(', Name.Decorator, ('#pop', 'meta-call')),
|
| 279 |
+
default('#pop'),
|
| 280 |
+
],
|
| 281 |
+
|
| 282 |
+
'meta-call': [
|
| 283 |
+
include('spaces'),
|
| 284 |
+
(r'\)', Name.Decorator, '#pop'),
|
| 285 |
+
default(('#pop', 'meta-call-sep', 'expr')),
|
| 286 |
+
],
|
| 287 |
+
|
| 288 |
+
'meta-call-sep': [
|
| 289 |
+
include('spaces'),
|
| 290 |
+
(r'\)', Name.Decorator, '#pop'),
|
| 291 |
+
(r',', Punctuation, ('#pop', 'meta-call')),
|
| 292 |
+
],
|
| 293 |
+
|
| 294 |
+
'typedef': [
|
| 295 |
+
include('spaces'),
|
| 296 |
+
default(('#pop', 'typedef-body', 'type-param-constraint',
|
| 297 |
+
'type-name')),
|
| 298 |
+
],
|
| 299 |
+
|
| 300 |
+
'typedef-body': [
|
| 301 |
+
include('spaces'),
|
| 302 |
+
(r'=', Operator, ('#pop', 'optional-semicolon', 'type')),
|
| 303 |
+
],
|
| 304 |
+
|
| 305 |
+
'enum': [
|
| 306 |
+
include('spaces'),
|
| 307 |
+
default(('#pop', 'enum-body', 'bracket-open',
|
| 308 |
+
'type-param-constraint', 'type-name')),
|
| 309 |
+
],
|
| 310 |
+
|
| 311 |
+
'enum-body': [
|
| 312 |
+
include('spaces'),
|
| 313 |
+
include('meta'),
|
| 314 |
+
(r'\}', Punctuation, '#pop'),
|
| 315 |
+
(ident_no_keyword, Name, ('enum-member', 'type-param-constraint')),
|
| 316 |
+
],
|
| 317 |
+
|
| 318 |
+
'enum-member': [
|
| 319 |
+
include('spaces'),
|
| 320 |
+
(r'\(', Punctuation,
|
| 321 |
+
('#pop', 'semicolon', 'flag', 'function-param')),
|
| 322 |
+
default(('#pop', 'semicolon', 'flag')),
|
| 323 |
+
],
|
| 324 |
+
|
| 325 |
+
'class': [
|
| 326 |
+
include('spaces'),
|
| 327 |
+
default(('#pop', 'class-body', 'bracket-open', 'extends',
|
| 328 |
+
'type-param-constraint', 'type-name')),
|
| 329 |
+
],
|
| 330 |
+
|
| 331 |
+
'extends': [
|
| 332 |
+
include('spaces'),
|
| 333 |
+
(r'(?:extends|implements)\b', Keyword.Declaration, 'type'),
|
| 334 |
+
(r',', Punctuation), # the comma is made optional here, since haxe2
|
| 335 |
+
# requires the comma but haxe3 does not allow it
|
| 336 |
+
default('#pop'),
|
| 337 |
+
],
|
| 338 |
+
|
| 339 |
+
'bracket-open': [
|
| 340 |
+
include('spaces'),
|
| 341 |
+
(r'\{', Punctuation, '#pop'),
|
| 342 |
+
],
|
| 343 |
+
|
| 344 |
+
'bracket-close': [
|
| 345 |
+
include('spaces'),
|
| 346 |
+
(r'\}', Punctuation, '#pop'),
|
| 347 |
+
],
|
| 348 |
+
|
| 349 |
+
'class-body': [
|
| 350 |
+
include('spaces'),
|
| 351 |
+
include('meta'),
|
| 352 |
+
(r'\}', Punctuation, '#pop'),
|
| 353 |
+
(r'(?:static|public|private|override|dynamic|inline|macro)\b',
|
| 354 |
+
Keyword.Declaration),
|
| 355 |
+
default('class-member'),
|
| 356 |
+
],
|
| 357 |
+
|
| 358 |
+
'class-member': [
|
| 359 |
+
include('spaces'),
|
| 360 |
+
(r'(var)\b', Keyword.Declaration,
|
| 361 |
+
('#pop', 'optional-semicolon', 'var')),
|
| 362 |
+
(r'(function)\b', Keyword.Declaration,
|
| 363 |
+
('#pop', 'optional-semicolon', 'class-method')),
|
| 364 |
+
],
|
| 365 |
+
|
| 366 |
+
# local function, anonymous or not
|
| 367 |
+
'function-local': [
|
| 368 |
+
include('spaces'),
|
| 369 |
+
(ident_no_keyword, Name.Function,
|
| 370 |
+
('#pop', 'optional-expr', 'flag', 'function-param',
|
| 371 |
+
'parenthesis-open', 'type-param-constraint')),
|
| 372 |
+
default(('#pop', 'optional-expr', 'flag', 'function-param',
|
| 373 |
+
'parenthesis-open', 'type-param-constraint')),
|
| 374 |
+
],
|
| 375 |
+
|
| 376 |
+
'optional-expr': [
|
| 377 |
+
include('spaces'),
|
| 378 |
+
include('expr'),
|
| 379 |
+
default('#pop'),
|
| 380 |
+
],
|
| 381 |
+
|
| 382 |
+
'class-method': [
|
| 383 |
+
include('spaces'),
|
| 384 |
+
(ident, Name.Function, ('#pop', 'optional-expr', 'flag',
|
| 385 |
+
'function-param', 'parenthesis-open',
|
| 386 |
+
'type-param-constraint')),
|
| 387 |
+
],
|
| 388 |
+
|
| 389 |
+
# function arguments
|
| 390 |
+
'function-param': [
|
| 391 |
+
include('spaces'),
|
| 392 |
+
(r'\)', Punctuation, '#pop'),
|
| 393 |
+
(r'\?', Punctuation),
|
| 394 |
+
(ident_no_keyword, Name,
|
| 395 |
+
('#pop', 'function-param-sep', 'assign', 'flag')),
|
| 396 |
+
],
|
| 397 |
+
|
| 398 |
+
'function-param-sep': [
|
| 399 |
+
include('spaces'),
|
| 400 |
+
(r'\)', Punctuation, '#pop'),
|
| 401 |
+
(r',', Punctuation, ('#pop', 'function-param')),
|
| 402 |
+
],
|
| 403 |
+
|
| 404 |
+
'prop-get-set': [
|
| 405 |
+
include('spaces'),
|
| 406 |
+
(r'\(', Punctuation, ('#pop', 'parenthesis-close',
|
| 407 |
+
'prop-get-set-opt', 'comma', 'prop-get-set-opt')),
|
| 408 |
+
default('#pop'),
|
| 409 |
+
],
|
| 410 |
+
|
| 411 |
+
'prop-get-set-opt': [
|
| 412 |
+
include('spaces'),
|
| 413 |
+
(r'(?:default|null|never|dynamic|get|set)\b', Keyword, '#pop'),
|
| 414 |
+
(ident_no_keyword, Text, '#pop'), # custom getter/setter
|
| 415 |
+
],
|
| 416 |
+
|
| 417 |
+
'expr-statement': [
|
| 418 |
+
include('spaces'),
|
| 419 |
+
# makes semicolon optional here, just to avoid checking the last
|
| 420 |
+
# one is bracket or not.
|
| 421 |
+
default(('#pop', 'optional-semicolon', 'expr')),
|
| 422 |
+
],
|
| 423 |
+
|
| 424 |
+
'expr': [
|
| 425 |
+
include('spaces'),
|
| 426 |
+
(r'@', Name.Decorator, ('#pop', 'optional-expr', 'meta-body',
|
| 427 |
+
'meta-ident', 'meta-colon')),
|
| 428 |
+
(r'(?:\+\+|\-\-|~(?!/)|!|\-)', Operator),
|
| 429 |
+
(r'\(', Punctuation, ('#pop', 'expr-chain', 'parenthesis')),
|
| 430 |
+
(r'(?:static|public|private|override|dynamic|inline)\b',
|
| 431 |
+
Keyword.Declaration),
|
| 432 |
+
(r'(?:function)\b', Keyword.Declaration, ('#pop', 'expr-chain',
|
| 433 |
+
'function-local')),
|
| 434 |
+
(r'\{', Punctuation, ('#pop', 'expr-chain', 'bracket')),
|
| 435 |
+
(r'(?:true|false|null)\b', Keyword.Constant, ('#pop', 'expr-chain')),
|
| 436 |
+
(r'(?:this)\b', Keyword, ('#pop', 'expr-chain')),
|
| 437 |
+
(r'(?:cast)\b', Keyword, ('#pop', 'expr-chain', 'cast')),
|
| 438 |
+
(r'(?:try)\b', Keyword, ('#pop', 'catch', 'expr')),
|
| 439 |
+
(r'(?:var)\b', Keyword.Declaration, ('#pop', 'var')),
|
| 440 |
+
(r'(?:new)\b', Keyword, ('#pop', 'expr-chain', 'new')),
|
| 441 |
+
(r'(?:switch)\b', Keyword, ('#pop', 'switch')),
|
| 442 |
+
(r'(?:if)\b', Keyword, ('#pop', 'if')),
|
| 443 |
+
(r'(?:do)\b', Keyword, ('#pop', 'do')),
|
| 444 |
+
(r'(?:while)\b', Keyword, ('#pop', 'while')),
|
| 445 |
+
(r'(?:for)\b', Keyword, ('#pop', 'for')),
|
| 446 |
+
(r'(?:untyped|throw)\b', Keyword),
|
| 447 |
+
(r'(?:return)\b', Keyword, ('#pop', 'optional-expr')),
|
| 448 |
+
(r'(?:macro)\b', Keyword, ('#pop', 'macro')),
|
| 449 |
+
(r'(?:continue|break)\b', Keyword, '#pop'),
|
| 450 |
+
(r'(?:\$\s*[a-z]\b|\$(?!'+ident+'))', Name, ('#pop', 'dollar')),
|
| 451 |
+
(ident_no_keyword, Name, ('#pop', 'expr-chain')),
|
| 452 |
+
|
| 453 |
+
# Float
|
| 454 |
+
(r'\.[0-9]+', Number.Float, ('#pop', 'expr-chain')),
|
| 455 |
+
(r'[0-9]+[eE][+\-]?[0-9]+', Number.Float, ('#pop', 'expr-chain')),
|
| 456 |
+
(r'[0-9]+\.[0-9]*[eE][+\-]?[0-9]+', Number.Float, ('#pop', 'expr-chain')),
|
| 457 |
+
(r'[0-9]+\.[0-9]+', Number.Float, ('#pop', 'expr-chain')),
|
| 458 |
+
(r'[0-9]+\.(?!' + ident + r'|\.\.)', Number.Float, ('#pop', 'expr-chain')),
|
| 459 |
+
|
| 460 |
+
# Int
|
| 461 |
+
(r'0x[0-9a-fA-F]+', Number.Hex, ('#pop', 'expr-chain')),
|
| 462 |
+
(r'[0-9]+', Number.Integer, ('#pop', 'expr-chain')),
|
| 463 |
+
|
| 464 |
+
# String
|
| 465 |
+
(r"'", String.Single, ('#pop', 'expr-chain', 'string-single-interpol')),
|
| 466 |
+
(r'"', String.Double, ('#pop', 'expr-chain', 'string-double')),
|
| 467 |
+
|
| 468 |
+
# EReg
|
| 469 |
+
(r'~/(\\\\|\\[^\\]|[^/\\\n])*/[gimsu]*', String.Regex, ('#pop', 'expr-chain')),
|
| 470 |
+
|
| 471 |
+
# Array
|
| 472 |
+
(r'\[', Punctuation, ('#pop', 'expr-chain', 'array-decl')),
|
| 473 |
+
],
|
| 474 |
+
|
| 475 |
+
'expr-chain': [
|
| 476 |
+
include('spaces'),
|
| 477 |
+
(r'(?:\+\+|\-\-)', Operator),
|
| 478 |
+
(binop, Operator, ('#pop', 'expr')),
|
| 479 |
+
(r'(?:in)\b', Keyword, ('#pop', 'expr')),
|
| 480 |
+
(r'\?', Operator, ('#pop', 'expr', 'ternary', 'expr')),
|
| 481 |
+
(r'(\.)(' + ident_no_keyword + ')', bygroups(Punctuation, Name)),
|
| 482 |
+
(r'\[', Punctuation, 'array-access'),
|
| 483 |
+
(r'\(', Punctuation, 'call'),
|
| 484 |
+
default('#pop'),
|
| 485 |
+
],
|
| 486 |
+
|
| 487 |
+
# macro reification
|
| 488 |
+
'macro': [
|
| 489 |
+
include('spaces'),
|
| 490 |
+
include('meta'),
|
| 491 |
+
(r':', Punctuation, ('#pop', 'type')),
|
| 492 |
+
|
| 493 |
+
(r'(?:extern|private)\b', Keyword.Declaration),
|
| 494 |
+
(r'(?:abstract)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'abstract')),
|
| 495 |
+
(r'(?:class|interface)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'macro-class')),
|
| 496 |
+
(r'(?:enum)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'enum')),
|
| 497 |
+
(r'(?:typedef)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'typedef')),
|
| 498 |
+
|
| 499 |
+
default(('#pop', 'expr')),
|
| 500 |
+
],
|
| 501 |
+
|
| 502 |
+
'macro-class': [
|
| 503 |
+
(r'\{', Punctuation, ('#pop', 'class-body')),
|
| 504 |
+
include('class')
|
| 505 |
+
],
|
| 506 |
+
|
| 507 |
+
# cast can be written as "cast expr" or "cast(expr, type)"
|
| 508 |
+
'cast': [
|
| 509 |
+
include('spaces'),
|
| 510 |
+
(r'\(', Punctuation, ('#pop', 'parenthesis-close',
|
| 511 |
+
'cast-type', 'expr')),
|
| 512 |
+
default(('#pop', 'expr')),
|
| 513 |
+
],
|
| 514 |
+
|
| 515 |
+
# optionally give a type as the 2nd argument of cast()
|
| 516 |
+
'cast-type': [
|
| 517 |
+
include('spaces'),
|
| 518 |
+
(r',', Punctuation, ('#pop', 'type')),
|
| 519 |
+
default('#pop'),
|
| 520 |
+
],
|
| 521 |
+
|
| 522 |
+
'catch': [
|
| 523 |
+
include('spaces'),
|
| 524 |
+
(r'(?:catch)\b', Keyword, ('expr', 'function-param',
|
| 525 |
+
'parenthesis-open')),
|
| 526 |
+
default('#pop'),
|
| 527 |
+
],
|
| 528 |
+
|
| 529 |
+
# do-while loop
|
| 530 |
+
'do': [
|
| 531 |
+
include('spaces'),
|
| 532 |
+
default(('#pop', 'do-while', 'expr')),
|
| 533 |
+
],
|
| 534 |
+
|
| 535 |
+
# the while after do
|
| 536 |
+
'do-while': [
|
| 537 |
+
include('spaces'),
|
| 538 |
+
(r'(?:while)\b', Keyword, ('#pop', 'parenthesis',
|
| 539 |
+
'parenthesis-open')),
|
| 540 |
+
],
|
| 541 |
+
|
| 542 |
+
'while': [
|
| 543 |
+
include('spaces'),
|
| 544 |
+
(r'\(', Punctuation, ('#pop', 'expr', 'parenthesis')),
|
| 545 |
+
],
|
| 546 |
+
|
| 547 |
+
'for': [
|
| 548 |
+
include('spaces'),
|
| 549 |
+
(r'\(', Punctuation, ('#pop', 'expr', 'parenthesis')),
|
| 550 |
+
],
|
| 551 |
+
|
| 552 |
+
'if': [
|
| 553 |
+
include('spaces'),
|
| 554 |
+
(r'\(', Punctuation, ('#pop', 'else', 'optional-semicolon', 'expr',
|
| 555 |
+
'parenthesis')),
|
| 556 |
+
],
|
| 557 |
+
|
| 558 |
+
'else': [
|
| 559 |
+
include('spaces'),
|
| 560 |
+
(r'(?:else)\b', Keyword, ('#pop', 'expr')),
|
| 561 |
+
default('#pop'),
|
| 562 |
+
],
|
| 563 |
+
|
| 564 |
+
'switch': [
|
| 565 |
+
include('spaces'),
|
| 566 |
+
default(('#pop', 'switch-body', 'bracket-open', 'expr')),
|
| 567 |
+
],
|
| 568 |
+
|
| 569 |
+
'switch-body': [
|
| 570 |
+
include('spaces'),
|
| 571 |
+
(r'(?:case|default)\b', Keyword, ('case-block', 'case')),
|
| 572 |
+
(r'\}', Punctuation, '#pop'),
|
| 573 |
+
],
|
| 574 |
+
|
| 575 |
+
'case': [
|
| 576 |
+
include('spaces'),
|
| 577 |
+
(r':', Punctuation, '#pop'),
|
| 578 |
+
default(('#pop', 'case-sep', 'case-guard', 'expr')),
|
| 579 |
+
],
|
| 580 |
+
|
| 581 |
+
'case-sep': [
|
| 582 |
+
include('spaces'),
|
| 583 |
+
(r':', Punctuation, '#pop'),
|
| 584 |
+
(r',', Punctuation, ('#pop', 'case')),
|
| 585 |
+
],
|
| 586 |
+
|
| 587 |
+
'case-guard': [
|
| 588 |
+
include('spaces'),
|
| 589 |
+
(r'(?:if)\b', Keyword, ('#pop', 'parenthesis', 'parenthesis-open')),
|
| 590 |
+
default('#pop'),
|
| 591 |
+
],
|
| 592 |
+
|
| 593 |
+
# optional multiple expr under a case
|
| 594 |
+
'case-block': [
|
| 595 |
+
include('spaces'),
|
| 596 |
+
(r'(?!(?:case|default)\b|\})', Keyword, 'expr-statement'),
|
| 597 |
+
default('#pop'),
|
| 598 |
+
],
|
| 599 |
+
|
| 600 |
+
'new': [
|
| 601 |
+
include('spaces'),
|
| 602 |
+
default(('#pop', 'call', 'parenthesis-open', 'type')),
|
| 603 |
+
],
|
| 604 |
+
|
| 605 |
+
'array-decl': [
|
| 606 |
+
include('spaces'),
|
| 607 |
+
(r'\]', Punctuation, '#pop'),
|
| 608 |
+
default(('#pop', 'array-decl-sep', 'expr')),
|
| 609 |
+
],
|
| 610 |
+
|
| 611 |
+
'array-decl-sep': [
|
| 612 |
+
include('spaces'),
|
| 613 |
+
(r'\]', Punctuation, '#pop'),
|
| 614 |
+
(r',', Punctuation, ('#pop', 'array-decl')),
|
| 615 |
+
],
|
| 616 |
+
|
| 617 |
+
'array-access': [
|
| 618 |
+
include('spaces'),
|
| 619 |
+
default(('#pop', 'array-access-close', 'expr')),
|
| 620 |
+
],
|
| 621 |
+
|
| 622 |
+
'array-access-close': [
|
| 623 |
+
include('spaces'),
|
| 624 |
+
(r'\]', Punctuation, '#pop'),
|
| 625 |
+
],
|
| 626 |
+
|
| 627 |
+
'comma': [
|
| 628 |
+
include('spaces'),
|
| 629 |
+
(r',', Punctuation, '#pop'),
|
| 630 |
+
],
|
| 631 |
+
|
| 632 |
+
'colon': [
|
| 633 |
+
include('spaces'),
|
| 634 |
+
(r':', Punctuation, '#pop'),
|
| 635 |
+
],
|
| 636 |
+
|
| 637 |
+
'semicolon': [
|
| 638 |
+
include('spaces'),
|
| 639 |
+
(r';', Punctuation, '#pop'),
|
| 640 |
+
],
|
| 641 |
+
|
| 642 |
+
'optional-semicolon': [
|
| 643 |
+
include('spaces'),
|
| 644 |
+
(r';', Punctuation, '#pop'),
|
| 645 |
+
default('#pop'),
|
| 646 |
+
],
|
| 647 |
+
|
| 648 |
+
# identity that CAN be a Haxe keyword
|
| 649 |
+
'ident': [
|
| 650 |
+
include('spaces'),
|
| 651 |
+
(ident, Name, '#pop'),
|
| 652 |
+
],
|
| 653 |
+
|
| 654 |
+
'dollar': [
|
| 655 |
+
include('spaces'),
|
| 656 |
+
(r'\{', Punctuation, ('#pop', 'expr-chain', 'bracket-close', 'expr')),
|
| 657 |
+
default(('#pop', 'expr-chain')),
|
| 658 |
+
],
|
| 659 |
+
|
| 660 |
+
'type-name': [
|
| 661 |
+
include('spaces'),
|
| 662 |
+
(typeid, Name, '#pop'),
|
| 663 |
+
],
|
| 664 |
+
|
| 665 |
+
'type-full-name': [
|
| 666 |
+
include('spaces'),
|
| 667 |
+
(r'\.', Punctuation, 'ident'),
|
| 668 |
+
default('#pop'),
|
| 669 |
+
],
|
| 670 |
+
|
| 671 |
+
'type': [
|
| 672 |
+
include('spaces'),
|
| 673 |
+
(r'\?', Punctuation),
|
| 674 |
+
(ident, Name, ('#pop', 'type-check', 'type-full-name')),
|
| 675 |
+
(r'\{', Punctuation, ('#pop', 'type-check', 'type-struct')),
|
| 676 |
+
(r'\(', Punctuation, ('#pop', 'type-check', 'type-parenthesis')),
|
| 677 |
+
],
|
| 678 |
+
|
| 679 |
+
'type-parenthesis': [
|
| 680 |
+
include('spaces'),
|
| 681 |
+
default(('#pop', 'parenthesis-close', 'type')),
|
| 682 |
+
],
|
| 683 |
+
|
| 684 |
+
'type-check': [
|
| 685 |
+
include('spaces'),
|
| 686 |
+
(r'->', Punctuation, ('#pop', 'type')),
|
| 687 |
+
(r'<(?!=)', Punctuation, 'type-param'),
|
| 688 |
+
default('#pop'),
|
| 689 |
+
],
|
| 690 |
+
|
| 691 |
+
'type-struct': [
|
| 692 |
+
include('spaces'),
|
| 693 |
+
(r'\}', Punctuation, '#pop'),
|
| 694 |
+
(r'\?', Punctuation),
|
| 695 |
+
(r'>', Punctuation, ('comma', 'type')),
|
| 696 |
+
(ident_no_keyword, Name, ('#pop', 'type-struct-sep', 'type', 'colon')),
|
| 697 |
+
include('class-body'),
|
| 698 |
+
],
|
| 699 |
+
|
| 700 |
+
'type-struct-sep': [
|
| 701 |
+
include('spaces'),
|
| 702 |
+
(r'\}', Punctuation, '#pop'),
|
| 703 |
+
(r',', Punctuation, ('#pop', 'type-struct')),
|
| 704 |
+
],
|
| 705 |
+
|
| 706 |
+
# type-param can be a normal type or a constant literal...
|
| 707 |
+
'type-param-type': [
|
| 708 |
+
# Float
|
| 709 |
+
(r'\.[0-9]+', Number.Float, '#pop'),
|
| 710 |
+
(r'[0-9]+[eE][+\-]?[0-9]+', Number.Float, '#pop'),
|
| 711 |
+
(r'[0-9]+\.[0-9]*[eE][+\-]?[0-9]+', Number.Float, '#pop'),
|
| 712 |
+
(r'[0-9]+\.[0-9]+', Number.Float, '#pop'),
|
| 713 |
+
(r'[0-9]+\.(?!' + ident + r'|\.\.)', Number.Float, '#pop'),
|
| 714 |
+
|
| 715 |
+
# Int
|
| 716 |
+
(r'0x[0-9a-fA-F]+', Number.Hex, '#pop'),
|
| 717 |
+
(r'[0-9]+', Number.Integer, '#pop'),
|
| 718 |
+
|
| 719 |
+
# String
|
| 720 |
+
(r"'", String.Single, ('#pop', 'string-single')),
|
| 721 |
+
(r'"', String.Double, ('#pop', 'string-double')),
|
| 722 |
+
|
| 723 |
+
# EReg
|
| 724 |
+
(r'~/(\\\\|\\[^\\]|[^/\\\n])*/[gim]*', String.Regex, '#pop'),
|
| 725 |
+
|
| 726 |
+
# Array
|
| 727 |
+
(r'\[', Operator, ('#pop', 'array-decl')),
|
| 728 |
+
|
| 729 |
+
include('type'),
|
| 730 |
+
],
|
| 731 |
+
|
| 732 |
+
# type-param part of a type
|
| 733 |
+
# ie. the <A,B> path in Map<A,B>
|
| 734 |
+
'type-param': [
|
| 735 |
+
include('spaces'),
|
| 736 |
+
default(('#pop', 'type-param-sep', 'type-param-type')),
|
| 737 |
+
],
|
| 738 |
+
|
| 739 |
+
'type-param-sep': [
|
| 740 |
+
include('spaces'),
|
| 741 |
+
(r'>', Punctuation, '#pop'),
|
| 742 |
+
(r',', Punctuation, ('#pop', 'type-param')),
|
| 743 |
+
],
|
| 744 |
+
|
| 745 |
+
# optional type-param that may include constraint
|
| 746 |
+
# ie. <T:Constraint, T2:(ConstraintA,ConstraintB)>
|
| 747 |
+
'type-param-constraint': [
|
| 748 |
+
include('spaces'),
|
| 749 |
+
(r'<(?!=)', Punctuation, ('#pop', 'type-param-constraint-sep',
|
| 750 |
+
'type-param-constraint-flag', 'type-name')),
|
| 751 |
+
default('#pop'),
|
| 752 |
+
],
|
| 753 |
+
|
| 754 |
+
'type-param-constraint-sep': [
|
| 755 |
+
include('spaces'),
|
| 756 |
+
(r'>', Punctuation, '#pop'),
|
| 757 |
+
(r',', Punctuation, ('#pop', 'type-param-constraint-sep',
|
| 758 |
+
'type-param-constraint-flag', 'type-name')),
|
| 759 |
+
],
|
| 760 |
+
|
| 761 |
+
# the optional constraint inside type-param
|
| 762 |
+
'type-param-constraint-flag': [
|
| 763 |
+
include('spaces'),
|
| 764 |
+
(r':', Punctuation, ('#pop', 'type-param-constraint-flag-type')),
|
| 765 |
+
default('#pop'),
|
| 766 |
+
],
|
| 767 |
+
|
| 768 |
+
'type-param-constraint-flag-type': [
|
| 769 |
+
include('spaces'),
|
| 770 |
+
(r'\(', Punctuation, ('#pop', 'type-param-constraint-flag-type-sep',
|
| 771 |
+
'type')),
|
| 772 |
+
default(('#pop', 'type')),
|
| 773 |
+
],
|
| 774 |
+
|
| 775 |
+
'type-param-constraint-flag-type-sep': [
|
| 776 |
+
include('spaces'),
|
| 777 |
+
(r'\)', Punctuation, '#pop'),
|
| 778 |
+
(r',', Punctuation, 'type'),
|
| 779 |
+
],
|
| 780 |
+
|
| 781 |
+
# a parenthesis expr that contain exactly one expr
|
| 782 |
+
'parenthesis': [
|
| 783 |
+
include('spaces'),
|
| 784 |
+
default(('#pop', 'parenthesis-close', 'flag', 'expr')),
|
| 785 |
+
],
|
| 786 |
+
|
| 787 |
+
'parenthesis-open': [
|
| 788 |
+
include('spaces'),
|
| 789 |
+
(r'\(', Punctuation, '#pop'),
|
| 790 |
+
],
|
| 791 |
+
|
| 792 |
+
'parenthesis-close': [
|
| 793 |
+
include('spaces'),
|
| 794 |
+
(r'\)', Punctuation, '#pop'),
|
| 795 |
+
],
|
| 796 |
+
|
| 797 |
+
'var': [
|
| 798 |
+
include('spaces'),
|
| 799 |
+
(ident_no_keyword, Text, ('#pop', 'var-sep', 'assign', 'flag', 'prop-get-set')),
|
| 800 |
+
],
|
| 801 |
+
|
| 802 |
+
# optional more var decl.
|
| 803 |
+
'var-sep': [
|
| 804 |
+
include('spaces'),
|
| 805 |
+
(r',', Punctuation, ('#pop', 'var')),
|
| 806 |
+
default('#pop'),
|
| 807 |
+
],
|
| 808 |
+
|
| 809 |
+
# optional assignment
|
| 810 |
+
'assign': [
|
| 811 |
+
include('spaces'),
|
| 812 |
+
(r'=', Operator, ('#pop', 'expr')),
|
| 813 |
+
default('#pop'),
|
| 814 |
+
],
|
| 815 |
+
|
| 816 |
+
# optional type flag
|
| 817 |
+
'flag': [
|
| 818 |
+
include('spaces'),
|
| 819 |
+
(r':', Punctuation, ('#pop', 'type')),
|
| 820 |
+
default('#pop'),
|
| 821 |
+
],
|
| 822 |
+
|
| 823 |
+
# colon as part of a ternary operator (?:)
|
| 824 |
+
'ternary': [
|
| 825 |
+
include('spaces'),
|
| 826 |
+
(r':', Operator, '#pop'),
|
| 827 |
+
],
|
| 828 |
+
|
| 829 |
+
# function call
|
| 830 |
+
'call': [
|
| 831 |
+
include('spaces'),
|
| 832 |
+
(r'\)', Punctuation, '#pop'),
|
| 833 |
+
default(('#pop', 'call-sep', 'expr')),
|
| 834 |
+
],
|
| 835 |
+
|
| 836 |
+
# after a call param
|
| 837 |
+
'call-sep': [
|
| 838 |
+
include('spaces'),
|
| 839 |
+
(r'\)', Punctuation, '#pop'),
|
| 840 |
+
(r',', Punctuation, ('#pop', 'call')),
|
| 841 |
+
],
|
| 842 |
+
|
| 843 |
+
# bracket can be block or object
|
| 844 |
+
'bracket': [
|
| 845 |
+
include('spaces'),
|
| 846 |
+
(r'(?!(?:\$\s*[a-z]\b|\$(?!'+ident+')))' + ident_no_keyword, Name,
|
| 847 |
+
('#pop', 'bracket-check')),
|
| 848 |
+
(r"'", String.Single, ('#pop', 'bracket-check', 'string-single')),
|
| 849 |
+
(r'"', String.Double, ('#pop', 'bracket-check', 'string-double')),
|
| 850 |
+
default(('#pop', 'block')),
|
| 851 |
+
],
|
| 852 |
+
|
| 853 |
+
'bracket-check': [
|
| 854 |
+
include('spaces'),
|
| 855 |
+
(r':', Punctuation, ('#pop', 'object-sep', 'expr')), # is object
|
| 856 |
+
default(('#pop', 'block', 'optional-semicolon', 'expr-chain')), # is block
|
| 857 |
+
],
|
| 858 |
+
|
| 859 |
+
# code block
|
| 860 |
+
'block': [
|
| 861 |
+
include('spaces'),
|
| 862 |
+
(r'\}', Punctuation, '#pop'),
|
| 863 |
+
default('expr-statement'),
|
| 864 |
+
],
|
| 865 |
+
|
| 866 |
+
# object in key-value pairs
|
| 867 |
+
'object': [
|
| 868 |
+
include('spaces'),
|
| 869 |
+
(r'\}', Punctuation, '#pop'),
|
| 870 |
+
default(('#pop', 'object-sep', 'expr', 'colon', 'ident-or-string'))
|
| 871 |
+
],
|
| 872 |
+
|
| 873 |
+
# a key of an object
|
| 874 |
+
'ident-or-string': [
|
| 875 |
+
include('spaces'),
|
| 876 |
+
(ident_no_keyword, Name, '#pop'),
|
| 877 |
+
(r"'", String.Single, ('#pop', 'string-single')),
|
| 878 |
+
(r'"', String.Double, ('#pop', 'string-double')),
|
| 879 |
+
],
|
| 880 |
+
|
| 881 |
+
# after a key-value pair in object
|
| 882 |
+
'object-sep': [
|
| 883 |
+
include('spaces'),
|
| 884 |
+
(r'\}', Punctuation, '#pop'),
|
| 885 |
+
(r',', Punctuation, ('#pop', 'object')),
|
| 886 |
+
],
|
| 887 |
+
|
| 888 |
+
|
| 889 |
+
|
| 890 |
+
}
|
| 891 |
+
|
| 892 |
+
def analyse_text(text):
|
| 893 |
+
rv = 0
|
| 894 |
+
if re.search(r'\bimport\s+haxe\.', text):
|
| 895 |
+
rv = max(rv, 0.2)
|
| 896 |
+
if re.search(r'\bStd\.', text):
|
| 897 |
+
rv = max(rv, 0.1)
|
| 898 |
+
if re.search(r'\btrace\s*\(', text):
|
| 899 |
+
rv = max(rv, 0.05)
|
| 900 |
+
return rv
|
| 901 |
+
|
| 902 |
+
|
| 903 |
+
class HxmlLexer(RegexLexer):
|
| 904 |
+
"""
|
| 905 |
+
Lexer for haXe build files.
|
| 906 |
+
"""
|
| 907 |
+
name = 'Hxml'
|
| 908 |
+
url = 'https://haxe.org/manual/compiler-usage-hxml.html'
|
| 909 |
+
aliases = ['haxeml', 'hxml']
|
| 910 |
+
filenames = ['*.hxml']
|
| 911 |
+
version_added = '1.6'
|
| 912 |
+
|
| 913 |
+
tokens = {
|
| 914 |
+
'root': [
|
| 915 |
+
# Separator
|
| 916 |
+
(r'(--)(next)', bygroups(Punctuation, Generic.Heading)),
|
| 917 |
+
# Compiler switches with one dash
|
| 918 |
+
(r'(-)(prompt|debug|v)', bygroups(Punctuation, Keyword.Keyword)),
|
| 919 |
+
# Compilerswitches with two dashes
|
| 920 |
+
(r'(--)(neko-source|flash-strict|flash-use-stage|no-opt|no-traces|'
|
| 921 |
+
r'no-inline|times|no-output)', bygroups(Punctuation, Keyword)),
|
| 922 |
+
# Targets and other options that take an argument
|
| 923 |
+
(r'(-)(cpp|js|neko|x|as3|swf9?|swf-lib|php|xml|main|lib|D|resource|'
|
| 924 |
+
r'cp|cmd)( +)(.+)',
|
| 925 |
+
bygroups(Punctuation, Keyword, Whitespace, String)),
|
| 926 |
+
# Options that take only numerical arguments
|
| 927 |
+
(r'(-)(swf-version)( +)(\d+)',
|
| 928 |
+
bygroups(Punctuation, Keyword, Whitespace, Number.Integer)),
|
| 929 |
+
# An Option that defines the size, the fps and the background
|
| 930 |
+
# color of an flash movie
|
| 931 |
+
(r'(-)(swf-header)( +)(\d+)(:)(\d+)(:)(\d+)(:)([A-Fa-f0-9]{6})',
|
| 932 |
+
bygroups(Punctuation, Keyword, Whitespace, Number.Integer,
|
| 933 |
+
Punctuation, Number.Integer, Punctuation, Number.Integer,
|
| 934 |
+
Punctuation, Number.Hex)),
|
| 935 |
+
# options with two dashes that takes arguments
|
| 936 |
+
(r'(--)(js-namespace|php-front|php-lib|remap|gen-hx-classes)( +)'
|
| 937 |
+
r'(.+)', bygroups(Punctuation, Keyword, Whitespace, String)),
|
| 938 |
+
# Single line comment, multiline ones are not allowed.
|
| 939 |
+
(r'#.*', Comment.Single)
|
| 940 |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
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, bygroups, include, using, this, words
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Number, Punctuation, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['VerilogLexer', 'SystemVerilogLexer', 'VhdlLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class VerilogLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
For verilog source code with preprocessor directives.
|
| 23 |
+
"""
|
| 24 |
+
name = 'verilog'
|
| 25 |
+
aliases = ['verilog', 'v']
|
| 26 |
+
filenames = ['*.v']
|
| 27 |
+
mimetypes = ['text/x-verilog']
|
| 28 |
+
url = 'https://en.wikipedia.org/wiki/Verilog'
|
| 29 |
+
version_added = '1.4'
|
| 30 |
+
|
| 31 |
+
#: optional Comment or Whitespace
|
| 32 |
+
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
|
| 33 |
+
|
| 34 |
+
tokens = {
|
| 35 |
+
'root': [
|
| 36 |
+
(r'^\s*`define', Comment.Preproc, 'macro'),
|
| 37 |
+
(r'\s+', Whitespace),
|
| 38 |
+
(r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation
|
| 39 |
+
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
| 40 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 41 |
+
(r'[{}#@]', Punctuation),
|
| 42 |
+
(r'L?"', String, 'string'),
|
| 43 |
+
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
| 44 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
|
| 45 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 46 |
+
(r'([0-9]+)|(\'h)[0-9a-fA-F]+', Number.Hex),
|
| 47 |
+
(r'([0-9]+)|(\'b)[01]+', Number.Bin),
|
| 48 |
+
(r'([0-9]+)|(\'d)[0-9]+', Number.Integer),
|
| 49 |
+
(r'([0-9]+)|(\'o)[0-7]+', Number.Oct),
|
| 50 |
+
(r'\'[01xz]', Number),
|
| 51 |
+
(r'\d+[Ll]?', Number.Integer),
|
| 52 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 53 |
+
(r'[()\[\],.;\']', Punctuation),
|
| 54 |
+
(r'`[a-zA-Z_]\w*', Name.Constant),
|
| 55 |
+
|
| 56 |
+
(r'^(\s*)(package)(\s+)', bygroups(Whitespace, Keyword.Namespace, Text)),
|
| 57 |
+
(r'^(\s*)(import)(\s+)', bygroups(Whitespace, Keyword.Namespace, Text),
|
| 58 |
+
'import'),
|
| 59 |
+
|
| 60 |
+
(words((
|
| 61 |
+
'always', 'always_comb', 'always_ff', 'always_latch', 'and',
|
| 62 |
+
'assign', 'automatic', 'begin', 'break', 'buf', 'bufif0', 'bufif1',
|
| 63 |
+
'case', 'casex', 'casez', 'cmos', 'const', 'continue', 'deassign',
|
| 64 |
+
'default', 'defparam', 'disable', 'do', 'edge', 'else', 'end', 'endcase',
|
| 65 |
+
'endfunction', 'endgenerate', 'endmodule', 'endpackage', 'endprimitive',
|
| 66 |
+
'endspecify', 'endtable', 'endtask', 'enum', 'event', 'final', 'for',
|
| 67 |
+
'force', 'forever', 'fork', 'function', 'generate', 'genvar', 'highz0',
|
| 68 |
+
'highz1', 'if', 'initial', 'inout', 'input', 'integer', 'join', 'large',
|
| 69 |
+
'localparam', 'macromodule', 'medium', 'module', 'nand', 'negedge',
|
| 70 |
+
'nmos', 'nor', 'not', 'notif0', 'notif1', 'or', 'output', 'packed',
|
| 71 |
+
'parameter', 'pmos', 'posedge', 'primitive', 'pull0', 'pull1',
|
| 72 |
+
'pulldown', 'pullup', 'rcmos', 'ref', 'release', 'repeat', 'return',
|
| 73 |
+
'rnmos', 'rpmos', 'rtran', 'rtranif0', 'rtranif1', 'scalared', 'signed',
|
| 74 |
+
'small', 'specify', 'specparam', 'strength', 'string', 'strong0',
|
| 75 |
+
'strong1', 'struct', 'table', 'task', 'tran', 'tranif0', 'tranif1',
|
| 76 |
+
'type', 'typedef', 'unsigned', 'var', 'vectored', 'void', 'wait',
|
| 77 |
+
'weak0', 'weak1', 'while', 'xnor', 'xor'), suffix=r'\b'),
|
| 78 |
+
Keyword),
|
| 79 |
+
|
| 80 |
+
(words((
|
| 81 |
+
'accelerate', 'autoexpand_vectornets', 'celldefine', 'default_nettype',
|
| 82 |
+
'else', 'elsif', 'endcelldefine', 'endif', 'endprotect', 'endprotected',
|
| 83 |
+
'expand_vectornets', 'ifdef', 'ifndef', 'include', 'noaccelerate',
|
| 84 |
+
'noexpand_vectornets', 'noremove_gatenames', 'noremove_netnames',
|
| 85 |
+
'nounconnected_drive', 'protect', 'protected', 'remove_gatenames',
|
| 86 |
+
'remove_netnames', 'resetall', 'timescale', 'unconnected_drive',
|
| 87 |
+
'undef'), prefix=r'`', suffix=r'\b'),
|
| 88 |
+
Comment.Preproc),
|
| 89 |
+
|
| 90 |
+
(words((
|
| 91 |
+
'bits', 'bitstoreal', 'bitstoshortreal', 'countdrivers', 'display', 'fclose',
|
| 92 |
+
'fdisplay', 'finish', 'floor', 'fmonitor', 'fopen', 'fstrobe', 'fwrite',
|
| 93 |
+
'getpattern', 'history', 'incsave', 'input', 'itor', 'key', 'list', 'log',
|
| 94 |
+
'monitor', 'monitoroff', 'monitoron', 'nokey', 'nolog', 'printtimescale',
|
| 95 |
+
'random', 'readmemb', 'readmemh', 'realtime', 'realtobits', 'reset',
|
| 96 |
+
'reset_count', 'reset_value', 'restart', 'rtoi', 'save', 'scale', 'scope',
|
| 97 |
+
'shortrealtobits', 'showscopes', 'showvariables', 'showvars', 'sreadmemb',
|
| 98 |
+
'sreadmemh', 'stime', 'stop', 'strobe', 'time', 'timeformat', 'write'),
|
| 99 |
+
prefix=r'\$', suffix=r'\b'),
|
| 100 |
+
Name.Builtin),
|
| 101 |
+
|
| 102 |
+
(words((
|
| 103 |
+
'byte', 'shortint', 'int', 'longint', 'integer', 'time',
|
| 104 |
+
'bit', 'logic', 'reg', 'supply0', 'supply1', 'tri', 'triand',
|
| 105 |
+
'trior', 'tri0', 'tri1', 'trireg', 'uwire', 'wire', 'wand', 'wor'
|
| 106 |
+
'shortreal', 'real', 'realtime'), suffix=r'\b'),
|
| 107 |
+
Keyword.Type),
|
| 108 |
+
(r'[a-zA-Z_]\w*:(?!:)', Name.Label),
|
| 109 |
+
(r'\$?[a-zA-Z_]\w*', Name),
|
| 110 |
+
(r'\\(\S+)', Name),
|
| 111 |
+
],
|
| 112 |
+
'string': [
|
| 113 |
+
(r'"', String, '#pop'),
|
| 114 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
| 115 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 116 |
+
(r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation
|
| 117 |
+
(r'\\', String), # stray backslash
|
| 118 |
+
],
|
| 119 |
+
'macro': [
|
| 120 |
+
(r'[^/\n]+', Comment.Preproc),
|
| 121 |
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
| 122 |
+
(r'//.*?\n', Comment.Single, '#pop'),
|
| 123 |
+
(r'/', Comment.Preproc),
|
| 124 |
+
(r'(?<=\\)\n', Comment.Preproc),
|
| 125 |
+
(r'\n', Whitespace, '#pop'),
|
| 126 |
+
],
|
| 127 |
+
'import': [
|
| 128 |
+
(r'[\w:]+\*?', Name.Namespace, '#pop')
|
| 129 |
+
]
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
def analyse_text(text):
|
| 133 |
+
"""Verilog code will use one of reg/wire/assign for sure, and that
|
| 134 |
+
is not common elsewhere."""
|
| 135 |
+
result = 0
|
| 136 |
+
if 'reg' in text:
|
| 137 |
+
result += 0.1
|
| 138 |
+
if 'wire' in text:
|
| 139 |
+
result += 0.1
|
| 140 |
+
if 'assign' in text:
|
| 141 |
+
result += 0.1
|
| 142 |
+
|
| 143 |
+
return result
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
class SystemVerilogLexer(RegexLexer):
|
| 147 |
+
"""
|
| 148 |
+
Extends verilog lexer to recognise all SystemVerilog keywords from IEEE
|
| 149 |
+
1800-2009 standard.
|
| 150 |
+
"""
|
| 151 |
+
name = 'systemverilog'
|
| 152 |
+
aliases = ['systemverilog', 'sv']
|
| 153 |
+
filenames = ['*.sv', '*.svh']
|
| 154 |
+
mimetypes = ['text/x-systemverilog']
|
| 155 |
+
url = 'https://en.wikipedia.org/wiki/SystemVerilog'
|
| 156 |
+
version_added = '1.5'
|
| 157 |
+
|
| 158 |
+
#: optional Comment or Whitespace
|
| 159 |
+
_ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
|
| 160 |
+
|
| 161 |
+
tokens = {
|
| 162 |
+
'root': [
|
| 163 |
+
(r'^(\s*)(`define)', bygroups(Whitespace, Comment.Preproc), 'macro'),
|
| 164 |
+
(r'^(\s*)(package)(\s+)', bygroups(Whitespace, Keyword.Namespace, Whitespace)),
|
| 165 |
+
(r'^(\s*)(import)(\s+)', bygroups(Whitespace, Keyword.Namespace, Whitespace), 'import'),
|
| 166 |
+
|
| 167 |
+
(r'\s+', Whitespace),
|
| 168 |
+
(r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation
|
| 169 |
+
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
| 170 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 171 |
+
(r'[{}#@]', Punctuation),
|
| 172 |
+
(r'L?"', String, 'string'),
|
| 173 |
+
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
| 174 |
+
|
| 175 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
|
| 176 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 177 |
+
|
| 178 |
+
(r'([1-9][_0-9]*)?\s*\'[sS]?[bB]\s*[xXzZ?01][_xXzZ?01]*',
|
| 179 |
+
Number.Bin),
|
| 180 |
+
(r'([1-9][_0-9]*)?\s*\'[sS]?[oO]\s*[xXzZ?0-7][_xXzZ?0-7]*',
|
| 181 |
+
Number.Oct),
|
| 182 |
+
(r'([1-9][_0-9]*)?\s*\'[sS]?[dD]\s*[xXzZ?0-9][_xXzZ?0-9]*',
|
| 183 |
+
Number.Integer),
|
| 184 |
+
(r'([1-9][_0-9]*)?\s*\'[sS]?[hH]\s*[xXzZ?0-9a-fA-F][_xXzZ?0-9a-fA-F]*',
|
| 185 |
+
Number.Hex),
|
| 186 |
+
|
| 187 |
+
(r'\'[01xXzZ]', Number),
|
| 188 |
+
(r'[0-9][_0-9]*', Number.Integer),
|
| 189 |
+
|
| 190 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 191 |
+
(words(('inside', 'dist'), suffix=r'\b'), Operator.Word),
|
| 192 |
+
|
| 193 |
+
(r'[()\[\],.;\'$]', Punctuation),
|
| 194 |
+
(r'`[a-zA-Z_]\w*', Name.Constant),
|
| 195 |
+
|
| 196 |
+
(words((
|
| 197 |
+
'accept_on', 'alias', 'always', 'always_comb', 'always_ff',
|
| 198 |
+
'always_latch', 'and', 'assert', 'assign', 'assume', 'automatic',
|
| 199 |
+
'before', 'begin', 'bind', 'bins', 'binsof', 'break', 'buf',
|
| 200 |
+
'bufif0', 'bufif1', 'case', 'casex', 'casez', 'cell',
|
| 201 |
+
'checker', 'clocking', 'cmos', 'config',
|
| 202 |
+
'constraint', 'context', 'continue', 'cover', 'covergroup',
|
| 203 |
+
'coverpoint', 'cross', 'deassign', 'default', 'defparam', 'design',
|
| 204 |
+
'disable', 'do', 'edge', 'else', 'end', 'endcase',
|
| 205 |
+
'endchecker', 'endclocking', 'endconfig', 'endfunction',
|
| 206 |
+
'endgenerate', 'endgroup', 'endinterface', 'endmodule', 'endpackage',
|
| 207 |
+
'endprimitive', 'endprogram', 'endproperty', 'endsequence',
|
| 208 |
+
'endspecify', 'endtable', 'endtask', 'enum', 'eventually',
|
| 209 |
+
'expect', 'export', 'extern', 'final', 'first_match',
|
| 210 |
+
'for', 'force', 'foreach', 'forever', 'fork', 'forkjoin', 'function',
|
| 211 |
+
'generate', 'genvar', 'global', 'highz0', 'highz1', 'if', 'iff',
|
| 212 |
+
'ifnone', 'ignore_bins', 'illegal_bins', 'implies', 'implements', 'import',
|
| 213 |
+
'incdir', 'include', 'initial', 'inout', 'input',
|
| 214 |
+
'instance', 'interconnect', 'interface', 'intersect', 'join',
|
| 215 |
+
'join_any', 'join_none', 'large', 'let', 'liblist', 'library',
|
| 216 |
+
'local', 'localparam', 'macromodule', 'matches',
|
| 217 |
+
'medium', 'modport', 'module', 'nand', 'negedge', 'nettype', 'new', 'nexttime',
|
| 218 |
+
'nmos', 'nor', 'noshowcancelled', 'not', 'notif0', 'notif1', 'null',
|
| 219 |
+
'or', 'output', 'package', 'packed', 'parameter', 'pmos', 'posedge',
|
| 220 |
+
'primitive', 'priority', 'program', 'property', 'protected', 'pull0',
|
| 221 |
+
'pull1', 'pulldown', 'pullup', 'pulsestyle_ondetect',
|
| 222 |
+
'pulsestyle_onevent', 'pure', 'rand', 'randc', 'randcase',
|
| 223 |
+
'randsequence', 'rcmos', 'ref',
|
| 224 |
+
'reject_on', 'release', 'repeat', 'restrict', 'return', 'rnmos',
|
| 225 |
+
'rpmos', 'rtran', 'rtranif0', 'rtranif1', 's_always', 's_eventually',
|
| 226 |
+
's_nexttime', 's_until', 's_until_with', 'scalared', 'sequence',
|
| 227 |
+
'showcancelled', 'small', 'soft', 'solve',
|
| 228 |
+
'specify', 'specparam', 'static', 'strong', 'strong0',
|
| 229 |
+
'strong1', 'struct', 'super', 'sync_accept_on',
|
| 230 |
+
'sync_reject_on', 'table', 'tagged', 'task', 'this', 'throughout',
|
| 231 |
+
'timeprecision', 'timeunit', 'tran', 'tranif0', 'tranif1',
|
| 232 |
+
'typedef', 'union', 'unique', 'unique0', 'until',
|
| 233 |
+
'until_with', 'untyped', 'use', 'vectored',
|
| 234 |
+
'virtual', 'wait', 'wait_order', 'weak', 'weak0',
|
| 235 |
+
'weak1', 'while', 'wildcard', 'with', 'within',
|
| 236 |
+
'xnor', 'xor'),
|
| 237 |
+
suffix=r'\b'),
|
| 238 |
+
Keyword),
|
| 239 |
+
|
| 240 |
+
(r'(class)(\s+)([a-zA-Z_]\w*)',
|
| 241 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Class)),
|
| 242 |
+
(r'(extends)(\s+)([a-zA-Z_]\w*)',
|
| 243 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Class)),
|
| 244 |
+
(r'(endclass\b)(?:(\s*)(:)(\s*)([a-zA-Z_]\w*))?',
|
| 245 |
+
bygroups(Keyword.Declaration, Whitespace, Punctuation, Whitespace, Name.Class)),
|
| 246 |
+
|
| 247 |
+
(words((
|
| 248 |
+
# Variable types
|
| 249 |
+
'bit', 'byte', 'chandle', 'const', 'event', 'int', 'integer',
|
| 250 |
+
'logic', 'longint', 'real', 'realtime', 'reg', 'shortint',
|
| 251 |
+
'shortreal', 'signed', 'string', 'time', 'type', 'unsigned',
|
| 252 |
+
'var', 'void',
|
| 253 |
+
# Net types
|
| 254 |
+
'supply0', 'supply1', 'tri', 'triand', 'trior', 'trireg',
|
| 255 |
+
'tri0', 'tri1', 'uwire', 'wand', 'wire', 'wor'),
|
| 256 |
+
suffix=r'\b'),
|
| 257 |
+
Keyword.Type),
|
| 258 |
+
|
| 259 |
+
(words((
|
| 260 |
+
'`__FILE__', '`__LINE__', '`begin_keywords', '`celldefine',
|
| 261 |
+
'`default_nettype', '`define', '`else', '`elsif', '`end_keywords',
|
| 262 |
+
'`endcelldefine', '`endif', '`ifdef', '`ifndef', '`include',
|
| 263 |
+
'`line', '`nounconnected_drive', '`pragma', '`resetall',
|
| 264 |
+
'`timescale', '`unconnected_drive', '`undef', '`undefineall'),
|
| 265 |
+
suffix=r'\b'),
|
| 266 |
+
Comment.Preproc),
|
| 267 |
+
|
| 268 |
+
(words((
|
| 269 |
+
# Simulation control tasks (20.2)
|
| 270 |
+
'$exit', '$finish', '$stop',
|
| 271 |
+
# Simulation time functions (20.3)
|
| 272 |
+
'$realtime', '$stime', '$time',
|
| 273 |
+
# Timescale tasks (20.4)
|
| 274 |
+
'$printtimescale', '$timeformat',
|
| 275 |
+
# Conversion functions
|
| 276 |
+
'$bitstoreal', '$bitstoshortreal', '$cast', '$itor',
|
| 277 |
+
'$realtobits', '$rtoi', '$shortrealtobits', '$signed',
|
| 278 |
+
'$unsigned',
|
| 279 |
+
# Data query functions (20.6)
|
| 280 |
+
'$bits', '$isunbounded', '$typename',
|
| 281 |
+
# Array query functions (20.7)
|
| 282 |
+
'$dimensions', '$high', '$increment', '$left', '$low', '$right',
|
| 283 |
+
'$size', '$unpacked_dimensions',
|
| 284 |
+
# Math functions (20.8)
|
| 285 |
+
'$acos', '$acosh', '$asin', '$asinh', '$atan', '$atan2',
|
| 286 |
+
'$atanh', '$ceil', '$clog2', '$cos', '$cosh', '$exp', '$floor',
|
| 287 |
+
'$hypot', '$ln', '$log10', '$pow', '$sin', '$sinh', '$sqrt',
|
| 288 |
+
'$tan', '$tanh',
|
| 289 |
+
# Bit vector system functions (20.9)
|
| 290 |
+
'$countbits', '$countones', '$isunknown', '$onehot', '$onehot0',
|
| 291 |
+
# Severity tasks (20.10)
|
| 292 |
+
'$info', '$error', '$fatal', '$warning',
|
| 293 |
+
# Assertion control tasks (20.12)
|
| 294 |
+
'$assertcontrol', '$assertfailoff', '$assertfailon',
|
| 295 |
+
'$assertkill', '$assertnonvacuouson', '$assertoff', '$asserton',
|
| 296 |
+
'$assertpassoff', '$assertpasson', '$assertvacuousoff',
|
| 297 |
+
# Sampled value system functions (20.13)
|
| 298 |
+
'$changed', '$changed_gclk', '$changing_gclk', '$falling_gclk',
|
| 299 |
+
'$fell', '$fell_gclk', '$future_gclk', '$past', '$past_gclk',
|
| 300 |
+
'$rising_gclk', '$rose', '$rose_gclk', '$sampled', '$stable',
|
| 301 |
+
'$stable_gclk', '$steady_gclk',
|
| 302 |
+
# Coverage control functions (20.14)
|
| 303 |
+
'$coverage_control', '$coverage_get', '$coverage_get_max',
|
| 304 |
+
'$coverage_merge', '$coverage_save', '$get_coverage',
|
| 305 |
+
'$load_coverage_db', '$set_coverage_db_name',
|
| 306 |
+
# Probabilistic distribution functions (20.15)
|
| 307 |
+
'$dist_chi_square', '$dist_erlang', '$dist_exponential',
|
| 308 |
+
'$dist_normal', '$dist_poisson', '$dist_t', '$dist_uniform',
|
| 309 |
+
'$random',
|
| 310 |
+
# Stochastic analysis tasks and functions (20.16)
|
| 311 |
+
'$q_add', '$q_exam', '$q_full', '$q_initialize', '$q_remove',
|
| 312 |
+
# PLA modeling tasks (20.17)
|
| 313 |
+
'$async$and$array', '$async$and$plane', '$async$nand$array',
|
| 314 |
+
'$async$nand$plane', '$async$nor$array', '$async$nor$plane',
|
| 315 |
+
'$async$or$array', '$async$or$plane', '$sync$and$array',
|
| 316 |
+
'$sync$and$plane', '$sync$nand$array', '$sync$nand$plane',
|
| 317 |
+
'$sync$nor$array', '$sync$nor$plane', '$sync$or$array',
|
| 318 |
+
'$sync$or$plane',
|
| 319 |
+
# Miscellaneous tasks and functions (20.18)
|
| 320 |
+
'$system',
|
| 321 |
+
# Display tasks (21.2)
|
| 322 |
+
'$display', '$displayb', '$displayh', '$displayo', '$monitor',
|
| 323 |
+
'$monitorb', '$monitorh', '$monitoro', '$monitoroff',
|
| 324 |
+
'$monitoron', '$strobe', '$strobeb', '$strobeh', '$strobeo',
|
| 325 |
+
'$write', '$writeb', '$writeh', '$writeo',
|
| 326 |
+
# File I/O tasks and functions (21.3)
|
| 327 |
+
'$fclose', '$fdisplay', '$fdisplayb', '$fdisplayh',
|
| 328 |
+
'$fdisplayo', '$feof', '$ferror', '$fflush', '$fgetc', '$fgets',
|
| 329 |
+
'$fmonitor', '$fmonitorb', '$fmonitorh', '$fmonitoro', '$fopen',
|
| 330 |
+
'$fread', '$fscanf', '$fseek', '$fstrobe', '$fstrobeb',
|
| 331 |
+
'$fstrobeh', '$fstrobeo', '$ftell', '$fwrite', '$fwriteb',
|
| 332 |
+
'$fwriteh', '$fwriteo', '$rewind', '$sformat', '$sformatf',
|
| 333 |
+
'$sscanf', '$swrite', '$swriteb', '$swriteh', '$swriteo',
|
| 334 |
+
'$ungetc',
|
| 335 |
+
# Memory load tasks (21.4)
|
| 336 |
+
'$readmemb', '$readmemh',
|
| 337 |
+
# Memory dump tasks (21.5)
|
| 338 |
+
'$writememb', '$writememh',
|
| 339 |
+
# Command line input (21.6)
|
| 340 |
+
'$test$plusargs', '$value$plusargs',
|
| 341 |
+
# VCD tasks (21.7)
|
| 342 |
+
'$dumpall', '$dumpfile', '$dumpflush', '$dumplimit', '$dumpoff',
|
| 343 |
+
'$dumpon', '$dumpports', '$dumpportsall', '$dumpportsflush',
|
| 344 |
+
'$dumpportslimit', '$dumpportsoff', '$dumpportson', '$dumpvars',
|
| 345 |
+
), suffix=r'\b'),
|
| 346 |
+
Name.Builtin),
|
| 347 |
+
|
| 348 |
+
(r'[a-zA-Z_]\w*:(?!:)', Name.Label),
|
| 349 |
+
(r'\$?[a-zA-Z_]\w*', Name),
|
| 350 |
+
(r'\\(\S+)', Name),
|
| 351 |
+
],
|
| 352 |
+
'string': [
|
| 353 |
+
(r'"', String, '#pop'),
|
| 354 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
| 355 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 356 |
+
(r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation
|
| 357 |
+
(r'\\', String), # stray backslash
|
| 358 |
+
],
|
| 359 |
+
'macro': [
|
| 360 |
+
(r'[^/\n]+', Comment.Preproc),
|
| 361 |
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
| 362 |
+
(r'//.*?$', Comment.Single, '#pop'),
|
| 363 |
+
(r'/', Comment.Preproc),
|
| 364 |
+
(r'(?<=\\)\n', Comment.Preproc),
|
| 365 |
+
(r'\n', Whitespace, '#pop'),
|
| 366 |
+
],
|
| 367 |
+
'import': [
|
| 368 |
+
(r'[\w:]+\*?', Name.Namespace, '#pop')
|
| 369 |
+
]
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
class VhdlLexer(RegexLexer):
|
| 374 |
+
"""
|
| 375 |
+
For VHDL source code.
|
| 376 |
+
"""
|
| 377 |
+
name = 'vhdl'
|
| 378 |
+
aliases = ['vhdl']
|
| 379 |
+
filenames = ['*.vhdl', '*.vhd']
|
| 380 |
+
mimetypes = ['text/x-vhdl']
|
| 381 |
+
url = 'https://en.wikipedia.org/wiki/VHDL'
|
| 382 |
+
version_added = '1.5'
|
| 383 |
+
flags = re.MULTILINE | re.IGNORECASE
|
| 384 |
+
|
| 385 |
+
tokens = {
|
| 386 |
+
'root': [
|
| 387 |
+
(r'\s+', Whitespace),
|
| 388 |
+
(r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation
|
| 389 |
+
(r'--.*?$', Comment.Single),
|
| 390 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 391 |
+
(r"'(U|X|0|1|Z|W|L|H|-)'", String.Char),
|
| 392 |
+
(r'[~!%^&*+=|?:<>/-]', Operator),
|
| 393 |
+
(r"'[a-z_]\w*", Name.Attribute),
|
| 394 |
+
(r'[()\[\],.;\']', Punctuation),
|
| 395 |
+
(r'"[^\n\\"]*"', String),
|
| 396 |
+
|
| 397 |
+
(r'(library)(\s+)([a-z_]\w*)',
|
| 398 |
+
bygroups(Keyword, Whitespace, Name.Namespace)),
|
| 399 |
+
(r'(use)(\s+)(entity)', bygroups(Keyword, Whitespace, Keyword)),
|
| 400 |
+
(r'(use)(\s+)([a-z_][\w.]*\.)(all)',
|
| 401 |
+
bygroups(Keyword, Whitespace, Name.Namespace, Keyword)),
|
| 402 |
+
(r'(use)(\s+)([a-z_][\w.]*)',
|
| 403 |
+
bygroups(Keyword, Whitespace, Name.Namespace)),
|
| 404 |
+
(r'(std|ieee)(\.[a-z_]\w*)',
|
| 405 |
+
bygroups(Name.Namespace, Name.Namespace)),
|
| 406 |
+
(words(('std', 'ieee', 'work'), suffix=r'\b'),
|
| 407 |
+
Name.Namespace),
|
| 408 |
+
(r'(entity|component)(\s+)([a-z_]\w*)',
|
| 409 |
+
bygroups(Keyword, Whitespace, Name.Class)),
|
| 410 |
+
(r'(architecture|configuration)(\s+)([a-z_]\w*)(\s+)'
|
| 411 |
+
r'(of)(\s+)([a-z_]\w*)(\s+)(is)',
|
| 412 |
+
bygroups(Keyword, Whitespace, Name.Class, Whitespace, Keyword, Whitespace,
|
| 413 |
+
Name.Class, Whitespace, Keyword)),
|
| 414 |
+
(r'([a-z_]\w*)(:)(\s+)(process|for)',
|
| 415 |
+
bygroups(Name.Class, Operator, Whitespace, Keyword)),
|
| 416 |
+
(r'(end)(\s+)', bygroups(using(this), Whitespace), 'endblock'),
|
| 417 |
+
|
| 418 |
+
include('types'),
|
| 419 |
+
include('keywords'),
|
| 420 |
+
include('numbers'),
|
| 421 |
+
|
| 422 |
+
(r'[a-z_]\w*', Name),
|
| 423 |
+
],
|
| 424 |
+
'endblock': [
|
| 425 |
+
include('keywords'),
|
| 426 |
+
(r'[a-z_]\w*', Name.Class),
|
| 427 |
+
(r'\s+', Whitespace),
|
| 428 |
+
(r';', Punctuation, '#pop'),
|
| 429 |
+
],
|
| 430 |
+
'types': [
|
| 431 |
+
(words((
|
| 432 |
+
'boolean', 'bit', 'character', 'severity_level', 'integer', 'time',
|
| 433 |
+
'delay_length', 'natural', 'positive', 'string', 'bit_vector',
|
| 434 |
+
'file_open_kind', 'file_open_status', 'std_ulogic', 'std_ulogic_vector',
|
| 435 |
+
'std_logic', 'std_logic_vector', 'signed', 'unsigned'), suffix=r'\b'),
|
| 436 |
+
Keyword.Type),
|
| 437 |
+
],
|
| 438 |
+
'keywords': [
|
| 439 |
+
(words((
|
| 440 |
+
'abs', 'access', 'after', 'alias', 'all', 'and',
|
| 441 |
+
'architecture', 'array', 'assert', 'attribute', 'begin', 'block',
|
| 442 |
+
'body', 'buffer', 'bus', 'case', 'component', 'configuration',
|
| 443 |
+
'constant', 'disconnect', 'downto', 'else', 'elsif', 'end',
|
| 444 |
+
'entity', 'exit', 'file', 'for', 'function', 'generate',
|
| 445 |
+
'generic', 'group', 'guarded', 'if', 'impure', 'in',
|
| 446 |
+
'inertial', 'inout', 'is', 'label', 'library', 'linkage',
|
| 447 |
+
'literal', 'loop', 'map', 'mod', 'nand', 'new',
|
| 448 |
+
'next', 'nor', 'not', 'null', 'of', 'on',
|
| 449 |
+
'open', 'or', 'others', 'out', 'package', 'port',
|
| 450 |
+
'postponed', 'procedure', 'process', 'pure', 'range', 'record',
|
| 451 |
+
'register', 'reject', 'rem', 'return', 'rol', 'ror', 'select',
|
| 452 |
+
'severity', 'signal', 'shared', 'sla', 'sll', 'sra',
|
| 453 |
+
'srl', 'subtype', 'then', 'to', 'transport', 'type',
|
| 454 |
+
'units', 'until', 'use', 'variable', 'wait', 'when',
|
| 455 |
+
'while', 'with', 'xnor', 'xor'), suffix=r'\b'),
|
| 456 |
+
Keyword),
|
| 457 |
+
],
|
| 458 |
+
'numbers': [
|
| 459 |
+
(r'\d{1,2}#[0-9a-f_]+#?', Number.Integer),
|
| 460 |
+
(r'\d+', Number.Integer),
|
| 461 |
+
(r'(\d+\.\d*|\.\d+|\d+)E[+-]?\d+', Number.Float),
|
| 462 |
+
(r'X"[0-9a-f_]+"', Number.Hex),
|
| 463 |
+
(r'O"[0-7_]+"', Number.Oct),
|
| 464 |
+
(r'B"[01_]+"', Number.Bin),
|
| 465 |
+
],
|
| 466 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/hexdump.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.hexdump
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for hexadecimal dumps.
|
| 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 Name, Number, String, Punctuation, Whitespace
|
| 13 |
+
|
| 14 |
+
__all__ = ['HexdumpLexer']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class HexdumpLexer(RegexLexer):
|
| 18 |
+
"""
|
| 19 |
+
For typical hex dump output formats by the UNIX and GNU/Linux tools ``hexdump``,
|
| 20 |
+
``hd``, ``hexcat``, ``od`` and ``xxd``, and the DOS tool ``DEBUG``. For example:
|
| 21 |
+
|
| 22 |
+
.. sourcecode:: hexdump
|
| 23 |
+
|
| 24 |
+
00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
|
| 25 |
+
00000010 02 00 3e 00 01 00 00 00 c5 48 40 00 00 00 00 00 |..>......H@.....|
|
| 26 |
+
|
| 27 |
+
The specific supported formats are the outputs of:
|
| 28 |
+
|
| 29 |
+
* ``hexdump FILE``
|
| 30 |
+
* ``hexdump -C FILE`` -- the `canonical` format used in the example.
|
| 31 |
+
* ``hd FILE`` -- same as ``hexdump -C FILE``.
|
| 32 |
+
* ``hexcat FILE``
|
| 33 |
+
* ``od -t x1z FILE``
|
| 34 |
+
* ``xxd FILE``
|
| 35 |
+
* ``DEBUG.EXE FILE.COM`` and entering ``d`` to the prompt.
|
| 36 |
+
"""
|
| 37 |
+
name = 'Hexdump'
|
| 38 |
+
aliases = ['hexdump']
|
| 39 |
+
url = 'https://en.wikipedia.org/wiki/Hex_dump'
|
| 40 |
+
version_added = '2.1'
|
| 41 |
+
|
| 42 |
+
hd = r'[0-9A-Ha-h]'
|
| 43 |
+
|
| 44 |
+
tokens = {
|
| 45 |
+
'root': [
|
| 46 |
+
(r'\n', Whitespace),
|
| 47 |
+
include('offset'),
|
| 48 |
+
(r'('+hd+r'{2})(\-)('+hd+r'{2})',
|
| 49 |
+
bygroups(Number.Hex, Punctuation, Number.Hex)),
|
| 50 |
+
(hd+r'{2}', Number.Hex),
|
| 51 |
+
(r'(\s{2,3})(\>)(.{16})(\<)$',
|
| 52 |
+
bygroups(Whitespace, Punctuation, String, Punctuation), 'bracket-strings'),
|
| 53 |
+
(r'(\s{2,3})(\|)(.{16})(\|)$',
|
| 54 |
+
bygroups(Whitespace, Punctuation, String, Punctuation), 'piped-strings'),
|
| 55 |
+
(r'(\s{2,3})(\>)(.{1,15})(\<)$',
|
| 56 |
+
bygroups(Whitespace, Punctuation, String, Punctuation)),
|
| 57 |
+
(r'(\s{2,3})(\|)(.{1,15})(\|)$',
|
| 58 |
+
bygroups(Whitespace, Punctuation, String, Punctuation)),
|
| 59 |
+
(r'(\s{2,3})(.{1,15})$', bygroups(Whitespace, String)),
|
| 60 |
+
(r'(\s{2,3})(.{16}|.{20})$', bygroups(Whitespace, String), 'nonpiped-strings'),
|
| 61 |
+
(r'\s', Whitespace),
|
| 62 |
+
(r'^\*', Punctuation),
|
| 63 |
+
],
|
| 64 |
+
'offset': [
|
| 65 |
+
(r'^('+hd+'+)(:)', bygroups(Name.Label, Punctuation), 'offset-mode'),
|
| 66 |
+
(r'^'+hd+'+', Name.Label),
|
| 67 |
+
],
|
| 68 |
+
'offset-mode': [
|
| 69 |
+
(r'\s', Whitespace, '#pop'),
|
| 70 |
+
(hd+'+', Name.Label),
|
| 71 |
+
(r':', Punctuation)
|
| 72 |
+
],
|
| 73 |
+
'piped-strings': [
|
| 74 |
+
(r'\n', Whitespace),
|
| 75 |
+
include('offset'),
|
| 76 |
+
(hd+r'{2}', Number.Hex),
|
| 77 |
+
(r'(\s{2,3})(\|)(.{1,16})(\|)$',
|
| 78 |
+
bygroups(Whitespace, Punctuation, String, Punctuation)),
|
| 79 |
+
(r'\s', Whitespace),
|
| 80 |
+
(r'^\*', Punctuation),
|
| 81 |
+
],
|
| 82 |
+
'bracket-strings': [
|
| 83 |
+
(r'\n', Whitespace),
|
| 84 |
+
include('offset'),
|
| 85 |
+
(hd+r'{2}', Number.Hex),
|
| 86 |
+
(r'(\s{2,3})(\>)(.{1,16})(\<)$',
|
| 87 |
+
bygroups(Whitespace, Punctuation, String, Punctuation)),
|
| 88 |
+
(r'\s', Whitespace),
|
| 89 |
+
(r'^\*', Punctuation),
|
| 90 |
+
],
|
| 91 |
+
'nonpiped-strings': [
|
| 92 |
+
(r'\n', Whitespace),
|
| 93 |
+
include('offset'),
|
| 94 |
+
(r'('+hd+r'{2})(\-)('+hd+r'{2})',
|
| 95 |
+
bygroups(Number.Hex, Punctuation, Number.Hex)),
|
| 96 |
+
(hd+r'{2}', Number.Hex),
|
| 97 |
+
(r'(\s{19,})(.{1,20}?)$', bygroups(Whitespace, String)),
|
| 98 |
+
(r'(\s{2,3})(.{1,20})$', bygroups(Whitespace, String)),
|
| 99 |
+
(r'\s', Whitespace),
|
| 100 |
+
(r'^\*', Punctuation),
|
| 101 |
+
],
|
| 102 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/html.py
ADDED
|
@@ -0,0 +1,670 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.html
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for HTML, XML and related markup.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import re
|
| 12 |
+
|
| 13 |
+
from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, bygroups, \
|
| 14 |
+
default, using, inherit, this
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Punctuation, Whitespace
|
| 17 |
+
from pygments.util import looks_like_xml, html_doctype_matches
|
| 18 |
+
|
| 19 |
+
from pygments.lexers.javascript import JavascriptLexer
|
| 20 |
+
from pygments.lexers.jvm import ScalaLexer
|
| 21 |
+
from pygments.lexers.css import CssLexer, _indentation, _starts_block
|
| 22 |
+
from pygments.lexers.ruby import RubyLexer
|
| 23 |
+
|
| 24 |
+
__all__ = ['HtmlLexer', 'DtdLexer', 'XmlLexer', 'XsltLexer', 'HamlLexer',
|
| 25 |
+
'ScamlLexer', 'PugLexer', 'VueLexer', 'UrlEncodedLexer']
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class HtmlLexer(RegexLexer):
|
| 29 |
+
"""
|
| 30 |
+
For HTML 4 and XHTML 1 markup. Nested JavaScript and CSS is highlighted
|
| 31 |
+
by the appropriate lexer.
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
name = 'HTML'
|
| 35 |
+
url = 'https://html.spec.whatwg.org/'
|
| 36 |
+
aliases = ['html']
|
| 37 |
+
filenames = ['*.html', '*.htm', '*.xhtml', '*.xslt']
|
| 38 |
+
mimetypes = ['text/html', 'application/xhtml+xml']
|
| 39 |
+
version_added = ''
|
| 40 |
+
|
| 41 |
+
flags = re.IGNORECASE | re.DOTALL
|
| 42 |
+
tokens = {
|
| 43 |
+
'root': [
|
| 44 |
+
('[^<&]+', Text),
|
| 45 |
+
(r'&\S*?;', Name.Entity),
|
| 46 |
+
(r'\<\!\[CDATA\[.*?\]\]\>', Comment.Preproc),
|
| 47 |
+
(r'<!--.*?-->', Comment.Multiline),
|
| 48 |
+
(r'<\?.*?\?>', Comment.Preproc),
|
| 49 |
+
('<![^>]*>', Comment.Preproc),
|
| 50 |
+
(r'(<)(\s*)(script)(\s*)',
|
| 51 |
+
bygroups(Punctuation, Text, Name.Tag, Text),
|
| 52 |
+
('script-content', 'tag')),
|
| 53 |
+
(r'(<)(\s*)(style)(\s*)',
|
| 54 |
+
bygroups(Punctuation, Text, Name.Tag, Text),
|
| 55 |
+
('style-content', 'tag')),
|
| 56 |
+
# note: this allows tag names not used in HTML like <x:with-dash>,
|
| 57 |
+
# this is to support yet-unknown template engines and the like
|
| 58 |
+
(r'(<)(\s*)([\w:.-]+)',
|
| 59 |
+
bygroups(Punctuation, Text, Name.Tag), 'tag'),
|
| 60 |
+
(r'(<)(\s*)(/)(\s*)([\w:.-]+)(\s*)(>)',
|
| 61 |
+
bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
|
| 62 |
+
Punctuation)),
|
| 63 |
+
],
|
| 64 |
+
'tag': [
|
| 65 |
+
(r'\s+', Text),
|
| 66 |
+
(r'([\w:-]+\s*)(=)(\s*)', bygroups(Name.Attribute, Operator, Text),
|
| 67 |
+
'attr'),
|
| 68 |
+
(r'[\w:-]+', Name.Attribute),
|
| 69 |
+
(r'(/?)(\s*)(>)', bygroups(Punctuation, Text, Punctuation), '#pop'),
|
| 70 |
+
],
|
| 71 |
+
'script-content': [
|
| 72 |
+
(r'(<)(\s*)(/)(\s*)(script)(\s*)(>)',
|
| 73 |
+
bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
|
| 74 |
+
Punctuation), '#pop'),
|
| 75 |
+
(r'.+?(?=<\s*/\s*script\s*>)', using(JavascriptLexer)),
|
| 76 |
+
# fallback cases for when there is no closing script tag
|
| 77 |
+
# first look for newline and then go back into root state
|
| 78 |
+
# if that fails just read the rest of the file
|
| 79 |
+
# this is similar to the error handling logic in lexer.py
|
| 80 |
+
(r'.+?\n', using(JavascriptLexer), '#pop'),
|
| 81 |
+
(r'.+', using(JavascriptLexer), '#pop'),
|
| 82 |
+
],
|
| 83 |
+
'style-content': [
|
| 84 |
+
(r'(<)(\s*)(/)(\s*)(style)(\s*)(>)',
|
| 85 |
+
bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
|
| 86 |
+
Punctuation),'#pop'),
|
| 87 |
+
(r'.+?(?=<\s*/\s*style\s*>)', using(CssLexer)),
|
| 88 |
+
# fallback cases for when there is no closing style tag
|
| 89 |
+
# first look for newline and then go back into root state
|
| 90 |
+
# if that fails just read the rest of the file
|
| 91 |
+
# this is similar to the error handling logic in lexer.py
|
| 92 |
+
(r'.+?\n', using(CssLexer), '#pop'),
|
| 93 |
+
(r'.+', using(CssLexer), '#pop'),
|
| 94 |
+
],
|
| 95 |
+
'attr': [
|
| 96 |
+
('".*?"', String, '#pop'),
|
| 97 |
+
("'.*?'", String, '#pop'),
|
| 98 |
+
(r'[^\s>]+', String, '#pop'),
|
| 99 |
+
],
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
def analyse_text(text):
|
| 103 |
+
if html_doctype_matches(text):
|
| 104 |
+
return 0.5
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
class DtdLexer(RegexLexer):
|
| 108 |
+
"""
|
| 109 |
+
A lexer for DTDs (Document Type Definitions).
|
| 110 |
+
"""
|
| 111 |
+
|
| 112 |
+
flags = re.MULTILINE | re.DOTALL
|
| 113 |
+
|
| 114 |
+
name = 'DTD'
|
| 115 |
+
aliases = ['dtd']
|
| 116 |
+
filenames = ['*.dtd']
|
| 117 |
+
mimetypes = ['application/xml-dtd']
|
| 118 |
+
url = 'https://en.wikipedia.org/wiki/Document_type_definition'
|
| 119 |
+
version_added = '1.5'
|
| 120 |
+
|
| 121 |
+
tokens = {
|
| 122 |
+
'root': [
|
| 123 |
+
include('common'),
|
| 124 |
+
|
| 125 |
+
(r'(<!ELEMENT)(\s+)(\S+)',
|
| 126 |
+
bygroups(Keyword, Text, Name.Tag), 'element'),
|
| 127 |
+
(r'(<!ATTLIST)(\s+)(\S+)',
|
| 128 |
+
bygroups(Keyword, Text, Name.Tag), 'attlist'),
|
| 129 |
+
(r'(<!ENTITY)(\s+)(\S+)',
|
| 130 |
+
bygroups(Keyword, Text, Name.Entity), 'entity'),
|
| 131 |
+
(r'(<!NOTATION)(\s+)(\S+)',
|
| 132 |
+
bygroups(Keyword, Text, Name.Tag), 'notation'),
|
| 133 |
+
(r'(<!\[)([^\[\s]+)(\s*)(\[)', # conditional sections
|
| 134 |
+
bygroups(Keyword, Name.Entity, Text, Keyword)),
|
| 135 |
+
|
| 136 |
+
(r'(<!DOCTYPE)(\s+)([^>\s]+)',
|
| 137 |
+
bygroups(Keyword, Text, Name.Tag)),
|
| 138 |
+
(r'PUBLIC|SYSTEM', Keyword.Constant),
|
| 139 |
+
(r'[\[\]>]', Keyword),
|
| 140 |
+
],
|
| 141 |
+
|
| 142 |
+
'common': [
|
| 143 |
+
(r'\s+', Text),
|
| 144 |
+
(r'(%|&)[^;]*;', Name.Entity),
|
| 145 |
+
('<!--', Comment, 'comment'),
|
| 146 |
+
(r'[(|)*,?+]', Operator),
|
| 147 |
+
(r'"[^"]*"', String.Double),
|
| 148 |
+
(r'\'[^\']*\'', String.Single),
|
| 149 |
+
],
|
| 150 |
+
|
| 151 |
+
'comment': [
|
| 152 |
+
('[^-]+', Comment),
|
| 153 |
+
('-->', Comment, '#pop'),
|
| 154 |
+
('-', Comment),
|
| 155 |
+
],
|
| 156 |
+
|
| 157 |
+
'element': [
|
| 158 |
+
include('common'),
|
| 159 |
+
(r'EMPTY|ANY|#PCDATA', Keyword.Constant),
|
| 160 |
+
(r'[^>\s|()?+*,]+', Name.Tag),
|
| 161 |
+
(r'>', Keyword, '#pop'),
|
| 162 |
+
],
|
| 163 |
+
|
| 164 |
+
'attlist': [
|
| 165 |
+
include('common'),
|
| 166 |
+
(r'CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION',
|
| 167 |
+
Keyword.Constant),
|
| 168 |
+
(r'#REQUIRED|#IMPLIED|#FIXED', Keyword.Constant),
|
| 169 |
+
(r'xml:space|xml:lang', Keyword.Reserved),
|
| 170 |
+
(r'[^>\s|()?+*,]+', Name.Attribute),
|
| 171 |
+
(r'>', Keyword, '#pop'),
|
| 172 |
+
],
|
| 173 |
+
|
| 174 |
+
'entity': [
|
| 175 |
+
include('common'),
|
| 176 |
+
(r'SYSTEM|PUBLIC|NDATA', Keyword.Constant),
|
| 177 |
+
(r'[^>\s|()?+*,]+', Name.Entity),
|
| 178 |
+
(r'>', Keyword, '#pop'),
|
| 179 |
+
],
|
| 180 |
+
|
| 181 |
+
'notation': [
|
| 182 |
+
include('common'),
|
| 183 |
+
(r'SYSTEM|PUBLIC', Keyword.Constant),
|
| 184 |
+
(r'[^>\s|()?+*,]+', Name.Attribute),
|
| 185 |
+
(r'>', Keyword, '#pop'),
|
| 186 |
+
],
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
def analyse_text(text):
|
| 190 |
+
if not looks_like_xml(text) and \
|
| 191 |
+
('<!ELEMENT' in text or '<!ATTLIST' in text or '<!ENTITY' in text):
|
| 192 |
+
return 0.8
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
class XmlLexer(RegexLexer):
|
| 196 |
+
"""
|
| 197 |
+
Generic lexer for XML (eXtensible Markup Language).
|
| 198 |
+
"""
|
| 199 |
+
|
| 200 |
+
flags = re.MULTILINE | re.DOTALL
|
| 201 |
+
|
| 202 |
+
name = 'XML'
|
| 203 |
+
aliases = ['xml']
|
| 204 |
+
filenames = ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd',
|
| 205 |
+
'*.wsdl', '*.wsf', '*.xbrl', '*.pom']
|
| 206 |
+
mimetypes = ['text/xml', 'application/xml', 'image/svg+xml',
|
| 207 |
+
'application/rss+xml', 'application/atom+xml']
|
| 208 |
+
url = 'https://www.w3.org/XML'
|
| 209 |
+
version_added = ''
|
| 210 |
+
|
| 211 |
+
tokens = {
|
| 212 |
+
'root': [
|
| 213 |
+
(r'[^<&\s]+', Text),
|
| 214 |
+
(r'[^<&\S]+', Whitespace),
|
| 215 |
+
(r'&\S*?;', Name.Entity),
|
| 216 |
+
(r'\<\!\[CDATA\[.*?\]\]\>', Comment.Preproc),
|
| 217 |
+
(r'<!--.*?-->', Comment.Multiline),
|
| 218 |
+
(r'<\?.*?\?>', Comment.Preproc),
|
| 219 |
+
('<![^>]*>', Comment.Preproc),
|
| 220 |
+
(r'<\s*[\w:.-]+', Name.Tag, 'tag'),
|
| 221 |
+
(r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
|
| 222 |
+
],
|
| 223 |
+
'tag': [
|
| 224 |
+
(r'\s+', Whitespace),
|
| 225 |
+
(r'[\w.:-]+\s*=', Name.Attribute, 'attr'),
|
| 226 |
+
(r'/?\s*>', Name.Tag, '#pop'),
|
| 227 |
+
],
|
| 228 |
+
'attr': [
|
| 229 |
+
(r'\s+', Whitespace),
|
| 230 |
+
('".*?"', String, '#pop'),
|
| 231 |
+
("'.*?'", String, '#pop'),
|
| 232 |
+
(r'[^\s>]+', String, '#pop'),
|
| 233 |
+
],
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
def analyse_text(text):
|
| 237 |
+
if looks_like_xml(text):
|
| 238 |
+
return 0.45 # less than HTML
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
class XsltLexer(XmlLexer):
|
| 242 |
+
"""
|
| 243 |
+
A lexer for XSLT.
|
| 244 |
+
"""
|
| 245 |
+
|
| 246 |
+
name = 'XSLT'
|
| 247 |
+
aliases = ['xslt']
|
| 248 |
+
filenames = ['*.xsl', '*.xslt', '*.xpl'] # xpl is XProc
|
| 249 |
+
mimetypes = ['application/xsl+xml', 'application/xslt+xml']
|
| 250 |
+
url = 'https://www.w3.org/TR/xslt-30'
|
| 251 |
+
version_added = '0.10'
|
| 252 |
+
|
| 253 |
+
EXTRA_KEYWORDS = {
|
| 254 |
+
'apply-imports', 'apply-templates', 'attribute',
|
| 255 |
+
'attribute-set', 'call-template', 'choose', 'comment',
|
| 256 |
+
'copy', 'copy-of', 'decimal-format', 'element', 'fallback',
|
| 257 |
+
'for-each', 'if', 'import', 'include', 'key', 'message',
|
| 258 |
+
'namespace-alias', 'number', 'otherwise', 'output', 'param',
|
| 259 |
+
'preserve-space', 'processing-instruction', 'sort',
|
| 260 |
+
'strip-space', 'stylesheet', 'template', 'text', 'transform',
|
| 261 |
+
'value-of', 'variable', 'when', 'with-param'
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
def get_tokens_unprocessed(self, text):
|
| 265 |
+
for index, token, value in XmlLexer.get_tokens_unprocessed(self, text):
|
| 266 |
+
m = re.match('</?xsl:([^>]*)/?>?', value)
|
| 267 |
+
|
| 268 |
+
if token is Name.Tag and m and m.group(1) in self.EXTRA_KEYWORDS:
|
| 269 |
+
yield index, Keyword, value
|
| 270 |
+
else:
|
| 271 |
+
yield index, token, value
|
| 272 |
+
|
| 273 |
+
def analyse_text(text):
|
| 274 |
+
if looks_like_xml(text) and '<xsl' in text:
|
| 275 |
+
return 0.8
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
class HamlLexer(ExtendedRegexLexer):
|
| 279 |
+
"""
|
| 280 |
+
For Haml markup.
|
| 281 |
+
"""
|
| 282 |
+
|
| 283 |
+
name = 'Haml'
|
| 284 |
+
aliases = ['haml']
|
| 285 |
+
filenames = ['*.haml']
|
| 286 |
+
mimetypes = ['text/x-haml']
|
| 287 |
+
url = 'https://haml.info'
|
| 288 |
+
version_added = '1.3'
|
| 289 |
+
|
| 290 |
+
flags = re.IGNORECASE
|
| 291 |
+
# Haml can include " |\n" anywhere,
|
| 292 |
+
# which is ignored and used to wrap long lines.
|
| 293 |
+
# To accommodate this, use this custom faux dot instead.
|
| 294 |
+
_dot = r'(?: \|\n(?=.* \|)|.)'
|
| 295 |
+
|
| 296 |
+
# In certain places, a comma at the end of the line
|
| 297 |
+
# allows line wrapping as well.
|
| 298 |
+
_comma_dot = r'(?:,\s*\n|' + _dot + ')'
|
| 299 |
+
tokens = {
|
| 300 |
+
'root': [
|
| 301 |
+
(r'[ \t]*\n', Text),
|
| 302 |
+
(r'[ \t]*', _indentation),
|
| 303 |
+
],
|
| 304 |
+
|
| 305 |
+
'css': [
|
| 306 |
+
(r'\.[\w:-]+', Name.Class, 'tag'),
|
| 307 |
+
(r'\#[\w:-]+', Name.Function, 'tag'),
|
| 308 |
+
],
|
| 309 |
+
|
| 310 |
+
'eval-or-plain': [
|
| 311 |
+
(r'[&!]?==', Punctuation, 'plain'),
|
| 312 |
+
(r'([&!]?[=~])(' + _comma_dot + r'*\n)',
|
| 313 |
+
bygroups(Punctuation, using(RubyLexer)),
|
| 314 |
+
'root'),
|
| 315 |
+
default('plain'),
|
| 316 |
+
],
|
| 317 |
+
|
| 318 |
+
'content': [
|
| 319 |
+
include('css'),
|
| 320 |
+
(r'%[\w:-]+', Name.Tag, 'tag'),
|
| 321 |
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
| 322 |
+
(r'(/)(\[' + _dot + r'*?\])(' + _dot + r'*\n)',
|
| 323 |
+
bygroups(Comment, Comment.Special, Comment),
|
| 324 |
+
'#pop'),
|
| 325 |
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
| 326 |
+
'#pop'),
|
| 327 |
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
| 328 |
+
'haml-comment-block'), '#pop'),
|
| 329 |
+
(r'(-)(' + _comma_dot + r'*\n)',
|
| 330 |
+
bygroups(Punctuation, using(RubyLexer)),
|
| 331 |
+
'#pop'),
|
| 332 |
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
| 333 |
+
'#pop'),
|
| 334 |
+
include('eval-or-plain'),
|
| 335 |
+
],
|
| 336 |
+
|
| 337 |
+
'tag': [
|
| 338 |
+
include('css'),
|
| 339 |
+
(r'\{(,\n|' + _dot + r')*?\}', using(RubyLexer)),
|
| 340 |
+
(r'\[' + _dot + r'*?\]', using(RubyLexer)),
|
| 341 |
+
(r'\(', Text, 'html-attributes'),
|
| 342 |
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
| 343 |
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
| 344 |
+
include('eval-or-plain'),
|
| 345 |
+
],
|
| 346 |
+
|
| 347 |
+
'plain': [
|
| 348 |
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
| 349 |
+
(r'(#\{)(' + _dot + r'*?)(\})',
|
| 350 |
+
bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
|
| 351 |
+
(r'\n', Text, 'root'),
|
| 352 |
+
],
|
| 353 |
+
|
| 354 |
+
'html-attributes': [
|
| 355 |
+
(r'\s+', Text),
|
| 356 |
+
(r'[\w:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
| 357 |
+
(r'[\w:-]+', Name.Attribute),
|
| 358 |
+
(r'\)', Text, '#pop'),
|
| 359 |
+
],
|
| 360 |
+
|
| 361 |
+
'html-attribute-value': [
|
| 362 |
+
(r'[ \t]+', Text),
|
| 363 |
+
(r'\w+', Name.Variable, '#pop'),
|
| 364 |
+
(r'@\w+', Name.Variable.Instance, '#pop'),
|
| 365 |
+
(r'\$\w+', Name.Variable.Global, '#pop'),
|
| 366 |
+
(r"'(\\\\|\\[^\\]|[^'\\\n])*'", String, '#pop'),
|
| 367 |
+
(r'"(\\\\|\\[^\\]|[^"\\\n])*"', String, '#pop'),
|
| 368 |
+
],
|
| 369 |
+
|
| 370 |
+
'html-comment-block': [
|
| 371 |
+
(_dot + '+', Comment),
|
| 372 |
+
(r'\n', Text, 'root'),
|
| 373 |
+
],
|
| 374 |
+
|
| 375 |
+
'haml-comment-block': [
|
| 376 |
+
(_dot + '+', Comment.Preproc),
|
| 377 |
+
(r'\n', Text, 'root'),
|
| 378 |
+
],
|
| 379 |
+
|
| 380 |
+
'filter-block': [
|
| 381 |
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
| 382 |
+
(r'(#\{)(' + _dot + r'*?)(\})',
|
| 383 |
+
bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
|
| 384 |
+
(r'\n', Text, 'root'),
|
| 385 |
+
],
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
class ScamlLexer(ExtendedRegexLexer):
|
| 390 |
+
"""
|
| 391 |
+
For Scaml markup. Scaml is Haml for Scala.
|
| 392 |
+
"""
|
| 393 |
+
|
| 394 |
+
name = 'Scaml'
|
| 395 |
+
aliases = ['scaml']
|
| 396 |
+
filenames = ['*.scaml']
|
| 397 |
+
mimetypes = ['text/x-scaml']
|
| 398 |
+
url = 'https://scalate.github.io/scalate/'
|
| 399 |
+
version_added = '1.4'
|
| 400 |
+
|
| 401 |
+
flags = re.IGNORECASE
|
| 402 |
+
# Scaml does not yet support the " |\n" notation to
|
| 403 |
+
# wrap long lines. Once it does, use the custom faux
|
| 404 |
+
# dot instead.
|
| 405 |
+
# _dot = r'(?: \|\n(?=.* \|)|.)'
|
| 406 |
+
_dot = r'.'
|
| 407 |
+
|
| 408 |
+
tokens = {
|
| 409 |
+
'root': [
|
| 410 |
+
(r'[ \t]*\n', Text),
|
| 411 |
+
(r'[ \t]*', _indentation),
|
| 412 |
+
],
|
| 413 |
+
|
| 414 |
+
'css': [
|
| 415 |
+
(r'\.[\w:-]+', Name.Class, 'tag'),
|
| 416 |
+
(r'\#[\w:-]+', Name.Function, 'tag'),
|
| 417 |
+
],
|
| 418 |
+
|
| 419 |
+
'eval-or-plain': [
|
| 420 |
+
(r'[&!]?==', Punctuation, 'plain'),
|
| 421 |
+
(r'([&!]?[=~])(' + _dot + r'*\n)',
|
| 422 |
+
bygroups(Punctuation, using(ScalaLexer)),
|
| 423 |
+
'root'),
|
| 424 |
+
default('plain'),
|
| 425 |
+
],
|
| 426 |
+
|
| 427 |
+
'content': [
|
| 428 |
+
include('css'),
|
| 429 |
+
(r'%[\w:-]+', Name.Tag, 'tag'),
|
| 430 |
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
| 431 |
+
(r'(/)(\[' + _dot + r'*?\])(' + _dot + r'*\n)',
|
| 432 |
+
bygroups(Comment, Comment.Special, Comment),
|
| 433 |
+
'#pop'),
|
| 434 |
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
| 435 |
+
'#pop'),
|
| 436 |
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
| 437 |
+
'scaml-comment-block'), '#pop'),
|
| 438 |
+
(r'(-@\s*)(import)?(' + _dot + r'*\n)',
|
| 439 |
+
bygroups(Punctuation, Keyword, using(ScalaLexer)),
|
| 440 |
+
'#pop'),
|
| 441 |
+
(r'(-)(' + _dot + r'*\n)',
|
| 442 |
+
bygroups(Punctuation, using(ScalaLexer)),
|
| 443 |
+
'#pop'),
|
| 444 |
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
| 445 |
+
'#pop'),
|
| 446 |
+
include('eval-or-plain'),
|
| 447 |
+
],
|
| 448 |
+
|
| 449 |
+
'tag': [
|
| 450 |
+
include('css'),
|
| 451 |
+
(r'\{(,\n|' + _dot + r')*?\}', using(ScalaLexer)),
|
| 452 |
+
(r'\[' + _dot + r'*?\]', using(ScalaLexer)),
|
| 453 |
+
(r'\(', Text, 'html-attributes'),
|
| 454 |
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
| 455 |
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
| 456 |
+
include('eval-or-plain'),
|
| 457 |
+
],
|
| 458 |
+
|
| 459 |
+
'plain': [
|
| 460 |
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
| 461 |
+
(r'(#\{)(' + _dot + r'*?)(\})',
|
| 462 |
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
| 463 |
+
(r'\n', Text, 'root'),
|
| 464 |
+
],
|
| 465 |
+
|
| 466 |
+
'html-attributes': [
|
| 467 |
+
(r'\s+', Text),
|
| 468 |
+
(r'[\w:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
| 469 |
+
(r'[\w:-]+', Name.Attribute),
|
| 470 |
+
(r'\)', Text, '#pop'),
|
| 471 |
+
],
|
| 472 |
+
|
| 473 |
+
'html-attribute-value': [
|
| 474 |
+
(r'[ \t]+', Text),
|
| 475 |
+
(r'\w+', Name.Variable, '#pop'),
|
| 476 |
+
(r'@\w+', Name.Variable.Instance, '#pop'),
|
| 477 |
+
(r'\$\w+', Name.Variable.Global, '#pop'),
|
| 478 |
+
(r"'(\\\\|\\[^\\]|[^'\\\n])*'", String, '#pop'),
|
| 479 |
+
(r'"(\\\\|\\[^\\]|[^"\\\n])*"', String, '#pop'),
|
| 480 |
+
],
|
| 481 |
+
|
| 482 |
+
'html-comment-block': [
|
| 483 |
+
(_dot + '+', Comment),
|
| 484 |
+
(r'\n', Text, 'root'),
|
| 485 |
+
],
|
| 486 |
+
|
| 487 |
+
'scaml-comment-block': [
|
| 488 |
+
(_dot + '+', Comment.Preproc),
|
| 489 |
+
(r'\n', Text, 'root'),
|
| 490 |
+
],
|
| 491 |
+
|
| 492 |
+
'filter-block': [
|
| 493 |
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
| 494 |
+
(r'(#\{)(' + _dot + r'*?)(\})',
|
| 495 |
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
| 496 |
+
(r'\n', Text, 'root'),
|
| 497 |
+
],
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
class PugLexer(ExtendedRegexLexer):
|
| 502 |
+
"""
|
| 503 |
+
For Pug markup.
|
| 504 |
+
Pug is a variant of Scaml, see:
|
| 505 |
+
http://scalate.fusesource.org/documentation/scaml-reference.html
|
| 506 |
+
"""
|
| 507 |
+
|
| 508 |
+
name = 'Pug'
|
| 509 |
+
aliases = ['pug', 'jade']
|
| 510 |
+
filenames = ['*.pug', '*.jade']
|
| 511 |
+
mimetypes = ['text/x-pug', 'text/x-jade']
|
| 512 |
+
url = 'https://pugjs.org'
|
| 513 |
+
version_added = '1.4'
|
| 514 |
+
|
| 515 |
+
flags = re.IGNORECASE
|
| 516 |
+
_dot = r'.'
|
| 517 |
+
|
| 518 |
+
tokens = {
|
| 519 |
+
'root': [
|
| 520 |
+
(r'[ \t]*\n', Text),
|
| 521 |
+
(r'[ \t]*', _indentation),
|
| 522 |
+
],
|
| 523 |
+
|
| 524 |
+
'css': [
|
| 525 |
+
(r'\.[\w:-]+', Name.Class, 'tag'),
|
| 526 |
+
(r'\#[\w:-]+', Name.Function, 'tag'),
|
| 527 |
+
],
|
| 528 |
+
|
| 529 |
+
'eval-or-plain': [
|
| 530 |
+
(r'[&!]?==', Punctuation, 'plain'),
|
| 531 |
+
(r'([&!]?[=~])(' + _dot + r'*\n)',
|
| 532 |
+
bygroups(Punctuation, using(ScalaLexer)), 'root'),
|
| 533 |
+
default('plain'),
|
| 534 |
+
],
|
| 535 |
+
|
| 536 |
+
'content': [
|
| 537 |
+
include('css'),
|
| 538 |
+
(r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'),
|
| 539 |
+
(r'(/)(\[' + _dot + r'*?\])(' + _dot + r'*\n)',
|
| 540 |
+
bygroups(Comment, Comment.Special, Comment),
|
| 541 |
+
'#pop'),
|
| 542 |
+
(r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'),
|
| 543 |
+
'#pop'),
|
| 544 |
+
(r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc,
|
| 545 |
+
'scaml-comment-block'), '#pop'),
|
| 546 |
+
(r'(-@\s*)(import)?(' + _dot + r'*\n)',
|
| 547 |
+
bygroups(Punctuation, Keyword, using(ScalaLexer)),
|
| 548 |
+
'#pop'),
|
| 549 |
+
(r'(-)(' + _dot + r'*\n)',
|
| 550 |
+
bygroups(Punctuation, using(ScalaLexer)),
|
| 551 |
+
'#pop'),
|
| 552 |
+
(r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'),
|
| 553 |
+
'#pop'),
|
| 554 |
+
(r'[\w:-]+', Name.Tag, 'tag'),
|
| 555 |
+
(r'\|', Text, 'eval-or-plain'),
|
| 556 |
+
],
|
| 557 |
+
|
| 558 |
+
'tag': [
|
| 559 |
+
include('css'),
|
| 560 |
+
(r'\{(,\n|' + _dot + r')*?\}', using(ScalaLexer)),
|
| 561 |
+
(r'\[' + _dot + r'*?\]', using(ScalaLexer)),
|
| 562 |
+
(r'\(', Text, 'html-attributes'),
|
| 563 |
+
(r'/[ \t]*\n', Punctuation, '#pop:2'),
|
| 564 |
+
(r'[<>]{1,2}(?=[ \t=])', Punctuation),
|
| 565 |
+
include('eval-or-plain'),
|
| 566 |
+
],
|
| 567 |
+
|
| 568 |
+
'plain': [
|
| 569 |
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
|
| 570 |
+
(r'(#\{)(' + _dot + r'*?)(\})',
|
| 571 |
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
| 572 |
+
(r'\n', Text, 'root'),
|
| 573 |
+
],
|
| 574 |
+
|
| 575 |
+
'html-attributes': [
|
| 576 |
+
(r'\s+', Text),
|
| 577 |
+
(r'[\w:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'),
|
| 578 |
+
(r'[\w:-]+', Name.Attribute),
|
| 579 |
+
(r'\)', Text, '#pop'),
|
| 580 |
+
],
|
| 581 |
+
|
| 582 |
+
'html-attribute-value': [
|
| 583 |
+
(r'[ \t]+', Text),
|
| 584 |
+
(r'\w+', Name.Variable, '#pop'),
|
| 585 |
+
(r'@\w+', Name.Variable.Instance, '#pop'),
|
| 586 |
+
(r'\$\w+', Name.Variable.Global, '#pop'),
|
| 587 |
+
(r"'(\\\\|\\[^\\]|[^'\\\n])*'", String, '#pop'),
|
| 588 |
+
(r'"(\\\\|\\[^\\]|[^"\\\n])*"', String, '#pop'),
|
| 589 |
+
],
|
| 590 |
+
|
| 591 |
+
'html-comment-block': [
|
| 592 |
+
(_dot + '+', Comment),
|
| 593 |
+
(r'\n', Text, 'root'),
|
| 594 |
+
],
|
| 595 |
+
|
| 596 |
+
'scaml-comment-block': [
|
| 597 |
+
(_dot + '+', Comment.Preproc),
|
| 598 |
+
(r'\n', Text, 'root'),
|
| 599 |
+
],
|
| 600 |
+
|
| 601 |
+
'filter-block': [
|
| 602 |
+
(r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator),
|
| 603 |
+
(r'(#\{)(' + _dot + r'*?)(\})',
|
| 604 |
+
bygroups(String.Interpol, using(ScalaLexer), String.Interpol)),
|
| 605 |
+
(r'\n', Text, 'root'),
|
| 606 |
+
],
|
| 607 |
+
}
|
| 608 |
+
JadeLexer = PugLexer # compat
|
| 609 |
+
|
| 610 |
+
|
| 611 |
+
class UrlEncodedLexer(RegexLexer):
|
| 612 |
+
"""
|
| 613 |
+
Lexer for urlencoded data
|
| 614 |
+
"""
|
| 615 |
+
|
| 616 |
+
name = 'urlencoded'
|
| 617 |
+
aliases = ['urlencoded']
|
| 618 |
+
mimetypes = ['application/x-www-form-urlencoded']
|
| 619 |
+
url = 'https://en.wikipedia.org/wiki/Percent-encoding'
|
| 620 |
+
version_added = '2.16'
|
| 621 |
+
|
| 622 |
+
tokens = {
|
| 623 |
+
'root': [
|
| 624 |
+
('([^&=]*)(=)([^=&]*)(&?)', bygroups(Name.Tag, Operator, String, Punctuation)),
|
| 625 |
+
],
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
class VueLexer(HtmlLexer):
|
| 630 |
+
"""
|
| 631 |
+
For Vue Single-File Component.
|
| 632 |
+
"""
|
| 633 |
+
|
| 634 |
+
name = 'Vue'
|
| 635 |
+
url = 'https://vuejs.org/api/sfc-spec.html'
|
| 636 |
+
aliases = ['vue']
|
| 637 |
+
filenames = ['*.vue']
|
| 638 |
+
mimetypes = []
|
| 639 |
+
version_added = '2.19'
|
| 640 |
+
|
| 641 |
+
flags = re.IGNORECASE | re.DOTALL
|
| 642 |
+
tokens = {
|
| 643 |
+
'root': [
|
| 644 |
+
(r'(\{\{)(.*?)(\}\})', bygroups(Comment.Preproc,
|
| 645 |
+
using(JavascriptLexer), Comment.Preproc)),
|
| 646 |
+
('[^<&{]+', Text),
|
| 647 |
+
inherit,
|
| 648 |
+
],
|
| 649 |
+
'tag': [
|
| 650 |
+
(r'\s+', Text),
|
| 651 |
+
(r'((?:[@:]|v-)(?:[.\w:-]|\[[^\]]*?\])+\s*)(=)(\s*)',
|
| 652 |
+
bygroups(using(this, state=['name']), Operator, Text),
|
| 653 |
+
'attr-directive'),
|
| 654 |
+
(r'([\w:-]+\s*)(=)(\s*)', bygroups(Name.Attribute, Operator, Text),
|
| 655 |
+
'attr'),
|
| 656 |
+
(r'[\w:-]+', Name.Attribute),
|
| 657 |
+
(r'(/?)(\s*)(>)', bygroups(Punctuation, Text, Punctuation), '#pop'),
|
| 658 |
+
],
|
| 659 |
+
'name': [
|
| 660 |
+
(r'[\w-]+', Name.Attribute),
|
| 661 |
+
(r'[:@.]', Punctuation),
|
| 662 |
+
(r'(\[)([^\]]*?)(\])', bygroups(Comment.Preproc,
|
| 663 |
+
using(JavascriptLexer), Comment.Preproc)),
|
| 664 |
+
],
|
| 665 |
+
'attr-directive': [
|
| 666 |
+
(r'(["\'])(.*?)(\1)', bygroups(String,
|
| 667 |
+
using(JavascriptLexer), String), '#pop'),
|
| 668 |
+
(r'[^\s>]+', using(JavascriptLexer), '#pop'),
|
| 669 |
+
],
|
| 670 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/idl.py
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.idl
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for IDL.
|
| 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, bygroups
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, Number, \
|
| 15 |
+
String, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['IDLLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class IDLLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Pygments Lexer for IDL (Interactive Data Language).
|
| 23 |
+
"""
|
| 24 |
+
name = 'IDL'
|
| 25 |
+
url = 'https://www.l3harrisgeospatial.com/Software-Technology/IDL'
|
| 26 |
+
aliases = ['idl']
|
| 27 |
+
filenames = ['*.pro']
|
| 28 |
+
mimetypes = ['text/idl']
|
| 29 |
+
version_added = '1.6'
|
| 30 |
+
|
| 31 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 32 |
+
|
| 33 |
+
_RESERVED = (
|
| 34 |
+
'and', 'begin', 'break', 'case', 'common', 'compile_opt',
|
| 35 |
+
'continue', 'do', 'else', 'end', 'endcase', 'endelse',
|
| 36 |
+
'endfor', 'endforeach', 'endif', 'endrep', 'endswitch',
|
| 37 |
+
'endwhile', 'eq', 'for', 'foreach', 'forward_function',
|
| 38 |
+
'function', 'ge', 'goto', 'gt', 'if', 'inherits', 'le',
|
| 39 |
+
'lt', 'mod', 'ne', 'not', 'of', 'on_ioerror', 'or', 'pro',
|
| 40 |
+
'repeat', 'switch', 'then', 'until', 'while', 'xor')
|
| 41 |
+
"""Reserved words from: http://www.exelisvis.com/docs/reswords.html"""
|
| 42 |
+
|
| 43 |
+
_BUILTIN_LIB = (
|
| 44 |
+
'abs', 'acos', 'adapt_hist_equal', 'alog', 'alog10',
|
| 45 |
+
'amoeba', 'annotate', 'app_user_dir', 'app_user_dir_query',
|
| 46 |
+
'arg_present', 'array_equal', 'array_indices', 'arrow',
|
| 47 |
+
'ascii_template', 'asin', 'assoc', 'atan', 'axis',
|
| 48 |
+
'a_correlate', 'bandpass_filter', 'bandreject_filter',
|
| 49 |
+
'barplot', 'bar_plot', 'beseli', 'beselj', 'beselk',
|
| 50 |
+
'besely', 'beta', 'bilinear', 'binary_template', 'bindgen',
|
| 51 |
+
'binomial', 'bin_date', 'bit_ffs', 'bit_population',
|
| 52 |
+
'blas_axpy', 'blk_con', 'box_cursor', 'breakpoint',
|
| 53 |
+
'broyden', 'butterworth', 'bytarr', 'byte', 'byteorder',
|
| 54 |
+
'bytscl', 'caldat', 'calendar', 'call_external',
|
| 55 |
+
'call_function', 'call_method', 'call_procedure', 'canny',
|
| 56 |
+
'catch', 'cd', r'cdf_\w*', 'ceil', 'chebyshev',
|
| 57 |
+
'check_math',
|
| 58 |
+
'chisqr_cvf', 'chisqr_pdf', 'choldc', 'cholsol', 'cindgen',
|
| 59 |
+
'cir_3pnt', 'close', 'cluster', 'cluster_tree', 'clust_wts',
|
| 60 |
+
'cmyk_convert', 'colorbar', 'colorize_sample',
|
| 61 |
+
'colormap_applicable', 'colormap_gradient',
|
| 62 |
+
'colormap_rotation', 'colortable', 'color_convert',
|
| 63 |
+
'color_exchange', 'color_quan', 'color_range_map', 'comfit',
|
| 64 |
+
'command_line_args', 'complex', 'complexarr', 'complexround',
|
| 65 |
+
'compute_mesh_normals', 'cond', 'congrid', 'conj',
|
| 66 |
+
'constrained_min', 'contour', 'convert_coord', 'convol',
|
| 67 |
+
'convol_fft', 'coord2to3', 'copy_lun', 'correlate', 'cos',
|
| 68 |
+
'cosh', 'cpu', 'cramer', 'create_cursor', 'create_struct',
|
| 69 |
+
'create_view', 'crossp', 'crvlength', 'cti_test',
|
| 70 |
+
'ct_luminance', 'cursor', 'curvefit', 'cvttobm', 'cv_coord',
|
| 71 |
+
'cw_animate', 'cw_animate_getp', 'cw_animate_load',
|
| 72 |
+
'cw_animate_run', 'cw_arcball', 'cw_bgroup', 'cw_clr_index',
|
| 73 |
+
'cw_colorsel', 'cw_defroi', 'cw_field', 'cw_filesel',
|
| 74 |
+
'cw_form', 'cw_fslider', 'cw_light_editor',
|
| 75 |
+
'cw_light_editor_get', 'cw_light_editor_set', 'cw_orient',
|
| 76 |
+
'cw_palette_editor', 'cw_palette_editor_get',
|
| 77 |
+
'cw_palette_editor_set', 'cw_pdmenu', 'cw_rgbslider',
|
| 78 |
+
'cw_tmpl', 'cw_zoom', 'c_correlate', 'dblarr', 'db_exists',
|
| 79 |
+
'dcindgen', 'dcomplex', 'dcomplexarr', 'define_key',
|
| 80 |
+
'define_msgblk', 'define_msgblk_from_file', 'defroi',
|
| 81 |
+
'defsysv', 'delvar', 'dendrogram', 'dendro_plot', 'deriv',
|
| 82 |
+
'derivsig', 'determ', 'device', 'dfpmin', 'diag_matrix',
|
| 83 |
+
'dialog_dbconnect', 'dialog_message', 'dialog_pickfile',
|
| 84 |
+
'dialog_printersetup', 'dialog_printjob',
|
| 85 |
+
'dialog_read_image', 'dialog_write_image', 'digital_filter',
|
| 86 |
+
'dilate', 'dindgen', 'dissolve', 'dist', 'distance_measure',
|
| 87 |
+
'dlm_load', 'dlm_register', 'doc_library', 'double',
|
| 88 |
+
'draw_roi', 'edge_dog', 'efont', 'eigenql', 'eigenvec',
|
| 89 |
+
'ellipse', 'elmhes', 'emboss', 'empty', 'enable_sysrtn',
|
| 90 |
+
'eof', r'eos_\w*', 'erase', 'erf', 'erfc', 'erfcx',
|
| 91 |
+
'erode', 'errorplot', 'errplot', 'estimator_filter',
|
| 92 |
+
'execute', 'exit', 'exp', 'expand', 'expand_path', 'expint',
|
| 93 |
+
'extrac', 'extract_slice', 'factorial', 'fft', 'filepath',
|
| 94 |
+
'file_basename', 'file_chmod', 'file_copy', 'file_delete',
|
| 95 |
+
'file_dirname', 'file_expand_path', 'file_info',
|
| 96 |
+
'file_lines', 'file_link', 'file_mkdir', 'file_move',
|
| 97 |
+
'file_poll_input', 'file_readlink', 'file_same',
|
| 98 |
+
'file_search', 'file_test', 'file_which', 'findgen',
|
| 99 |
+
'finite', 'fix', 'flick', 'float', 'floor', 'flow3',
|
| 100 |
+
'fltarr', 'flush', 'format_axis_values', 'free_lun',
|
| 101 |
+
'fstat', 'fulstr', 'funct', 'fv_test', 'fx_root',
|
| 102 |
+
'fz_roots', 'f_cvf', 'f_pdf', 'gamma', 'gamma_ct',
|
| 103 |
+
'gauss2dfit', 'gaussfit', 'gaussian_function', 'gaussint',
|
| 104 |
+
'gauss_cvf', 'gauss_pdf', 'gauss_smooth', 'getenv',
|
| 105 |
+
'getwindows', 'get_drive_list', 'get_dxf_objects',
|
| 106 |
+
'get_kbrd', 'get_login_info', 'get_lun', 'get_screen_size',
|
| 107 |
+
'greg2jul', r'grib_\w*', 'grid3', 'griddata',
|
| 108 |
+
'grid_input', 'grid_tps', 'gs_iter',
|
| 109 |
+
r'h5[adfgirst]_\w*', 'h5_browser', 'h5_close',
|
| 110 |
+
'h5_create', 'h5_get_libversion', 'h5_open', 'h5_parse',
|
| 111 |
+
'hanning', 'hash', r'hdf_\w*', 'heap_free',
|
| 112 |
+
'heap_gc', 'heap_nosave', 'heap_refcount', 'heap_save',
|
| 113 |
+
'help', 'hilbert', 'histogram', 'hist_2d', 'hist_equal',
|
| 114 |
+
'hls', 'hough', 'hqr', 'hsv', 'h_eq_ct', 'h_eq_int',
|
| 115 |
+
'i18n_multibytetoutf8', 'i18n_multibytetowidechar',
|
| 116 |
+
'i18n_utf8tomultibyte', 'i18n_widechartomultibyte',
|
| 117 |
+
'ibeta', 'icontour', 'iconvertcoord', 'idelete', 'identity',
|
| 118 |
+
'idlexbr_assistant', 'idlitsys_createtool', 'idl_base64',
|
| 119 |
+
'idl_validname', 'iellipse', 'igamma', 'igetcurrent',
|
| 120 |
+
'igetdata', 'igetid', 'igetproperty', 'iimage', 'image',
|
| 121 |
+
'image_cont', 'image_statistics', 'imaginary', 'imap',
|
| 122 |
+
'indgen', 'intarr', 'interpol', 'interpolate',
|
| 123 |
+
'interval_volume', 'int_2d', 'int_3d', 'int_tabulated',
|
| 124 |
+
'invert', 'ioctl', 'iopen', 'iplot', 'ipolygon',
|
| 125 |
+
'ipolyline', 'iputdata', 'iregister', 'ireset', 'iresolve',
|
| 126 |
+
'irotate', 'ir_filter', 'isa', 'isave', 'iscale',
|
| 127 |
+
'isetcurrent', 'isetproperty', 'ishft', 'isocontour',
|
| 128 |
+
'isosurface', 'isurface', 'itext', 'itranslate', 'ivector',
|
| 129 |
+
'ivolume', 'izoom', 'i_beta', 'journal', 'json_parse',
|
| 130 |
+
'json_serialize', 'jul2greg', 'julday', 'keyword_set',
|
| 131 |
+
'krig2d', 'kurtosis', 'kw_test', 'l64indgen', 'label_date',
|
| 132 |
+
'label_region', 'ladfit', 'laguerre', 'laplacian',
|
| 133 |
+
'la_choldc', 'la_cholmprove', 'la_cholsol', 'la_determ',
|
| 134 |
+
'la_eigenproblem', 'la_eigenql', 'la_eigenvec', 'la_elmhes',
|
| 135 |
+
'la_gm_linear_model', 'la_hqr', 'la_invert',
|
| 136 |
+
'la_least_squares', 'la_least_square_equality',
|
| 137 |
+
'la_linear_equation', 'la_ludc', 'la_lumprove', 'la_lusol',
|
| 138 |
+
'la_svd', 'la_tridc', 'la_trimprove', 'la_triql',
|
| 139 |
+
'la_trired', 'la_trisol', 'least_squares_filter', 'leefilt',
|
| 140 |
+
'legend', 'legendre', 'linbcg', 'lindgen', 'linfit',
|
| 141 |
+
'linkimage', 'list', 'll_arc_distance', 'lmfit', 'lmgr',
|
| 142 |
+
'lngamma', 'lnp_test', 'loadct', 'locale_get',
|
| 143 |
+
'logical_and', 'logical_or', 'logical_true', 'lon64arr',
|
| 144 |
+
'lonarr', 'long', 'long64', 'lsode', 'ludc', 'lumprove',
|
| 145 |
+
'lusol', 'lu_complex', 'machar', 'make_array', 'make_dll',
|
| 146 |
+
'make_rt', 'map', 'mapcontinents', 'mapgrid', 'map_2points',
|
| 147 |
+
'map_continents', 'map_grid', 'map_image', 'map_patch',
|
| 148 |
+
'map_proj_forward', 'map_proj_image', 'map_proj_info',
|
| 149 |
+
'map_proj_init', 'map_proj_inverse', 'map_set',
|
| 150 |
+
'matrix_multiply', 'matrix_power', 'max', 'md_test',
|
| 151 |
+
'mean', 'meanabsdev', 'mean_filter', 'median', 'memory',
|
| 152 |
+
'mesh_clip', 'mesh_decimate', 'mesh_issolid', 'mesh_merge',
|
| 153 |
+
'mesh_numtriangles', 'mesh_obj', 'mesh_smooth',
|
| 154 |
+
'mesh_surfacearea', 'mesh_validate', 'mesh_volume',
|
| 155 |
+
'message', 'min', 'min_curve_surf', 'mk_html_help',
|
| 156 |
+
'modifyct', 'moment', 'morph_close', 'morph_distance',
|
| 157 |
+
'morph_gradient', 'morph_hitormiss', 'morph_open',
|
| 158 |
+
'morph_thin', 'morph_tophat', 'multi', 'm_correlate',
|
| 159 |
+
r'ncdf_\w*', 'newton', 'noise_hurl', 'noise_pick',
|
| 160 |
+
'noise_scatter', 'noise_slur', 'norm', 'n_elements',
|
| 161 |
+
'n_params', 'n_tags', 'objarr', 'obj_class', 'obj_destroy',
|
| 162 |
+
'obj_hasmethod', 'obj_isa', 'obj_new', 'obj_valid',
|
| 163 |
+
'online_help', 'on_error', 'open', 'oplot', 'oploterr',
|
| 164 |
+
'parse_url', 'particle_trace', 'path_cache', 'path_sep',
|
| 165 |
+
'pcomp', 'plot', 'plot3d', 'ploterr', 'plots', 'plot_3dbox',
|
| 166 |
+
'plot_field', 'pnt_line', 'point_lun', 'polarplot',
|
| 167 |
+
'polar_contour', 'polar_surface', 'poly', 'polyfill',
|
| 168 |
+
'polyfillv', 'polygon', 'polyline', 'polyshade', 'polywarp',
|
| 169 |
+
'poly_2d', 'poly_area', 'poly_fit', 'popd', 'powell',
|
| 170 |
+
'pref_commit', 'pref_get', 'pref_set', 'prewitt', 'primes',
|
| 171 |
+
'print', 'printd', 'product', 'profile', 'profiler',
|
| 172 |
+
'profiles', 'project_vol', 'psafm', 'pseudo',
|
| 173 |
+
'ps_show_fonts', 'ptrarr', 'ptr_free', 'ptr_new',
|
| 174 |
+
'ptr_valid', 'pushd', 'p_correlate', 'qgrid3', 'qhull',
|
| 175 |
+
'qromb', 'qromo', 'qsimp', 'query_ascii', 'query_bmp',
|
| 176 |
+
'query_csv', 'query_dicom', 'query_gif', 'query_image',
|
| 177 |
+
'query_jpeg', 'query_jpeg2000', 'query_mrsid', 'query_pict',
|
| 178 |
+
'query_png', 'query_ppm', 'query_srf', 'query_tiff',
|
| 179 |
+
'query_wav', 'radon', 'randomn', 'randomu', 'ranks',
|
| 180 |
+
'rdpix', 'read', 'reads', 'readu', 'read_ascii',
|
| 181 |
+
'read_binary', 'read_bmp', 'read_csv', 'read_dicom',
|
| 182 |
+
'read_gif', 'read_image', 'read_interfile', 'read_jpeg',
|
| 183 |
+
'read_jpeg2000', 'read_mrsid', 'read_pict', 'read_png',
|
| 184 |
+
'read_ppm', 'read_spr', 'read_srf', 'read_sylk',
|
| 185 |
+
'read_tiff', 'read_wav', 'read_wave', 'read_x11_bitmap',
|
| 186 |
+
'read_xwd', 'real_part', 'rebin', 'recall_commands',
|
| 187 |
+
'recon3', 'reduce_colors', 'reform', 'region_grow',
|
| 188 |
+
'register_cursor', 'regress', 'replicate',
|
| 189 |
+
'replicate_inplace', 'resolve_all', 'resolve_routine',
|
| 190 |
+
'restore', 'retall', 'return', 'reverse', 'rk4', 'roberts',
|
| 191 |
+
'rot', 'rotate', 'round', 'routine_filepath',
|
| 192 |
+
'routine_info', 'rs_test', 'r_correlate', 'r_test',
|
| 193 |
+
'save', 'savgol', 'scale3', 'scale3d', 'scope_level',
|
| 194 |
+
'scope_traceback', 'scope_varfetch', 'scope_varname',
|
| 195 |
+
'search2d', 'search3d', 'sem_create', 'sem_delete',
|
| 196 |
+
'sem_lock', 'sem_release', 'setenv', 'set_plot',
|
| 197 |
+
'set_shading', 'sfit', 'shade_surf', 'shade_surf_irr',
|
| 198 |
+
'shade_volume', 'shift', 'shift_diff', 'shmdebug', 'shmmap',
|
| 199 |
+
'shmunmap', 'shmvar', 'show3', 'showfont', 'simplex', 'sin',
|
| 200 |
+
'sindgen', 'sinh', 'size', 'skewness', 'skip_lun',
|
| 201 |
+
'slicer3', 'slide_image', 'smooth', 'sobel', 'socket',
|
| 202 |
+
'sort', 'spawn', 'spher_harm', 'sph_4pnt', 'sph_scat',
|
| 203 |
+
'spline', 'spline_p', 'spl_init', 'spl_interp', 'sprsab',
|
| 204 |
+
'sprsax', 'sprsin', 'sprstp', 'sqrt', 'standardize',
|
| 205 |
+
'stddev', 'stop', 'strarr', 'strcmp', 'strcompress',
|
| 206 |
+
'streamline', 'stregex', 'stretch', 'string', 'strjoin',
|
| 207 |
+
'strlen', 'strlowcase', 'strmatch', 'strmessage', 'strmid',
|
| 208 |
+
'strpos', 'strput', 'strsplit', 'strtrim', 'struct_assign',
|
| 209 |
+
'struct_hide', 'strupcase', 'surface', 'surfr', 'svdc',
|
| 210 |
+
'svdfit', 'svsol', 'swap_endian', 'swap_endian_inplace',
|
| 211 |
+
'symbol', 'systime', 's_test', 't3d', 'tag_names', 'tan',
|
| 212 |
+
'tanh', 'tek_color', 'temporary', 'tetra_clip',
|
| 213 |
+
'tetra_surface', 'tetra_volume', 'text', 'thin', 'threed',
|
| 214 |
+
'timegen', 'time_test2', 'tm_test', 'total', 'trace',
|
| 215 |
+
'transpose', 'triangulate', 'trigrid', 'triql', 'trired',
|
| 216 |
+
'trisol', 'tri_surf', 'truncate_lun', 'ts_coef', 'ts_diff',
|
| 217 |
+
'ts_fcast', 'ts_smooth', 'tv', 'tvcrs', 'tvlct', 'tvrd',
|
| 218 |
+
'tvscl', 'typename', 't_cvt', 't_pdf', 'uindgen', 'uint',
|
| 219 |
+
'uintarr', 'ul64indgen', 'ulindgen', 'ulon64arr', 'ulonarr',
|
| 220 |
+
'ulong', 'ulong64', 'uniq', 'unsharp_mask', 'usersym',
|
| 221 |
+
'value_locate', 'variance', 'vector', 'vector_field', 'vel',
|
| 222 |
+
'velovect', 'vert_t3d', 'voigt', 'voronoi', 'voxel_proj',
|
| 223 |
+
'wait', 'warp_tri', 'watershed', 'wdelete', 'wf_draw',
|
| 224 |
+
'where', 'widget_base', 'widget_button', 'widget_combobox',
|
| 225 |
+
'widget_control', 'widget_displaycontextmen', 'widget_draw',
|
| 226 |
+
'widget_droplist', 'widget_event', 'widget_info',
|
| 227 |
+
'widget_label', 'widget_list', 'widget_propertysheet',
|
| 228 |
+
'widget_slider', 'widget_tab', 'widget_table',
|
| 229 |
+
'widget_text', 'widget_tree', 'widget_tree_move',
|
| 230 |
+
'widget_window', 'wiener_filter', 'window', 'writeu',
|
| 231 |
+
'write_bmp', 'write_csv', 'write_gif', 'write_image',
|
| 232 |
+
'write_jpeg', 'write_jpeg2000', 'write_nrif', 'write_pict',
|
| 233 |
+
'write_png', 'write_ppm', 'write_spr', 'write_srf',
|
| 234 |
+
'write_sylk', 'write_tiff', 'write_wav', 'write_wave',
|
| 235 |
+
'wset', 'wshow', 'wtn', 'wv_applet', 'wv_cwt',
|
| 236 |
+
'wv_cw_wavelet', 'wv_denoise', 'wv_dwt', 'wv_fn_coiflet',
|
| 237 |
+
'wv_fn_daubechies', 'wv_fn_gaussian', 'wv_fn_haar',
|
| 238 |
+
'wv_fn_morlet', 'wv_fn_paul', 'wv_fn_symlet',
|
| 239 |
+
'wv_import_data', 'wv_import_wavelet', 'wv_plot3d_wps',
|
| 240 |
+
'wv_plot_multires', 'wv_pwt', 'wv_tool_denoise',
|
| 241 |
+
'xbm_edit', 'xdisplayfile', 'xdxf', 'xfont',
|
| 242 |
+
'xinteranimate', 'xloadct', 'xmanager', 'xmng_tmpl',
|
| 243 |
+
'xmtool', 'xobjview', 'xobjview_rotate',
|
| 244 |
+
'xobjview_write_image', 'xpalette', 'xpcolor', 'xplot3d',
|
| 245 |
+
'xregistered', 'xroi', 'xsq_test', 'xsurface', 'xvaredit',
|
| 246 |
+
'xvolume', 'xvolume_rotate', 'xvolume_write_image',
|
| 247 |
+
'xyouts', 'zoom', 'zoom_24')
|
| 248 |
+
"""Functions from: http://www.exelisvis.com/docs/routines-1.html"""
|
| 249 |
+
|
| 250 |
+
tokens = {
|
| 251 |
+
'root': [
|
| 252 |
+
(r'(^\s*)(;.*?)(\n)', bygroups(Whitespace, Comment.Single,
|
| 253 |
+
Whitespace)),
|
| 254 |
+
(words(_RESERVED, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 255 |
+
(words(_BUILTIN_LIB, prefix=r'\b', suffix=r'\b'), Name.Builtin),
|
| 256 |
+
(r'\+=|-=|\^=|\*=|/=|#=|##=|<=|>=|=', Operator),
|
| 257 |
+
(r'\+\+|--|->|\+|-|##|#|\*|/|<|>|&&|\^|~|\|\|\?|:', Operator),
|
| 258 |
+
(r'\b(mod=|lt=|le=|eq=|ne=|ge=|gt=|not=|and=|or=|xor=)', Operator),
|
| 259 |
+
(r'\b(mod|lt|le|eq|ne|ge|gt|not|and|or|xor)\b', Operator),
|
| 260 |
+
(r'"[^\"]*"', String.Double),
|
| 261 |
+
(r"'[^\']*'", String.Single),
|
| 262 |
+
(r'\b[+\-]?([0-9]*\.[0-9]+|[0-9]+\.[0-9]*)(D|E)?([+\-]?[0-9]+)?\b',
|
| 263 |
+
Number.Float),
|
| 264 |
+
(r'\b\'[+\-]?[0-9A-F]+\'X(U?(S?|L{1,2})|B)\b', Number.Hex),
|
| 265 |
+
(r'\b\'[+\-]?[0-7]+\'O(U?(S?|L{1,2})|B)\b', Number.Oct),
|
| 266 |
+
(r'\b[+\-]?[0-9]+U?L{1,2}\b', Number.Integer.Long),
|
| 267 |
+
(r'\b[+\-]?[0-9]+U?S?\b', Number.Integer),
|
| 268 |
+
(r'\b[+\-]?[0-9]+B\b', Number),
|
| 269 |
+
(r'[ \t]+', Whitespace),
|
| 270 |
+
(r'\n', Whitespace),
|
| 271 |
+
(r'.', Text),
|
| 272 |
+
]
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
def analyse_text(text):
|
| 276 |
+
"""endelse seems to be unique to IDL, endswitch is rare at least."""
|
| 277 |
+
result = 0
|
| 278 |
+
|
| 279 |
+
if 'endelse' in text:
|
| 280 |
+
result += 0.2
|
| 281 |
+
if 'endswitch' in text:
|
| 282 |
+
result += 0.01
|
| 283 |
+
|
| 284 |
+
return result
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/igor.py
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Igor Pro.
|
| 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, Keyword, Name, String, Whitespace
|
| 15 |
+
|
| 16 |
+
__all__ = ['IgorLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class IgorLexer(RegexLexer):
|
| 20 |
+
"""
|
| 21 |
+
Pygments Lexer for Igor Pro procedure files (.ipf).
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
name = 'Igor'
|
| 25 |
+
aliases = ['igor', 'igorpro']
|
| 26 |
+
filenames = ['*.ipf']
|
| 27 |
+
mimetypes = ['text/ipf']
|
| 28 |
+
url = 'http://www.wavemetrics.com'
|
| 29 |
+
version_added = '2.0'
|
| 30 |
+
|
| 31 |
+
flags = re.IGNORECASE | re.MULTILINE
|
| 32 |
+
|
| 33 |
+
flowControl = (
|
| 34 |
+
'if', 'else', 'elseif', 'endif', 'for', 'endfor', 'strswitch', 'switch',
|
| 35 |
+
'case', 'default', 'endswitch', 'do', 'while', 'try', 'catch', 'endtry',
|
| 36 |
+
'break', 'continue', 'return', 'AbortOnRTE', 'AbortOnValue'
|
| 37 |
+
)
|
| 38 |
+
types = (
|
| 39 |
+
'variable', 'string', 'constant', 'strconstant', 'NVAR', 'SVAR', 'WAVE',
|
| 40 |
+
'STRUCT', 'dfref', 'funcref', 'char', 'uchar', 'int16', 'uint16', 'int32',
|
| 41 |
+
'uint32', 'int64', 'uint64', 'float', 'double', 'int'
|
| 42 |
+
)
|
| 43 |
+
keywords = (
|
| 44 |
+
'override', 'ThreadSafe', 'MultiThread', 'static', 'Proc',
|
| 45 |
+
'Picture', 'Prompt', 'DoPrompt', 'macro', 'window', 'function', 'end',
|
| 46 |
+
'Structure', 'EndStructure', 'EndMacro', 'Menu', 'SubMenu'
|
| 47 |
+
)
|
| 48 |
+
operations = (
|
| 49 |
+
'Abort', 'AddFIFOData', 'AddFIFOVectData', 'AddMovieAudio', 'AddMovieFrame',
|
| 50 |
+
'AddWavesToBoxPlot', 'AddWavesToViolinPlot', 'AdoptFiles', 'APMath', 'Append',
|
| 51 |
+
'AppendBoxPlot', 'AppendImage', 'AppendLayoutObject', 'AppendMatrixContour',
|
| 52 |
+
'AppendText', 'AppendToGizmo', 'AppendToGraph', 'AppendToLayout',
|
| 53 |
+
'AppendToTable', 'AppendViolinPlot', 'AppendXYZContour', 'AutoPositionWindow',
|
| 54 |
+
'AxonTelegraphFindServers', 'BackgroundInfo', 'Beep', 'BezierToPolygon',
|
| 55 |
+
'BoundingBall', 'BoxSmooth', 'BrowseURL', 'BuildMenu', 'Button', 'cd', 'Chart',
|
| 56 |
+
'CheckBox', 'CheckDisplayed', 'ChooseColor', 'Close', 'CloseHelp', 'CloseMovie',
|
| 57 |
+
'CloseProc', 'ColorScale', 'ColorTab2Wave', 'Concatenate', 'ControlBar',
|
| 58 |
+
'ControlInfo', 'ControlUpdate', 'ConvertGlobalStringTextEncoding', 'ConvexHull',
|
| 59 |
+
'Convolve', 'CopyDimLabels', 'CopyFile', 'CopyFolder', 'CopyScales', 'Correlate',
|
| 60 |
+
'CreateAliasShortcut', 'CreateBrowser', 'Cross', 'CtrlBackground', 'CtrlFIFO',
|
| 61 |
+
'CtrlNamedBackground', 'Cursor', 'CurveFit', 'CustomControl', 'CWT',
|
| 62 |
+
'DAQmx_AI_SetupReader', 'DAQmx_AO_SetOutputs', 'DAQmx_CTR_CountEdges',
|
| 63 |
+
'DAQmx_CTR_OutputPulse', 'DAQmx_CTR_Period', 'DAQmx_CTR_PulseWidth',
|
| 64 |
+
'DAQmx_DeviceInfo', 'DAQmx_DIO_Config', 'DAQmx_DIO_WriteNewData', 'DAQmx_Scan',
|
| 65 |
+
'DAQmx_WaveformGen', 'Debugger', 'DebuggerOptions', 'DefaultFont',
|
| 66 |
+
'DefaultGuiControls', 'DefaultGuiFont', 'DefaultTextEncoding', 'DefineGuide',
|
| 67 |
+
'DelayUpdate', 'DeleteAnnotations', 'DeleteFile', 'DeleteFolder', 'DeletePoints',
|
| 68 |
+
'Differentiate', 'dir', 'Display', 'DisplayHelpTopic', 'DisplayProcedure',
|
| 69 |
+
'DoAlert', 'DoIgorMenu', 'DoUpdate', 'DoWindow', 'DoXOPIdle', 'DPSS',
|
| 70 |
+
'DrawAction', 'DrawArc', 'DrawBezier', 'DrawLine', 'DrawOval', 'DrawPICT',
|
| 71 |
+
'DrawPoly', 'DrawRect', 'DrawRRect', 'DrawText', 'DrawUserShape', 'DSPDetrend',
|
| 72 |
+
'DSPPeriodogram', 'Duplicate', 'DuplicateDataFolder', 'DWT', 'EdgeStats', 'Edit',
|
| 73 |
+
'ErrorBars', 'EstimatePeakSizes', 'Execute', 'ExecuteScriptText',
|
| 74 |
+
'ExperimentInfo', 'ExperimentModified', 'ExportGizmo', 'Extract',
|
| 75 |
+
'FastGaussTransform', 'FastOp', 'FBinRead', 'FBinWrite', 'FCALL_CallFunction',
|
| 76 |
+
'FCALL_FreeLibrary', 'FCALL_GetFunctionList', 'FCALL_GetParamTypeList',
|
| 77 |
+
'FCALL_LoadLibrary', 'FCALL_Version', 'FFT', 'FGetPos', 'FIFOStatus',
|
| 78 |
+
'FIFO2Wave', 'FilterFIR', 'FilterIIR', 'FindAPeak', 'FindContour',
|
| 79 |
+
'FindDuplicates', 'FindLevel', 'FindLevels', 'FindPeak', 'FindPointsInPoly',
|
| 80 |
+
'FindRoots', 'FindSequence', 'FindValue', 'FMaxFlat', 'FPClustering', 'fprintf',
|
| 81 |
+
'FReadLine', 'FSetPos', 'FStatus', 'FTPCreateDirectory', 'FTPDelete',
|
| 82 |
+
'FTPDownload', 'FTPUpload', 'FuncFit', 'FuncFitMD', 'GBLoadWave', 'GetAxis',
|
| 83 |
+
'GetCamera', 'GetFileFolderInfo', 'GetGizmo', 'GetLastUserMenuInfo',
|
| 84 |
+
'GetMarquee', 'GetMouse', 'GetSelection', 'GetWindow', 'GISCreateVectorLayer',
|
| 85 |
+
'GISGetRasterInfo', 'GISGetRegisteredFileInfo', 'GISGetVectorLayerInfo',
|
| 86 |
+
'GISLoadRasterData', 'GISLoadVectorData', 'GISRasterizeVectorData',
|
| 87 |
+
'GISRegisterFile', 'GISTransformCoords', 'GISUnRegisterFile',
|
| 88 |
+
'GISWriteFieldData', 'GISWriteGeometryData', 'GISWriteRaster',
|
| 89 |
+
'GPIBReadBinaryWave2', 'GPIBReadBinary2', 'GPIBReadWave2', 'GPIBRead2',
|
| 90 |
+
'GPIBWriteBinaryWave2', 'GPIBWriteBinary2', 'GPIBWriteWave2', 'GPIBWrite2',
|
| 91 |
+
'GPIB2', 'GraphNormal', 'GraphWaveDraw', 'GraphWaveEdit', 'Grep', 'GroupBox',
|
| 92 |
+
'Hanning', 'HCluster', 'HDFInfo', 'HDFReadImage', 'HDFReadSDS', 'HDFReadVset',
|
| 93 |
+
'HDF5CloseFile', 'HDF5CloseGroup', 'HDF5Control', 'HDF5CreateFile',
|
| 94 |
+
'HDF5CreateGroup', 'HDF5CreateLink', 'HDF5DimensionScale', 'HDF5Dump',
|
| 95 |
+
'HDF5DumpErrors', 'HDF5FlushFile', 'HDF5ListAttributes', 'HDF5ListGroup',
|
| 96 |
+
'HDF5LoadData', 'HDF5LoadGroup', 'HDF5LoadImage', 'HDF5OpenFile',
|
| 97 |
+
'HDF5OpenGroup', 'HDF5SaveData', 'HDF5SaveGroup', 'HDF5SaveImage',
|
| 98 |
+
'HDF5UnlinkObject', 'HideIgorMenus', 'HideInfo', 'HideProcedures', 'HideTools',
|
| 99 |
+
'HilbertTransform', 'Histogram', 'ICA', 'IFFT', 'ImageAnalyzeParticles',
|
| 100 |
+
'ImageBlend', 'ImageBoundaryToMask', 'ImageComposite', 'ImageEdgeDetection',
|
| 101 |
+
'ImageFileInfo', 'ImageFilter', 'ImageFocus', 'ImageFromXYZ',
|
| 102 |
+
'ImageGenerateROIMask', 'ImageGLCM', 'ImageHistModification', 'ImageHistogram',
|
| 103 |
+
'ImageInterpolate', 'ImageLineProfile', 'ImageLoad', 'ImageMorphology',
|
| 104 |
+
'ImageRegistration', 'ImageRemoveBackground', 'ImageRestore', 'ImageRotate',
|
| 105 |
+
'ImageSave', 'ImageSeedFill', 'ImageSkeleton3d', 'ImageSnake', 'ImageStats',
|
| 106 |
+
'ImageThreshold', 'ImageTransform', 'ImageUnwrapPhase', 'ImageWindow',
|
| 107 |
+
'IndexSort', 'InsertPoints', 'InstantFrequency', 'Integrate', 'IntegrateODE',
|
| 108 |
+
'Integrate2D', 'Interpolate2', 'Interpolate3D', 'Interp3DPath', 'ITCCloseAll2',
|
| 109 |
+
'ITCCloseDevice2', 'ITCConfigAllChannels2', 'ITCConfigChannelReset2',
|
| 110 |
+
'ITCConfigChannelUpload2', 'ITCConfigChannel2', 'ITCFIFOAvailableAll2',
|
| 111 |
+
'ITCFIFOAvailable2', 'ITCGetAllChannelsConfig2', 'ITCGetChannelConfig2',
|
| 112 |
+
'ITCGetCurrentDevice2', 'ITCGetDeviceInfo2', 'ITCGetDevices2',
|
| 113 |
+
'ITCGetErrorString2', 'ITCGetSerialNumber2', 'ITCGetState2', 'ITCGetVersions2',
|
| 114 |
+
'ITCInitialize2', 'ITCOpenDevice2', 'ITCReadADC2', 'ITCReadDigital2',
|
| 115 |
+
'ITCReadTimer2', 'ITCSelectDevice2', 'ITCSetDAC2', 'ITCSetGlobals2',
|
| 116 |
+
'ITCSetModes2', 'ITCSetState2', 'ITCStartAcq2', 'ITCStopAcq2',
|
| 117 |
+
'ITCUpdateFIFOPositionAll2', 'ITCUpdateFIFOPosition2', 'ITCWriteDigital2',
|
| 118 |
+
'JCAMPLoadWave', 'JointHistogram', 'JSONXOP_AddTree', 'JSONXOP_AddValue',
|
| 119 |
+
'JSONXOP_Dump', 'JSONXOP_GetArraySize', 'JSONXOP_GetKeys',
|
| 120 |
+
'JSONXOP_GetMaxArraySize', 'JSONXOP_GetType', 'JSONXOP_GetValue', 'JSONXOP_New',
|
| 121 |
+
'JSONXOP_Parse', 'JSONXOP_Release', 'JSONXOP_Remove', 'JSONXOP_Version',
|
| 122 |
+
'KillBackground', 'KillControl', 'KillDataFolder', 'KillFIFO', 'KillFreeAxis',
|
| 123 |
+
'KillPath', 'KillPICTs', 'KillStrings', 'KillVariables', 'KillWaves',
|
| 124 |
+
'KillWindow', 'KMeans', 'Label', 'Layout', 'LayoutPageAction',
|
| 125 |
+
'LayoutSlideShow', 'Legend', 'LinearFeedbackShiftRegister', 'ListBox',
|
| 126 |
+
'LoadData', 'LoadPackagePreferences', 'LoadPICT', 'LoadWave', 'Loess',
|
| 127 |
+
'LombPeriodogram', 'Make', 'MakeIndex', 'MarkPerfTestTime', 'MatrixBalance',
|
| 128 |
+
'MatrixConvolve', 'MatrixCorr', 'MatrixEigenV', 'MatrixFactor', 'MatrixFilter',
|
| 129 |
+
'MatrixGaussJ', 'MatrixGLM', 'MatrixInverse', 'MatrixLinearSolve',
|
| 130 |
+
'MatrixLinearSolveTD', 'MatrixLLS', 'MatrixLUBkSub', 'MatrixLUD', 'MatrixLUDTD',
|
| 131 |
+
'MatrixMultiply', 'MatrixMultiplyAdd', 'MatrixOP', 'MatrixReverseBalance',
|
| 132 |
+
'MatrixSchur', 'MatrixSolve', 'MatrixSparse', 'MatrixSVBkSub', 'MatrixSVD',
|
| 133 |
+
'MatrixTranspose', 'MCC_FindServers', 'MeasureStyledText',
|
| 134 |
+
'MFR_CheckForNewBricklets', 'MFR_CloseResultFile', 'MFR_CreateOverviewTable',
|
| 135 |
+
'MFR_GetBrickletCount', 'MFR_GetBrickletData', 'MFR_GetBrickletDeployData',
|
| 136 |
+
'MFR_GetBrickletMetaData', 'MFR_GetBrickletRawData', 'MFR_GetReportTemplate',
|
| 137 |
+
'MFR_GetResultFileMetaData', 'MFR_GetResultFileName',
|
| 138 |
+
'MFR_GetVernissageVersion', 'MFR_GetVersion', 'MFR_GetXOPErrorMessage',
|
| 139 |
+
'MFR_OpenResultFile', 'MLLoadWave', 'Modify', 'ModifyBoxPlot', 'ModifyBrowser',
|
| 140 |
+
'ModifyCamera', 'ModifyContour', 'ModifyControl', 'ModifyControlList',
|
| 141 |
+
'ModifyFreeAxis', 'ModifyGizmo', 'ModifyGraph', 'ModifyImage', 'ModifyLayout',
|
| 142 |
+
'ModifyPanel', 'ModifyProcedure', 'ModifyTable', 'ModifyViolinPlot',
|
| 143 |
+
'ModifyWaterfall', 'MoveDataFolder', 'MoveFile', 'MoveFolder', 'MoveString',
|
| 144 |
+
'MoveSubwindow', 'MoveVariable', 'MoveWave', 'MoveWindow', 'MultiTaperPSD',
|
| 145 |
+
'MultiThreadingControl', 'NC_CloseFile', 'NC_DumpErrors', 'NC_Inquire',
|
| 146 |
+
'NC_ListAttributes', 'NC_ListObjects', 'NC_LoadData', 'NC_OpenFile',
|
| 147 |
+
'NeuralNetworkRun', 'NeuralNetworkTrain', 'NewCamera', 'NewDataFolder',
|
| 148 |
+
'NewFIFO', 'NewFIFOChan', 'NewFreeAxis', 'NewGizmo', 'NewImage', 'NewLayout',
|
| 149 |
+
'NewMovie', 'NewNotebook', 'NewPanel', 'NewPath', 'NewWaterfall', 'NILoadWave',
|
| 150 |
+
'NI4882', 'Note', 'Notebook', 'NotebookAction', 'Open', 'OpenHelp',
|
| 151 |
+
'OpenNotebook', 'Optimize', 'ParseOperationTemplate', 'PathInfo',
|
| 152 |
+
'PauseForUser', 'PauseUpdate', 'PCA', 'PlayMovie', 'PlayMovieAction',
|
| 153 |
+
'PlaySound', 'PolygonOp', 'PopupContextualMenu', 'PopupMenu', 'Preferences',
|
| 154 |
+
'PrimeFactors', 'Print', 'printf', 'PrintGraphs', 'PrintLayout',
|
| 155 |
+
'PrintNotebook', 'PrintSettings', 'PrintTable', 'Project', 'PulseStats',
|
| 156 |
+
'PutScrapText', 'pwd', 'Quit', 'RatioFromNumber', 'Redimension', 'Remez',
|
| 157 |
+
'Remove', 'RemoveContour', 'RemoveFromGizmo', 'RemoveFromGraph',
|
| 158 |
+
'RemoveFromLayout', 'RemoveFromTable', 'RemoveImage', 'RemoveLayoutObjects',
|
| 159 |
+
'RemovePath', 'Rename', 'RenameDataFolder', 'RenamePath', 'RenamePICT',
|
| 160 |
+
'RenameWindow', 'ReorderImages', 'ReorderTraces', 'ReplaceText', 'ReplaceWave',
|
| 161 |
+
'Resample', 'ResumeUpdate', 'Reverse', 'Rotate', 'Save', 'SaveData',
|
| 162 |
+
'SaveExperiment', 'SaveGizmoCopy', 'SaveGraphCopy', 'SaveNotebook',
|
| 163 |
+
'SavePackagePreferences', 'SavePICT', 'SaveTableCopy', 'SetActiveSubwindow',
|
| 164 |
+
'SetAxis', 'SetBackground', 'SetDashPattern', 'SetDataFolder', 'SetDimLabel',
|
| 165 |
+
'SetDrawEnv', 'SetDrawLayer', 'SetFileFolderInfo', 'SetFormula',
|
| 166 |
+
'SetIdlePeriod', 'SetIgorHook', 'SetIgorMenuMode', 'SetIgorOption',
|
| 167 |
+
'SetMarquee', 'SetProcessSleep', 'SetRandomSeed', 'SetScale', 'SetVariable',
|
| 168 |
+
'SetWaveLock', 'SetWaveTextEncoding', 'SetWindow', 'ShowIgorMenus', 'ShowInfo',
|
| 169 |
+
'ShowTools', 'Silent', 'Sleep', 'Slider', 'Smooth', 'SmoothCustom', 'Sort',
|
| 170 |
+
'SortColumns', 'SoundInRecord', 'SoundInSet', 'SoundInStartChart',
|
| 171 |
+
'SoundInStatus', 'SoundInStopChart', 'SoundLoadWave', 'SoundSaveWave',
|
| 172 |
+
'SphericalInterpolate', 'SphericalTriangulate', 'SplitString', 'SplitWave',
|
| 173 |
+
'sprintf', 'SQLHighLevelOp', 'sscanf', 'Stack', 'StackWindows',
|
| 174 |
+
'StatsAngularDistanceTest', 'StatsANOVA1Test', 'StatsANOVA2NRTest',
|
| 175 |
+
'StatsANOVA2RMTest', 'StatsANOVA2Test', 'StatsChiTest',
|
| 176 |
+
'StatsCircularCorrelationTest', 'StatsCircularMeans', 'StatsCircularMoments',
|
| 177 |
+
'StatsCircularTwoSampleTest', 'StatsCochranTest', 'StatsContingencyTable',
|
| 178 |
+
'StatsDIPTest', 'StatsDunnettTest', 'StatsFriedmanTest', 'StatsFTest',
|
| 179 |
+
'StatsHodgesAjneTest', 'StatsJBTest', 'StatsKDE', 'StatsKendallTauTest',
|
| 180 |
+
'StatsKSTest', 'StatsKWTest', 'StatsLinearCorrelationTest',
|
| 181 |
+
'StatsLinearRegression', 'StatsMultiCorrelationTest', 'StatsNPMCTest',
|
| 182 |
+
'StatsNPNominalSRTest', 'StatsQuantiles', 'StatsRankCorrelationTest',
|
| 183 |
+
'StatsResample', 'StatsSample', 'StatsScheffeTest', 'StatsShapiroWilkTest',
|
| 184 |
+
'StatsSignTest', 'StatsSRTest', 'StatsTTest', 'StatsTukeyTest',
|
| 185 |
+
'StatsVariancesTest', 'StatsWatsonUSquaredTest', 'StatsWatsonWilliamsTest',
|
| 186 |
+
'StatsWheelerWatsonTest', 'StatsWilcoxonRankTest', 'StatsWRCorrelationTest',
|
| 187 |
+
'STFT', 'StructFill', 'StructGet', 'StructPut', 'SumDimension', 'SumSeries',
|
| 188 |
+
'TabControl', 'Tag', 'TDMLoadData', 'TDMSaveData', 'TextBox', 'TextHistogram',
|
| 189 |
+
'Text2Bezier', 'ThreadGroupPutDF', 'ThreadStart', 'TickWavesFromAxis', 'Tile',
|
| 190 |
+
'TileWindows', 'TitleBox', 'ToCommandLine', 'ToolsGrid', 'Triangulate3d',
|
| 191 |
+
'TUFXOP_AcquireLock', 'TUFXOP_Clear', 'TUFXOP_GetStorage', 'TUFXOP_Init',
|
| 192 |
+
'TUFXOP_ReleaseLock', 'TUFXOP_RunningInMainThread', 'TUFXOP_Version', 'Unwrap',
|
| 193 |
+
'UnzipFile', 'URLRequest', 'ValDisplay', 'VDTClosePort2', 'VDTGetPortList2',
|
| 194 |
+
'VDTGetStatus2', 'VDTOpenPort2', 'VDTOperationsPort2', 'VDTReadBinaryWave2',
|
| 195 |
+
'VDTReadBinary2', 'VDTReadHexWave2', 'VDTReadHex2', 'VDTReadWave2', 'VDTRead2',
|
| 196 |
+
'VDTTerminalPort2', 'VDTWriteBinaryWave2', 'VDTWriteBinary2',
|
| 197 |
+
'VDTWriteHexWave2', 'VDTWriteHex2', 'VDTWriteWave2', 'VDTWrite2', 'VDT2',
|
| 198 |
+
'VISAControl', 'VISARead', 'VISAReadBinary', 'VISAReadBinaryWave',
|
| 199 |
+
'VISAReadWave', 'VISAWrite', 'VISAWriteBinary', 'VISAWriteBinaryWave',
|
| 200 |
+
'VISAWriteWave', 'WaveMeanStdv', 'WaveStats', 'WaveTracking', 'WaveTransform',
|
| 201 |
+
'wfprintf', 'WignerTransform', 'WindowFunction', 'XLLoadWave'
|
| 202 |
+
)
|
| 203 |
+
functions = (
|
| 204 |
+
'abs', 'acos', 'acosh', 'AddListItem', 'AiryA', 'AiryAD', 'AiryB', 'AiryBD',
|
| 205 |
+
'alog', 'AnnotationInfo', 'AnnotationList', 'area', 'areaXY', 'asin', 'asinh',
|
| 206 |
+
'atan', 'atanh', 'atan2', 'AxisInfo', 'AxisLabel', 'AxisList',
|
| 207 |
+
'AxisValFromPixel', 'AxonTelegraphAGetDataNum', 'AxonTelegraphAGetDataString',
|
| 208 |
+
'AxonTelegraphAGetDataStruct', 'AxonTelegraphGetDataNum',
|
| 209 |
+
'AxonTelegraphGetDataString', 'AxonTelegraphGetDataStruct',
|
| 210 |
+
'AxonTelegraphGetTimeoutMs', 'AxonTelegraphSetTimeoutMs', 'Base64Decode',
|
| 211 |
+
'Base64Encode', 'Besseli', 'Besselj', 'Besselk', 'Bessely', 'beta', 'betai',
|
| 212 |
+
'BinarySearch', 'BinarySearchInterp', 'binomial', 'binomialln', 'binomialNoise',
|
| 213 |
+
'cabs', 'CaptureHistory', 'CaptureHistoryStart', 'ceil', 'centerOfMass',
|
| 214 |
+
'centerOfMassXY', 'cequal', 'char2num', 'chebyshev', 'chebyshevU', 'CheckName',
|
| 215 |
+
'ChildWindowList', 'CleanupName', 'cmplx', 'cmpstr', 'conj', 'ContourInfo',
|
| 216 |
+
'ContourNameList', 'ContourNameToWaveRef', 'ContourZ', 'ControlNameList',
|
| 217 |
+
'ConvertTextEncoding', 'cos', 'cosh', 'cosIntegral', 'cot', 'coth',
|
| 218 |
+
'CountObjects', 'CountObjectsDFR', 'cpowi', 'CreateDataObjectName',
|
| 219 |
+
'CreationDate', 'csc', 'csch', 'CsrInfo', 'CsrWave', 'CsrWaveRef', 'CsrXWave',
|
| 220 |
+
'CsrXWaveRef', 'CTabList', 'DataFolderDir', 'DataFolderExists',
|
| 221 |
+
'DataFolderList', 'DataFolderRefChanges', 'DataFolderRefsEqual',
|
| 222 |
+
'DataFolderRefStatus', 'date', 'datetime', 'DateToJulian', 'date2secs',
|
| 223 |
+
'Dawson', 'defined', 'deltax', 'digamma', 'dilogarithm', 'DimDelta',
|
| 224 |
+
'DimOffset', 'DimSize', 'ei', 'ellipticE', 'ellipticK', 'enoise', 'equalWaves',
|
| 225 |
+
'erf', 'erfc', 'erfcw', 'erfcx', 'exists', 'exp', 'expInt', 'expIntegralE1',
|
| 226 |
+
'expNoise', 'factorial', 'Faddeeva', 'fakedata', 'faverage', 'faverageXY',
|
| 227 |
+
'fDAQmx_AI_ChannelConfigs', 'fDAQmx_AI_GetReader', 'fDAQmx_AO_UpdateOutputs',
|
| 228 |
+
'fDAQmx_ConnectTerminals', 'fDAQmx_CTR_Finished', 'fDAQmx_CTR_IsFinished',
|
| 229 |
+
'fDAQmx_CTR_IsPulseFinished', 'fDAQmx_CTR_ReadCounter',
|
| 230 |
+
'fDAQmx_CTR_ReadWithOptions', 'fDAQmx_CTR_SetPulseFrequency',
|
| 231 |
+
'fDAQmx_CTR_Start', 'fDAQmx_DeviceNames', 'fDAQmx_DIO_Finished',
|
| 232 |
+
'fDAQmx_DIO_PortWidth', 'fDAQmx_DIO_Read', 'fDAQmx_DIO_Write',
|
| 233 |
+
'fDAQmx_DisconnectTerminals', 'fDAQmx_ErrorString', 'fDAQmx_ExternalCalDate',
|
| 234 |
+
'fDAQmx_NumAnalogInputs', 'fDAQmx_NumAnalogOutputs', 'fDAQmx_NumCounters',
|
| 235 |
+
'fDAQmx_NumDIOPorts', 'fDAQmx_ReadChan', 'fDAQmx_ReadNamedChan',
|
| 236 |
+
'fDAQmx_ResetDevice', 'fDAQmx_ScanGetAvailable', 'fDAQmx_ScanGetNextIndex',
|
| 237 |
+
'fDAQmx_ScanStart', 'fDAQmx_ScanStop', 'fDAQmx_ScanWait',
|
| 238 |
+
'fDAQmx_ScanWaitWithTimeout', 'fDAQmx_SelfCalDate', 'fDAQmx_SelfCalibration',
|
| 239 |
+
'fDAQmx_WaveformStart', 'fDAQmx_WaveformStop', 'fDAQmx_WF_IsFinished',
|
| 240 |
+
'fDAQmx_WF_WaitUntilFinished', 'fDAQmx_WriteChan', 'FetchURL', 'FindDimLabel',
|
| 241 |
+
'FindListItem', 'floor', 'FontList', 'FontSizeHeight', 'FontSizeStringWidth',
|
| 242 |
+
'FresnelCos', 'FresnelSin', 'FuncRefInfo', 'FunctionInfo', 'FunctionList',
|
| 243 |
+
'FunctionPath', 'gamma', 'gammaEuler', 'gammaInc', 'gammaNoise', 'gammln',
|
| 244 |
+
'gammp', 'gammq', 'Gauss', 'Gauss1D', 'Gauss2D', 'gcd', 'GeometricMean',
|
| 245 |
+
'GetBrowserLine', 'GetBrowserSelection', 'GetDataFolder', 'GetDataFolderDFR',
|
| 246 |
+
'GetDefaultFont', 'GetDefaultFontSize', 'GetDefaultFontStyle', 'GetDimLabel',
|
| 247 |
+
'GetEnvironmentVariable', 'GetErrMessage', 'GetFormula',
|
| 248 |
+
'GetIndependentModuleName', 'GetIndexedObjName', 'GetIndexedObjNameDFR',
|
| 249 |
+
'GetKeyState', 'GetRTErrMessage', 'GetRTError', 'GetRTLocation', 'GetRTLocInfo',
|
| 250 |
+
'GetRTStackInfo', 'GetScrapText', 'GetUserData', 'GetWavesDataFolder',
|
| 251 |
+
'GetWavesDataFolderDFR', 'GetWindowBrowserSelection', 'GISGetAllFileFormats',
|
| 252 |
+
'GISSRefsAreEqual', 'GizmoInfo', 'GizmoScale', 'gnoise', 'GrepList',
|
| 253 |
+
'GrepString', 'GuideInfo', 'GuideNameList', 'Hash', 'hcsr', 'HDF5AttributeInfo',
|
| 254 |
+
'HDF5DatasetInfo', 'HDF5LibraryInfo', 'HDF5LinkInfo', 'HDF5TypeInfo', 'hermite',
|
| 255 |
+
'hermiteGauss', 'HyperGNoise', 'HyperGPFQ', 'HyperG0F1', 'HyperG1F1',
|
| 256 |
+
'HyperG2F1', 'i', 'IgorInfo', 'IgorVersion', 'imag', 'ImageInfo',
|
| 257 |
+
'ImageNameList', 'ImageNameToWaveRef', 'IndependentModuleList', 'IndexedDir',
|
| 258 |
+
'IndexedFile', 'IndexToScale', 'Inf', 'Integrate1D', 'interp', 'Interp2D',
|
| 259 |
+
'Interp3D', 'inverseERF', 'inverseERFC', 'ItemsInList', 'JacobiCn', 'JacobiSn',
|
| 260 |
+
'JulianToDate', 'Laguerre', 'LaguerreA', 'LaguerreGauss', 'LambertW',
|
| 261 |
+
'LayoutInfo', 'leftx', 'LegendreA', 'limit', 'ListMatch', 'ListToTextWave',
|
| 262 |
+
'ListToWaveRefWave', 'ln', 'log', 'logNormalNoise', 'lorentzianNoise',
|
| 263 |
+
'LowerStr', 'MacroInfo', 'MacroList', 'MacroPath', 'magsqr', 'MandelbrotPoint',
|
| 264 |
+
'MarcumQ', 'MatrixCondition', 'MatrixDet', 'MatrixDot', 'MatrixRank',
|
| 265 |
+
'MatrixTrace', 'max', 'MCC_AutoBridgeBal', 'MCC_AutoFastComp',
|
| 266 |
+
'MCC_AutoPipetteOffset', 'MCC_AutoSlowComp', 'MCC_AutoWholeCellComp',
|
| 267 |
+
'MCC_GetBridgeBalEnable', 'MCC_GetBridgeBalResist', 'MCC_GetFastCompCap',
|
| 268 |
+
'MCC_GetFastCompTau', 'MCC_GetHolding', 'MCC_GetHoldingEnable', 'MCC_GetMode',
|
| 269 |
+
'MCC_GetNeutralizationCap', 'MCC_GetNeutralizationEnable',
|
| 270 |
+
'MCC_GetOscKillerEnable', 'MCC_GetPipetteOffset', 'MCC_GetPrimarySignalGain',
|
| 271 |
+
'MCC_GetPrimarySignalHPF', 'MCC_GetPrimarySignalLPF', 'MCC_GetRsCompBandwidth',
|
| 272 |
+
'MCC_GetRsCompCorrection', 'MCC_GetRsCompEnable', 'MCC_GetRsCompPrediction',
|
| 273 |
+
'MCC_GetSecondarySignalGain', 'MCC_GetSecondarySignalLPF', 'MCC_GetSlowCompCap',
|
| 274 |
+
'MCC_GetSlowCompTau', 'MCC_GetSlowCompTauX20Enable',
|
| 275 |
+
'MCC_GetSlowCurrentInjEnable', 'MCC_GetSlowCurrentInjLevel',
|
| 276 |
+
'MCC_GetSlowCurrentInjSetlTime', 'MCC_GetWholeCellCompCap',
|
| 277 |
+
'MCC_GetWholeCellCompEnable', 'MCC_GetWholeCellCompResist',
|
| 278 |
+
'MCC_SelectMultiClamp700B', 'MCC_SetBridgeBalEnable', 'MCC_SetBridgeBalResist',
|
| 279 |
+
'MCC_SetFastCompCap', 'MCC_SetFastCompTau', 'MCC_SetHolding',
|
| 280 |
+
'MCC_SetHoldingEnable', 'MCC_SetMode', 'MCC_SetNeutralizationCap',
|
| 281 |
+
'MCC_SetNeutralizationEnable', 'MCC_SetOscKillerEnable', 'MCC_SetPipetteOffset',
|
| 282 |
+
'MCC_SetPrimarySignalGain', 'MCC_SetPrimarySignalHPF', 'MCC_SetPrimarySignalLPF',
|
| 283 |
+
'MCC_SetRsCompBandwidth', 'MCC_SetRsCompCorrection', 'MCC_SetRsCompEnable',
|
| 284 |
+
'MCC_SetRsCompPrediction', 'MCC_SetSecondarySignalGain',
|
| 285 |
+
'MCC_SetSecondarySignalLPF', 'MCC_SetSlowCompCap', 'MCC_SetSlowCompTau',
|
| 286 |
+
'MCC_SetSlowCompTauX20Enable', 'MCC_SetSlowCurrentInjEnable',
|
| 287 |
+
'MCC_SetSlowCurrentInjLevel', 'MCC_SetSlowCurrentInjSetlTime',
|
| 288 |
+
'MCC_SetTimeoutMs', 'MCC_SetWholeCellCompCap', 'MCC_SetWholeCellCompEnable',
|
| 289 |
+
'MCC_SetWholeCellCompResist', 'mean', 'median', 'min', 'mod', 'ModDate',
|
| 290 |
+
'MPFXEMGPeak', 'MPFXExpConvExpPeak', 'MPFXGaussPeak', 'MPFXLorentzianPeak',
|
| 291 |
+
'MPFXVoigtPeak', 'NameOfWave', 'NaN', 'NewFreeDataFolder', 'NewFreeWave', 'norm',
|
| 292 |
+
'NormalizeUnicode', 'note', 'NumberByKey', 'numpnts', 'numtype',
|
| 293 |
+
'NumVarOrDefault', 'num2char', 'num2istr', 'num2str', 'NVAR_Exists',
|
| 294 |
+
'OperationList', 'PadString', 'PanelResolution', 'ParamIsDefault',
|
| 295 |
+
'ParseFilePath', 'PathList', 'pcsr', 'Pi', 'PICTInfo', 'PICTList',
|
| 296 |
+
'PixelFromAxisVal', 'pnt2x', 'poissonNoise', 'poly', 'PolygonArea', 'poly2D',
|
| 297 |
+
'PossiblyQuoteName', 'ProcedureText', 'ProcedureVersion', 'p2rect', 'qcsr',
|
| 298 |
+
'real', 'RemoveByKey', 'RemoveEnding', 'RemoveFromList', 'RemoveListItem',
|
| 299 |
+
'ReplaceNumberByKey', 'ReplaceString', 'ReplaceStringByKey', 'ReplicateString',
|
| 300 |
+
'rightx', 'round', 'r2polar', 'sawtooth', 'scaleToIndex', 'ScreenResolution',
|
| 301 |
+
'sec', 'sech', 'Secs2Date', 'Secs2Time', 'SelectNumber', 'SelectString',
|
| 302 |
+
'SetEnvironmentVariable', 'sign', 'sin', 'sinc', 'sinh', 'sinIntegral',
|
| 303 |
+
'SortList', 'SpecialCharacterInfo', 'SpecialCharacterList', 'SpecialDirPath',
|
| 304 |
+
'SphericalBessJ', 'SphericalBessJD', 'SphericalBessY', 'SphericalBessYD',
|
| 305 |
+
'SphericalHarmonics', 'SQLAllocHandle', 'SQLAllocStmt',
|
| 306 |
+
'SQLBinaryWavesToTextWave', 'SQLBindCol', 'SQLBindParameter', 'SQLBrowseConnect',
|
| 307 |
+
'SQLBulkOperations', 'SQLCancel', 'SQLCloseCursor', 'SQLColAttributeNum',
|
| 308 |
+
'SQLColAttributeStr', 'SQLColumnPrivileges', 'SQLColumns', 'SQLConnect',
|
| 309 |
+
'SQLDataSources', 'SQLDescribeCol', 'SQLDescribeParam', 'SQLDisconnect',
|
| 310 |
+
'SQLDriverConnect', 'SQLDrivers', 'SQLEndTran', 'SQLError', 'SQLExecDirect',
|
| 311 |
+
'SQLExecute', 'SQLFetch', 'SQLFetchScroll', 'SQLForeignKeys', 'SQLFreeConnect',
|
| 312 |
+
'SQLFreeEnv', 'SQLFreeHandle', 'SQLFreeStmt', 'SQLGetConnectAttrNum',
|
| 313 |
+
'SQLGetConnectAttrStr', 'SQLGetCursorName', 'SQLGetDataNum', 'SQLGetDataStr',
|
| 314 |
+
'SQLGetDescFieldNum', 'SQLGetDescFieldStr', 'SQLGetDescRec',
|
| 315 |
+
'SQLGetDiagFieldNum', 'SQLGetDiagFieldStr', 'SQLGetDiagRec', 'SQLGetEnvAttrNum',
|
| 316 |
+
'SQLGetEnvAttrStr', 'SQLGetFunctions', 'SQLGetInfoNum', 'SQLGetInfoStr',
|
| 317 |
+
'SQLGetStmtAttrNum', 'SQLGetStmtAttrStr', 'SQLGetTypeInfo', 'SQLMoreResults',
|
| 318 |
+
'SQLNativeSql', 'SQLNumParams', 'SQLNumResultCols', 'SQLNumResultRowsIfKnown',
|
| 319 |
+
'SQLNumRowsFetched', 'SQLParamData', 'SQLPrepare', 'SQLPrimaryKeys',
|
| 320 |
+
'SQLProcedureColumns', 'SQLProcedures', 'SQLPutData', 'SQLReinitialize',
|
| 321 |
+
'SQLRowCount', 'SQLSetConnectAttrNum', 'SQLSetConnectAttrStr',
|
| 322 |
+
'SQLSetCursorName', 'SQLSetDescFieldNum', 'SQLSetDescFieldStr', 'SQLSetDescRec',
|
| 323 |
+
'SQLSetEnvAttrNum', 'SQLSetEnvAttrStr', 'SQLSetPos', 'SQLSetStmtAttrNum',
|
| 324 |
+
'SQLSetStmtAttrStr', 'SQLSpecialColumns', 'SQLStatistics', 'SQLTablePrivileges',
|
| 325 |
+
'SQLTables', 'SQLTextWaveToBinaryWaves', 'SQLTextWaveTo2DBinaryWave',
|
| 326 |
+
'SQLUpdateBoundValues', 'SQLXOPCheckState', 'SQL2DBinaryWaveToTextWave', 'sqrt',
|
| 327 |
+
'StartMSTimer', 'StatsBetaCDF', 'StatsBetaPDF', 'StatsBinomialCDF',
|
| 328 |
+
'StatsBinomialPDF', 'StatsCauchyCDF', 'StatsCauchyPDF', 'StatsChiCDF',
|
| 329 |
+
'StatsChiPDF', 'StatsCMSSDCDF', 'StatsCorrelation', 'StatsDExpCDF',
|
| 330 |
+
'StatsDExpPDF', 'StatsErlangCDF', 'StatsErlangPDF', 'StatsErrorPDF',
|
| 331 |
+
'StatsEValueCDF', 'StatsEValuePDF', 'StatsExpCDF', 'StatsExpPDF', 'StatsFCDF',
|
| 332 |
+
'StatsFPDF', 'StatsFriedmanCDF', 'StatsGammaCDF', 'StatsGammaPDF',
|
| 333 |
+
'StatsGeometricCDF', 'StatsGeometricPDF', 'StatsGEVCDF', 'StatsGEVPDF',
|
| 334 |
+
'StatsHyperGCDF', 'StatsHyperGPDF', 'StatsInvBetaCDF', 'StatsInvBinomialCDF',
|
| 335 |
+
'StatsInvCauchyCDF', 'StatsInvChiCDF', 'StatsInvCMSSDCDF', 'StatsInvDExpCDF',
|
| 336 |
+
'StatsInvEValueCDF', 'StatsInvExpCDF', 'StatsInvFCDF', 'StatsInvFriedmanCDF',
|
| 337 |
+
'StatsInvGammaCDF', 'StatsInvGeometricCDF', 'StatsInvKuiperCDF',
|
| 338 |
+
'StatsInvLogisticCDF', 'StatsInvLogNormalCDF', 'StatsInvMaxwellCDF',
|
| 339 |
+
'StatsInvMooreCDF', 'StatsInvNBinomialCDF', 'StatsInvNCChiCDF', 'StatsInvNCFCDF',
|
| 340 |
+
'StatsInvNormalCDF', 'StatsInvParetoCDF', 'StatsInvPoissonCDF',
|
| 341 |
+
'StatsInvPowerCDF', 'StatsInvQCDF', 'StatsInvQpCDF', 'StatsInvRayleighCDF',
|
| 342 |
+
'StatsInvRectangularCDF', 'StatsInvSpearmanCDF', 'StatsInvStudentCDF',
|
| 343 |
+
'StatsInvTopDownCDF', 'StatsInvTriangularCDF', 'StatsInvUsquaredCDF',
|
| 344 |
+
'StatsInvVonMisesCDF', 'StatsInvWeibullCDF', 'StatsKuiperCDF',
|
| 345 |
+
'StatsLogisticCDF', 'StatsLogisticPDF', 'StatsLogNormalCDF', 'StatsLogNormalPDF',
|
| 346 |
+
'StatsMaxwellCDF', 'StatsMaxwellPDF', 'StatsMedian', 'StatsMooreCDF',
|
| 347 |
+
'StatsNBinomialCDF', 'StatsNBinomialPDF', 'StatsNCChiCDF', 'StatsNCChiPDF',
|
| 348 |
+
'StatsNCFCDF', 'StatsNCFPDF', 'StatsNCTCDF', 'StatsNCTPDF', 'StatsNormalCDF',
|
| 349 |
+
'StatsNormalPDF', 'StatsParetoCDF', 'StatsParetoPDF', 'StatsPermute',
|
| 350 |
+
'StatsPoissonCDF', 'StatsPoissonPDF', 'StatsPowerCDF', 'StatsPowerNoise',
|
| 351 |
+
'StatsPowerPDF', 'StatsQCDF', 'StatsQpCDF', 'StatsRayleighCDF',
|
| 352 |
+
'StatsRayleighPDF', 'StatsRectangularCDF', 'StatsRectangularPDF', 'StatsRunsCDF',
|
| 353 |
+
'StatsSpearmanRhoCDF', 'StatsStudentCDF', 'StatsStudentPDF', 'StatsTopDownCDF',
|
| 354 |
+
'StatsTriangularCDF', 'StatsTriangularPDF', 'StatsTrimmedMean',
|
| 355 |
+
'StatsUSquaredCDF', 'StatsVonMisesCDF', 'StatsVonMisesNoise', 'StatsVonMisesPDF',
|
| 356 |
+
'StatsWaldCDF', 'StatsWaldPDF', 'StatsWeibullCDF', 'StatsWeibullPDF',
|
| 357 |
+
'StopMSTimer', 'StringByKey', 'stringCRC', 'StringFromList', 'StringList',
|
| 358 |
+
'stringmatch', 'StringToUnsignedByteWave', 'strlen', 'strsearch',
|
| 359 |
+
'StrVarOrDefault', 'str2num', 'StudentA', 'StudentT', 'sum', 'SVAR_Exists',
|
| 360 |
+
'TableInfo', 'TagVal', 'TagWaveRef', 'tan', 'tanh', 'TDMAddChannel',
|
| 361 |
+
'TDMAddGroup', 'TDMAppendDataValues', 'TDMAppendDataValuesTime',
|
| 362 |
+
'TDMChannelPropertyExists', 'TDMCloseChannel', 'TDMCloseFile', 'TDMCloseGroup',
|
| 363 |
+
'TDMCreateChannelProperty', 'TDMCreateFile', 'TDMCreateFileProperty',
|
| 364 |
+
'TDMCreateGroupProperty', 'TDMFilePropertyExists', 'TDMGetChannelPropertyNames',
|
| 365 |
+
'TDMGetChannelPropertyNum', 'TDMGetChannelPropertyStr',
|
| 366 |
+
'TDMGetChannelPropertyTime', 'TDMGetChannelPropertyType', 'TDMGetChannels',
|
| 367 |
+
'TDMGetChannelStringPropertyLen', 'TDMGetDataType', 'TDMGetDataValues',
|
| 368 |
+
'TDMGetDataValuesTime', 'TDMGetFilePropertyNames', 'TDMGetFilePropertyNum',
|
| 369 |
+
'TDMGetFilePropertyStr', 'TDMGetFilePropertyTime', 'TDMGetFilePropertyType',
|
| 370 |
+
'TDMGetFileStringPropertyLen', 'TDMGetGroupPropertyNames',
|
| 371 |
+
'TDMGetGroupPropertyNum', 'TDMGetGroupPropertyStr', 'TDMGetGroupPropertyTime',
|
| 372 |
+
'TDMGetGroupPropertyType', 'TDMGetGroups', 'TDMGetGroupStringPropertyLen',
|
| 373 |
+
'TDMGetLibraryErrorDescription', 'TDMGetNumChannelProperties',
|
| 374 |
+
'TDMGetNumChannels', 'TDMGetNumDataValues', 'TDMGetNumFileProperties',
|
| 375 |
+
'TDMGetNumGroupProperties', 'TDMGetNumGroups', 'TDMGroupPropertyExists',
|
| 376 |
+
'TDMOpenFile', 'TDMOpenFileEx', 'TDMRemoveChannel', 'TDMRemoveGroup',
|
| 377 |
+
'TDMReplaceDataValues', 'TDMReplaceDataValuesTime', 'TDMSaveFile',
|
| 378 |
+
'TDMSetChannelPropertyNum', 'TDMSetChannelPropertyStr',
|
| 379 |
+
'TDMSetChannelPropertyTime', 'TDMSetDataValues', 'TDMSetDataValuesTime',
|
| 380 |
+
'TDMSetFilePropertyNum', 'TDMSetFilePropertyStr', 'TDMSetFilePropertyTime',
|
| 381 |
+
'TDMSetGroupPropertyNum', 'TDMSetGroupPropertyStr', 'TDMSetGroupPropertyTime',
|
| 382 |
+
'TextEncodingCode', 'TextEncodingName', 'TextFile', 'ThreadGroupCreate',
|
| 383 |
+
'ThreadGroupGetDF', 'ThreadGroupGetDFR', 'ThreadGroupRelease', 'ThreadGroupWait',
|
| 384 |
+
'ThreadProcessorCount', 'ThreadReturnValue', 'ticks', 'time', 'TraceFromPixel',
|
| 385 |
+
'TraceInfo', 'TraceNameList', 'TraceNameToWaveRef', 'TrimString', 'trunc',
|
| 386 |
+
'UniqueName', 'UnPadString', 'UnsetEnvironmentVariable', 'UpperStr', 'URLDecode',
|
| 387 |
+
'URLEncode', 'VariableList', 'Variance', 'vcsr', 'viAssertIntrSignal',
|
| 388 |
+
'viAssertTrigger', 'viAssertUtilSignal', 'viClear', 'viClose', 'viDisableEvent',
|
| 389 |
+
'viDiscardEvents', 'viEnableEvent', 'viFindNext', 'viFindRsrc', 'viGetAttribute',
|
| 390 |
+
'viGetAttributeString', 'viGpibCommand', 'viGpibControlATN', 'viGpibControlREN',
|
| 391 |
+
'viGpibPassControl', 'viGpibSendIFC', 'viIn8', 'viIn16', 'viIn32', 'viLock',
|
| 392 |
+
'viMapAddress', 'viMapTrigger', 'viMemAlloc', 'viMemFree', 'viMoveIn8',
|
| 393 |
+
'viMoveIn16', 'viMoveIn32', 'viMoveOut8', 'viMoveOut16', 'viMoveOut32', 'viOpen',
|
| 394 |
+
'viOpenDefaultRM', 'viOut8', 'viOut16', 'viOut32', 'viPeek8', 'viPeek16',
|
| 395 |
+
'viPeek32', 'viPoke8', 'viPoke16', 'viPoke32', 'viRead', 'viReadSTB',
|
| 396 |
+
'viSetAttribute', 'viSetAttributeString', 'viStatusDesc', 'viTerminate',
|
| 397 |
+
'viUnlock', 'viUnmapAddress', 'viUnmapTrigger', 'viUsbControlIn',
|
| 398 |
+
'viUsbControlOut', 'viVxiCommandQuery', 'viWaitOnEvent', 'viWrite', 'VoigtFunc',
|
| 399 |
+
'VoigtPeak', 'WaveCRC', 'WaveDataToString', 'WaveDims', 'WaveExists', 'WaveHash',
|
| 400 |
+
'WaveInfo', 'WaveList', 'WaveMax', 'WaveMin', 'WaveMinAndMax', 'WaveModCount',
|
| 401 |
+
'WaveName', 'WaveRefIndexed', 'WaveRefIndexedDFR', 'WaveRefsEqual',
|
| 402 |
+
'WaveRefWaveToList', 'WaveTextEncoding', 'WaveType', 'WaveUnits',
|
| 403 |
+
'WhichListItem', 'WinList', 'WinName', 'WinRecreation', 'WinType', 'wnoise',
|
| 404 |
+
'xcsr', 'XWaveName', 'XWaveRefFromTrace', 'x2pnt', 'zcsr', 'ZernikeR',
|
| 405 |
+
'zeromq_client_connect', 'zeromq_client_recv', 'zeromq_client_send',
|
| 406 |
+
'zeromq_handler_start', 'zeromq_handler_stop', 'zeromq_pub_bind',
|
| 407 |
+
'zeromq_pub_send', 'zeromq_server_bind', 'zeromq_server_recv',
|
| 408 |
+
'zeromq_server_send', 'zeromq_set', 'zeromq_set_logging_template', 'zeromq_stop',
|
| 409 |
+
'zeromq_sub_add_filter', 'zeromq_sub_connect', 'zeromq_sub_recv',
|
| 410 |
+
'zeromq_sub_remove_filter', 'zeromq_test_callfunction',
|
| 411 |
+
'zeromq_test_serializeWave', 'zeta'
|
| 412 |
+
)
|
| 413 |
+
|
| 414 |
+
tokens = {
|
| 415 |
+
'root': [
|
| 416 |
+
(r'//.*$', Comment.Single),
|
| 417 |
+
(r'"([^"\\]|\\.)*"', String),
|
| 418 |
+
# Flow Control.
|
| 419 |
+
(words(flowControl, prefix=r'\b', suffix=r'\b'), Keyword),
|
| 420 |
+
# Types.
|
| 421 |
+
(words(types, prefix=r'\b', suffix=r'\b'), Keyword.Type),
|
| 422 |
+
# Keywords.
|
| 423 |
+
(words(keywords, prefix=r'\b', suffix=r'\b'), Keyword.Reserved),
|
| 424 |
+
# Built-in operations.
|
| 425 |
+
(words(operations, prefix=r'\b', suffix=r'\b'), Name.Class),
|
| 426 |
+
# Built-in functions.
|
| 427 |
+
(words(functions, prefix=r'\b', suffix=r'\b'), Name.Function),
|
| 428 |
+
# Compiler directives.
|
| 429 |
+
(r'^#(include|pragma|define|undef|ifdef|ifndef|if|elif|else|endif)',
|
| 430 |
+
Name.Decorator),
|
| 431 |
+
(r'\s+', Whitespace),
|
| 432 |
+
(r'[^a-z"/]+$', Text),
|
| 433 |
+
(r'.', Text),
|
| 434 |
+
],
|
| 435 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/inferno.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.inferno
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for Inferno os and all the related stuff.
|
| 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
|
| 14 |
+
from pygments.token import Punctuation, Comment, Operator, Keyword, \
|
| 15 |
+
Name, String, Number, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['LimboLexer']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class LimboLexer(RegexLexer):
|
| 21 |
+
"""
|
| 22 |
+
Lexer for Limbo programming language
|
| 23 |
+
|
| 24 |
+
TODO:
|
| 25 |
+
- maybe implement better var declaration highlighting
|
| 26 |
+
- some simple syntax error highlighting
|
| 27 |
+
"""
|
| 28 |
+
name = 'Limbo'
|
| 29 |
+
url = 'http://www.vitanuova.com/inferno/limbo.html'
|
| 30 |
+
aliases = ['limbo']
|
| 31 |
+
filenames = ['*.b']
|
| 32 |
+
mimetypes = ['text/limbo']
|
| 33 |
+
version_added = '2.0'
|
| 34 |
+
|
| 35 |
+
tokens = {
|
| 36 |
+
'whitespace': [
|
| 37 |
+
(r'^(\s*)([a-zA-Z_]\w*:)(\s*\n)',
|
| 38 |
+
bygroups(Whitespace, Name.Label, Whitespace)),
|
| 39 |
+
(r'\n', Whitespace),
|
| 40 |
+
(r'\s+', Whitespace),
|
| 41 |
+
(r'#(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
| 42 |
+
],
|
| 43 |
+
'string': [
|
| 44 |
+
(r'"', String, '#pop'),
|
| 45 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
|
| 46 |
+
r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
|
| 47 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 48 |
+
(r'\\', String), # stray backslash
|
| 49 |
+
],
|
| 50 |
+
'statements': [
|
| 51 |
+
(r'"', String, 'string'),
|
| 52 |
+
(r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
|
| 53 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
|
| 54 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])', Number.Float),
|
| 55 |
+
(r'16r[0-9a-fA-F]+', Number.Hex),
|
| 56 |
+
(r'8r[0-7]+', Number.Oct),
|
| 57 |
+
(r'((([1-3]\d)|([2-9]))r)?(\d+)', Number.Integer),
|
| 58 |
+
(r'[()\[\],.]', Punctuation),
|
| 59 |
+
(r'[~!%^&*+=|?:<>/-]|(->)|(<-)|(=>)|(::)', Operator),
|
| 60 |
+
(r'(alt|break|case|continue|cyclic|do|else|exit'
|
| 61 |
+
r'for|hd|if|implement|import|include|len|load|or'
|
| 62 |
+
r'pick|return|spawn|tagof|tl|to|while)\b', Keyword),
|
| 63 |
+
(r'(byte|int|big|real|string|array|chan|list|adt'
|
| 64 |
+
r'|fn|ref|of|module|self|type)\b', Keyword.Type),
|
| 65 |
+
(r'(con|iota|nil)\b', Keyword.Constant),
|
| 66 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 67 |
+
],
|
| 68 |
+
'statement' : [
|
| 69 |
+
include('whitespace'),
|
| 70 |
+
include('statements'),
|
| 71 |
+
('[{}]', Punctuation),
|
| 72 |
+
(';', Punctuation, '#pop'),
|
| 73 |
+
],
|
| 74 |
+
'root': [
|
| 75 |
+
include('whitespace'),
|
| 76 |
+
default('statement'),
|
| 77 |
+
],
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
def analyse_text(text):
|
| 81 |
+
# Any limbo module implements something
|
| 82 |
+
if re.search(r'^implement \w+;', text, re.MULTILINE):
|
| 83 |
+
return 0.7
|
| 84 |
+
|
| 85 |
+
# TODO:
|
| 86 |
+
# - Make lexers for:
|
| 87 |
+
# - asm sources
|
| 88 |
+
# - man pages
|
| 89 |
+
# - mkfiles
|
| 90 |
+
# - module definitions
|
| 91 |
+
# - namespace definitions
|
| 92 |
+
# - shell scripts
|
| 93 |
+
# - maybe keyfiles and fonts
|
| 94 |
+
# they all seem to be quite similar to their equivalents
|
| 95 |
+
# from unix world, so there should not be a lot of problems
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/installers.py
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.installers
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for installer/packager DSLs and 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.lexer import RegexLexer, include, bygroups, using, this, default
|
| 14 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 15 |
+
Punctuation, Generic, Number, Whitespace
|
| 16 |
+
|
| 17 |
+
__all__ = ['NSISLexer', 'RPMSpecLexer',
|
| 18 |
+
'DebianSourcesLexer', 'SourcesListLexer',
|
| 19 |
+
'DebianControlLexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class NSISLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For NSIS scripts.
|
| 25 |
+
"""
|
| 26 |
+
name = 'NSIS'
|
| 27 |
+
url = 'http://nsis.sourceforge.net/'
|
| 28 |
+
aliases = ['nsis', 'nsi', 'nsh']
|
| 29 |
+
filenames = ['*.nsi', '*.nsh']
|
| 30 |
+
mimetypes = ['text/x-nsis']
|
| 31 |
+
version_added = '1.6'
|
| 32 |
+
|
| 33 |
+
flags = re.IGNORECASE
|
| 34 |
+
|
| 35 |
+
tokens = {
|
| 36 |
+
'root': [
|
| 37 |
+
(r'([;#].*)(\n)', bygroups(Comment, Whitespace)),
|
| 38 |
+
(r"'.*?'", String.Single),
|
| 39 |
+
(r'"', String.Double, 'str_double'),
|
| 40 |
+
(r'`', String.Backtick, 'str_backtick'),
|
| 41 |
+
include('macro'),
|
| 42 |
+
include('interpol'),
|
| 43 |
+
include('basic'),
|
| 44 |
+
(r'\$\{[a-z_|][\w|]*\}', Keyword.Pseudo),
|
| 45 |
+
(r'/[a-z_]\w*', Name.Attribute),
|
| 46 |
+
(r'\s+', Whitespace),
|
| 47 |
+
(r'[\w.]+', Text),
|
| 48 |
+
],
|
| 49 |
+
'basic': [
|
| 50 |
+
(r'(\n)(Function)(\s+)([._a-z][.\w]*)\b',
|
| 51 |
+
bygroups(Whitespace, Keyword, Whitespace, Name.Function)),
|
| 52 |
+
(r'\b([_a-z]\w*)(::)([a-z][a-z0-9]*)\b',
|
| 53 |
+
bygroups(Keyword.Namespace, Punctuation, Name.Function)),
|
| 54 |
+
(r'\b([_a-z]\w*)(:)', bygroups(Name.Label, Punctuation)),
|
| 55 |
+
(r'(\b[ULS]|\B)([!<>=]?=|\<\>?|\>)\B', Operator),
|
| 56 |
+
(r'[|+-]', Operator),
|
| 57 |
+
(r'\\', Punctuation),
|
| 58 |
+
(r'\b(Abort|Add(?:BrandingImage|Size)|'
|
| 59 |
+
r'Allow(?:RootDirInstall|SkipFiles)|AutoCloseWindow|'
|
| 60 |
+
r'BG(?:Font|Gradient)|BrandingText|BringToFront|Call(?:InstDLL)?|'
|
| 61 |
+
r'(?:Sub)?Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|'
|
| 62 |
+
r'ComponentText|CopyFiles|CRCCheck|'
|
| 63 |
+
r'Create(?:Directory|Font|Shortcut)|Delete(?:INI(?:Sec|Str)|'
|
| 64 |
+
r'Reg(?:Key|Value))?|DetailPrint|DetailsButtonText|'
|
| 65 |
+
r'Dir(?:Show|Text|Var|Verify)|(?:Disabled|Enabled)Bitmap|'
|
| 66 |
+
r'EnableWindow|EnumReg(?:Key|Value)|Exch|Exec(?:Shell|Wait)?|'
|
| 67 |
+
r'ExpandEnvStrings|File(?:BufSize|Close|ErrorText|Open|'
|
| 68 |
+
r'Read(?:Byte)?|Seek|Write(?:Byte)?)?|'
|
| 69 |
+
r'Find(?:Close|First|Next|Window)|FlushINI|Function(?:End)?|'
|
| 70 |
+
r'Get(?:CurInstType|CurrentAddress|DlgItem|DLLVersion(?:Local)?|'
|
| 71 |
+
r'ErrorLevel|FileTime(?:Local)?|FullPathName|FunctionAddress|'
|
| 72 |
+
r'InstDirError|LabelAddress|TempFileName)|'
|
| 73 |
+
r'Goto|HideWindow|Icon|'
|
| 74 |
+
r'If(?:Abort|Errors|FileExists|RebootFlag|Silent)|'
|
| 75 |
+
r'InitPluginsDir|Install(?:ButtonText|Colors|Dir(?:RegKey)?)|'
|
| 76 |
+
r'Inst(?:ProgressFlags|Type(?:[GS]etText)?)|Int(?:CmpU?|Fmt|Op)|'
|
| 77 |
+
r'IsWindow|LangString(?:UP)?|'
|
| 78 |
+
r'License(?:BkColor|Data|ForceSelection|LangString|Text)|'
|
| 79 |
+
r'LoadLanguageFile|LockWindow|Log(?:Set|Text)|MessageBox|'
|
| 80 |
+
r'MiscButtonText|Name|Nop|OutFile|(?:Uninst)?Page(?:Ex(?:End)?)?|'
|
| 81 |
+
r'PluginDir|Pop|Push|Quit|Read(?:(?:Env|INI|Reg)Str|RegDWORD)|'
|
| 82 |
+
r'Reboot|(?:Un)?RegDLL|Rename|RequestExecutionLevel|ReserveFile|'
|
| 83 |
+
r'Return|RMDir|SearchPath|Section(?:Divider|End|'
|
| 84 |
+
r'(?:(?:Get|Set)(?:Flags|InstTypes|Size|Text))|Group(?:End)?|In)?|'
|
| 85 |
+
r'SendMessage|Set(?:AutoClose|BrandingImage|Compress(?:ionLevel|'
|
| 86 |
+
r'or(?:DictSize)?)?|CtlColors|CurInstType|DatablockOptimize|'
|
| 87 |
+
r'DateSave|Details(?:Print|View)|Error(?:s|Level)|FileAttributes|'
|
| 88 |
+
r'Font|OutPath|Overwrite|PluginUnload|RebootFlag|ShellVarContext|'
|
| 89 |
+
r'Silent|StaticBkColor)|'
|
| 90 |
+
r'Show(?:(?:I|Uni)nstDetails|Window)|Silent(?:Un)?Install|Sleep|'
|
| 91 |
+
r'SpaceTexts|Str(?:CmpS?|Cpy|Len)|SubSection(?:End)?|'
|
| 92 |
+
r'Uninstall(?:ButtonText|(?:Sub)?Caption|EXEName|Icon|Text)|'
|
| 93 |
+
r'UninstPage|Var|VI(?:AddVersionKey|ProductVersion)|WindowIcon|'
|
| 94 |
+
r'Write(?:INIStr|Reg(:?Bin|DWORD|(?:Expand)?Str)|Uninstaller)|'
|
| 95 |
+
r'XPStyle)\b', Keyword),
|
| 96 |
+
(r'\b(CUR|END|(?:FILE_ATTRIBUTE_)?'
|
| 97 |
+
r'(?:ARCHIVE|HIDDEN|NORMAL|OFFLINE|READONLY|SYSTEM|TEMPORARY)|'
|
| 98 |
+
r'HK(CC|CR|CU|DD|LM|PD|U)|'
|
| 99 |
+
r'HKEY_(?:CLASSES_ROOT|CURRENT_(?:CONFIG|USER)|DYN_DATA|'
|
| 100 |
+
r'LOCAL_MACHINE|PERFORMANCE_DATA|USERS)|'
|
| 101 |
+
r'ID(?:ABORT|CANCEL|IGNORE|NO|OK|RETRY|YES)|'
|
| 102 |
+
r'MB_(?:ABORTRETRYIGNORE|DEFBUTTON[1-4]|'
|
| 103 |
+
r'ICON(?:EXCLAMATION|INFORMATION|QUESTION|STOP)|'
|
| 104 |
+
r'OK(?:CANCEL)?|RETRYCANCEL|RIGHT|SETFOREGROUND|TOPMOST|USERICON|'
|
| 105 |
+
r'YESNO(?:CANCEL)?)|SET|SHCTX|'
|
| 106 |
+
r'SW_(?:HIDE|SHOW(?:MAXIMIZED|MINIMIZED|NORMAL))|'
|
| 107 |
+
r'admin|all|auto|both|bottom|bzip2|checkbox|colored|current|false|'
|
| 108 |
+
r'force|hide|highest|if(?:diff|newer)|lastused|leave|left|'
|
| 109 |
+
r'listonly|lzma|nevershow|none|normal|off|on|pop|push|'
|
| 110 |
+
r'radiobuttons|right|show|silent|silentlog|smooth|textonly|top|'
|
| 111 |
+
r'true|try|user|zlib)\b', Name.Constant),
|
| 112 |
+
],
|
| 113 |
+
'macro': [
|
| 114 |
+
(r'\!(addincludedir(?:dir)?|addplugindir|appendfile|cd|define|'
|
| 115 |
+
r'delfilefile|echo(?:message)?|else|endif|error|execute|'
|
| 116 |
+
r'if(?:macro)?n?(?:def)?|include|insertmacro|macro(?:end)?|packhdr|'
|
| 117 |
+
r'search(?:parse|replace)|system|tempfilesymbol|undef|verbose|'
|
| 118 |
+
r'warning)\b', Comment.Preproc),
|
| 119 |
+
],
|
| 120 |
+
'interpol': [
|
| 121 |
+
(r'\$(R?[0-9])', Name.Builtin.Pseudo), # registers
|
| 122 |
+
(r'\$(ADMINTOOLS|APPDATA|CDBURN_AREA|COOKIES|COMMONFILES(?:32|64)|'
|
| 123 |
+
r'DESKTOP|DOCUMENTS|EXE(?:DIR|FILE|PATH)|FAVORITES|FONTS|HISTORY|'
|
| 124 |
+
r'HWNDPARENT|INTERNET_CACHE|LOCALAPPDATA|MUSIC|NETHOOD|PICTURES|'
|
| 125 |
+
r'PLUGINSDIR|PRINTHOOD|PROFILE|PROGRAMFILES(?:32|64)|QUICKLAUNCH|'
|
| 126 |
+
r'RECENT|RESOURCES(?:_LOCALIZED)?|SENDTO|SM(?:PROGRAMS|STARTUP)|'
|
| 127 |
+
r'STARTMENU|SYSDIR|TEMP(?:LATES)?|VIDEOS|WINDIR|\{NSISDIR\})',
|
| 128 |
+
Name.Builtin),
|
| 129 |
+
(r'\$(CMDLINE|INSTDIR|OUTDIR|LANGUAGE)', Name.Variable.Global),
|
| 130 |
+
(r'\$[a-z_]\w*', Name.Variable),
|
| 131 |
+
],
|
| 132 |
+
'str_double': [
|
| 133 |
+
(r'"', String.Double, '#pop'),
|
| 134 |
+
(r'\$(\\[nrt"]|\$)', String.Escape),
|
| 135 |
+
include('interpol'),
|
| 136 |
+
(r'[^"]+', String.Double),
|
| 137 |
+
],
|
| 138 |
+
'str_backtick': [
|
| 139 |
+
(r'`', String.Double, '#pop'),
|
| 140 |
+
(r'\$(\\[nrt"]|\$)', String.Escape),
|
| 141 |
+
include('interpol'),
|
| 142 |
+
(r'[^`]+', String.Double),
|
| 143 |
+
],
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class RPMSpecLexer(RegexLexer):
|
| 148 |
+
"""
|
| 149 |
+
For RPM ``.spec`` files.
|
| 150 |
+
"""
|
| 151 |
+
|
| 152 |
+
name = 'RPMSpec'
|
| 153 |
+
aliases = ['spec']
|
| 154 |
+
filenames = ['*.spec']
|
| 155 |
+
mimetypes = ['text/x-rpm-spec']
|
| 156 |
+
url = 'https://rpm-software-management.github.io/rpm/manual/spec.html'
|
| 157 |
+
version_added = '1.6'
|
| 158 |
+
|
| 159 |
+
_directives = ('(?:package|prep|build|install|clean|check|pre[a-z]*|'
|
| 160 |
+
'post[a-z]*|trigger[a-z]*|files)')
|
| 161 |
+
|
| 162 |
+
tokens = {
|
| 163 |
+
'root': [
|
| 164 |
+
(r'#.*$', Comment),
|
| 165 |
+
include('basic'),
|
| 166 |
+
],
|
| 167 |
+
'description': [
|
| 168 |
+
(r'^(%' + _directives + ')(.*)$',
|
| 169 |
+
bygroups(Name.Decorator, Text), '#pop'),
|
| 170 |
+
(r'\s+', Whitespace),
|
| 171 |
+
(r'.', Text),
|
| 172 |
+
],
|
| 173 |
+
'changelog': [
|
| 174 |
+
(r'\*.*$', Generic.Subheading),
|
| 175 |
+
(r'^(%' + _directives + ')(.*)$',
|
| 176 |
+
bygroups(Name.Decorator, Text), '#pop'),
|
| 177 |
+
(r'\s+', Whitespace),
|
| 178 |
+
(r'.', Text),
|
| 179 |
+
],
|
| 180 |
+
'string': [
|
| 181 |
+
(r'"', String.Double, '#pop'),
|
| 182 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
| 183 |
+
include('interpol'),
|
| 184 |
+
(r'.', String.Double),
|
| 185 |
+
],
|
| 186 |
+
'basic': [
|
| 187 |
+
include('macro'),
|
| 188 |
+
(r'(?i)^(Name|Version|Release|Epoch|Summary|Group|License|Packager|'
|
| 189 |
+
r'Vendor|Icon|URL|Distribution|Prefix|Patch[0-9]*|Source[0-9]*|'
|
| 190 |
+
r'Requires\(?[a-z]*\)?|[a-z]+Req|Obsoletes|Suggests|Provides|Conflicts|'
|
| 191 |
+
r'Build[a-z]+|[a-z]+Arch|Auto[a-z]+)(:)(.*)$',
|
| 192 |
+
bygroups(Generic.Heading, Punctuation, using(this))),
|
| 193 |
+
(r'^%description', Name.Decorator, 'description'),
|
| 194 |
+
(r'^%changelog', Name.Decorator, 'changelog'),
|
| 195 |
+
(r'^(%' + _directives + ')(.*)$', bygroups(Name.Decorator, Text)),
|
| 196 |
+
(r'%(attr|defattr|dir|doc(?:dir)?|setup|config(?:ure)?|'
|
| 197 |
+
r'make(?:install)|ghost|patch[0-9]+|find_lang|exclude|verify)',
|
| 198 |
+
Keyword),
|
| 199 |
+
include('interpol'),
|
| 200 |
+
(r"'.*?'", String.Single),
|
| 201 |
+
(r'"', String.Double, 'string'),
|
| 202 |
+
(r'\s+', Whitespace),
|
| 203 |
+
(r'.', Text),
|
| 204 |
+
],
|
| 205 |
+
'macro': [
|
| 206 |
+
(r'%define.*$', Comment.Preproc),
|
| 207 |
+
(r'%\{\!\?.*%define.*\}', Comment.Preproc),
|
| 208 |
+
(r'(%(?:if(?:n?arch)?|else(?:if)?|endif))(.*)$',
|
| 209 |
+
bygroups(Comment.Preproc, Text)),
|
| 210 |
+
],
|
| 211 |
+
'interpol': [
|
| 212 |
+
(r'%\{?__[a-z_]+\}?', Name.Function),
|
| 213 |
+
(r'%\{?_([a-z_]+dir|[a-z_]+path|prefix)\}?', Keyword.Pseudo),
|
| 214 |
+
(r'%\{\?\w+\}', Name.Variable),
|
| 215 |
+
(r'\$\{?RPM_[A-Z0-9_]+\}?', Name.Variable.Global),
|
| 216 |
+
(r'%\{[a-zA-Z]\w+\}', Keyword.Constant),
|
| 217 |
+
]
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
class DebianSourcesLexer(RegexLexer):
|
| 222 |
+
"""
|
| 223 |
+
Lexer that highlights debian.sources files.
|
| 224 |
+
"""
|
| 225 |
+
|
| 226 |
+
name = 'Debian Sources file'
|
| 227 |
+
aliases = ['debian.sources']
|
| 228 |
+
filenames = ['*.sources']
|
| 229 |
+
version_added = '2.19'
|
| 230 |
+
url = 'https://manpages.debian.org/bookworm/apt/sources.list.5.en.html#THE_DEB_AND_DEB-SRC_TYPES:_GENERAL_FORMAT'
|
| 231 |
+
|
| 232 |
+
tokens = {
|
| 233 |
+
'root': [
|
| 234 |
+
(r'^(Signed-By)(:)(\s*)', bygroups(Keyword, Punctuation, Whitespace), 'signed-by'),
|
| 235 |
+
(r'^([a-zA-Z\-0-9\.]*?)(:)(\s*)(.*?)$',
|
| 236 |
+
bygroups(Keyword, Punctuation, Whitespace, String)),
|
| 237 |
+
],
|
| 238 |
+
'signed-by': [
|
| 239 |
+
(r' -----END PGP PUBLIC KEY BLOCK-----\n', Text, '#pop'),
|
| 240 |
+
(r'.+\n', Text),
|
| 241 |
+
],
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
class SourcesListLexer(RegexLexer):
|
| 246 |
+
"""
|
| 247 |
+
Lexer that highlights debian sources.list files.
|
| 248 |
+
"""
|
| 249 |
+
|
| 250 |
+
name = 'Debian Sourcelist'
|
| 251 |
+
aliases = ['debsources', 'sourceslist', 'sources.list']
|
| 252 |
+
filenames = ['sources.list']
|
| 253 |
+
version_added = '0.7'
|
| 254 |
+
mimetype = ['application/x-debian-sourceslist']
|
| 255 |
+
url = 'https://wiki.debian.org/SourcesList'
|
| 256 |
+
|
| 257 |
+
tokens = {
|
| 258 |
+
'root': [
|
| 259 |
+
(r'\s+', Whitespace),
|
| 260 |
+
(r'#.*?$', Comment),
|
| 261 |
+
(r'^(deb(?:-src)?)(\s+)',
|
| 262 |
+
bygroups(Keyword, Whitespace), 'distribution')
|
| 263 |
+
],
|
| 264 |
+
'distribution': [
|
| 265 |
+
(r'#.*?$', Comment, '#pop'),
|
| 266 |
+
(r'\$\(ARCH\)', Name.Variable),
|
| 267 |
+
(r'[^\s$[]+', String),
|
| 268 |
+
(r'\[', String.Other, 'escaped-distribution'),
|
| 269 |
+
(r'\$', String),
|
| 270 |
+
(r'\s+', Whitespace, 'components')
|
| 271 |
+
],
|
| 272 |
+
'escaped-distribution': [
|
| 273 |
+
(r'\]', String.Other, '#pop'),
|
| 274 |
+
(r'\$\(ARCH\)', Name.Variable),
|
| 275 |
+
(r'[^\]$]+', String.Other),
|
| 276 |
+
(r'\$', String.Other)
|
| 277 |
+
],
|
| 278 |
+
'components': [
|
| 279 |
+
(r'#.*?$', Comment, '#pop:2'),
|
| 280 |
+
(r'$', Text, '#pop:2'),
|
| 281 |
+
(r'\s+', Whitespace),
|
| 282 |
+
(r'\S+', Keyword.Pseudo),
|
| 283 |
+
]
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
def analyse_text(text):
|
| 287 |
+
for line in text.splitlines():
|
| 288 |
+
line = line.strip()
|
| 289 |
+
if line.startswith('deb ') or line.startswith('deb-src '):
|
| 290 |
+
return True
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
class DebianControlLexer(RegexLexer):
|
| 294 |
+
"""
|
| 295 |
+
Lexer for Debian ``control`` files and ``apt-cache show <pkg>`` outputs.
|
| 296 |
+
"""
|
| 297 |
+
name = 'Debian Control file'
|
| 298 |
+
url = 'https://www.debian.org/doc/debian-policy/ch-controlfields.html'
|
| 299 |
+
aliases = ['debcontrol', 'control']
|
| 300 |
+
filenames = ['control']
|
| 301 |
+
version_added = '0.9'
|
| 302 |
+
|
| 303 |
+
tokens = {
|
| 304 |
+
'root': [
|
| 305 |
+
(r'^(Description)', Keyword, 'description'),
|
| 306 |
+
(r'^(Maintainer|Uploaders|Changed-By)(:)(\s*)',
|
| 307 |
+
bygroups(Keyword, Punctuation, Whitespace),
|
| 308 |
+
'maintainer'),
|
| 309 |
+
(r'^((?:Build-|Pre-)?Depends(?:-Indep|-Arch)?)(:)(\s*)',
|
| 310 |
+
bygroups(Keyword, Punctuation, Whitespace), 'package_list'),
|
| 311 |
+
(r'^(Recommends|Suggests|Enhances|Breaks|Replaces|Provides|Conflicts)(:)(\s*)',
|
| 312 |
+
bygroups(Keyword, Punctuation, Whitespace), 'package_list'),
|
| 313 |
+
(r'^((?:Python-)?Version)(:)(\s*)(\S+)$',
|
| 314 |
+
bygroups(Keyword, Punctuation, Whitespace, Number)),
|
| 315 |
+
(r'^((?:Installed-)?Size)(:)(\s*)(\S+)$',
|
| 316 |
+
bygroups(Keyword, Punctuation, Whitespace, Number)),
|
| 317 |
+
(r'^(MD5Sum|SHA1|SHA256)(:)(\s*)(\S+)$',
|
| 318 |
+
bygroups(Keyword, Punctuation, Whitespace, Number)),
|
| 319 |
+
(r'^([a-zA-Z\-0-9\.]*?)(:)(\s*)(.*?)$',
|
| 320 |
+
bygroups(Keyword, Punctuation, Whitespace, String)),
|
| 321 |
+
],
|
| 322 |
+
'maintainer': [
|
| 323 |
+
(r'<[^>]+>$', Generic.Strong, '#pop'),
|
| 324 |
+
(r'<[^>]+>', Generic.Strong),
|
| 325 |
+
(r',\n?', Whitespace),
|
| 326 |
+
(r'[^,<]+$', Text, '#pop'),
|
| 327 |
+
(r'[^,<]+', Text),
|
| 328 |
+
],
|
| 329 |
+
'description': [
|
| 330 |
+
(r'(.*)(Homepage)(: )(\S+)',
|
| 331 |
+
bygroups(Text, String, Name, Name.Class)),
|
| 332 |
+
(r':.*\n', Generic.Strong),
|
| 333 |
+
(r' .*\n', Text),
|
| 334 |
+
default('#pop'),
|
| 335 |
+
],
|
| 336 |
+
'package_list': [
|
| 337 |
+
(r'(\$)(\{)(\w+)(\s*)(:)(\s*)(\w+)(\})',
|
| 338 |
+
bygroups(Operator, Punctuation, Name.Entity, Whitespace,
|
| 339 |
+
Punctuation, Whitespace, Text, Punctuation)),
|
| 340 |
+
(r'\(', Punctuation, 'package_list_vers'),
|
| 341 |
+
(r'\|', Operator),
|
| 342 |
+
(r'\n\s', Whitespace),
|
| 343 |
+
(r'\n', Whitespace, '#pop'),
|
| 344 |
+
(r'[,\s]', Text),
|
| 345 |
+
(r'[+.a-zA-Z0-9-]+', Name.Function),
|
| 346 |
+
(r'(\[)(!?)(.*?)(\])', bygroups(Punctuation, Operator, Name.Entity, Punctuation)),
|
| 347 |
+
],
|
| 348 |
+
'package_list_vers': [
|
| 349 |
+
(r'\)', Punctuation, '#pop'),
|
| 350 |
+
(r'([><=]+)(\s*)([^)]+)', bygroups(Operator, Whitespace, Number)),
|
| 351 |
+
]
|
| 352 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/int_fiction.py
ADDED
|
@@ -0,0 +1,1370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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~~
|
| 4 |
+
|
| 5 |
+
Lexers for interactive fiction 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, \
|
| 14 |
+
this, default, words
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Error, Generic
|
| 17 |
+
|
| 18 |
+
__all__ = ['Inform6Lexer', 'Inform6TemplateLexer', 'Inform7Lexer',
|
| 19 |
+
'Tads3Lexer']
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class Inform6Lexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For Inform 6 source code.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
name = 'Inform 6'
|
| 28 |
+
url = 'http://inform-fiction.org/'
|
| 29 |
+
aliases = ['inform6', 'i6']
|
| 30 |
+
filenames = ['*.inf']
|
| 31 |
+
version_added = '2.0'
|
| 32 |
+
|
| 33 |
+
flags = re.MULTILINE | re.DOTALL
|
| 34 |
+
|
| 35 |
+
_name = r'[a-zA-Z_]\w*'
|
| 36 |
+
|
| 37 |
+
# Inform 7 maps these four character classes to their ASCII
|
| 38 |
+
# equivalents. To support Inform 6 inclusions within Inform 7,
|
| 39 |
+
# Inform6Lexer maps them too.
|
| 40 |
+
_dash = '\\-\u2010-\u2014'
|
| 41 |
+
_dquote = '"\u201c\u201d'
|
| 42 |
+
_squote = "'\u2018\u2019"
|
| 43 |
+
_newline = '\\n\u0085\u2028\u2029'
|
| 44 |
+
|
| 45 |
+
tokens = {
|
| 46 |
+
'root': [
|
| 47 |
+
(rf'\A(!%[^{_newline}]*[{_newline}])+', Comment.Preproc,
|
| 48 |
+
'directive'),
|
| 49 |
+
default('directive')
|
| 50 |
+
],
|
| 51 |
+
'_whitespace': [
|
| 52 |
+
(r'\s+', Text),
|
| 53 |
+
(rf'![^{_newline}]*', Comment.Single)
|
| 54 |
+
],
|
| 55 |
+
'default': [
|
| 56 |
+
include('_whitespace'),
|
| 57 |
+
(r'\[', Punctuation, 'many-values'), # Array initialization
|
| 58 |
+
(r':|(?=;)', Punctuation, '#pop'),
|
| 59 |
+
(r'<', Punctuation), # Second angle bracket in an action statement
|
| 60 |
+
default(('expression', '_expression'))
|
| 61 |
+
],
|
| 62 |
+
|
| 63 |
+
# Expressions
|
| 64 |
+
'_expression': [
|
| 65 |
+
include('_whitespace'),
|
| 66 |
+
(r'(?=sp\b)', Text, '#pop'),
|
| 67 |
+
(rf'(?=[{_dquote}{_squote}$0-9#a-zA-Z_])', Text,
|
| 68 |
+
('#pop', 'value')),
|
| 69 |
+
(rf'\+\+|[{_dash}]{{1,2}}(?!>)|~~?', Operator),
|
| 70 |
+
(rf'(?=[()\[{_dash},?@{{:;])', Text, '#pop')
|
| 71 |
+
],
|
| 72 |
+
'expression': [
|
| 73 |
+
include('_whitespace'),
|
| 74 |
+
(r'\(', Punctuation, ('expression', '_expression')),
|
| 75 |
+
(r'\)', Punctuation, '#pop'),
|
| 76 |
+
(r'\[', Punctuation, ('#pop', 'statements', 'locals')),
|
| 77 |
+
(rf'>(?=(\s+|(![^{_newline}]*))*[>;])', Punctuation),
|
| 78 |
+
(rf'\+\+|[{_dash}]{{2}}(?!>)', Operator),
|
| 79 |
+
(r',', Punctuation, '_expression'),
|
| 80 |
+
(rf'&&?|\|\|?|[=~><]?=|[{_dash}]{{1,2}}>?|\.\.?[&#]?|::|[<>+*/%]',
|
| 81 |
+
Operator, '_expression'),
|
| 82 |
+
(r'(has|hasnt|in|notin|ofclass|or|provides)\b', Operator.Word,
|
| 83 |
+
'_expression'),
|
| 84 |
+
(r'sp\b', Name),
|
| 85 |
+
(r'\?~?', Name.Label, 'label?'),
|
| 86 |
+
(r'[@{]', Error),
|
| 87 |
+
default('#pop')
|
| 88 |
+
],
|
| 89 |
+
'_assembly-expression': [
|
| 90 |
+
(r'\(', Punctuation, ('#push', '_expression')),
|
| 91 |
+
(r'[\[\]]', Punctuation),
|
| 92 |
+
(rf'[{_dash}]>', Punctuation, '_expression'),
|
| 93 |
+
(r'sp\b', Keyword.Pseudo),
|
| 94 |
+
(r';', Punctuation, '#pop:3'),
|
| 95 |
+
include('expression')
|
| 96 |
+
],
|
| 97 |
+
'_for-expression': [
|
| 98 |
+
(r'\)', Punctuation, '#pop:2'),
|
| 99 |
+
(r':', Punctuation, '#pop'),
|
| 100 |
+
include('expression')
|
| 101 |
+
],
|
| 102 |
+
'_keyword-expression': [
|
| 103 |
+
(r'(from|near|to)\b', Keyword, '_expression'),
|
| 104 |
+
include('expression')
|
| 105 |
+
],
|
| 106 |
+
'_list-expression': [
|
| 107 |
+
(r',', Punctuation, '#pop'),
|
| 108 |
+
include('expression')
|
| 109 |
+
],
|
| 110 |
+
'_object-expression': [
|
| 111 |
+
(r'has\b', Keyword.Declaration, '#pop'),
|
| 112 |
+
include('_list-expression')
|
| 113 |
+
],
|
| 114 |
+
|
| 115 |
+
# Values
|
| 116 |
+
'value': [
|
| 117 |
+
include('_whitespace'),
|
| 118 |
+
# Strings
|
| 119 |
+
(rf'[{_squote}][^@][{_squote}]', String.Char, '#pop'),
|
| 120 |
+
(rf'([{_squote}])(@\{{[0-9a-fA-F]*\}})([{_squote}])',
|
| 121 |
+
bygroups(String.Char, String.Escape, String.Char), '#pop'),
|
| 122 |
+
(rf'([{_squote}])(@.{{2}})([{_squote}])',
|
| 123 |
+
bygroups(String.Char, String.Escape, String.Char), '#pop'),
|
| 124 |
+
(rf'[{_squote}]', String.Single, ('#pop', 'dictionary-word')),
|
| 125 |
+
(rf'[{_dquote}]', String.Double, ('#pop', 'string')),
|
| 126 |
+
# Numbers
|
| 127 |
+
(rf'\$[<>]?[+{_dash}][0-9]*\.?[0-9]*([eE][+{_dash}]?[0-9]+)?',
|
| 128 |
+
Number.Float, '#pop'),
|
| 129 |
+
(r'\$[0-9a-fA-F]+', Number.Hex, '#pop'),
|
| 130 |
+
(r'\$\$[01]+', Number.Bin, '#pop'),
|
| 131 |
+
(r'[0-9]+', Number.Integer, '#pop'),
|
| 132 |
+
# Values prefixed by hashes
|
| 133 |
+
(rf'(##|#a\$)({_name})', bygroups(Operator, Name), '#pop'),
|
| 134 |
+
(rf'(#g\$)({_name})',
|
| 135 |
+
bygroups(Operator, Name.Variable.Global), '#pop'),
|
| 136 |
+
(r'#[nw]\$', Operator, ('#pop', 'obsolete-dictionary-word')),
|
| 137 |
+
(rf'(#r\$)({_name})', bygroups(Operator, Name.Function), '#pop'),
|
| 138 |
+
(r'#', Name.Builtin, ('#pop', 'system-constant')),
|
| 139 |
+
# System functions
|
| 140 |
+
(words((
|
| 141 |
+
'child', 'children', 'elder', 'eldest', 'glk', 'indirect', 'metaclass',
|
| 142 |
+
'parent', 'random', 'sibling', 'younger', 'youngest'), suffix=r'\b'),
|
| 143 |
+
Name.Builtin, '#pop'),
|
| 144 |
+
# Metaclasses
|
| 145 |
+
(r'(?i)(Class|Object|Routine|String)\b', Name.Builtin, '#pop'),
|
| 146 |
+
# Veneer routines
|
| 147 |
+
(words((
|
| 148 |
+
'Box__Routine', 'CA__Pr', 'CDefArt', 'CInDefArt', 'Cl__Ms',
|
| 149 |
+
'Copy__Primitive', 'CP__Tab', 'DA__Pr', 'DB__Pr', 'DefArt', 'Dynam__String',
|
| 150 |
+
'EnglishNumber', 'Glk__Wrap', 'IA__Pr', 'IB__Pr', 'InDefArt', 'Main__',
|
| 151 |
+
'Meta__class', 'OB__Move', 'OB__Remove', 'OC__Cl', 'OP__Pr', 'Print__Addr',
|
| 152 |
+
'Print__PName', 'PrintShortName', 'RA__Pr', 'RA__Sc', 'RL__Pr', 'R_Process',
|
| 153 |
+
'RT__ChG', 'RT__ChGt', 'RT__ChLDB', 'RT__ChLDW', 'RT__ChPR', 'RT__ChPrintA',
|
| 154 |
+
'RT__ChPrintC', 'RT__ChPrintO', 'RT__ChPrintS', 'RT__ChPS', 'RT__ChR',
|
| 155 |
+
'RT__ChSTB', 'RT__ChSTW', 'RT__ChT', 'RT__Err', 'RT__TrPS', 'RV__Pr',
|
| 156 |
+
'Symb__Tab', 'Unsigned__Compare', 'WV__Pr', 'Z__Region'),
|
| 157 |
+
prefix='(?i)', suffix=r'\b'),
|
| 158 |
+
Name.Builtin, '#pop'),
|
| 159 |
+
# Other built-in symbols
|
| 160 |
+
(words((
|
| 161 |
+
'call', 'copy', 'create', 'DEBUG', 'destroy', 'DICT_CHAR_SIZE',
|
| 162 |
+
'DICT_ENTRY_BYTES', 'DICT_IS_UNICODE', 'DICT_WORD_SIZE', 'DOUBLE_HI_INFINITY',
|
| 163 |
+
'DOUBLE_HI_NAN', 'DOUBLE_HI_NINFINITY', 'DOUBLE_LO_INFINITY', 'DOUBLE_LO_NAN',
|
| 164 |
+
'DOUBLE_LO_NINFINITY', 'false', 'FLOAT_INFINITY', 'FLOAT_NAN', 'FLOAT_NINFINITY',
|
| 165 |
+
'GOBJFIELD_CHAIN', 'GOBJFIELD_CHILD', 'GOBJFIELD_NAME', 'GOBJFIELD_PARENT',
|
| 166 |
+
'GOBJFIELD_PROPTAB', 'GOBJFIELD_SIBLING', 'GOBJ_EXT_START',
|
| 167 |
+
'GOBJ_TOTAL_LENGTH', 'Grammar__Version', 'INDIV_PROP_START', 'INFIX',
|
| 168 |
+
'infix__watching', 'MODULE_MODE', 'name', 'nothing', 'NUM_ATTR_BYTES', 'print',
|
| 169 |
+
'print_to_array', 'recreate', 'remaining', 'self', 'sender', 'STRICT_MODE',
|
| 170 |
+
'sw__var', 'sys__glob0', 'sys__glob1', 'sys__glob2', 'sys_statusline_flag',
|
| 171 |
+
'TARGET_GLULX', 'TARGET_ZCODE', 'temp__global2', 'temp__global3',
|
| 172 |
+
'temp__global4', 'temp_global', 'true', 'USE_MODULES', 'WORDSIZE'),
|
| 173 |
+
prefix='(?i)', suffix=r'\b'),
|
| 174 |
+
Name.Builtin, '#pop'),
|
| 175 |
+
# Other values
|
| 176 |
+
(_name, Name, '#pop')
|
| 177 |
+
],
|
| 178 |
+
'value?': [
|
| 179 |
+
include('value'),
|
| 180 |
+
default('#pop')
|
| 181 |
+
],
|
| 182 |
+
# Strings
|
| 183 |
+
'dictionary-word': [
|
| 184 |
+
(rf'[~^]+|//[^{_squote}]*', String.Escape),
|
| 185 |
+
(rf'[^~^/\\@({{{_squote}]+', String.Single),
|
| 186 |
+
(r'[/({]', String.Single),
|
| 187 |
+
(r'@\{[0-9a-fA-F]*\}', String.Escape),
|
| 188 |
+
(r'@.{2}', String.Escape),
|
| 189 |
+
(rf'[{_squote}]', String.Single, '#pop')
|
| 190 |
+
],
|
| 191 |
+
'string': [
|
| 192 |
+
(r'[~^]+', String.Escape),
|
| 193 |
+
(rf'[^~^\\@({{{_dquote}]+', String.Double),
|
| 194 |
+
(r'[({]', String.Double),
|
| 195 |
+
(r'\\', String.Escape),
|
| 196 |
+
(rf'@(\\\s*[{_newline}]\s*)*@((\\\s*[{_newline}]\s*)*[0-9])*', String.Escape),
|
| 197 |
+
(rf'@(\\\s*[{_newline}]\s*)*[({{]((\\\s*[{_newline}]\s*)*[0-9a-zA-Z_])*'
|
| 198 |
+
rf'(\\\s*[{_newline}]\s*)*[)}}]',
|
| 199 |
+
String.Escape),
|
| 200 |
+
(rf'@(\\\s*[{_newline}]\s*)*.(\\\s*[{_newline}]\s*)*.',
|
| 201 |
+
String.Escape),
|
| 202 |
+
(rf'[{_dquote}]', String.Double, '#pop')
|
| 203 |
+
],
|
| 204 |
+
'plain-string': [
|
| 205 |
+
(rf'[^~^\\({{\[\]{_dquote}]+', String.Double),
|
| 206 |
+
(r'[~^({\[\]]', String.Double),
|
| 207 |
+
(r'\\', String.Escape),
|
| 208 |
+
(rf'[{_dquote}]', String.Double, '#pop')
|
| 209 |
+
],
|
| 210 |
+
# Names
|
| 211 |
+
'_constant': [
|
| 212 |
+
include('_whitespace'),
|
| 213 |
+
(_name, Name.Constant, '#pop'),
|
| 214 |
+
include('value')
|
| 215 |
+
],
|
| 216 |
+
'constant*': [
|
| 217 |
+
include('_whitespace'),
|
| 218 |
+
(r',', Punctuation),
|
| 219 |
+
(r'=', Punctuation, 'value?'),
|
| 220 |
+
(_name, Name.Constant, 'value?'),
|
| 221 |
+
default('#pop')
|
| 222 |
+
],
|
| 223 |
+
'_global': [
|
| 224 |
+
include('_whitespace'),
|
| 225 |
+
(_name, Name.Variable.Global, '#pop'),
|
| 226 |
+
include('value')
|
| 227 |
+
],
|
| 228 |
+
'label?': [
|
| 229 |
+
include('_whitespace'),
|
| 230 |
+
(_name, Name.Label, '#pop'),
|
| 231 |
+
default('#pop')
|
| 232 |
+
],
|
| 233 |
+
'variable?': [
|
| 234 |
+
include('_whitespace'),
|
| 235 |
+
(_name, Name.Variable, '#pop'),
|
| 236 |
+
default('#pop')
|
| 237 |
+
],
|
| 238 |
+
# Values after hashes
|
| 239 |
+
'obsolete-dictionary-word': [
|
| 240 |
+
(r'\S\w*', String.Other, '#pop')
|
| 241 |
+
],
|
| 242 |
+
'system-constant': [
|
| 243 |
+
include('_whitespace'),
|
| 244 |
+
(_name, Name.Builtin, '#pop')
|
| 245 |
+
],
|
| 246 |
+
|
| 247 |
+
# Directives
|
| 248 |
+
'directive': [
|
| 249 |
+
include('_whitespace'),
|
| 250 |
+
(r'#', Punctuation),
|
| 251 |
+
(r';', Punctuation, '#pop'),
|
| 252 |
+
(r'\[', Punctuation,
|
| 253 |
+
('default', 'statements', 'locals', 'routine-name?')),
|
| 254 |
+
(words((
|
| 255 |
+
'abbreviate', 'endif', 'dictionary', 'ifdef', 'iffalse', 'ifndef', 'ifnot',
|
| 256 |
+
'iftrue', 'ifv3', 'ifv5', 'release', 'serial', 'switches', 'system_file',
|
| 257 |
+
'version'), prefix='(?i)', suffix=r'\b'),
|
| 258 |
+
Keyword, 'default'),
|
| 259 |
+
(r'(?i)(array|global)\b', Keyword,
|
| 260 |
+
('default', 'directive-keyword?', '_global')),
|
| 261 |
+
(r'(?i)attribute\b', Keyword, ('default', 'alias?', '_constant')),
|
| 262 |
+
(r'(?i)class\b', Keyword,
|
| 263 |
+
('object-body', 'duplicates', 'class-name')),
|
| 264 |
+
(r'(?i)(constant|default)\b', Keyword,
|
| 265 |
+
('default', 'constant*')),
|
| 266 |
+
(r'(?i)(end\b)(.*)', bygroups(Keyword, Text)),
|
| 267 |
+
(r'(?i)(extend|verb)\b', Keyword, 'grammar'),
|
| 268 |
+
(r'(?i)fake_action\b', Keyword, ('default', '_constant')),
|
| 269 |
+
(r'(?i)import\b', Keyword, 'manifest'),
|
| 270 |
+
(r'(?i)(include|link|origsource)\b', Keyword,
|
| 271 |
+
('default', 'before-plain-string?')),
|
| 272 |
+
(r'(?i)(lowstring|undef)\b', Keyword, ('default', '_constant')),
|
| 273 |
+
(r'(?i)message\b', Keyword, ('default', 'diagnostic')),
|
| 274 |
+
(r'(?i)(nearby|object)\b', Keyword,
|
| 275 |
+
('object-body', '_object-head')),
|
| 276 |
+
(r'(?i)property\b', Keyword,
|
| 277 |
+
('default', 'alias?', '_constant', 'property-keyword*')),
|
| 278 |
+
(r'(?i)replace\b', Keyword,
|
| 279 |
+
('default', 'routine-name?', 'routine-name?')),
|
| 280 |
+
(r'(?i)statusline\b', Keyword, ('default', 'directive-keyword?')),
|
| 281 |
+
(r'(?i)stub\b', Keyword, ('default', 'routine-name?')),
|
| 282 |
+
(r'(?i)trace\b', Keyword,
|
| 283 |
+
('default', 'trace-keyword?', 'trace-keyword?')),
|
| 284 |
+
(r'(?i)zcharacter\b', Keyword,
|
| 285 |
+
('default', 'directive-keyword?', 'directive-keyword?')),
|
| 286 |
+
(_name, Name.Class, ('object-body', '_object-head'))
|
| 287 |
+
],
|
| 288 |
+
# [, Replace, Stub
|
| 289 |
+
'routine-name?': [
|
| 290 |
+
include('_whitespace'),
|
| 291 |
+
(_name, Name.Function, '#pop'),
|
| 292 |
+
default('#pop')
|
| 293 |
+
],
|
| 294 |
+
'locals': [
|
| 295 |
+
include('_whitespace'),
|
| 296 |
+
(r';', Punctuation, '#pop'),
|
| 297 |
+
(r'\*', Punctuation),
|
| 298 |
+
(r'"', String.Double, 'plain-string'),
|
| 299 |
+
(_name, Name.Variable)
|
| 300 |
+
],
|
| 301 |
+
# Array
|
| 302 |
+
'many-values': [
|
| 303 |
+
include('_whitespace'),
|
| 304 |
+
(r';', Punctuation),
|
| 305 |
+
(r'\]', Punctuation, '#pop'),
|
| 306 |
+
(r':', Error),
|
| 307 |
+
default(('expression', '_expression'))
|
| 308 |
+
],
|
| 309 |
+
# Attribute, Property
|
| 310 |
+
'alias?': [
|
| 311 |
+
include('_whitespace'),
|
| 312 |
+
(r'alias\b', Keyword, ('#pop', '_constant')),
|
| 313 |
+
default('#pop')
|
| 314 |
+
],
|
| 315 |
+
# Class, Object, Nearby
|
| 316 |
+
'class-name': [
|
| 317 |
+
include('_whitespace'),
|
| 318 |
+
(r'(?=[,;]|(class|has|private|with)\b)', Text, '#pop'),
|
| 319 |
+
(_name, Name.Class, '#pop')
|
| 320 |
+
],
|
| 321 |
+
'duplicates': [
|
| 322 |
+
include('_whitespace'),
|
| 323 |
+
(r'\(', Punctuation, ('#pop', 'expression', '_expression')),
|
| 324 |
+
default('#pop')
|
| 325 |
+
],
|
| 326 |
+
'_object-head': [
|
| 327 |
+
(rf'[{_dash}]>', Punctuation),
|
| 328 |
+
(r'(class|has|private|with)\b', Keyword.Declaration, '#pop'),
|
| 329 |
+
include('_global')
|
| 330 |
+
],
|
| 331 |
+
'object-body': [
|
| 332 |
+
include('_whitespace'),
|
| 333 |
+
(r';', Punctuation, '#pop:2'),
|
| 334 |
+
(r',', Punctuation),
|
| 335 |
+
(r'class\b', Keyword.Declaration, 'class-segment'),
|
| 336 |
+
(r'(has|private|with)\b', Keyword.Declaration),
|
| 337 |
+
(r':', Error),
|
| 338 |
+
default(('_object-expression', '_expression'))
|
| 339 |
+
],
|
| 340 |
+
'class-segment': [
|
| 341 |
+
include('_whitespace'),
|
| 342 |
+
(r'(?=[,;]|(class|has|private|with)\b)', Text, '#pop'),
|
| 343 |
+
(_name, Name.Class),
|
| 344 |
+
default('value')
|
| 345 |
+
],
|
| 346 |
+
# Extend, Verb
|
| 347 |
+
'grammar': [
|
| 348 |
+
include('_whitespace'),
|
| 349 |
+
(r'=', Punctuation, ('#pop', 'default')),
|
| 350 |
+
(r'\*', Punctuation, ('#pop', 'grammar-line')),
|
| 351 |
+
default('_directive-keyword')
|
| 352 |
+
],
|
| 353 |
+
'grammar-line': [
|
| 354 |
+
include('_whitespace'),
|
| 355 |
+
(r';', Punctuation, '#pop'),
|
| 356 |
+
(r'[/*]', Punctuation),
|
| 357 |
+
(rf'[{_dash}]>', Punctuation, 'value'),
|
| 358 |
+
(r'(noun|scope)\b', Keyword, '=routine'),
|
| 359 |
+
default('_directive-keyword')
|
| 360 |
+
],
|
| 361 |
+
'=routine': [
|
| 362 |
+
include('_whitespace'),
|
| 363 |
+
(r'=', Punctuation, 'routine-name?'),
|
| 364 |
+
default('#pop')
|
| 365 |
+
],
|
| 366 |
+
# Import
|
| 367 |
+
'manifest': [
|
| 368 |
+
include('_whitespace'),
|
| 369 |
+
(r';', Punctuation, '#pop'),
|
| 370 |
+
(r',', Punctuation),
|
| 371 |
+
(r'(?i)global\b', Keyword, '_global'),
|
| 372 |
+
default('_global')
|
| 373 |
+
],
|
| 374 |
+
# Include, Link, Message
|
| 375 |
+
'diagnostic': [
|
| 376 |
+
include('_whitespace'),
|
| 377 |
+
(rf'[{_dquote}]', String.Double, ('#pop', 'message-string')),
|
| 378 |
+
default(('#pop', 'before-plain-string?', 'directive-keyword?'))
|
| 379 |
+
],
|
| 380 |
+
'before-plain-string?': [
|
| 381 |
+
include('_whitespace'),
|
| 382 |
+
(rf'[{_dquote}]', String.Double, ('#pop', 'plain-string')),
|
| 383 |
+
default('#pop')
|
| 384 |
+
],
|
| 385 |
+
'message-string': [
|
| 386 |
+
(r'[~^]+', String.Escape),
|
| 387 |
+
include('plain-string')
|
| 388 |
+
],
|
| 389 |
+
|
| 390 |
+
# Keywords used in directives
|
| 391 |
+
'_directive-keyword!': [
|
| 392 |
+
include('_whitespace'),
|
| 393 |
+
(words((
|
| 394 |
+
'additive', 'alias', 'buffer', 'class', 'creature', 'data', 'error', 'fatalerror',
|
| 395 |
+
'first', 'has', 'held', 'individual', 'initial', 'initstr', 'last', 'long', 'meta',
|
| 396 |
+
'multi', 'multiexcept', 'multiheld', 'multiinside', 'noun', 'number', 'only',
|
| 397 |
+
'private', 'replace', 'reverse', 'scope', 'score', 'special', 'string', 'table',
|
| 398 |
+
'terminating', 'time', 'topic', 'warning', 'with'), suffix=r'\b'),
|
| 399 |
+
Keyword, '#pop'),
|
| 400 |
+
(r'static\b', Keyword),
|
| 401 |
+
(rf'[{_dash}]{{1,2}}>|[+=]', Punctuation, '#pop')
|
| 402 |
+
],
|
| 403 |
+
'_directive-keyword': [
|
| 404 |
+
include('_directive-keyword!'),
|
| 405 |
+
include('value')
|
| 406 |
+
],
|
| 407 |
+
'directive-keyword?': [
|
| 408 |
+
include('_directive-keyword!'),
|
| 409 |
+
default('#pop')
|
| 410 |
+
],
|
| 411 |
+
'property-keyword*': [
|
| 412 |
+
include('_whitespace'),
|
| 413 |
+
(words(('additive', 'individual', 'long'),
|
| 414 |
+
suffix=rf'\b(?=(\s*|(![^{_newline}]*[{_newline}]))*[_a-zA-Z])'),
|
| 415 |
+
Keyword),
|
| 416 |
+
default('#pop')
|
| 417 |
+
],
|
| 418 |
+
'trace-keyword?': [
|
| 419 |
+
include('_whitespace'),
|
| 420 |
+
(words((
|
| 421 |
+
'assembly', 'dictionary', 'expressions', 'lines', 'linker',
|
| 422 |
+
'objects', 'off', 'on', 'symbols', 'tokens', 'verbs'), suffix=r'\b'),
|
| 423 |
+
Keyword, '#pop'),
|
| 424 |
+
default('#pop')
|
| 425 |
+
],
|
| 426 |
+
|
| 427 |
+
# Statements
|
| 428 |
+
'statements': [
|
| 429 |
+
include('_whitespace'),
|
| 430 |
+
(r'\]', Punctuation, '#pop'),
|
| 431 |
+
(r'[;{}]', Punctuation),
|
| 432 |
+
(words((
|
| 433 |
+
'box', 'break', 'continue', 'default', 'give', 'inversion',
|
| 434 |
+
'new_line', 'quit', 'read', 'remove', 'return', 'rfalse', 'rtrue',
|
| 435 |
+
'spaces', 'string', 'until'), suffix=r'\b'),
|
| 436 |
+
Keyword, 'default'),
|
| 437 |
+
(r'(do|else)\b', Keyword),
|
| 438 |
+
(r'(font|style)\b', Keyword,
|
| 439 |
+
('default', 'miscellaneous-keyword?')),
|
| 440 |
+
(r'for\b', Keyword, ('for', '(?')),
|
| 441 |
+
(r'(if|switch|while)', Keyword,
|
| 442 |
+
('expression', '_expression', '(?')),
|
| 443 |
+
(r'(jump|save|restore)\b', Keyword, ('default', 'label?')),
|
| 444 |
+
(r'objectloop\b', Keyword,
|
| 445 |
+
('_keyword-expression', 'variable?', '(?')),
|
| 446 |
+
(rf'print(_ret)?\b|(?=[{_dquote}])', Keyword, 'print-list'),
|
| 447 |
+
(r'\.', Name.Label, 'label?'),
|
| 448 |
+
(r'@', Keyword, 'opcode'),
|
| 449 |
+
(r'#(?![agrnw]\$|#)', Punctuation, 'directive'),
|
| 450 |
+
(r'<', Punctuation, 'default'),
|
| 451 |
+
(r'move\b', Keyword,
|
| 452 |
+
('default', '_keyword-expression', '_expression')),
|
| 453 |
+
default(('default', '_keyword-expression', '_expression'))
|
| 454 |
+
],
|
| 455 |
+
'miscellaneous-keyword?': [
|
| 456 |
+
include('_whitespace'),
|
| 457 |
+
(r'(bold|fixed|from|near|off|on|reverse|roman|to|underline)\b',
|
| 458 |
+
Keyword, '#pop'),
|
| 459 |
+
(r'(a|A|an|address|char|name|number|object|property|string|the|'
|
| 460 |
+
rf'The)\b(?=(\s+|(![^{_newline}]*))*\))', Keyword.Pseudo,
|
| 461 |
+
'#pop'),
|
| 462 |
+
(rf'{_name}(?=(\s+|(![^{_newline}]*))*\))', Name.Function,
|
| 463 |
+
'#pop'),
|
| 464 |
+
default('#pop')
|
| 465 |
+
],
|
| 466 |
+
'(?': [
|
| 467 |
+
include('_whitespace'),
|
| 468 |
+
(r'\(', Punctuation, '#pop'),
|
| 469 |
+
default('#pop')
|
| 470 |
+
],
|
| 471 |
+
'for': [
|
| 472 |
+
include('_whitespace'),
|
| 473 |
+
(r';', Punctuation, ('_for-expression', '_expression')),
|
| 474 |
+
default(('_for-expression', '_expression'))
|
| 475 |
+
],
|
| 476 |
+
'print-list': [
|
| 477 |
+
include('_whitespace'),
|
| 478 |
+
(r';', Punctuation, '#pop'),
|
| 479 |
+
(r':', Error),
|
| 480 |
+
default(('_list-expression', '_expression', '_list-expression', 'form'))
|
| 481 |
+
],
|
| 482 |
+
'form': [
|
| 483 |
+
include('_whitespace'),
|
| 484 |
+
(r'\(', Punctuation, ('#pop', 'miscellaneous-keyword?')),
|
| 485 |
+
default('#pop')
|
| 486 |
+
],
|
| 487 |
+
|
| 488 |
+
# Assembly
|
| 489 |
+
'opcode': [
|
| 490 |
+
include('_whitespace'),
|
| 491 |
+
(rf'[{_dquote}]', String.Double, ('operands', 'plain-string')),
|
| 492 |
+
(rf'[{_dash}]{{1,2}}>', Punctuation, 'operands'),
|
| 493 |
+
(_name, Keyword, 'operands')
|
| 494 |
+
],
|
| 495 |
+
'operands': [
|
| 496 |
+
(r':', Error),
|
| 497 |
+
default(('_assembly-expression', '_expression'))
|
| 498 |
+
]
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
def get_tokens_unprocessed(self, text):
|
| 502 |
+
# 'in' is either a keyword or an operator.
|
| 503 |
+
# If the token two tokens after 'in' is ')', 'in' is a keyword:
|
| 504 |
+
# objectloop(a in b)
|
| 505 |
+
# Otherwise, it is an operator:
|
| 506 |
+
# objectloop(a in b && true)
|
| 507 |
+
objectloop_queue = []
|
| 508 |
+
objectloop_token_count = -1
|
| 509 |
+
previous_token = None
|
| 510 |
+
for index, token, value in RegexLexer.get_tokens_unprocessed(self,
|
| 511 |
+
text):
|
| 512 |
+
if previous_token is Name.Variable and value == 'in':
|
| 513 |
+
objectloop_queue = [[index, token, value]]
|
| 514 |
+
objectloop_token_count = 2
|
| 515 |
+
elif objectloop_token_count > 0:
|
| 516 |
+
if token not in Comment and token not in Text:
|
| 517 |
+
objectloop_token_count -= 1
|
| 518 |
+
objectloop_queue.append((index, token, value))
|
| 519 |
+
else:
|
| 520 |
+
if objectloop_token_count == 0:
|
| 521 |
+
if objectloop_queue[-1][2] == ')':
|
| 522 |
+
objectloop_queue[0][1] = Keyword
|
| 523 |
+
while objectloop_queue:
|
| 524 |
+
yield objectloop_queue.pop(0)
|
| 525 |
+
objectloop_token_count = -1
|
| 526 |
+
yield index, token, value
|
| 527 |
+
if token not in Comment and token not in Text:
|
| 528 |
+
previous_token = token
|
| 529 |
+
while objectloop_queue:
|
| 530 |
+
yield objectloop_queue.pop(0)
|
| 531 |
+
|
| 532 |
+
def analyse_text(text):
|
| 533 |
+
"""We try to find a keyword which seem relatively common, unfortunately
|
| 534 |
+
there is a decent overlap with Smalltalk keywords otherwise here.."""
|
| 535 |
+
result = 0
|
| 536 |
+
if re.search('\borigsource\b', text, re.IGNORECASE):
|
| 537 |
+
result += 0.05
|
| 538 |
+
|
| 539 |
+
return result
|
| 540 |
+
|
| 541 |
+
|
| 542 |
+
class Inform7Lexer(RegexLexer):
|
| 543 |
+
"""
|
| 544 |
+
For Inform 7 source code.
|
| 545 |
+
"""
|
| 546 |
+
|
| 547 |
+
name = 'Inform 7'
|
| 548 |
+
url = 'http://inform7.com/'
|
| 549 |
+
aliases = ['inform7', 'i7']
|
| 550 |
+
filenames = ['*.ni', '*.i7x']
|
| 551 |
+
version_added = '2.0'
|
| 552 |
+
|
| 553 |
+
flags = re.MULTILINE | re.DOTALL
|
| 554 |
+
|
| 555 |
+
_dash = Inform6Lexer._dash
|
| 556 |
+
_dquote = Inform6Lexer._dquote
|
| 557 |
+
_newline = Inform6Lexer._newline
|
| 558 |
+
_start = rf'\A|(?<=[{_newline}])'
|
| 559 |
+
|
| 560 |
+
# There are three variants of Inform 7, differing in how to
|
| 561 |
+
# interpret at signs and braces in I6T. In top-level inclusions, at
|
| 562 |
+
# signs in the first column are inweb syntax. In phrase definitions
|
| 563 |
+
# and use options, tokens in braces are treated as I7. Use options
|
| 564 |
+
# also interpret "{N}".
|
| 565 |
+
tokens = {}
|
| 566 |
+
token_variants = ['+i6t-not-inline', '+i6t-inline', '+i6t-use-option']
|
| 567 |
+
|
| 568 |
+
for level in token_variants:
|
| 569 |
+
tokens[level] = {
|
| 570 |
+
'+i6-root': list(Inform6Lexer.tokens['root']),
|
| 571 |
+
'+i6t-root': [ # For Inform6TemplateLexer
|
| 572 |
+
(rf'[^{Inform6Lexer._newline}]*', Comment.Preproc,
|
| 573 |
+
('directive', '+p'))
|
| 574 |
+
],
|
| 575 |
+
'root': [
|
| 576 |
+
(r'(\|?\s)+', Text),
|
| 577 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 578 |
+
(rf'[{_dquote}]', Generic.Heading,
|
| 579 |
+
('+main', '+titling', '+titling-string')),
|
| 580 |
+
default(('+main', '+heading?'))
|
| 581 |
+
],
|
| 582 |
+
'+titling-string': [
|
| 583 |
+
(rf'[^{_dquote}]+', Generic.Heading),
|
| 584 |
+
(rf'[{_dquote}]', Generic.Heading, '#pop')
|
| 585 |
+
],
|
| 586 |
+
'+titling': [
|
| 587 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 588 |
+
(rf'[^{_dquote}.;:|{_newline}]+', Generic.Heading),
|
| 589 |
+
(rf'[{_dquote}]', Generic.Heading, '+titling-string'),
|
| 590 |
+
(rf'[{_newline}]{{2}}|(?<=[\s{_dquote}])\|[\s{_dquote}]',
|
| 591 |
+
Text, ('#pop', '+heading?')),
|
| 592 |
+
(rf'[.;:]|(?<=[\s{_dquote}])\|', Text, '#pop'),
|
| 593 |
+
(rf'[|{_newline}]', Generic.Heading)
|
| 594 |
+
],
|
| 595 |
+
'+main': [
|
| 596 |
+
(rf'(?i)[^{_dquote}:a\[(|{_newline}]+', Text),
|
| 597 |
+
(rf'[{_dquote}]', String.Double, '+text'),
|
| 598 |
+
(r':', Text, '+phrase-definition'),
|
| 599 |
+
(r'(?i)\bas\b', Text, '+use-option'),
|
| 600 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 601 |
+
(rf'(\([{_dash}])(.*?)([{_dash}]\))',
|
| 602 |
+
bygroups(Punctuation,
|
| 603 |
+
using(this, state=('+i6-root', 'directive'),
|
| 604 |
+
i6t='+i6t-not-inline'), Punctuation)),
|
| 605 |
+
(rf'({_start}|(?<=[\s;:.{_dquote}]))\|\s|[{_newline}]{{2,}}', Text, '+heading?'),
|
| 606 |
+
(rf'(?i)[a(|{_newline}]', Text)
|
| 607 |
+
],
|
| 608 |
+
'+phrase-definition': [
|
| 609 |
+
(r'\s+', Text),
|
| 610 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 611 |
+
(rf'(\([{_dash}])(.*?)([{_dash}]\))',
|
| 612 |
+
bygroups(Punctuation,
|
| 613 |
+
using(this, state=('+i6-root', 'directive',
|
| 614 |
+
'default', 'statements'),
|
| 615 |
+
i6t='+i6t-inline'), Punctuation), '#pop'),
|
| 616 |
+
default('#pop')
|
| 617 |
+
],
|
| 618 |
+
'+use-option': [
|
| 619 |
+
(r'\s+', Text),
|
| 620 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 621 |
+
(rf'(\([{_dash}])(.*?)([{_dash}]\))',
|
| 622 |
+
bygroups(Punctuation,
|
| 623 |
+
using(this, state=('+i6-root', 'directive'),
|
| 624 |
+
i6t='+i6t-use-option'), Punctuation), '#pop'),
|
| 625 |
+
default('#pop')
|
| 626 |
+
],
|
| 627 |
+
'+comment': [
|
| 628 |
+
(r'[^\[\]]+', Comment.Multiline),
|
| 629 |
+
(r'\[', Comment.Multiline, '#push'),
|
| 630 |
+
(r'\]', Comment.Multiline, '#pop')
|
| 631 |
+
],
|
| 632 |
+
'+text': [
|
| 633 |
+
(rf'[^\[{_dquote}]+', String.Double),
|
| 634 |
+
(r'\[.*?\]', String.Interpol),
|
| 635 |
+
(rf'[{_dquote}]', String.Double, '#pop')
|
| 636 |
+
],
|
| 637 |
+
'+heading?': [
|
| 638 |
+
(r'(\|?\s)+', Text),
|
| 639 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 640 |
+
(rf'[{_dash}]{{4}}\s+', Text, '+documentation-heading'),
|
| 641 |
+
(rf'[{_dash}]{{1,3}}', Text),
|
| 642 |
+
(rf'(?i)(volume|book|part|chapter|section)\b[^{_newline}]*',
|
| 643 |
+
Generic.Heading, '#pop'),
|
| 644 |
+
default('#pop')
|
| 645 |
+
],
|
| 646 |
+
'+documentation-heading': [
|
| 647 |
+
(r'\s+', Text),
|
| 648 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 649 |
+
(r'(?i)documentation\s+', Text, '+documentation-heading2'),
|
| 650 |
+
default('#pop')
|
| 651 |
+
],
|
| 652 |
+
'+documentation-heading2': [
|
| 653 |
+
(r'\s+', Text),
|
| 654 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 655 |
+
(rf'[{_dash}]{{4}}\s', Text, '+documentation'),
|
| 656 |
+
default('#pop:2')
|
| 657 |
+
],
|
| 658 |
+
'+documentation': [
|
| 659 |
+
(rf'(?i)({_start})\s*(chapter|example)\s*:[^{_newline}]*', Generic.Heading),
|
| 660 |
+
(rf'(?i)({_start})\s*section\s*:[^{_newline}]*',
|
| 661 |
+
Generic.Subheading),
|
| 662 |
+
(rf'(({_start})\t.*?[{_newline}])+',
|
| 663 |
+
using(this, state='+main')),
|
| 664 |
+
(rf'[^{_newline}\[]+|[{_newline}\[]', Text),
|
| 665 |
+
(r'\[', Comment.Multiline, '+comment'),
|
| 666 |
+
],
|
| 667 |
+
'+i6t-not-inline': [
|
| 668 |
+
(rf'({_start})@c( .*?)?([{_newline}]|\Z)',
|
| 669 |
+
Comment.Preproc),
|
| 670 |
+
(rf'({_start})@([{_dash}]+|Purpose:)[^{_newline}]*',
|
| 671 |
+
Comment.Preproc),
|
| 672 |
+
(rf'({_start})@p( .*?)?([{_newline}]|\Z)',
|
| 673 |
+
Generic.Heading, '+p')
|
| 674 |
+
],
|
| 675 |
+
'+i6t-use-option': [
|
| 676 |
+
include('+i6t-not-inline'),
|
| 677 |
+
(r'(\{)(N)(\})', bygroups(Punctuation, Text, Punctuation))
|
| 678 |
+
],
|
| 679 |
+
'+i6t-inline': [
|
| 680 |
+
(r'(\{)(\S[^}]*)?(\})',
|
| 681 |
+
bygroups(Punctuation, using(this, state='+main'),
|
| 682 |
+
Punctuation))
|
| 683 |
+
],
|
| 684 |
+
'+i6t': [
|
| 685 |
+
(rf'(\{{[{_dash}])(![^}}]*)(\}}?)',
|
| 686 |
+
bygroups(Punctuation, Comment.Single, Punctuation)),
|
| 687 |
+
(rf'(\{{[{_dash}])(lines)(:)([^}}]*)(\}}?)',
|
| 688 |
+
bygroups(Punctuation, Keyword, Punctuation, Text,
|
| 689 |
+
Punctuation), '+lines'),
|
| 690 |
+
(rf'(\{{[{_dash}])([^:}}]*)(:?)([^}}]*)(\}}?)',
|
| 691 |
+
bygroups(Punctuation, Keyword, Punctuation, Text,
|
| 692 |
+
Punctuation)),
|
| 693 |
+
(r'(\(\+)(.*?)(\+\)|\Z)',
|
| 694 |
+
bygroups(Punctuation, using(this, state='+main'),
|
| 695 |
+
Punctuation))
|
| 696 |
+
],
|
| 697 |
+
'+p': [
|
| 698 |
+
(r'[^@]+', Comment.Preproc),
|
| 699 |
+
(rf'({_start})@c( .*?)?([{_newline}]|\Z)',
|
| 700 |
+
Comment.Preproc, '#pop'),
|
| 701 |
+
(rf'({_start})@([{_dash}]|Purpose:)', Comment.Preproc),
|
| 702 |
+
(rf'({_start})@p( .*?)?([{_newline}]|\Z)',
|
| 703 |
+
Generic.Heading),
|
| 704 |
+
(r'@', Comment.Preproc)
|
| 705 |
+
],
|
| 706 |
+
'+lines': [
|
| 707 |
+
(rf'({_start})@c( .*?)?([{_newline}]|\Z)',
|
| 708 |
+
Comment.Preproc),
|
| 709 |
+
(rf'({_start})@([{_dash}]|Purpose:)[^{_newline}]*',
|
| 710 |
+
Comment.Preproc),
|
| 711 |
+
(rf'({_start})@p( .*?)?([{_newline}]|\Z)',
|
| 712 |
+
Generic.Heading, '+p'),
|
| 713 |
+
(rf'({_start})@\w*[ {_newline}]', Keyword),
|
| 714 |
+
(rf'![^{_newline}]*', Comment.Single),
|
| 715 |
+
(rf'(\{{)([{_dash}]endlines)(\}})',
|
| 716 |
+
bygroups(Punctuation, Keyword, Punctuation), '#pop'),
|
| 717 |
+
(rf'[^@!{{]+?([{_newline}]|\Z)|.', Text)
|
| 718 |
+
]
|
| 719 |
+
}
|
| 720 |
+
# Inform 7 can include snippets of Inform 6 template language,
|
| 721 |
+
# so all of Inform6Lexer's states are copied here, with
|
| 722 |
+
# modifications to account for template syntax. Inform7Lexer's
|
| 723 |
+
# own states begin with '+' to avoid name conflicts. Some of
|
| 724 |
+
# Inform6Lexer's states begin with '_': these are not modified.
|
| 725 |
+
# They deal with template syntax either by including modified
|
| 726 |
+
# states, or by matching r'' then pushing to modified states.
|
| 727 |
+
for token in Inform6Lexer.tokens:
|
| 728 |
+
if token == 'root':
|
| 729 |
+
continue
|
| 730 |
+
tokens[level][token] = list(Inform6Lexer.tokens[token])
|
| 731 |
+
if not token.startswith('_'):
|
| 732 |
+
tokens[level][token][:0] = [include('+i6t'), include(level)]
|
| 733 |
+
|
| 734 |
+
def __init__(self, **options):
|
| 735 |
+
level = options.get('i6t', '+i6t-not-inline')
|
| 736 |
+
if level not in self._all_tokens:
|
| 737 |
+
self._tokens = self.__class__.process_tokendef(level)
|
| 738 |
+
else:
|
| 739 |
+
self._tokens = self._all_tokens[level]
|
| 740 |
+
RegexLexer.__init__(self, **options)
|
| 741 |
+
|
| 742 |
+
|
| 743 |
+
class Inform6TemplateLexer(Inform7Lexer):
|
| 744 |
+
"""
|
| 745 |
+
For Inform 6 template code.
|
| 746 |
+
"""
|
| 747 |
+
|
| 748 |
+
name = 'Inform 6 template'
|
| 749 |
+
aliases = ['i6t']
|
| 750 |
+
filenames = ['*.i6t']
|
| 751 |
+
version_added = '2.0'
|
| 752 |
+
|
| 753 |
+
def get_tokens_unprocessed(self, text, stack=('+i6t-root',)):
|
| 754 |
+
return Inform7Lexer.get_tokens_unprocessed(self, text, stack)
|
| 755 |
+
|
| 756 |
+
|
| 757 |
+
class Tads3Lexer(RegexLexer):
|
| 758 |
+
"""
|
| 759 |
+
For TADS 3 source code.
|
| 760 |
+
"""
|
| 761 |
+
|
| 762 |
+
name = 'TADS 3'
|
| 763 |
+
aliases = ['tads3']
|
| 764 |
+
filenames = ['*.t']
|
| 765 |
+
url = 'https://www.tads.org'
|
| 766 |
+
version_added = ''
|
| 767 |
+
|
| 768 |
+
flags = re.DOTALL | re.MULTILINE
|
| 769 |
+
|
| 770 |
+
_comment_single = r'(?://(?:[^\\\n]|\\+[\w\W])*$)'
|
| 771 |
+
_comment_multiline = r'(?:/\*(?:[^*]|\*(?!/))*\*/)'
|
| 772 |
+
_escape = (r'(?:\\(?:[\n\\<>"\'^v bnrt]|u[\da-fA-F]{,4}|x[\da-fA-F]{,2}|'
|
| 773 |
+
r'[0-3]?[0-7]{1,2}))')
|
| 774 |
+
_name = r'(?:[_a-zA-Z]\w*)'
|
| 775 |
+
_no_quote = r'(?=\s|\\?>)'
|
| 776 |
+
_operator = (r'(?:&&|\|\||\+\+|--|\?\?|::|[.,@\[\]~]|'
|
| 777 |
+
r'(?:[=+\-*/%!&|^]|<<?|>>?>?)=?)')
|
| 778 |
+
_ws = rf'(?:\\|\s|{_comment_single}|{_comment_multiline})'
|
| 779 |
+
_ws_pp = rf'(?:\\\n|[^\S\n]|{_comment_single}|{_comment_multiline})'
|
| 780 |
+
|
| 781 |
+
def _make_string_state(triple, double, verbatim=None, _escape=_escape):
|
| 782 |
+
if verbatim:
|
| 783 |
+
verbatim = ''.join([f'(?:{re.escape(c.lower())}|{re.escape(c.upper())})'
|
| 784 |
+
for c in verbatim])
|
| 785 |
+
char = r'"' if double else r"'"
|
| 786 |
+
token = String.Double if double else String.Single
|
| 787 |
+
escaped_quotes = rf'+|{char}(?!{char}{{2}})' if triple else r''
|
| 788 |
+
prefix = '{}{}'.format('t' if triple else '', 'd' if double else 's')
|
| 789 |
+
tag_state_name = f'{prefix}qt'
|
| 790 |
+
state = []
|
| 791 |
+
if triple:
|
| 792 |
+
state += [
|
| 793 |
+
(rf'{char}{{3,}}', token, '#pop'),
|
| 794 |
+
(rf'\\{char}+', String.Escape),
|
| 795 |
+
(char, token)
|
| 796 |
+
]
|
| 797 |
+
else:
|
| 798 |
+
state.append((char, token, '#pop'))
|
| 799 |
+
state += [
|
| 800 |
+
include('s/verbatim'),
|
| 801 |
+
(rf'[^\\<&{{}}{char}]+', token)
|
| 802 |
+
]
|
| 803 |
+
if verbatim:
|
| 804 |
+
# This regex can't use `(?i)` because escape sequences are
|
| 805 |
+
# case-sensitive. `<\XMP>` works; `<\xmp>` doesn't.
|
| 806 |
+
state.append((rf'\\?<(/|\\\\|(?!{_escape})\\){verbatim}(?=[\s=>])',
|
| 807 |
+
Name.Tag, ('#pop', f'{prefix}qs', tag_state_name)))
|
| 808 |
+
else:
|
| 809 |
+
state += [
|
| 810 |
+
(rf'\\?<!([^><\\{char}]|<(?!<)|\\{char}{escaped_quotes}|{_escape}|\\.)*>?', Comment.Multiline),
|
| 811 |
+
(r'(?i)\\?<listing(?=[\s=>]|\\>)', Name.Tag,
|
| 812 |
+
('#pop', f'{prefix}qs/listing', tag_state_name)),
|
| 813 |
+
(r'(?i)\\?<xmp(?=[\s=>]|\\>)', Name.Tag,
|
| 814 |
+
('#pop', f'{prefix}qs/xmp', tag_state_name)),
|
| 815 |
+
(rf'\\?<([^\s=><\\{char}]|<(?!<)|\\{char}{escaped_quotes}|{_escape}|\\.)*', Name.Tag,
|
| 816 |
+
tag_state_name),
|
| 817 |
+
include('s/entity')
|
| 818 |
+
]
|
| 819 |
+
state += [
|
| 820 |
+
include('s/escape'),
|
| 821 |
+
(rf'\{{([^}}<\\{char}]|<(?!<)|\\{char}{escaped_quotes}|{_escape}|\\.)*\}}', String.Interpol),
|
| 822 |
+
(r'[\\&{}<]', token)
|
| 823 |
+
]
|
| 824 |
+
return state
|
| 825 |
+
|
| 826 |
+
def _make_tag_state(triple, double, _escape=_escape):
|
| 827 |
+
char = r'"' if double else r"'"
|
| 828 |
+
quantifier = r'{3,}' if triple else r''
|
| 829 |
+
state_name = '{}{}qt'.format('t' if triple else '', 'd' if double else 's')
|
| 830 |
+
token = String.Double if double else String.Single
|
| 831 |
+
escaped_quotes = rf'+|{char}(?!{char}{{2}})' if triple else r''
|
| 832 |
+
return [
|
| 833 |
+
(rf'{char}{quantifier}', token, '#pop:2'),
|
| 834 |
+
(r'(\s|\\\n)+', Text),
|
| 835 |
+
(r'(=)(\\?")', bygroups(Punctuation, String.Double),
|
| 836 |
+
f'dqs/{state_name}'),
|
| 837 |
+
(r"(=)(\\?')", bygroups(Punctuation, String.Single),
|
| 838 |
+
f'sqs/{state_name}'),
|
| 839 |
+
(r'=', Punctuation, f'uqs/{state_name}'),
|
| 840 |
+
(r'\\?>', Name.Tag, '#pop'),
|
| 841 |
+
(rf'\{{([^}}<\\{char}]|<(?!<)|\\{char}{escaped_quotes}|{_escape}|\\.)*\}}', String.Interpol),
|
| 842 |
+
(rf'([^\s=><\\{char}]|<(?!<)|\\{char}{escaped_quotes}|{_escape}|\\.)+', Name.Attribute),
|
| 843 |
+
include('s/escape'),
|
| 844 |
+
include('s/verbatim'),
|
| 845 |
+
include('s/entity'),
|
| 846 |
+
(r'[\\{}&]', Name.Attribute)
|
| 847 |
+
]
|
| 848 |
+
|
| 849 |
+
def _make_attribute_value_state(terminator, host_triple, host_double,
|
| 850 |
+
_escape=_escape):
|
| 851 |
+
token = (String.Double if terminator == r'"' else
|
| 852 |
+
String.Single if terminator == r"'" else String.Other)
|
| 853 |
+
host_char = r'"' if host_double else r"'"
|
| 854 |
+
host_quantifier = r'{3,}' if host_triple else r''
|
| 855 |
+
host_token = String.Double if host_double else String.Single
|
| 856 |
+
escaped_quotes = (rf'+|{host_char}(?!{host_char}{{2}})'
|
| 857 |
+
if host_triple else r'')
|
| 858 |
+
return [
|
| 859 |
+
(rf'{host_char}{host_quantifier}', host_token, '#pop:3'),
|
| 860 |
+
(r'{}{}'.format(r'' if token is String.Other else r'\\?', terminator),
|
| 861 |
+
token, '#pop'),
|
| 862 |
+
include('s/verbatim'),
|
| 863 |
+
include('s/entity'),
|
| 864 |
+
(rf'\{{([^}}<\\{host_char}]|<(?!<)|\\{host_char}{escaped_quotes}|{_escape}|\\.)*\}}', String.Interpol),
|
| 865 |
+
(r'([^\s"\'<%s{}\\&])+' % (r'>' if token is String.Other else r''),
|
| 866 |
+
token),
|
| 867 |
+
include('s/escape'),
|
| 868 |
+
(r'["\'\s&{<}\\]', token)
|
| 869 |
+
]
|
| 870 |
+
|
| 871 |
+
tokens = {
|
| 872 |
+
'root': [
|
| 873 |
+
('\ufeff', Text),
|
| 874 |
+
(r'\{', Punctuation, 'object-body'),
|
| 875 |
+
(r';+', Punctuation),
|
| 876 |
+
(r'(?=(argcount|break|case|catch|continue|default|definingobj|'
|
| 877 |
+
r'delegated|do|else|for|foreach|finally|goto|if|inherited|'
|
| 878 |
+
r'invokee|local|nil|new|operator|replaced|return|self|switch|'
|
| 879 |
+
r'targetobj|targetprop|throw|true|try|while)\b)', Text, 'block'),
|
| 880 |
+
(rf'({_name})({_ws}*)(\()',
|
| 881 |
+
bygroups(Name.Function, using(this, state='whitespace'),
|
| 882 |
+
Punctuation),
|
| 883 |
+
('block?/root', 'more/parameters', 'main/parameters')),
|
| 884 |
+
include('whitespace'),
|
| 885 |
+
(r'\++', Punctuation),
|
| 886 |
+
(r'[^\s!"%-(*->@-_a-z{-~]+', Error), # Averts an infinite loop
|
| 887 |
+
(r'(?!\Z)', Text, 'main/root')
|
| 888 |
+
],
|
| 889 |
+
'main/root': [
|
| 890 |
+
include('main/basic'),
|
| 891 |
+
default(('#pop', 'object-body/no-braces', 'classes', 'class'))
|
| 892 |
+
],
|
| 893 |
+
'object-body/no-braces': [
|
| 894 |
+
(r';', Punctuation, '#pop'),
|
| 895 |
+
(r'\{', Punctuation, ('#pop', 'object-body')),
|
| 896 |
+
include('object-body')
|
| 897 |
+
],
|
| 898 |
+
'object-body': [
|
| 899 |
+
(r';', Punctuation),
|
| 900 |
+
(r'\{', Punctuation, '#push'),
|
| 901 |
+
(r'\}', Punctuation, '#pop'),
|
| 902 |
+
(r':', Punctuation, ('classes', 'class')),
|
| 903 |
+
(rf'({_name}?)({_ws}*)(\()',
|
| 904 |
+
bygroups(Name.Function, using(this, state='whitespace'),
|
| 905 |
+
Punctuation),
|
| 906 |
+
('block?', 'more/parameters', 'main/parameters')),
|
| 907 |
+
(rf'({_name})({_ws}*)(\{{)',
|
| 908 |
+
bygroups(Name.Function, using(this, state='whitespace'),
|
| 909 |
+
Punctuation), 'block'),
|
| 910 |
+
(rf'({_name})({_ws}*)(:)',
|
| 911 |
+
bygroups(Name.Variable, using(this, state='whitespace'),
|
| 912 |
+
Punctuation),
|
| 913 |
+
('object-body/no-braces', 'classes', 'class')),
|
| 914 |
+
include('whitespace'),
|
| 915 |
+
(rf'->|{_operator}', Punctuation, 'main'),
|
| 916 |
+
default('main/object-body')
|
| 917 |
+
],
|
| 918 |
+
'main/object-body': [
|
| 919 |
+
include('main/basic'),
|
| 920 |
+
(rf'({_name})({_ws}*)(=?)',
|
| 921 |
+
bygroups(Name.Variable, using(this, state='whitespace'),
|
| 922 |
+
Punctuation), ('#pop', 'more', 'main')),
|
| 923 |
+
default('#pop:2')
|
| 924 |
+
],
|
| 925 |
+
'block?/root': [
|
| 926 |
+
(r'\{', Punctuation, ('#pop', 'block')),
|
| 927 |
+
include('whitespace'),
|
| 928 |
+
(r'(?=[\[\'"<(:])', Text, # It might be a VerbRule macro.
|
| 929 |
+
('#pop', 'object-body/no-braces', 'grammar', 'grammar-rules')),
|
| 930 |
+
# It might be a macro like DefineAction.
|
| 931 |
+
default(('#pop', 'object-body/no-braces'))
|
| 932 |
+
],
|
| 933 |
+
'block?': [
|
| 934 |
+
(r'\{', Punctuation, ('#pop', 'block')),
|
| 935 |
+
include('whitespace'),
|
| 936 |
+
default('#pop')
|
| 937 |
+
],
|
| 938 |
+
'block/basic': [
|
| 939 |
+
(r'[;:]+', Punctuation),
|
| 940 |
+
(r'\{', Punctuation, '#push'),
|
| 941 |
+
(r'\}', Punctuation, '#pop'),
|
| 942 |
+
(r'default\b', Keyword.Reserved),
|
| 943 |
+
(rf'({_name})({_ws}*)(:)',
|
| 944 |
+
bygroups(Name.Label, using(this, state='whitespace'),
|
| 945 |
+
Punctuation)),
|
| 946 |
+
include('whitespace')
|
| 947 |
+
],
|
| 948 |
+
'block': [
|
| 949 |
+
include('block/basic'),
|
| 950 |
+
(r'(?!\Z)', Text, ('more', 'main'))
|
| 951 |
+
],
|
| 952 |
+
'block/embed': [
|
| 953 |
+
(r'>>', String.Interpol, '#pop'),
|
| 954 |
+
include('block/basic'),
|
| 955 |
+
(r'(?!\Z)', Text, ('more/embed', 'main'))
|
| 956 |
+
],
|
| 957 |
+
'main/basic': [
|
| 958 |
+
include('whitespace'),
|
| 959 |
+
(r'\(', Punctuation, ('#pop', 'more', 'main')),
|
| 960 |
+
(r'\[', Punctuation, ('#pop', 'more/list', 'main')),
|
| 961 |
+
(r'\{', Punctuation, ('#pop', 'more/inner', 'main/inner',
|
| 962 |
+
'more/parameters', 'main/parameters')),
|
| 963 |
+
(r'\*|\.{3}', Punctuation, '#pop'),
|
| 964 |
+
(r'(?i)0x[\da-f]+', Number.Hex, '#pop'),
|
| 965 |
+
(r'(\d+\.(?!\.)\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+',
|
| 966 |
+
Number.Float, '#pop'),
|
| 967 |
+
(r'0[0-7]+', Number.Oct, '#pop'),
|
| 968 |
+
(r'\d+', Number.Integer, '#pop'),
|
| 969 |
+
(r'"""', String.Double, ('#pop', 'tdqs')),
|
| 970 |
+
(r"'''", String.Single, ('#pop', 'tsqs')),
|
| 971 |
+
(r'"', String.Double, ('#pop', 'dqs')),
|
| 972 |
+
(r"'", String.Single, ('#pop', 'sqs')),
|
| 973 |
+
(r'R"""', String.Regex, ('#pop', 'tdqr')),
|
| 974 |
+
(r"R'''", String.Regex, ('#pop', 'tsqr')),
|
| 975 |
+
(r'R"', String.Regex, ('#pop', 'dqr')),
|
| 976 |
+
(r"R'", String.Regex, ('#pop', 'sqr')),
|
| 977 |
+
# Two-token keywords
|
| 978 |
+
(rf'(extern)({_ws}+)(object\b)',
|
| 979 |
+
bygroups(Keyword.Reserved, using(this, state='whitespace'),
|
| 980 |
+
Keyword.Reserved)),
|
| 981 |
+
(rf'(function|method)({_ws}*)(\()',
|
| 982 |
+
bygroups(Keyword.Reserved, using(this, state='whitespace'),
|
| 983 |
+
Punctuation),
|
| 984 |
+
('#pop', 'block?', 'more/parameters', 'main/parameters')),
|
| 985 |
+
(rf'(modify)({_ws}+)(grammar\b)',
|
| 986 |
+
bygroups(Keyword.Reserved, using(this, state='whitespace'),
|
| 987 |
+
Keyword.Reserved),
|
| 988 |
+
('#pop', 'object-body/no-braces', ':', 'grammar')),
|
| 989 |
+
(rf'(new)({_ws}+(?=(?:function|method)\b))',
|
| 990 |
+
bygroups(Keyword.Reserved, using(this, state='whitespace'))),
|
| 991 |
+
(rf'(object)({_ws}+)(template\b)',
|
| 992 |
+
bygroups(Keyword.Reserved, using(this, state='whitespace'),
|
| 993 |
+
Keyword.Reserved), ('#pop', 'template')),
|
| 994 |
+
(rf'(string)({_ws}+)(template\b)',
|
| 995 |
+
bygroups(Keyword, using(this, state='whitespace'),
|
| 996 |
+
Keyword.Reserved), ('#pop', 'function-name')),
|
| 997 |
+
# Keywords
|
| 998 |
+
(r'(argcount|definingobj|invokee|replaced|targetobj|targetprop)\b',
|
| 999 |
+
Name.Builtin, '#pop'),
|
| 1000 |
+
(r'(break|continue|goto)\b', Keyword.Reserved, ('#pop', 'label')),
|
| 1001 |
+
(r'(case|extern|if|intrinsic|return|static|while)\b',
|
| 1002 |
+
Keyword.Reserved),
|
| 1003 |
+
(r'catch\b', Keyword.Reserved, ('#pop', 'catch')),
|
| 1004 |
+
(r'class\b', Keyword.Reserved,
|
| 1005 |
+
('#pop', 'object-body/no-braces', 'class')),
|
| 1006 |
+
(r'(default|do|else|finally|try)\b', Keyword.Reserved, '#pop'),
|
| 1007 |
+
(r'(dictionary|property)\b', Keyword.Reserved,
|
| 1008 |
+
('#pop', 'constants')),
|
| 1009 |
+
(r'enum\b', Keyword.Reserved, ('#pop', 'enum')),
|
| 1010 |
+
(r'export\b', Keyword.Reserved, ('#pop', 'main')),
|
| 1011 |
+
(r'(for|foreach)\b', Keyword.Reserved,
|
| 1012 |
+
('#pop', 'more/inner', 'main/inner')),
|
| 1013 |
+
(r'(function|method)\b', Keyword.Reserved,
|
| 1014 |
+
('#pop', 'block?', 'function-name')),
|
| 1015 |
+
(r'grammar\b', Keyword.Reserved,
|
| 1016 |
+
('#pop', 'object-body/no-braces', 'grammar')),
|
| 1017 |
+
(r'inherited\b', Keyword.Reserved, ('#pop', 'inherited')),
|
| 1018 |
+
(r'local\b', Keyword.Reserved,
|
| 1019 |
+
('#pop', 'more/local', 'main/local')),
|
| 1020 |
+
(r'(modify|replace|switch|throw|transient)\b', Keyword.Reserved,
|
| 1021 |
+
'#pop'),
|
| 1022 |
+
(r'new\b', Keyword.Reserved, ('#pop', 'class')),
|
| 1023 |
+
(r'(nil|true)\b', Keyword.Constant, '#pop'),
|
| 1024 |
+
(r'object\b', Keyword.Reserved, ('#pop', 'object-body/no-braces')),
|
| 1025 |
+
(r'operator\b', Keyword.Reserved, ('#pop', 'operator')),
|
| 1026 |
+
(r'propertyset\b', Keyword.Reserved,
|
| 1027 |
+
('#pop', 'propertyset', 'main')),
|
| 1028 |
+
(r'self\b', Name.Builtin.Pseudo, '#pop'),
|
| 1029 |
+
(r'template\b', Keyword.Reserved, ('#pop', 'template')),
|
| 1030 |
+
# Operators
|
| 1031 |
+
(rf'(__objref|defined)({_ws}*)(\()',
|
| 1032 |
+
bygroups(Operator.Word, using(this, state='whitespace'),
|
| 1033 |
+
Operator), ('#pop', 'more/__objref', 'main')),
|
| 1034 |
+
(r'delegated\b', Operator.Word),
|
| 1035 |
+
# Compiler-defined macros and built-in properties
|
| 1036 |
+
(r'(__DATE__|__DEBUG|__LINE__|__FILE__|'
|
| 1037 |
+
r'__TADS_MACRO_FORMAT_VERSION|__TADS_SYS_\w*|__TADS_SYSTEM_NAME|'
|
| 1038 |
+
r'__TADS_VERSION_MAJOR|__TADS_VERSION_MINOR|__TADS3|__TIME__|'
|
| 1039 |
+
r'construct|finalize|grammarInfo|grammarTag|lexicalParent|'
|
| 1040 |
+
r'miscVocab|sourceTextGroup|sourceTextGroupName|'
|
| 1041 |
+
r'sourceTextGroupOrder|sourceTextOrder)\b', Name.Builtin, '#pop')
|
| 1042 |
+
],
|
| 1043 |
+
'main': [
|
| 1044 |
+
include('main/basic'),
|
| 1045 |
+
(_name, Name, '#pop'),
|
| 1046 |
+
default('#pop')
|
| 1047 |
+
],
|
| 1048 |
+
'more/basic': [
|
| 1049 |
+
(r'\(', Punctuation, ('more/list', 'main')),
|
| 1050 |
+
(r'\[', Punctuation, ('more', 'main')),
|
| 1051 |
+
(r'\.{3}', Punctuation),
|
| 1052 |
+
(r'->|\.\.', Punctuation, 'main'),
|
| 1053 |
+
(r'(?=;)|[:)\]]', Punctuation, '#pop'),
|
| 1054 |
+
include('whitespace'),
|
| 1055 |
+
(_operator, Operator, 'main'),
|
| 1056 |
+
(r'\?', Operator, ('main', 'more/conditional', 'main')),
|
| 1057 |
+
(rf'(is|not)({_ws}+)(in\b)',
|
| 1058 |
+
bygroups(Operator.Word, using(this, state='whitespace'),
|
| 1059 |
+
Operator.Word)),
|
| 1060 |
+
(r'[^\s!"%-_a-z{-~]+', Error) # Averts an infinite loop
|
| 1061 |
+
],
|
| 1062 |
+
'more': [
|
| 1063 |
+
include('more/basic'),
|
| 1064 |
+
default('#pop')
|
| 1065 |
+
],
|
| 1066 |
+
# Then expression (conditional operator)
|
| 1067 |
+
'more/conditional': [
|
| 1068 |
+
(r':(?!:)', Operator, '#pop'),
|
| 1069 |
+
include('more')
|
| 1070 |
+
],
|
| 1071 |
+
# Embedded expressions
|
| 1072 |
+
'more/embed': [
|
| 1073 |
+
(r'>>', String.Interpol, '#pop:2'),
|
| 1074 |
+
include('more')
|
| 1075 |
+
],
|
| 1076 |
+
# For/foreach loop initializer or short-form anonymous function
|
| 1077 |
+
'main/inner': [
|
| 1078 |
+
(r'\(', Punctuation, ('#pop', 'more/inner', 'main/inner')),
|
| 1079 |
+
(r'local\b', Keyword.Reserved, ('#pop', 'main/local')),
|
| 1080 |
+
include('main')
|
| 1081 |
+
],
|
| 1082 |
+
'more/inner': [
|
| 1083 |
+
(r'\}', Punctuation, '#pop'),
|
| 1084 |
+
(r',', Punctuation, 'main/inner'),
|
| 1085 |
+
(r'(in|step)\b', Keyword, 'main/inner'),
|
| 1086 |
+
include('more')
|
| 1087 |
+
],
|
| 1088 |
+
# Local
|
| 1089 |
+
'main/local': [
|
| 1090 |
+
(_name, Name.Variable, '#pop'),
|
| 1091 |
+
include('whitespace')
|
| 1092 |
+
],
|
| 1093 |
+
'more/local': [
|
| 1094 |
+
(r',', Punctuation, 'main/local'),
|
| 1095 |
+
include('more')
|
| 1096 |
+
],
|
| 1097 |
+
# List
|
| 1098 |
+
'more/list': [
|
| 1099 |
+
(r'[,:]', Punctuation, 'main'),
|
| 1100 |
+
include('more')
|
| 1101 |
+
],
|
| 1102 |
+
# Parameter list
|
| 1103 |
+
'main/parameters': [
|
| 1104 |
+
(rf'({_name})({_ws}*)(?=:)',
|
| 1105 |
+
bygroups(Name.Variable, using(this, state='whitespace')), '#pop'),
|
| 1106 |
+
(rf'({_name})({_ws}+)({_name})',
|
| 1107 |
+
bygroups(Name.Class, using(this, state='whitespace'),
|
| 1108 |
+
Name.Variable), '#pop'),
|
| 1109 |
+
(r'\[+', Punctuation),
|
| 1110 |
+
include('main/basic'),
|
| 1111 |
+
(_name, Name.Variable, '#pop'),
|
| 1112 |
+
default('#pop')
|
| 1113 |
+
],
|
| 1114 |
+
'more/parameters': [
|
| 1115 |
+
(rf'(:)({_ws}*(?=[?=,:)]))',
|
| 1116 |
+
bygroups(Punctuation, using(this, state='whitespace'))),
|
| 1117 |
+
(r'[?\]]+', Punctuation),
|
| 1118 |
+
(r'[:)]', Punctuation, ('#pop', 'multimethod?')),
|
| 1119 |
+
(r',', Punctuation, 'main/parameters'),
|
| 1120 |
+
(r'=', Punctuation, ('more/parameter', 'main')),
|
| 1121 |
+
include('more')
|
| 1122 |
+
],
|
| 1123 |
+
'more/parameter': [
|
| 1124 |
+
(r'(?=[,)])', Text, '#pop'),
|
| 1125 |
+
include('more')
|
| 1126 |
+
],
|
| 1127 |
+
'multimethod?': [
|
| 1128 |
+
(r'multimethod\b', Keyword, '#pop'),
|
| 1129 |
+
include('whitespace'),
|
| 1130 |
+
default('#pop')
|
| 1131 |
+
],
|
| 1132 |
+
|
| 1133 |
+
# Statements and expressions
|
| 1134 |
+
'more/__objref': [
|
| 1135 |
+
(r',', Punctuation, 'mode'),
|
| 1136 |
+
(r'\)', Operator, '#pop'),
|
| 1137 |
+
include('more')
|
| 1138 |
+
],
|
| 1139 |
+
'mode': [
|
| 1140 |
+
(r'(error|warn)\b', Keyword, '#pop'),
|
| 1141 |
+
include('whitespace')
|
| 1142 |
+
],
|
| 1143 |
+
'catch': [
|
| 1144 |
+
(r'\(+', Punctuation),
|
| 1145 |
+
(_name, Name.Exception, ('#pop', 'variables')),
|
| 1146 |
+
include('whitespace')
|
| 1147 |
+
],
|
| 1148 |
+
'enum': [
|
| 1149 |
+
include('whitespace'),
|
| 1150 |
+
(r'token\b', Keyword, ('#pop', 'constants')),
|
| 1151 |
+
default(('#pop', 'constants'))
|
| 1152 |
+
],
|
| 1153 |
+
'grammar': [
|
| 1154 |
+
(r'\)+', Punctuation),
|
| 1155 |
+
(r'\(', Punctuation, 'grammar-tag'),
|
| 1156 |
+
(r':', Punctuation, 'grammar-rules'),
|
| 1157 |
+
(_name, Name.Class),
|
| 1158 |
+
include('whitespace')
|
| 1159 |
+
],
|
| 1160 |
+
'grammar-tag': [
|
| 1161 |
+
include('whitespace'),
|
| 1162 |
+
(r'"""([^\\"<]|""?(?!")|\\"+|\\.|<(?!<))+("{3,}|<<)|'
|
| 1163 |
+
r'R"""([^\\"]|""?(?!")|\\"+|\\.)+"{3,}|'
|
| 1164 |
+
r"'''([^\\'<]|''?(?!')|\\'+|\\.|<(?!<))+('{3,}|<<)|"
|
| 1165 |
+
r"R'''([^\\']|''?(?!')|\\'+|\\.)+'{3,}|"
|
| 1166 |
+
r'"([^\\"<]|\\.|<(?!<))+("|<<)|R"([^\\"]|\\.)+"|'
|
| 1167 |
+
r"'([^\\'<]|\\.|<(?!<))+('|<<)|R'([^\\']|\\.)+'|"
|
| 1168 |
+
r"([^)\s\\/]|/(?![/*]))+|\)", String.Other, '#pop')
|
| 1169 |
+
],
|
| 1170 |
+
'grammar-rules': [
|
| 1171 |
+
include('string'),
|
| 1172 |
+
include('whitespace'),
|
| 1173 |
+
(rf'(\[)({_ws}*)(badness)',
|
| 1174 |
+
bygroups(Punctuation, using(this, state='whitespace'), Keyword),
|
| 1175 |
+
'main'),
|
| 1176 |
+
(rf'->|{_operator}|[()]', Punctuation),
|
| 1177 |
+
(_name, Name.Constant),
|
| 1178 |
+
default('#pop:2')
|
| 1179 |
+
],
|
| 1180 |
+
':': [
|
| 1181 |
+
(r':', Punctuation, '#pop')
|
| 1182 |
+
],
|
| 1183 |
+
'function-name': [
|
| 1184 |
+
(r'(<<([^>]|>>>|>(?!>))*>>)+', String.Interpol),
|
| 1185 |
+
(rf'(?={_name}?{_ws}*[({{])', Text, '#pop'),
|
| 1186 |
+
(_name, Name.Function, '#pop'),
|
| 1187 |
+
include('whitespace')
|
| 1188 |
+
],
|
| 1189 |
+
'inherited': [
|
| 1190 |
+
(r'<', Punctuation, ('#pop', 'classes', 'class')),
|
| 1191 |
+
include('whitespace'),
|
| 1192 |
+
(_name, Name.Class, '#pop'),
|
| 1193 |
+
default('#pop')
|
| 1194 |
+
],
|
| 1195 |
+
'operator': [
|
| 1196 |
+
(r'negate\b', Operator.Word, '#pop'),
|
| 1197 |
+
include('whitespace'),
|
| 1198 |
+
(_operator, Operator),
|
| 1199 |
+
default('#pop')
|
| 1200 |
+
],
|
| 1201 |
+
'propertyset': [
|
| 1202 |
+
(r'\(', Punctuation, ('more/parameters', 'main/parameters')),
|
| 1203 |
+
(r'\{', Punctuation, ('#pop', 'object-body')),
|
| 1204 |
+
include('whitespace')
|
| 1205 |
+
],
|
| 1206 |
+
'template': [
|
| 1207 |
+
(r'(?=;)', Text, '#pop'),
|
| 1208 |
+
include('string'),
|
| 1209 |
+
(r'inherited\b', Keyword.Reserved),
|
| 1210 |
+
include('whitespace'),
|
| 1211 |
+
(rf'->|\?|{_operator}', Punctuation),
|
| 1212 |
+
(_name, Name.Variable)
|
| 1213 |
+
],
|
| 1214 |
+
|
| 1215 |
+
# Identifiers
|
| 1216 |
+
'class': [
|
| 1217 |
+
(r'\*|\.{3}', Punctuation, '#pop'),
|
| 1218 |
+
(r'object\b', Keyword.Reserved, '#pop'),
|
| 1219 |
+
(r'transient\b', Keyword.Reserved),
|
| 1220 |
+
(_name, Name.Class, '#pop'),
|
| 1221 |
+
include('whitespace'),
|
| 1222 |
+
default('#pop')
|
| 1223 |
+
],
|
| 1224 |
+
'classes': [
|
| 1225 |
+
(r'[:,]', Punctuation, 'class'),
|
| 1226 |
+
include('whitespace'),
|
| 1227 |
+
(r'>', Punctuation, '#pop'),
|
| 1228 |
+
default('#pop')
|
| 1229 |
+
],
|
| 1230 |
+
'constants': [
|
| 1231 |
+
(r',+', Punctuation),
|
| 1232 |
+
(r';', Punctuation, '#pop'),
|
| 1233 |
+
(r'property\b', Keyword.Reserved),
|
| 1234 |
+
(_name, Name.Constant),
|
| 1235 |
+
include('whitespace')
|
| 1236 |
+
],
|
| 1237 |
+
'label': [
|
| 1238 |
+
(_name, Name.Label, '#pop'),
|
| 1239 |
+
include('whitespace'),
|
| 1240 |
+
default('#pop')
|
| 1241 |
+
],
|
| 1242 |
+
'variables': [
|
| 1243 |
+
(r',+', Punctuation),
|
| 1244 |
+
(r'\)', Punctuation, '#pop'),
|
| 1245 |
+
include('whitespace'),
|
| 1246 |
+
(_name, Name.Variable)
|
| 1247 |
+
],
|
| 1248 |
+
|
| 1249 |
+
# Whitespace and comments
|
| 1250 |
+
'whitespace': [
|
| 1251 |
+
(rf'^{_ws_pp}*#({_comment_multiline}|[^\n]|(?<=\\)\n)*\n?',
|
| 1252 |
+
Comment.Preproc),
|
| 1253 |
+
(_comment_single, Comment.Single),
|
| 1254 |
+
(_comment_multiline, Comment.Multiline),
|
| 1255 |
+
(rf'\\+\n+{_ws_pp}*#?|\n+|([^\S\n]|\\)+', Text)
|
| 1256 |
+
],
|
| 1257 |
+
|
| 1258 |
+
# Strings
|
| 1259 |
+
'string': [
|
| 1260 |
+
(r'"""', String.Double, 'tdqs'),
|
| 1261 |
+
(r"'''", String.Single, 'tsqs'),
|
| 1262 |
+
(r'"', String.Double, 'dqs'),
|
| 1263 |
+
(r"'", String.Single, 'sqs')
|
| 1264 |
+
],
|
| 1265 |
+
's/escape': [
|
| 1266 |
+
(rf'\{{\{{|\}}\}}|{_escape}', String.Escape)
|
| 1267 |
+
],
|
| 1268 |
+
's/verbatim': [
|
| 1269 |
+
(r'<<\s*(as\s+decreasingly\s+likely\s+outcomes|cycling|else|end|'
|
| 1270 |
+
r'first\s+time|one\s+of|only|or|otherwise|'
|
| 1271 |
+
r'(sticky|(then\s+)?(purely\s+)?at)\s+random|stopping|'
|
| 1272 |
+
r'(then\s+)?(half\s+)?shuffled|\|\|)\s*>>', String.Interpol),
|
| 1273 |
+
(rf'<<(%(_({_escape}|\\?.)|[\-+ ,#]|\[\d*\]?)*\d*\.?\d*({_escape}|\\?.)|'
|
| 1274 |
+
r'\s*((else|otherwise)\s+)?(if|unless)\b)?',
|
| 1275 |
+
String.Interpol, ('block/embed', 'more/embed', 'main'))
|
| 1276 |
+
],
|
| 1277 |
+
's/entity': [
|
| 1278 |
+
(r'(?i)&(#(x[\da-f]+|\d+)|[a-z][\da-z]*);?', Name.Entity)
|
| 1279 |
+
],
|
| 1280 |
+
'tdqs': _make_string_state(True, True),
|
| 1281 |
+
'tsqs': _make_string_state(True, False),
|
| 1282 |
+
'dqs': _make_string_state(False, True),
|
| 1283 |
+
'sqs': _make_string_state(False, False),
|
| 1284 |
+
'tdqs/listing': _make_string_state(True, True, 'listing'),
|
| 1285 |
+
'tsqs/listing': _make_string_state(True, False, 'listing'),
|
| 1286 |
+
'dqs/listing': _make_string_state(False, True, 'listing'),
|
| 1287 |
+
'sqs/listing': _make_string_state(False, False, 'listing'),
|
| 1288 |
+
'tdqs/xmp': _make_string_state(True, True, 'xmp'),
|
| 1289 |
+
'tsqs/xmp': _make_string_state(True, False, 'xmp'),
|
| 1290 |
+
'dqs/xmp': _make_string_state(False, True, 'xmp'),
|
| 1291 |
+
'sqs/xmp': _make_string_state(False, False, 'xmp'),
|
| 1292 |
+
|
| 1293 |
+
# Tags
|
| 1294 |
+
'tdqt': _make_tag_state(True, True),
|
| 1295 |
+
'tsqt': _make_tag_state(True, False),
|
| 1296 |
+
'dqt': _make_tag_state(False, True),
|
| 1297 |
+
'sqt': _make_tag_state(False, False),
|
| 1298 |
+
'dqs/tdqt': _make_attribute_value_state(r'"', True, True),
|
| 1299 |
+
'dqs/tsqt': _make_attribute_value_state(r'"', True, False),
|
| 1300 |
+
'dqs/dqt': _make_attribute_value_state(r'"', False, True),
|
| 1301 |
+
'dqs/sqt': _make_attribute_value_state(r'"', False, False),
|
| 1302 |
+
'sqs/tdqt': _make_attribute_value_state(r"'", True, True),
|
| 1303 |
+
'sqs/tsqt': _make_attribute_value_state(r"'", True, False),
|
| 1304 |
+
'sqs/dqt': _make_attribute_value_state(r"'", False, True),
|
| 1305 |
+
'sqs/sqt': _make_attribute_value_state(r"'", False, False),
|
| 1306 |
+
'uqs/tdqt': _make_attribute_value_state(_no_quote, True, True),
|
| 1307 |
+
'uqs/tsqt': _make_attribute_value_state(_no_quote, True, False),
|
| 1308 |
+
'uqs/dqt': _make_attribute_value_state(_no_quote, False, True),
|
| 1309 |
+
'uqs/sqt': _make_attribute_value_state(_no_quote, False, False),
|
| 1310 |
+
|
| 1311 |
+
# Regular expressions
|
| 1312 |
+
'tdqr': [
|
| 1313 |
+
(r'[^\\"]+', String.Regex),
|
| 1314 |
+
(r'\\"*', String.Regex),
|
| 1315 |
+
(r'"{3,}', String.Regex, '#pop'),
|
| 1316 |
+
(r'"', String.Regex)
|
| 1317 |
+
],
|
| 1318 |
+
'tsqr': [
|
| 1319 |
+
(r"[^\\']+", String.Regex),
|
| 1320 |
+
(r"\\'*", String.Regex),
|
| 1321 |
+
(r"'{3,}", String.Regex, '#pop'),
|
| 1322 |
+
(r"'", String.Regex)
|
| 1323 |
+
],
|
| 1324 |
+
'dqr': [
|
| 1325 |
+
(r'[^\\"]+', String.Regex),
|
| 1326 |
+
(r'\\"?', String.Regex),
|
| 1327 |
+
(r'"', String.Regex, '#pop')
|
| 1328 |
+
],
|
| 1329 |
+
'sqr': [
|
| 1330 |
+
(r"[^\\']+", String.Regex),
|
| 1331 |
+
(r"\\'?", String.Regex),
|
| 1332 |
+
(r"'", String.Regex, '#pop')
|
| 1333 |
+
]
|
| 1334 |
+
}
|
| 1335 |
+
|
| 1336 |
+
def get_tokens_unprocessed(self, text, **kwargs):
|
| 1337 |
+
pp = rf'^{self._ws_pp}*#{self._ws_pp}*'
|
| 1338 |
+
if_false_level = 0
|
| 1339 |
+
for index, token, value in (
|
| 1340 |
+
RegexLexer.get_tokens_unprocessed(self, text, **kwargs)):
|
| 1341 |
+
if if_false_level == 0: # Not in a false #if
|
| 1342 |
+
if (token is Comment.Preproc and
|
| 1343 |
+
re.match(rf'{pp}if{self._ws_pp}+(0|nil){self._ws_pp}*$\n?', value)):
|
| 1344 |
+
if_false_level = 1
|
| 1345 |
+
else: # In a false #if
|
| 1346 |
+
if token is Comment.Preproc:
|
| 1347 |
+
if (if_false_level == 1 and
|
| 1348 |
+
re.match(rf'{pp}el(if|se)\b', value)):
|
| 1349 |
+
if_false_level = 0
|
| 1350 |
+
elif re.match(rf'{pp}if', value):
|
| 1351 |
+
if_false_level += 1
|
| 1352 |
+
elif re.match(rf'{pp}endif\b', value):
|
| 1353 |
+
if_false_level -= 1
|
| 1354 |
+
else:
|
| 1355 |
+
token = Comment
|
| 1356 |
+
yield index, token, value
|
| 1357 |
+
|
| 1358 |
+
def analyse_text(text):
|
| 1359 |
+
"""This is a rather generic descriptive language without strong
|
| 1360 |
+
identifiers. It looks like a 'GameMainDef' has to be present,
|
| 1361 |
+
and/or a 'versionInfo' with an 'IFID' field."""
|
| 1362 |
+
result = 0
|
| 1363 |
+
if '__TADS' in text or 'GameMainDef' in text:
|
| 1364 |
+
result += 0.2
|
| 1365 |
+
|
| 1366 |
+
# This is a fairly unique keyword which is likely used in source as well
|
| 1367 |
+
if 'versionInfo' in text and 'IFID' in text:
|
| 1368 |
+
result += 0.1
|
| 1369 |
+
|
| 1370 |
+
return result
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/iolang.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.iolang
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the Io language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer
|
| 12 |
+
from pygments.token import Comment, Operator, Keyword, Name, String, Number, \
|
| 13 |
+
Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['IoLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class IoLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For Io (a small, prototype-based programming language) source.
|
| 21 |
+
"""
|
| 22 |
+
name = 'Io'
|
| 23 |
+
url = 'http://iolanguage.com/'
|
| 24 |
+
filenames = ['*.io']
|
| 25 |
+
aliases = ['io']
|
| 26 |
+
mimetypes = ['text/x-iosrc']
|
| 27 |
+
version_added = '0.10'
|
| 28 |
+
tokens = {
|
| 29 |
+
'root': [
|
| 30 |
+
(r'\n', Whitespace),
|
| 31 |
+
(r'\s+', Whitespace),
|
| 32 |
+
# Comments
|
| 33 |
+
(r'//(.*?)$', Comment.Single),
|
| 34 |
+
(r'#(.*?)$', Comment.Single),
|
| 35 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 36 |
+
(r'/\+', Comment.Multiline, 'nestedcomment'),
|
| 37 |
+
# DoubleQuotedString
|
| 38 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
| 39 |
+
# Operators
|
| 40 |
+
(r'::=|:=|=|\(|\)|;|,|\*|-|\+|>|<|@|!|/|\||\^|\.|%|&|\[|\]|\{|\}',
|
| 41 |
+
Operator),
|
| 42 |
+
# keywords
|
| 43 |
+
(r'(clone|do|doFile|doString|method|for|if|else|elseif|then)\b',
|
| 44 |
+
Keyword),
|
| 45 |
+
# constants
|
| 46 |
+
(r'(nil|false|true)\b', Name.Constant),
|
| 47 |
+
# names
|
| 48 |
+
(r'(Object|list|List|Map|args|Sequence|Coroutine|File)\b',
|
| 49 |
+
Name.Builtin),
|
| 50 |
+
(r'[a-zA-Z_]\w*', Name),
|
| 51 |
+
# numbers
|
| 52 |
+
(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
| 53 |
+
(r'\d+', Number.Integer)
|
| 54 |
+
],
|
| 55 |
+
'nestedcomment': [
|
| 56 |
+
(r'[^+/]+', Comment.Multiline),
|
| 57 |
+
(r'/\+', Comment.Multiline, '#push'),
|
| 58 |
+
(r'\+/', Comment.Multiline, '#pop'),
|
| 59 |
+
(r'[+/]', Comment.Multiline),
|
| 60 |
+
]
|
| 61 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/j.py
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.j
|
| 3 |
+
~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for the J programming language.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, words, include, bygroups
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, String, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['JLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class JLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For J source code.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
name = 'J'
|
| 24 |
+
url = 'http://jsoftware.com/'
|
| 25 |
+
aliases = ['j']
|
| 26 |
+
filenames = ['*.ijs']
|
| 27 |
+
mimetypes = ['text/x-j']
|
| 28 |
+
version_added = '2.1'
|
| 29 |
+
|
| 30 |
+
validName = r'\b[a-zA-Z]\w*'
|
| 31 |
+
|
| 32 |
+
tokens = {
|
| 33 |
+
'root': [
|
| 34 |
+
# Shebang script
|
| 35 |
+
(r'#!.*$', Comment.Preproc),
|
| 36 |
+
|
| 37 |
+
# Comments
|
| 38 |
+
(r'NB\..*', Comment.Single),
|
| 39 |
+
(r'(\n+\s*)(Note)', bygroups(Whitespace, Comment.Multiline),
|
| 40 |
+
'comment'),
|
| 41 |
+
(r'(\s*)(Note.*)', bygroups(Whitespace, Comment.Single)),
|
| 42 |
+
|
| 43 |
+
# Whitespace
|
| 44 |
+
(r'\s+', Whitespace),
|
| 45 |
+
|
| 46 |
+
# Strings
|
| 47 |
+
(r"'", String, 'singlequote'),
|
| 48 |
+
|
| 49 |
+
# Definitions
|
| 50 |
+
(r'0\s+:\s*0', Name.Entity, 'nounDefinition'),
|
| 51 |
+
(r'(noun)(\s+)(define)(\s*)$', bygroups(Name.Entity, Whitespace,
|
| 52 |
+
Name.Entity, Whitespace), 'nounDefinition'),
|
| 53 |
+
(r'([1-4]|13)\s+:\s*0\b',
|
| 54 |
+
Name.Function, 'explicitDefinition'),
|
| 55 |
+
(r'(adverb|conjunction|dyad|monad|verb)(\s+)(define)\b',
|
| 56 |
+
bygroups(Name.Function, Whitespace, Name.Function),
|
| 57 |
+
'explicitDefinition'),
|
| 58 |
+
|
| 59 |
+
# Flow Control
|
| 60 |
+
(words(('for_', 'goto_', 'label_'), suffix=validName+r'\.'), Name.Label),
|
| 61 |
+
(words((
|
| 62 |
+
'assert', 'break', 'case', 'catch', 'catchd',
|
| 63 |
+
'catcht', 'continue', 'do', 'else', 'elseif',
|
| 64 |
+
'end', 'fcase', 'for', 'if', 'return',
|
| 65 |
+
'select', 'throw', 'try', 'while', 'whilst',
|
| 66 |
+
), suffix=r'\.'), Name.Label),
|
| 67 |
+
|
| 68 |
+
# Variable Names
|
| 69 |
+
(validName, Name.Variable),
|
| 70 |
+
|
| 71 |
+
# Standard Library
|
| 72 |
+
(words((
|
| 73 |
+
'ARGV', 'CR', 'CRLF', 'DEL', 'Debug',
|
| 74 |
+
'EAV', 'EMPTY', 'FF', 'JVERSION', 'LF',
|
| 75 |
+
'LF2', 'Note', 'TAB', 'alpha17', 'alpha27',
|
| 76 |
+
'apply', 'bind', 'boxopen', 'boxxopen', 'bx',
|
| 77 |
+
'clear', 'cutLF', 'cutopen', 'datatype', 'def',
|
| 78 |
+
'dfh', 'drop', 'each', 'echo', 'empty',
|
| 79 |
+
'erase', 'every', 'evtloop', 'exit', 'expand',
|
| 80 |
+
'fetch', 'file2url', 'fixdotdot', 'fliprgb', 'getargs',
|
| 81 |
+
'getenv', 'hfd', 'inv', 'inverse', 'iospath',
|
| 82 |
+
'isatty', 'isutf8', 'items', 'leaf', 'list',
|
| 83 |
+
'nameclass', 'namelist', 'names', 'nc',
|
| 84 |
+
'nl', 'on', 'pick', 'rows',
|
| 85 |
+
'script', 'scriptd', 'sign', 'sminfo', 'smoutput',
|
| 86 |
+
'sort', 'split', 'stderr', 'stdin', 'stdout',
|
| 87 |
+
'table', 'take', 'timespacex', 'timex', 'tmoutput',
|
| 88 |
+
'toCRLF', 'toHOST', 'toJ', 'tolower', 'toupper',
|
| 89 |
+
'type', 'ucp', 'ucpcount', 'usleep', 'utf8',
|
| 90 |
+
'uucp',
|
| 91 |
+
)), Name.Function),
|
| 92 |
+
|
| 93 |
+
# Copula
|
| 94 |
+
(r'=[.:]', Operator),
|
| 95 |
+
|
| 96 |
+
# Builtins
|
| 97 |
+
(r'[-=+*#$%@!~`^&";:.,<>{}\[\]\\|/?]', Operator),
|
| 98 |
+
|
| 99 |
+
# Short Keywords
|
| 100 |
+
(r'[abCdDeEfHiIjLMoprtT]\.', Keyword.Reserved),
|
| 101 |
+
(r'[aDiLpqsStux]\:', Keyword.Reserved),
|
| 102 |
+
(r'(_[0-9])\:', Keyword.Constant),
|
| 103 |
+
|
| 104 |
+
# Parens
|
| 105 |
+
(r'\(', Punctuation, 'parentheses'),
|
| 106 |
+
|
| 107 |
+
# Numbers
|
| 108 |
+
include('numbers'),
|
| 109 |
+
],
|
| 110 |
+
|
| 111 |
+
'comment': [
|
| 112 |
+
(r'[^)]', Comment.Multiline),
|
| 113 |
+
(r'^\)', Comment.Multiline, '#pop'),
|
| 114 |
+
(r'[)]', Comment.Multiline),
|
| 115 |
+
],
|
| 116 |
+
|
| 117 |
+
'explicitDefinition': [
|
| 118 |
+
(r'\b[nmuvxy]\b', Name.Decorator),
|
| 119 |
+
include('root'),
|
| 120 |
+
(r'[^)]', Name),
|
| 121 |
+
(r'^\)', Name.Label, '#pop'),
|
| 122 |
+
(r'[)]', Name),
|
| 123 |
+
],
|
| 124 |
+
|
| 125 |
+
'numbers': [
|
| 126 |
+
(r'\b_{1,2}\b', Number),
|
| 127 |
+
(r'_?\d+(\.\d+)?(\s*[ejr]\s*)_?\d+(\.?=\d+)?', Number),
|
| 128 |
+
(r'_?\d+\.(?=\d+)', Number.Float),
|
| 129 |
+
(r'_?\d+x', Number.Integer.Long),
|
| 130 |
+
(r'_?\d+', Number.Integer),
|
| 131 |
+
],
|
| 132 |
+
|
| 133 |
+
'nounDefinition': [
|
| 134 |
+
(r'[^)]+', String),
|
| 135 |
+
(r'^\)', Name.Label, '#pop'),
|
| 136 |
+
(r'[)]', String),
|
| 137 |
+
],
|
| 138 |
+
|
| 139 |
+
'parentheses': [
|
| 140 |
+
(r'\)', Punctuation, '#pop'),
|
| 141 |
+
# include('nounDefinition'),
|
| 142 |
+
include('explicitDefinition'),
|
| 143 |
+
include('root'),
|
| 144 |
+
],
|
| 145 |
+
|
| 146 |
+
'singlequote': [
|
| 147 |
+
(r"[^']+", String),
|
| 148 |
+
(r"''", String),
|
| 149 |
+
(r"'", String, '#pop'),
|
| 150 |
+
],
|
| 151 |
+
}
|
.cache/uv/archive-v0/RMeM3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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.javascript
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for JavaScript 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 bygroups, combined, default, do_insertions, include, \
|
| 14 |
+
inherit, Lexer, RegexLexer, this, using, words, line_re
|
| 15 |
+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
| 16 |
+
Number, Punctuation, Other, Generic, Whitespace
|
| 17 |
+
from pygments.util import get_bool_opt
|
| 18 |
+
import pygments.unistring as uni
|
| 19 |
+
|
| 20 |
+
__all__ = ['JavascriptLexer', 'KalLexer', 'LiveScriptLexer', 'DartLexer',
|
| 21 |
+
'TypeScriptLexer', 'LassoLexer', 'ObjectiveJLexer',
|
| 22 |
+
'CoffeeScriptLexer', 'MaskLexer', 'EarlGreyLexer', 'JuttleLexer',
|
| 23 |
+
'NodeConsoleLexer']
|
| 24 |
+
|
| 25 |
+
JS_IDENT_START = ('(?:[$_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') +
|
| 26 |
+
']|\\\\u[a-fA-F0-9]{4})')
|
| 27 |
+
JS_IDENT_PART = ('(?:[$' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
|
| 28 |
+
'Mn', 'Mc', 'Nd', 'Pc') +
|
| 29 |
+
'\u200c\u200d]|\\\\u[a-fA-F0-9]{4})')
|
| 30 |
+
JS_IDENT = JS_IDENT_START + '(?:' + JS_IDENT_PART + ')*'
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class JavascriptLexer(RegexLexer):
|
| 34 |
+
"""
|
| 35 |
+
For JavaScript source code.
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
name = 'JavaScript'
|
| 39 |
+
url = 'https://www.ecma-international.org/publications-and-standards/standards/ecma-262/'
|
| 40 |
+
aliases = ['javascript', 'js']
|
| 41 |
+
filenames = ['*.js', '*.jsm', '*.mjs', '*.cjs']
|
| 42 |
+
mimetypes = ['application/javascript', 'application/x-javascript',
|
| 43 |
+
'text/x-javascript', 'text/javascript']
|
| 44 |
+
version_added = ''
|
| 45 |
+
|
| 46 |
+
flags = re.DOTALL | re.MULTILINE
|
| 47 |
+
|
| 48 |
+
tokens = {
|
| 49 |
+
'commentsandwhitespace': [
|
| 50 |
+
(r'\s+', Whitespace),
|
| 51 |
+
(r'<!--', Comment),
|
| 52 |
+
(r'//.*?$', Comment.Single),
|
| 53 |
+
(r'/\*.*?\*/', Comment.Multiline)
|
| 54 |
+
],
|
| 55 |
+
'slashstartsregex': [
|
| 56 |
+
include('commentsandwhitespace'),
|
| 57 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 58 |
+
r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
|
| 59 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 60 |
+
default('#pop')
|
| 61 |
+
],
|
| 62 |
+
'badregex': [
|
| 63 |
+
(r'\n', Whitespace, '#pop')
|
| 64 |
+
],
|
| 65 |
+
'root': [
|
| 66 |
+
(r'\A#! ?/.*?$', Comment.Hashbang), # recognized by node.js
|
| 67 |
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
| 68 |
+
include('commentsandwhitespace'),
|
| 69 |
+
|
| 70 |
+
# Numeric literals
|
| 71 |
+
(r'0[bB][01]+n?', Number.Bin),
|
| 72 |
+
(r'0[oO]?[0-7]+n?', Number.Oct), # Browsers support "0o7" and "07" (< ES5) notations
|
| 73 |
+
(r'0[xX][0-9a-fA-F]+n?', Number.Hex),
|
| 74 |
+
(r'[0-9]+n', Number.Integer), # Javascript BigInt requires an "n" postfix
|
| 75 |
+
# Javascript doesn't have actual integer literals, so every other
|
| 76 |
+
# numeric literal is handled by the regex below (including "normal")
|
| 77 |
+
# integers
|
| 78 |
+
(r'(\.[0-9]+|[0-9]+\.[0-9]*|[0-9]+)([eE][-+]?[0-9]+)?', Number.Float),
|
| 79 |
+
|
| 80 |
+
(r'\.\.\.|=>', Punctuation),
|
| 81 |
+
(r'\+\+|--|~|\?\?=?|\?|:|\\(?=\n)|'
|
| 82 |
+
r'(<<|>>>?|==?|!=?|(?:\*\*|\|\||&&|[-<>+*%&|^/]))=?', Operator, 'slashstartsregex'),
|
| 83 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 84 |
+
(r'[})\].]', Punctuation),
|
| 85 |
+
|
| 86 |
+
(r'(typeof|instanceof|in|void|delete|new)\b', Operator.Word, 'slashstartsregex'),
|
| 87 |
+
|
| 88 |
+
# Match stuff like: constructor
|
| 89 |
+
(r'\b(constructor|from|as)\b', Keyword.Reserved),
|
| 90 |
+
|
| 91 |
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
|
| 92 |
+
r'throw|try|catch|finally|yield|await|async|this|of|static|export|'
|
| 93 |
+
r'import|debugger|extends|super)\b', Keyword, 'slashstartsregex'),
|
| 94 |
+
(r'(var|let|const|with|function|class)\b', Keyword.Declaration, 'slashstartsregex'),
|
| 95 |
+
|
| 96 |
+
(r'(abstract|boolean|byte|char|double|enum|final|float|goto|'
|
| 97 |
+
r'implements|int|interface|long|native|package|private|protected|'
|
| 98 |
+
r'public|short|synchronized|throws|transient|volatile)\b', Keyword.Reserved),
|
| 99 |
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
| 100 |
+
|
| 101 |
+
(r'(Array|Boolean|Date|BigInt|Function|Math|ArrayBuffer|'
|
| 102 |
+
r'Number|Object|RegExp|String|Promise|Proxy|decodeURI|'
|
| 103 |
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
| 104 |
+
r'eval|isFinite|isNaN|parseFloat|parseInt|DataView|'
|
| 105 |
+
r'document|window|globalThis|global|Symbol|Intl|'
|
| 106 |
+
r'WeakSet|WeakMap|Set|Map|Reflect|JSON|Atomics|'
|
| 107 |
+
r'Int(?:8|16|32)Array|BigInt64Array|Float32Array|Float64Array|'
|
| 108 |
+
r'Uint8ClampedArray|Uint(?:8|16|32)Array|BigUint64Array)\b', Name.Builtin),
|
| 109 |
+
|
| 110 |
+
(r'((?:Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\b', Name.Exception),
|
| 111 |
+
|
| 112 |
+
# Match stuff like: super(argument, list)
|
| 113 |
+
(r'(super)(\s*)(\([\w,?.$\s]+\s*\))',
|
| 114 |
+
bygroups(Keyword, Whitespace), 'slashstartsregex'),
|
| 115 |
+
# Match stuff like: function() {...}
|
| 116 |
+
(r'([a-zA-Z_?.$][\w?.$]*)(?=\(\) \{)', Name.Other, 'slashstartsregex'),
|
| 117 |
+
|
| 118 |
+
(JS_IDENT, Name.Other),
|
| 119 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 120 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 121 |
+
(r'`', String.Backtick, 'interp'),
|
| 122 |
+
# private identifier
|
| 123 |
+
(r'#[a-zA-Z_]\w*', Name),
|
| 124 |
+
],
|
| 125 |
+
'interp': [
|
| 126 |
+
(r'`', String.Backtick, '#pop'),
|
| 127 |
+
(r'\\.', String.Backtick),
|
| 128 |
+
(r'\$\{', String.Interpol, 'interp-inside'),
|
| 129 |
+
(r'\$', String.Backtick),
|
| 130 |
+
(r'[^`\\$]+', String.Backtick),
|
| 131 |
+
],
|
| 132 |
+
'interp-inside': [
|
| 133 |
+
# TODO: should this include single-line comments and allow nesting strings?
|
| 134 |
+
(r'\}', String.Interpol, '#pop'),
|
| 135 |
+
include('root'),
|
| 136 |
+
],
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
class TypeScriptLexer(JavascriptLexer):
|
| 141 |
+
"""
|
| 142 |
+
For TypeScript source code.
|
| 143 |
+
"""
|
| 144 |
+
|
| 145 |
+
name = 'TypeScript'
|
| 146 |
+
url = 'https://www.typescriptlang.org/'
|
| 147 |
+
aliases = ['typescript', 'ts']
|
| 148 |
+
filenames = ['*.ts']
|
| 149 |
+
mimetypes = ['application/x-typescript', 'text/x-typescript']
|
| 150 |
+
version_added = '1.6'
|
| 151 |
+
|
| 152 |
+
# Higher priority than the TypoScriptLexer, as TypeScript is far more
|
| 153 |
+
# common these days
|
| 154 |
+
priority = 0.5
|
| 155 |
+
|
| 156 |
+
tokens = {
|
| 157 |
+
'root': [
|
| 158 |
+
(r'(abstract|implements|private|protected|public|readonly)\b',
|
| 159 |
+
Keyword, 'slashstartsregex'),
|
| 160 |
+
(r'(enum|interface|override)\b', Keyword.Declaration, 'slashstartsregex'),
|
| 161 |
+
(r'\b(declare|type)\b', Keyword.Reserved),
|
| 162 |
+
# Match variable type keywords
|
| 163 |
+
(r'\b(string|boolean|number)\b', Keyword.Type),
|
| 164 |
+
# Match stuff like: module name {...}
|
| 165 |
+
(r'\b(module)(\s*)([\w?.$]+)(\s*)',
|
| 166 |
+
bygroups(Keyword.Reserved, Whitespace, Name.Other, Whitespace), 'slashstartsregex'),
|
| 167 |
+
# Match stuff like: (function: return type)
|
| 168 |
+
(r'([\w?.$]+)(\s*)(:)(\s*)([\w?.$]+)',
|
| 169 |
+
bygroups(Name.Other, Whitespace, Operator, Whitespace, Keyword.Type)),
|
| 170 |
+
# Match stuff like: Decorators
|
| 171 |
+
(r'@' + JS_IDENT, Keyword.Declaration),
|
| 172 |
+
inherit,
|
| 173 |
+
# private identifier
|
| 174 |
+
(r'#[a-zA-Z_]\w*', Name),
|
| 175 |
+
],
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
class KalLexer(RegexLexer):
|
| 180 |
+
"""
|
| 181 |
+
For Kal source code.
|
| 182 |
+
"""
|
| 183 |
+
|
| 184 |
+
name = 'Kal'
|
| 185 |
+
url = 'http://rzimmerman.github.io/kal'
|
| 186 |
+
aliases = ['kal']
|
| 187 |
+
filenames = ['*.kal']
|
| 188 |
+
mimetypes = ['text/kal', 'application/kal']
|
| 189 |
+
version_added = '2.0'
|
| 190 |
+
|
| 191 |
+
flags = re.DOTALL
|
| 192 |
+
tokens = {
|
| 193 |
+
'commentsandwhitespace': [
|
| 194 |
+
(r'\s+', Whitespace),
|
| 195 |
+
(r'###[^#].*?###', Comment.Multiline),
|
| 196 |
+
(r'(#(?!##[^#]).*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 197 |
+
],
|
| 198 |
+
'functiondef': [
|
| 199 |
+
(r'([$a-zA-Z_][\w$]*)(\s*)', bygroups(Name.Function, Whitespace),
|
| 200 |
+
'#pop'),
|
| 201 |
+
include('commentsandwhitespace'),
|
| 202 |
+
],
|
| 203 |
+
'classdef': [
|
| 204 |
+
(r'\b(inherits)(\s+)(from)\b',
|
| 205 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 206 |
+
(r'([$a-zA-Z_][\w$]*)(?=\s*\n)', Name.Class, '#pop'),
|
| 207 |
+
(r'[$a-zA-Z_][\w$]*\b', Name.Class),
|
| 208 |
+
include('commentsandwhitespace'),
|
| 209 |
+
],
|
| 210 |
+
'listcomprehension': [
|
| 211 |
+
(r'\]', Punctuation, '#pop'),
|
| 212 |
+
(r'\b(property|value)\b', Keyword),
|
| 213 |
+
include('root'),
|
| 214 |
+
],
|
| 215 |
+
'waitfor': [
|
| 216 |
+
(r'\n', Whitespace, '#pop'),
|
| 217 |
+
(r'\bfrom\b', Keyword),
|
| 218 |
+
include('root'),
|
| 219 |
+
],
|
| 220 |
+
'root': [
|
| 221 |
+
include('commentsandwhitespace'),
|
| 222 |
+
(r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 223 |
+
r'([gimuysd]+\b|\B)', String.Regex),
|
| 224 |
+
(r'\?|:|_(?=\n)|==?|!=|-(?!>)|[<>+*/-]=?',
|
| 225 |
+
Operator),
|
| 226 |
+
(r'\b(and|or|isnt|is|not|but|bitwise|mod|\^|xor|exists|'
|
| 227 |
+
r'doesnt\s+exist)\b', Operator.Word),
|
| 228 |
+
(r'(\([^()]+\))?(\s*)(>)',
|
| 229 |
+
bygroups(Name.Function, Whitespace, Punctuation)),
|
| 230 |
+
(r'[{(]', Punctuation),
|
| 231 |
+
(r'\[', Punctuation, 'listcomprehension'),
|
| 232 |
+
(r'[})\].,]', Punctuation),
|
| 233 |
+
(r'\b(function|method|task)\b', Keyword.Declaration, 'functiondef'),
|
| 234 |
+
(r'\bclass\b', Keyword.Declaration, 'classdef'),
|
| 235 |
+
(r'\b(safe(?=\s))?(\s*)(wait(?=\s))(\s+)(for)\b',
|
| 236 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace,
|
| 237 |
+
Keyword), 'waitfor'),
|
| 238 |
+
(r'\b(me|this)(\.[$a-zA-Z_][\w.$]*)?\b', Name.Variable.Instance),
|
| 239 |
+
(r'(?<![.$])(run)(\s+)(in)(\s+)(parallel)\b',
|
| 240 |
+
bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)),
|
| 241 |
+
(r'(?<![.$])(for)(\s+)(parallel|series)?\b',
|
| 242 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 243 |
+
(r'(?<![.$])(except)(\s+)(when)?\b',
|
| 244 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 245 |
+
(r'(?<![.$])(fail)(\s+)(with)?\b',
|
| 246 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 247 |
+
(r'(?<![.$])(inherits)(\s+)(from)?\b',
|
| 248 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 249 |
+
(r'(?<![.$])(for)(\s+)(parallel|series)?\b',
|
| 250 |
+
bygroups(Keyword, Whitespace, Keyword)),
|
| 251 |
+
(words((
|
| 252 |
+
'in', 'of', 'while', 'until', 'break', 'return', 'continue',
|
| 253 |
+
'when', 'if', 'unless', 'else', 'otherwise', 'throw', 'raise',
|
| 254 |
+
'try', 'catch', 'finally', 'new', 'delete', 'typeof',
|
| 255 |
+
'instanceof', 'super'), prefix=r'(?<![.$])', suffix=r'\b'),
|
| 256 |
+
Keyword),
|
| 257 |
+
(words((
|
| 258 |
+
'true', 'false', 'yes', 'no', 'on', 'off', 'null', 'nothing',
|
| 259 |
+
'none', 'NaN', 'Infinity', 'undefined'), prefix=r'(?<![.$])',
|
| 260 |
+
suffix=r'\b'), Keyword.Constant),
|
| 261 |
+
(words((
|
| 262 |
+
'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math',
|
| 263 |
+
'Number', 'Object', 'RegExp', 'String', 'decodeURI',
|
| 264 |
+
'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'eval',
|
| 265 |
+
'isFinite', 'isNaN', 'isSafeInteger', 'parseFloat', 'parseInt',
|
| 266 |
+
'document', 'window', 'globalThis', 'Symbol', 'print'),
|
| 267 |
+
suffix=r'\b'), Name.Builtin),
|
| 268 |
+
(r'([$a-zA-Z_][\w.$]*)(\s*)(:|[+\-*/]?\=)?\b',
|
| 269 |
+
bygroups(Name.Variable, Whitespace, Operator)),
|
| 270 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 271 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 272 |
+
(r'[0-9]+', Number.Integer),
|
| 273 |
+
('"""', String, 'tdqs'),
|
| 274 |
+
("'''", String, 'tsqs'),
|
| 275 |
+
('"', String, 'dqs'),
|
| 276 |
+
("'", String, 'sqs'),
|
| 277 |
+
],
|
| 278 |
+
'strings': [
|
| 279 |
+
(r'[^#\\\'"]+', String),
|
| 280 |
+
# note that all kal strings are multi-line.
|
| 281 |
+
# hashmarks, quotes and backslashes must be parsed one at a time
|
| 282 |
+
],
|
| 283 |
+
'interpoling_string': [
|
| 284 |
+
(r'\}', String.Interpol, "#pop"),
|
| 285 |
+
include('root')
|
| 286 |
+
],
|
| 287 |
+
'dqs': [
|
| 288 |
+
(r'"', String, '#pop'),
|
| 289 |
+
(r'\\.|\'', String), # double-quoted string don't need ' escapes
|
| 290 |
+
(r'#\{', String.Interpol, "interpoling_string"),
|
| 291 |
+
include('strings')
|
| 292 |
+
],
|
| 293 |
+
'sqs': [
|
| 294 |
+
(r"'", String, '#pop'),
|
| 295 |
+
(r'#|\\.|"', String), # single quoted strings don't need " escapses
|
| 296 |
+
include('strings')
|
| 297 |
+
],
|
| 298 |
+
'tdqs': [
|
| 299 |
+
(r'"""', String, '#pop'),
|
| 300 |
+
(r'\\.|\'|"', String), # no need to escape quotes in triple-string
|
| 301 |
+
(r'#\{', String.Interpol, "interpoling_string"),
|
| 302 |
+
include('strings'),
|
| 303 |
+
],
|
| 304 |
+
'tsqs': [
|
| 305 |
+
(r"'''", String, '#pop'),
|
| 306 |
+
(r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
|
| 307 |
+
include('strings')
|
| 308 |
+
],
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
class LiveScriptLexer(RegexLexer):
|
| 313 |
+
"""
|
| 314 |
+
For LiveScript source code.
|
| 315 |
+
"""
|
| 316 |
+
|
| 317 |
+
name = 'LiveScript'
|
| 318 |
+
url = 'https://livescript.net/'
|
| 319 |
+
aliases = ['livescript', 'live-script']
|
| 320 |
+
filenames = ['*.ls']
|
| 321 |
+
mimetypes = ['text/livescript']
|
| 322 |
+
version_added = '1.6'
|
| 323 |
+
|
| 324 |
+
flags = re.DOTALL
|
| 325 |
+
tokens = {
|
| 326 |
+
'commentsandwhitespace': [
|
| 327 |
+
(r'\s+', Whitespace),
|
| 328 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 329 |
+
(r'(#.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 330 |
+
],
|
| 331 |
+
'multilineregex': [
|
| 332 |
+
include('commentsandwhitespace'),
|
| 333 |
+
(r'//([gimuysd]+\b|\B)', String.Regex, '#pop'),
|
| 334 |
+
(r'/', String.Regex),
|
| 335 |
+
(r'[^/#]+', String.Regex)
|
| 336 |
+
],
|
| 337 |
+
'slashstartsregex': [
|
| 338 |
+
include('commentsandwhitespace'),
|
| 339 |
+
(r'//', String.Regex, ('#pop', 'multilineregex')),
|
| 340 |
+
(r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 341 |
+
r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
|
| 342 |
+
(r'/', Operator, '#pop'),
|
| 343 |
+
default('#pop'),
|
| 344 |
+
],
|
| 345 |
+
'root': [
|
| 346 |
+
(r'\A(?=\s|/)', Text, 'slashstartsregex'),
|
| 347 |
+
include('commentsandwhitespace'),
|
| 348 |
+
(r'(?:\([^()]+\))?[ ]*[~-]{1,2}>|'
|
| 349 |
+
r'(?:\(?[^()\n]+\)?)?[ ]*<[~-]{1,2}', Name.Function),
|
| 350 |
+
(r'\+\+|&&|(?<![.$])\b(?:and|x?or|is|isnt|not)\b|\?|:|=|'
|
| 351 |
+
r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|'
|
| 352 |
+
r'~(?!\~?>)|-(?!\-?>)|<(?!\[)|(?<!\])>|'
|
| 353 |
+
r'[+*`%&|^/])=?',
|
| 354 |
+
Operator, 'slashstartsregex'),
|
| 355 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 356 |
+
(r'[})\].]', Punctuation),
|
| 357 |
+
(r'(?<![.$])(for|own|in|of|while|until|loop|break|'
|
| 358 |
+
r'return|continue|switch|when|then|if|unless|else|'
|
| 359 |
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|super|'
|
| 360 |
+
r'extends|this|class|by|const|var|to|til)\b', Keyword,
|
| 361 |
+
'slashstartsregex'),
|
| 362 |
+
(r'(?<![.$])(true|false|yes|no|on|off|'
|
| 363 |
+
r'null|NaN|Infinity|undefined|void)\b',
|
| 364 |
+
Keyword.Constant),
|
| 365 |
+
(r'(Array|Boolean|Date|Error|Function|Math|'
|
| 366 |
+
r'Number|Object|RegExp|String|decodeURI|'
|
| 367 |
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
| 368 |
+
r'eval|isFinite|isNaN|parseFloat|parseInt|document|window|'
|
| 369 |
+
r'globalThis|Symbol|Symbol|BigInt)\b', Name.Builtin),
|
| 370 |
+
(r'([$a-zA-Z_][\w.\-:$]*)(\s*)([:=])(\s+)',
|
| 371 |
+
bygroups(Name.Variable, Whitespace, Operator, Whitespace),
|
| 372 |
+
'slashstartsregex'),
|
| 373 |
+
(r'(@[$a-zA-Z_][\w.\-:$]*)(\s*)([:=])(\s+)',
|
| 374 |
+
bygroups(Name.Variable.Instance, Whitespace, Operator,
|
| 375 |
+
Whitespace),
|
| 376 |
+
'slashstartsregex'),
|
| 377 |
+
(r'@', Name.Other, 'slashstartsregex'),
|
| 378 |
+
(r'@?[$a-zA-Z_][\w-]*', Name.Other, 'slashstartsregex'),
|
| 379 |
+
(r'[0-9]+\.[0-9]+([eE][0-9]+)?[fd]?(?:[a-zA-Z_]+)?', Number.Float),
|
| 380 |
+
(r'[0-9]+(~[0-9a-z]+)?(?:[a-zA-Z_]+)?', Number.Integer),
|
| 381 |
+
('"""', String, 'tdqs'),
|
| 382 |
+
("'''", String, 'tsqs'),
|
| 383 |
+
('"', String, 'dqs'),
|
| 384 |
+
("'", String, 'sqs'),
|
| 385 |
+
(r'\\\S+', String),
|
| 386 |
+
(r'<\[.*?\]>', String),
|
| 387 |
+
],
|
| 388 |
+
'strings': [
|
| 389 |
+
(r'[^#\\\'"]+', String),
|
| 390 |
+
# note that all coffee script strings are multi-line.
|
| 391 |
+
# hashmarks, quotes and backslashes must be parsed one at a time
|
| 392 |
+
],
|
| 393 |
+
'interpoling_string': [
|
| 394 |
+
(r'\}', String.Interpol, "#pop"),
|
| 395 |
+
include('root')
|
| 396 |
+
],
|
| 397 |
+
'dqs': [
|
| 398 |
+
(r'"', String, '#pop'),
|
| 399 |
+
(r'\\.|\'', String), # double-quoted string don't need ' escapes
|
| 400 |
+
(r'#\{', String.Interpol, "interpoling_string"),
|
| 401 |
+
(r'#', String),
|
| 402 |
+
include('strings')
|
| 403 |
+
],
|
| 404 |
+
'sqs': [
|
| 405 |
+
(r"'", String, '#pop'),
|
| 406 |
+
(r'#|\\.|"', String), # single quoted strings don't need " escapses
|
| 407 |
+
include('strings')
|
| 408 |
+
],
|
| 409 |
+
'tdqs': [
|
| 410 |
+
(r'"""', String, '#pop'),
|
| 411 |
+
(r'\\.|\'|"', String), # no need to escape quotes in triple-string
|
| 412 |
+
(r'#\{', String.Interpol, "interpoling_string"),
|
| 413 |
+
(r'#', String),
|
| 414 |
+
include('strings'),
|
| 415 |
+
],
|
| 416 |
+
'tsqs': [
|
| 417 |
+
(r"'''", String, '#pop'),
|
| 418 |
+
(r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
|
| 419 |
+
include('strings')
|
| 420 |
+
],
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
class DartLexer(RegexLexer):
|
| 425 |
+
"""
|
| 426 |
+
For Dart source code.
|
| 427 |
+
"""
|
| 428 |
+
|
| 429 |
+
name = 'Dart'
|
| 430 |
+
url = 'http://dart.dev/'
|
| 431 |
+
aliases = ['dart']
|
| 432 |
+
filenames = ['*.dart']
|
| 433 |
+
mimetypes = ['text/x-dart']
|
| 434 |
+
version_added = '1.5'
|
| 435 |
+
|
| 436 |
+
flags = re.MULTILINE | re.DOTALL
|
| 437 |
+
|
| 438 |
+
tokens = {
|
| 439 |
+
'root': [
|
| 440 |
+
include('string_literal'),
|
| 441 |
+
(r'#!(.*?)$', Comment.Preproc),
|
| 442 |
+
(r'\b(import|export)\b', Keyword, 'import_decl'),
|
| 443 |
+
(r'\b(library|source|part of|part)\b', Keyword),
|
| 444 |
+
(r'[^\S\n]+', Whitespace),
|
| 445 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 446 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 447 |
+
(r'\b(class|extension|mixin)\b(\s+)',
|
| 448 |
+
bygroups(Keyword.Declaration, Whitespace), 'class'),
|
| 449 |
+
(r'\b(as|assert|break|case|catch|const|continue|default|do|else|finally|'
|
| 450 |
+
r'for|if|in|is|new|rethrow|return|super|switch|this|throw|try|while)\b',
|
| 451 |
+
Keyword),
|
| 452 |
+
(r'\b(abstract|async|await|const|covariant|extends|external|factory|final|'
|
| 453 |
+
r'get|implements|late|native|on|operator|required|set|static|sync|typedef|'
|
| 454 |
+
r'var|with|yield)\b', Keyword.Declaration),
|
| 455 |
+
(r'\b(bool|double|dynamic|int|num|Function|Never|Null|Object|String|void)\b',
|
| 456 |
+
Keyword.Type),
|
| 457 |
+
(r'\b(false|null|true)\b', Keyword.Constant),
|
| 458 |
+
(r'[~!%^&*+=|?:<>/-]|as\b', Operator),
|
| 459 |
+
(r'@[a-zA-Z_$]\w*', Name.Decorator),
|
| 460 |
+
(r'[a-zA-Z_$]\w*:', Name.Label),
|
| 461 |
+
(r'[a-zA-Z_$]\w*', Name),
|
| 462 |
+
(r'[(){}\[\],.;]', Punctuation),
|
| 463 |
+
(r'0[xX][0-9a-fA-F]+', Number.Hex),
|
| 464 |
+
# DIGIT+ (‘.’ DIGIT*)? EXPONENT?
|
| 465 |
+
(r'\d+(\.\d*)?([eE][+-]?\d+)?', Number),
|
| 466 |
+
(r'\.\d+([eE][+-]?\d+)?', Number), # ‘.’ DIGIT+ EXPONENT?
|
| 467 |
+
(r'\n', Whitespace)
|
| 468 |
+
# pseudo-keyword negate intentionally left out
|
| 469 |
+
],
|
| 470 |
+
'class': [
|
| 471 |
+
(r'[a-zA-Z_$]\w*', Name.Class, '#pop')
|
| 472 |
+
],
|
| 473 |
+
'import_decl': [
|
| 474 |
+
include('string_literal'),
|
| 475 |
+
(r'\s+', Whitespace),
|
| 476 |
+
(r'\b(as|deferred|show|hide)\b', Keyword),
|
| 477 |
+
(r'[a-zA-Z_$]\w*', Name),
|
| 478 |
+
(r'\,', Punctuation),
|
| 479 |
+
(r'\;', Punctuation, '#pop')
|
| 480 |
+
],
|
| 481 |
+
'string_literal': [
|
| 482 |
+
# Raw strings.
|
| 483 |
+
(r'r"""([\w\W]*?)"""', String.Double),
|
| 484 |
+
(r"r'''([\w\W]*?)'''", String.Single),
|
| 485 |
+
(r'r"(.*?)"', String.Double),
|
| 486 |
+
(r"r'(.*?)'", String.Single),
|
| 487 |
+
# Normal Strings.
|
| 488 |
+
(r'"""', String.Double, 'string_double_multiline'),
|
| 489 |
+
(r"'''", String.Single, 'string_single_multiline'),
|
| 490 |
+
(r'"', String.Double, 'string_double'),
|
| 491 |
+
(r"'", String.Single, 'string_single')
|
| 492 |
+
],
|
| 493 |
+
'string_common': [
|
| 494 |
+
(r"\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z'\"$\\])",
|
| 495 |
+
String.Escape),
|
| 496 |
+
(r'(\$)([a-zA-Z_]\w*)', bygroups(String.Interpol, Name)),
|
| 497 |
+
(r'(\$\{)(.*?)(\})',
|
| 498 |
+
bygroups(String.Interpol, using(this), String.Interpol))
|
| 499 |
+
],
|
| 500 |
+
'string_double': [
|
| 501 |
+
(r'"', String.Double, '#pop'),
|
| 502 |
+
(r'[^"$\\\n]+', String.Double),
|
| 503 |
+
include('string_common'),
|
| 504 |
+
(r'\$+', String.Double)
|
| 505 |
+
],
|
| 506 |
+
'string_double_multiline': [
|
| 507 |
+
(r'"""', String.Double, '#pop'),
|
| 508 |
+
(r'[^"$\\]+', String.Double),
|
| 509 |
+
include('string_common'),
|
| 510 |
+
(r'(\$|\")+', String.Double)
|
| 511 |
+
],
|
| 512 |
+
'string_single': [
|
| 513 |
+
(r"'", String.Single, '#pop'),
|
| 514 |
+
(r"[^'$\\\n]+", String.Single),
|
| 515 |
+
include('string_common'),
|
| 516 |
+
(r'\$+', String.Single)
|
| 517 |
+
],
|
| 518 |
+
'string_single_multiline': [
|
| 519 |
+
(r"'''", String.Single, '#pop'),
|
| 520 |
+
(r'[^\'$\\]+', String.Single),
|
| 521 |
+
include('string_common'),
|
| 522 |
+
(r'(\$|\')+', String.Single)
|
| 523 |
+
]
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
|
| 527 |
+
class LassoLexer(RegexLexer):
|
| 528 |
+
"""
|
| 529 |
+
For Lasso source code, covering both Lasso 9
|
| 530 |
+
syntax and LassoScript for Lasso 8.6 and earlier. For Lasso embedded in
|
| 531 |
+
HTML, use the `LassoHtmlLexer`.
|
| 532 |
+
|
| 533 |
+
Additional options accepted:
|
| 534 |
+
|
| 535 |
+
`builtinshighlighting`
|
| 536 |
+
If given and ``True``, highlight builtin types, traits, methods, and
|
| 537 |
+
members (default: ``True``).
|
| 538 |
+
`requiredelimiters`
|
| 539 |
+
If given and ``True``, only highlight code between delimiters as Lasso
|
| 540 |
+
(default: ``False``).
|
| 541 |
+
"""
|
| 542 |
+
|
| 543 |
+
name = 'Lasso'
|
| 544 |
+
aliases = ['lasso', 'lassoscript']
|
| 545 |
+
filenames = ['*.lasso', '*.lasso[89]']
|
| 546 |
+
version_added = '1.6'
|
| 547 |
+
alias_filenames = ['*.incl', '*.inc', '*.las']
|
| 548 |
+
mimetypes = ['text/x-lasso']
|
| 549 |
+
url = 'https://www.lassosoft.com'
|
| 550 |
+
|
| 551 |
+
flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
|
| 552 |
+
|
| 553 |
+
tokens = {
|
| 554 |
+
'root': [
|
| 555 |
+
(r'^#![ \S]+lasso9\b', Comment.Preproc, 'lasso'),
|
| 556 |
+
(r'(?=\[|<)', Other, 'delimiters'),
|
| 557 |
+
(r'\s+', Whitespace),
|
| 558 |
+
default(('delimiters', 'lassofile')),
|
| 559 |
+
],
|
| 560 |
+
'delimiters': [
|
| 561 |
+
(r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'),
|
| 562 |
+
(r'\[noprocess\]', Comment.Preproc, 'noprocess'),
|
| 563 |
+
(r'\[', Comment.Preproc, 'squarebrackets'),
|
| 564 |
+
(r'<\?(lasso(script)?|=)', Comment.Preproc, 'anglebrackets'),
|
| 565 |
+
(r'<(!--.*?-->)?', Other),
|
| 566 |
+
(r'[^[<]+', Other),
|
| 567 |
+
],
|
| 568 |
+
'nosquarebrackets': [
|
| 569 |
+
(r'\[noprocess\]', Comment.Preproc, 'noprocess'),
|
| 570 |
+
(r'\[', Other),
|
| 571 |
+
(r'<\?(lasso(script)?|=)', Comment.Preproc, 'anglebrackets'),
|
| 572 |
+
(r'<(!--.*?-->)?', Other),
|
| 573 |
+
(r'[^[<]+', Other),
|
| 574 |
+
],
|
| 575 |
+
'noprocess': [
|
| 576 |
+
(r'\[/noprocess\]', Comment.Preproc, '#pop'),
|
| 577 |
+
(r'\[', Other),
|
| 578 |
+
(r'[^[]', Other),
|
| 579 |
+
],
|
| 580 |
+
'squarebrackets': [
|
| 581 |
+
(r'\]', Comment.Preproc, '#pop'),
|
| 582 |
+
include('lasso'),
|
| 583 |
+
],
|
| 584 |
+
'anglebrackets': [
|
| 585 |
+
(r'\?>', Comment.Preproc, '#pop'),
|
| 586 |
+
include('lasso'),
|
| 587 |
+
],
|
| 588 |
+
'lassofile': [
|
| 589 |
+
(r'\]|\?>', Comment.Preproc, '#pop'),
|
| 590 |
+
include('lasso'),
|
| 591 |
+
],
|
| 592 |
+
'whitespacecomments': [
|
| 593 |
+
(r'\s+', Whitespace),
|
| 594 |
+
(r'(//.*?)(\s*)$', bygroups(Comment.Single, Whitespace)),
|
| 595 |
+
(r'/\*\*!.*?\*/', String.Doc),
|
| 596 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 597 |
+
],
|
| 598 |
+
'lasso': [
|
| 599 |
+
# whitespace/comments
|
| 600 |
+
include('whitespacecomments'),
|
| 601 |
+
|
| 602 |
+
# literals
|
| 603 |
+
(r'\d*\.\d+(e[+-]?\d+)?', Number.Float),
|
| 604 |
+
(r'0x[\da-f]+', Number.Hex),
|
| 605 |
+
(r'\d+', Number.Integer),
|
| 606 |
+
(r'(infinity|NaN)\b', Number),
|
| 607 |
+
(r"'", String.Single, 'singlestring'),
|
| 608 |
+
(r'"', String.Double, 'doublestring'),
|
| 609 |
+
(r'`[^`]*`', String.Backtick),
|
| 610 |
+
|
| 611 |
+
# names
|
| 612 |
+
(r'\$[a-z_][\w.]*', Name.Variable),
|
| 613 |
+
(r'#([a-z_][\w.]*|\d+\b)', Name.Variable.Instance),
|
| 614 |
+
(r"(\.)(\s*)('[a-z_][\w.]*')",
|
| 615 |
+
bygroups(Name.Builtin.Pseudo, Whitespace, Name.Variable.Class)),
|
| 616 |
+
(r"(self)(\s*)(->)(\s*)('[a-z_][\w.]*')",
|
| 617 |
+
bygroups(Name.Builtin.Pseudo, Whitespace, Operator, Whitespace,
|
| 618 |
+
Name.Variable.Class)),
|
| 619 |
+
(r'(\.\.?)(\s*)([a-z_][\w.]*(=(?!=))?)',
|
| 620 |
+
bygroups(Name.Builtin.Pseudo, Whitespace, Name.Other.Member)),
|
| 621 |
+
(r'(->\\?|&)(\s*)([a-z_][\w.]*(=(?!=))?)',
|
| 622 |
+
bygroups(Operator, Whitespace, Name.Other.Member)),
|
| 623 |
+
(r'(?<!->)(self|inherited|currentcapture|givenblock)\b',
|
| 624 |
+
Name.Builtin.Pseudo),
|
| 625 |
+
(r'-(?!infinity)[a-z_][\w.]*', Name.Attribute),
|
| 626 |
+
(r'(::)(\s*)([a-z_][\w.]*)',
|
| 627 |
+
bygroups(Punctuation, Whitespace, Name.Label)),
|
| 628 |
+
(r'(error_(code|msg)_\w+|Error_AddError|Error_ColumnRestriction|'
|
| 629 |
+
r'Error_DatabaseConnectionUnavailable|Error_DatabaseTimeout|'
|
| 630 |
+
r'Error_DeleteError|Error_FieldRestriction|Error_FileNotFound|'
|
| 631 |
+
r'Error_InvalidDatabase|Error_InvalidPassword|'
|
| 632 |
+
r'Error_InvalidUsername|Error_ModuleNotFound|'
|
| 633 |
+
r'Error_NoError|Error_NoPermission|Error_OutOfMemory|'
|
| 634 |
+
r'Error_ReqColumnMissing|Error_ReqFieldMissing|'
|
| 635 |
+
r'Error_RequiredColumnMissing|Error_RequiredFieldMissing|'
|
| 636 |
+
r'Error_UpdateError)\b', Name.Exception),
|
| 637 |
+
|
| 638 |
+
# definitions
|
| 639 |
+
(r'(define)(\s+)([a-z_][\w.]*)(\s*)(=>)(\s*)(type|trait|thread)\b',
|
| 640 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Class,
|
| 641 |
+
Whitespace, Operator, Whitespace, Keyword)),
|
| 642 |
+
(r'(define)(\s+)([a-z_][\w.]*)(\s*)(->)(\s*)([a-z_][\w.]*=?|[-+*/%])',
|
| 643 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Class,
|
| 644 |
+
Whitespace, Operator, Whitespace, Name.Function),
|
| 645 |
+
'signature'),
|
| 646 |
+
(r'(define)(\s+)([a-z_][\w.]*)',
|
| 647 |
+
bygroups(Keyword.Declaration, Whitespace, Name.Function), 'signature'),
|
| 648 |
+
(r'(public|protected|private|provide)(\s+)(([a-z_][\w.]*=?|[-+*/%])'
|
| 649 |
+
r'(?=\s*\())', bygroups(Keyword, Whitespace, Name.Function),
|
| 650 |
+
'signature'),
|
| 651 |
+
(r'(public|protected|private|provide)(\s+)([a-z_][\w.]*)',
|
| 652 |
+
bygroups(Keyword, Whitespace, Name.Function)),
|
| 653 |
+
|
| 654 |
+
# keywords
|
| 655 |
+
(r'(true|false|none|minimal|full|all|void)\b', Keyword.Constant),
|
| 656 |
+
(r'(local|var|variable|global|data(?=\s))\b', Keyword.Declaration),
|
| 657 |
+
(r'(array|date|decimal|duration|integer|map|pair|string|tag|xml|'
|
| 658 |
+
r'null|boolean|bytes|keyword|list|locale|queue|set|stack|'
|
| 659 |
+
r'staticarray)\b', Keyword.Type),
|
| 660 |
+
(r'([a-z_][\w.]*)(\s+)(in)\b', bygroups(Name, Whitespace, Keyword)),
|
| 661 |
+
(r'(let|into)(\s+)([a-z_][\w.]*)', bygroups(Keyword, Whitespace, Name)),
|
| 662 |
+
(r'require\b', Keyword, 'requiresection'),
|
| 663 |
+
(r'(/?)(Namespace_Using)\b', bygroups(Punctuation, Keyword.Namespace)),
|
| 664 |
+
(r'(/?)(Cache|Database_Names|Database_SchemaNames|'
|
| 665 |
+
r'Database_TableNames|Define_Tag|Define_Type|Email_Batch|'
|
| 666 |
+
r'Encode_Set|HTML_Comment|Handle|Handle_Error|Header|If|Inline|'
|
| 667 |
+
r'Iterate|LJAX_Target|Link|Link_CurrentAction|Link_CurrentGroup|'
|
| 668 |
+
r'Link_CurrentRecord|Link_Detail|Link_FirstGroup|Link_FirstRecord|'
|
| 669 |
+
r'Link_LastGroup|Link_LastRecord|Link_NextGroup|Link_NextRecord|'
|
| 670 |
+
r'Link_PrevGroup|Link_PrevRecord|Log|Loop|Output_None|Portal|'
|
| 671 |
+
r'Private|Protect|Records|Referer|Referrer|Repeating|ResultSet|'
|
| 672 |
+
r'Rows|Search_Args|Search_Arguments|Select|Sort_Args|'
|
| 673 |
+
r'Sort_Arguments|Thread_Atomic|Value_List|While|Abort|Case|Else|'
|
| 674 |
+
r'Fail_If|Fail_IfNot|Fail|If_Empty|If_False|If_Null|If_True|'
|
| 675 |
+
r'Loop_Abort|Loop_Continue|Loop_Count|Params|Params_Up|Return|'
|
| 676 |
+
r'Return_Value|Run_Children|SOAP_DefineTag|SOAP_LastRequest|'
|
| 677 |
+
r'SOAP_LastResponse|Tag_Name|ascending|average|by|define|'
|
| 678 |
+
r'descending|do|equals|frozen|group|handle_failure|import|in|into|'
|
| 679 |
+
r'join|let|match|max|min|on|order|parent|protected|provide|public|'
|
| 680 |
+
r'require|returnhome|skip|split_thread|sum|take|thread|to|trait|'
|
| 681 |
+
r'type|where|with|yield|yieldhome)\b',
|
| 682 |
+
bygroups(Punctuation, Keyword)),
|
| 683 |
+
|
| 684 |
+
# other
|
| 685 |
+
(r',', Punctuation, 'commamember'),
|
| 686 |
+
(r'(and|or|not)\b', Operator.Word),
|
| 687 |
+
(r'([a-z_][\w.]*)(\s*)(::)(\s*)([a-z_][\w.]*)?(\s*=(?!=))',
|
| 688 |
+
bygroups(Name, Whitespace, Punctuation, Whitespace, Name.Label,
|
| 689 |
+
Operator)),
|
| 690 |
+
(r'(/?)([\w.]+)', bygroups(Punctuation, Name.Other)),
|
| 691 |
+
(r'(=)(n?bw|n?ew|n?cn|lte?|gte?|n?eq|n?rx|ft)\b',
|
| 692 |
+
bygroups(Operator, Operator.Word)),
|
| 693 |
+
(r':=|[-+*/%=<>&|!?\\]+', Operator),
|
| 694 |
+
(r'[{}():;,@^]', Punctuation),
|
| 695 |
+
],
|
| 696 |
+
'singlestring': [
|
| 697 |
+
(r"'", String.Single, '#pop'),
|
| 698 |
+
(r"[^'\\]+", String.Single),
|
| 699 |
+
include('escape'),
|
| 700 |
+
(r"\\", String.Single),
|
| 701 |
+
],
|
| 702 |
+
'doublestring': [
|
| 703 |
+
(r'"', String.Double, '#pop'),
|
| 704 |
+
(r'[^"\\]+', String.Double),
|
| 705 |
+
include('escape'),
|
| 706 |
+
(r'\\', String.Double),
|
| 707 |
+
],
|
| 708 |
+
'escape': [
|
| 709 |
+
(r'\\(U[\da-f]{8}|u[\da-f]{4}|x[\da-f]{1,2}|[0-7]{1,3}|:[^:\n\r]+:|'
|
| 710 |
+
r'[abefnrtv?"\'\\]|$)', String.Escape),
|
| 711 |
+
],
|
| 712 |
+
'signature': [
|
| 713 |
+
(r'=>', Operator, '#pop'),
|
| 714 |
+
(r'\)', Punctuation, '#pop'),
|
| 715 |
+
(r'[(,]', Punctuation, 'parameter'),
|
| 716 |
+
include('lasso'),
|
| 717 |
+
],
|
| 718 |
+
'parameter': [
|
| 719 |
+
(r'\)', Punctuation, '#pop'),
|
| 720 |
+
(r'-?[a-z_][\w.]*', Name.Attribute, '#pop'),
|
| 721 |
+
(r'\.\.\.', Name.Builtin.Pseudo),
|
| 722 |
+
include('lasso'),
|
| 723 |
+
],
|
| 724 |
+
'requiresection': [
|
| 725 |
+
(r'(([a-z_][\w.]*=?|[-+*/%])(?=\s*\())', Name, 'requiresignature'),
|
| 726 |
+
(r'(([a-z_][\w.]*=?|[-+*/%])(?=(\s*::\s*[\w.]+)?\s*,))', Name),
|
| 727 |
+
(r'[a-z_][\w.]*=?|[-+*/%]', Name, '#pop'),
|
| 728 |
+
(r'(::)(\s*)([a-z_][\w.]*)',
|
| 729 |
+
bygroups(Punctuation, Whitespace, Name.Label)),
|
| 730 |
+
(r',', Punctuation),
|
| 731 |
+
include('whitespacecomments'),
|
| 732 |
+
],
|
| 733 |
+
'requiresignature': [
|
| 734 |
+
(r'(\)(?=(\s*::\s*[\w.]+)?\s*,))', Punctuation, '#pop'),
|
| 735 |
+
(r'\)', Punctuation, '#pop:2'),
|
| 736 |
+
(r'-?[a-z_][\w.]*', Name.Attribute),
|
| 737 |
+
(r'(::)(\s*)([a-z_][\w.]*)',
|
| 738 |
+
bygroups(Punctuation, Whitespace, Name.Label)),
|
| 739 |
+
(r'\.\.\.', Name.Builtin.Pseudo),
|
| 740 |
+
(r'[(,]', Punctuation),
|
| 741 |
+
include('whitespacecomments'),
|
| 742 |
+
],
|
| 743 |
+
'commamember': [
|
| 744 |
+
(r'(([a-z_][\w.]*=?|[-+*/%])'
|
| 745 |
+
r'(?=\s*(\(([^()]*\([^()]*\))*[^)]*\)\s*)?(::[\w.\s]+)?=>))',
|
| 746 |
+
Name.Function, 'signature'),
|
| 747 |
+
include('whitespacecomments'),
|
| 748 |
+
default('#pop'),
|
| 749 |
+
],
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
+
def __init__(self, **options):
|
| 753 |
+
self.builtinshighlighting = get_bool_opt(
|
| 754 |
+
options, 'builtinshighlighting', True)
|
| 755 |
+
self.requiredelimiters = get_bool_opt(
|
| 756 |
+
options, 'requiredelimiters', False)
|
| 757 |
+
|
| 758 |
+
self._builtins = set()
|
| 759 |
+
self._members = set()
|
| 760 |
+
if self.builtinshighlighting:
|
| 761 |
+
from pygments.lexers._lasso_builtins import BUILTINS, MEMBERS
|
| 762 |
+
for key, value in BUILTINS.items():
|
| 763 |
+
self._builtins.update(value)
|
| 764 |
+
for key, value in MEMBERS.items():
|
| 765 |
+
self._members.update(value)
|
| 766 |
+
RegexLexer.__init__(self, **options)
|
| 767 |
+
|
| 768 |
+
def get_tokens_unprocessed(self, text):
|
| 769 |
+
stack = ['root']
|
| 770 |
+
if self.requiredelimiters:
|
| 771 |
+
stack.append('delimiters')
|
| 772 |
+
for index, token, value in \
|
| 773 |
+
RegexLexer.get_tokens_unprocessed(self, text, stack):
|
| 774 |
+
if (token is Name.Other and value.lower() in self._builtins or
|
| 775 |
+
token is Name.Other.Member and
|
| 776 |
+
value.lower().rstrip('=') in self._members):
|
| 777 |
+
yield index, Name.Builtin, value
|
| 778 |
+
continue
|
| 779 |
+
yield index, token, value
|
| 780 |
+
|
| 781 |
+
def analyse_text(text):
|
| 782 |
+
rv = 0.0
|
| 783 |
+
if 'bin/lasso9' in text:
|
| 784 |
+
rv += 0.8
|
| 785 |
+
if re.search(r'<\?lasso', text, re.I):
|
| 786 |
+
rv += 0.4
|
| 787 |
+
if re.search(r'local\(', text, re.I):
|
| 788 |
+
rv += 0.4
|
| 789 |
+
return rv
|
| 790 |
+
|
| 791 |
+
|
| 792 |
+
class ObjectiveJLexer(RegexLexer):
|
| 793 |
+
"""
|
| 794 |
+
For Objective-J source code with preprocessor directives.
|
| 795 |
+
"""
|
| 796 |
+
|
| 797 |
+
name = 'Objective-J'
|
| 798 |
+
aliases = ['objective-j', 'objectivej', 'obj-j', 'objj']
|
| 799 |
+
filenames = ['*.j']
|
| 800 |
+
mimetypes = ['text/x-objective-j']
|
| 801 |
+
url = 'https://www.cappuccino.dev/learn/objective-j.html'
|
| 802 |
+
version_added = '1.3'
|
| 803 |
+
|
| 804 |
+
#: optional Comment or Whitespace
|
| 805 |
+
_ws = r'(?:\s|//[^\n]*\n|/[*](?:[^*]|[*][^/])*[*]/)*'
|
| 806 |
+
|
| 807 |
+
flags = re.DOTALL | re.MULTILINE
|
| 808 |
+
|
| 809 |
+
tokens = {
|
| 810 |
+
'root': [
|
| 811 |
+
include('whitespace'),
|
| 812 |
+
|
| 813 |
+
# function definition
|
| 814 |
+
(r'^(' + _ws + r'[+-]' + _ws + r')([(a-zA-Z_].*?[^(])(' + _ws + r'\{)',
|
| 815 |
+
bygroups(using(this), using(this, state='function_signature'),
|
| 816 |
+
using(this))),
|
| 817 |
+
|
| 818 |
+
# class definition
|
| 819 |
+
(r'(@interface|@implementation)(\s+)', bygroups(Keyword, Whitespace),
|
| 820 |
+
'classname'),
|
| 821 |
+
(r'(@class|@protocol)(\s*)', bygroups(Keyword, Whitespace),
|
| 822 |
+
'forward_classname'),
|
| 823 |
+
(r'(\s*)(@end)(\s*)', bygroups(Whitespace, Keyword, Whitespace)),
|
| 824 |
+
|
| 825 |
+
include('statements'),
|
| 826 |
+
('[{()}]', Punctuation),
|
| 827 |
+
(';', Punctuation),
|
| 828 |
+
],
|
| 829 |
+
'whitespace': [
|
| 830 |
+
(r'(@import)(\s+)("(?:\\\\|\\"|[^"])*")',
|
| 831 |
+
bygroups(Comment.Preproc, Whitespace, String.Double)),
|
| 832 |
+
(r'(@import)(\s+)(<(?:\\\\|\\>|[^>])*>)',
|
| 833 |
+
bygroups(Comment.Preproc, Whitespace, String.Double)),
|
| 834 |
+
(r'(#(?:include|import))(\s+)("(?:\\\\|\\"|[^"])*")',
|
| 835 |
+
bygroups(Comment.Preproc, Whitespace, String.Double)),
|
| 836 |
+
(r'(#(?:include|import))(\s+)(<(?:\\\\|\\>|[^>])*>)',
|
| 837 |
+
bygroups(Comment.Preproc, Whitespace, String.Double)),
|
| 838 |
+
|
| 839 |
+
(r'#if\s+0', Comment.Preproc, 'if0'),
|
| 840 |
+
(r'#', Comment.Preproc, 'macro'),
|
| 841 |
+
|
| 842 |
+
(r'\s+', Whitespace),
|
| 843 |
+
(r'(\\)(\n)',
|
| 844 |
+
bygroups(String.Escape, Whitespace)), # line continuation
|
| 845 |
+
(r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
|
| 846 |
+
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
| 847 |
+
(r'<!--', Comment),
|
| 848 |
+
],
|
| 849 |
+
'slashstartsregex': [
|
| 850 |
+
include('whitespace'),
|
| 851 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 852 |
+
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
| 853 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 854 |
+
default('#pop'),
|
| 855 |
+
],
|
| 856 |
+
'badregex': [
|
| 857 |
+
(r'\n', Whitespace, '#pop'),
|
| 858 |
+
],
|
| 859 |
+
'statements': [
|
| 860 |
+
(r'(L|@)?"', String, 'string'),
|
| 861 |
+
(r"(L|@)?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
|
| 862 |
+
String.Char),
|
| 863 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 864 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 865 |
+
(r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
|
| 866 |
+
(r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
|
| 867 |
+
(r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
|
| 868 |
+
(r'0[0-7]+[Ll]?', Number.Oct),
|
| 869 |
+
(r'\d+[Ll]?', Number.Integer),
|
| 870 |
+
|
| 871 |
+
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
| 872 |
+
|
| 873 |
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
| 874 |
+
r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?',
|
| 875 |
+
Operator, 'slashstartsregex'),
|
| 876 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 877 |
+
(r'[})\].]', Punctuation),
|
| 878 |
+
|
| 879 |
+
(r'(for|in|while|do|break|return|continue|switch|case|default|if|'
|
| 880 |
+
r'else|throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
| 881 |
+
r'prototype|__proto__)\b', Keyword, 'slashstartsregex'),
|
| 882 |
+
|
| 883 |
+
(r'(var|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
|
| 884 |
+
|
| 885 |
+
(r'(@selector|@private|@protected|@public|@encode|'
|
| 886 |
+
r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
|
| 887 |
+
r'@synthesize|@dynamic|@for|@accessors|new)\b', Keyword),
|
| 888 |
+
|
| 889 |
+
(r'(int|long|float|short|double|char|unsigned|signed|void|'
|
| 890 |
+
r'id|BOOL|bool|boolean|IBOutlet|IBAction|SEL|@outlet|@action)\b',
|
| 891 |
+
Keyword.Type),
|
| 892 |
+
|
| 893 |
+
(r'(self|super)\b', Name.Builtin),
|
| 894 |
+
|
| 895 |
+
(r'(TRUE|YES|FALSE|NO|Nil|nil|NULL)\b', Keyword.Constant),
|
| 896 |
+
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
| 897 |
+
(r'(ABS|ASIN|ACOS|ATAN|ATAN2|SIN|COS|TAN|EXP|POW|CEIL|FLOOR|ROUND|'
|
| 898 |
+
r'MIN|MAX|RAND|SQRT|E|LN2|LN10|LOG2E|LOG10E|PI|PI2|PI_2|SQRT1_2|'
|
| 899 |
+
r'SQRT2)\b', Keyword.Constant),
|
| 900 |
+
|
| 901 |
+
(r'(Array|Boolean|Date|Error|Function|Math|'
|
| 902 |
+
r'Number|Object|RegExp|String|decodeURI|'
|
| 903 |
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
| 904 |
+
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
| 905 |
+
r'window|globalThis|Symbol)\b', Name.Builtin),
|
| 906 |
+
|
| 907 |
+
(r'([$a-zA-Z_]\w*)(' + _ws + r')(?=\()',
|
| 908 |
+
bygroups(Name.Function, using(this))),
|
| 909 |
+
|
| 910 |
+
(r'[$a-zA-Z_]\w*', Name),
|
| 911 |
+
],
|
| 912 |
+
'classname': [
|
| 913 |
+
# interface definition that inherits
|
| 914 |
+
(r'([a-zA-Z_]\w*)(' + _ws + r':' + _ws +
|
| 915 |
+
r')([a-zA-Z_]\w*)?',
|
| 916 |
+
bygroups(Name.Class, using(this), Name.Class), '#pop'),
|
| 917 |
+
# interface definition for a category
|
| 918 |
+
(r'([a-zA-Z_]\w*)(' + _ws + r'\()([a-zA-Z_]\w*)(\))',
|
| 919 |
+
bygroups(Name.Class, using(this), Name.Label, Text), '#pop'),
|
| 920 |
+
# simple interface / implementation
|
| 921 |
+
(r'([a-zA-Z_]\w*)', Name.Class, '#pop'),
|
| 922 |
+
],
|
| 923 |
+
'forward_classname': [
|
| 924 |
+
(r'([a-zA-Z_]\w*)(\s*)(,)(\s*)',
|
| 925 |
+
bygroups(Name.Class, Whitespace, Text, Whitespace), '#push'),
|
| 926 |
+
(r'([a-zA-Z_]\w*)(\s*)(;?)',
|
| 927 |
+
bygroups(Name.Class, Whitespace, Text), '#pop'),
|
| 928 |
+
],
|
| 929 |
+
'function_signature': [
|
| 930 |
+
include('whitespace'),
|
| 931 |
+
|
| 932 |
+
# start of a selector w/ parameters
|
| 933 |
+
(r'(\(' + _ws + r')' # open paren
|
| 934 |
+
r'([a-zA-Z_]\w+)' # return type
|
| 935 |
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
| 936 |
+
r'([$a-zA-Z_]\w+' + _ws + r':)', # function name
|
| 937 |
+
bygroups(using(this), Keyword.Type, using(this),
|
| 938 |
+
Name.Function), 'function_parameters'),
|
| 939 |
+
|
| 940 |
+
# no-param function
|
| 941 |
+
(r'(\(' + _ws + r')' # open paren
|
| 942 |
+
r'([a-zA-Z_]\w+)' # return type
|
| 943 |
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
| 944 |
+
r'([$a-zA-Z_]\w+)', # function name
|
| 945 |
+
bygroups(using(this), Keyword.Type, using(this),
|
| 946 |
+
Name.Function), "#pop"),
|
| 947 |
+
|
| 948 |
+
# no return type given, start of a selector w/ parameters
|
| 949 |
+
(r'([$a-zA-Z_]\w+' + _ws + r':)', # function name
|
| 950 |
+
bygroups(Name.Function), 'function_parameters'),
|
| 951 |
+
|
| 952 |
+
# no return type given, no-param function
|
| 953 |
+
(r'([$a-zA-Z_]\w+)', # function name
|
| 954 |
+
bygroups(Name.Function), "#pop"),
|
| 955 |
+
|
| 956 |
+
default('#pop'),
|
| 957 |
+
],
|
| 958 |
+
'function_parameters': [
|
| 959 |
+
include('whitespace'),
|
| 960 |
+
|
| 961 |
+
# parameters
|
| 962 |
+
(r'(\(' + _ws + ')' # open paren
|
| 963 |
+
r'([^)]+)' # type
|
| 964 |
+
r'(' + _ws + r'\)' + _ws + r')' # close paren
|
| 965 |
+
r'([$a-zA-Z_]\w+)', # param name
|
| 966 |
+
bygroups(using(this), Keyword.Type, using(this), Text)),
|
| 967 |
+
|
| 968 |
+
# one piece of a selector name
|
| 969 |
+
(r'([$a-zA-Z_]\w+' + _ws + r':)', # function name
|
| 970 |
+
Name.Function),
|
| 971 |
+
|
| 972 |
+
# smallest possible selector piece
|
| 973 |
+
(r'(:)', Name.Function),
|
| 974 |
+
|
| 975 |
+
# var args
|
| 976 |
+
(r'(,' + _ws + r'\.\.\.)', using(this)),
|
| 977 |
+
|
| 978 |
+
# param name
|
| 979 |
+
(r'([$a-zA-Z_]\w+)', Text),
|
| 980 |
+
],
|
| 981 |
+
'expression': [
|
| 982 |
+
(r'([$a-zA-Z_]\w*)(\()', bygroups(Name.Function,
|
| 983 |
+
Punctuation)),
|
| 984 |
+
(r'(\))', Punctuation, "#pop"),
|
| 985 |
+
],
|
| 986 |
+
'string': [
|
| 987 |
+
(r'"', String, '#pop'),
|
| 988 |
+
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
|
| 989 |
+
(r'[^\\"\n]+', String), # all other characters
|
| 990 |
+
(r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation
|
| 991 |
+
(r'\\', String), # stray backslash
|
| 992 |
+
],
|
| 993 |
+
'macro': [
|
| 994 |
+
(r'[^/\n]+', Comment.Preproc),
|
| 995 |
+
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
|
| 996 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace), '#pop'),
|
| 997 |
+
(r'/', Comment.Preproc),
|
| 998 |
+
(r'(?<=\\)\n', Whitespace),
|
| 999 |
+
(r'\n', Whitespace, '#pop'),
|
| 1000 |
+
],
|
| 1001 |
+
'if0': [
|
| 1002 |
+
(r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
|
| 1003 |
+
(r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
|
| 1004 |
+
(r'(.*?)(\n)', bygroups(Comment, Whitespace)),
|
| 1005 |
+
]
|
| 1006 |
+
}
|
| 1007 |
+
|
| 1008 |
+
def analyse_text(text):
|
| 1009 |
+
if re.search(r'^\s*@import\s+[<"]', text, re.MULTILINE):
|
| 1010 |
+
# special directive found in most Objective-J files
|
| 1011 |
+
return True
|
| 1012 |
+
return False
|
| 1013 |
+
|
| 1014 |
+
|
| 1015 |
+
class CoffeeScriptLexer(RegexLexer):
|
| 1016 |
+
"""
|
| 1017 |
+
For CoffeeScript source code.
|
| 1018 |
+
"""
|
| 1019 |
+
|
| 1020 |
+
name = 'CoffeeScript'
|
| 1021 |
+
url = 'http://coffeescript.org'
|
| 1022 |
+
aliases = ['coffeescript', 'coffee-script', 'coffee']
|
| 1023 |
+
filenames = ['*.coffee']
|
| 1024 |
+
mimetypes = ['text/coffeescript']
|
| 1025 |
+
version_added = '1.3'
|
| 1026 |
+
|
| 1027 |
+
_operator_re = (
|
| 1028 |
+
r'\+\+|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|'
|
| 1029 |
+
r'\|\||\\(?=\n)|'
|
| 1030 |
+
r'(<<|>>>?|==?(?!>)|!=?|=(?!>)|-(?!>)|[<>+*`%&|\^/])=?')
|
| 1031 |
+
|
| 1032 |
+
flags = re.DOTALL
|
| 1033 |
+
tokens = {
|
| 1034 |
+
'commentsandwhitespace': [
|
| 1035 |
+
(r'\s+', Whitespace),
|
| 1036 |
+
(r'###[^#].*?###', Comment.Multiline),
|
| 1037 |
+
(r'(#(?!##[^#]).*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 1038 |
+
],
|
| 1039 |
+
'multilineregex': [
|
| 1040 |
+
(r'[^/#]+', String.Regex),
|
| 1041 |
+
(r'///([gimuysd]+\b|\B)', String.Regex, '#pop'),
|
| 1042 |
+
(r'#\{', String.Interpol, 'interpoling_string'),
|
| 1043 |
+
(r'[/#]', String.Regex),
|
| 1044 |
+
],
|
| 1045 |
+
'slashstartsregex': [
|
| 1046 |
+
include('commentsandwhitespace'),
|
| 1047 |
+
(r'///', String.Regex, ('#pop', 'multilineregex')),
|
| 1048 |
+
(r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 1049 |
+
r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
|
| 1050 |
+
# This isn't really guarding against mishighlighting well-formed
|
| 1051 |
+
# code, just the ability to infinite-loop between root and
|
| 1052 |
+
# slashstartsregex.
|
| 1053 |
+
(r'/', Operator, '#pop'),
|
| 1054 |
+
default('#pop'),
|
| 1055 |
+
],
|
| 1056 |
+
'root': [
|
| 1057 |
+
include('commentsandwhitespace'),
|
| 1058 |
+
(r'\A(?=\s|/)', Text, 'slashstartsregex'),
|
| 1059 |
+
(_operator_re, Operator, 'slashstartsregex'),
|
| 1060 |
+
(r'(?:\([^()]*\))?\s*[=-]>', Name.Function, 'slashstartsregex'),
|
| 1061 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 1062 |
+
(r'[})\].]', Punctuation),
|
| 1063 |
+
(r'(?<![.$])(for|own|in|of|while|until|'
|
| 1064 |
+
r'loop|break|return|continue|'
|
| 1065 |
+
r'switch|when|then|if|unless|else|'
|
| 1066 |
+
r'throw|try|catch|finally|new|delete|typeof|instanceof|super|'
|
| 1067 |
+
r'extends|this|class|by)\b', Keyword, 'slashstartsregex'),
|
| 1068 |
+
(r'(?<![.$])(true|false|yes|no|on|off|null|'
|
| 1069 |
+
r'NaN|Infinity|undefined)\b',
|
| 1070 |
+
Keyword.Constant),
|
| 1071 |
+
(r'(Array|Boolean|Date|Error|Function|Math|'
|
| 1072 |
+
r'Number|Object|RegExp|String|decodeURI|'
|
| 1073 |
+
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
| 1074 |
+
r'eval|isFinite|isNaN|parseFloat|parseInt|document|window|globalThis|Symbol)\b',
|
| 1075 |
+
Name.Builtin),
|
| 1076 |
+
(r'([$a-zA-Z_][\w.:$]*)(\s*)([:=])(\s+)',
|
| 1077 |
+
bygroups(Name.Variable, Whitespace, Operator, Whitespace),
|
| 1078 |
+
'slashstartsregex'),
|
| 1079 |
+
(r'(@[$a-zA-Z_][\w.:$]*)(\s*)([:=])(\s+)',
|
| 1080 |
+
bygroups(Name.Variable.Instance, Whitespace, Operator, Whitespace),
|
| 1081 |
+
'slashstartsregex'),
|
| 1082 |
+
(r'@', Name.Other, 'slashstartsregex'),
|
| 1083 |
+
(r'@?[$a-zA-Z_][\w$]*', Name.Other),
|
| 1084 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 1085 |
+
(r'0x[0-9a-fA-F]+', Number.Hex),
|
| 1086 |
+
(r'[0-9]+', Number.Integer),
|
| 1087 |
+
('"""', String, 'tdqs'),
|
| 1088 |
+
("'''", String, 'tsqs'),
|
| 1089 |
+
('"', String, 'dqs'),
|
| 1090 |
+
("'", String, 'sqs'),
|
| 1091 |
+
],
|
| 1092 |
+
'strings': [
|
| 1093 |
+
(r'[^#\\\'"]+', String),
|
| 1094 |
+
# note that all coffee script strings are multi-line.
|
| 1095 |
+
# hashmarks, quotes and backslashes must be parsed one at a time
|
| 1096 |
+
],
|
| 1097 |
+
'interpoling_string': [
|
| 1098 |
+
(r'\}', String.Interpol, "#pop"),
|
| 1099 |
+
include('root')
|
| 1100 |
+
],
|
| 1101 |
+
'dqs': [
|
| 1102 |
+
(r'"', String, '#pop'),
|
| 1103 |
+
(r'\\.|\'', String), # double-quoted string don't need ' escapes
|
| 1104 |
+
(r'#\{', String.Interpol, "interpoling_string"),
|
| 1105 |
+
(r'#', String),
|
| 1106 |
+
include('strings')
|
| 1107 |
+
],
|
| 1108 |
+
'sqs': [
|
| 1109 |
+
(r"'", String, '#pop'),
|
| 1110 |
+
(r'#|\\.|"', String), # single quoted strings don't need " escapses
|
| 1111 |
+
include('strings')
|
| 1112 |
+
],
|
| 1113 |
+
'tdqs': [
|
| 1114 |
+
(r'"""', String, '#pop'),
|
| 1115 |
+
(r'\\.|\'|"', String), # no need to escape quotes in triple-string
|
| 1116 |
+
(r'#\{', String.Interpol, "interpoling_string"),
|
| 1117 |
+
(r'#', String),
|
| 1118 |
+
include('strings'),
|
| 1119 |
+
],
|
| 1120 |
+
'tsqs': [
|
| 1121 |
+
(r"'''", String, '#pop'),
|
| 1122 |
+
(r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
|
| 1123 |
+
include('strings')
|
| 1124 |
+
],
|
| 1125 |
+
}
|
| 1126 |
+
|
| 1127 |
+
|
| 1128 |
+
class MaskLexer(RegexLexer):
|
| 1129 |
+
"""
|
| 1130 |
+
For Mask markup.
|
| 1131 |
+
"""
|
| 1132 |
+
name = 'Mask'
|
| 1133 |
+
url = 'https://github.com/atmajs/MaskJS'
|
| 1134 |
+
aliases = ['mask']
|
| 1135 |
+
filenames = ['*.mask']
|
| 1136 |
+
mimetypes = ['text/x-mask']
|
| 1137 |
+
version_added = '2.0'
|
| 1138 |
+
|
| 1139 |
+
flags = re.MULTILINE | re.IGNORECASE | re.DOTALL
|
| 1140 |
+
tokens = {
|
| 1141 |
+
'root': [
|
| 1142 |
+
(r'\s+', Whitespace),
|
| 1143 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 1144 |
+
(r'/\*.*?\*/', Comment.Multiline),
|
| 1145 |
+
(r'[{};>]', Punctuation),
|
| 1146 |
+
(r"'''", String, 'string-trpl-single'),
|
| 1147 |
+
(r'"""', String, 'string-trpl-double'),
|
| 1148 |
+
(r"'", String, 'string-single'),
|
| 1149 |
+
(r'"', String, 'string-double'),
|
| 1150 |
+
(r'([\w-]+)', Name.Tag, 'node'),
|
| 1151 |
+
(r'([^.#;{>\s]+)', Name.Class, 'node'),
|
| 1152 |
+
(r'(#[\w-]+)', Name.Function, 'node'),
|
| 1153 |
+
(r'(\.[\w-]+)', Name.Variable.Class, 'node')
|
| 1154 |
+
],
|
| 1155 |
+
'string-base': [
|
| 1156 |
+
(r'\\.', String.Escape),
|
| 1157 |
+
(r'~\[', String.Interpol, 'interpolation'),
|
| 1158 |
+
(r'.', String.Single),
|
| 1159 |
+
],
|
| 1160 |
+
'string-single': [
|
| 1161 |
+
(r"'", String.Single, '#pop'),
|
| 1162 |
+
include('string-base')
|
| 1163 |
+
],
|
| 1164 |
+
'string-double': [
|
| 1165 |
+
(r'"', String.Single, '#pop'),
|
| 1166 |
+
include('string-base')
|
| 1167 |
+
],
|
| 1168 |
+
'string-trpl-single': [
|
| 1169 |
+
(r"'''", String.Single, '#pop'),
|
| 1170 |
+
include('string-base')
|
| 1171 |
+
],
|
| 1172 |
+
'string-trpl-double': [
|
| 1173 |
+
(r'"""', String.Single, '#pop'),
|
| 1174 |
+
include('string-base')
|
| 1175 |
+
],
|
| 1176 |
+
'interpolation': [
|
| 1177 |
+
(r'\]', String.Interpol, '#pop'),
|
| 1178 |
+
(r'(\s*)(:)', bygroups(Whitespace, String.Interpol), 'expression'),
|
| 1179 |
+
(r'(\s*)(\w+)(:)', bygroups(Whitespace, Name.Other, Punctuation)),
|
| 1180 |
+
(r'[^\]]+', String.Interpol)
|
| 1181 |
+
],
|
| 1182 |
+
'expression': [
|
| 1183 |
+
(r'[^\]]+', using(JavascriptLexer), '#pop')
|
| 1184 |
+
],
|
| 1185 |
+
'node': [
|
| 1186 |
+
(r'\s+', Whitespace),
|
| 1187 |
+
(r'\.', Name.Variable.Class, 'node-class'),
|
| 1188 |
+
(r'\#', Name.Function, 'node-id'),
|
| 1189 |
+
(r'(style)([ \t]*)(=)',
|
| 1190 |
+
bygroups(Name.Attribute, Whitespace, Operator),
|
| 1191 |
+
'node-attr-style-value'),
|
| 1192 |
+
(r'([\w:-]+)([ \t]*)(=)',
|
| 1193 |
+
bygroups(Name.Attribute, Whitespace, Operator),
|
| 1194 |
+
'node-attr-value'),
|
| 1195 |
+
(r'[\w:-]+', Name.Attribute),
|
| 1196 |
+
(r'[>{;]', Punctuation, '#pop')
|
| 1197 |
+
],
|
| 1198 |
+
'node-class': [
|
| 1199 |
+
(r'[\w-]+', Name.Variable.Class),
|
| 1200 |
+
(r'~\[', String.Interpol, 'interpolation'),
|
| 1201 |
+
default('#pop')
|
| 1202 |
+
],
|
| 1203 |
+
'node-id': [
|
| 1204 |
+
(r'[\w-]+', Name.Function),
|
| 1205 |
+
(r'~\[', String.Interpol, 'interpolation'),
|
| 1206 |
+
default('#pop')
|
| 1207 |
+
],
|
| 1208 |
+
'node-attr-value': [
|
| 1209 |
+
(r'\s+', Whitespace),
|
| 1210 |
+
(r'\w+', Name.Variable, '#pop'),
|
| 1211 |
+
(r"'", String, 'string-single-pop2'),
|
| 1212 |
+
(r'"', String, 'string-double-pop2'),
|
| 1213 |
+
default('#pop')
|
| 1214 |
+
],
|
| 1215 |
+
'node-attr-style-value': [
|
| 1216 |
+
(r'\s+', Whitespace),
|
| 1217 |
+
(r"'", String.Single, 'css-single-end'),
|
| 1218 |
+
(r'"', String.Single, 'css-double-end'),
|
| 1219 |
+
include('node-attr-value')
|
| 1220 |
+
],
|
| 1221 |
+
'css-base': [
|
| 1222 |
+
(r'\s+', Whitespace),
|
| 1223 |
+
(r";", Punctuation),
|
| 1224 |
+
(r"[\w\-]+\s*:", Name.Builtin)
|
| 1225 |
+
],
|
| 1226 |
+
'css-single-end': [
|
| 1227 |
+
include('css-base'),
|
| 1228 |
+
(r"'", String.Single, '#pop:2'),
|
| 1229 |
+
(r"[^;']+", Name.Entity)
|
| 1230 |
+
],
|
| 1231 |
+
'css-double-end': [
|
| 1232 |
+
include('css-base'),
|
| 1233 |
+
(r'"', String.Single, '#pop:2'),
|
| 1234 |
+
(r'[^;"]+', Name.Entity)
|
| 1235 |
+
],
|
| 1236 |
+
'string-single-pop2': [
|
| 1237 |
+
(r"'", String.Single, '#pop:2'),
|
| 1238 |
+
include('string-base')
|
| 1239 |
+
],
|
| 1240 |
+
'string-double-pop2': [
|
| 1241 |
+
(r'"', String.Single, '#pop:2'),
|
| 1242 |
+
include('string-base')
|
| 1243 |
+
],
|
| 1244 |
+
}
|
| 1245 |
+
|
| 1246 |
+
|
| 1247 |
+
class EarlGreyLexer(RegexLexer):
|
| 1248 |
+
"""
|
| 1249 |
+
For Earl-Grey source code.
|
| 1250 |
+
|
| 1251 |
+
.. versionadded: 2.1
|
| 1252 |
+
"""
|
| 1253 |
+
|
| 1254 |
+
name = 'Earl Grey'
|
| 1255 |
+
aliases = ['earl-grey', 'earlgrey', 'eg']
|
| 1256 |
+
filenames = ['*.eg']
|
| 1257 |
+
mimetypes = ['text/x-earl-grey']
|
| 1258 |
+
url = 'https://github.com/breuleux/earl-grey'
|
| 1259 |
+
version_added = ''
|
| 1260 |
+
|
| 1261 |
+
tokens = {
|
| 1262 |
+
'root': [
|
| 1263 |
+
(r'\n', Whitespace),
|
| 1264 |
+
include('control'),
|
| 1265 |
+
(r'[^\S\n]+', Text),
|
| 1266 |
+
(r'(;;.*)(\n)', bygroups(Comment, Whitespace)),
|
| 1267 |
+
(r'[\[\]{}:(),;]', Punctuation),
|
| 1268 |
+
(r'(\\)(\n)', bygroups(String.Escape, Whitespace)),
|
| 1269 |
+
(r'\\', Text),
|
| 1270 |
+
include('errors'),
|
| 1271 |
+
(words((
|
| 1272 |
+
'with', 'where', 'when', 'and', 'not', 'or', 'in',
|
| 1273 |
+
'as', 'of', 'is'),
|
| 1274 |
+
prefix=r'(?<=\s|\[)', suffix=r'(?![\w$\-])'),
|
| 1275 |
+
Operator.Word),
|
| 1276 |
+
(r'[*@]?->', Name.Function),
|
| 1277 |
+
(r'[+\-*/~^<>%&|?!@#.]*=', Operator.Word),
|
| 1278 |
+
(r'\.{2,3}', Operator.Word), # Range Operator
|
| 1279 |
+
(r'([+*/~^<>&|?!]+)|([#\-](?=\s))|@@+(?=\s)|=+', Operator),
|
| 1280 |
+
(r'(?<![\w$\-])(var|let)(?:[^\w$])', Keyword.Declaration),
|
| 1281 |
+
include('keywords'),
|
| 1282 |
+
include('builtins'),
|
| 1283 |
+
include('assignment'),
|
| 1284 |
+
(r'''(?x)
|
| 1285 |
+
(?:()([a-zA-Z$_](?:[\w$\-]*[\w$])?)|
|
| 1286 |
+
(?<=[\s{\[(])(\.)([a-zA-Z$_](?:[\w$\-]*[\w$])?))
|
| 1287 |
+
(?=.*%)''',
|
| 1288 |
+
bygroups(Punctuation, Name.Tag, Punctuation, Name.Class.Start), 'dbs'),
|
| 1289 |
+
(r'[rR]?`', String.Backtick, 'bt'),
|
| 1290 |
+
(r'[rR]?```', String.Backtick, 'tbt'),
|
| 1291 |
+
(r'(?<=[\s\[{(,;])\.([a-zA-Z$_](?:[\w$\-]*[\w$])?)'
|
| 1292 |
+
r'(?=[\s\]}),;])', String.Symbol),
|
| 1293 |
+
include('nested'),
|
| 1294 |
+
(r'(?:[rR]|[rR]\.[gmi]{1,3})?"', String, combined('stringescape', 'dqs')),
|
| 1295 |
+
(r'(?:[rR]|[rR]\.[gmi]{1,3})?\'', String, combined('stringescape', 'sqs')),
|
| 1296 |
+
(r'"""', String, combined('stringescape', 'tdqs')),
|
| 1297 |
+
include('tuple'),
|
| 1298 |
+
include('import_paths'),
|
| 1299 |
+
include('name'),
|
| 1300 |
+
include('numbers'),
|
| 1301 |
+
],
|
| 1302 |
+
'dbs': [
|
| 1303 |
+
(r'(\.)([a-zA-Z$_](?:[\w$\-]*[\w$])?)(?=[.\[\s])',
|
| 1304 |
+
bygroups(Punctuation, Name.Class.DBS)),
|
| 1305 |
+
(r'(\[)([\^#][a-zA-Z$_](?:[\w$\-]*[\w$])?)(\])',
|
| 1306 |
+
bygroups(Punctuation, Name.Entity.DBS, Punctuation)),
|
| 1307 |
+
(r'\s+', Whitespace),
|
| 1308 |
+
(r'%', Operator.DBS, '#pop'),
|
| 1309 |
+
],
|
| 1310 |
+
'import_paths': [
|
| 1311 |
+
(r'(?<=[\s:;,])(\.{1,3}(?:[\w\-]*/)*)(\w(?:[\w\-]*\w)*)(?=[\s;,])',
|
| 1312 |
+
bygroups(Text.Whitespace, Text)),
|
| 1313 |
+
],
|
| 1314 |
+
'assignment': [
|
| 1315 |
+
(r'(\.)?([a-zA-Z$_](?:[\w$\-]*[\w$])?)'
|
| 1316 |
+
r'(?=\s+[+\-*/~^<>%&|?!@#.]*\=\s)',
|
| 1317 |
+
bygroups(Punctuation, Name.Variable))
|
| 1318 |
+
],
|
| 1319 |
+
'errors': [
|
| 1320 |
+
(words(('Error', 'TypeError', 'ReferenceError'),
|
| 1321 |
+
prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$.])'),
|
| 1322 |
+
Name.Exception),
|
| 1323 |
+
(r'''(?x)
|
| 1324 |
+
(?<![\w$])
|
| 1325 |
+
E\.[\w$](?:[\w$\-]*[\w$])?
|
| 1326 |
+
(?:\.[\w$](?:[\w$\-]*[\w$])?)*
|
| 1327 |
+
(?=[({\[?!\s])''',
|
| 1328 |
+
Name.Exception),
|
| 1329 |
+
],
|
| 1330 |
+
'control': [
|
| 1331 |
+
(r'''(?x)
|
| 1332 |
+
([a-zA-Z$_](?:[\w$-]*[\w$])?)
|
| 1333 |
+
(?!\n)\s+
|
| 1334 |
+
(?!and|as|each\*|each|in|is|mod|of|or|when|where|with)
|
| 1335 |
+
(?=(?:[+\-*/~^<>%&|?!@#.])?[a-zA-Z$_](?:[\w$-]*[\w$])?)''',
|
| 1336 |
+
Keyword.Control),
|
| 1337 |
+
(r'([a-zA-Z$_](?:[\w$-]*[\w$])?)(?!\n)(\s+)(?=[\'"\d{\[(])',
|
| 1338 |
+
bygroups(Keyword.Control, Whitespace)),
|
| 1339 |
+
(r'''(?x)
|
| 1340 |
+
(?:
|
| 1341 |
+
(?<=[%=])|
|
| 1342 |
+
(?<=[=\-]>)|
|
| 1343 |
+
(?<=with|each|with)|
|
| 1344 |
+
(?<=each\*|where)
|
| 1345 |
+
)(\s+)
|
| 1346 |
+
([a-zA-Z$_](?:[\w$-]*[\w$])?)(:)''',
|
| 1347 |
+
bygroups(Whitespace, Keyword.Control, Punctuation)),
|
| 1348 |
+
(r'''(?x)
|
| 1349 |
+
(?<![+\-*/~^<>%&|?!@#.])(\s+)
|
| 1350 |
+
([a-zA-Z$_](?:[\w$-]*[\w$])?)(:)''',
|
| 1351 |
+
bygroups(Whitespace, Keyword.Control, Punctuation)),
|
| 1352 |
+
],
|
| 1353 |
+
'nested': [
|
| 1354 |
+
(r'''(?x)
|
| 1355 |
+
(?<=[\w$\]})])(\.)
|
| 1356 |
+
([a-zA-Z$_](?:[\w$-]*[\w$])?)
|
| 1357 |
+
(?=\s+with(?:\s|\n))''',
|
| 1358 |
+
bygroups(Punctuation, Name.Function)),
|
| 1359 |
+
(r'''(?x)
|
| 1360 |
+
(?<!\s)(\.)
|
| 1361 |
+
([a-zA-Z$_](?:[\w$-]*[\w$])?)
|
| 1362 |
+
(?=[}\]).,;:\s])''',
|
| 1363 |
+
bygroups(Punctuation, Name.Field)),
|
| 1364 |
+
(r'''(?x)
|
| 1365 |
+
(?<=[\w$\]})])(\.)
|
| 1366 |
+
([a-zA-Z$_](?:[\w$-]*[\w$])?)
|
| 1367 |
+
(?=[\[{(:])''',
|
| 1368 |
+
bygroups(Punctuation, Name.Function)),
|
| 1369 |
+
],
|
| 1370 |
+
'keywords': [
|
| 1371 |
+
(words((
|
| 1372 |
+
'each', 'each*', 'mod', 'await', 'break', 'chain',
|
| 1373 |
+
'continue', 'elif', 'expr-value', 'if', 'match',
|
| 1374 |
+
'return', 'yield', 'pass', 'else', 'require', 'var',
|
| 1375 |
+
'let', 'async', 'method', 'gen'),
|
| 1376 |
+
prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$.])'),
|
| 1377 |
+
Keyword.Pseudo),
|
| 1378 |
+
(words(('this', 'self', '@'),
|
| 1379 |
+
prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$])'),
|
| 1380 |
+
Keyword.Constant),
|
| 1381 |
+
(words((
|
| 1382 |
+
'Function', 'Object', 'Array', 'String', 'Number',
|
| 1383 |
+
'Boolean', 'ErrorFactory', 'ENode', 'Promise'),
|
| 1384 |
+
prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$])'),
|
| 1385 |
+
Keyword.Type),
|
| 1386 |
+
],
|
| 1387 |
+
'builtins': [
|
| 1388 |
+
(words((
|
| 1389 |
+
'send', 'object', 'keys', 'items', 'enumerate', 'zip',
|
| 1390 |
+
'product', 'neighbours', 'predicate', 'equal',
|
| 1391 |
+
'nequal', 'contains', 'repr', 'clone', 'range',
|
| 1392 |
+
'getChecker', 'get-checker', 'getProperty', 'get-property',
|
| 1393 |
+
'getProjector', 'get-projector', 'consume', 'take',
|
| 1394 |
+
'promisify', 'spawn', 'constructor'),
|
| 1395 |
+
prefix=r'(?<![\w\-#.])', suffix=r'(?![\w\-.])'),
|
| 1396 |
+
Name.Builtin),
|
| 1397 |
+
(words((
|
| 1398 |
+
'true', 'false', 'null', 'undefined'),
|
| 1399 |
+
prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$.])'),
|
| 1400 |
+
Name.Constant),
|
| 1401 |
+
],
|
| 1402 |
+
'name': [
|
| 1403 |
+
(r'@([a-zA-Z$_](?:[\w$-]*[\w$])?)', Name.Variable.Instance),
|
| 1404 |
+
(r'([a-zA-Z$_](?:[\w$-]*[\w$])?)(\+\+|\-\-)?',
|
| 1405 |
+
bygroups(Name.Symbol, Operator.Word))
|
| 1406 |
+
],
|
| 1407 |
+
'tuple': [
|
| 1408 |
+
(r'#[a-zA-Z_][\w\-]*(?=[\s{(,;])', Name.Namespace)
|
| 1409 |
+
],
|
| 1410 |
+
'interpoling_string': [
|
| 1411 |
+
(r'\}', String.Interpol, '#pop'),
|
| 1412 |
+
include('root')
|
| 1413 |
+
],
|
| 1414 |
+
'stringescape': [
|
| 1415 |
+
(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|'
|
| 1416 |
+
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
| 1417 |
+
],
|
| 1418 |
+
'strings': [
|
| 1419 |
+
(r'[^\\\'"]', String),
|
| 1420 |
+
(r'[\'"\\]', String),
|
| 1421 |
+
(r'\n', String) # All strings are multiline in EG
|
| 1422 |
+
],
|
| 1423 |
+
'dqs': [
|
| 1424 |
+
(r'"', String, '#pop'),
|
| 1425 |
+
(r'\\\\|\\"|\\\n', String.Escape),
|
| 1426 |
+
include('strings')
|
| 1427 |
+
],
|
| 1428 |
+
'sqs': [
|
| 1429 |
+
(r"'", String, '#pop'),
|
| 1430 |
+
(r"\\\\|\\'|\\\n", String.Escape),
|
| 1431 |
+
(r'\{', String.Interpol, 'interpoling_string'),
|
| 1432 |
+
include('strings')
|
| 1433 |
+
],
|
| 1434 |
+
'tdqs': [
|
| 1435 |
+
(r'"""', String, '#pop'),
|
| 1436 |
+
include('strings'),
|
| 1437 |
+
],
|
| 1438 |
+
'bt': [
|
| 1439 |
+
(r'`', String.Backtick, '#pop'),
|
| 1440 |
+
(r'(?<!`)\n', String.Backtick),
|
| 1441 |
+
(r'\^=?', String.Escape),
|
| 1442 |
+
(r'.+', String.Backtick),
|
| 1443 |
+
],
|
| 1444 |
+
'tbt': [
|
| 1445 |
+
(r'```', String.Backtick, '#pop'),
|
| 1446 |
+
(r'\n', String.Backtick),
|
| 1447 |
+
(r'\^=?', String.Escape),
|
| 1448 |
+
(r'[^`]+', String.Backtick),
|
| 1449 |
+
],
|
| 1450 |
+
'numbers': [
|
| 1451 |
+
(r'\d+\.(?!\.)\d*([eE][+-]?[0-9]+)?', Number.Float),
|
| 1452 |
+
(r'\d+[eE][+-]?[0-9]+', Number.Float),
|
| 1453 |
+
(r'8r[0-7]+', Number.Oct),
|
| 1454 |
+
(r'2r[01]+', Number.Bin),
|
| 1455 |
+
(r'16r[a-fA-F0-9]+', Number.Hex),
|
| 1456 |
+
(r'([3-79]|[12][0-9]|3[0-6])r[a-zA-Z\d]+(\.[a-zA-Z\d]+)?',
|
| 1457 |
+
Number.Radix),
|
| 1458 |
+
(r'\d+', Number.Integer)
|
| 1459 |
+
],
|
| 1460 |
+
}
|
| 1461 |
+
|
| 1462 |
+
|
| 1463 |
+
class JuttleLexer(RegexLexer):
|
| 1464 |
+
"""
|
| 1465 |
+
For Juttle source code.
|
| 1466 |
+
"""
|
| 1467 |
+
|
| 1468 |
+
name = 'Juttle'
|
| 1469 |
+
url = 'http://juttle.github.io/'
|
| 1470 |
+
aliases = ['juttle']
|
| 1471 |
+
filenames = ['*.juttle']
|
| 1472 |
+
mimetypes = ['application/juttle', 'application/x-juttle',
|
| 1473 |
+
'text/x-juttle', 'text/juttle']
|
| 1474 |
+
version_added = '2.2'
|
| 1475 |
+
|
| 1476 |
+
flags = re.DOTALL | re.MULTILINE
|
| 1477 |
+
|
| 1478 |
+
tokens = {
|
| 1479 |
+
'commentsandwhitespace': [
|
| 1480 |
+
(r'\s+', Whitespace),
|
| 1481 |
+
(r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
|
| 1482 |
+
(r'/\*.*?\*/', Comment.Multiline)
|
| 1483 |
+
],
|
| 1484 |
+
'slashstartsregex': [
|
| 1485 |
+
include('commentsandwhitespace'),
|
| 1486 |
+
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
| 1487 |
+
r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
|
| 1488 |
+
(r'(?=/)', Text, ('#pop', 'badregex')),
|
| 1489 |
+
default('#pop')
|
| 1490 |
+
],
|
| 1491 |
+
'badregex': [
|
| 1492 |
+
(r'\n', Text, '#pop')
|
| 1493 |
+
],
|
| 1494 |
+
'root': [
|
| 1495 |
+
(r'^(?=\s|/)', Text, 'slashstartsregex'),
|
| 1496 |
+
include('commentsandwhitespace'),
|
| 1497 |
+
(r':\d{2}:\d{2}:\d{2}(\.\d*)?:', String.Moment),
|
| 1498 |
+
(r':(now|beginning|end|forever|yesterday|today|tomorrow|'
|
| 1499 |
+
r'(\d+(\.\d*)?|\.\d+)(ms|[smhdwMy])?):', String.Moment),
|
| 1500 |
+
(r':\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d*)?)?'
|
| 1501 |
+
r'(Z|[+-]\d{2}:\d{2}|[+-]\d{4})?:', String.Moment),
|
| 1502 |
+
(r':((\d+(\.\d*)?|\.\d+)[ ]+)?(millisecond|second|minute|hour|'
|
| 1503 |
+
r'day|week|month|year)[s]?'
|
| 1504 |
+
r'(([ ]+and[ ]+(\d+[ ]+)?(millisecond|second|minute|hour|'
|
| 1505 |
+
r'day|week|month|year)[s]?)'
|
| 1506 |
+
r'|[ ]+(ago|from[ ]+now))*:', String.Moment),
|
| 1507 |
+
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
|
| 1508 |
+
r'(==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
|
| 1509 |
+
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
| 1510 |
+
(r'[})\].]', Punctuation),
|
| 1511 |
+
(r'(import|return|continue|if|else)\b', Keyword, 'slashstartsregex'),
|
| 1512 |
+
(r'(var|const|function|reducer|sub|input)\b', Keyword.Declaration,
|
| 1513 |
+
'slashstartsregex'),
|
| 1514 |
+
(r'(batch|emit|filter|head|join|keep|pace|pass|put|read|reduce|remove|'
|
| 1515 |
+
r'sequence|skip|sort|split|tail|unbatch|uniq|view|write)\b',
|
| 1516 |
+
Keyword.Reserved),
|
| 1517 |
+
(r'(true|false|null|Infinity)\b', Keyword.Constant),
|
| 1518 |
+
(r'(Array|Date|Juttle|Math|Number|Object|RegExp|String)\b',
|
| 1519 |
+
Name.Builtin),
|
| 1520 |
+
(JS_IDENT, Name.Other),
|
| 1521 |
+
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
| 1522 |
+
(r'[0-9]+', Number.Integer),
|
| 1523 |
+
(r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
|
| 1524 |
+
(r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
|
| 1525 |
+
]
|
| 1526 |
+
|
| 1527 |
+
}
|
| 1528 |
+
|
| 1529 |
+
|
| 1530 |
+
class NodeConsoleLexer(Lexer):
|
| 1531 |
+
"""
|
| 1532 |
+
For parsing within an interactive Node.js REPL, such as:
|
| 1533 |
+
|
| 1534 |
+
.. sourcecode:: nodejsrepl
|
| 1535 |
+
|
| 1536 |
+
> let a = 3
|
| 1537 |
+
undefined
|
| 1538 |
+
> a
|
| 1539 |
+
3
|
| 1540 |
+
> let b = '4'
|
| 1541 |
+
undefined
|
| 1542 |
+
> b
|
| 1543 |
+
'4'
|
| 1544 |
+
> b == a
|
| 1545 |
+
false
|
| 1546 |
+
|
| 1547 |
+
.. versionadded: 2.10
|
| 1548 |
+
"""
|
| 1549 |
+
name = 'Node.js REPL console session'
|
| 1550 |
+
aliases = ['nodejsrepl', ]
|
| 1551 |
+
mimetypes = ['text/x-nodejsrepl', ]
|
| 1552 |
+
url = 'https://nodejs.org'
|
| 1553 |
+
version_added = ''
|
| 1554 |
+
|
| 1555 |
+
def get_tokens_unprocessed(self, text):
|
| 1556 |
+
jslexer = JavascriptLexer(**self.options)
|
| 1557 |
+
|
| 1558 |
+
curcode = ''
|
| 1559 |
+
insertions = []
|
| 1560 |
+
|
| 1561 |
+
for match in line_re.finditer(text):
|
| 1562 |
+
line = match.group()
|
| 1563 |
+
if line.startswith('> '):
|
| 1564 |
+
insertions.append((len(curcode),
|
| 1565 |
+
[(0, Generic.Prompt, line[:1]),
|
| 1566 |
+
(1, Whitespace, line[1:2])]))
|
| 1567 |
+
|
| 1568 |
+
curcode += line[2:]
|
| 1569 |
+
elif line.startswith('...'):
|
| 1570 |
+
# node does a nested ... thing depending on depth
|
| 1571 |
+
code = line.lstrip('.')
|
| 1572 |
+
lead = len(line) - len(code)
|
| 1573 |
+
|
| 1574 |
+
insertions.append((len(curcode),
|
| 1575 |
+
[(0, Generic.Prompt, line[:lead])]))
|
| 1576 |
+
|
| 1577 |
+
curcode += code
|
| 1578 |
+
else:
|
| 1579 |
+
if curcode:
|
| 1580 |
+
yield from do_insertions(insertions,
|
| 1581 |
+
jslexer.get_tokens_unprocessed(curcode))
|
| 1582 |
+
|
| 1583 |
+
curcode = ''
|
| 1584 |
+
insertions = []
|
| 1585 |
+
|
| 1586 |
+
yield from do_insertions([],
|
| 1587 |
+
jslexer.get_tokens_unprocessed(line))
|
| 1588 |
+
|
| 1589 |
+
if curcode:
|
| 1590 |
+
yield from do_insertions(insertions,
|
| 1591 |
+
jslexer.get_tokens_unprocessed(curcode))
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/jmespath.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.jmespath
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the JMESPath language
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, bygroups, include
|
| 12 |
+
from pygments.token import String, Punctuation, Whitespace, Name, Operator, \
|
| 13 |
+
Number, Literal, Keyword
|
| 14 |
+
|
| 15 |
+
__all__ = ['JMESPathLexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class JMESPathLexer(RegexLexer):
|
| 19 |
+
"""
|
| 20 |
+
For JMESPath queries.
|
| 21 |
+
"""
|
| 22 |
+
name = 'JMESPath'
|
| 23 |
+
url = 'https://jmespath.org'
|
| 24 |
+
filenames = ['*.jp']
|
| 25 |
+
aliases = ['jmespath', 'jp']
|
| 26 |
+
version_added = ''
|
| 27 |
+
|
| 28 |
+
tokens = {
|
| 29 |
+
'string': [
|
| 30 |
+
(r"'(\\(.|\n)|[^'\\])*'", String),
|
| 31 |
+
],
|
| 32 |
+
'punctuation': [
|
| 33 |
+
(r'(\[\?|[\.\*\[\],:\(\)\{\}\|])', Punctuation),
|
| 34 |
+
],
|
| 35 |
+
'ws': [
|
| 36 |
+
(r" |\t|\n|\r", Whitespace)
|
| 37 |
+
],
|
| 38 |
+
"dq-identifier": [
|
| 39 |
+
(r'[^\\"]+', Name.Variable),
|
| 40 |
+
(r'\\"', Name.Variable),
|
| 41 |
+
(r'.', Punctuation, '#pop'),
|
| 42 |
+
],
|
| 43 |
+
'identifier': [
|
| 44 |
+
(r'(&)?(")', bygroups(Name.Variable, Punctuation), 'dq-identifier'),
|
| 45 |
+
(r'(")?(&?[A-Za-z][A-Za-z0-9_-]*)(")?', bygroups(Punctuation, Name.Variable, Punctuation)),
|
| 46 |
+
],
|
| 47 |
+
'root': [
|
| 48 |
+
include('ws'),
|
| 49 |
+
include('string'),
|
| 50 |
+
(r'(==|!=|<=|>=|<|>|&&|\|\||!)', Operator),
|
| 51 |
+
include('punctuation'),
|
| 52 |
+
(r'@', Name.Variable.Global),
|
| 53 |
+
(r'(&?[A-Za-z][A-Za-z0-9_]*)(\()', bygroups(Name.Function, Punctuation)),
|
| 54 |
+
(r'(&)(\()', bygroups(Name.Variable, Punctuation)),
|
| 55 |
+
include('identifier'),
|
| 56 |
+
(r'-?\d+', Number),
|
| 57 |
+
(r'`', Literal, 'literal'),
|
| 58 |
+
],
|
| 59 |
+
'literal': [
|
| 60 |
+
include('ws'),
|
| 61 |
+
include('string'),
|
| 62 |
+
include('punctuation'),
|
| 63 |
+
(r'(false|true|null)\b', Keyword.Constant),
|
| 64 |
+
include('identifier'),
|
| 65 |
+
(r'-?\d+\.?\d*([eE][-+]\d+)?', Number),
|
| 66 |
+
(r'\\`', Literal),
|
| 67 |
+
(r'`', Literal, '#pop'),
|
| 68 |
+
]
|
| 69 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/jslt.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.jslt
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexers for the JSLT language
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import RegexLexer, combined, words
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, String, Whitespace
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
__all__ = ['JSLTLexer']
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
_WORD_END = r'(?=[^0-9A-Z_a-z-])'
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class JSLTLexer(RegexLexer):
|
| 23 |
+
"""
|
| 24 |
+
For JSLT source.
|
| 25 |
+
"""
|
| 26 |
+
name = 'JSLT'
|
| 27 |
+
url = 'https://github.com/schibsted/jslt'
|
| 28 |
+
filenames = ['*.jslt']
|
| 29 |
+
aliases = ['jslt']
|
| 30 |
+
mimetypes = ['text/x-jslt']
|
| 31 |
+
version_added = '2.10'
|
| 32 |
+
|
| 33 |
+
tokens = {
|
| 34 |
+
'root': [
|
| 35 |
+
(r'[\t\n\f\r ]+', Whitespace),
|
| 36 |
+
(r'//.*(\n|\Z)', Comment.Single),
|
| 37 |
+
(r'-?(0|[1-9][0-9]*)', Number.Integer),
|
| 38 |
+
(r'-?(0|[1-9][0-9]*)(.[0-9]+a)?([Ee][+-]?[0-9]+)', Number.Float),
|
| 39 |
+
(r'"([^"\\]|\\.)*"', String.Double),
|
| 40 |
+
(r'[(),:\[\]{}]', Punctuation),
|
| 41 |
+
(r'(!=|[<=>]=?)', Operator),
|
| 42 |
+
(r'[*+/|-]', Operator),
|
| 43 |
+
(r'\.', Operator),
|
| 44 |
+
(words(('import',), suffix=_WORD_END), Keyword.Namespace, combined('import-path', 'whitespace')),
|
| 45 |
+
(words(('as',), suffix=_WORD_END), Keyword.Namespace, combined('import-alias', 'whitespace')),
|
| 46 |
+
(words(('let',), suffix=_WORD_END), Keyword.Declaration, combined('constant', 'whitespace')),
|
| 47 |
+
(words(('def',), suffix=_WORD_END), Keyword.Declaration, combined('function', 'whitespace')),
|
| 48 |
+
(words(('false', 'null', 'true'), suffix=_WORD_END), Keyword.Constant),
|
| 49 |
+
(words(('else', 'for', 'if'), suffix=_WORD_END), Keyword),
|
| 50 |
+
(words(('and', 'or'), suffix=_WORD_END), Operator.Word),
|
| 51 |
+
(words((
|
| 52 |
+
'all', 'any', 'array', 'boolean', 'capture', 'ceiling',
|
| 53 |
+
'contains', 'ends-with', 'error', 'flatten', 'floor',
|
| 54 |
+
'format-time', 'from-json', 'get-key', 'hash-int', 'index-of',
|
| 55 |
+
'is-array', 'is-boolean', 'is-decimal', 'is-integer',
|
| 56 |
+
'is-number', 'is-object', 'is-string', 'join', 'lowercase',
|
| 57 |
+
'max', 'min', 'mod', 'not', 'now', 'number', 'parse-time',
|
| 58 |
+
'parse-url', 'random', 'replace', 'round', 'sha256-hex', 'size',
|
| 59 |
+
'split', 'starts-with', 'string', 'sum', 'test', 'to-json',
|
| 60 |
+
'trim', 'uppercase', 'zip', 'zip-with-index', 'fallback'), suffix=_WORD_END),
|
| 61 |
+
Name.Builtin),
|
| 62 |
+
(r'[A-Z_a-z][0-9A-Z_a-z-]*:[A-Z_a-z][0-9A-Z_a-z-]*', Name.Function),
|
| 63 |
+
(r'[A-Z_a-z][0-9A-Z_a-z-]*', Name),
|
| 64 |
+
(r'\$[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable),
|
| 65 |
+
],
|
| 66 |
+
'constant': [
|
| 67 |
+
(r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable, 'root'),
|
| 68 |
+
],
|
| 69 |
+
'function': [
|
| 70 |
+
(r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Function, combined('function-parameter-list', 'whitespace')),
|
| 71 |
+
],
|
| 72 |
+
'function-parameter-list': [
|
| 73 |
+
(r'\(', Punctuation, combined('function-parameters', 'whitespace')),
|
| 74 |
+
],
|
| 75 |
+
'function-parameters': [
|
| 76 |
+
(r',', Punctuation),
|
| 77 |
+
(r'\)', Punctuation, 'root'),
|
| 78 |
+
(r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable),
|
| 79 |
+
],
|
| 80 |
+
'import-path': [
|
| 81 |
+
(r'"([^"]|\\.)*"', String.Symbol, 'root'),
|
| 82 |
+
],
|
| 83 |
+
'import-alias': [
|
| 84 |
+
(r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Namespace, 'root'),
|
| 85 |
+
],
|
| 86 |
+
'string': [
|
| 87 |
+
(r'"', String.Double, '#pop'),
|
| 88 |
+
(r'\\.', String.Escape),
|
| 89 |
+
],
|
| 90 |
+
'whitespace': [
|
| 91 |
+
(r'[\t\n\f\r ]+', Whitespace),
|
| 92 |
+
(r'//.*(\n|\Z)', Comment.Single),
|
| 93 |
+
]
|
| 94 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/json5.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.lexers.json5
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Lexer for Json5 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 include, RegexLexer, words
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Punctuation, \
|
| 13 |
+
String, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['Json5Lexer']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def string_rules(quote_mark):
|
| 19 |
+
return [
|
| 20 |
+
(rf"[^{quote_mark}\\]+", String),
|
| 21 |
+
(r"\\.", String.Escape),
|
| 22 |
+
(r"\\", Punctuation),
|
| 23 |
+
(quote_mark, String, '#pop'),
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def quoted_field_name(quote_mark):
|
| 28 |
+
return [
|
| 29 |
+
(rf'([^{quote_mark}\\]|\\.)*{quote_mark}',
|
| 30 |
+
Name.Variable, ('#pop', 'object_value'))
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class Json5Lexer(RegexLexer):
|
| 35 |
+
"""Lexer for JSON5 data structures."""
|
| 36 |
+
|
| 37 |
+
name = 'JSON5'
|
| 38 |
+
aliases = ['json5']
|
| 39 |
+
filenames = ['*.json5']
|
| 40 |
+
url = "https://json5.org"
|
| 41 |
+
version_added = '2.19'
|
| 42 |
+
tokens = {
|
| 43 |
+
'_comments': [
|
| 44 |
+
(r'(//|#).*\n', Comment.Single),
|
| 45 |
+
(r'/\*\*([^/]|/(?!\*))*\*/', String.Doc),
|
| 46 |
+
(r'/\*([^/]|/(?!\*))*\*/', Comment),
|
| 47 |
+
],
|
| 48 |
+
'root': [
|
| 49 |
+
include('_comments'),
|
| 50 |
+
(r"'", String, 'singlestring'),
|
| 51 |
+
(r'"', String, 'doublestring'),
|
| 52 |
+
(r'[+-]?0[xX][0-9a-fA-F]+', Number.Hex),
|
| 53 |
+
(r'[+-.]?[0-9]+[.]?[0-9]?([eE][-]?[0-9]+)?', Number.Float),
|
| 54 |
+
(r'\{', Punctuation, 'object'),
|
| 55 |
+
(r'\[', Punctuation, 'array'),
|
| 56 |
+
(words(['false', 'Infinity', '+Infinity', '-Infinity', 'NaN',
|
| 57 |
+
'null', 'true',], suffix=r'\b'), Keyword),
|
| 58 |
+
(r'\s+', Whitespace),
|
| 59 |
+
(r':', Punctuation),
|
| 60 |
+
],
|
| 61 |
+
'singlestring': string_rules("'"),
|
| 62 |
+
'doublestring': string_rules('"'),
|
| 63 |
+
'array': [
|
| 64 |
+
(r',', Punctuation),
|
| 65 |
+
(r'\]', Punctuation, '#pop'),
|
| 66 |
+
include('root'),
|
| 67 |
+
],
|
| 68 |
+
'object': [
|
| 69 |
+
(r'\s+', Whitespace),
|
| 70 |
+
(r'\}', Punctuation, '#pop'),
|
| 71 |
+
(r'\b([^:]+)', Name.Variable, 'object_value'),
|
| 72 |
+
(r'"', Name.Variable, 'double_field_name'),
|
| 73 |
+
(r"'", Name.Variable, 'single_field_name'),
|
| 74 |
+
include('_comments'),
|
| 75 |
+
],
|
| 76 |
+
'double_field_name': quoted_field_name('"'),
|
| 77 |
+
'single_field_name': quoted_field_name("'"),
|
| 78 |
+
'object_value': [
|
| 79 |
+
(r',', Punctuation, '#pop'),
|
| 80 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 81 |
+
include('root'),
|
| 82 |
+
],
|
| 83 |
+
}
|
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/jsonnet.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pygments.lexer import include, RegexLexer, words
|
| 12 |
+
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
| 13 |
+
Punctuation, String, Text, Whitespace
|
| 14 |
+
|
| 15 |
+
__all__ = ['JsonnetLexer']
|
| 16 |
+
|
| 17 |
+
jsonnet_token = r'[^\W\d]\w*'
|
| 18 |
+
jsonnet_function_token = jsonnet_token + r'(?=\()'
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def string_rules(quote_mark):
|
| 22 |
+
return [
|
| 23 |
+
(rf"[^{quote_mark}\\]", String),
|
| 24 |
+
(r"\\.", String.Escape),
|
| 25 |
+
(quote_mark, String, '#pop'),
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def quoted_field_name(quote_mark):
|
| 30 |
+
return [
|
| 31 |
+
(rf'([^{quote_mark}\\]|\\.)*{quote_mark}',
|
| 32 |
+
Name.Variable, 'field_separator')
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class JsonnetLexer(RegexLexer):
|
| 37 |
+
"""Lexer for Jsonnet source code."""
|
| 38 |
+
|
| 39 |
+
name = 'Jsonnet'
|
| 40 |
+
aliases = ['jsonnet']
|
| 41 |
+
filenames = ['*.jsonnet', '*.libsonnet']
|
| 42 |
+
url = "https://jsonnet.org"
|
| 43 |
+
version_added = ''
|
| 44 |
+
tokens = {
|
| 45 |
+
# Not used by itself
|
| 46 |
+
'_comments': [
|
| 47 |
+
(r'(//|#).*\n', Comment.Single),
|
| 48 |
+
(r'/\*\*([^/]|/(?!\*))*\*/', String.Doc),
|
| 49 |
+
(r'/\*([^/]|/(?!\*))*\*/', Comment),
|
| 50 |
+
],
|
| 51 |
+
'root': [
|
| 52 |
+
include('_comments'),
|
| 53 |
+
(r"@'.*'", String),
|
| 54 |
+
(r'@".*"', String),
|
| 55 |
+
(r"'", String, 'singlestring'),
|
| 56 |
+
(r'"', String, 'doublestring'),
|
| 57 |
+
(r'\|\|\|(.|\n)*\|\|\|', String),
|
| 58 |
+
# Jsonnet has no integers, only an IEEE754 64-bit float
|
| 59 |
+
(r'[+-]?[0-9]+(.[0-9])?', Number.Float),
|
| 60 |
+
# Omit : despite spec because it appears to be used as a field
|
| 61 |
+
# separator
|
| 62 |
+
(r'[!$~+\-&|^=<>*/%]', Operator),
|
| 63 |
+
(r'\{', Punctuation, 'object'),
|
| 64 |
+
(r'\[', Punctuation, 'array'),
|
| 65 |
+
(r'local\b', Keyword, ('local_name')),
|
| 66 |
+
(r'assert\b', Keyword, 'assert'),
|
| 67 |
+
(words([
|
| 68 |
+
'assert', 'else', 'error', 'false', 'for', 'if', 'import',
|
| 69 |
+
'importstr', 'in', 'null', 'tailstrict', 'then', 'self',
|
| 70 |
+
'super', 'true',
|
| 71 |
+
], suffix=r'\b'), Keyword),
|
| 72 |
+
(r'\s+', Whitespace),
|
| 73 |
+
(r'function(?=\()', Keyword, 'function_params'),
|
| 74 |
+
(r'std\.' + jsonnet_function_token, Name.Builtin, 'function_args'),
|
| 75 |
+
(jsonnet_function_token, Name.Function, 'function_args'),
|
| 76 |
+
(jsonnet_token, Name.Variable),
|
| 77 |
+
(r'[\.()]', Punctuation),
|
| 78 |
+
],
|
| 79 |
+
'singlestring': string_rules("'"),
|
| 80 |
+
'doublestring': string_rules('"'),
|
| 81 |
+
'array': [
|
| 82 |
+
(r',', Punctuation),
|
| 83 |
+
(r'\]', Punctuation, '#pop'),
|
| 84 |
+
include('root'),
|
| 85 |
+
],
|
| 86 |
+
'local_name': [
|
| 87 |
+
(jsonnet_function_token, Name.Function, 'function_params'),
|
| 88 |
+
(jsonnet_token, Name.Variable),
|
| 89 |
+
(r'\s+', Whitespace),
|
| 90 |
+
('(?==)', Whitespace, ('#pop', 'local_value')),
|
| 91 |
+
],
|
| 92 |
+
'local_value': [
|
| 93 |
+
(r'=', Operator),
|
| 94 |
+
(r';', Punctuation, '#pop'),
|
| 95 |
+
include('root'),
|
| 96 |
+
],
|
| 97 |
+
'assert': [
|
| 98 |
+
(r':', Punctuation),
|
| 99 |
+
(r';', Punctuation, '#pop'),
|
| 100 |
+
include('root'),
|
| 101 |
+
],
|
| 102 |
+
'function_params': [
|
| 103 |
+
(jsonnet_token, Name.Variable),
|
| 104 |
+
(r'\(', Punctuation),
|
| 105 |
+
(r'\)', Punctuation, '#pop'),
|
| 106 |
+
(r',', Punctuation),
|
| 107 |
+
(r'\s+', Whitespace),
|
| 108 |
+
(r'=', Operator, 'function_param_default'),
|
| 109 |
+
],
|
| 110 |
+
'function_args': [
|
| 111 |
+
(r'\(', Punctuation),
|
| 112 |
+
(r'\)', Punctuation, '#pop'),
|
| 113 |
+
(r',', Punctuation),
|
| 114 |
+
(r'\s+', Whitespace),
|
| 115 |
+
include('root'),
|
| 116 |
+
],
|
| 117 |
+
'object': [
|
| 118 |
+
(r'\s+', Whitespace),
|
| 119 |
+
(r'local\b', Keyword, 'object_local_name'),
|
| 120 |
+
(r'assert\b', Keyword, 'object_assert'),
|
| 121 |
+
(r'\[', Operator, 'field_name_expr'),
|
| 122 |
+
(fr'(?={jsonnet_token})', Text, 'field_name'),
|
| 123 |
+
(r'\}', Punctuation, '#pop'),
|
| 124 |
+
(r'"', Name.Variable, 'double_field_name'),
|
| 125 |
+
(r"'", Name.Variable, 'single_field_name'),
|
| 126 |
+
include('_comments'),
|
| 127 |
+
],
|
| 128 |
+
'field_name': [
|
| 129 |
+
(jsonnet_function_token, Name.Function,
|
| 130 |
+
('field_separator', 'function_params')
|
| 131 |
+
),
|
| 132 |
+
(jsonnet_token, Name.Variable, 'field_separator'),
|
| 133 |
+
],
|
| 134 |
+
'double_field_name': quoted_field_name('"'),
|
| 135 |
+
'single_field_name': quoted_field_name("'"),
|
| 136 |
+
'field_name_expr': [
|
| 137 |
+
(r'\]', Operator, 'field_separator'),
|
| 138 |
+
include('root'),
|
| 139 |
+
],
|
| 140 |
+
'function_param_default': [
|
| 141 |
+
(r'(?=[,\)])', Whitespace, '#pop'),
|
| 142 |
+
include('root'),
|
| 143 |
+
],
|
| 144 |
+
'field_separator': [
|
| 145 |
+
(r'\s+', Whitespace),
|
| 146 |
+
(r'\+?::?:?', Punctuation, ('#pop', '#pop', 'field_value')),
|
| 147 |
+
include('_comments'),
|
| 148 |
+
],
|
| 149 |
+
'field_value': [
|
| 150 |
+
(r',', Punctuation, '#pop'),
|
| 151 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 152 |
+
include('root'),
|
| 153 |
+
],
|
| 154 |
+
'object_assert': [
|
| 155 |
+
(r':', Punctuation),
|
| 156 |
+
(r',', Punctuation, '#pop'),
|
| 157 |
+
include('root'),
|
| 158 |
+
],
|
| 159 |
+
'object_local_name': [
|
| 160 |
+
(jsonnet_token, Name.Variable, ('#pop', 'object_local_value')),
|
| 161 |
+
(r'\s+', Whitespace),
|
| 162 |
+
],
|
| 163 |
+
'object_local_value': [
|
| 164 |
+
(r'=', Operator),
|
| 165 |
+
(r',', Punctuation, '#pop'),
|
| 166 |
+
(r'\}', Punctuation, '#pop:2'),
|
| 167 |
+
include('root'),
|
| 168 |
+
],
|
| 169 |
+
}
|