dts.js (2700B)
1 /* 2 Language: Device Tree 3 Description: *.dts files used in the Linux kernel 4 Author: Martin Braun <martin.braun@ettus.com>, Moritz Fischer <moritz.fischer@ettus.com> 5 Website: https://elinux.org/Device_Tree_Reference 6 Category: config 7 */ 8 9 function dts(hljs) { 10 var STRINGS = { 11 className: 'string', 12 variants: [ 13 hljs.inherit(hljs.QUOTE_STRING_MODE, { begin: '((u8?|U)|L)?"' }), 14 { 15 begin: '(u8?|U)?R"', end: '"', 16 contains: [hljs.BACKSLASH_ESCAPE] 17 }, 18 { 19 begin: '\'\\\\?.', end: '\'', 20 illegal: '.' 21 } 22 ] 23 }; 24 25 var NUMBERS = { 26 className: 'number', 27 variants: [ 28 { begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)' }, 29 { begin: hljs.C_NUMBER_RE } 30 ], 31 relevance: 0 32 }; 33 34 var PREPROCESSOR = { 35 className: 'meta', 36 begin: '#', end: '$', 37 keywords: {'meta-keyword': 'if else elif endif define undef ifdef ifndef'}, 38 contains: [ 39 { 40 begin: /\\\n/, relevance: 0 41 }, 42 { 43 beginKeywords: 'include', end: '$', 44 keywords: {'meta-keyword': 'include'}, 45 contains: [ 46 hljs.inherit(STRINGS, {className: 'meta-string'}), 47 { 48 className: 'meta-string', 49 begin: '<', end: '>', 50 illegal: '\\n' 51 } 52 ] 53 }, 54 STRINGS, 55 hljs.C_LINE_COMMENT_MODE, 56 hljs.C_BLOCK_COMMENT_MODE 57 ] 58 }; 59 60 var DTS_REFERENCE = { 61 className: 'variable', 62 begin: '\\&[a-z\\d_]*\\b' 63 }; 64 65 var DTS_KEYWORD = { 66 className: 'meta-keyword', 67 begin: '/[a-z][a-z\\d-]*/' 68 }; 69 70 var DTS_LABEL = { 71 className: 'symbol', 72 begin: '^\\s*[a-zA-Z_][a-zA-Z\\d_]*:' 73 }; 74 75 var DTS_CELL_PROPERTY = { 76 className: 'params', 77 begin: '<', 78 end: '>', 79 contains: [ 80 NUMBERS, 81 DTS_REFERENCE 82 ] 83 }; 84 85 var DTS_NODE = { 86 className: 'class', 87 begin: /[a-zA-Z_][a-zA-Z\d_@]*\s{/, 88 end: /[{;=]/, 89 returnBegin: true, 90 excludeEnd: true 91 }; 92 93 var DTS_ROOT_NODE = { 94 className: 'class', 95 begin: '/\\s*{', 96 end: '};', 97 relevance: 10, 98 contains: [ 99 DTS_REFERENCE, 100 DTS_KEYWORD, 101 DTS_LABEL, 102 DTS_NODE, 103 DTS_CELL_PROPERTY, 104 hljs.C_LINE_COMMENT_MODE, 105 hljs.C_BLOCK_COMMENT_MODE, 106 NUMBERS, 107 STRINGS 108 ] 109 }; 110 111 return { 112 name: 'Device Tree', 113 keywords: "", 114 contains: [ 115 DTS_ROOT_NODE, 116 DTS_REFERENCE, 117 DTS_KEYWORD, 118 DTS_LABEL, 119 DTS_NODE, 120 DTS_CELL_PROPERTY, 121 hljs.C_LINE_COMMENT_MODE, 122 hljs.C_BLOCK_COMMENT_MODE, 123 NUMBERS, 124 STRINGS, 125 PREPROCESSOR, 126 { 127 begin: hljs.IDENT_RE + '::', 128 keywords: "" 129 } 130 ] 131 }; 132 } 133 134 module.exports = dts;