(stream, state)
| 45 | } |
| 46 | |
| 47 | function jsTokenBase(stream, state) { |
| 48 | var ch = stream.next(); |
| 49 | if (ch == '"' || ch == "'") |
| 50 | return chain(stream, state, jsTokenString(ch)); |
| 51 | else if (/[\[\]{}\(\),;\:\.]/.test(ch)) |
| 52 | return ret(ch); |
| 53 | else if (ch == "0" && stream.eat(/x/i)) { |
| 54 | stream.eatWhile(/[\da-f]/i); |
| 55 | return ret("number", "number"); |
| 56 | } |
| 57 | else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) { |
| 58 | stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); |
| 59 | return ret("number", "number"); |
| 60 | } |
| 61 | else if (ch == "/") { |
| 62 | if (stream.eat("*")) { |
| 63 | return chain(stream, state, jsTokenComment); |
| 64 | } |
| 65 | else if (stream.eat("/")) { |
| 66 | stream.skipToEnd(); |
| 67 | return ret("comment", "comment"); |
| 68 | } |
| 69 | else if (state.reAllowed) { |
| 70 | nextUntilUnescaped(stream, "/"); |
| 71 | stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla |
| 72 | return ret("regexp", "string-2"); |
| 73 | } |
| 74 | else { |
| 75 | stream.eatWhile(isOperatorChar); |
| 76 | return ret("operator", null, stream.current()); |
| 77 | } |
| 78 | } |
| 79 | else if (ch == "#") { |
| 80 | stream.skipToEnd(); |
| 81 | return ret("error", "error"); |
| 82 | } |
| 83 | else if (isOperatorChar.test(ch)) { |
| 84 | stream.eatWhile(isOperatorChar); |
| 85 | return ret("operator", null, stream.current()); |
| 86 | } |
| 87 | else { |
| 88 | stream.eatWhile(/[\w\$_]/); |
| 89 | var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; |
| 90 | return (known && state.kwAllowed) ? ret(known.type, known.style, word) : |
| 91 | ret("variable", "variable", word); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | function jsTokenString(quote) { |
| 96 | return function(stream, state) { |
nothing calls this directly
no test coverage detected