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

Function tokenBase

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

Source from the content-addressed store, hash-verified

25 var curPunc;
26
27 function tokenBase(stream, state) {
28 curPunc = null;
29 var ch = stream.next();
30 if (ch == "#") {
31 stream.skipToEnd();
32 return "comment";
33 } else if (ch == "0" && stream.eat("x")) {
34 stream.eatWhile(/[\da-f]/i);
35 return "number";
36 } else if (ch == "." && stream.eat(/\d/)) {
37 stream.match(/\d*(?:e[+\-]?\d+)?/);
38 return "number";
39 } else if (/\d/.test(ch)) {
40 stream.match(/\d*(?:\.\d+)?(?:e[+\-]\d+)?L?/);
41 return "number";
42 } else if (ch == "'" || ch == '"') {
43 state.tokenize = tokenString(ch);
44 return "string";
45 } else if (ch == "." && stream.match(/.[.\d]+/)) {
46 return "keyword";
47 } else if (/[\w\.]/.test(ch) && ch != "_") {
48 stream.eatWhile(/[\w\.]/);
49 var word = stream.current();
50 if (atoms.propertyIsEnumerable(word)) return "atom";
51 if (keywords.propertyIsEnumerable(word)) {
52 // Block keywords start new blocks, except 'else if', which only starts
53 // one new block for the 'if', no block for the 'else'.
54 if (blockkeywords.propertyIsEnumerable(word) &&
55 !stream.match(/\s*if(\s+|$)/, false))
56 curPunc = "block";
57 return "keyword";
58 }
59 if (builtins.propertyIsEnumerable(word)) return "builtin";
60 return "variable";
61 } else if (ch == "%") {
62 if (stream.skipTo("%")) stream.next();
63 return "variable-2";
64 } else if (ch == "<" && stream.eat("-")) {
65 return "arrow";
66 } else if (ch == "=" && state.ctx.argList) {
67 return "arg-is";
68 } else if (opChars.test(ch)) {
69 if (ch == "$") return "dollar";
70 stream.eatWhile(opChars);
71 return "operator";
72 } else if (/[\(\){}\[\];]/.test(ch)) {
73 curPunc = ch;
74 if (ch == ";") return "semi";
75 return null;
76 } else {
77 return null;
78 }
79 }
80
81 function tokenString(quote) {
82 return function(stream, state) {

Callers

nothing calls this directly

Calls 1

tokenStringFunction · 0.70

Tested by

no test coverage detected