mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
update Espree
This commit is contained in:
parent
a340e8b098
commit
dcb327605e
180
node_modules/espree/espree.js
generated
vendored
180
node_modules/espree/espree.js
generated
vendored
@ -427,27 +427,43 @@ function scanPunctuator() {
|
||||
case 41: // ) close bracket
|
||||
case 59: // ; semicolon
|
||||
case 44: // , comma
|
||||
case 123: // { open curly brace
|
||||
case 125: // } close curly brace
|
||||
case 91: // [
|
||||
case 93: // ]
|
||||
case 58: // :
|
||||
case 63: // ?
|
||||
case 126: // ~
|
||||
++index;
|
||||
if (extra.tokenize) {
|
||||
if (code === 40) {
|
||||
extra.openParenToken = extra.tokens.length;
|
||||
} else if (code === 123) {
|
||||
extra.openCurlyToken = extra.tokens.length;
|
||||
}
|
||||
|
||||
if (extra.tokenize && code === 40) {
|
||||
extra.openParenToken = extra.tokens.length;
|
||||
}
|
||||
|
||||
// 123 is {, 125 is }
|
||||
if (code === 123) {
|
||||
state.curlyStack.push("{");
|
||||
} else if (code === 125) {
|
||||
state.curlyStack.pop();
|
||||
return {
|
||||
type: Token.Punctuator,
|
||||
value: String.fromCharCode(code),
|
||||
lineNumber: lineNumber,
|
||||
lineStart: lineStart,
|
||||
range: [start, index]
|
||||
};
|
||||
|
||||
case 123: // { open curly brace
|
||||
case 125: // } close curly brace
|
||||
++index;
|
||||
|
||||
if (extra.tokenize && code === 123) {
|
||||
extra.openCurlyToken = extra.tokens.length;
|
||||
}
|
||||
|
||||
// lookahead2 function can cause tokens to be scanned twice and in doing so
|
||||
// would wreck the curly stack by pushing the same token onto the stack twice.
|
||||
// curlyLastIndex ensures each token is pushed or popped exactly once
|
||||
if (index > state.curlyLastIndex) {
|
||||
state.curlyLastIndex = index;
|
||||
if (code === 123) {
|
||||
state.curlyStack.push("{");
|
||||
} else {
|
||||
state.curlyStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@ -958,7 +974,6 @@ function scanTemplate() {
|
||||
var cooked = "",
|
||||
ch,
|
||||
escapedSequence,
|
||||
octal = false,
|
||||
start = index,
|
||||
terminated = false,
|
||||
tail = false,
|
||||
@ -983,8 +998,13 @@ function scanTemplate() {
|
||||
} else if (ch === "\\") {
|
||||
ch = source[index++];
|
||||
escapedSequence = scanEscapeSequence(ch);
|
||||
|
||||
if (escapedSequence.octal) {
|
||||
throwError({}, Messages.TemplateOctalLiteral);
|
||||
}
|
||||
|
||||
cooked += escapedSequence.ch;
|
||||
octal = escapedSequence.octal || octal;
|
||||
|
||||
} else if (syntax.isLineTerminator(ch.charCodeAt(0))) {
|
||||
++lineNumber;
|
||||
if (ch === "\r" && source[index] === "\n") {
|
||||
@ -1001,12 +1021,16 @@ function scanTemplate() {
|
||||
throwError({}, Messages.UnexpectedToken, "ILLEGAL");
|
||||
}
|
||||
|
||||
if (!tail) {
|
||||
state.curlyStack.push("template");
|
||||
}
|
||||
if (index > state.curlyLastIndex) {
|
||||
state.curlyLastIndex = index;
|
||||
|
||||
if (!head) {
|
||||
state.curlyStack.pop();
|
||||
if (!tail) {
|
||||
state.curlyStack.push("template");
|
||||
}
|
||||
|
||||
if (!head) {
|
||||
state.curlyStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@ -1017,40 +1041,12 @@ function scanTemplate() {
|
||||
},
|
||||
head: head,
|
||||
tail: tail,
|
||||
octal: octal,
|
||||
lineNumber: lineNumber,
|
||||
lineStart: lineStart,
|
||||
range: [start, index]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan a template string element and return a ASTNode representation
|
||||
* @param {Object} options Scan options
|
||||
* @param {Object} options.head True if this element is the first in the
|
||||
* template string, false otherwise.
|
||||
* @returns {ASTNode} The template element node
|
||||
* @private
|
||||
*/
|
||||
function scanTemplateElement(options) {
|
||||
var startsWith, template;
|
||||
|
||||
lookahead = null;
|
||||
skipComment();
|
||||
|
||||
startsWith = (options.head) ? "`" : "}";
|
||||
|
||||
if (source[index] !== startsWith) {
|
||||
throwError({}, Messages.UnexpectedToken, "ILLEGAL");
|
||||
}
|
||||
|
||||
template = scanTemplate();
|
||||
|
||||
peek();
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
function testRegExp(pattern, flags) {
|
||||
var tmp = pattern,
|
||||
validFlags = "gmsi";
|
||||
@ -1484,22 +1480,6 @@ function lex() {
|
||||
lineNumber = token.lineNumber;
|
||||
lineStart = token.lineStart;
|
||||
|
||||
if (token.type === Token.Template) {
|
||||
if (token.tail) {
|
||||
state.curlyStack.pop();
|
||||
} else {
|
||||
state.curlyStack.push("template");
|
||||
}
|
||||
}
|
||||
|
||||
if (token.value === "{") {
|
||||
state.curlyStack.push("{");
|
||||
}
|
||||
|
||||
if (token.value === "}") {
|
||||
state.curlyStack.pop();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
@ -2435,7 +2415,7 @@ function tryParseMethodDefinition(token, key, computed, marker) {
|
||||
rest: null
|
||||
};
|
||||
if (match(")")) {
|
||||
throwErrorTolerant(lookahead, Messages.UnexpectedToken);
|
||||
throwErrorTolerant(lookahead, Messages.UnexpectedToken, lookahead.value);
|
||||
} else {
|
||||
parseParam(options);
|
||||
if (options.defaultCount === 0) {
|
||||
@ -2506,7 +2486,8 @@ function parseObjectProperty() {
|
||||
* Check for getters and setters. Be careful! "get" and "set" are legal
|
||||
* method names. It's only a getter or setter if followed by a space.
|
||||
*/
|
||||
if (token.value === "get" && !(match(":") || match("("))) {
|
||||
if (token.value === "get" &&
|
||||
!(match(":") || match("(") || match(",") || match("}"))) {
|
||||
computed = (lookahead.value === "[");
|
||||
key = parseObjectPropertyKey();
|
||||
methodMarker = markerCreate();
|
||||
@ -2530,7 +2511,8 @@ function parseObjectProperty() {
|
||||
);
|
||||
}
|
||||
|
||||
if (token.value === "set" && !(match(":") || match("("))) {
|
||||
if (token.value === "set" &&
|
||||
!(match(":") || match("(") || match(",") || match("}"))) {
|
||||
computed = (lookahead.value === "[");
|
||||
key = parseObjectPropertyKey();
|
||||
methodMarker = markerCreate();
|
||||
@ -2775,19 +2757,32 @@ function parseObjectInitialiser() {
|
||||
|
||||
/**
|
||||
* Parse a template string element and return its ASTNode representation
|
||||
* @param {Object} options Parsing & scanning options
|
||||
* @param {Object} options.head True if this element is the first in the
|
||||
* @param {Object} option Parsing & scanning options
|
||||
* @param {Object} option.head True if this element is the first in the
|
||||
* template string, false otherwise.
|
||||
* @returns {ASTNode} The template element node with marker info applied
|
||||
* @private
|
||||
*/
|
||||
function parseTemplateElement(options) {
|
||||
var marker = markerCreate(),
|
||||
token = scanTemplateElement(options);
|
||||
if (strict && token.octal) {
|
||||
throwError(token, Messages.StrictOctalLiteral);
|
||||
function parseTemplateElement(option) {
|
||||
var marker, token;
|
||||
|
||||
if (lookahead.type !== Token.Template || (option.head && !lookahead.head)) {
|
||||
throwError({}, Messages.UnexpectedToken, "ILLEGAL");
|
||||
}
|
||||
return markerApply(marker, astNodeFactory.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail));
|
||||
|
||||
marker = markerCreate();
|
||||
token = lex();
|
||||
|
||||
return markerApply(
|
||||
marker,
|
||||
astNodeFactory.createTemplateElement(
|
||||
{
|
||||
raw: token.value.raw,
|
||||
cooked: token.value.cooked
|
||||
},
|
||||
token.tail
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3003,7 +2998,7 @@ function parseLeftHandSideExpressionAllowCall() {
|
||||
expr = markerApply(marker, astNodeFactory.createMemberExpression("[", expr, parseComputedMember()));
|
||||
} else if (match(".")) {
|
||||
expr = markerApply(marker, astNodeFactory.createMemberExpression(".", expr, parseNonComputedMember()));
|
||||
} else if (!lookahead.tail) {
|
||||
} else {
|
||||
expr = markerApply(marker, astNodeFactory.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
|
||||
}
|
||||
}
|
||||
@ -4137,7 +4132,11 @@ function parseThrowStatement() {
|
||||
|
||||
function parseCatchClause() {
|
||||
var param, body,
|
||||
marker = markerCreate();
|
||||
marker = markerCreate(),
|
||||
allowDestructuring = extra.ecmaFeatures.destructuring,
|
||||
options = {
|
||||
paramSet: new StringMap()
|
||||
};
|
||||
|
||||
expectKeyword("catch");
|
||||
|
||||
@ -4146,9 +4145,25 @@ function parseCatchClause() {
|
||||
throwUnexpected(lookahead);
|
||||
}
|
||||
|
||||
param = parseVariableIdentifier();
|
||||
if (match("[")) {
|
||||
if (!allowDestructuring) {
|
||||
throwUnexpected(lookahead);
|
||||
}
|
||||
param = parseArrayInitialiser();
|
||||
reinterpretAsDestructuredParameter(options, param);
|
||||
} else if (match("{")) {
|
||||
|
||||
if (!allowDestructuring) {
|
||||
throwUnexpected(lookahead);
|
||||
}
|
||||
param = parseObjectInitialiser();
|
||||
reinterpretAsDestructuredParameter(options, param);
|
||||
} else {
|
||||
param = parseVariableIdentifier();
|
||||
}
|
||||
|
||||
// 12.14.1
|
||||
if (strict && syntax.isRestrictedWord(param.name)) {
|
||||
if (strict && param.name && syntax.isRestrictedWord(param.name)) {
|
||||
throwErrorTolerant({}, Messages.StrictCatchVariable);
|
||||
}
|
||||
|
||||
@ -5219,6 +5234,8 @@ function tokenize(code, options) {
|
||||
inSwitch: false,
|
||||
lastCommentStart: -1,
|
||||
yieldAllowed: false,
|
||||
curlyStack: [],
|
||||
curlyLastIndex: 0,
|
||||
inJSXSpreadAttribute: false,
|
||||
inJSXChild: false,
|
||||
inJSXTag: false
|
||||
@ -5240,9 +5257,6 @@ function tokenize(code, options) {
|
||||
extra.openParenToken = -1;
|
||||
extra.openCurlyToken = -1;
|
||||
|
||||
// Needed when using template string tokenization
|
||||
state.curlyStack = [];
|
||||
|
||||
extra.range = (typeof options.range === "boolean") && options.range;
|
||||
extra.loc = (typeof options.loc === "boolean") && options.loc;
|
||||
|
||||
@ -5324,6 +5338,8 @@ function parse(code, options) {
|
||||
inSwitch: false,
|
||||
lastCommentStart: -1,
|
||||
yieldAllowed: false,
|
||||
curlyStack: [],
|
||||
curlyLastIndex: 0,
|
||||
inJSXSpreadAttribute: false,
|
||||
inJSXChild: false,
|
||||
inJSXTag: false
|
||||
|
||||
1
node_modules/espree/lib/messages.js
generated
vendored
1
node_modules/espree/lib/messages.js
generated
vendored
@ -68,6 +68,7 @@ module.exports = {
|
||||
StrictVarName: "Variable name may not be eval or arguments in strict mode",
|
||||
StrictParamName: "Parameter name eval or arguments is not allowed in strict mode",
|
||||
StrictParamDupe: "Strict mode function may not have duplicate parameter names",
|
||||
TemplateOctalLiteral: "Octal literals are not allowed in template strings.",
|
||||
ParameterAfterRestParameter: "Rest parameter must be final parameter of an argument list",
|
||||
DefaultRestParameter: "Rest parameter can not have a default value",
|
||||
ElementAfterSpreadElement: "Spread must be the final element of an element list",
|
||||
|
||||
8
node_modules/espree/package.json
generated
vendored
8
node_modules/espree/package.json
generated
vendored
File diff suppressed because one or more lines are too long
@ -17,7 +17,7 @@
|
||||
"bluebird": "~2.9.14",
|
||||
"catharsis": "~0.8.6",
|
||||
"escape-string-regexp": "~1.0.2",
|
||||
"espree": "~1.12.0",
|
||||
"espree": "~1.12.3",
|
||||
"js2xmlparser": "~0.1.7",
|
||||
"marked": "~0.3.2",
|
||||
"requizzle": "~0.2.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user