[Pkg-javascript-commits] [node-acorn-jsx] 77/484: [loose parser] Make expect check two tokens ahead if it fails to find its target

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:07 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 a2788f8864b9a7453be80bac49e550e7be6914d0
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Wed Jan 16 17:38:56 2013 +0100

    [loose parser] Make expect check two tokens ahead if it fails to find its target
---
 acorn_loose.js | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/acorn_loose.js b/acorn_loose.js
index a95efae..81f5f2f 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -97,7 +97,7 @@
       var tok = readToken();
       ahead.push({start: tok.from, end: tok.end, type: tok.type, value: tok.value});
     }
-    return ahead[n];
+    return ahead[n-1];
   }
 
   var newline = /[\n\r\u2028\u2029]/;
@@ -125,7 +125,6 @@
     }
     return count;
   }
-  // FIXME maybe use smarter heuristics (look at next lines, etc)
   function closesBlock(closeTok, indent) {
     return token.type === closeTok || token.type === tt.eof || indent > indentationAt(token.start);
   }
@@ -172,9 +171,14 @@
 
   function expect(type) {
     if (eat(type)) return true;
-    // FIXME
-    // - it might just be missing, in which case ignoring is good
-    // + custom strategies for re-syncing in other cases
+    if (lookAhead(1).type == type) {
+      next(); next();
+      return true;
+    }
+    if (lookAhead(2).type == type) {
+      next(); next(); next();
+      return true;
+    }
   }
 
   function checkLVal(expr) {

-- 
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