()
| 206 | } |
| 207 | |
| 208 | private parseNumber(): number { |
| 209 | const start = this.index; |
| 210 | |
| 211 | // Check explicitly for signed Infinity |
| 212 | if (this.text.startsWith('-Infinity', this.index)) { |
| 213 | this.index += '-Infinity'.length; |
| 214 | return -Infinity; |
| 215 | } |
| 216 | if (this.text.startsWith('+Infinity', this.index)) { |
| 217 | this.index += '+Infinity'.length; |
| 218 | return Infinity; |
| 219 | } |
| 220 | if (this.text.startsWith('Infinity', this.index)) { |
| 221 | this.index += 'Infinity'.length; |
| 222 | return Infinity; |
| 223 | } |
| 224 | |
| 225 | // Otherwise, collect a typical number literal. |
| 226 | while (!this.isAtEnd() && /[0-9+\-_.eE]/.test(this.currentChar())) { |
| 227 | this.index++; |
| 228 | } |
| 229 | const token = this.text.slice(start, this.index); |
| 230 | // Remove underscores (allowed in JSON5) |
| 231 | const normalized = token.replace(/_/g, ''); |
| 232 | const num = Number(normalized); |
| 233 | if (isNaN(num)) { |
| 234 | throw this.error(`Invalid number: ${token}`); |
| 235 | } |
| 236 | return num; |
| 237 | } |
| 238 | |
| 239 | private parseIdentifier(): any { |
| 240 | const start = this.index; |
no test coverage detected