]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/dts.js
Initial commit.
[flow-web.git] / static / highlight / languages / dts.js
1 /*! `dts` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Device Tree
8 Description: *.dts files used in the Linux kernel
9 Author: Martin Braun <martin.braun@ettus.com>, Moritz Fischer <moritz.fischer@ettus.com>
10 Website: https://elinux.org/Device_Tree_Reference
11 Category: config
12 */
13
14 /** @type LanguageFn */
15 function dts(hljs) {
16 const STRINGS = {
17 className: 'string',
18 variants: [
19 hljs.inherit(hljs.QUOTE_STRING_MODE, { begin: '((u8?|U)|L)?"' }),
20 {
21 begin: '(u8?|U)?R"',
22 end: '"',
23 contains: [ hljs.BACKSLASH_ESCAPE ]
24 },
25 {
26 begin: '\'\\\\?.',
27 end: '\'',
28 illegal: '.'
29 }
30 ]
31 };
32
33 const NUMBERS = {
34 className: 'number',
35 variants: [
36 { begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)' },
37 { begin: hljs.C_NUMBER_RE }
38 ],
39 relevance: 0
40 };
41
42 const PREPROCESSOR = {
43 className: 'meta',
44 begin: '#',
45 end: '$',
46 keywords: { keyword: 'if else elif endif define undef ifdef ifndef' },
47 contains: [
48 {
49 begin: /\\\n/,
50 relevance: 0
51 },
52 {
53 beginKeywords: 'include',
54 end: '$',
55 keywords: { keyword: 'include' },
56 contains: [
57 hljs.inherit(STRINGS, { className: 'string' }),
58 {
59 className: 'string',
60 begin: '<',
61 end: '>',
62 illegal: '\\n'
63 }
64 ]
65 },
66 STRINGS,
67 hljs.C_LINE_COMMENT_MODE,
68 hljs.C_BLOCK_COMMENT_MODE
69 ]
70 };
71
72 const REFERENCE = {
73 className: 'variable',
74 begin: /&[a-z\d_]*\b/
75 };
76
77 const KEYWORD = {
78 className: 'keyword',
79 begin: '/[a-z][a-z\\d-]*/'
80 };
81
82 const LABEL = {
83 className: 'symbol',
84 begin: '^\\s*[a-zA-Z_][a-zA-Z\\d_]*:'
85 };
86
87 const CELL_PROPERTY = {
88 className: 'params',
89 relevance: 0,
90 begin: '<',
91 end: '>',
92 contains: [
93 NUMBERS,
94 REFERENCE
95 ]
96 };
97
98 const NODE = {
99 className: 'title.class',
100 begin: /[a-zA-Z_][a-zA-Z\d_@-]*(?=\s\{)/,
101 relevance: 0.2
102 };
103
104 const ROOT_NODE = {
105 className: 'title.class',
106 begin: /^\/(?=\s*\{)/,
107 relevance: 10
108 };
109
110 // TODO: `attribute` might be the right scope here, unsure
111 // I'm not sure if all these key names have semantic meaning or not
112 const ATTR_NO_VALUE = {
113 match: /[a-z][a-z-,]+(?=;)/,
114 relevance: 0,
115 scope: "attr"
116 };
117 const ATTR = {
118 relevance: 0,
119 match: [
120 /[a-z][a-z-,]+/,
121 /\s*/,
122 /=/
123 ],
124 scope: {
125 1: "attr",
126 3: "operator"
127 }
128 };
129
130 const PUNC = {
131 scope: "punctuation",
132 relevance: 0,
133 // `};` combined is just to avoid tons of useless punctuation nodes
134 match: /\};|[;{}]/
135 };
136
137 return {
138 name: 'Device Tree',
139 contains: [
140 ROOT_NODE,
141 REFERENCE,
142 KEYWORD,
143 LABEL,
144 NODE,
145 ATTR,
146 ATTR_NO_VALUE,
147 CELL_PROPERTY,
148 hljs.C_LINE_COMMENT_MODE,
149 hljs.C_BLOCK_COMMENT_MODE,
150 NUMBERS,
151 STRINGS,
152 PREPROCESSOR,
153 PUNC,
154 {
155 begin: hljs.IDENT_RE + '::',
156 keywords: ""
157 }
158 ]
159 };
160 }
161
162 return dts;
163
164 })();
165
166 hljs.registerLanguage('dts', hljsGrammar);
167 })();