aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/lexer/lexer.h
blob: 226e8b6ed25ec62452786c823ebe84845dc8e16d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include <yql/essentials/parser/lexer_common/lexer.h>

namespace NSQLTranslationV1 {

struct TLexers {
    NSQLTranslation::TLexerFactoryPtr Antlr3;
    NSQLTranslation::TLexerFactoryPtr Antlr3Ansi;
    NSQLTranslation::TLexerFactoryPtr Antlr4;
    NSQLTranslation::TLexerFactoryPtr Antlr4Ansi;
    NSQLTranslation::TLexerFactoryPtr Antlr4Pure;
    NSQLTranslation::TLexerFactoryPtr Antlr4PureAnsi;
    NSQLTranslation::TLexerFactoryPtr Regex;
    NSQLTranslation::TLexerFactoryPtr RegexAnsi;
};

enum class ELexerFlavor {
    Default,
    Pure,
    Regex,
};

NSQLTranslation::ILexer::TPtr MakeLexer(
    const TLexers& lexers, bool ansi, bool antlr4, ELexerFlavor flavor = ELexerFlavor::Default);

// "Probably" because YQL keyword can be an identifier
// depending on a query context. For example
// in SELECT * FROM group - group is an identifier, but
// in SELECT * FROM ... GROUP BY ... - group is a keyword.
bool IsProbablyKeyword(const NSQLTranslation::TParsedToken& token);

bool SplitQueryToStatements(
    const TString& query, NSQLTranslation::ILexer::TPtr& lexer,
    TVector<TString>& statements, NYql::TIssues& issues, const TString& file = "",
    bool areBlankSkipped = true);
}