summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/proto_parser/token.cpp
blob: b00d49b27ab29a49a0544079daed45373f8c1428 (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
#include "token.h"

#include "parse_tree.h"

#include <yql/essentials/utils/yql_panic.h>

namespace NSQLTranslationV1 {

TToken Beginning(const TRule_select_stmt& rule) {
    const auto& parenthesis = rule.GetRule_select_stmt_core2()
                                  .GetRule_select_stmt_intersect1()
                                  .GetRule_select_kind_parenthesis1();
    return Beginning(Unpack(parenthesis).GetRule_select_kind1());
}

TToken Beginning(const TRule_select_kind& rule) {
    const auto& block = rule.GetBlock2();
    switch (block.GetAltCase()) {
        case NSQLv1Generated::TRule_select_kind_TBlock2::kAlt1:
            return block.GetAlt1().GetRule_process_core1().GetToken1();
        case NSQLv1Generated::TRule_select_kind_TBlock2::kAlt2:
            return block.GetAlt2().GetRule_reduce_core1().GetToken1();
        case NSQLv1Generated::TRule_select_kind_TBlock2::kAlt3:
            return block.GetAlt3().GetRule_select_core1().GetToken2();
        case NSQLv1Generated::TRule_select_kind_TBlock2::kAlt4:
            return block.GetAlt4().GetRule_combine_core1().GetToken1();
        case NSQLv1Generated::TRule_select_kind_TBlock2::ALT_NOT_SET:
            YQL_ENSURE(false, "Unreachable");
    }
}

} // namespace NSQLTranslationV1