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).
121 lines
4.7 KiB
Python
121 lines
4.7 KiB
Python
"""
|
|
pygments.lexers.devicetree
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Lexers for Devicetree language.
|
|
|
|
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
|
:license: BSD, see LICENSE for details.
|
|
"""
|
|
|
|
from pygments.lexer import RegexLexer, bygroups, include, default, words
|
|
from pygments.token import Comment, Keyword, Name, Number, Operator, \
|
|
Punctuation, String, Text, Whitespace
|
|
|
|
__all__ = ['DevicetreeLexer']
|
|
|
|
|
|
class DevicetreeLexer(RegexLexer):
|
|
"""
|
|
Lexer for Devicetree files.
|
|
"""
|
|
|
|
name = 'Devicetree'
|
|
url = 'https://www.devicetree.org/'
|
|
aliases = ['devicetree', 'dts']
|
|
filenames = ['*.dts', '*.dtsi']
|
|
mimetypes = ['text/x-c']
|
|
version_added = '2.7'
|
|
|
|
#: optional Whitespace or /*...*/ style comment
|
|
_ws = r'\s*(?:/[*][^*/]*?[*]/\s*)*'
|
|
|
|
tokens = {
|
|
'macro': [
|
|
# Include preprocessor directives (C style):
|
|
(r'(#include)(' + _ws + r')([^\n]+)',
|
|
bygroups(Comment.Preproc, Comment.Multiline, Comment.PreprocFile)),
|
|
# Define preprocessor directives (C style):
|
|
(r'(#define)(' + _ws + r')([^\n]+)',
|
|
bygroups(Comment.Preproc, Comment.Multiline, Comment.Preproc)),
|
|
# devicetree style with file:
|
|
(r'(/[^*/{]+/)(' + _ws + r')("[^\n{]+")',
|
|
bygroups(Comment.Preproc, Comment.Multiline, Comment.PreprocFile)),
|
|
# devicetree style with property:
|
|
(r'(/[^*/{]+/)(' + _ws + r')([^\n;{]*)([;]?)',
|
|
bygroups(Comment.Preproc, Comment.Multiline, Comment.Preproc, Punctuation)),
|
|
],
|
|
'whitespace': [
|
|
(r'\n', Whitespace),
|
|
(r'\s+', Whitespace),
|
|
(r'\\\n', Text), # line continuation
|
|
(r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single),
|
|
(r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline),
|
|
# Open until EOF, so no ending delimiter
|
|
(r'/(\\\n)?[*][\w\W]*', Comment.Multiline),
|
|
],
|
|
'statements': [
|
|
(r'(L?)(")', bygroups(String.Affix, String), 'string'),
|
|
(r'0x[0-9a-fA-F]+', Number.Hex),
|
|
(r'\d+', Number.Integer),
|
|
(r'([^\s{}/*]*)(\s*)(:)', bygroups(Name.Label, Text, Punctuation), '#pop'),
|
|
(words(('compatible', 'model', 'phandle', 'status', '#address-cells',
|
|
'#size-cells', 'reg', 'virtual-reg', 'ranges', 'dma-ranges',
|
|
'device_type', 'name'), suffix=r'\b'), Keyword.Reserved),
|
|
(r'([~!%^&*+=|?:<>/#-])', Operator),
|
|
(r'[(){},.\]]', Punctuation),
|
|
(r'\[', Punctuation, 'bytestring'),
|
|
(r'[a-zA-Z_][\w-]*(?=(?:\s*,' + _ws + r'[a-zA-Z_][\w-]*)*' + _ws + r'[=;])',
|
|
Name),
|
|
(r'[a-zA-Z_]\w*', Name.Attribute),
|
|
],
|
|
'root': [
|
|
include('whitespace'),
|
|
include('macro'),
|
|
# Overlay/fragment: &label { ... } or &{/path/to/node} { ... }
|
|
(r'(&)(?:([A-Za-z_]\w*)|(\{)([^}]+)(\}))(' + _ws + r')(\{)',
|
|
bygroups(Operator, Name.Function, Punctuation, Name.Namespace,
|
|
Punctuation, Comment.Multiline, Punctuation), 'node'),
|
|
# Nodes
|
|
(r'([^/*@\s&]+|/)(@?)((?:0x)?[0-9a-fA-F,]*)(' + _ws + r')(\{)',
|
|
bygroups(Name.Function, Operator, Number.Integer,
|
|
Comment.Multiline, Punctuation), 'node'),
|
|
|
|
default('statement'),
|
|
],
|
|
'statement': [
|
|
include('whitespace'),
|
|
include('statements'),
|
|
(';', Punctuation, '#pop'),
|
|
],
|
|
'node': [
|
|
include('whitespace'),
|
|
include('macro'),
|
|
# Overlay/fragment: &label { ... } or &{/path/to/node} { ... }
|
|
(r'(&)(?:([A-Za-z_]\w*)|(\{)([^}]+)(\}))(' + _ws + r')(\{)',
|
|
bygroups(Operator, Name.Function, Punctuation, Name.Namespace,
|
|
Punctuation, Comment.Multiline, Punctuation), '#push'),
|
|
(r'([^/*@\s&]+|/)(@?)((?:0x)?[0-9a-fA-F,]*)(' + _ws + r')(\{)',
|
|
bygroups(Name.Function, Operator, Number.Integer,
|
|
Comment.Multiline, Punctuation), '#push'),
|
|
|
|
include('statements'),
|
|
|
|
(r'\};', Punctuation, '#pop'),
|
|
(';', Punctuation),
|
|
],
|
|
'string': [
|
|
(r'"', String, '#pop'),
|
|
(r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'
|
|
r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),
|
|
(r'[^\\"\n]+', String), # all other characters
|
|
(r'\\\n', String), # line continuation
|
|
(r'\\', String), # stray backslash
|
|
],
|
|
'bytestring': [
|
|
(r'\]', Punctuation, '#pop'),
|
|
(r'[0-9a-fA-F]{2}', Number.Hex),
|
|
(r'\s+', Whitespace),
|
|
],
|
|
}
|