1use super::{Language, Syntax};
2
3impl Language {
4 #[must_use]
6 pub const fn syntax(self) -> Syntax {
7 match self {
8 Self::JavaScript | Self::TypeScript => JAVASCRIPT,
9 Self::Graphql => GRAPHQL,
10 Self::Protobuf => PROTOBUF,
11 Self::Rust => RUST,
12 Self::Python => PYTHON,
13 Self::Go | Self::Java | Self::CSharp | Self::C | Self::Cpp | Self::Solidity => C_FAMILY,
14 Self::Sql => SQL,
15 Self::Swift => SWIFT,
16 Self::Terraform => TERRAFORM,
17 Self::Html => HTML,
18 Self::Css => CSS,
19 Self::Scss => SCSS,
20 Self::Xml => XML,
21 Self::Markdown | Self::Mdx | Self::ReStructuredText | Self::AsciiDoc => PROSE,
22 Self::Bash => BASH,
23 Self::Yaml => YAML,
24 }
25 }
26}
27
28const JAVASCRIPT: Syntax = Syntax {
29 line_comments: &["//"],
30 block_comment: Some(("/*", "*/")),
31 nested_block_comments: false,
32 quotes: &['"', '\'', '`'],
33 interpolated_quote: Some('`'),
34 escapes: true,
35 regex_literals: true,
36 raw_strings: false,
37 triple_quotes: false,
38 char_literals: false,
39 significant_indentation: false,
40 identifier_extra: &['$', '_'],
41};
42
43const GRAPHQL: Syntax = Syntax {
44 line_comments: &["#"],
45 block_comment: None,
46 nested_block_comments: false,
47 quotes: &['"'],
48 interpolated_quote: None,
49 escapes: true,
50 regex_literals: false,
51 raw_strings: false,
52 triple_quotes: true,
54 char_literals: false,
55 significant_indentation: false,
56 identifier_extra: &['_'],
57};
58
59const PROTOBUF: Syntax = Syntax {
60 line_comments: &["//"],
61 block_comment: Some(("/*", "*/")),
62 nested_block_comments: false,
63 quotes: &['"', '\''],
64 interpolated_quote: None,
65 escapes: true,
66 regex_literals: false,
67 raw_strings: false,
68 triple_quotes: false,
69 char_literals: false,
70 significant_indentation: false,
71 identifier_extra: &['_'],
72};
73
74const RUST: Syntax = Syntax {
75 line_comments: &["//"],
76 block_comment: Some(("/*", "*/")),
77 nested_block_comments: true,
79 quotes: &['"'],
80 interpolated_quote: None,
81 escapes: true,
82 regex_literals: false,
83 raw_strings: true,
84 triple_quotes: false,
85 char_literals: true,
86 significant_indentation: false,
87 identifier_extra: &['_'],
88};
89
90const PYTHON: Syntax = Syntax {
91 line_comments: &["#"],
92 block_comment: None,
93 nested_block_comments: false,
94 quotes: &['"', '\''],
95 interpolated_quote: None,
96 escapes: true,
97 regex_literals: false,
98 raw_strings: false,
99 triple_quotes: true,
100 char_literals: false,
101 significant_indentation: true,
102 identifier_extra: &['_'],
103};
104
105const C_FAMILY: Syntax = Syntax {
107 line_comments: &["//"],
108 block_comment: Some(("/*", "*/")),
109 nested_block_comments: false,
110 quotes: &['"', '\'', '`'],
111 interpolated_quote: None,
112 escapes: true,
113 regex_literals: false,
114 raw_strings: false,
115 triple_quotes: false,
116 char_literals: false,
117 significant_indentation: false,
118 identifier_extra: &['_'],
119};
120
121const SQL: Syntax = Syntax {
122 line_comments: &["--"],
123 block_comment: Some(("/*", "*/")),
124 nested_block_comments: false,
125 quotes: &['\'', '"'],
126 interpolated_quote: None,
127 escapes: false,
129 regex_literals: false,
130 raw_strings: false,
131 triple_quotes: false,
132 char_literals: false,
133 significant_indentation: false,
134 identifier_extra: &['_', '$'],
135};
136
137const SWIFT: Syntax = Syntax {
138 line_comments: &["//"],
139 block_comment: Some(("/*", "*/")),
140 nested_block_comments: true,
142 quotes: &['"'],
143 interpolated_quote: None,
144 escapes: true,
145 raw_strings: false,
146 regex_literals: false,
147 triple_quotes: true,
148 char_literals: false,
149 significant_indentation: false,
150 identifier_extra: &['_', '$'],
152};
153
154const TERRAFORM: Syntax = Syntax {
155 line_comments: &["#", "//"],
156 block_comment: Some(("/*", "*/")),
157 nested_block_comments: false,
158 quotes: &['"'],
159 interpolated_quote: Some('"'),
160 escapes: true,
161 regex_literals: false,
162 raw_strings: false,
163 triple_quotes: false,
164 char_literals: false,
165 significant_indentation: false,
166 identifier_extra: &['_', '-'],
167};
168
169const HTML: Syntax = Syntax {
170 line_comments: &[],
171 block_comment: Some(("<!--", "-->")),
172 nested_block_comments: false,
173 quotes: &['"', '\''],
174 interpolated_quote: None,
175 escapes: false,
177 regex_literals: false,
178 raw_strings: false,
179 triple_quotes: false,
180 char_literals: false,
181 significant_indentation: false,
182 identifier_extra: &['_', '-', ':', '.', '@'],
183};
184
185const CSS: Syntax = Syntax {
186 line_comments: &[],
187 block_comment: Some(("/*", "*/")),
188 nested_block_comments: false,
189 quotes: &['"', '\''],
190 interpolated_quote: None,
191 escapes: true,
192 regex_literals: false,
193 raw_strings: false,
194 triple_quotes: false,
195 char_literals: false,
196 significant_indentation: false,
197 identifier_extra: &['_', '-'],
198};
199
200const SCSS: Syntax = Syntax {
201 line_comments: &["//"],
202 block_comment: Some(("/*", "*/")),
203 nested_block_comments: false,
204 quotes: &['"', '\''],
205 interpolated_quote: None,
206 escapes: true,
207 regex_literals: false,
208 raw_strings: false,
209 triple_quotes: false,
210 char_literals: false,
211 significant_indentation: false,
212 identifier_extra: &['_', '-', '$', '@'],
213};
214
215const XML: Syntax = Syntax {
216 line_comments: &[],
217 block_comment: Some(("<!--", "-->")),
218 nested_block_comments: false,
219 quotes: &['"', '\''],
220 interpolated_quote: None,
221 escapes: false,
222 regex_literals: false,
223 raw_strings: false,
224 triple_quotes: false,
225 char_literals: false,
226 significant_indentation: false,
227 identifier_extra: &['_', '-', ':', '.'],
228};
229
230const PROSE: Syntax = Syntax {
231 line_comments: &[],
232 block_comment: Some(("<!--", "-->")),
233 nested_block_comments: false,
234 quotes: &[],
235 interpolated_quote: None,
236 escapes: false,
237 regex_literals: false,
238 raw_strings: false,
239 triple_quotes: false,
240 char_literals: false,
241 significant_indentation: true,
242 identifier_extra: &['_', '-', '.'],
243};
244
245const BASH: Syntax = Syntax {
246 line_comments: &["#"],
247 block_comment: None,
248 nested_block_comments: false,
249 quotes: &['"', '\''],
250 interpolated_quote: Some('"'),
251 escapes: true,
252 regex_literals: false,
253 raw_strings: false,
254 triple_quotes: false,
255 char_literals: false,
256 significant_indentation: false,
257 identifier_extra: &['_'],
258};
259
260const YAML: Syntax = Syntax {
261 line_comments: &["#"],
262 block_comment: None,
263 nested_block_comments: false,
264 quotes: &['"', '\''],
265 interpolated_quote: None,
266 escapes: true,
267 regex_literals: false,
268 raw_strings: false,
269 triple_quotes: false,
270 char_literals: false,
271 significant_indentation: true,
272 identifier_extra: &['_', '-', '.'],
273};