Permalink
Browse files

Cover for bug in narcissus

Narcissus handles [,] weirdly, which funnily enough is used in narcissus. You
can't use [,] in a pattern, but I don't know what it does so how can that be a
problem?
  • Loading branch information...
1 parent c33c830 commit dccf1e400377f031ffd647e54f4fc34306989392 Ryan Patterson committed Jan 10, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/jsgrep.js
View
@@ -91,6 +91,13 @@ function astMatchEllipsis(nodes, patterns, config, matcher) {
var astIsEqual = exports.astIsEqual = function(node, pattern, config) {
const tokens = Narcissus.definitions.tokenIds;
+ // Narcissus messes up the AST when parsing [,] (no idea what [,] means)
+ if (node == null && pattern == null) {
+ return true;
+ } else if (node == null || pattern == null) {
+ return false;
+ }
+
if (pattern.type == tokens.IDENTIFIER &&
/^[A-Z](_.*)?$/.test(pattern.value)) {
if (pattern.value in config.variables) {
@@ -410,6 +417,10 @@ var forEachNode = exports.forEachNode = function(node, callback) {
callback(node);
+ if (node == null) {
+ return;
+ }
+
switch(node.type) {
// Core values
case tokens.FALSE:

0 comments on commit dccf1e4

Please sign in to comment.