|
| 1 | +/* Generated by `npm run build`, do not edit! */ |
| 2 | + |
| 3 | +"use strict" |
| 4 | + |
| 5 | +var acorn = require("acorn") |
| 6 | +var tt = acorn.tokTypes |
| 7 | +var isIdentifierStart = acorn.isIdentifierStart |
| 8 | + |
| 9 | +module.exports = function(Parser) { |
| 10 | + return /*@__PURE__*/(function (Parser) { |
| 11 | + function anonymous () { |
| 12 | + Parser.apply(this, arguments); |
| 13 | + } |
| 14 | + |
| 15 | + if ( Parser ) anonymous.__proto__ = Parser; |
| 16 | + anonymous.prototype = Object.create( Parser && Parser.prototype ); |
| 17 | + anonymous.prototype.constructor = anonymous; |
| 18 | + |
| 19 | + anonymous.prototype.parseLiteral = function parseLiteral (value) { |
| 20 | + var node = Parser.prototype.parseLiteral.call(this, value) |
| 21 | + if (node.raw.charCodeAt(node.raw.length - 1) == 110) { node.bigint = this.getNumberInput(node.start, node.end) } |
| 22 | + return node |
| 23 | + }; |
| 24 | + |
| 25 | + anonymous.prototype.readRadixNumber = function readRadixNumber (radix) { |
| 26 | + var start = this.pos |
| 27 | + this.pos += 2 // 0x |
| 28 | + var val = this.readInt(radix) |
| 29 | + if (val === null) { this.raise(this.start + 2, ("Expected number in radix " + radix)) } |
| 30 | + if (this.input.charCodeAt(this.pos) == 110) { |
| 31 | + var str = this.getNumberInput(start, this.pos) |
| 32 | + val = typeof BigInt !== "undefined" ? BigInt(str) : null |
| 33 | + ++this.pos |
| 34 | + } else if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number") } |
| 35 | + return this.finishToken(tt.num, val) |
| 36 | + }; |
| 37 | + |
| 38 | + anonymous.prototype.readNumber = function readNumber (startsWithDot) { |
| 39 | + var start = this.pos |
| 40 | + |
| 41 | + // Not an int |
| 42 | + if (startsWithDot) { return Parser.prototype.readNumber.call(this, startsWithDot) } |
| 43 | + |
| 44 | + // Legacy octal |
| 45 | + if (this.input.charCodeAt(start) === 48 && this.input.charCodeAt(start + 1) !== 110) { |
| 46 | + return Parser.prototype.readNumber.call(this, startsWithDot) |
| 47 | + } |
| 48 | + |
| 49 | + if (this.readInt(10) === null) { this.raise(start, "Invalid number") } |
| 50 | + |
| 51 | + // Not a BigInt, reset and parse again |
| 52 | + if (this.input.charCodeAt(this.pos) != 110) { |
| 53 | + this.pos = start |
| 54 | + return Parser.prototype.readNumber.call(this, startsWithDot) |
| 55 | + } |
| 56 | + |
| 57 | + var str = this.getNumberInput(start, this.pos) |
| 58 | + var val = typeof BigInt !== "undefined" ? BigInt(str) : null |
| 59 | + ++this.pos |
| 60 | + return this.finishToken(tt.num, val) |
| 61 | + }; |
| 62 | + |
| 63 | + // This is basically a hook for acorn-numeric-separator |
| 64 | + anonymous.prototype.getNumberInput = function getNumberInput (start, end) { |
| 65 | + if (Parser.prototype.getNumberInput) { return Parser.prototype.getNumberInput.call(this, start, end) } |
| 66 | + return this.input.slice(start, end) |
| 67 | + }; |
| 68 | + |
| 69 | + return anonymous; |
| 70 | + }(Parser)) |
| 71 | +} |
0 commit comments