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

Function tokenBase

static/editor.md/lib/codemirror/mode/d/d.js:27–75  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

25 var curPunc;
26
27 function tokenBase(stream, state) {
28 var ch = stream.next();
29 if (hooks[ch]) {
30 var result = hooks[ch](stream, state);
31 if (result !== false) return result;
32 }
33 if (ch == '"' || ch == "'" || ch == "`") {
34 state.tokenize = tokenString(ch);
35 return state.tokenize(stream, state);
36 }
37 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
38 curPunc = ch;
39 return null;
40 }
41 if (/\d/.test(ch)) {
42 stream.eatWhile(/[\w\.]/);
43 return "number";
44 }
45 if (ch == "/") {
46 if (stream.eat("+")) {
47 state.tokenize = tokenComment;
48 return tokenNestedComment(stream, state);
49 }
50 if (stream.eat("*")) {
51 state.tokenize = tokenComment;
52 return tokenComment(stream, state);
53 }
54 if (stream.eat("/")) {
55 stream.skipToEnd();
56 return "comment";
57 }
58 }
59 if (isOperatorChar.test(ch)) {
60 stream.eatWhile(isOperatorChar);
61 return "operator";
62 }
63 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
64 var cur = stream.current();
65 if (keywords.propertyIsEnumerable(cur)) {
66 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
67 return "keyword";
68 }
69 if (builtin.propertyIsEnumerable(cur)) {
70 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
71 return "builtin";
72 }
73 if (atoms.propertyIsEnumerable(cur)) return "atom";
74 return "variable";
75 }
76
77 function tokenString(quote) {
78 return function(stream, state) {

Callers

nothing calls this directly

Calls 3

tokenNestedCommentFunction · 0.85
tokenStringFunction · 0.70
tokenCommentFunction · 0.70

Tested by

no test coverage detected