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

Function tokenBase

static/editor.md/lib/codemirror/mode/groovy/groovy.js:30–76  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

28
29 var curPunc;
30 function tokenBase(stream, state) {
31 var ch = stream.next();
32 if (ch == '"' || ch == "'") {
33 return startString(ch, stream, state);
34 }
35 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
36 curPunc = ch;
37 return null;
38 }
39 if (/\d/.test(ch)) {
40 stream.eatWhile(/[\w\.]/);
41 if (stream.eat(/eE/)) { stream.eat(/\+\-/); stream.eatWhile(/\d/); }
42 return "number";
43 }
44 if (ch == "/") {
45 if (stream.eat("*")) {
46 state.tokenize.push(tokenComment);
47 return tokenComment(stream, state);
48 }
49 if (stream.eat("/")) {
50 stream.skipToEnd();
51 return "comment";
52 }
53 if (expectExpression(state.lastToken)) {
54 return startString(ch, stream, state);
55 }
56 }
57 if (ch == "-" && stream.eat(">")) {
58 curPunc = "->";
59 return null;
60 }
61 if (/[+\-*&%=<>!?|\/~]/.test(ch)) {
62 stream.eatWhile(/[+\-*&%=<>|~]/);
63 return "operator";
64 }
65 stream.eatWhile(/[\w\$_]/);
66 if (ch == "@") { stream.eatWhile(/[\w\$_\.]/); return "meta"; }
67 if (state.lastToken == ".") return "property";
68 if (stream.eat(":")) { curPunc = "proplabel"; return "property"; }
69 var cur = stream.current();
70 if (atoms.propertyIsEnumerable(cur)) { return "atom"; }
71 if (keywords.propertyIsEnumerable(cur)) {
72 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
73 return "keyword";
74 }
75 return "variable";
76 }
77 tokenBase.isBase = true;
78
79 function startString(quote, stream, state) {

Callers 1

tFunction · 0.70

Calls 3

startStringFunction · 0.70
tokenCommentFunction · 0.70
expectExpressionFunction · 0.70

Tested by

no test coverage detected