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

Function tokenBase

static/editor.md/lib/codemirror/mode/pig/pig.js:67–130  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

65 }
66
67 function tokenBase(stream, state) {
68 var ch = stream.next();
69
70 // is a start of string?
71 if (ch == '"' || ch == "'")
72 return chain(stream, state, tokenString(ch));
73 // is it one of the special chars
74 else if(/[\[\]{}\(\),;\.]/.test(ch))
75 return ret(ch);
76 // is it a number?
77 else if(/\d/.test(ch)) {
78 stream.eatWhile(/[\w\.]/);
79 return ret("number", "number");
80 }
81 // multi line comment or operator
82 else if (ch == "/") {
83 if (stream.eat("*")) {
84 return chain(stream, state, tokenComment);
85 }
86 else {
87 stream.eatWhile(isOperatorChar);
88 return ret("operator", "operator");
89 }
90 }
91 // single line comment or operator
92 else if (ch=="-") {
93 if(stream.eat("-")){
94 stream.skipToEnd();
95 return ret("comment", "comment");
96 }
97 else {
98 stream.eatWhile(isOperatorChar);
99 return ret("operator", "operator");
100 }
101 }
102 // is it an operator
103 else if (isOperatorChar.test(ch)) {
104 stream.eatWhile(isOperatorChar);
105 return ret("operator", "operator");
106 }
107 else {
108 // get the while word
109 stream.eatWhile(/[\w\$_]/);
110 // is it one of the listed keywords?
111 if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
112 if (stream.eat(")") || stream.eat(".")) {
113 //keywords can be used as variables like flatten(group), group.$0 etc..
114 }
115 else {
116 return ("keyword", "keyword");
117 }
118 }
119 // is it one of the builtin functions?
120 if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase()))
121 {
122 return ("keyword", "variable-2");
123 }
124 // is it one of the listed types?

Callers

nothing calls this directly

Calls 3

chainFunction · 0.70
tokenStringFunction · 0.70
retFunction · 0.70

Tested by

no test coverage detected