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

Function tokenBase

static/editor.md/lib/codemirror/mode/ecl/ecl.js:42–106  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

40 var curPunc;
41
42 function tokenBase(stream, state) {
43 var ch = stream.next();
44 if (hooks[ch]) {
45 var result = hooks[ch](stream, state);
46 if (result !== false) return result;
47 }
48 if (ch == '"' || ch == "'") {
49 state.tokenize = tokenString(ch);
50 return state.tokenize(stream, state);
51 }
52 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
53 curPunc = ch;
54 return null;
55 }
56 if (/\d/.test(ch)) {
57 stream.eatWhile(/[\w\.]/);
58 return "number";
59 }
60 if (ch == "/") {
61 if (stream.eat("*")) {
62 state.tokenize = tokenComment;
63 return tokenComment(stream, state);
64 }
65 if (stream.eat("/")) {
66 stream.skipToEnd();
67 return "comment";
68 }
69 }
70 if (isOperatorChar.test(ch)) {
71 stream.eatWhile(isOperatorChar);
72 return "operator";
73 }
74 stream.eatWhile(/[\w\$_]/);
75 var cur = stream.current().toLowerCase();
76 if (keyword.propertyIsEnumerable(cur)) {
77 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
78 return "keyword";
79 } else if (variable.propertyIsEnumerable(cur)) {
80 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
81 return "variable";
82 } else if (variable_2.propertyIsEnumerable(cur)) {
83 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
84 return "variable-2";
85 } else if (variable_3.propertyIsEnumerable(cur)) {
86 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
87 return "variable-3";
88 } else if (builtin.propertyIsEnumerable(cur)) {
89 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
90 return "builtin";
91 } else { //Data types are of from KEYWORD##
92 var i = cur.length - 1;
93 while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
94 --i;
95
96 if (i > 0) {
97 var cur2 = cur.substr(0, i + 1);
98 if (variable_3.propertyIsEnumerable(cur2)) {
99 if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";

Callers

nothing calls this directly

Calls 2

tokenStringFunction · 0.70
tokenCommentFunction · 0.70

Tested by

no test coverage detected