From 3e9e522f6acf08281c35f44a0ce15bf51886d29b Mon Sep 17 00:00:00 2001 From: shellscape Date: Thu, 4 May 2017 09:59:58 -0400 Subject: [PATCH 1/2] fixes #25: many nested functions --- lib/parser.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/parser.js b/lib/parser.js index 5c5f921..37cf8a6 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -29,6 +29,8 @@ module.exports = class Parser { constructor (input, options) { const defaults = { loose: false }; + // cache needs to be an array for values with more than 1 level of function nesting + this.cache = []; this.input = input; this.options = Object.assign({}, defaults, options); this.position = 0; @@ -266,7 +268,6 @@ module.exports = class Parser { if (last && last.type === 'func' && last.unbalanced < 0) { last.unbalanced = 0; // ok we're ready to add parens now - this.cache = this.current; this.current = last; } @@ -345,7 +346,7 @@ module.exports = class Parser { this.position ++; - if (this.position >= this.tokens.length - 1) { + if (this.position >= this.tokens.length - 1 && !this.current.unbalanced) { return; } @@ -355,9 +356,8 @@ module.exports = class Parser { this.error('Expected opening parenthesis', token); } - if (!this.current.unbalanced && this.cache) { - this.current = this.cache; - this.cache = null; + if (!this.current.unbalanced && this.cache.length) { + this.current = this.cache.pop(); } } @@ -452,6 +452,9 @@ module.exports = class Parser { node.isHex = /^#/.test(value); node.isColor = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(value); } + else { + this.cache.push(this.current); + } } this.newNode(node); From db2c8b7cd7cb17fdd4a925b4140fd99d20f77b87 Mon Sep 17 00:00:00 2001 From: shellscape Date: Sat, 20 May 2017 09:07:51 -0400 Subject: [PATCH 2/2] asserting issue and pr templates aren't optional --- .github/ISSUE_TEMPLATE.md | 6 +++--- .github/PULL_REQUEST_TEMPLATE.md | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 10c9e58..8ceef92 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,7 +1,7 @@ * Node Version: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5a0e2ad..ffcc245 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,6 @@ + + **Which issue #** if any, does this resolve?