lava-oushudb-dt-sql-parser/src/parser/trinosql.ts
Hayden 9cf79064de
refactor: optimize basic parser interface (#121)
* feat: set all internal method to protected

* feat: public createLexer and createParser method

* feat: remove error listeners of parser when get suggestion
2023-06-16 16:14:53 +08:00

37 lines
1.1 KiB
TypeScript

import { Token } from 'antlr4ts';
import { CandidatesCollection } from 'antlr4-c3';
import { TrinoSqlLexer } from '../lib/trinosql/TrinoSqlLexer';
import { TrinoSqlParser, ProgramContext } from '../lib/trinosql/TrinoSqlParser';
import BasicParser from './common/basicParser';
import { Suggestions } from './common/basic-parser-types';
export default class TrinoSQL extends BasicParser<TrinoSqlLexer, ProgramContext, TrinoSqlParser> {
protected createLexerFormCharStream(charStreams) {
const lexer = new TrinoSqlLexer(charStreams);
return lexer;
}
protected createParserFromTokenStream(tokenStream) {
const parser = new TrinoSqlParser(tokenStream);
return parser;
}
protected get splitListener () {
return null as any;
}
protected preferredRules: Set<number> = new Set();
protected processCandidates(
candidates: CandidatesCollection,
allTokens: Token[],
caretTokenIndex: number
): Suggestions<Token> {
return {
syntax: [],
keywords: []
}
}
}