Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var Parser = require('babylon/lib/parser').default;
var _tokenizerTypes = require('babylon/lib/tokenizer/types');
var Tokenizer = require('babylon/lib/tokenizer').default;
// Add tokenizer type.
_tokenizerTypes.types.questionDot = new _tokenizerTypes.TokenType("?.", { beforeExpr: true });
_tokenizerTypes.types.questionParenL = new _tokenizerTypes.TokenType("?(", { beforeExpr: true, startsExpr: true });
// Tokenize "?(" and "?.".
const originalGetTokenFromCode = Tokenizer.prototype.getTokenFromCode;
Tokenizer.prototype.getTokenFromCode = function getTokenFromCode(code) {
if (code === 63) {
var next = this.input.charCodeAt(this.state.pos + 1);
switch (next) {
case 40:
this.state.pos += 2;
return this.finishToken(_tokenizerTypes.types.questionParenL);
case 46:
this.state.pos += 2;
return this.finishToken(_tokenizerTypes.types.questionDot);
}
}
return originalGetTokenFromCode.apply(this, arguments);
};
// Parse SafeMemberExpression.
var Parser = require('babylon/lib/parser').default;
var _tokenizerTypes = require('babylon/lib/tokenizer/types');
var Tokenizer = require('babylon/lib/tokenizer').default;
// Add tokenizer type.
_tokenizerTypes.types.questionDot = new _tokenizerTypes.TokenType("?.", { beforeExpr: true });
_tokenizerTypes.types.questionParenL = new _tokenizerTypes.TokenType("?(", { beforeExpr: true, startsExpr: true });
// Tokenize "?(" and "?.".
const originalGetTokenFromCode = Tokenizer.prototype.getTokenFromCode;
Tokenizer.prototype.getTokenFromCode = function getTokenFromCode(code) {
if (code === 63) {
var next = this.input.charCodeAt(this.state.pos + 1);
switch (next) {
case 40:
this.state.pos += 2;
return this.finishToken(_tokenizerTypes.types.questionParenL);
case 46:
this.state.pos += 2;
return this.finishToken(_tokenizerTypes.types.questionDot);
}
}
return originalGetTokenFromCode.apply(this, arguments);
};
// Parse SafeMemberExpression.
const originalParseSubscripts = Parser.prototype.parseSubscripts;