2020-08-28 13:29:47 +08:00
|
|
|
const path = require('path');
|
|
|
|
const exec = require('child_process').exec;
|
|
|
|
|
2020-09-09 14:11:04 +08:00
|
|
|
const antlr4 = path.resolve(__dirname, 'antlr-4.8-complete.jar');
|
2020-08-28 13:29:47 +08:00
|
|
|
const grammars = path.resolve(__dirname, '../src/grammar');
|
2020-09-11 17:39:10 +08:00
|
|
|
const output = path.resolve(__dirname, '../src/lib');
|
2020-08-28 13:29:47 +08:00
|
|
|
|
2020-09-09 14:11:04 +08:00
|
|
|
const entry = [
|
2020-12-14 11:09:57 +08:00
|
|
|
'generic',
|
|
|
|
'hive',
|
|
|
|
'plsql',
|
|
|
|
'spark',
|
|
|
|
'impala',
|
2020-10-22 19:57:13 +08:00
|
|
|
'flinksql',
|
2020-08-28 13:29:47 +08:00
|
|
|
];
|
|
|
|
|
2020-09-09 14:11:04 +08:00
|
|
|
entry.forEach((language) => {
|
|
|
|
const cmd = `
|
|
|
|
java -jar ${antlr4}
|
|
|
|
-Dlanguage=JavaScript
|
|
|
|
-visitor
|
|
|
|
-listener
|
|
|
|
-o ${output}/${language}
|
|
|
|
${grammars}/${language}/*.g4
|
|
|
|
`.replace(/\n/g, '');
|
|
|
|
console.log('cmd:', cmd);
|
|
|
|
exec(cmd, (err) => {
|
|
|
|
if (err) {
|
|
|
|
console.error('Antlr4 build error: ' + language, err);
|
|
|
|
} else {
|
|
|
|
console.log(`Build ${language} success.`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2020-08-28 13:29:47 +08:00
|
|
|
|