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

Function tokenBase

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

Source from the content-addressed store, hash-verified

25 var isOperatorChar = /[+\-*&%=<>!?|\/]/;
26
27 function tokenBase(stream, state) {
28 var ch = stream.next();
29 if (ch == "#" && state.startOfLine) {
30 stream.skipToEnd();
31 return "meta";
32 }
33 if (ch == '"' || ch == "'") {
34 state.tokenize = tokenString(ch);
35 return state.tokenize(stream, state);
36 }
37 if (ch == "(" && stream.eat("*")) {
38 state.tokenize = tokenComment;
39 return tokenComment(stream, state);
40 }
41 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
42 return null;
43 }
44 if (/\d/.test(ch)) {
45 stream.eatWhile(/[\w\.]/);
46 return "number";
47 }
48 if (ch == "/") {
49 if (stream.eat("/")) {
50 stream.skipToEnd();
51 return "comment";
52 }
53 }
54 if (isOperatorChar.test(ch)) {
55 stream.eatWhile(isOperatorChar);
56 return "operator";
57 }
58 stream.eatWhile(/[\w\$_]/);
59 var cur = stream.current();
60 if (keywords.propertyIsEnumerable(cur)) return "keyword";
61 if (atoms.propertyIsEnumerable(cur)) return "atom";
62 return "variable";
63 }
64
65 function tokenString(quote) {
66 return function(stream, state) {

Callers

nothing calls this directly

Calls 2

tokenStringFunction · 0.70
tokenCommentFunction · 0.70

Tested by

no test coverage detected