: 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("vb", function(conf, parserConf) {
var ERRORCLASS = 'error';
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
var singleOperators = new RegExp("^[\\+\\-\\*/%&\\\\|\\^~<>!]");
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
var doubleOperators = new RegExp("^((==)|(<>)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
var doubleDelimiters = new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
var tripleDelimiters = new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
var openingKeywords = ['class','module', 'sub','enum','select','while','if','function', 'get','set','property', 'try'];
var middleKeywords = ['else','elseif','case', 'catch'];
var endKeywords = ['next','loop'];
var operatorKeywords = ['and', 'or', 'not', 'xor', 'in'];
var wordOperators = wordRegexp(operatorKeywords);
var commonKeywords = ['as', 'dim', 'break', 'continue','optional', 'then', 'until',
'goto', 'byval','byref','new','handles','property', 'return',
'const','private', 'protected', 'friend', 'public', 'shared', 'static', 'true','false'];
var commontypes = ['integer','string','double','decimal','boolean','short','char', 'float','single'];
var keywords = wordRegexp(commonKeywords);
var types = wordRegexp(commontypes);
var stringPrefixes = '"';
var opening = wordRegexp(openingKeywords);
var middle = wordRegexp(middleKeywords);
var closing = wordRegexp(endKeywords);
var doubleClosing = wordRegexp(['end']);
var doOpening = wordRegexp(['do']);
CodeMirror.registerHelper("hintWords", "vb", openingKeywords.concat(middleKeywords).concat(endKeywords)
.concat(operatorKeywords).concat(commonKeywords).concat(commontypes));
function indent(_stream, state) {
function dedent(_stream, state) {
function tokenBase(stream, state) {
// Handle Number Literals
if (stream.match(/^((&H)|(&O))?[0-9\.a-f]/i, false)) {
var floatLiteral = false;
if (stream.match(/^\d*\.\d+F?/i)) { floatLiteral = true; }
else if (stream.match(/^\d+\.\d*F?/)) { floatLiteral = true; }
else if (stream.match(/^\.\d+F?/)) { floatLiteral = true; }
// Float literals may be "imaginary"
if (stream.match(/^&H[0-9a-f]+/i)) { intLiteral = true; }
else if (stream.match(/^&O[0-7]+/i)) { intLiteral = true; }
else if (stream.match(/^[1-9]\d*F?/)) {
// Decimal literals may be "imaginary"
// TODO - Can you have imaginary longs?
// Zero by itself with no other piece of number.
else if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
// Integer literals may be "long"
if (stream.match(stringPrefixes)) {
state.tokenize = tokenStringFactory(stream.current());
return state.tokenize(stream, state);
// Handle operators and Delimiters
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
if (stream.match(doubleOperators)
|| stream.match(singleOperators)
|| stream.match(wordOperators)) {
if (stream.match(singleDelimiters)) {
if (stream.match(doOpening)) {
state.doInCurrentLine = true;
if (stream.match(opening)) {
if (! state.doInCurrentLine)
state.doInCurrentLine = false;
if (stream.match(middle)) {
if (stream.match(doubleClosing)) {
if (stream.match(closing)) {
if (stream.match(types)) {
if (stream.match(keywords)) {
if (stream.match(identifiers)) {
// Handle non-detected items
function tokenStringFactory(delimiter) {
var singleline = delimiter.length == 1;
return function(stream, state) {
stream.eatWhile(/[^'"]/);
if (stream.match(delimiter)) {
state.tokenize = tokenBase;
if (parserConf.singleLineStringErrors) {
state.tokenize = tokenBase;
function tokenLexer(stream, state) {
var style = state.tokenize(stream, state);
var current = stream.current();
// Handle '.' connected identifiers
style = state.tokenize(stream, state);
current = stream.current();
if (style === 'variable') {
var delimiter_index = '[({'.indexOf(current);
if (delimiter_index !== -1) {
if (indentInfo === 'dedent') {
if (dedent(stream, state)) {
delimiter_index = '])}'.indexOf(current);
if (delimiter_index !== -1) {
if (dedent(stream, state)) {
electricChars:"dDpPtTfFeE ",
token: function(stream, state) {
state.currentIndent += state.nextLineIndent;
state.nextLineIndent = 0;
state.doInCurrentLine = 0;
var style = tokenLexer(stream, state);
state.lastToken = {style:style, content: stream.current()};
indent: function(state, textAfter) {
var trueText = textAfter.replace(/^\s+|\s+$/g, '') ;
if (trueText.match(closing) || trueText.match(doubleClosing) || trueText.match(middle)) return conf.indentUnit*(state.currentIndent-1);
if(state.currentIndent < 0) return 0;
return state.currentIndent * conf.indentUnit;
CodeMirror.defineMIME("text/x-vb", "vb");