5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
11
})(function(CodeMirror) {
14
CodeMirror.defineSimpleMode("rust",{
17
{regex: /b?"/, token: "string", next: "string"},
19
{regex: /b?r"/, token: "string", next: "string_raw"},
20
{regex: /b?r#+"/, token: "string", next: "string_raw_hash"},
22
{regex: /'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/, token: "string-2"},
24
{regex: /b'(?:[^']|\\(?:['\\nrt0]|x[\da-fA-F]{2}))'/, token: "string-2"},
26
{regex: /(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/,
28
{regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type|union)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]},
29
{regex: /(?:abstract|alignof|as|async|await|box|break|continue|const|crate|do|dyn|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"},
30
{regex: /\b(?:Self|isize|usize|char|bool|u8|u16|u32|u64|f16|f32|f64|i8|i16|i32|i64|str|Option)\b/, token: "atom"},
31
{regex: /\b(?:true|false|Some|None|Ok|Err)\b/, token: "builtin"},
32
{regex: /\b(fn)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/,
33
token: ["keyword", null ,"def"]},
34
{regex: /#!?\[.*\]/, token: "meta"},
35
{regex: /\/\/.*/, token: "comment"},
36
{regex: /\/\*/, token: "comment", next: "comment"},
37
{regex: /[-+\/*=<>!]+/, token: "operator"},
38
{regex: /[a-zA-Z_]\w*!/,token: "variable-3"},
39
{regex: /[a-zA-Z_]\w*/, token: "variable"},
40
{regex: /[\{\[\(]/, indent: true},
41
{regex: /[\}\]\)]/, dedent: true}
44
{regex: /"/, token: "string", next: "start"},
45
{regex: /(?:[^\\"]|\\(?:.|$))*/, token: "string"}
48
{regex: /"/, token: "string", next: "start"},
49
{regex: /[^"]*/, token: "string"}
52
{regex: /"#+/, token: "string", next: "start"},
53
{regex: /(?:[^"]|"(?!#))*/, token: "string"}
56
{regex: /.*?\*\//, token: "comment", next: "start"},
57
{regex: /.*/, token: "comment"}
60
dontIndentStates: ["comment"],
61
electricInput: /^\s*\}$/,
62
blockCommentStart: "/*",
63
blockCommentEnd: "*/",
70
CodeMirror.defineMIME("text/x-rustsrc", "rust");
71
CodeMirror.defineMIME("text/rust", "rust");