blob: f012c77583ca7e88f4e68184b669646004c74379 (
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
|
#include "evaluate.h"
namespace NSQLComplete {
namespace {
class TVisitor: public SQLv1Antlr4BaseVisitor {
public:
explicit TVisitor(const TEnvironment* env)
: Env_(env)
{
}
std::any visitBind_parameter(SQLv1::Bind_parameterContext* ctx) override {
TMaybe<std::string> id = GetId(ctx);
if (id.Empty()) {
return defaultResult();
}
if (const NYT::TNode* node = Env_->Parameters.FindPtr(*id)) {
return *node;
}
return defaultResult();
}
std::any defaultResult() override {
return NYT::TNode();
}
private:
const TEnvironment* Env_;
};
NYT::TNode EvaluateG(antlr4::ParserRuleContext* ctx, const TEnvironment& env) {
return std::any_cast<NYT::TNode>(TVisitor(&env).visit(ctx));
}
} // namespace
NYT::TNode Evaluate(SQLv1::Bind_parameterContext* ctx, const TEnvironment& env) {
return EvaluateG(ctx, env);
}
} // namespace NSQLComplete
|