1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | Prism.languages.rust = {
|
9 | 'comment': [
|
10 | {
|
11 | pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
|
12 | lookbehind: true
|
13 | },
|
14 | {
|
15 | pattern: /(^|[^\\:])\/\/.*/,
|
16 | lookbehind: true
|
17 | }
|
18 | ],
|
19 | 'string': [
|
20 | {
|
21 | pattern: /b?r(#*)"(?:\\.|(?!"\1)[^\\\r\n])*"\1/,
|
22 | greedy: true
|
23 | },
|
24 | {
|
25 | pattern: /b?"(?:\\.|[^\\\r\n"])*"/,
|
26 | greedy: true
|
27 | }
|
28 | ],
|
29 | 'char': {
|
30 | pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
|
31 | alias: 'string'
|
32 | },
|
33 | 'lifetime-annotation': {
|
34 | pattern: /'[^\s>']+/,
|
35 | alias: 'symbol'
|
36 | },
|
37 | 'keyword': /\b(?:abstract|alignof|as|async|await|be|box|break|const|continue|crate|do|dyn|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|Self|struct|super|true|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
|
38 |
|
39 | 'attribute': {
|
40 | pattern: /#!?\[.+?\]/,
|
41 | greedy: true,
|
42 | alias: 'attr-name'
|
43 | },
|
44 |
|
45 | 'function': [
|
46 | /\w+(?=\s*\()/,
|
47 |
|
48 | /\w+!(?=\s*\(|\[)/
|
49 | ],
|
50 | 'macro-rules': {
|
51 | pattern: /\w+!/,
|
52 | alias: 'function'
|
53 | },
|
54 |
|
55 |
|
56 | 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,
|
57 |
|
58 |
|
59 | 'closure-params': {
|
60 | pattern: /\|[^|]*\|(?=\s*[{-])/,
|
61 | inside: {
|
62 | 'punctuation': /[|:,]/,
|
63 | 'operator': /[&*]/
|
64 | }
|
65 | },
|
66 | 'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
67 | 'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
68 | };
|