MCPcopy
hub / github.com/pandao/editor.md / tokenBase

Function tokenBase

lib/codemirror/mode/shell/shell.js:38–82  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

36 'touch vi vim wall wc wget who write yes zsh');
37
38 function tokenBase(stream, state) {
39 if (stream.eatSpace()) return null;
40
41 var sol = stream.sol();
42 var ch = stream.next();
43
44 if (ch === '\\') {
45 stream.next();
46 return null;
47 }
48 if (ch === '\'' || ch === '"' || ch === '`') {
49 state.tokens.unshift(tokenString(ch));
50 return tokenize(stream, state);
51 }
52 if (ch === '#') {
53 if (sol && stream.eat('!')) {
54 stream.skipToEnd();
55 return 'meta'; // 'comment'?
56 }
57 stream.skipToEnd();
58 return 'comment';
59 }
60 if (ch === '$') {
61 state.tokens.unshift(tokenDollar);
62 return tokenize(stream, state);
63 }
64 if (ch === '+' || ch === '=') {
65 return 'operator';
66 }
67 if (ch === '-') {
68 stream.eat('-');
69 stream.eatWhile(/\w/);
70 return 'attribute';
71 }
72 if (/\d/.test(ch)) {
73 stream.eatWhile(/\d/);
74 if(stream.eol() || !/\w/.test(stream.peek())) {
75 return 'number';
76 }
77 }
78 stream.eatWhile(/[\w-]/);
79 var cur = stream.current();
80 if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
81 return words.hasOwnProperty(cur) ? words[cur] : null;
82 }
83
84 function tokenString(quote) {
85 return function(stream, state) {

Callers

nothing calls this directly

Calls 2

tokenStringFunction · 0.70
tokenizeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…