: 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("oz", function (conf) {
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
var singleOperators = /[\^@!\|<>#~\.\*\-\+\\/,=]/;
var doubleOperators = /(<-)|(:=)|(=<)|(>=)|(<=)|(<:)|(>:)|(=:)|(\\=)|(\\=:)|(!!)|(==)|(::)/;
var tripleOperators = /(:::)|(\.\.\.)|(=<:)|(>=:)/;
var middle = ["in", "then", "else", "of", "elseof", "elsecase", "elseif", "catch",
"finally", "with", "require", "prepare", "import", "export", "define", "do"];
var atoms = wordRegexp(["true", "false", "nil", "unit"]);
var commonKeywords = wordRegexp(["andthen", "at", "attr", "declare", "feat", "from", "lex",
"mod", "mode", "orelse", "parser", "prod", "prop", "scanner", "self", "syn", "token"]);
var openingKeywords = wordRegexp(["local", "proc", "fun", "case", "class", "if", "cond", "or", "dis",
"choice", "not", "thread", "try", "raise", "lock", "for", "suchthat", "meth", "functor"]);
var middleKeywords = wordRegexp(middle);
var endKeywords = wordRegexp(end);
function tokenBase(stream, state) {
if(stream.match(/[{}]/)) {
if (stream.match(/(\[])/)) {
if (stream.match(tripleOperators) || stream.match(doubleOperators)) {
if(stream.match(atoms)) {
var matched = stream.match(openingKeywords);
if (!state.doInCurrentLine)
state.doInCurrentLine = false;
// Special matching for signatures
if(matched[0] == "proc" || matched[0] == "fun")
state.tokenize = tokenFunProc;
else if(matched[0] == "class")
state.tokenize = tokenClass;
else if(matched[0] == "meth")
state.tokenize = tokenMeth;
// Middle and other keywords
if (stream.match(middleKeywords) || stream.match(commonKeywords)) {
if (stream.match(endKeywords)) {
// Eat the next char for next comparisons
if (ch == '"' || ch == "'") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
if(! /^[0-9]/.test(stream.peek()))
else if (( stream.next() == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))
if ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))
state.tokenize = tokenComment;
return tokenComment(stream, state);
if(singleOperators.test(ch)) {
// If nothing match, we skip the entire alphanumerical block
function tokenClass(stream, state) {
stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)/);
state.tokenize = tokenBase;
function tokenMeth(stream, state) {
stream.match(/([a-zA-Z][A-Za-z0-9_]*)|(`.+`)/);
state.tokenize = tokenBase;
function tokenFunProc(stream, state) {
if(!state.hasPassedFirstStage && stream.eat("{")) {
state.hasPassedFirstStage = true;
else if(state.hasPassedFirstStage) {
stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)|\$/);
state.hasPassedFirstStage = false;
state.tokenize = tokenBase;
state.tokenize = tokenBase;
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = tokenBase;
function tokenString(quote) {
return function (stream, state) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {
escaped = !escaped && next == "\\";
state.tokenize = tokenBase;
function buildElectricInputRegEx() {
// Reindentation should occur on [] or on a match of any of
// the block closing keywords, at the end of a line.
var allClosings = middle.concat(end);
return new RegExp("[\\[\\]]|(" + allClosings.join("|") + ")$");
startState: function () {
hasPassedFirstStage: false
token: function (stream, state) {
state.doInCurrentLine = 0;
return state.tokenize(stream, state);
indent: function (state, textAfter) {
var trueText = textAfter.replace(/^\s+|\s+$/g, '');
if (trueText.match(endKeywords) || trueText.match(middleKeywords) || trueText.match(/(\[])/))
return conf.indentUnit * (state.currentIndent - 1);
if (state.currentIndent < 0)
return state.currentIndent * conf.indentUnit;
electricInput: buildElectricInputRegEx(),
CodeMirror.defineMIME("text/x-oz", "oz");