lava-oushudb-dt-sql-parser/src/parser/generic.ts

18 lines
680 B
TypeScript
Raw Normal View History

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';
import BasicParser from './common/basicParser';
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);
return lexer;
}
2023-05-04 10:13:05 +08:00
public createParserFromLexer(lexer: Lexer): SqlParser {
const tokenStream = new CommonTokenStream(lexer);
return new SqlParser(tokenStream);
}
}