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

Function tokenBase

static/editor.md/lib/codemirror/mode/tcl/tcl.js:41–91  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

39 return f(stream, state);
40 }
41 function tokenBase(stream, state) {
42 var beforeParams = state.beforeParams;
43 state.beforeParams = false;
44 var ch = stream.next();
45 if ((ch == '"' || ch == "'") && state.inParams)
46 return chain(stream, state, tokenString(ch));
47 else if (/[\[\]{}\(\),;\.]/.test(ch)) {
48 if (ch == "(" && beforeParams) state.inParams = true;
49 else if (ch == ")") state.inParams = false;
50 return null;
51 }
52 else if (/\d/.test(ch)) {
53 stream.eatWhile(/[\w\.]/);
54 return "number";
55 }
56 else if (ch == "#" && stream.eat("*")) {
57 return chain(stream, state, tokenComment);
58 }
59 else if (ch == "#" && stream.match(/ *\[ *\[/)) {
60 return chain(stream, state, tokenUnparsed);
61 }
62 else if (ch == "#" && stream.eat("#")) {
63 stream.skipToEnd();
64 return "comment";
65 }
66 else if (ch == '"') {
67 stream.skipTo(/"/);
68 return "comment";
69 }
70 else if (ch == "$") {
71 stream.eatWhile(/[$_a-z0-9A-Z\.{:]/);
72 stream.eatWhile(/}/);
73 state.beforeParams = true;
74 return "builtin";
75 }
76 else if (isOperatorChar.test(ch)) {
77 stream.eatWhile(isOperatorChar);
78 return "comment";
79 }
80 else {
81 stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);
82 var word = stream.current().toLowerCase();
83 if (keywords && keywords.propertyIsEnumerable(word))
84 return "keyword";
85 if (functions && functions.propertyIsEnumerable(word)) {
86 state.beforeParams = true;
87 return "keyword";
88 }
89 return null;
90 }
91 }
92 function tokenString(quote) {
93 return function(stream, state) {
94 var escaped = false, next, end = false;

Callers

nothing calls this directly

Calls 2

chainFunction · 0.70
tokenStringFunction · 0.70

Tested by

no test coverage detected