blob: ecd1cf96d54001cc35e7c8f05955de9d1c49e101 (
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
39
40
41
42
43
44
45
46
47
48
49
|
#include "lexer.h"
#include <yql/essentials/public/issue/yql_issue.h>
#include <yql/essentials/parser/proto_ast/antlr3/proto_ast_antlr3.h>
#include <yql/essentials/parser/proto_ast/collect_issues/collect_issues.h>
#include <yql/essentials/parser/proto_ast/gen/v0/SQLLexer.h>
#if defined(_tsan_enabled_)
#include <util/system/mutex.h>
#endif
namespace NALP {
extern ANTLR_UINT8* SQLParserTokenNames[];
}
namespace NSQLTranslationV0 {
namespace {
#if defined(_tsan_enabled_)
TMutex SanitizerSQLTranslationMutex;
#endif
using NSQLTranslation::ILexer;
class TV0Lexer : public ILexer {
public:
TV0Lexer() = default;
bool Tokenize(const TString& query, const TString& queryName, const TTokenCallback& onNextToken, NYql::TIssues& issues, size_t maxErrors) override {
NYql::TIssues newIssues;
#if defined(_tsan_enabled_)
TGuard<TMutex> grd(SanitizerSQLTranslationMutex);
#endif
NSQLTranslation::TErrorCollectorOverIssues collector(newIssues, maxErrors, "");
NProtoAST::TLexerTokensCollector3<NALP::SQLLexer> tokensCollector(query, (const char**)NALP::SQLParserTokenNames, 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; });
}
};
} // namespace
NSQLTranslation::ILexer::TPtr MakeLexer() {
return NSQLTranslation::ILexer::TPtr(new TV0Lexer);
}
} // namespace NSQLTranslationV1
|