|
1 | 1 | {
|
2 | 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
3 | 3 | "comment": "Some of these patterns are taken straight from rust-analyzer: https://github.com/rust-lang/vscode-rust/blob/master/rust-analyzer/editors/code/rust.tmGrammar.json. Some was also taken from https://github.com/arm32x/vscode-sdlang/blob/master/syntaxes/sdlang.tmLanguage.json",
|
4 |
| - "name": "KDL", |
| 4 | + "name": "kdl", |
5 | 5 | "patterns": [
|
| 6 | + { |
| 7 | + "include": "#forbidden_ident" |
| 8 | + }, |
6 | 9 | {
|
7 | 10 | "include": "#null"
|
8 | 11 | },
|
9 | 12 | {
|
10 | 13 | "include": "#boolean"
|
11 | 14 | },
|
| 15 | + { |
| 16 | + "include": "#float_keyword" |
| 17 | + }, |
12 | 18 | {
|
13 | 19 | "include": "#float_fraction"
|
14 | 20 | },
|
|
28 | 34 | "include": "#binary"
|
29 | 35 | },
|
30 | 36 | {
|
31 |
| - "include": "#raw-strings" |
| 37 | + "include": "#raw-string" |
| 38 | + }, |
| 39 | + { |
| 40 | + "include": "#string_multi_line" |
32 | 41 | },
|
33 | 42 | {
|
34 |
| - "include": "#strings" |
| 43 | + "include": "#string_single_line" |
35 | 44 | },
|
36 | 45 | {
|
37 | 46 | "include": "#block_comment"
|
|
45 | 54 | {
|
46 | 55 | "include": "#slashdash_comment"
|
47 | 56 | },
|
| 57 | + { |
| 58 | + "include": "#slashdash_node_with_children_comment" |
| 59 | + }, |
48 | 60 | {
|
49 | 61 | "include": "#slashdash_node_comment"
|
50 | 62 | },
|
|
56 | 68 | },
|
57 | 69 | {
|
58 | 70 | "include": "#node_name"
|
| 71 | + }, |
| 72 | + { |
| 73 | + "include": "#ident_string" |
59 | 74 | }
|
60 | 75 | ],
|
61 | 76 | "repository": {
|
|
77 | 92 | "hexadecimal": {
|
78 | 93 | "comment": "Integer literal (hexadecimal)",
|
79 | 94 | "name": "constant.numeric.integer.hexadecimal.rust",
|
80 |
| - "match": "\\b0x[a-fA-F0-9_]+\\b" |
| 95 | + "match": "\\b0x[a-fA-F0-9][a-fA-F0-9_]*\\b" |
81 | 96 | },
|
82 | 97 | "octal": {
|
83 | 98 | "comment": "Integer literal (octal)",
|
84 | 99 | "name": "constant.numeric.integer.octal.rust",
|
85 |
| - "match": "\\b0o[0-7_]+\\b" |
| 100 | + "match": "\\b0o[0-7][0-7_]*\\b" |
86 | 101 | },
|
87 | 102 | "binary": {
|
88 | 103 | "comment": "Integer literal (binary)",
|
89 | 104 | "name": "constant.numeric.integer.binary.rust",
|
90 |
| - "match": "\\b0b[01_]+\\b" |
| 105 | + "match": "\\b0b[01][01_]*\\b" |
| 106 | + }, |
| 107 | + "forbidden_ident": { |
| 108 | + "name": "invalid.illegal.kdl.bad-ident", |
| 109 | + "match": "(?<!#)(?:true|false|null|nan|[-]?inf)" |
91 | 110 | },
|
92 | 111 | "node_name": {
|
93 | 112 | "name": "entity.name.tag",
|
94 |
| - "match": "(?![\\\\{\\}<>;\\[\\]\\=,])[\\w\\-_~!@#\\$%^&*+|/.\\(\\)]+" |
| 113 | + "match": "((?<={|;)|^)\\s*(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*" |
95 | 114 | },
|
96 | 115 | "attribute": {
|
97 | 116 | "name": "entity.other.attribute-name.kdl",
|
98 |
| - "match": "(?![\\\\{\\}<>;\\[\\]\\=,])[\\w\\-_~!@#\\$%^&*+|/.]+(=)", |
| 117 | + "match": "(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*(=)", |
99 | 118 | "captures": {
|
100 | 119 | "1": {
|
101 | 120 | "name": "punctuation.separator.key-value.kdl"
|
102 | 121 | }
|
103 | 122 | }
|
104 | 123 | },
|
| 124 | + "ident_string": { |
| 125 | + "name": "string.unquoted", |
| 126 | + "match": "(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*" |
| 127 | + }, |
| 128 | + "float_keyword": { |
| 129 | + "name": "constant.language.other.kdl", |
| 130 | + "match": "#nan|#inf|#-inf" |
| 131 | + }, |
105 | 132 | "null": {
|
106 | 133 | "name": "constant.language.null.kdl",
|
107 |
| - "match": "\\bnull\\b" |
| 134 | + "match": "#null" |
108 | 135 | },
|
109 | 136 | "boolean": {
|
110 | 137 | "name": "constant.language.boolean.kdl",
|
111 |
| - "match": "\\b(true|false)\\b" |
| 138 | + "match": "#true|#false" |
112 | 139 | },
|
113 |
| - "strings": { |
| 140 | + "string_single_line": { |
114 | 141 | "name": "string.quoted.double.kdl",
|
115 | 142 | "begin": "\"",
|
116 | 143 | "end": "\"",
|
117 | 144 | "patterns": [
|
118 | 145 | {
|
119 | 146 | "name": "constant.character.escape.kdl",
|
120 |
| - "match": "\\\\(:?[nrtbf\\\\\"]|u\\{[a-fA-F0-9]{1,6}\\})" |
| 147 | + "match": "\\\\(:?[nrtbfs\\\\\"]|u\\{[a-fA-F0-9]{1,6}\\})" |
121 | 148 | }
|
122 | 149 | ]
|
123 | 150 | },
|
124 |
| - "raw-strings": { |
125 |
| - "name": "string.quoted.double.raw.kdl", |
126 |
| - "begin": "b?r(#*)\"", |
127 |
| - "end": "\"\\1" |
| 151 | + "string_multi_line": { |
| 152 | + "name": "string.quoted.triple.kdl", |
| 153 | + "begin": "\"\"\"", |
| 154 | + "end": "\"\"\"", |
| 155 | + "patterns": [ |
| 156 | + { |
| 157 | + "name": "constant.character.escape.kdl", |
| 158 | + "match": "\\\\(:?[nrtbfs\\\\\"]|u\\{[a-fA-F0-9]{1,6}\\})" |
| 159 | + } |
| 160 | + ] |
| 161 | + }, |
| 162 | + "raw-string": { |
| 163 | + "name": "string.quoted.other.raw.kdl", |
| 164 | + "begin": "(#+)(\"{3,1})", |
| 165 | + "end": "\\2\\1" |
128 | 166 | },
|
129 | 167 | "block_doc_comment": {
|
130 | 168 | "comment": "Block documentation comment",
|
|
156 | 194 | },
|
157 | 195 | "line_comment": {
|
158 | 196 | "comment": "Single-line comment",
|
159 |
| - "name": "comment.line.double-slash.rust", |
| 197 | + "name": "comment.line.double-slash.kdl", |
160 | 198 | "begin": "//",
|
161 | 199 | "end": "$"
|
162 | 200 | },
|
163 | 201 | "slashdash_comment": {
|
164 |
| - "name": "comment.line.double-slash", |
| 202 | + "name": "comment.block.slashdash.kdl", |
165 | 203 | "comment": "Slashdash inline comment",
|
166 | 204 | "begin": "(?<!^)/-",
|
167 | 205 | "end": "\\s"
|
168 | 206 | },
|
169 | 207 | "slashdash_node_comment": {
|
170 |
| - "name": "comment.block", |
| 208 | + "name": "comment.block.slashdash.kdl", |
171 | 209 | "comment": "Slashdash node comment",
|
172 | 210 | "begin": "(?<=^)/-",
|
173 |
| - "end": "}" |
| 211 | + "end": "(?:;|(?<!\\\\)$)" |
| 212 | + }, |
| 213 | + "slashdash_node_with_children_comment": { |
| 214 | + "name": "comment.block.slashdash.kdl", |
| 215 | + "comment": "Slashdash node comment", |
| 216 | + "begin": "(?<=^)/-[^{]+{", |
| 217 | + "end": "\\}" |
174 | 218 | },
|
175 | 219 | "slashdash_block_comment": {
|
176 |
| - "name": "comment.block", |
| 220 | + "name": "comment.block.slashdash.kdl", |
177 | 221 | "comment": "Slashdash block comment",
|
178 |
| - "begin": "/-{", |
| 222 | + "begin": "/-(?:\\s*){", |
179 | 223 | "end": "}"
|
180 | 224 | }
|
181 | 225 | },
|
|
0 commit comments