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

Commit

Permalink
Upgrade pegjs and devDependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
nwronski committed Oct 3, 2016
1 parent d641e6d commit 61817f8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 45 deletions.
17 changes: 2 additions & 15 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(grunt) {
}
const customArgs = {
mocha: '--compilers js:babel-core/register',
pegjs: `--trace --cache --optimize size -e parser src/grammar.pegjs .tmp/parser.js`
pegjs: `--trace --cache --optimize size --output lib/parser.js src/grammar.pegjs`
};

const tmpDir = './.tmp/';
Expand All @@ -28,7 +28,6 @@ module.exports = function(grunt) {
browserify: {
options: {
transform: [require('babelify').configure({
sourceMapRelative: './',
compact: true,
sourceMaps: true
})]
Expand Down Expand Up @@ -104,18 +103,6 @@ module.exports = function(grunt) {
interactive: ['.tmp/**/*'],
demo: ['demo/**/*']
},
concat: {
options: {
stripBanners: true,
// This exports the compiled parser
banner: "\nconst ",
footer: "\nexport default parser.parse;"
},
build: {
src: ['.tmp/parser.js'],
dest: 'lib/parser.js'
}
},
shell: {
build: {
options: {
Expand Down Expand Up @@ -288,7 +275,7 @@ module.exports = function(grunt) {
'build'
]);
grunt.registerTask('build', [
'clean:build', 'shell:build', 'concat:build', 'copy:build'
'clean:build', 'shell:build', 'copy:build'
]);
grunt.registerTask('test', [
'build', 'shell:test'
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* sqlite-parser
*/
import parser from './lib/parser';
import Tracer from './lib/tracer';
import { parse } from './lib/parser';
import { Tracer } from './lib/tracer';

export default function sqliteParser(source, callback) {
const t = Tracer();
Expand All @@ -12,7 +12,7 @@ export default function sqliteParser(source, callback) {
if (isAsync) {
setTimeout(function () {
try {
callback(null, parser(source, opts));
callback(null, parse(source, opts));
} catch (e) {
callback(t.smartError(e));
}
Expand All @@ -21,7 +21,7 @@ export default function sqliteParser(source, callback) {
}
// Sync
try {
return parser(source, opts);
return parse(source, opts);
} catch (e) {
throw t.smartError(e);
}
Expand Down
26 changes: 11 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,31 @@
},
"scripts": {
"test": "grunt test",
"build": "grunt dist",
"preversion": "npm test",
"version": "npm run build && git add .",
"postversion": "git push && git push --tags"
"build": "grunt dist"
},
"devDependencies": {
"babel-core": "^6.9.1",
"babel-core": "^6.17.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015": "^6.16.0",
"babelify": "^7.3.0",
"bluebird": "^3.4.0",
"bluebird": "^3.4.6",
"chai": "^3.5.0",
"codemirror": "^5.15.2",
"codemirror": "^5.19.0",
"grunt": "^1.0.1",
"grunt-banner": "^0.6.0",
"grunt-browserify": "^5.0.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^1.0.1",
"grunt-contrib-uglify": "^1.0.1",
"grunt-contrib-cssmin": "^1.0.2",
"grunt-contrib-uglify": "^2.0.0",
"pegjs": "git+https://github.com/nwronski/pegjs.git#master",
"grunt-contrib-watch": "^1.0.0",
"grunt-replace": "^1.0.1",
"grunt-shell": "^1.3.0",
"load-grunt-tasks": "^3.5.0",
"lodash": "^4.13.1",
"mocha": "^2.5.3",
"grunt-shell": "^2.0.0",
"load-grunt-tasks": "^3.5.2",
"lodash": "^4.16.2",
"mocha": "^3.1.0",
"prettyjson": "^1.1.3"
},
"dependencies": {}
Expand Down
20 changes: 10 additions & 10 deletions src/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ literal_number_signed
}

literal_number
= literal_number_decimal
/ literal_number_hex
= literal_number_hex
/ literal_number_decimal

literal_number_decimal
= d:( number_decimal_node ) e:( number_decimal_exponent )?
Expand Down Expand Up @@ -954,17 +954,17 @@ stmt_pragma "PRAGMA Statement"
}

pragma_expression
= ( sym_equal v:( pragma_value ) o ) { return v; }
/ ( sym_popen v:( pragma_value ) o sym_pclose ) { return v; }
= sym_equal v:( pragma_value ) o { return v; }
/ sym_popen v:( pragma_value ) o sym_pclose { return v; }

pragma_value
= pragma_value_bool
/ pragma_value_literal
/ pragma_value_name

pragma_value_literal
= v:( literal_number_signed / literal_string )
{ return v; }
= literal_number_signed
/ literal_string

/**
* @note
Expand Down Expand Up @@ -1121,31 +1121,31 @@ select_target_loop
{ return n; }

select_core_from "FROM Clause"
= s:( FROM ) o s:( select_source ) o
= f:( FROM ) o s:( select_source ) o
{
return {
'from': s
};
}

stmt_core_where "WHERE Clause"
= s:( WHERE ) o e:( expression ) o
= f:( WHERE ) o e:( expression ) o
{
return {
'where': makeArray(e)
};
}

select_core_group "GROUP BY Clause"
= s:( GROUP ) o BY o e:( expression_list ) o h:( select_core_having )?
= f:( GROUP ) o BY o e:( expression_list ) o h:( select_core_having )?
{
return Object.assign({
'group': makeArray(e)
}, h);
}

select_core_having "HAVING Clause"
= s:( HAVING ) o e:( expression ) o
= f:( HAVING ) o e:( expression ) o
{
return {
'having': e
Expand Down
2 changes: 1 addition & 1 deletion src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function takeWhile(arr, func) {
return arr;
}

export default (function () {
export const Tracer = (function () {
function Tracer() {
if (!(this instanceof Tracer)) {
return new Tracer();
Expand Down

0 comments on commit 61817f8

Please sign in to comment.