(stream, state)
| 89 | } |
| 90 | |
| 91 | function tokenBase(stream, state) { |
| 92 | // whitespaces |
| 93 | if (stream.eatSpace()) return null |
| 94 | |
| 95 | // Handle one line Comments |
| 96 | if (stream.match('#{')) { |
| 97 | state.tokenize = tokenComment |
| 98 | stream.skipToEnd() |
| 99 | return 'comment' |
| 100 | } |
| 101 | |
| 102 | if (stream.match(/^#/)) { |
| 103 | stream.skipToEnd() |
| 104 | return 'comment' |
| 105 | } |
| 106 | |
| 107 | // Handle Number Literals |
| 108 | if (stream.match(/^[0-9.+-]/, false)) { |
| 109 | if (stream.match(/^[+-]?0x[0-9a-fA-F]+[ij]?/)) { |
| 110 | stream.tokenize = tokenBase |
| 111 | return 'number' |
| 112 | } |
| 113 | if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?[ij]?/)) { |
| 114 | return 'number' |
| 115 | } |
| 116 | if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?[ij]?/)) { |
| 117 | return 'number' |
| 118 | } |
| 119 | } |
| 120 | if (stream.match(wordRegexp(numberLiterals))) { |
| 121 | return 'number' |
| 122 | } |
| 123 | |
| 124 | // Handle Strings |
| 125 | let m = stream.match(/^"(?:[^"]|"")*("|$)/) || stream.match(/^'(?:[^']|'')*('|$)/) |
| 126 | if (m) { |
| 127 | return m[1] ? 'string' : 'string error' |
| 128 | } |
| 129 | |
| 130 | // Handle words |
| 131 | if (stream.match(keywords)) { |
| 132 | return 'keyword' |
| 133 | } |
| 134 | if (stream.match(builtins)) { |
| 135 | return 'builtin' |
| 136 | } |
| 137 | if (stream.match(physicalConstants)) { |
| 138 | return 'tag' |
| 139 | } |
| 140 | if (stream.match(units)) { |
| 141 | return 'attribute' |
| 142 | } |
| 143 | if (stream.match(identifiers)) { |
| 144 | return 'variable' |
| 145 | } |
| 146 | if (stream.match(singleOperators) || stream.match(doubleOperators)) { |
| 147 | return 'operator' |
| 148 | } |
no test coverage detected
searching dependent graphs…