(stream, state)
| 78 | } |
| 79 | |
| 80 | function jsTokenBase(stream, state) { |
| 81 | var ch = stream.next(); |
| 82 | if (ch == '"' || ch == "'") |
| 83 | return chain(stream, state, jsTokenString(ch)); |
| 84 | else if (/[\[\]{}\(\),;\:\.]/.test(ch)) |
| 85 | return ret(ch); |
| 86 | else if (ch == "0" && stream.eat(/x/i)) { |
| 87 | stream.eatWhile(/[\da-f]/i); |
| 88 | return ret("number", "number"); |
| 89 | } |
| 90 | else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) { |
| 91 | stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); |
| 92 | return ret("number", "number"); |
| 93 | } |
| 94 | else if (ch == "/") { |
| 95 | if (stream.eat("*")) { |
| 96 | return chain(stream, state, jsTokenComment); |
| 97 | } |
| 98 | else if (stream.eat("/")) { |
| 99 | stream.skipToEnd(); |
| 100 | return ret("comment", "comment"); |
| 101 | } |
| 102 | else if (state.lastType == "operator" || state.lastType == "keyword c" || |
| 103 | /^[\[{}\(,;:]$/.test(state.lastType)) { |
| 104 | nextUntilUnescaped(stream, "/"); |
| 105 | stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla |
| 106 | return ret("regexp", "string-2"); |
| 107 | } |
| 108 | else { |
| 109 | stream.eatWhile(isOperatorChar); |
| 110 | return ret("operator", null, stream.current()); |
| 111 | } |
| 112 | } |
| 113 | else if (ch == "#") { |
| 114 | stream.skipToEnd(); |
| 115 | return ret("error", "error"); |
| 116 | } |
| 117 | else if (isOperatorChar.test(ch)) { |
| 118 | stream.eatWhile(isOperatorChar); |
| 119 | return ret("operator", null, stream.current()); |
| 120 | } |
| 121 | else { |
| 122 | stream.eatWhile(/[\w\$_]/); |
| 123 | var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; |
| 124 | return (known && state.lastType != ".") ? ret(known.type, known.style, word) : |
| 125 | ret("variable", "variable", word); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | function jsTokenString(quote) { |
| 130 | return function(stream, state) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…