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

Function tokenBase

static/editor.md/lib/codemirror/mode/dylan/dylan.js:165–248  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

163 }
164
165 function tokenBase(stream, state) {
166 // String
167 var ch = stream.peek();
168 if (ch == "'" || ch == '"') {
169 stream.next();
170 return chain(stream, state, tokenString(ch, "string", "string"));
171 }
172 // Comment
173 else if (ch == "/") {
174 stream.next();
175 if (stream.eat("*")) {
176 return chain(stream, state, tokenComment);
177 } else if (stream.eat("/")) {
178 stream.skipToEnd();
179 return ret("comment", "comment");
180 } else {
181 stream.skipTo(" ");
182 return ret("operator", "operator");
183 }
184 }
185 // Decimal
186 else if (/\d/.test(ch)) {
187 stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
188 return ret("number", "number");
189 }
190 // Hash
191 else if (ch == "#") {
192 stream.next();
193 // Symbol with string syntax
194 ch = stream.peek();
195 if (ch == '"') {
196 stream.next();
197 return chain(stream, state, tokenString('"', "symbol", "string-2"));
198 }
199 // Binary number
200 else if (ch == "b") {
201 stream.next();
202 stream.eatWhile(/[01]/);
203 return ret("number", "number");
204 }
205 // Hex number
206 else if (ch == "x") {
207 stream.next();
208 stream.eatWhile(/[\da-f]/i);
209 return ret("number", "number");
210 }
211 // Octal number
212 else if (ch == "o") {
213 stream.next();
214 stream.eatWhile(/[0-7]/);
215 return ret("number", "number");
216 }
217 // Hash symbol
218 else {
219 stream.eatWhile(/[-a-zA-Z]/);
220 return ret("hash", "keyword");
221 }
222 } else if (stream.match("end")) {

Callers

nothing calls this directly

Calls 3

chainFunction · 0.70
tokenStringFunction · 0.70
retFunction · 0.70

Tested by

no test coverage detected