(lexer, start, firstCode)
| 1185 | ); |
| 1186 | } |
| 1187 | function readNumber(lexer, start, firstCode) { |
| 1188 | const body = lexer.source.body; |
| 1189 | let position = start; |
| 1190 | let code = firstCode; |
| 1191 | let isFloat = false; |
| 1192 | if (code === 45) { |
| 1193 | code = body.charCodeAt(++position); |
| 1194 | } |
| 1195 | if (code === 48) { |
| 1196 | code = body.charCodeAt(++position); |
| 1197 | if ((0, _characterClasses.isDigit)(code)) { |
| 1198 | throw (0, _syntaxError.syntaxError)( |
| 1199 | lexer.source, |
| 1200 | position, |
| 1201 | `Invalid number, unexpected digit after 0: ${printCodePointAt( |
| 1202 | lexer, |
| 1203 | position |
| 1204 | )}.` |
| 1205 | ); |
| 1206 | } |
| 1207 | } else { |
| 1208 | position = readDigits(lexer, position, code); |
| 1209 | code = body.charCodeAt(position); |
| 1210 | } |
| 1211 | if (code === 46) { |
| 1212 | isFloat = true; |
| 1213 | code = body.charCodeAt(++position); |
| 1214 | position = readDigits(lexer, position, code); |
| 1215 | code = body.charCodeAt(position); |
| 1216 | } |
| 1217 | if (code === 69 || code === 101) { |
| 1218 | isFloat = true; |
| 1219 | code = body.charCodeAt(++position); |
| 1220 | if (code === 43 || code === 45) { |
| 1221 | code = body.charCodeAt(++position); |
| 1222 | } |
| 1223 | position = readDigits(lexer, position, code); |
| 1224 | code = body.charCodeAt(position); |
| 1225 | } |
| 1226 | if (code === 46 || (0, _characterClasses.isNameStart)(code)) { |
| 1227 | throw (0, _syntaxError.syntaxError)( |
| 1228 | lexer.source, |
| 1229 | position, |
| 1230 | `Invalid number, expected digit but got: ${printCodePointAt( |
| 1231 | lexer, |
| 1232 | position |
| 1233 | )}.` |
| 1234 | ); |
| 1235 | } |
| 1236 | return createToken( |
| 1237 | lexer, |
| 1238 | isFloat ? _tokenKind.TokenKind.FLOAT : _tokenKind.TokenKind.INT, |
| 1239 | start, |
| 1240 | position, |
| 1241 | body.slice(start, position) |
| 1242 | ); |
| 1243 | } |
| 1244 | function readDigits(lexer, start, firstCode) { |
no test coverage detected