: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
cp = this.codePointAt(this.index);
if (!character_1.Character.isIdentifierPart(cp)) {
ch = character_1.Character.fromCodePoint(cp);
// '\u' (U+005C, U+0075) denotes an escaped character.
id = id.substr(0, id.length - 1);
if (this.source.charCodeAt(this.index) !== 0x75) {
this.throwUnexpectedToken();
if (this.source[this.index] === '{') {
ch = this.scanUnicodeCodePointEscape();
ch = this.scanHexEscape('u');
if (ch === null || ch === '\\' || !character_1.Character.isIdentifierPart(ch.charCodeAt(0))) {
this.throwUnexpectedToken();
Scanner.prototype.octalToDecimal = function (ch) {
// \0 is not octal escape sequence
var octal = (ch !== '0');
var code = octalValue(ch);
if (!this.eof() && character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
code = code * 8 + octalValue(this.source[this.index++]);
// 3 digits are only allowed when string starts
if ('0123'.indexOf(ch) >= 0 && !this.eof() && character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
code = code * 8 + octalValue(this.source[this.index++]);
// https://tc39.github.io/ecma262/#sec-names-and-keywords
Scanner.prototype.scanIdentifier = function () {
// Backslash (U+005C) starts an escaped character.
var id = (this.source.charCodeAt(start) === 0x5C) ? this.getComplexIdentifier() : this.getIdentifier();
// There is no keyword or literal with only one character.
// Thus, it must be an identifier.
type = 3 /* Identifier */;
else if (this.isKeyword(id)) {
else if (id === 'null') {
type = 5 /* NullLiteral */;
else if (id === 'true' || id === 'false') {
type = 1 /* BooleanLiteral */;
type = 3 /* Identifier */;
if (type !== 3 /* Identifier */ && (start + id.length !== this.index)) {
var restore = this.index;
this.tolerateUnexpectedToken(messages_1.Messages.InvalidEscapedReservedWord);
lineNumber: this.lineNumber,
lineStart: this.lineStart,
// https://tc39.github.io/ecma262/#sec-punctuators
Scanner.prototype.scanPunctuator = function () {
// Check for most common single-character punctuators.
var str = this.source[this.index];
this.curlyStack.push('{');
if (this.source[this.index] === '.' && this.source[this.index + 1] === '.') {
// 4-character punctuator.
str = this.source.substr(this.index, 4);
// 3-character punctuators.
if (str === '===' || str === '!==' || str === '>>>' ||
str === '<<=' || str === '>>=' || str === '**=') {
// 2-character punctuators.
if (str === '&&' || str === '||' || str === '==' || str === '!=' ||
str === '+=' || str === '-=' || str === '*=' || str === '/=' ||
str === '++' || str === '--' || str === '<<' || str === '>>' ||
str === '&=' || str === '|=' || str === '^=' || str === '%=' ||
str === '<=' || str === '>=' || str === '=>' || str === '**') {
// 1-character punctuators.
str = this.source[this.index];
if ('<>=!+-*%&|^/'.indexOf(str) >= 0) {
if (this.index === start) {
this.throwUnexpectedToken();
type: 7 /* Punctuator */,
lineNumber: this.lineNumber,
lineStart: this.lineStart,
// https://tc39.github.io/ecma262/#sec-literals-numeric-literals
Scanner.prototype.scanHexLiteral = function (start) {
if (!character_1.Character.isHexDigit(this.source.charCodeAt(this.index))) {
num += this.source[this.index++];
this.throwUnexpectedToken();
if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index))) {
this.throwUnexpectedToken();
type: 6 /* NumericLiteral */,
value: parseInt('0x' + num, 16),
lineNumber: this.lineNumber,
lineStart: this.lineStart,
Scanner.prototype.scanBinaryLiteral = function (start) {
ch = this.source[this.index];
if (ch !== '0' && ch !== '1') {
num += this.source[this.index++];
this.throwUnexpectedToken();
ch = this.source.charCodeAt(this.index);
/* istanbul ignore else */
if (character_1.Character.isIdentifierStart(ch) || character_1.Character.isDecimalDigit(ch)) {
this.throwUnexpectedToken();
type: 6 /* NumericLiteral */,
lineNumber: this.lineNumber,
lineStart: this.lineStart,
Scanner.prototype.scanOctalLiteral = function (prefix, start) {
if (character_1.Character.isOctalDigit(prefix.charCodeAt(0))) {
num = '0' + this.source[this.index++];
if (!character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
num += this.source[this.index++];
if (!octal && num.length === 0) {
this.throwUnexpectedToken();
if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index)) || character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
this.throwUnexpectedToken();
type: 6 /* NumericLiteral */,
lineNumber: this.lineNumber,
lineStart: this.lineStart,
Scanner.prototype.isImplicitOctalLiteral = function () {
// Implicit octal, unless there is a non-octal digit.
// (Annex B.1.1 on Numeric Literals)
for (var i = this.index + 1; i < this.length; ++i) {
if (ch === '8' || ch === '9') {
if (!character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
Scanner.prototype.scanNumericLiteral = function () {
var ch = this.source[start];
assert_1.assert(character_1.Character.isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), 'Numeric literal must start with a decimal digit or a decimal point');
num = this.source[this.index++];
ch = this.source[this.index];
// Hex number starts with '0x'.
// Octal number starts with '0'.
// Octal number in ES6 starts with '0o'.
// Binary number in ES6 starts with '0b'.
if (ch === 'x' || ch === 'X') {
return this.scanHexLiteral(start);
if (ch === 'b' || ch === 'B') {
return this.scanBinaryLiteral(start);
if (ch === 'o' || ch === 'O') {
return this.scanOctalLiteral(ch, start);
if (ch && character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
if (this.isImplicitOctalLiteral()) {
return this.scanOctalLiteral(ch, start);
while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
num += this.source[this.index++];
ch = this.source[this.index];
num += this.source[this.index++];
while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
num += this.source[this.index++];
ch = this.source[this.index];
if (ch === 'e' || ch === 'E') {
num += this.source[this.index++];
ch = this.source[this.index];
if (ch === '+' || ch === '-') {
num += this.source[this.index++];
if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
num += this.source[this.index++];
this.throwUnexpectedToken();
if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index))) {
this.throwUnexpectedToken();
type: 6 /* NumericLiteral */,
lineNumber: this.lineNumber,
lineStart: this.lineStart,
// https://tc39.github.io/ecma262/#sec-literals-string-literals
Scanner.prototype.scanStringLiteral = function () {
var quote = this.source[start];
assert_1.assert((quote === '\'' || quote === '"'), 'String literal must starts with a quote');
var ch = this.source[this.index++];
ch = this.source[this.index++];
if (!ch || !character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
if (this.source[this.index] === '{') {
str += this.scanUnicodeCodePointEscape();
var unescaped_1 = this.scanHexEscape(ch);
if (unescaped_1 === null) {
this.throwUnexpectedToken();
var unescaped = this.scanHexEscape(ch);
if (unescaped === null) {
this.throwUnexpectedToken(messages_1.Messages.InvalidHexEscapeSequence);
this.tolerateUnexpectedToken();
if (ch && character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
var octToDec = this.octalToDecimal(ch);
octal = octToDec.octal || octal;
str += String.fromCharCode(octToDec.code);
if (ch === '\r' && this.source[this.index] === '\n') {
this.lineStart = this.index;
else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
this.throwUnexpectedToken();
type: 8 /* StringLiteral */,
lineNumber: this.lineNumber,
lineStart: this.lineStart,
// https://tc39.github.io/ecma262/#sec-template-literal-lexical-components
Scanner.prototype.scanTemplate = function () {
var head = (this.source[start] === '`');
var ch = this.source[this.index++];
if (this.source[this.index] === '{') {
this.curlyStack.push('${');
ch = this.source[this.index++];
if (!character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
if (this.source[this.index] === '{') {
cooked += this.scanUnicodeCodePointEscape();
var restore = this.index;
var unescaped_2 = this.scanHexEscape(ch);
if (unescaped_2 !== null) {
var unescaped = this.scanHexEscape(ch);
if (unescaped === null) {
this.throwUnexpectedToken(messages_1.Messages.InvalidHexEscapeSequence);