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