LaravelTest
72 строки · 3.0 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function(mod) {5if (typeof exports == "object" && typeof module == "object") // CommonJS6mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror", "../../addon/mode/simple"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14CodeMirror.defineSimpleMode("rust",{15start: [16// string and byte string17{regex: /b?"/, token: "string", next: "string"},18// raw string and raw byte string19{regex: /b?r"/, token: "string", next: "string_raw"},20{regex: /b?r#+"/, token: "string", next: "string_raw_hash"},21// character22{regex: /'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/, token: "string-2"},23// byte24{regex: /b'(?:[^']|\\(?:['\\nrt0]|x[\da-fA-F]{2}))'/, token: "string-2"},25
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)?/,27token: "number"},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_]*)/,33token: ["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}42],43string: [44{regex: /"/, token: "string", next: "start"},45{regex: /(?:[^\\"]|\\(?:.|$))*/, token: "string"}46],47string_raw: [48{regex: /"/, token: "string", next: "start"},49{regex: /[^"]*/, token: "string"}50],51string_raw_hash: [52{regex: /"#+/, token: "string", next: "start"},53{regex: /(?:[^"]|"(?!#))*/, token: "string"}54],55comment: [56{regex: /.*?\*\//, token: "comment", next: "start"},57{regex: /.*/, token: "comment"}58],59meta: {60dontIndentStates: ["comment"],61electricInput: /^\s*\}$/,62blockCommentStart: "/*",63blockCommentEnd: "*/",64lineComment: "//",65fold: "brace"66}67});68
69
70CodeMirror.defineMIME("text/x-rustsrc", "rust");71CodeMirror.defineMIME("text/rust", "rust");72});73