Update Acorn.js and use it now by default, thanks to Marijn's fast bugfix:

https://github.com/marijnh/acorn/issues/14
This commit is contained in:
Jürg Lehni 2012-11-18 12:25:37 -08:00
parent 14642e63b3
commit 302f23bc5a
7 changed files with 18 additions and 7 deletions

View file

@ -34,5 +34,5 @@ then
mkdir ../dist/
fi
./preprocess.sh $MODE ../src/paper.js '{ "browser": true }' ../src/constants.js ../dist/paper.js
./preprocess.sh $MODE ../src/paper.js '{ "browser": true, "parser": "acorn" }' ../src/constants.js ../dist/paper.js
#./preprocess.sh $MODE ../src/paper.js '{ "server": true }' ../src/constants.js ../dist/paper-server.js

View file

@ -33,5 +33,5 @@ cd ..
if [ $MODE = "docs" ]
then
# Build paper.js library for documentation
./preprocess.sh stripped ../src/paper.js '{ "browser": true }' ../src/constants.js ../dist/docs/resources/js/paper.js
./preprocess.sh stripped ../src/paper.js '{ "browser": true, "parser": "acorn" }' ../src/constants.js ../dist/docs/resources/js/paper.js
fi

2
lib/acorn-min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1433,8 +1433,17 @@
return finishNode(node, "Literal");
case _parenL:
var tokStartLoc1 = tokStartLoc, tokStart1 = tokStart;
next();
var val = parseExpression();
val.start = tokStart1;
val.end = tokEnd;
if (options.locations) {
val.loc.start = tokStartLoc1;
val.loc.end = tokEndLoc;
}
if (options.ranges)
val.range = [tokStart1, tokEnd];
expect(_parenR);
return val;
@ -1592,4 +1601,4 @@
return finishNode(node, "Identifier");
}
})(typeof exports === "undefined" ? (window.acorn = {}) : exports);
})(typeof exports === "undefined" ? (window.acorn = {}) : exports);

View file

@ -9,6 +9,7 @@ __dirname = path.resolve(__dirname, '../src/');
var context = vm.createContext({
options: {
server: true,
parser: 'acorn',
version: 'dev'
},
fs: fs,

View file

@ -21,7 +21,7 @@
/*#*/ if (options.parser == 'acorn') {
/*#*/ include('../../lib/acorn-min.js');
/*#*/ } else {
/*#*/ } else if (options.parser == 'esprima') {
/*#*/ include('../../lib/esprima-min.js');
/*#*/ }
@ -189,7 +189,7 @@ var PaperScript = this.PaperScript = new function() {
// Now do the parsing magic
/*#*/ if (options.parser == 'acorn') {
walkAst(acorn.parse(code, { ranges: true }));
/*#*/ } else {
/*#*/ } else if (options.parser == 'esprima') {
walkAst(esprima.parse(code, { range: true }));
/*#*/ }
return code;

View file

@ -22,7 +22,8 @@
var options = {
browser: true,
stats: true,
version: 'dev'
version: 'dev',
parser: 'acorn'
};
// This folder is specified relatively to the lib folder from which prepro.js is