##// END OF EJS Templates
fix(pull-requests): fixes for rendering comments
fix(pull-requests): fixes for rendering comments

File last commit:

r4105:10488616 default
r5211:5e903185 default
Show More
mllike.js
359 lines | 8.5 KiB | application/javascript | JavascriptLexer
project: added all source files and assets
r1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
codemirror: bumped to version 5.49.2
r4105 // Distributed under an MIT license: https://codemirror.net/LICENSE
project: added all source files and assets
r1
(function(mod) {
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
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode('mllike', function(_config, parserConfig) {
var words = {
codemirror: bumped to version 5.49.2
r4105 'as': 'keyword',
project: added all source files and assets
r1 'do': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'else': 'keyword',
'end': 'keyword',
'exception': 'keyword',
project: added all source files and assets
r1 'fun': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'functor': 'keyword',
'if': 'keyword',
'in': 'keyword',
'include': 'keyword',
'let': 'keyword',
'of': 'keyword',
'open': 'keyword',
'rec': 'keyword',
'struct': 'keyword',
'then': 'keyword',
project: added all source files and assets
r1 'type': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'val': 'keyword',
'while': 'keyword',
'with': 'keyword'
project: added all source files and assets
r1 };
var extraWords = parserConfig.extraWords || {};
for (var prop in extraWords) {
if (extraWords.hasOwnProperty(prop)) {
words[prop] = parserConfig.extraWords[prop];
}
}
codemirror: bumped to version 5.49.2
r4105 var hintWords = [];
for (var k in words) { hintWords.push(k); }
CodeMirror.registerHelper("hintWords", "mllike", hintWords);
project: added all source files and assets
r1
function tokenBase(stream, state) {
var ch = stream.next();
if (ch === '"') {
state.tokenize = tokenString;
return state.tokenize(stream, state);
}
codemirror: bumped to version 5.49.2
r4105 if (ch === '{') {
if (stream.eat('|')) {
state.longString = true;
state.tokenize = tokenLongString;
return state.tokenize(stream, state);
}
}
project: added all source files and assets
r1 if (ch === '(') {
if (stream.eat('*')) {
state.commentLevel++;
state.tokenize = tokenComment;
return state.tokenize(stream, state);
}
}
codemirror: bumped to version 5.49.2
r4105 if (ch === '~' || ch === '?') {
project: added all source files and assets
r1 stream.eatWhile(/\w/);
return 'variable-2';
}
if (ch === '`') {
stream.eatWhile(/\w/);
return 'quote';
}
if (ch === '/' && parserConfig.slashComments && stream.eat('/')) {
stream.skipToEnd();
return 'comment';
}
if (/\d/.test(ch)) {
codemirror: bumped to version 5.49.2
r4105 if (ch === '0' && stream.eat(/[bB]/)) {
stream.eatWhile(/[01]/);
} if (ch === '0' && stream.eat(/[xX]/)) {
stream.eatWhile(/[0-9a-fA-F]/)
} if (ch === '0' && stream.eat(/[oO]/)) {
stream.eatWhile(/[0-7]/);
} else {
stream.eatWhile(/[\d_]/);
if (stream.eat('.')) {
stream.eatWhile(/[\d]/);
}
if (stream.eat(/[eE]/)) {
stream.eatWhile(/[\d\-+]/);
}
project: added all source files and assets
r1 }
return 'number';
}
codemirror: bumped to version 5.49.2
r4105 if ( /[+\-*&%=<>!?|@\.~:]/.test(ch)) {
project: added all source files and assets
r1 return 'operator';
}
codemirror: bumped to version 5.49.2
r4105 if (/[\w\xa1-\uffff]/.test(ch)) {
stream.eatWhile(/[\w\xa1-\uffff]/);
var cur = stream.current();
return words.hasOwnProperty(cur) ? words[cur] : 'variable';
}
return null
project: added all source files and assets
r1 }
function tokenString(stream, state) {
var next, end = false, escaped = false;
while ((next = stream.next()) != null) {
if (next === '"' && !escaped) {
end = true;
break;
}
escaped = !escaped && next === '\\';
}
if (end && !escaped) {
state.tokenize = tokenBase;
}
return 'string';
};
function tokenComment(stream, state) {
var prev, next;
while(state.commentLevel > 0 && (next = stream.next()) != null) {
if (prev === '(' && next === '*') state.commentLevel++;
if (prev === '*' && next === ')') state.commentLevel--;
prev = next;
}
if (state.commentLevel <= 0) {
state.tokenize = tokenBase;
}
return 'comment';
}
codemirror: bumped to version 5.49.2
r4105 function tokenLongString(stream, state) {
var prev, next;
while (state.longString && (next = stream.next()) != null) {
if (prev === '|' && next === '}') state.longString = false;
prev = next;
}
if (!state.longString) {
state.tokenize = tokenBase;
}
return 'string';
}
project: added all source files and assets
r1 return {
codemirror: bumped to version 5.49.2
r4105 startState: function() {return {tokenize: tokenBase, commentLevel: 0, longString: false};},
project: added all source files and assets
r1 token: function(stream, state) {
if (stream.eatSpace()) return null;
return state.tokenize(stream, state);
},
blockCommentStart: "(*",
blockCommentEnd: "*)",
lineComment: parserConfig.slashComments ? "//" : null
};
});
CodeMirror.defineMIME('text/x-ocaml', {
name: 'mllike',
extraWords: {
codemirror: bumped to version 5.49.2
r4105 'and': 'keyword',
'assert': 'keyword',
'begin': 'keyword',
'class': 'keyword',
'constraint': 'keyword',
'done': 'keyword',
'downto': 'keyword',
'external': 'keyword',
'function': 'keyword',
'initializer': 'keyword',
'lazy': 'keyword',
'match': 'keyword',
'method': 'keyword',
'module': 'keyword',
'mutable': 'keyword',
'new': 'keyword',
'nonrec': 'keyword',
'object': 'keyword',
'private': 'keyword',
'sig': 'keyword',
'to': 'keyword',
'try': 'keyword',
'value': 'keyword',
'virtual': 'keyword',
'when': 'keyword',
// builtins
'raise': 'builtin',
'failwith': 'builtin',
'true': 'builtin',
'false': 'builtin',
// Pervasives builtins
'asr': 'builtin',
'land': 'builtin',
'lor': 'builtin',
'lsl': 'builtin',
'lsr': 'builtin',
'lxor': 'builtin',
'mod': 'builtin',
'or': 'builtin',
// More Pervasives
'raise_notrace': 'builtin',
project: added all source files and assets
r1 'trace': 'builtin',
'exit': 'builtin',
'print_string': 'builtin',
'print_endline': 'builtin',
codemirror: bumped to version 5.49.2
r4105
'int': 'type',
'float': 'type',
'bool': 'type',
'char': 'type',
'string': 'type',
'unit': 'type',
// Modules
'List': 'builtin'
project: added all source files and assets
r1 }
});
CodeMirror.defineMIME('text/x-fsharp', {
name: 'mllike',
extraWords: {
'abstract': 'keyword',
'assert': 'keyword',
'base': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'begin': 'keyword',
project: added all source files and assets
r1 'class': 'keyword',
'default': 'keyword',
'delegate': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'do!': 'keyword',
'done': 'keyword',
project: added all source files and assets
r1 'downcast': 'keyword',
'downto': 'keyword',
'elif': 'keyword',
'extern': 'keyword',
'finally': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'for': 'keyword',
'function': 'keyword',
project: added all source files and assets
r1 'global': 'keyword',
'inherit': 'keyword',
'inline': 'keyword',
'interface': 'keyword',
'internal': 'keyword',
'lazy': 'keyword',
'let!': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'match': 'keyword',
'member': 'keyword',
project: added all source files and assets
r1 'module': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'mutable': 'keyword',
project: added all source files and assets
r1 'namespace': 'keyword',
'new': 'keyword',
'null': 'keyword',
'override': 'keyword',
'private': 'keyword',
'public': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'return!': 'keyword',
project: added all source files and assets
r1 'return': 'keyword',
'select': 'keyword',
'static': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'to': 'keyword',
'try': 'keyword',
project: added all source files and assets
r1 'upcast': 'keyword',
'use!': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'use': 'keyword',
'void': 'keyword',
project: added all source files and assets
r1 'when': 'keyword',
codemirror: bumped to version 5.49.2
r4105 'yield!': 'keyword',
project: added all source files and assets
r1 'yield': 'keyword',
codemirror: bumped to version 5.49.2
r4105 // Reserved words
'atomic': 'keyword',
'break': 'keyword',
'checked': 'keyword',
'component': 'keyword',
'const': 'keyword',
'constraint': 'keyword',
'constructor': 'keyword',
'continue': 'keyword',
'eager': 'keyword',
'event': 'keyword',
'external': 'keyword',
'fixed': 'keyword',
'method': 'keyword',
'mixin': 'keyword',
'object': 'keyword',
'parallel': 'keyword',
'process': 'keyword',
'protected': 'keyword',
'pure': 'keyword',
'sealed': 'keyword',
'tailcall': 'keyword',
'trait': 'keyword',
'virtual': 'keyword',
'volatile': 'keyword',
// builtins
project: added all source files and assets
r1 'List': 'builtin',
'Seq': 'builtin',
'Map': 'builtin',
'Set': 'builtin',
codemirror: bumped to version 5.49.2
r4105 'Option': 'builtin',
project: added all source files and assets
r1 'int': 'builtin',
'string': 'builtin',
'not': 'builtin',
'true': 'builtin',
codemirror: bumped to version 5.49.2
r4105 'false': 'builtin',
'raise': 'builtin',
'failwith': 'builtin'
},
slashComments: true
});
CodeMirror.defineMIME('text/x-sml', {
name: 'mllike',
extraWords: {
'abstype': 'keyword',
'and': 'keyword',
'andalso': 'keyword',
'case': 'keyword',
'datatype': 'keyword',
'fn': 'keyword',
'handle': 'keyword',
'infix': 'keyword',
'infixr': 'keyword',
'local': 'keyword',
'nonfix': 'keyword',
'op': 'keyword',
'orelse': 'keyword',
'raise': 'keyword',
'withtype': 'keyword',
'eqtype': 'keyword',
'sharing': 'keyword',
'sig': 'keyword',
'signature': 'keyword',
'structure': 'keyword',
'where': 'keyword',
'true': 'keyword',
'false': 'keyword',
// types
'int': 'builtin',
'real': 'builtin',
'string': 'builtin',
'char': 'builtin',
'bool': 'builtin'
project: added all source files and assets
r1 },
slashComments: true
});
});