build: add antlr4 compile script
This commit is contained in:
parent
d86a6e7638
commit
68800312d3
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ package-lock.json
|
|||||||
.vscode
|
.vscode
|
||||||
.history
|
.history
|
||||||
lib/
|
lib/
|
||||||
|
src/**/.antlr
|
BIN
build/antlr-4.8-complete.jar
Normal file
BIN
build/antlr-4.8-complete.jar
Normal file
Binary file not shown.
@ -1,31 +1,35 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
|
|
||||||
|
const antlr4 = path.resolve(__dirname, 'antlr-4.8-complete.jar');
|
||||||
const grammars = path.resolve(__dirname, '../src/grammar');
|
const grammars = path.resolve(__dirname, '../src/grammar');
|
||||||
|
const output = path.resolve(__dirname, '../src/parser');
|
||||||
|
|
||||||
const languages = [
|
const entry = [
|
||||||
'generic',
|
'generic',
|
||||||
'mysql',
|
'mysql',
|
||||||
// 'oracle',
|
'hive',
|
||||||
// 'flink',
|
'plsql',
|
||||||
// 'hive',
|
'spark',
|
||||||
// 'impala',
|
'tsql',
|
||||||
// 'libra',
|
|
||||||
// 'spark',
|
|
||||||
// 'tidb'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
languages.forEach(language => {
|
entry.forEach((language) => {
|
||||||
|
const cmd = `
|
||||||
exec(`npx antlr4-tool -l ts -o ${grammars}/${language}/parser ${grammars}/${language}/*.g4`, (error) => {
|
java -jar ${antlr4}
|
||||||
console.log('error:', error)
|
-Dlanguage=JavaScript
|
||||||
})
|
-visitor
|
||||||
|
-listener
|
||||||
// const compiledResults = antlr4Tool.compile({
|
-o ${output}/${language}
|
||||||
// language: 'ts', // Only support for JavaScript & TypeScript
|
${grammars}/${language}/*.g4
|
||||||
// grammarFiles: [`${grammars}/${language}/*.g4`],
|
`.replace(/\n/g, '');
|
||||||
// outputDirectory: `${grammars}/${language}/parser`
|
console.log('cmd:', cmd);
|
||||||
// });
|
exec(cmd, (err) => {
|
||||||
|
if (err) {
|
||||||
})
|
console.error('Antlr4 build error: ' + language, err);
|
||||||
|
} else {
|
||||||
|
console.log(`Build ${language} success.`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
],
|
],
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:parser": "node build/antlr4.js",
|
"antlr": "node build/antlr4.js",
|
||||||
"build": "npm test && rm -rf lib && tsc",
|
"build": "npm test && rm -rf lib && tsc",
|
||||||
"eslint": "eslint ./src/**/*.ts",
|
"eslint": "eslint ./src/**/*.ts",
|
||||||
"check-types": "tsc --skipLibCheck",
|
"check-types": "tsc --skipLibCheck",
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
126333
src/parser/TSqlParser.js
126333
src/parser/TSqlParser.js
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user