Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alsotang committed Jan 15, 2014
0 parents commit 51ee2db
Show file tree
Hide file tree
Showing 9 changed files with 12,354 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build: lib/sql.pegjs
@pegjs lib/sql.pegjs lib/sqlparser.js

test:
@./node_modules/.bin/mocha

.PHONY: build test
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# sql.pegjs

This project is a SQL parser based on PEG([parsing expression grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar)).

And the `sql.pegjs` file is modified from [https://github.com/steveyen/sqld3](https://github.com/steveyen/sqld3).

Thanks for the effort of @steveyen.

## Usage

```js
var parser = require('sql.pegjs');
var sql = 'select * from users;';
parser.parse(sql)
// => [{"stmt":"select","select_cores":[{"results":[{"column":"*"}],"from":[{"table":"users"}]}]}]);

```


## How to contribute

1. modify `lib/sql.pegjs` and add tests.

1. run `make build`

1. then run `make test`

## License

MIT
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/parser.js');
5 changes: 5 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var peg = require('pegjs');
var fs = require('fs');
var parser = require('./sqlparser');

module.exports = parser;
Loading

0 comments on commit 51ee2db

Please sign in to comment.