Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit 8eb07a7

Browse files
committed
forked pegjs repository as nwronski/pegjs to get the changes into pegjs core into version control so they are not accidentally overwritten. refs #2
1 parent 8bb7139 commit 8eb07a7

File tree

10 files changed

+88
-23
lines changed

10 files changed

+88
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
## [Unreleased][unreleased]
55

6+
## [v0.8.1] - 2015-07-04
7+
### Changed
8+
- forked `pegjs` repository as `nwronski/pegjs` to get the changes into `pegjs` core into version control so they are not accidentally overwritten
9+
610
## [v0.8.0] - 2015-07-04
711
### Added
812
- added several array methods (e.g.: `findLast()`, `takeRight()`, `pluck()`) so that I could remove `lodash` as a dependency of the "smart error" `Tracer` class

demo/sqlite-parser-demo.js

Lines changed: 22 additions & 6 deletions
Large diffs are not rendered by default.

dist/sqlite-parser.js

Lines changed: 22 additions & 6 deletions
Large diffs are not rendered by default.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
});
2121
}
2222
sqliteParser['NAME'] = 'sqlite-parser';
23-
sqliteParser['VERSION'] = '0.8.0';
23+
sqliteParser['VERSION'] = '0.8.1';
2424

2525
module.exports = root.sqliteParser = sqliteParser;
2626
})(typeof self === 'object' ? self : global);

lib/parser-util.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ function rest(arr) {
217217
return 2 <= arr.length ? slice.call(arr, 1) : [];
218218
}
219219

220+
function uniq(arr) {
221+
var u = {}, a = [];
222+
for(var i = 0, l = arr.length; i < l; ++i){
223+
if(Object.prototype.hasOwnProperty.call(u, arr[i])) {
224+
continue;
225+
}
226+
a.push(arr[i]);
227+
u[arr[i]] = 1;
228+
}
229+
return a;
230+
}
231+
220232
module.exports = {
221233
// Array methods
222234
'stack': stack,
@@ -232,6 +244,7 @@ module.exports = {
232244
'first': first,
233245
'last': last,
234246
'rest': rest,
247+
'uniq': uniq,
235248
// String methods
236249
'nodeToString': nodeToString,
237250
'textNode': textNode,

lib/parser.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tracer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = (function (util) {
4747

4848
chain = this.events.filter(function (e) {
4949
// Only use nodes with a set description
50-
return e.description !== '' && !/whitespace|(semi$)|(^[oe]$)/i.test(e.rule);
50+
return e.description != null && !/whitespace|(semi$)|(^[oe]$)/i.test(e.rule);
5151
})
5252
.reverse()
5353
.filter(function (e) {
@@ -65,13 +65,13 @@ module.exports = (function (util) {
6565
// Get best location data
6666
location = util.first(chain).location;
6767
// Collect descriptions
68-
chain = util.takeWhile(util.pluck(chain, 'description'), function (d) {
68+
chain = util.uniq(util.takeWhile(util.pluck(chain, 'description'), function (d) {
6969
if (!bestDescriptor && /(Statement|Clause)$/i.test(d)) {
7070
bestDescriptor = true;
7171
return true;
7272
}
7373
return !bestDescriptor;
74-
})
74+
}))
7575
.reverse();
7676
// Don't accidentally repeat the first description in the output
7777
chainDetail = util.takeRight(util.rest(chain), 2);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "sqlite-parser",
33
"description": "JavaScript implentation of SQLite 3 query parser",
44
"author": "Code School (http://codeschool.com)",
5-
"version": "0.8.0",
5+
"version": "0.8.1",
66
"contributors": [
77
"Nick Wronski <nick@javascript.com>"
88
],
@@ -42,7 +42,7 @@
4242
"grunt-shell": "^1.1.2",
4343
"lodash": "^3.10.0",
4444
"mocha": "^2.2.5",
45-
"pegjs": "git+https://github.com/pegjs/pegjs.git#master",
45+
"pegjs": "git+https://github.com/nwronski/pegjs.git#master",
4646
"prettyjson": "^1.1.2"
4747
},
4848
"dependencies": {

src/parser-util.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ function rest(arr) {
217217
return 2 <= arr.length ? slice.call(arr, 1) : [];
218218
}
219219

220+
function uniq(arr) {
221+
var u = {}, a = [];
222+
for(var i = 0, l = arr.length; i < l; ++i){
223+
if(Object.prototype.hasOwnProperty.call(u, arr[i])) {
224+
continue;
225+
}
226+
a.push(arr[i]);
227+
u[arr[i]] = 1;
228+
}
229+
return a;
230+
}
231+
220232
module.exports = {
221233
// Array methods
222234
'stack': stack,
@@ -232,6 +244,7 @@ module.exports = {
232244
'first': first,
233245
'last': last,
234246
'rest': rest,
247+
'uniq': uniq,
235248
// String methods
236249
'nodeToString': nodeToString,
237250
'textNode': textNode,

src/tracer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = (function (util) {
4747

4848
chain = this.events.filter(function (e) {
4949
// Only use nodes with a set description
50-
return e.description !== '' && !/whitespace|(semi$)|(^[oe]$)/i.test(e.rule);
50+
return e.description != null && !/whitespace|(semi$)|(^[oe]$)/i.test(e.rule);
5151
})
5252
.reverse()
5353
.filter(function (e) {
@@ -65,13 +65,13 @@ module.exports = (function (util) {
6565
// Get best location data
6666
location = util.first(chain).location;
6767
// Collect descriptions
68-
chain = util.takeWhile(util.pluck(chain, 'description'), function (d) {
68+
chain = util.uniq(util.takeWhile(util.pluck(chain, 'description'), function (d) {
6969
if (!bestDescriptor && /(Statement|Clause)$/i.test(d)) {
7070
bestDescriptor = true;
7171
return true;
7272
}
7373
return !bestDescriptor;
74-
})
74+
}))
7575
.reverse();
7676
// Don't accidentally repeat the first description in the output
7777
chainDetail = util.takeRight(util.rest(chain), 2);

0 commit comments

Comments
 (0)