MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / tokenBase

Function tokenBase

static/js/codemirror/mode/css/css.js:191–249  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

189 function ret(style, tp) {type = tp; return style;}
190
191 function tokenBase(stream, state) {
192 var ch = stream.next();
193 if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current());}
194 else if (ch == "/" && stream.eat("*")) {
195 state.tokenize = tokenCComment;
196 return tokenCComment(stream, state);
197 }
198 else if (ch == "<" && stream.eat("!")) {
199 state.tokenize = tokenSGMLComment;
200 return tokenSGMLComment(stream, state);
201 }
202 else if (ch == "=") ret(null, "compare");
203 else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
204 else if (ch == "\"" || ch == "'") {
205 state.tokenize = tokenString(ch);
206 return state.tokenize(stream, state);
207 }
208 else if (ch == "#") {
209 stream.eatWhile(/[\w\\\-]/);
210 return ret("atom", "hash");
211 }
212 else if (ch == "!") {
213 stream.match(/^\s*\w*/);
214 return ret("keyword", "important");
215 }
216 else if (/\d/.test(ch)) {
217 stream.eatWhile(/[\w.%]/);
218 return ret("number", "unit");
219 }
220 else if (ch === "-") {
221 if (/\d/.test(stream.peek())) {
222 stream.eatWhile(/[\w.%]/);
223 return ret("number", "unit");
224 } else if (stream.match(/^[^-]+-/)) {
225 return ret("meta", "meta");
226 }
227 }
228 else if (/[,+>*\/]/.test(ch)) {
229 return ret(null, "select-op");
230 }
231 else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
232 return ret("qualifier", "qualifier");
233 }
234 else if (ch == ":") {
235 return ret("operator", ch);
236 }
237 else if (/[;{}\[\]\(\)]/.test(ch)) {
238 return ret(null, ch);
239 }
240 else if (ch == "u" && stream.match("rl(")) {
241 stream.backUp(1);
242 state.tokenize = tokenParenthesized;
243 return ret("property", "variable");
244 }
245 else {
246 stream.eatWhile(/[\w\\\-]/);
247 return ret("property", "variable");
248 }

Callers

nothing calls this directly

Calls 7

retFunction · 0.70
tokenCCommentFunction · 0.70
tokenSGMLCommentFunction · 0.70
tokenStringFunction · 0.70
nextMethod · 0.45
matchMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected