f20080305d
Определение специфических рекомендаций (матрица профилей §8):
1. Ж/д слой (закрыт мёртвый railway ×2.5 у РАС):
- /api/v1/water/{case_id} отдаёт railway=rail как LineString
(без service/industrial/military веток), кэш общий v2;
- railway_warning «перекрыть/проверить немедленно» по профилям;
- SearchMap: Polyline слой ж/д (тёмно-красный), счётчики 💧/🚂.
2. cant_swim → профиль не_умеет_плавать (water ×3.0, без изменения
радиуса, critical_warning «обследовать водоёмы НЕМЕДЛЕННО»):
- раньше чекбокс влиял только на текст, в скоринге был пробел;
- derive в analyze._derive_profiles — работает и для closed_cases.
3. unmodeled_profiles: ДЦП/слабое зрение/слух — честная пометка
«вне поведенческой модели» с пояснением (vector_tasks B12:
профили без аналога не выдавать за учтённые); блок на фронте
в карточке здоровья.
Площадь воды: сферический эксцесс, проверен на квадрате 53° (744017 м²
vs 743272 точного). Тесты: 202 passed (новый test_cant_swim_profile).
88 lines
3.1 KiB
Python
88 lines
3.1 KiB
Python
"""
|
|
pygments.lexers.solidity
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Lexers for Solidity.
|
|
|
|
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
|
:license: BSD, see LICENSE for details.
|
|
"""
|
|
|
|
from pygments.lexer import RegexLexer, bygroups, include, words
|
|
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
|
Number, Punctuation, Whitespace
|
|
|
|
__all__ = ['SolidityLexer']
|
|
|
|
|
|
class SolidityLexer(RegexLexer):
|
|
"""
|
|
For Solidity source code.
|
|
"""
|
|
|
|
name = 'Solidity'
|
|
aliases = ['solidity']
|
|
filenames = ['*.sol']
|
|
mimetypes = []
|
|
url = 'https://soliditylang.org'
|
|
version_added = '2.5'
|
|
|
|
datatype = (
|
|
r'\b(address|bool|(?:(?:bytes|hash|int|string|uint)(?:8|16|24|32|40|48|56|64'
|
|
r'|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208'
|
|
r'|216|224|232|240|248|256)?))\b'
|
|
)
|
|
|
|
tokens = {
|
|
'root': [
|
|
include('whitespace'),
|
|
include('comments'),
|
|
(r'\bpragma\s+solidity\b', Keyword, 'pragma'),
|
|
(r'\b(contract)(\s+)([a-zA-Z_]\w*)',
|
|
bygroups(Keyword, Whitespace, Name.Entity)),
|
|
(datatype + r'(\s+)((?:external|public|internal|private)\s+)?' +
|
|
r'([a-zA-Z_]\w*)',
|
|
bygroups(Keyword.Type, Whitespace, Keyword, Name.Variable)),
|
|
(r'\b(enum|event|function|struct)(\s+)([a-zA-Z_]\w*)',
|
|
bygroups(Keyword.Type, Whitespace, Name.Variable)),
|
|
(r'\b(msg|block|tx)\.([A-Za-z_][a-zA-Z0-9_]*)\b', Keyword),
|
|
(words((
|
|
'block', 'break', 'constant', 'constructor', 'continue',
|
|
'contract', 'do', 'else', 'external', 'false', 'for',
|
|
'function', 'if', 'import', 'inherited', 'internal', 'is',
|
|
'library', 'mapping', 'memory', 'modifier', 'msg', 'new',
|
|
'payable', 'private', 'public', 'require', 'return',
|
|
'returns', 'struct', 'suicide', 'throw', 'this', 'true',
|
|
'tx', 'var', 'while'), prefix=r'\b', suffix=r'\b'),
|
|
Keyword.Type),
|
|
(words(('keccak256',), prefix=r'\b', suffix=r'\b'), Name.Builtin),
|
|
(datatype, Keyword.Type),
|
|
include('constants'),
|
|
(r'[a-zA-Z_]\w*', Text),
|
|
(r'[~!%^&*+=|?:<>/-]', Operator),
|
|
(r'[.;{}(),\[\]]', Punctuation)
|
|
],
|
|
'comments': [
|
|
(r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single),
|
|
(r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline),
|
|
(r'/(\\\n)?[*][\w\W]*', Comment.Multiline)
|
|
],
|
|
'constants': [
|
|
(r'("(\\"|.)*?")', String.Double),
|
|
(r"('(\\'|.)*?')", String.Single),
|
|
(r'\b0[xX][0-9a-fA-F]+\b', Number.Hex),
|
|
(r'\b\d+\b', Number.Decimal),
|
|
],
|
|
'pragma': [
|
|
include('whitespace'),
|
|
include('comments'),
|
|
(r'(\^|>=|<)(\s*)(\d+\.\d+\.\d+)',
|
|
bygroups(Operator, Whitespace, Keyword)),
|
|
(r';', Punctuation, '#pop')
|
|
],
|
|
'whitespace': [
|
|
(r'\s+', Whitespace),
|
|
(r'\n', Whitespace)
|
|
]
|
|
}
|