-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 51ee2db
Showing
9 changed files
with
12,354 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./lib/parser.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.