: 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("ebnf", function (config) {
var commentType = {slash: 0, parenthesis: 1};
var stateType = {comment: 0, _string: 1, characterClass: 2};
bracesMode = CodeMirror.getMode(config, config.bracesMode);
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(stateType._string);
} else if (stream.match(/^\/\*/)) { //comments starting with /*
state.stack.unshift(stateType.comment);
state.commentType = commentType.slash;
} else if (stream.match(/^\(\*/)) { //comments starting with (*
state.stack.unshift(stateType.comment);
state.commentType = commentType.parenthesis;
switch (state.stack[0]) {
while (state.stack[0] === stateType._string && !stream.eol()) {
if (stream.peek() === state.stringType) {
stream.next(); // Skip quote
state.stack.shift(); // Clear flag
} else if (stream.peek() === "\\") {
stream.match(/^.[^\\\"\']*/);
return state.lhs ? "property string" : "string"; // Token style
while (state.stack[0] === stateType.comment && !stream.eol()) {
if (state.commentType === commentType.slash && stream.match(/\*\//)) {
state.stack.shift(); // Clear flag
state.commentType = null;
} else if (state.commentType === commentType.parenthesis && stream.match(/\*\)/)) {
state.stack.shift(); // Clear flag
state.commentType = null;
stream.match(/^.[^\*]*/);
case stateType.characterClass:
while (state.stack[0] === stateType.characterClass && !stream.eol()) {
if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) {
var peek = stream.peek();
if (bracesMode !== null && (state.braced || peek === "{")) {
if (state.localState === null)
state.localState = CodeMirror.startState(bracesMode);
var token = bracesMode.token(stream, state.localState),
for (var i = 0; i < text.length; i++) {
if (state.braced === 0) {
token = "matchingbracket";
} else if (text[i] === "}") {
if (state.braced === 0) {
token = "matchingbracket";
state.stack.unshift(stateType.characterClass);
if (stream.match("%%")) {
} else if (stream.match(/[%][A-Za-z]+/)) {
} else if (stream.match(/[%][}]/)) {
return "matchingbracket";
if (stream.match(/[\/][A-Za-z]+/)) {
if (stream.match(/[\][a-z]+/)) {
if (stream.match(peek)) {
if (stream.match("$$")) {
} else if (stream.match(/[$][0-9]+/)) {
if (stream.match(/<<[a-zA-Z_]+>>/)) {
if (stream.match(/^\/\//)) {
} else if (stream.match(/return/)) {
} else if (stream.match(/^[a-zA-Z_][a-zA-Z0-9_]*/)) {
if (stream.match(/(?=[\(.])/)) {
} else if (stream.match(/(?=[\s\n]*[:=])/)) {
} else if (["[", "]", "(", ")"].indexOf(stream.peek()) != -1) {
} else if (!stream.eatSpace()) {
CodeMirror.defineMIME("text/x-ebnf", "ebnf");