Comparing version 2.0.1 to 2.0.4
@@ -371,3 +371,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.acorn || (g.acorn = {})).loose = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
elem.value = { | ||
raw: this.input.slice(this.tok.start, this.tok.end), | ||
raw: this.input.slice(this.tok.start, this.tok.end).replace(/\r\n?/g, "\n"), | ||
cooked: this.tok.value | ||
@@ -529,2 +529,3 @@ }; | ||
node.type = "AssignmentPattern"; | ||
delete node.operator; | ||
break; | ||
@@ -531,0 +532,0 @@ } |
@@ -359,3 +359,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.acorn || (g.acorn = {})).walk = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
base.Class = function (node, st, c) { | ||
c(node.id, st, "Pattern"); | ||
if (node.id) c(node.id, st, "Pattern"); | ||
if (node.superClass) c(node.superClass, st, "Expression"); | ||
@@ -362,0 +362,0 @@ for (var i = 0; i < node.body.body.length; i++) { |
@@ -6,3 +6,3 @@ { | ||
"main": "dist/acorn.js", | ||
"version": "2.0.1", | ||
"version": "2.0.4", | ||
"engines": { | ||
@@ -30,3 +30,3 @@ "node": ">=0.4.0" | ||
"test": "node test/run.js", | ||
"prepublish": "bin/prepublish.sh" | ||
"prepublish": "node bin/build-acorn.js && node bin/without_eval > dist/acorn_csp.js" | ||
}, | ||
@@ -33,0 +33,0 @@ "bin": { |
@@ -43,3 +43,3 @@ # Acorn | ||
be an abstract syntax tree object as specified by the | ||
[Mozilla Parser API][mozapi]. | ||
[ESTree spec][estree]. | ||
@@ -52,3 +52,3 @@ When encountering a syntax error, the parser will raise a | ||
[mozapi]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API | ||
[estree]: https://github.com/estree/estree | ||
@@ -133,3 +133,3 @@ - **ecmaVersion**: Indicates the ECMAScript version to parse. Must be | ||
rather than the `loc` object, which holds line/column data. To also | ||
add a [semi-standardized][range] "range" property holding a | ||
add a [semi-standardized][range] `range` property holding a | ||
`[start, end]` array with the same numbers, set the `ranges` option | ||
@@ -253,3 +253,3 @@ to `true`. | ||
object with properties whose names correspond to node types in the | ||
[Mozilla Parser API][mozapi]. The properties should contain functions | ||
[ESTree spec][estree]. The properties should contain functions | ||
that will be called with the node object and, if applicable the state | ||
@@ -358,3 +358,3 @@ at that point. The last two arguments are optional. `base` is a walker | ||
`acorn.plugins`, which holds a function. Calling `acorn.parse`, a | ||
`plugin` option can be passed, holding an object mapping plugin names | ||
`plugins` option can be passed, holding an object mapping plugin names | ||
to configuration values (or just `true` for plugins that don't take | ||
@@ -361,0 +361,0 @@ options). After the parser object has been created, the initialization |
@@ -32,3 +32,4 @@ // A recursive descent parser operates by defining functions for all | ||
pp.checkPropClash = function(prop, propHash) { | ||
if (this.options.ecmaVersion >= 6) return | ||
if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) | ||
return | ||
let key = prop.key, name | ||
@@ -40,3 +41,11 @@ switch (key.type) { | ||
} | ||
let kind = prop.kind || "init", other | ||
let kind = prop.kind | ||
if (this.options.ecmaVersion >= 6) { | ||
if (name === "__proto__" && kind === "init") { | ||
if (propHash.proto) this.raise(key.start, "Redefinition of __proto__ property"); | ||
propHash.proto = true | ||
} | ||
return | ||
} | ||
let other | ||
if (has(propHash, name)) { | ||
@@ -246,4 +255,6 @@ other = propHash[name] | ||
switch (this.type) { | ||
case tt._super: | ||
if (!this.inFunction) | ||
this.raise(this.start, "'super' outside of function or class") | ||
case tt._this: | ||
case tt._super: | ||
let type = this.type === tt._this ? "ThisExpression" : "Super" | ||
@@ -360,3 +371,3 @@ node = this.startNode() | ||
if (innerParenStart) this.unexpected(innerParenStart) | ||
return this.parseParenArrowList(startPos, startLoc, exprList) | ||
return this.parseParenArrowList(startPos, startLoc, exprList) | ||
} | ||
@@ -424,3 +435,3 @@ | ||
elem.value = { | ||
raw: this.input.slice(this.start, this.end), | ||
raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, '\n'), | ||
cooked: this.value | ||
@@ -496,2 +507,10 @@ } | ||
prop.value = this.parseMethod(false) | ||
let paramCount = prop.kind === "get" ? 0 : 1 | ||
if (prop.value.params.length !== paramCount) { | ||
let start = prop.value.start | ||
if (prop.kind === "get") | ||
this.raise(start, "getter should have no params"); | ||
else | ||
this.raise(start, "setter should have exactly one param") | ||
} | ||
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { | ||
@@ -550,7 +569,4 @@ prop.kind = "init" | ||
node.generator = isGenerator | ||
allowExpressionBody = true | ||
} else { | ||
allowExpressionBody = false | ||
} | ||
this.parseFunctionBody(node, allowExpressionBody) | ||
this.parseFunctionBody(node, false) | ||
return this.finishNode(node, "FunctionExpression") | ||
@@ -557,0 +573,0 @@ } |
@@ -40,3 +40,3 @@ // Acorn is a tiny, fast JavaScript parser written in JavaScript. | ||
export const version = "2.0.1" | ||
export const version = "2.0.4" | ||
@@ -43,0 +43,0 @@ // The main exported interface (under `self.acorn` when in the |
@@ -298,3 +298,3 @@ import {LooseParser} from "./state" | ||
elem.value = { | ||
raw: this.input.slice(this.tok.start, this.tok.end), | ||
raw: this.input.slice(this.tok.start, this.tok.end).replace(/\r\n?/g, '\n'), | ||
cooked: this.tok.value | ||
@@ -451,2 +451,3 @@ } | ||
node.type = "AssignmentPattern" | ||
delete node.operator | ||
break | ||
@@ -453,0 +454,0 @@ } |
@@ -37,2 +37,3 @@ import {types as tt} from "./tokentype" | ||
node.type = "AssignmentPattern" | ||
delete node.operator | ||
} else { | ||
@@ -39,0 +40,0 @@ this.raise(node.left.end, "Only '=' operator can be used for specifying default value.") |
@@ -301,3 +301,10 @@ import {types as tt} from "./tokentype" | ||
let kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null | ||
this.labels.push({name: maybeName, kind: kind}) | ||
for (let i = this.labels.length - 1; i >= 0; i--) { | ||
let label = this.labels[i] | ||
if (label.statementStart == node.start) { | ||
label.statementStart = this.start; | ||
label.kind = kind; | ||
} else break; | ||
} | ||
this.labels.push({name: maybeName, kind: kind, statementStart: this.start}) | ||
node.body = this.parseStatement(true) | ||
@@ -437,5 +444,5 @@ this.labels.pop() | ||
method.kind = "method" | ||
let isGetSet = false | ||
if (!method.computed) { | ||
let {key} = method | ||
let isGetSet = false | ||
if (!isGenerator && key.type === "Identifier" && this.type !== tt.parenL && (key.name === "get" || key.name === "set")) { | ||
@@ -456,2 +463,12 @@ isGetSet = true | ||
this.parseClassMethod(classBody, method, isGenerator) | ||
if (isGetSet) { | ||
let paramCount = method.kind === "get" ? 0 : 1 | ||
if (method.value.params.length !== paramCount) { | ||
let start = method.value.start | ||
if (method.kind === "get") | ||
this.raise(start, "getter should have no params"); | ||
else | ||
this.raise(start, "setter should have exactly one param") | ||
} | ||
} | ||
} | ||
@@ -458,0 +475,0 @@ node.body = this.finishNode(classBody, "ClassBody") |
@@ -29,3 +29,3 @@ import {isIdentifierStart, isIdentifierChar} from "./identifier" | ||
// Are we running under Rhino? | ||
const isRhino = typeof Packages !== "undefined" | ||
const isRhino = typeof Packages == "object" && Object.prototype.toString.call(Packages) == "[object JavaPackage]" | ||
@@ -417,3 +417,8 @@ // Move to the next token | ||
// be replaced by `[x-b]` which throws an error. | ||
tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]+)\}|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x") | ||
tmp = tmp.replace(/\\u\{([0-9a-fA-F]+)\}/g, (match, code, offset) => { | ||
code = Number("0x" + code) | ||
if (code > 0x10FFFF) this.raise(start + offset + 3, "Code point out of bounds") | ||
return "x" | ||
}); | ||
tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x") | ||
} | ||
@@ -504,6 +509,6 @@ } | ||
if (this.options.ecmaVersion < 6) this.unexpected() | ||
++this.pos | ||
let codePos = ++this.pos | ||
code = this.readHexChar(this.input.indexOf('}', this.pos) - this.pos) | ||
++this.pos | ||
if (code > 0x10FFFF) this.unexpected() | ||
if (code > 0x10FFFF) this.raise(codePos, "Code point out of bounds") | ||
} else { | ||
@@ -530,3 +535,3 @@ code = this.readHexChar(4) | ||
out += this.input.slice(chunkStart, this.pos) | ||
out += this.readEscapedChar() | ||
out += this.readEscapedChar(false) | ||
chunkStart = this.pos | ||
@@ -564,3 +569,3 @@ } else { | ||
out += this.input.slice(chunkStart, this.pos) | ||
out += this.readEscapedChar() | ||
out += this.readEscapedChar(true) | ||
chunkStart = this.pos | ||
@@ -570,7 +575,11 @@ } else if (isNewLine(ch)) { | ||
++this.pos | ||
if (ch === 13 && this.input.charCodeAt(this.pos) === 10) { | ||
++this.pos | ||
out += "\n" | ||
} else { | ||
out += String.fromCharCode(ch) | ||
switch (ch) { | ||
case 13: | ||
if (this.input.charCodeAt(this.pos) === 10) ++this.pos; | ||
case 10: | ||
out += "\n"; | ||
break; | ||
default: | ||
out += String.fromCharCode(ch); | ||
break; | ||
} | ||
@@ -590,30 +599,33 @@ if (this.options.locations) { | ||
pp.readEscapedChar = function() { | ||
pp.readEscapedChar = function(inTemplate) { | ||
let ch = this.input.charCodeAt(++this.pos) | ||
let octal = /^[0-7]+/.exec(this.input.slice(this.pos, this.pos + 3)) | ||
if (octal) octal = octal[0] | ||
while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1) | ||
if (octal === "0") octal = null | ||
++this.pos | ||
if (octal) { | ||
if (this.strict) this.raise(this.pos - 2, "Octal literal in strict mode") | ||
this.pos += octal.length - 1 | ||
return String.fromCharCode(parseInt(octal, 8)) | ||
} else { | ||
switch (ch) { | ||
case 110: return "\n"; // 'n' -> '\n' | ||
case 114: return "\r"; // 'r' -> '\r' | ||
case 120: return String.fromCharCode(this.readHexChar(2)); // 'x' | ||
case 117: return codePointToString(this.readCodePoint()); // 'u' | ||
case 116: return "\t"; // 't' -> '\t' | ||
case 98: return "\b"; // 'b' -> '\b' | ||
case 118: return "\u000b"; // 'v' -> '\u000b' | ||
case 102: return "\f"; // 'f' -> '\f' | ||
case 48: return "\0"; // 0 -> '\0' | ||
case 13: if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n' | ||
case 10: // ' \n' | ||
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine } | ||
return "" | ||
default: return String.fromCharCode(ch) | ||
switch (ch) { | ||
case 110: return "\n"; // 'n' -> '\n' | ||
case 114: return "\r"; // 'r' -> '\r' | ||
case 120: return String.fromCharCode(this.readHexChar(2)); // 'x' | ||
case 117: return codePointToString(this.readCodePoint()); // 'u' | ||
case 116: return "\t"; // 't' -> '\t' | ||
case 98: return "\b"; // 'b' -> '\b' | ||
case 118: return "\u000b"; // 'v' -> '\u000b' | ||
case 102: return "\f"; // 'f' -> '\f' | ||
case 13: if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n' | ||
case 10: // ' \n' | ||
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine } | ||
return "" | ||
default: | ||
if (ch >= 48 && ch <= 55) { | ||
let octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0] | ||
let octal = parseInt(octalStr, 8) | ||
if (octal > 255) { | ||
octalStr = octalStr.slice(0, -1) | ||
octal = parseInt(octalStr, 8) | ||
} | ||
if (octal > 0 && (this.strict || inTemplate)) { | ||
this.raise(this.pos - 2, "Octal literal in strict mode") | ||
} | ||
this.pos += octalStr.length - 1 | ||
return String.fromCharCode(octal) | ||
} | ||
return String.fromCharCode(ch) | ||
} | ||
@@ -625,4 +637,5 @@ } | ||
pp.readHexChar = function(len) { | ||
let codePos = this.pos | ||
let n = this.readInt(16, len) | ||
if (n === null) this.raise(this.start, "Bad character escape sequence") | ||
if (n === null) this.raise(codePos, "Bad character escape sequence") | ||
return n | ||
@@ -629,0 +642,0 @@ } |
@@ -316,3 +316,3 @@ // AST walker module for Mozilla Parser API compatible trees | ||
base.Class = (node, st, c) => { | ||
c(node.id, st, "Pattern") | ||
if (node.id) c(node.id, st, "Pattern") | ||
if (node.superClass) c(node.superClass, st, "Expression") | ||
@@ -319,0 +319,0 @@ for (let i = 0; i < node.body.body.length; i++) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
473592
11448