修改构建方式,升级peg为0.10.0

This commit is contained in:
HSunboy 2018-07-06 16:58:25 +08:00
parent 05d679d368
commit 4d3c998120
6 changed files with 8884 additions and 9281 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

6
package-lock.json generated
View File

@ -11,9 +11,9 @@
"dev": true
},
"pegjs": {
"version": "0.7.0",
"resolved": "http://registry.npm.taobao.org/pegjs/download/pegjs-0.7.0.tgz",
"integrity": "sha1-qqH4JPnnGX7ETiKlevUi9wDdaJ4=",
"version": "0.10.0",
"resolved": "http://registry.npm.taobao.org/pegjs/download/pegjs-0.10.0.tgz",
"integrity": "sha1-z4uvrm7d/0tafvsYUmnqr0YQ3b0=",
"dev": true
}
}

View File

@ -4,14 +4,14 @@
"description": "sql parser",
"main": "index.js",
"scripts": {
"build:parse": "pegjs peg/nquery.pegjs core/astParser.js",
"build:filter":"pegjs peg/comment.pegjs core/comment.js"
"build:parse": "pegjs -o core/astParser.js peg/nquery.pegjs ",
"build:filter": "pegjs -o core/comment.js peg/comment.pegjs "
},
"author": "xiaokang",
"license": "ISC",
"devDependencies": {
"node-query": "^0.3.3",
"pegjs": "^0.7.0"
"pegjs": "^0.10.0"
},
"dependencies": {}
}

View File

@ -2,6 +2,8 @@ const pegjs=require("pegjs");
const path=require("path");
const fs=require("fs");
const ENCODING="utf8"
const files=[{
source:path.resolve(process.cwd(),"./peg/comment.pegjs") ,
target:path.resolve(process.cwd(),"./core/comment.js") ,
@ -10,5 +12,19 @@ const files=[{
target:path.resolve(process.cwd(),"./core/astParser.js") ,
}];
const file=fs.readFileSync(files[0].source,{encoding:"utf8"})
pegjs.buildParser(file);
function writeIn(file,data){
fs.writeFileSync(file,data,{encoding:ENCODING})
}
function build(content){
return pegjs.generate(content,{
output:"source",
format:"umd"
});
}
files.forEach(
(file)=>{
let fileContent=fs.readFileSync(file.source,{encoding:ENCODING})
writeIn(file.target,build(fileContent))
}
)

View File

@ -278,7 +278,7 @@ table_name
db : '',
table : dt
}
if (tail != '') {
if (tail) {
obj.db = dt;
obj.table = tail[3];
}