aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/parser/lexer_common/lexer.cpp
blob: c93dd35bd48c5b6d57a4e41bafb5bddf9c77afd3 (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 <util/string/builder.h>

namespace NSQLTranslation {

namespace {

class TDummyLexer : public ILexer {
public:
    TDummyLexer(const TString& name)
        : Name_(name)
    {}

    bool Tokenize(const TString& query, const TString& queryName, const TTokenCallback& onNextToken, NYql::TIssues& issues, size_t maxErrors) final {
        Y_UNUSED(query);
        Y_UNUSED(queryName);
        Y_UNUSED(onNextToken);
        Y_UNUSED(maxErrors);
        issues.AddIssue(NYql::TIssue({}, TStringBuilder() << "Lexer " << Name_ << " is not supported"));
        return false;
    }

private:
    const TString Name_;
};

class TDummyFactory: public ILexerFactory {
public:
    TDummyFactory(const TString& name)
        : Name_(name)
    {}

    ILexer::TPtr MakeLexer() const final {
        return MakeHolder<TDummyLexer>(Name_);
    }

private:
    const TString Name_;
};

}

TLexerFactoryPtr MakeDummyLexerFactory(const TString& name) {
    return MakeIntrusive<TDummyFactory>(name);
}

}