aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/complete/syntax/grammar.h
blob: 4a259493dbcd6241d37b00e2c074b9b4ebb0eddc (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
#pragma once

#include <yql/essentials/sql/v1/complete/antlr4/defs.h>

#include <contrib/libs/antlr4_cpp_runtime/src/Vocabulary.h>

#include <unordered_set>
#include <string>
#include <string_view>

#ifdef TOKEN_QUERY // Conflict with the winnt.h
    #undef TOKEN_QUERY
#endif
#include <yql/essentials/parser/antlr_ast/gen/v1_antlr4/SQLv1Antlr4Parser.h>

#define RULE_(mode, name) NALA##mode##Antlr4::SQLv1Antlr4Parser::Rule##name
#define RULE(name) RULE_(Default, name)

namespace NSQLComplete {

    class ISqlGrammar {
    public:
        virtual const antlr4::dfa::Vocabulary& GetVocabulary() const = 0;
        virtual const std::string& SymbolizedRule(TRuleId rule) const = 0;
        virtual TRuleId GetRuleId(std::string_view symbolized) const = 0;
        virtual const std::vector<std::string>& GetAllRules() const = 0;
        virtual const std::unordered_set<TTokenId>& GetAllTokens() const = 0;
        virtual const std::unordered_set<TTokenId>& GetKeywordTokens() const = 0;
        virtual const std::unordered_set<TTokenId>& GetPunctuationTokens() const = 0;
        virtual ~ISqlGrammar() = default;
    };

    const ISqlGrammar& GetSqlGrammar();

} // namespace NSQLComplete