Skip to content

Commit c1c72de

Browse files
authored
feat: upgrade antlr4 to 4.12.0 (#88)
1 parent c0842b3 commit c1c72de

116 files changed

Lines changed: 552766 additions & 609987 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/nodejs.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [12.x, 14.x]
12+
node-version: [16.x]
1313

1414
steps:
1515
- uses: actions/checkout@v1
1616
- name: Use Node.js ${{ matrix.node-version }}
1717
uses: actions/setup-node@v1
1818
with:
1919
node-version: ${{ matrix.node-version }}
20-
- name: npm install, test, and build
20+
- name: install, test, build
2121
run: |
22-
npm install
23-
npm test
24-
npm run build
22+
export NODE_OPTIONS="--max_old_space_size=4096"
23+
yarn install
24+
yarn test
25+
yarn build
2526
env:
2627
CI: true

CONTRIBUTING.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
# dt-sql-parser
22

3+
## Get Start
34

4-
## Prerequisites
5+
installing the dependencies after cloned project:
56

7+
```bash
8+
yarn install
9+
```
610

7-
## Branch Organization
11+
- test
12+
13+
```bash
14+
yarn test
15+
```
16+
17+
## Compile the grammar sources
18+
19+
Compile one language:
820

21+
```bash
22+
yarn antlr4 --lang=generic
23+
```
24+
25+
Compile all languages:
26+
27+
```bash
28+
yarn antlr4 --all
29+
```
30+
31+
## Branch Organization
932

1033
## Source Code Organization

build/antlr-4.12.0-complete.jar

3.27 MB
Binary file not shown.

build/antlr-4.8-complete.jar

-1.99 MB
Binary file not shown.

build/antlr4.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const path = require('path');
22
const exec = require('child_process').exec;
3+
const argv = require('yargs-parser')(process.argv.slice(2))
34

4-
const antlr4 = path.resolve(__dirname, 'antlr-4.8-complete.jar');
5+
const antlr4 = path.resolve(__dirname, './antlr-4.12.0-complete.jar');
56
const grammars = path.resolve(__dirname, '../src/grammar');
67
const output = path.resolve(__dirname, '../src/lib');
78

@@ -14,22 +15,37 @@ const entry = [
1415
'flinksql',
1516
];
1617

17-
entry.forEach((language) => {
18+
function compile(language) {
1819
const cmd = `
1920
java -jar ${antlr4}
20-
-Dlanguage=JavaScript
21+
-Dlanguage=TypeScript
2122
-visitor
2223
-listener
2324
-o ${output}/${language}
2425
${grammars}/${language}/*.g4
2526
`.replace(/\n/g, '');
26-
console.log('cmd:', cmd);
27+
console.info('Executing:', cmd);
2728
exec(cmd, (err) => {
2829
if (err) {
2930
console.error('Antlr4 build error: ' + language, err);
3031
} else {
3132
console.log(`Build ${language} success.`);
3233
}
3334
});
34-
});
35+
}
36+
37+
if (argv.all) { // build all: yarn antlr4 --all
38+
entry.forEach((language) => {
39+
compile(language);
40+
});
41+
} else if (argv.lang) {// build single: yarn antlr4 --lang=generic
42+
const supportedLanguage = entry.find((language) => language === argv.lang);
43+
if (supportedLanguage) {
44+
compile(argv.lang);
45+
} else {
46+
console.error('Unsupported language: ' + argv.lang);
47+
}
48+
} else {
49+
console.error('Please to specify the language, just like: yarn antlr4 --lang flinksql');
50+
}
3551

0 commit comments

Comments
 (0)