]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/rust.js
1 /*! `rust` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
7 Author: Andrey Vlasovskikh <andrey.vlasovskikh@gmail.com>
8 Contributors: Roman Shmatov <romanshmatov@gmail.com>, Kasper Andersen <kma_untrusted@protonmail.com>
9 Website: https://www.rust-lang.org
10 Category: common, system
13 /** @type LanguageFn */
16 const regex
= hljs
.regex
;
17 // ============================================
18 // Added to support the r# keyword, which is a raw identifier in Rust.
19 const RAW_IDENTIFIER
= /(r#)?/;
20 const UNDERSCORE_IDENT_RE
= regex
.concat(RAW_IDENTIFIER
, hljs
.UNDERSCORE_IDENT_RE
);
21 const IDENT_RE
= regex
.concat(RAW_IDENTIFIER
, hljs
.IDENT_RE
);
22 // ============================================
23 const FUNCTION_INVOKE
= {
24 className: "title.function.invoke",
28 /(?!let|for|while|if|else|match\b)/,
30 regex
.lookahead(/\s*\(/))
32 const NUMBER_SUFFIX
= '([ui](8|16|32|64|128|size)|f(32|64))\?';
122 "DoubleEndedIterator",
191 $pattern: hljs
.IDENT_RE
+ '!?',
199 hljs
.C_LINE_COMMENT_MODE
,
200 hljs
.COMMENT('/\\*', '\\*/', { contains: [ 'self' ] }),
201 hljs
.inherit(hljs
.QUOTE_STRING_MODE
, {
207 // negative lookahead to avoid matching `'`
208 begin: /'[a-zA-Z_][a-zA-Z0-9_]*(?!')/
213 { begin: /b?r(#*)"(.|\n)*?"\1(?!#)/ },
219 scope: "char.escape",
220 match: /\\('|\w
|x
\w
{2}|u
\w
{4}|U
\w
{8})/
229 { begin: '\\b0b([01_]+)' + NUMBER_SUFFIX
},
230 { begin: '\\b0o([0-7_]+)' + NUMBER_SUFFIX
},
231 { begin: '\\b0x([A-Fa-f0-9_]+)' + NUMBER_SUFFIX
},
232 { begin: '\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)'
258 hljs
.BACKSLASH_ESCAPE
276 // must come before impl/for rule later
304 /(?:trait|enum|struct|union|impl|for)/,
314 begin: hljs
.IDENT_RE
+ '::',
322 className: "punctuation",
334 export default hljsGrammar
;