LaravelTest
85 строк · 3.5 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4// Factor syntax highlight - simple mode
5//
6// by Dimage Sapelkin (https://github.com/kerabromsmu)
7
8(function(mod) {9if (typeof exports == "object" && typeof module == "object") // CommonJS10mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));11else if (typeof define == "function" && define.amd) // AMD12define(["../../lib/codemirror", "../../addon/mode/simple"], mod);13else // Plain browser env14mod(CodeMirror);15})(function(CodeMirror) {16"use strict";17
18CodeMirror.defineSimpleMode("factor", {19// The start state contains the rules that are initially used20start: [21// comments22{regex: /#?!.*/, token: "comment"},23// strings """, multiline --> state24{regex: /"""/, token: "string", next: "string3"},25{regex: /(STRING:)(\s)/, token: ["keyword", null], next: "string2"},26{regex: /\S*?"/, token: "string", next: "string"},27// numbers: dec, hex, unicode, bin, fractional, complex28{regex: /(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\-?\d+.?\d*)(?=\s)/, token: "number"},29//{regex: /[+-]?/} //fractional30// definition: defining word, defined word, etc31{regex: /((?:GENERIC)|\:?\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "bracket"], next: "stack"},32// method definition: defining word, type, defined word, etc33{regex: /(M\:)(\s+)(\S+)(\s+)(\S+)/, token: ["keyword", null, "def", null, "tag"]},34// vocabulary using --> state35{regex: /USING\:/, token: "keyword", next: "vocabulary"},36// vocabulary definition/use37{regex: /(USE\:|IN\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "tag"]},38// definition: a defining word, defined word39{regex: /(\S+\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "def"]},40// "keywords", incl. ; t f . [ ] { } defining words41{regex: /(?:;|\\|t|f|if|loop|while|until|do|PRIVATE>|<PRIVATE|\.|\S*\[|\]|\S*\{|\})(?=\s|$)/, token: "keyword"},42// <constructors> and the like43{regex: /\S+[\)>\.\*\?]+(?=\s|$)/, token: "builtin"},44{regex: /[\)><]+\S+(?=\s|$)/, token: "builtin"},45// operators46{regex: /(?:[\+\-\=\/\*<>])(?=\s|$)/, token: "keyword"},47// any id (?)48{regex: /\S+/, token: "variable"},49{regex: /\s+|./, token: null}50],51vocabulary: [52{regex: /;/, token: "keyword", next: "start"},53{regex: /\S+/, token: "tag"},54{regex: /\s+|./, token: null}55],56string: [57{regex: /(?:[^\\]|\\.)*?"/, token: "string", next: "start"},58{regex: /.*/, token: "string"}59],60string2: [61{regex: /^;/, token: "keyword", next: "start"},62{regex: /.*/, token: "string"}63],64string3: [65{regex: /(?:[^\\]|\\.)*?"""/, token: "string", next: "start"},66{regex: /.*/, token: "string"}67],68stack: [69{regex: /\)/, token: "bracket", next: "start"},70{regex: /--/, token: "bracket"},71{regex: /\S+/, token: "meta"},72{regex: /\s+|./, token: null}73],74// The meta property contains global information about the mode. It75// can contain properties like lineComment, which are supported by76// all modes, and also directives like dontIndentStates, which are77// specific to simple modes.78meta: {79dontIndentStates: ["start", "vocabulary", "string", "string3", "stack"],80lineComment: "!"81}82});83
84CodeMirror.defineMIME("text/x-factor", "factor");85});86