// 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('mllike', function(_config, parserConfig) {
var extraWords = parserConfig.extraWords || {};
for (var prop in extraWords) {
if (extraWords.hasOwnProperty(prop)) {
words[prop] = parserConfig.extraWords[prop];
function tokenBase(stream, state) {
state.tokenize = tokenString;
return state.tokenize(stream, state);
state.tokenize = tokenComment;
return state.tokenize(stream, state);
if (ch === '/' && parserConfig.slashComments && stream.eat('/')) {
if ( /[+\-*&%=<>!?|]/.test(ch)) {
var cur = stream.current();
return words.hasOwnProperty(cur) ? words[cur] : 'variable';
function tokenString(stream, state) {
var next, end = false, escaped = false;
while ((next = stream.next()) != null) {
if (next === '"' && !escaped) {
escaped = !escaped && next === '\\';
state.tokenize = tokenBase;
function tokenComment(stream, state) {
while(state.commentLevel > 0 && (next = stream.next()) != null) {
if (prev === '(' && next === '*') state.commentLevel++;
if (prev === '*' && next === ')') state.commentLevel--;
if (state.commentLevel <= 0) {
state.tokenize = tokenBase;
startState: function() {return {tokenize: tokenBase, commentLevel: 0};},
token: function(stream, state) {
if (stream.eatSpace()) return null;
return state.tokenize(stream, state);
lineComment: parserConfig.slashComments ? "//" : null
CodeMirror.defineMIME('text/x-ocaml', {
'print_string': 'builtin',
'print_endline': 'builtin',
CodeMirror.defineMIME('text/x-fsharp', {