2023-05-04 10:13:05 +08:00
|
|
|
import { CharStream, CommonTokenStream, Lexer } from 'antlr4';
|
|
|
|
import SqlLexer from '../lib/generic/SqlLexer';
|
|
|
|
import SqlParser from '../lib/generic/SqlParser';
|
2021-01-05 15:27:43 +08:00
|
|
|
import BasicParser from './common/basicParser';
|
2020-09-11 17:39:10 +08:00
|
|
|
|
|
|
|
export default class GenericSQL extends BasicParser {
|
2023-05-04 10:13:05 +08:00
|
|
|
public createLexer(input: string): SqlLexer {
|
|
|
|
const chars = new CharStream(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform
|
|
|
|
const lexer = new SqlLexer(chars);
|
2020-09-11 17:39:10 +08:00
|
|
|
return lexer;
|
|
|
|
}
|
2023-05-04 10:13:05 +08:00
|
|
|
public createParserFromLexer(lexer: Lexer): SqlParser {
|
2020-09-11 17:39:10 +08:00
|
|
|
const tokenStream = new CommonTokenStream(lexer);
|
|
|
|
return new SqlParser(tokenStream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|