Blame view

bower_components/prism/components/prism-rust.js 1.5 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  /* TODO
  	Add support for Markdown notation inside doc comments
  	Add support for nested block comments...
  	Match closure params even when not followed by dash or brace
  	Add better support for macro definition
  */
  
  Prism.languages.rust = {
  	'comment': [
  		{
  			pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
  			lookbehind: true
  		},
  		{
eb240478   Luigi Serra   public room cards...
15
  			pattern: /(^|[^\\:])\/\/.*/,
73bcce88   luigser   COMPONENTS
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  			lookbehind: true
  		}
  	],
  	'string': [
  		/b?r(#*)"(?:\\?.)*?"\1/,
  		/b?("|')(?:\\?.)*?\1/
  	],
  	'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|do|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|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/,
  
  	'attribute': {
  		pattern: /#!?\[.+?\]/,
  		alias: 'attr-name'
  	},
  
  	'function': [
  		/[a-z0-9_]+(?=\s*\()/i,
  		// Macros can use parens or brackets
  		/[a-z0-9_]+!(?=\s*\(|\[)/i
  	],
  	'macro-rules': {
  		pattern: /[a-z0-9_]+!/i,
  		alias: 'function'
  	},
  
  	// Hex, oct, bin, dec numbers with visual separators and type suffix
eb240478   Luigi Serra   public room cards...
41
  	'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/,
73bcce88   luigser   COMPONENTS
42
43
44
45
46
47
48
49
50
  
  	// Closure params should not be confused with bitwise OR |
  	'closure-params': {
  		pattern: /\|[^|]*\|(?=\s*[{-])/,
  		inside: {
  			'punctuation': /[\|:,]/,
  			'operator': /[&*]/
  		}
  	},
eb240478   Luigi Serra   public room cards...
51
52
  	'punctuation': /[{}[\];(),:]|\.+|->/,
  	'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
73bcce88   luigser   COMPONENTS
53
  };