MCPcopy Create free account
hub / github.com/TruthHun/BookStack / tokenBase

Function tokenBase

static/editor.md/lib/codemirror/mode/idl/idl.js:244–279  ·  view source on GitHub ↗
(stream)

Source from the content-addressed store, hash-verified

242 var boolOperators = new RegExp('(and|or|eq|lt|le|gt|ge|ne|not)', 'i');
243
244 function tokenBase(stream) {
245 // whitespaces
246 if (stream.eatSpace()) return null;
247
248 // Handle one line Comments
249 if (stream.match(';')) {
250 stream.skipToEnd();
251 return 'comment';
252 }
253
254 // Handle Number Literals
255 if (stream.match(/^[0-9\.+-]/, false)) {
256 if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
257 return 'number';
258 if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
259 return 'number';
260 if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
261 return 'number';
262 }
263
264 // Handle Strings
265 if (stream.match(/^"([^"]|(""))*"/)) { return 'string'; }
266 if (stream.match(/^'([^']|(''))*'/)) { return 'string'; }
267
268 // Handle words
269 if (stream.match(keywords)) { return 'keyword'; }
270 if (stream.match(builtins)) { return 'builtin'; }
271 if (stream.match(identifiers)) { return 'variable'; }
272
273 if (stream.match(singleOperators) || stream.match(boolOperators)) {
274 return 'operator'; }
275
276 // Handle non-detected items
277 stream.next();
278 return null;
279 };
280
281 CodeMirror.defineMode('idl', function() {
282 return {

Callers 1

idl.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected