(stream, state)
| 64 | } |
| 65 | |
| 66 | function tokenBase(stream, state) { |
| 67 | // whitespaces |
| 68 | if (stream.eatSpace()) return null; |
| 69 | |
| 70 | // Handle one line Comments |
| 71 | if (stream.match('%{')){ |
| 72 | state.tokenize = tokenComment; |
| 73 | stream.skipToEnd(); |
| 74 | return 'comment'; |
| 75 | } |
| 76 | |
| 77 | if (stream.match(/^[%#]/)){ |
| 78 | stream.skipToEnd(); |
| 79 | return 'comment'; |
| 80 | } |
| 81 | |
| 82 | // Handle Number Literals |
| 83 | if (stream.match(/^[0-9\.+-]/, false)) { |
| 84 | if (stream.match(/^[+-]?0x[0-9a-fA-F]+[ij]?/)) { |
| 85 | stream.tokenize = tokenBase; |
| 86 | return 'number'; }; |
| 87 | if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?[ij]?/)) { return 'number'; }; |
| 88 | if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?[ij]?/)) { return 'number'; }; |
| 89 | } |
| 90 | if (stream.match(wordRegexp(['nan','NaN','inf','Inf']))) { return 'number'; }; |
| 91 | |
| 92 | // Handle Strings |
| 93 | if (stream.match(/^"([^"]|(""))*"/)) { return 'string'; } ; |
| 94 | if (stream.match(/^'([^']|(''))*'/)) { return 'string'; } ; |
| 95 | |
| 96 | // Handle words |
| 97 | if (stream.match(keywords)) { return 'keyword'; } ; |
| 98 | if (stream.match(builtins)) { return 'builtin'; } ; |
| 99 | if (stream.match(identifiers)) { return 'variable'; } ; |
| 100 | |
| 101 | if (stream.match(singleOperators) || stream.match(doubleOperators)) { return 'operator'; }; |
| 102 | if (stream.match(singleDelimiters) || stream.match(doubleDelimiters) || stream.match(tripleDelimiters)) { return null; }; |
| 103 | |
| 104 | if (stream.match(expressionEnd)) { |
| 105 | state.tokenize = tokenTranspose; |
| 106 | return null; |
| 107 | }; |
| 108 | |
| 109 | |
| 110 | // Handle non-detected items |
| 111 | stream.next(); |
| 112 | return 'error'; |
| 113 | }; |
| 114 | |
| 115 | |
| 116 | return { |
no test coverage detected