if (typeof exports == "object" && typeof module == "object")
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd)
define(["../../lib/codemirror"], mod);
})(function(CodeMirror) {
CodeMirror.defineMode("d", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
keywords = parserConfig.keywords || {},
builtin = parserConfig.builtin || {},
blockKeywords = parserConfig.blockKeywords || {},
atoms = parserConfig.atoms || {},
hooks = parserConfig.hooks || {},
multiLineStrings = parserConfig.multiLineStrings;
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
function tokenBase(stream, state) {
var result = hooks[ch](stream, state);
if (result !== false) return result;
if (ch == '"' || ch == "'" || ch == "`") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
stream.eatWhile(/[\w\.]/);
state.tokenize = tokenComment;
return tokenNestedComment(stream, state);
state.tokenize = tokenComment;
return tokenComment(stream, state);
if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
if (builtin.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
if (atoms.propertyIsEnumerable(cur)) return "atom";
function tokenString(quote) {
return function(stream, state) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
if (end || !(escaped || multiLineStrings))
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {