[Pkg-javascript-commits] [node-acorn-jsx] 412/484: Fix {start,end}Loc -> loc.{start,end} in acorn_loose; remove forceRegexp.
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:21:03 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit 2e55540bbee9475d3249e3442a2a3e640bf16808
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Thu Jan 22 18:53:45 2015 +0200
Fix {start,end}Loc -> loc.{start,end} in acorn_loose; remove forceRegexp.
---
acorn_loose.js | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/acorn_loose.js b/acorn_loose.js
index 27e8b65..db2883c 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -58,14 +58,12 @@
var lastEnd, token = {start: 0, end: 0}, ahead = [];
var curLineStart, nextLineStart, curIndent, lastEndLoc, sourceFile;
- function next(forceRegexp) {
+ function next() {
lastEnd = token.end;
if (options.locations)
- lastEndLoc = token.endLoc;
- if (forceRegexp)
- ahead.length = 0;
+ lastEndLoc = token.loc && token.loc.end;
- token = ahead.shift() || readToken(forceRegexp);
+ token = ahead.shift() || readToken();
if (options.onToken)
options.onToken(token);
@@ -78,10 +76,10 @@
}
}
- function readToken(forceRegexp) {
+ function readToken() {
for (;;) {
try {
- var tok = fetchToken(forceRegexp);
+ var tok = fetchToken();
if (tok.type === tt.dot && input.substr(tok.end, 1) === '.') {
tok = fetchToken();
tok.start--;
@@ -129,8 +127,8 @@
if (replace === true) replace = {start: pos, end: pos, type: tt.name, value: "✖"};
if (replace) {
if (options.locations) {
- replace.startLoc = acorn.getLineInfo(input, replace.start);
- replace.endLoc = acorn.getLineInfo(input, replace.end);
+ replace.loc = new SourceLocation(acorn.getLineInfo(input, replace.start));
+ replace.loc.end = acorn.getLineInfo(input, replace.end);
}
return replace;
}
@@ -212,7 +210,7 @@
Node.prototype = acorn.Node.prototype;
function SourceLocation(start) {
- this.start = start || token.startLoc || {line: 1, column: 0};
+ this.start = start || token.loc.start || {line: 1, column: 0};
this.end = null;
if (sourceFile !== null) this.source = sourceFile;
}
@@ -229,7 +227,7 @@
}
function storeCurrentPos() {
- return options.locations ? [token.start, token.startLoc] : token.start;
+ return options.locations ? [token.start, token.loc.start] : token.start;
}
function startNodeAt(pos) {
@@ -313,7 +311,7 @@
node.body = [];
while (token.type !== tt.eof) node.body.push(parseStatement());
lastEnd = token.end;
- lastEndLoc = token.endLoc;
+ lastEndLoc = token.loc && token.loc.end;
return finishNode(node, "Program");
}
@@ -913,7 +911,7 @@
// If there is no closing brace, make the node span to the start
// of the next token (this is useful for Tern)
lastEnd = token.start;
- if (options.locations) lastEndLoc = token.startLoc;
+ if (options.locations) lastEndLoc = token.loc.start;
}
if (isClass) {
semicolon();
@@ -1168,7 +1166,7 @@
// If there is no closing brace, make the node span to the start
// of the next token (this is useful for Tern)
lastEnd = token.start;
- if (options.locations) lastEndLoc = token.startLoc;
+ if (options.locations) lastEndLoc = token.loc.start;
}
return elts;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list