2023-06-09 11:22:53 +08:00
|
|
|
import { Token } from 'antlr4ts';
|
|
|
|
import { CandidatesCollection } from 'antlr4-c3';
|
2023-05-30 14:44:03 +08:00
|
|
|
import { TrinoSqlLexer } from '../lib/trinosql/TrinoSqlLexer';
|
2023-06-09 11:22:53 +08:00
|
|
|
import { TrinoSqlParser, ProgramContext } from '../lib/trinosql/TrinoSqlParser';
|
2023-05-24 15:07:02 +08:00
|
|
|
import BasicParser from './common/basicParser';
|
2023-06-09 11:22:53 +08:00
|
|
|
import { Suggestions } from './common/basic-parser-types';
|
|
|
|
|
|
|
|
export default class TrinoSQL extends BasicParser<TrinoSqlLexer, ProgramContext, TrinoSqlParser> {
|
2023-06-16 16:14:53 +08:00
|
|
|
protected createLexerFormCharStream(charStreams) {
|
2023-06-09 11:22:53 +08:00
|
|
|
const lexer = new TrinoSqlLexer(charStreams);
|
2023-05-24 15:07:02 +08:00
|
|
|
return lexer;
|
|
|
|
}
|
2023-06-09 11:22:53 +08:00
|
|
|
|
2023-06-16 16:14:53 +08:00
|
|
|
protected createParserFromTokenStream(tokenStream) {
|
2023-06-09 11:22:53 +08:00
|
|
|
const parser = new TrinoSqlParser(tokenStream);
|
2023-05-24 15:07:02 +08:00
|
|
|
return parser;
|
|
|
|
}
|
2023-06-09 11:22:53 +08:00
|
|
|
|
2023-10-13 11:16:36 +08:00
|
|
|
protected get splitListener() {
|
2023-06-09 11:22:53 +08:00
|
|
|
return null as any;
|
|
|
|
}
|
|
|
|
|
2023-06-16 16:14:53 +08:00
|
|
|
protected preferredRules: Set<number> = new Set();
|
2023-06-09 11:22:53 +08:00
|
|
|
|
2023-06-16 16:14:53 +08:00
|
|
|
protected processCandidates(
|
2023-10-13 11:16:36 +08:00
|
|
|
candidates: CandidatesCollection,
|
|
|
|
allTokens: Token[],
|
2023-06-09 11:22:53 +08:00
|
|
|
caretTokenIndex: number
|
|
|
|
): Suggestions<Token> {
|
|
|
|
return {
|
|
|
|
syntax: [],
|
2023-10-13 11:16:36 +08:00
|
|
|
keywords: [],
|
|
|
|
};
|
2023-06-09 11:22:53 +08:00
|
|
|
}
|
2023-05-24 15:07:02 +08:00
|
|
|
}
|