feat: migrate to antlr4ng (#267)

* feat: replace antlr4ts with antlr4ng

* feat: switch caseInsensitive option on

* feat: recompile all g4 file

* feat:  update parser to fit antlr4ng

* test: update test to fit antlr4ng
This commit is contained in:
Hayden
2024-02-26 20:25:09 +08:00
committed by GitHub
parent 5ce89cb421
commit 195878da9b
112 changed files with 648433 additions and 659067 deletions

View File

@ -19,9 +19,9 @@ describe('ImpalaSQL ErrorStrategy test', () => {
const statementCount = splitListener.statementsContext.length;
splitListener.statementsContext.map((item, index) => {
if (index !== statementCount - 1 && index !== statementCount - 2) {
expect(item.exception).not.toBe(undefined);
expect(item.exception).not.toBe(null);
} else {
expect(item.exception).toBe(undefined);
expect(item.exception).toBe(null);
}
});
});
@ -36,9 +36,9 @@ describe('ImpalaSQL ErrorStrategy test', () => {
const statementCount = splitListener.statementsContext.length;
splitListener.statementsContext.map((item, index) => {
if (index !== statementCount - 1 && index !== 0) {
expect(item.exception).not.toBe(undefined);
expect(item.exception).not.toBe(null);
} else {
expect(item.exception).toBe(undefined);
expect(item.exception).toBe(null);
}
});
});
@ -52,9 +52,9 @@ describe('ImpalaSQL ErrorStrategy test', () => {
splitListener.statementsContext.map((item, index) => {
if (index !== 0 && index !== 1) {
expect(item.exception).not.toBe(undefined);
expect(item.exception).not.toBe(null);
} else {
expect(item.exception).toBe(undefined);
expect(item.exception).toBe(null);
}
});
});

View File

@ -1,6 +1,6 @@
import ImpalaSQL from 'src/parser/impala';
import { ImpalaSqlParserListener } from 'src/lib/impala/ImpalaSqlParserListener';
import { ParseTreeListener } from 'antlr4ts/tree/ParseTreeListener';
import { ParseTreeListener } from 'antlr4ng';
describe('impala SQL Listener Tests', () => {
const expectTableName = 'user1';
@ -13,8 +13,13 @@ describe('impala SQL Listener Tests', () => {
let result = '';
class MyListener implements ImpalaSqlParserListener {
enterTableNamePath = (ctx): void => {
result = ctx.text.toLowerCase();
result = ctx.getText().toLowerCase();
};
visitTerminal() {}
visitErrorNode() {}
enterEveryRule() {}
exitEveryRule() {}
}
const listenTableName = new MyListener();

View File

@ -1,5 +1,5 @@
import ImpalaSQL from 'src/parser/impala';
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { AbstractParseTreeVisitor } from 'antlr4ng';
import { ImpalaSqlParserVisitor } from 'src/lib/impala/ImpalaSqlParserVisitor';
describe('impala SQL Visitor Tests', () => {
@ -8,7 +8,7 @@ describe('impala SQL Visitor Tests', () => {
const parser = new ImpalaSQL();
const parseTree = parser.parse(sql, (error) => {
console.log('Parse error:', error);
console.error('Parse error:', error);
});
test('Visitor visitTableNamePath', () => {
@ -21,7 +21,7 @@ describe('impala SQL Visitor Tests', () => {
return result;
}
visitTableNamePath = (ctx): void => {
result = ctx.text.toLowerCase();
result = ctx.getText().toLowerCase();
};
}
const visitor: any = new MyVisitor();