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

Function tokenBase

static/editor.md/lib/codemirror/mode/turtle/turtle.js:25–75  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

23 var operatorChars = /[*+\-<>=&|]/;
24
25 function tokenBase(stream, state) {
26 var ch = stream.next();
27 curPunc = null;
28 if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) {
29 stream.match(/^[^\s\u00a0>]*>?/);
30 return "atom";
31 }
32 else if (ch == "\"" || ch == "'") {
33 state.tokenize = tokenLiteral(ch);
34 return state.tokenize(stream, state);
35 }
36 else if (/[{}\(\),\.;\[\]]/.test(ch)) {
37 curPunc = ch;
38 return null;
39 }
40 else if (ch == "#") {
41 stream.skipToEnd();
42 return "comment";
43 }
44 else if (operatorChars.test(ch)) {
45 stream.eatWhile(operatorChars);
46 return null;
47 }
48 else if (ch == ":") {
49 return "operator";
50 } else {
51 stream.eatWhile(/[_\w\d]/);
52 if(stream.peek() == ":") {
53 return "variable-3";
54 } else {
55 var word = stream.current();
56
57 if(keywords.test(word)) {
58 return "meta";
59 }
60
61 if(ch >= "A" && ch <= "Z") {
62 return "comment";
63 } else {
64 return "keyword";
65 }
66 }
67 var word = stream.current();
68 if (ops.test(word))
69 return null;
70 else if (keywords.test(word))
71 return "meta";
72 else
73 return "variable";
74 }
75 }
76
77 function tokenLiteral(quote) {
78 return function(stream, state) {

Callers

nothing calls this directly

Calls 1

tokenLiteralFunction · 0.70

Tested by

no test coverage detected