LaravelTest
88 строк · 2.8 Кб
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"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14CodeMirror.defineMode("toml", function () {15return {16startState: function () {17return {18inString: false,19stringType: "",20lhs: true,21inArray: 022};23},24token: function (stream, state) {25//check for state changes26if (!state.inString && ((stream.peek() == '"') || (stream.peek() == "'"))) {27state.stringType = stream.peek();28stream.next(); // Skip quote29state.inString = true; // Update state30}31if (stream.sol() && state.inArray === 0) {32state.lhs = true;33}34//return state35if (state.inString) {36while (state.inString && !stream.eol()) {37if (stream.peek() === state.stringType) {38stream.next(); // Skip quote39state.inString = false; // Clear flag40} else if (stream.peek() === '\\') {41stream.next();42stream.next();43} else {44stream.match(/^.[^\\\"\']*/);45}46}47return state.lhs ? "property string" : "string"; // Token style48} else if (state.inArray && stream.peek() === ']') {49stream.next();50state.inArray--;51return 'bracket';52} else if (state.lhs && stream.peek() === '[' && stream.skipTo(']')) {53stream.next();//skip closing ]54// array of objects has an extra open & close []55if (stream.peek() === ']') stream.next();56return "atom";57} else if (stream.peek() === "#") {58stream.skipToEnd();59return "comment";60} else if (stream.eatSpace()) {61return null;62} else if (state.lhs && stream.eatWhile(function (c) { return c != '=' && c != ' '; })) {63return "property";64} else if (state.lhs && stream.peek() === "=") {65stream.next();66state.lhs = false;67return null;68} else if (!state.lhs && stream.match(/^\d\d\d\d[\d\-\:\.T]*Z/)) {69return 'atom'; //date70} else if (!state.lhs && (stream.match('true') || stream.match('false'))) {71return 'atom';72} else if (!state.lhs && stream.peek() === '[') {73state.inArray++;74stream.next();75return 'bracket';76} else if (!state.lhs && stream.match(/^\-?\d+(?:\.\d+)?/)) {77return 'number';78} else if (!stream.eatSpace()) {79stream.next();80}81return null;82}83};84});85
86CodeMirror.defineMIME('text/x-toml', 'toml');87
88});89