// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
})(function(CodeMirror) {
CodeMirror.defineMode("spreadsheet", function () {
startState: function () {
token: function (stream, state) {
//check for state changes
if (state.stack.length === 0) {
if ((stream.peek() == '"') || (stream.peek() == "'")) {
state.stringType = stream.peek();
stream.next(); // Skip quote
state.stack.unshift("string");
switch (state.stack[0]) {
while (state.stack[0] === "string" && !stream.eol()) {
if (stream.peek() === state.stringType) {
stream.next(); // Skip quote
state.stack.shift(); // Clear flag
} else if (stream.peek() === "\\") {
stream.match(/^.[^\\\"\']*/);
while (state.stack[0] === "characterClass" && !stream.eol()) {
if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./)))
var peek = stream.peek();
state.stack.unshift("characterClass");
if (stream.match(/\\[a-z]+/)) return "string-2";
if (stream.match(/\d+/)) {
if (stream.match(/^\w+/)) return "error";
} else if (stream.match(/^[a-zA-Z_]\w*/)) {
if (stream.match(/(?=[\(.])/, false)) return "keyword";
} else if (["[", "]", "(", ")", "{", "}"].indexOf(peek) != -1) {
} else if (!stream.eatSpace()) {
CodeMirror.defineMIME("text/x-spreadsheet", "spreadsheet");