source: node_modules/highlight.js/lib/languages/dts.js@ e48199a

main
Last change on this file since e48199a was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

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