dt-sql-parser
Version:
SQL Parsers for BigData, built with antlr4
50 lines (49 loc) • 1.39 kB
TypeScript
import type { ParserRuleContext, Token } from 'antlr4ng';
export interface WordPosition {
/** start at 0 */
readonly startIndex: number;
/** end at ..n-1 */
readonly endIndex: number;
/** start at 1 */
readonly line: number;
/** start at 1 */
readonly startColumn: number;
/** end at ..n + 1 */
readonly endColumn: number;
}
export interface WordRange extends WordPosition {
/** content of word */
readonly text: string;
}
export interface TextPosition {
/** start at 0 */
readonly startIndex: number;
/** end at ..n-1 */
readonly endIndex: number;
/** start at 1 */
readonly startLine: number;
/** end at ..n */
readonly endLine: number;
/** start at 1 */
readonly startColumn: number;
/** end at ..n + 1 */
readonly endColumn: number;
}
export interface TextSlice extends TextPosition {
readonly text: string;
}
/**
* Convert Token to Word
*/
export declare function tokenToWord(token: Token, input: string): WordRange;
/**
* Convert ParserRuleContext to Text
*/
export declare function ctxToText(ctx: ParserRuleContext, input: string): (TextPosition & {
text: string;
}) | null;
/**
* judge whether the context is a WordRange
* @param textOrWord TextSlice or WordRange object
* */
export declare function isWordRange(textOrWord: TextSlice | WordRange): textOrWord is WordRange;