()
| 162 | // Scan the next JSX token. This replaces Scanner#lex when in JSX mode. |
| 163 | |
| 164 | lexJSX(): RawJSXToken { |
| 165 | const cp = this.scanner.source.charCodeAt(this.scanner.index); |
| 166 | |
| 167 | // < > / : = { } |
| 168 | if (cp === 60 || cp === 62 || cp === 47 || cp === 58 || cp === 61 || cp === 123 || cp === 125) { |
| 169 | const value = this.scanner.source[this.scanner.index++]; |
| 170 | return { |
| 171 | type: Token.Punctuator, |
| 172 | value: value, |
| 173 | lineNumber: this.scanner.lineNumber, |
| 174 | lineStart: this.scanner.lineStart, |
| 175 | start: this.scanner.index - 1, |
| 176 | end: this.scanner.index |
| 177 | }; |
| 178 | } |
| 179 | |
| 180 | // " ' |
| 181 | if (cp === 34 || cp === 39) { |
| 182 | const start = this.scanner.index; |
| 183 | const quote = this.scanner.source[this.scanner.index++]; |
| 184 | let str = ''; |
| 185 | while (!this.scanner.eof()) { |
| 186 | const ch = this.scanner.source[this.scanner.index++]; |
| 187 | if (ch === quote) { |
| 188 | break; |
| 189 | } else if (ch === '&') { |
| 190 | str += this.scanXHTMLEntity(quote); |
| 191 | } else { |
| 192 | str += ch; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | return { |
| 197 | type: Token.StringLiteral, |
| 198 | value: str, |
| 199 | lineNumber: this.scanner.lineNumber, |
| 200 | lineStart: this.scanner.lineStart, |
| 201 | start: start, |
| 202 | end: this.scanner.index |
| 203 | }; |
| 204 | } |
| 205 | |
| 206 | // ... or . |
| 207 | if (cp === 46) { |
| 208 | const n1 = this.scanner.source.charCodeAt(this.scanner.index + 1); |
| 209 | const n2 = this.scanner.source.charCodeAt(this.scanner.index + 2); |
| 210 | const value = (n1 === 46 && n2 === 46) ? '...' : '.'; |
| 211 | const start = this.scanner.index; |
| 212 | this.scanner.index += value.length; |
| 213 | return { |
| 214 | type: Token.Punctuator, |
| 215 | value: value, |
| 216 | lineNumber: this.scanner.lineNumber, |
| 217 | lineStart: this.scanner.lineStart, |
| 218 | start: start, |
| 219 | end: this.scanner.index |
| 220 | }; |
| 221 | } |
no test coverage detected