8 const std::shared_ptr<Expr> E;
9 const std::shared_ptr<AttrPath> Path;
10 const std::shared_ptr<Expr> Default;
14 std::shared_ptr<AttrPath> Path, std::shared_ptr<Expr> Default)
15 :
Expr(NK_ExprSelect, Range), E(std::move(E)), Path(std::move(Path)),
16 Default(std::move(Default)) {
17 assert(this->E &&
"E must not be null");
21 assert(E &&
"E must not be null");
30 return {E.get(), Path.get(), Default.get()};
36 const std::shared_ptr<Expr> Fn;
37 const std::vector<std::shared_ptr<Expr>> Args;
41 std::vector<std::shared_ptr<Expr>> Args)
42 :
Expr(NK_ExprCall, Range), Fn(std::move(Fn)), Args(std::move(Args)) {
43 assert(this->Fn &&
"Fn must not be null");
47 assert(Fn &&
"Fn must not be null");
51 [[nodiscard]]
const std::vector<std::shared_ptr<Expr>> &
args()
const {
57 Children.reserve(Args.size() + 1);
58 Children.emplace_back(Fn.get());
59 for (
const auto &Member : Args) {
60 Children.emplace_back(Member.get());
67 const std::vector<std::shared_ptr<Expr>> Elements;
71 :
Expr(NK_ExprList, Range), Elements(std::move(Elements)) {}
73 [[nodiscard]]
const std::vector<std::shared_ptr<Expr>> &
elements()
const {
79 Children.reserve(Elements.size());
80 for (
const auto &Element : Elements) {
81 Children.emplace_back(Element.get());
88 const std::shared_ptr<Expr> Cond;
89 const std::shared_ptr<Expr> Then;
90 const std::shared_ptr<Expr> Else;
94 std::shared_ptr<Expr> Then, std::shared_ptr<Expr> Else)
95 :
Expr(NK_ExprIf, Range), Cond(std::move(Cond)), Then(std::move(Then)),
96 Else(std::move(Else)) {}
98 [[nodiscard]]
Expr *
cond()
const {
return Cond.get(); }
99 [[nodiscard]]
Expr *
then()
const {
return Then.get(); }
103 return {Cond.get(), Then.get(), Else.get()};
108 const std::shared_ptr<Expr> Cond;
109 const std::shared_ptr<Expr>
114 std::shared_ptr<Expr> Value)
115 :
Expr(NK_ExprAssert, Range), Cond(std::move(Cond)),
116 Value(std::move(Value)) {}
118 [[nodiscard]]
Expr *
cond()
const {
return Cond.get(); }
119 [[nodiscard]]
Expr *
value()
const {
return Value.get(); }
122 return {Cond.get(), Value.get()};
129 const std::shared_ptr<Misc> KwLet;
130 const std::shared_ptr<Misc> KwIn;
131 const std::shared_ptr<Expr> E;
133 const std::shared_ptr<ExprAttrs> Attrs;
137 std::shared_ptr<Misc> KwIn, std::shared_ptr<Expr> E,
138 std::shared_ptr<ExprAttrs> Attrs)
139 :
Expr(NK_ExprLet, Range), KwLet(std::move(KwLet)), KwIn(std::move(KwIn)),
140 E(std::move(E)), Attrs(std::move(Attrs)) {
141 assert(this->KwLet &&
"KwLet should not be empty!");
145 return Attrs ? Attrs->binds() :
nullptr;
148 [[nodiscard]]
const Expr *
expr()
const {
return E.get(); }
149 [[nodiscard]]
const Misc &
let()
const {
return *KwLet; }
150 [[nodiscard]]
const Misc *
in()
const {
return KwIn.get(); }
153 return {KwLet.get(), Attrs.get(), KwIn.get(), E.get()};
158 const std::shared_ptr<Misc> KwWith;
159 const std::shared_ptr<Misc> TokSemi;
160 const std::shared_ptr<Expr> With;
161 const std::shared_ptr<Expr> E;
165 std::shared_ptr<Misc> TokSemi, std::shared_ptr<Expr> With,
166 std::shared_ptr<Expr> E)
167 :
Expr(NK_ExprWith, Range), KwWith(std::move(KwWith)),
168 TokSemi(std::move(TokSemi)), With(std::move(With)), E(std::move(E)) {}
171 [[nodiscard]]
const Misc *
tokSemi()
const {
return TokSemi.get(); }
172 [[nodiscard]]
Expr *
with()
const {
return With.get(); }
173 [[nodiscard]]
Expr *
expr()
const {
return E.get(); }
176 return {KwWith.get(), TokSemi.get(), With.get(), E.get()};
ExprAssert(LexerCursorRange Range, std::shared_ptr< Expr > Cond, std::shared_ptr< Expr > Value)
ChildVector children() const override
A call/apply to some function.
ExprCall(LexerCursorRange Range, std::shared_ptr< Expr > Fn, std::vector< std::shared_ptr< Expr > > Args)
ChildVector children() const override
const std::vector< std::shared_ptr< Expr > > & args() const
ExprIf(LexerCursorRange Range, std::shared_ptr< Expr > Cond, std::shared_ptr< Expr > Then, std::shared_ptr< Expr > Else)
ChildVector children() const override
ExprLet(LexerCursorRange Range, std::shared_ptr< Misc > KwLet, std::shared_ptr< Misc > KwIn, std::shared_ptr< Expr > E, std::shared_ptr< ExprAttrs > Attrs)
const Binds * binds() const
const ExprAttrs * attrs() const
const Expr * expr() const
ChildVector children() const override
const std::vector< std::shared_ptr< Expr > > & elements() const
ChildVector children() const override
ExprList(LexerCursorRange Range, std::vector< std::shared_ptr< Expr > > Elements)
ChildVector children() const override
ExprSelect(LexerCursorRange Range, std::shared_ptr< Expr > E, std::shared_ptr< AttrPath > Path, std::shared_ptr< Expr > Default)
Expr * defaultExpr() const
const Misc & kwWith() const
const Misc * tokSemi() const
ExprWith(LexerCursorRange Range, std::shared_ptr< Misc > KwWith, std::shared_ptr< Misc > TokSemi, std::shared_ptr< Expr > With, std::shared_ptr< Expr > E)
ChildVector children() const override
Misc node, used for parentheses, keywords, etc.
boost::container::small_vector< Node *, 8 > ChildVector