2024-01-16 21:26:16 +08:00
|
|
|
/*
|
|
|
|
Language: Device Tree
|
|
|
|
Description: *.dts files used in the Linux kernel
|
|
|
|
Author: Martin Braun <martin.braun@ettus.com>, Moritz Fischer <moritz.fischer@ettus.com>
|
|
|
|
Website: https://elinux.org/Device_Tree_Reference
|
|
|
|
Category: config
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @type LanguageFn */
|
|
|
|
function dts(hljs) {
|
|
|
|
const STRINGS = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'string',
|
|
|
|
variants: [
|
2024-01-16 21:26:16 +08:00
|
|
|
hljs.inherit(hljs.QUOTE_STRING_MODE, {
|
|
|
|
begin: '((u8?|U)|L)?"'
|
|
|
|
}),
|
2023-12-18 13:12:25 +08:00
|
|
|
{
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '(u8?|U)?R"',
|
|
|
|
end: '"',
|
2023-12-18 13:12:25 +08:00
|
|
|
contains: [hljs.BACKSLASH_ESCAPE]
|
|
|
|
},
|
|
|
|
{
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '\'\\\\?.',
|
|
|
|
end: '\'',
|
2023-12-18 13:12:25 +08:00
|
|
|
illegal: '.'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const NUMBERS = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'number',
|
|
|
|
variants: [
|
2024-01-16 21:26:16 +08:00
|
|
|
{
|
|
|
|
begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
begin: hljs.C_NUMBER_RE
|
|
|
|
}
|
2023-12-18 13:12:25 +08:00
|
|
|
],
|
|
|
|
relevance: 0
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const PREPROCESSOR = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'meta',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '#',
|
|
|
|
end: '$',
|
|
|
|
keywords: {
|
|
|
|
'meta-keyword': 'if else elif endif define undef ifdef ifndef'
|
|
|
|
},
|
2023-12-18 13:12:25 +08:00
|
|
|
contains: [
|
|
|
|
{
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: /\\\n/,
|
|
|
|
relevance: 0
|
2023-12-18 13:12:25 +08:00
|
|
|
},
|
|
|
|
{
|
2024-01-16 21:26:16 +08:00
|
|
|
beginKeywords: 'include',
|
|
|
|
end: '$',
|
|
|
|
keywords: {
|
|
|
|
'meta-keyword': 'include'
|
|
|
|
},
|
2023-12-18 13:12:25 +08:00
|
|
|
contains: [
|
2024-01-16 21:26:16 +08:00
|
|
|
hljs.inherit(STRINGS, {
|
|
|
|
className: 'meta-string'
|
|
|
|
}),
|
2023-12-18 13:12:25 +08:00
|
|
|
{
|
|
|
|
className: 'meta-string',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '<',
|
|
|
|
end: '>',
|
2023-12-18 13:12:25 +08:00
|
|
|
illegal: '\\n'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
STRINGS,
|
|
|
|
hljs.C_LINE_COMMENT_MODE,
|
|
|
|
hljs.C_BLOCK_COMMENT_MODE
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const DTS_REFERENCE = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'variable',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: /&[a-z\d_]*\b/
|
2023-12-18 13:12:25 +08:00
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const DTS_KEYWORD = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'meta-keyword',
|
|
|
|
begin: '/[a-z][a-z\\d-]*/'
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const DTS_LABEL = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'symbol',
|
|
|
|
begin: '^\\s*[a-zA-Z_][a-zA-Z\\d_]*:'
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const DTS_CELL_PROPERTY = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'params',
|
|
|
|
begin: '<',
|
|
|
|
end: '>',
|
|
|
|
contains: [
|
|
|
|
NUMBERS,
|
|
|
|
DTS_REFERENCE
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const DTS_NODE = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'class',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: /[a-zA-Z_][a-zA-Z\d_@]*\s\{/,
|
2023-12-18 13:12:25 +08:00
|
|
|
end: /[{;=]/,
|
|
|
|
returnBegin: true,
|
|
|
|
excludeEnd: true
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const DTS_ROOT_NODE = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'class',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '/\\s*\\{',
|
|
|
|
end: /\};/,
|
2023-12-18 13:12:25 +08:00
|
|
|
relevance: 10,
|
|
|
|
contains: [
|
|
|
|
DTS_REFERENCE,
|
|
|
|
DTS_KEYWORD,
|
|
|
|
DTS_LABEL,
|
|
|
|
DTS_NODE,
|
|
|
|
DTS_CELL_PROPERTY,
|
|
|
|
hljs.C_LINE_COMMENT_MODE,
|
|
|
|
hljs.C_BLOCK_COMMENT_MODE,
|
|
|
|
NUMBERS,
|
|
|
|
STRINGS
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
2024-01-16 21:26:16 +08:00
|
|
|
name: 'Device Tree',
|
2023-12-18 13:12:25 +08:00
|
|
|
keywords: "",
|
|
|
|
contains: [
|
|
|
|
DTS_ROOT_NODE,
|
|
|
|
DTS_REFERENCE,
|
|
|
|
DTS_KEYWORD,
|
|
|
|
DTS_LABEL,
|
|
|
|
DTS_NODE,
|
|
|
|
DTS_CELL_PROPERTY,
|
|
|
|
hljs.C_LINE_COMMENT_MODE,
|
|
|
|
hljs.C_BLOCK_COMMENT_MODE,
|
|
|
|
NUMBERS,
|
|
|
|
STRINGS,
|
|
|
|
PREPROCESSOR,
|
|
|
|
{
|
|
|
|
begin: hljs.IDENT_RE + '::',
|
|
|
|
keywords: ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = dts;
|