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

Function tokenBase

static/js/codemirror/mode/shell/shell.js:25–64  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

23 'touch vi vim wall wc wget who write yes zsh');
24
25 function tokenBase(stream, state) {
26
27 var sol = stream.sol();
28 var ch = stream.next();
29
30 if (ch === '\'' || ch === '"' || ch === '`') {
31 state.tokens.unshift(tokenString(ch));
32 return tokenize(stream, state);
33 }
34 if (ch === '#') {
35 if (sol && stream.eat('!')) {
36 stream.skipToEnd();
37 return 'meta'; // 'comment'?
38 }
39 stream.skipToEnd();
40 return 'comment';
41 }
42 if (ch === '$') {
43 state.tokens.unshift(tokenDollar);
44 return tokenize(stream, state);
45 }
46 if (ch === '+' || ch === '=') {
47 return 'operator';
48 }
49 if (ch === '-') {
50 stream.eat('-');
51 stream.eatWhile(/\w/);
52 return 'attribute';
53 }
54 if (/\d/.test(ch)) {
55 stream.eatWhile(/\d/);
56 if(!/\w/.test(stream.peek())) {
57 return 'number';
58 }
59 }
60 stream.eatWhile(/\w/);
61 var cur = stream.current();
62 if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
63 return words.hasOwnProperty(cur) ? words[cur] : null;
64 }
65
66 function tokenString(quote) {
67 return function(stream, state) {

Callers

nothing calls this directly

Calls 4

tokenStringFunction · 0.70
tokenizeFunction · 0.70
nextMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected