: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// 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("elm", function() {
function switchState(source, setState, f) {
return f(source, setState);
// These should all be Unicode extended, as per the Haskell 2010 report
var hexitRE = /[0-9A-Fa-f]/;
var idRE = /[a-z_A-Z0-9\']/;
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]/;
var specialRE = /[(),;[\]`{}]/;
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
return function (source, setState) {
if (source.eatWhile(whiteCharRE)) {
if (specialRE.test(ch)) {
if (ch == '{' && source.eat('-')) {
if (source.eat('#')) t = "meta";
return switchState(source, setState, ncomment(t, 1));
source.next(); // should handle other escapes here
return switchState(source, setState, stringLiteral);
var isDef = source.pos === 1;
return isDef ? "variable-3" : "variable";
if (source.eat(/[xX]/)) {
source.eatWhile(hexitRE); // should require at least 1
if (source.eat(/[oO]/)) {
source.eatWhile(octitRE); // should require at least 1
source.eatWhile(digitRE);
source.eatWhile(digitRE); // should require at least 1
if (source.eat(/[eE]/)) {
source.eatWhile(digitRE); // should require at least 1
if (ch == '-' && source.eat(/-/)) {
if (!source.eat(symbolRE)) {
source.eatWhile(symbolRE);
function ncomment(type, nest) {
return function(source, setState) {
if (ch == '{' && source.eat('-')) {
} else if (ch == '-' && source.eat('}')) {
setState(ncomment(type, currNest));
function stringLiteral(source, setState) {
if (source.eol() || source.eat(whiteCharRE)) {
if (!source.eat('&')) source.next(); // should handle other escapes here
function stringGap(source, setState) {
return switchState(source, setState, stringLiteral);
var wellKnownWords = (function() {
"infix", "infixl", "infixr",
"input", "output", "foreign", "loopback",
"module", "where", "import", "exposing",
"_", "..", "|", ":", "=", "\\", "\"", "->", "<-"
for (var i = keywords.length; i--;)
wkw[keywords[i]] = "keyword";
startState: function () { return { f: normal() }; },
copyState: function (s) { return { f: s.f }; },
token: function(stream, state) {
var t = state.f(stream, function(s) { state.f = s; });
var w = stream.current();
return (wellKnownWords.hasOwnProperty(w)) ? wellKnownWords[w] : t;
CodeMirror.defineMIME("text/x-elm", "elm");