5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror"], mod);
11
})(function(CodeMirror) {
14
CodeMirror.defineMode("cmake", function () {
15
var variable_regex = /({)?[a-zA-Z0-9_]+(})?/;
17
function tokenString(stream, state) {
18
var current, prev, found_var = false;
19
while (!stream.eol() && (current = stream.next()) != state.pending) {
20
if (current === '$' && prev != '\\' && state.pending == '"') {
29
if (current == state.pending) {
30
state.continueString = false;
32
state.continueString = true;
37
function tokenize(stream, state) {
38
var ch = stream.next();
42
if (stream.match(variable_regex)) {
48
if (state.continueString) {
51
return tokenString(stream, state);
55
if (stream.match(/(\s+)?\w+\(/) || stream.match(/(\s+)?\w+\ \(/)) {
64
if (ch == "'" || ch == '"') {
68
return tokenString(stream, state);
70
if (ch == '(' || ch == ')') {
73
if (ch.match(/[0-9]/)) {
76
stream.eatWhile(/[\w-]/);
80
startState: function () {
82
state.inDefinition = false;
83
state.inInclude = false;
84
state.continueString = false;
85
state.pending = false;
88
token: function (stream, state) {
89
if (stream.eatSpace()) return null;
90
return tokenize(stream, state);
95
CodeMirror.defineMIME("text/x-cmake", "cmake");