(stream, state)
| 37 | define('builtin', commonCommands); |
| 38 | |
| 39 | function tokenBase(stream, state) { |
| 40 | if (stream.eatSpace()) return null; |
| 41 | |
| 42 | var sol = stream.sol(); |
| 43 | var ch = stream.next(); |
| 44 | |
| 45 | if (ch === '\\') { |
| 46 | stream.next(); |
| 47 | return null; |
| 48 | } |
| 49 | if (ch === '\'' || ch === '"' || ch === '`') { |
| 50 | state.tokens.unshift(tokenString(ch, ch === "`" ? "quote" : "string")); |
| 51 | return tokenize(stream, state); |
| 52 | } |
| 53 | if (ch === '#') { |
| 54 | if (sol && stream.eat('!')) { |
| 55 | stream.skipToEnd(); |
| 56 | return 'meta'; // 'comment'? |
| 57 | } |
| 58 | stream.skipToEnd(); |
| 59 | return 'comment'; |
| 60 | } |
| 61 | if (ch === '$') { |
| 62 | state.tokens.unshift(tokenDollar); |
| 63 | return tokenize(stream, state); |
| 64 | } |
| 65 | if (ch === '+' || ch === '=') { |
| 66 | return 'operator'; |
| 67 | } |
| 68 | if (ch === '-') { |
| 69 | stream.eat('-'); |
| 70 | stream.eatWhile(/\w/); |
| 71 | return 'attribute'; |
| 72 | } |
| 73 | if (ch == "<") { |
| 74 | if (stream.match("<<")) return "operator" |
| 75 | var heredoc = stream.match(/^<-?\s*['"]?([^'"]*)['"]?/) |
| 76 | if (heredoc) { |
| 77 | state.tokens.unshift(tokenHeredoc(heredoc[1])) |
| 78 | return 'string-2' |
| 79 | } |
| 80 | } |
| 81 | if (/\d/.test(ch)) { |
| 82 | stream.eatWhile(/\d/); |
| 83 | if(stream.eol() || !/\w/.test(stream.peek())) { |
| 84 | return 'number'; |
| 85 | } |
| 86 | } |
| 87 | stream.eatWhile(/[\w-]/); |
| 88 | var cur = stream.current(); |
| 89 | if (stream.peek() === '=' && /\w+/.test(cur)) return 'def'; |
| 90 | return words.hasOwnProperty(cur) ? words[cur] : null; |
| 91 | } |
| 92 | |
| 93 | function tokenString(quote, style) { |
| 94 | var close = quote == "(" ? ")" : quote == "{" ? "}" : quote |
nothing calls this directly
no test coverage detected