lava-oushudb-dt-sql-parser/lib/parser.js

23 lines
446 B
JavaScript
Raw Normal View History

2018-07-02 18:01:01 +08:00
const Parser = require('../core/astParser');
const Cache = require("../core/cache");
const filter = require("./filter");
const astCache=new Cache();
function parse(sql){
const cleanSql=filter.cleanSql(sql);
console.log(cleanSql)
let ast=astCache.get(cleanSql);
if(ast){
return ast
}else{
ast=Parser.parse(cleanSql).ast;
astCache.set(cleanSql,ast);
return ast;
}
}
exports.parse=parse;