blob: e3f63c4b65a26b4e6286fd1df13174f2cebe6e59 (
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
38
|
#include "lexer.h"
#include <yql/essentials/parser/proto_ast/gen/v1_antlr4/SQLv1Antlr4Lexer.h>
#include <yql/essentials/parser/proto_ast/antlr4/proto_ast_antlr4.h>
#include <yql/essentials/parser/proto_ast/collect_issues/collect_issues.h>
#include <yql/essentials/public/issue/yql_issue.h>
namespace NSQLTranslationV1 {
namespace {
class TLexer: public NSQLTranslation::ILexer {
public:
bool Tokenize(const TString& query, const TString& queryName, const TTokenCallback& onNextToken, NYql::TIssues& issues, size_t maxErrors) final {
NYql::TIssues newIssues;
NSQLTranslation::TErrorCollectorOverIssues collector(newIssues, maxErrors, queryName);
NProtoAST::TLexerTokensCollector4<NALPDefaultAntlr4::SQLv1Antlr4Lexer> tokensCollector(query, queryName);
tokensCollector.CollectTokens(collector, onNextToken);
issues.AddIssues(newIssues);
return !AnyOf(newIssues.begin(), newIssues.end(), [](auto issue) { return issue.GetSeverity() == NYql::ESeverity::TSeverityIds_ESeverityId_S_ERROR; });
}
};
class TFactory: public NSQLTranslation::ILexerFactory {
public:
THolder<NSQLTranslation::ILexer> MakeLexer() const final {
return MakeHolder<TLexer>();
}
};
}
NSQLTranslation::TLexerFactoryPtr MakeAntlr4LexerFactory() {
return MakeIntrusive<TFactory>();
}
}
|