123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- #include "ast_nodes.h"
- namespace NYql::NJsonPath {
- TAstNode::TAstNode(TPosition pos)
- : Pos(pos)
- {
- }
- TPosition TAstNode::GetPos() const {
- return Pos;
- }
- EReturnType TAstNode::GetReturnType() const {
- return EReturnType::Any;
- }
- TRootNode::TRootNode(TPosition pos, TAstNodePtr expr, EJsonPathMode mode)
- : TAstNode(pos)
- , Expr(expr)
- , Mode(mode)
- {
- }
- const TAstNodePtr TRootNode::GetExpr() const {
- return Expr;
- }
- EJsonPathMode TRootNode::GetMode() const {
- return Mode;
- }
- void TRootNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitRoot(*this);
- }
- EReturnType TRootNode::GetReturnType() const {
- return Expr->GetReturnType();
- }
- TContextObjectNode::TContextObjectNode(TPosition pos)
- : TAstNode(pos)
- {
- }
- void TContextObjectNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitContextObject(*this);
- }
- TVariableNode::TVariableNode(TPosition pos, const TString& name)
- : TAstNode(pos)
- , Name(name)
- {
- }
- const TString& TVariableNode::GetName() const {
- return Name;
- }
- void TVariableNode::Accept(IAstNodeVisitor& visitor) const {
- visitor.VisitVariable(*this);
- }
- TLastArrayIndexNode::TLastArrayIndexNode(TPosition pos)
- : TAstNode(pos)
- {
- }
- void TLastArrayIndexNode::Accept(IAstNodeVisitor& visitor) const {
- visitor.VisitLastArrayIndex(*this);
- }
- TNumberLiteralNode::TNumberLiteralNode(TPosition pos, double value)
- : TAstNode(pos)
- , Value(value)
- {
- }
- double TNumberLiteralNode::GetValue() const {
- return Value;
- }
- void TNumberLiteralNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitNumberLiteral(*this);
- }
- TMemberAccessNode::TMemberAccessNode(TPosition pos, const TString& member, TAstNodePtr input)
- : TAstNode(pos)
- , Member(member)
- , Input(input)
- {
- }
- const TStringBuf TMemberAccessNode::GetMember() const {
- return Member;
- }
- const TAstNodePtr TMemberAccessNode::GetInput() const {
- return Input;
- }
- void TMemberAccessNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitMemberAccess(*this);
- }
- TWildcardMemberAccessNode::TWildcardMemberAccessNode(TPosition pos, TAstNodePtr input)
- : TAstNode(pos)
- , Input(input)
- {
- }
- const TAstNodePtr TWildcardMemberAccessNode::GetInput() const {
- return Input;
- }
- void TWildcardMemberAccessNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitWildcardMemberAccess(*this);
- }
- TArrayAccessNode::TArrayAccessNode(TPosition pos, TVector<TSubscript> subscripts, TAstNodePtr input)
- : TAstNode(pos)
- , Subscripts(subscripts)
- , Input(input)
- {
- }
- const TVector<TArrayAccessNode::TSubscript>& TArrayAccessNode::GetSubscripts() const {
- return Subscripts;
- }
- const TAstNodePtr TArrayAccessNode::GetInput() const {
- return Input;
- }
- void TArrayAccessNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitArrayAccess(*this);
- }
- TWildcardArrayAccessNode::TWildcardArrayAccessNode(TPosition pos, TAstNodePtr input)
- : TAstNode(pos)
- , Input(input)
- {
- }
- const TAstNodePtr TWildcardArrayAccessNode::GetInput() const {
- return Input;
- }
- void TWildcardArrayAccessNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitWildcardArrayAccess(*this);
- }
- TUnaryOperationNode::TUnaryOperationNode(TPosition pos, EUnaryOperation op, TAstNodePtr expr)
- : TAstNode(pos)
- , Operation(op)
- , Expr(expr)
- {
- }
- EUnaryOperation TUnaryOperationNode::GetOp() const {
- return Operation;
- }
- const TAstNodePtr TUnaryOperationNode::GetExpr() const {
- return Expr;
- }
- void TUnaryOperationNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitUnaryOperation(*this);
- }
- EReturnType TUnaryOperationNode::GetReturnType() const {
- return Operation == EUnaryOperation::Not ? EReturnType::Bool : EReturnType::Any;
- }
- TBinaryOperationNode::TBinaryOperationNode(TPosition pos, EBinaryOperation op, TAstNodePtr leftExpr, TAstNodePtr rightExpr)
- : TAstNode(pos)
- , Operation(op)
- , LeftExpr(leftExpr)
- , RightExpr(rightExpr)
- {
- }
- EBinaryOperation TBinaryOperationNode::GetOp() const {
- return Operation;
- }
- const TAstNodePtr TBinaryOperationNode::GetLeftExpr() const {
- return LeftExpr;
- }
- const TAstNodePtr TBinaryOperationNode::GetRightExpr() const {
- return RightExpr;
- }
- void TBinaryOperationNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitBinaryOperation(*this);
- }
- EReturnType TBinaryOperationNode::GetReturnType() const {
- switch (Operation) {
- case EBinaryOperation::Less:
- case EBinaryOperation::LessEqual:
- case EBinaryOperation::Greater:
- case EBinaryOperation::GreaterEqual:
- case EBinaryOperation::Equal:
- case EBinaryOperation::NotEqual:
- case EBinaryOperation::And:
- case EBinaryOperation::Or:
- return EReturnType::Bool;
- default:
- return EReturnType::Any;
- }
- }
- TBooleanLiteralNode::TBooleanLiteralNode(TPosition pos, bool value)
- : TAstNode(pos)
- , Value(value)
- {
- }
- bool TBooleanLiteralNode::GetValue() const {
- return Value;
- }
- void TBooleanLiteralNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitBooleanLiteral(*this);
- }
- TNullLiteralNode::TNullLiteralNode(TPosition pos)
- : TAstNode(pos)
- {
- }
- void TNullLiteralNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitNullLiteral(*this);
- }
- TStringLiteralNode::TStringLiteralNode(TPosition pos, const TString& value)
- : TAstNode(pos)
- , Value(value)
- {
- }
- const TString& TStringLiteralNode::GetValue() const {
- return Value;
- }
- void TStringLiteralNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitStringLiteral(*this);
- }
- TFilterObjectNode::TFilterObjectNode(TPosition pos)
- : TAstNode(pos)
- {
- }
- void TFilterObjectNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitFilterObject(*this);
- }
- TFilterPredicateNode::TFilterPredicateNode(TPosition pos, TAstNodePtr predicate, TAstNodePtr input)
- : TAstNode(pos)
- , Predicate(predicate)
- , Input(input)
- {
- }
- const TAstNodePtr TFilterPredicateNode::GetPredicate() const {
- return Predicate;
- }
- const TAstNodePtr TFilterPredicateNode::GetInput() const {
- return Input;
- }
- void TFilterPredicateNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitFilterPredicate(*this);
- }
- TMethodCallNode::TMethodCallNode(TPosition pos, EMethodType type, TAstNodePtr input)
- : TAstNode(pos)
- , Type(type)
- , Input(input)
- {
- }
- EMethodType TMethodCallNode::GetType() const {
- return Type;
- }
- const TAstNodePtr TMethodCallNode::GetInput() const {
- return Input;
- }
- void TMethodCallNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitMethodCall(*this);
- }
- TStartsWithPredicateNode::TStartsWithPredicateNode(TPosition pos, TAstNodePtr input, TAstNodePtr prefix)
- : TAstNode(pos)
- , Input(input)
- , Prefix(prefix)
- {
- }
- const TAstNodePtr TStartsWithPredicateNode::GetInput() const {
- return Input;
- }
- const TAstNodePtr TStartsWithPredicateNode::GetPrefix() const {
- return Prefix;
- }
- EReturnType TStartsWithPredicateNode::GetReturnType() const {
- return EReturnType::Bool;
- }
- void TStartsWithPredicateNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitStartsWithPredicate(*this);
- }
- TExistsPredicateNode::TExistsPredicateNode(TPosition pos, TAstNodePtr input)
- : TAstNode(pos)
- , Input(input)
- {
- }
- const TAstNodePtr TExistsPredicateNode::GetInput() const {
- return Input;
- }
- EReturnType TExistsPredicateNode::GetReturnType() const {
- return EReturnType::Bool;
- }
- void TExistsPredicateNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitExistsPredicate(*this);
- }
- TIsUnknownPredicateNode::TIsUnknownPredicateNode(TPosition pos, TAstNodePtr input)
- : TAstNode(pos)
- , Input(input)
- {
- }
- const TAstNodePtr TIsUnknownPredicateNode::GetInput() const {
- return Input;
- }
- EReturnType TIsUnknownPredicateNode::GetReturnType() const {
- return EReturnType::Bool;
- }
- void TIsUnknownPredicateNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitIsUnknownPredicate(*this);
- }
- TLikeRegexPredicateNode::TLikeRegexPredicateNode(TPosition pos, TAstNodePtr input, NReWrapper::IRePtr&& regex)
- : TAstNode(pos)
- , Input(input)
- , Regex(std::move(regex))
- {
- }
- const TAstNodePtr TLikeRegexPredicateNode::GetInput() const {
- return Input;
- }
- const NReWrapper::IRePtr& TLikeRegexPredicateNode::GetRegex() const {
- return Regex;
- }
- EReturnType TLikeRegexPredicateNode::GetReturnType() const {
- return EReturnType::Bool;
- }
- void TLikeRegexPredicateNode::Accept(IAstNodeVisitor& visitor) const {
- return visitor.VisitLikeRegexPredicate(*this);
- }
- }
|