|
| 1 | +/* Generated by `npm run build`, do not edit! */ |
| 2 | + |
| 3 | +"use strict" |
| 4 | + |
| 5 | +module.exports = function(Parser) { |
| 6 | + return /*@__PURE__*/(function (Parser) { |
| 7 | + function anonymous () { |
| 8 | + Parser.apply(this, arguments); |
| 9 | + } |
| 10 | + |
| 11 | + if ( Parser ) anonymous.__proto__ = Parser; |
| 12 | + anonymous.prototype = Object.create( Parser && Parser.prototype ); |
| 13 | + anonymous.prototype.constructor = anonymous; |
| 14 | + |
| 15 | + anonymous.prototype.readInt = function readInt (radix, len) { |
| 16 | + // Hack: len is only != null for unicode escape sequences, |
| 17 | + // where numeric separators are not allowed |
| 18 | + if (len != null) { return Parser.prototype.readInt.call(this, radix, len) } |
| 19 | + |
| 20 | + var start = this.pos, total = 0, acceptUnderscore = false |
| 21 | + for (;;) { |
| 22 | + var code = this.input.charCodeAt(this.pos), val = (void 0) |
| 23 | + if (code >= 97) { val = code - 97 + 10 } // a |
| 24 | + else if (code == 95) { |
| 25 | + if (!acceptUnderscore) { this.raise(this.pos, "Invalid numeric separator") } |
| 26 | + ++this.pos |
| 27 | + acceptUnderscore = false |
| 28 | + continue |
| 29 | + } else if (code >= 65) { val = code - 65 + 10 } // A |
| 30 | + else if (code >= 48 && code <= 57) { val = code - 48 } // 0-9 |
| 31 | + else { val = Infinity } |
| 32 | + if (val >= radix) { break } |
| 33 | + ++this.pos |
| 34 | + total = total * radix + val |
| 35 | + acceptUnderscore = true |
| 36 | + } |
| 37 | + if (this.pos === start) { return null } |
| 38 | + if (!acceptUnderscore) { this.raise(this.pos - 1, "Invalid numeric separator") } |
| 39 | + |
| 40 | + return total |
| 41 | + }; |
| 42 | + |
| 43 | + anonymous.prototype.readNumber = function readNumber (startsWithDot) { |
| 44 | + var token = Parser.prototype.readNumber.call(this, startsWithDot) |
| 45 | + var octal = this.end - this.start >= 2 && this.input.charCodeAt(this.start) === 48 |
| 46 | + var stripped = this.getNumberInput(this.start, this.end) |
| 47 | + if (stripped.length < this.end - this.start) { |
| 48 | + if (octal) { this.raise(this.start, "Invalid number") } |
| 49 | + this.value = parseFloat(stripped) |
| 50 | + } |
| 51 | + return token |
| 52 | + }; |
| 53 | + |
| 54 | + // This is used by acorn-bigint |
| 55 | + anonymous.prototype.getNumberInput = function getNumberInput (start, end) { |
| 56 | + return this.input.slice(start, end).replace(/_/g, "") |
| 57 | + }; |
| 58 | + |
| 59 | + return anonymous; |
| 60 | + }(Parser)) |
| 61 | +} |
0 commit comments