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

Function tokenBase

static/editor.md/lib/codemirror/mode/go/go.js:40–82  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

38 var curPunc;
39
40 function tokenBase(stream, state) {
41 var ch = stream.next();
42 if (ch == '"' || ch == "'" || ch == "`") {
43 state.tokenize = tokenString(ch);
44 return state.tokenize(stream, state);
45 }
46 if (/[\d\.]/.test(ch)) {
47 if (ch == ".") {
48 stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
49 } else if (ch == "0") {
50 stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
51 } else {
52 stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
53 }
54 return "number";
55 }
56 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
57 curPunc = ch;
58 return null;
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\$_\xa1-\uffff]/);
75 var cur = stream.current();
76 if (keywords.propertyIsEnumerable(cur)) {
77 if (cur == "case" || cur == "default") curPunc = "case";
78 return "keyword";
79 }
80 if (atoms.propertyIsEnumerable(cur)) return "atom";
81 return "variable";
82 }
83
84 function tokenString(quote) {
85 return function(stream, state) {

Callers

nothing calls this directly

Calls 2

tokenStringFunction · 0.70
tokenCommentFunction · 0.70

Tested by

no test coverage detected