27#ifndef OPENVDB_AX_AST_HAS_BEEN_INCLUDED
28#define OPENVDB_AX_AST_HAS_BEEN_INCLUDED
32#include <openvdb/version.h>
103 using Ptr = std::shared_ptr<Node>;
183 template <
typename NodeT>
185 return dynamic_cast<const NodeT*
>(
this);
205 virtual const Node*
child(
const size_t index)
const = 0;
213 const Node* p = this->parent();
217 for (; i < count; ++i) {
218 if (p->
child(i) ==
this)
break;
220 if (i == count)
return -1;
221 return static_cast<int64_t
>(i);
249 const int64_t idx = this->childidx();
250 if (idx == -1)
return false;
251 return this->parent()->replacechild(idx, node);
260 inline virtual bool replacechild(
const size_t index,
Node* node);
278 bool hasChild =
false;
279 for (
size_t i = 0; i < parent->
children(); ++i)
280 hasChild |= parent->
child(i) ==
this;
292 inline Node* parent() {
return mParent; }
296 Node* mParent =
nullptr;
299inline bool Node::replacechild(
const size_t,
Node*) {
return false; }
350 const Node*
child(
const size_t)
const override {
return nullptr; }
352 inline const std::string&
name()
const {
return mName; }
355 const std::string mName;
368 const Node*
child(
const size_t)
const override {
return nullptr; }
398 this->addStatement(statement);
407 for (
Statement* statement : statements) {
408 this->addStatement(statement);
417 this->addStatement(stmnt->copy());
427 const char*
nodename()
const override {
return "statement list"; }
429 const char*
subname()
const override {
return "stml"; }
434 size_t children() const override final {
return this->size(); }
437 if (i >= mList.size())
return nullptr;
438 return mList[i].get();
442 if (mList.size() <= i)
return false;
444 if (!expr)
return false;
445 mList[i].reset(expr);
451 inline size_t size()
const {
return mList.size(); }
457 mList.emplace_back(stmnt);
462 std::vector<Statement::UniquePtr> mList;
488 this->addStatement(statement);
495 Block(
const std::vector<Statement*>& statements)
497 for (
Statement* statement : statements) {
498 this->addStatement(statement);
506 this->addStatement(stmnt->copy());
516 const char*
nodename()
const override {
return "scoped block"; }
518 const char*
subname()
const override {
return "blk"; }
523 size_t children() const override final {
return this->size(); }
526 if (i >= mList.size())
return nullptr;
527 return mList[i].get();
531 if (mList.size() <= i)
return false;
533 if (!expr)
return false;
534 mList[i].reset(expr);
540 inline size_t size()
const {
return mList.size(); }
546 mList.emplace_back(stmnt);
551 std::vector<Statement::UniquePtr> mList;
563 using Ptr = std::shared_ptr<Tree>;
573 mBlock->setParent(
this);
579 : mBlock(new
Block(*other.mBlock)) {
580 mBlock->setParent(
this);
589 const char*
nodename()
const override {
return "tree"; }
591 const char*
subname()
const override {
return "tree"; }
596 size_t children() const override final {
return 1; }
599 if (i == 0)
return mBlock.get();
619 this->append(expression);
628 mExpressions.reserve(expressions.size());
630 this->append(expression);
639 mExpressions.reserve(other.mExpressions.size());
641 this->append(expr->copy());
653 const char*
nodename()
const override {
return "comma"; }
655 const char*
subname()
const override {
return "comma"; }
660 size_t children() const override final {
return this->size(); }
663 if (i >= mExpressions.size())
return nullptr;
664 return mExpressions[i].get();
668 if (mExpressions.size() <= i)
return false;
670 mExpressions[i].reset(expr);
676 inline size_t size()
const {
return mExpressions.size(); }
679 inline bool empty()
const {
return mExpressions.empty(); }
685 mExpressions.emplace_back(expr);
690 std::vector<Expression::UniquePtr> mExpressions;
727 : mLoopType(loopType)
728 , mConditional(condition)
732 assert(mConditional);
734 mConditional->setParent(
this);
735 mBody->setParent(
this);
738 mInitial->setParent(
this);
742 mIteration->setParent(
this);
750 : mLoopType(other.mLoopType)
751 , mConditional(other.mConditional->copy())
752 , mBody(other.mBody->copy())
753 , mInitial(other.hasInit() ? other.mInitial->copy() : nullptr)
754 , mIteration(other.hasIter() ? other.mIteration->copy() : nullptr) {
755 mConditional->setParent(
this);
756 mBody->setParent(
this);
759 mInitial->setParent(
this);
763 mIteration->setParent(
this);
773 const char*
nodename()
const override {
return "loop"; }
775 const char*
subname()
const override {
return "loop"; }
780 size_t children() const override final {
return 4; }
783 if (i == 0)
return mConditional.get();
784 if (i == 1)
return mBody.get();
785 if (i == 2)
return mInitial.get();
786 if (i == 3)
return mIteration.get();
792 if (i == 0 || i == 2) {
794 if (!stmt)
return false;
796 mConditional.reset(stmt);
800 mInitial.reset(stmt);
801 mInitial->setParent(
this);
807 if (!blk)
return false;
814 if (!expr)
return false;
815 mIteration.reset(expr);
827 inline bool hasInit()
const {
return static_cast<bool>(this->initial()); }
830 inline bool hasIter()
const {
return static_cast<bool>(this->iteration()); }
865 using UniquePtr = std::unique_ptr<ConditionalStatement>;
879 Block* falseBlock =
nullptr)
880 : mConditional(conditional)
881 , mTrueBranch(trueBlock)
882 , mFalseBranch(falseBlock) {
883 assert(mConditional);
885 mConditional->setParent(
this);
886 mTrueBranch->setParent(
this);
887 if (mFalseBranch) mFalseBranch->setParent(
this);
895 : mConditional(other.mConditional->copy())
896 , mTrueBranch(other.mTrueBranch->copy())
897 , mFalseBranch(other.hasFalse() ? other.mFalseBranch->copy() : nullptr) {
898 mConditional->setParent(
this);
899 mTrueBranch->setParent(
this);
900 if (mFalseBranch) mFalseBranch->setParent(
this);
911 const char*
nodename()
const override {
return "conditional statement"; }
913 const char*
subname()
const override {
return "cond"; }
918 size_t children() const override final {
return 3; }
921 if (i == 0)
return this->condition();
922 if (i == 1)
return this->trueBranch();
923 if (i == 2)
return this->falseBranch();
931 if (!expr)
return false;
932 mConditional.reset(expr);
936 else if (i == 1 || i == 2) {
938 if (!blk)
return false;
940 mTrueBranch.reset(blk);
944 mFalseBranch.reset(blk);
945 mFalseBranch->setParent(
this);
955 return static_cast<bool>(this->falseBranch());
961 return this->hasFalse() ? 2 : 1;
1007 mLeft->setParent(
this);
1008 mRight->setParent(
this);
1017 const std::string& op)
1024 : mLeft(other.mLeft->copy())
1025 , mRight(other.mRight->copy())
1026 , mOperation(other.mOperation) {
1027 mLeft->setParent(
this);
1028 mRight->setParent(
this);
1039 const char*
nodename()
const override {
return "binary"; }
1041 const char*
subname()
const override {
return "bin"; }
1048 if (i == 0)
return mLeft.get();
1049 if (i == 1)
return mRight.get();
1054 if (i > 1)
return false;
1056 if (!expr)
return false;
1063 mRight->setParent(
this);
1107 : mConditional(conditional)
1108 , mTrueBranch(trueExpression)
1109 , mFalseBranch(falseExpression) {
1110 assert(mConditional);
1111 assert(mFalseBranch);
1112 mConditional->setParent(
this);
1113 if (mTrueBranch) mTrueBranch->setParent(
this);
1114 mFalseBranch->setParent(
this);
1121 : mConditional(other.mConditional->copy())
1122 , mTrueBranch(other.hasTrue() ? other.mTrueBranch->copy() : nullptr)
1123 , mFalseBranch(other.mFalseBranch->copy()) {
1124 mConditional->setParent(
this);
1125 if (mTrueBranch) mTrueBranch->setParent(
this);
1126 mFalseBranch->setParent(
this);
1137 const char*
nodename()
const override {
return "ternary"; }
1139 const char*
subname()
const override {
return "tern"; }
1146 if (i == 0)
return mConditional.get();
1147 if (i == 1)
return mTrueBranch.get();
1148 if (i == 2)
return mFalseBranch.get();
1153 if (i > 2)
return false;
1155 if (!expr)
return false;
1157 mConditional.reset(expr);
1161 mTrueBranch.reset(expr);
1162 mTrueBranch->setParent(
this);
1165 mFalseBranch.reset(expr);
1166 mFalseBranch->setParent(
this);
1172 bool hasTrue()
const {
return static_cast<bool>(this->trueBranch()); }
1214 mLHS->setParent(
this);
1215 mRHS->setParent(
this);
1223 : mLHS(other.mLHS->copy())
1224 , mRHS(other.mRHS->copy())
1225 , mOperation(other.mOperation) {
1226 mLHS->setParent(
this);
1227 mRHS->setParent(
this);
1238 const char*
nodename()
const override {
return "assignment expression"; }
1240 const char*
subname()
const override {
return "asgn"; }
1247 if (i == 0)
return this->lhs();
1248 if (i == 1)
return this->rhs();
1253 if (i > 1)
return false;
1255 if (!expr)
return false;
1262 mRHS->setParent(
this);
1314 mExpression->setParent(
this);
1321 : mExpression(other.mExpression->copy())
1322 , mOperation(other.mOperation)
1323 , mPost(other.mPost) {
1324 mExpression->setParent(
this);
1333 const char*
nodename()
const override {
return "crement"; }
1335 const char*
subname()
const override {
return "crmt"; }
1343 if (i == 0)
return this->expression();
1348 if (i != 0)
return false;
1350 if (!expr)
return false;
1351 mExpression.reset(expr);
1363 inline bool increment()
const {
return mOperation == Increment; }
1366 inline bool decrement()
const {
return mOperation == Decrement; }
1369 inline bool pre()
const {
return !mPost; }
1372 inline bool post()
const {
return mPost; }
1379 const Operation mOperation;
1400 assert(mExpression);
1401 mExpression->setParent(
this);
1414 : mExpression(other.mExpression->copy())
1415 , mOperation(other.mOperation) {
1416 mExpression->setParent(
this);
1425 const char*
nodename()
const override {
return "unary"; }
1427 const char*
subname()
const override {
return "unry"; }
1434 if (i == 0)
return this->expression();
1439 if (i != 0)
return false;
1441 if (!expr)
return false;
1442 mExpression.reset(expr);
1475 , mExpression(expr) {
1476 assert(mExpression);
1477 mExpression->setParent(
this);
1485 , mType(other.mType)
1486 , mExpression(other.mExpression->copy()) {
1496 const char*
nodename()
const override {
return "cast"; }
1498 const char*
subname()
const override {
return "cast"; }
1505 if (i == 0)
return this->expression();
1510 if (i != 0)
return false;
1512 if (!expr)
return false;
1513 mExpression.reset(expr);
1552 : mFunctionName(function)
1554 this->append(argument);
1563 const std::vector<Expression*>& arguments)
1564 : mFunctionName(function)
1566 mArguments.reserve(arguments.size());
1576 : mFunctionName(other.mFunctionName)
1578 mArguments.reserve(other.mArguments.size());
1580 this->append(expr->copy());
1590 const char*
nodename()
const override {
return "function call"; }
1592 const char*
subname()
const override {
return "call"; }
1596 size_t children() const override final {
return this->size(); }
1599 if (i >= mArguments.size())
return nullptr;
1600 return mArguments[i].get();
1604 if (mArguments.size() <= i)
return false;
1606 mArguments[i].reset(expr);
1613 inline const std::string&
name()
const {
return mFunctionName; }
1616 inline size_t numArgs()
const {
return mArguments.size(); }
1619 inline size_t size()
const {
return mArguments.size(); }
1622 inline bool empty()
const {
return mArguments.empty(); }
1628 mArguments.emplace_back(expr);
1633 const std::string mFunctionName;
1634 std::vector<Expression::UniquePtr> mArguments;
1651 : mKeyword(other.mKeyword) {}
1659 const char*
nodename()
const override {
return "keyword"; }
1661 const char*
subname()
const override {
return "keyw"; }
1703 , mExpression(expr) {
1705 assert(mExpression);
1706 mIdx0->setParent(
this);
1707 if(mIdx1) mIdx1->setParent(
this);
1708 mExpression->setParent(
this);
1716 other.mIdx0->copy(),
1717 other.mIdx1 ? other.mIdx1->copy() : nullptr) {}
1726 const char*
nodename()
const override {
return "array unpack"; }
1728 const char*
subname()
const override {
return "unpk"; }
1735 if (i == 0)
return this->component0();
1736 if (i == 1)
return this->component1();
1737 if (i == 2)
return this->expression();
1742 if (i > 2)
return false;
1744 if (!expr)
return false;
1745 if (i == 0) mIdx0.reset(expr);
1746 if (i == 1) mIdx1.reset(expr);
1747 if (i == 2) mExpression.reset(expr);
1775 return static_cast<bool>(this->component1());
1795 this->append(expression);
1803 mExpressions.reserve(arguments.size());
1813 mExpressions.reserve(other.mExpressions.size());
1815 this->append(expr->copy());
1825 const char*
nodename()
const override {
return "array pack"; }
1827 const char*
subname()
const override {
return "pack"; }
1831 size_t children() const override final {
return this->size(); }
1834 if (i >= mExpressions.size())
return nullptr;
1835 return mExpressions[i].get();
1839 if (mExpressions.size() <= i)
return false;
1841 mExpressions[i].reset(expr);
1847 inline size_t size()
const {
return mExpressions.size(); }
1850 inline bool empty()
const {
return mExpressions.empty(); }
1856 mExpressions.emplace_back(expr);
1861 std::vector<Expression::UniquePtr> mExpressions;
1885 const bool inferred =
false)
1888 , mTypeInferred(inferred) {}
1896 Attribute(
const std::string& name,
const std::string& token,
1897 const bool inferred =
false)
1905 , mType(other.mType)
1906 , mTypeInferred(other.mTypeInferred) {}
1914 const char*
nodename()
const override {
return "attribute"; }
1916 const char*
subname()
const override {
return "atr"; }
1938 return Attribute::tokenFromNameType(this->name(), this->type());
1957 static inline std::string
1960 Attribute::symbolseparator() + name;
1975 const size_t at = token.find(symbolseparator());
1976 if (at == std::string::npos)
return false;
1978 *type = token.substr(0, at);
1979 if (type->empty()) {
1983 if (name) *name = token.substr(at + 1, token.size());
1988 const bool mTypeInferred;
2025 , mType(other.mType) {}
2035 const char*
nodename()
const override {
return "external"; }
2037 const char*
subname()
const override {
return "ext"; }
2055 return ExternalVariable::tokenFromNameType(this->name(), this->type());
2074 static inline std::string
2077 ExternalVariable::symbolseparator() + name;
2092 const size_t at = token.find(symbolseparator());
2093 if (at == std::string::npos)
return false;
2095 *type = token.substr(0, at);
2096 if (type->empty()) {
2100 if (name) *name = token.substr(at + 1, token.size());
2126 const char*
nodename()
const override {
return "local"; }
2128 const char*
subname()
const override {
return "lcl"; }
2151 mLocal->setParent(
this);
2152 if (mInit) mInit->setParent(
this);
2159 : mType(other.mType)
2160 , mLocal(other.mLocal->copy())
2161 , mInit(other.hasInit() ? other.mInit->copy() : nullptr) {
2162 mLocal->setParent(
this);
2163 if (mInit) mInit->setParent(
this);
2172 const char*
nodename()
const override {
return "declaration"; }
2174 const char*
subname()
const override {
return "dcl"; }
2181 if (i == 0)
return this->local();
2182 if (i == 1)
return this->init();
2187 if (i > 1)
return false;
2190 if (!local)
return false;
2191 mLocal.reset(local);
2196 if (!init)
return false;
2216 inline bool hasInit()
const {
return static_cast<bool>(this->init()); }
2251template <
typename T>
2265 static constexpr bool IsSupported =
2272 static_assert(IsSupported,
"Incompatible ast::Value node instantiated.");
2284 : mValue(other.mValue) {}
2324 inline T
value()
const {
return static_cast<T
>(mValue); }
2329 const ContainerType mValue;
2351 const char*
nodename()
const override {
return "string value"; }
2352 const char*
subname()
const override {
return "str"; }
2357 inline const std::string&
value()
const {
return mValue; }
2363openvdb::ax::ast::Tree::Ptr
parse(
const char* code);
ValueT value
Definition: GridBuilder.h:1287
Various function and operator tokens used throughout the AST and code generation.
@ EQUALS
Definition: axparser.h:115
@ FLOAT
Definition: axparser.h:75
@ FOR
Definition: axparser.h:63
CoreType tokenFromTypeString(const std::string &type)
Definition: Tokens.h:66
OperatorToken
Definition: Tokens.h:151
KeywordToken
Definition: Tokens.h:315
std::string typeStringFromToken(const CoreType type)
Definition: Tokens.h:118
LoopToken
Definition: Tokens.h:297
OperatorToken operatorTokenFromName(const std::string &name)
Definition: Tokens.h:221
CoreType
Definition: Tokens.h:32
openvdb::ax::ast::Tree::Ptr parse(const char *code)
Construct an abstract syntax tree from a code snippet. A runtime exception will be thrown with the fi...
Definition: Exceptions.h:13
ArrayPacks represent temporary container creations of arbitrary sizes, typically generated through th...
Definition: AST.h:1785
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1823
~ArrayPack() override=default
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1825
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1833
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1831
size_t size() const
Alias for ArrayPack::children.
Definition: AST.h:1847
ArrayPack(const std::vector< Expression * > &arguments)
Construct a new ArrayPack transferring ownership of any provided arguments to the ArrayPack and updat...
Definition: AST.h:1801
ArrayPack * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1821
void append(Expression *expr)
Appends an argument to this ArrayPack, transferring ownership to the ArrayPack and updating parent da...
Definition: AST.h:1854
bool empty() const
Query whether this Expression list holds any valid expressions.
Definition: AST.h:1850
ArrayPack(const ArrayPack &other)
Deep copy constructor for a ArrayPack, performing a deep copy on all held arguments,...
Definition: AST.h:1811
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1829
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1838
ArrayPack(Expression *expression)
Construct a new ArrayPack with a single expression, transferring ownership of the expression to the A...
Definition: AST.h:1793
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1827
ArrayUnpack represent indexing operations into AX container types, primarily vectors and matrices ind...
Definition: AST.h:1686
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1724
ArrayUnpack(const ArrayUnpack &other)
Deep copy constructor for a ArrayUnpack, performing a deep copy on the expression being indexed and a...
Definition: AST.h:1714
ArrayUnpack * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1722
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1726
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1732
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1734
const Expression * expression() const
Access a const pointer to the expression being indexed as an abstract Expression.
Definition: AST.h:1764
bool isMatrixIndex() const
Query whether this ArrayUnpack operation must be a matrix indexing operation by checking the presence...
Definition: AST.h:1773
~ArrayUnpack() override=default
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1730
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1741
const Expression * component1() const
Access a const pointer to the second component being used as an abstract Expression.
Definition: AST.h:1760
const Expression * component0() const
Access a const pointer to the first component being used as an abstract Expression.
Definition: AST.h:1755
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1728
ArrayUnpack(Expression *expr, Expression *component0, Expression *component1=nullptr)
Construct a new ArrayUnpack with a valid expression, an initial component (as an expression) to the f...
Definition: AST.h:1698
AssignExpressions represents a similar object construction to a BinaryOperator. AssignExpressions can...
Definition: AST.h:1198
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1236
AssignExpression * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1232
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1238
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1246
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1244
~AssignExpression() override=default
const Expression * lhs() const
Access a const pointer to the AssignExpression LHS as an abstract expression.
Definition: AST.h:1279
tokens::OperatorToken operation() const
Query the actual operational type of this AssignExpression. For simple (non-compound) AssignExpressio...
Definition: AST.h:1275
const Expression * rhs() const
Access a const pointer to the AssignExpression RHS as an.
Definition: AST.h:1283
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1242
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1252
bool isCompound() const
Query whether or not this is a compound AssignExpression. Compound AssignExpressions are assignments ...
Definition: AST.h:1271
AssignExpression(const AssignExpression &other)
Deep copy constructor for an AssignExpression, performing a deep copy on both held expressions,...
Definition: AST.h:1222
AssignExpression(Expression *lhs, Expression *rhs, const tokens::OperatorToken op=tokens::EQUALS)
Construct a new AssignExpression with valid LHS and RHS expressions, transferring ownership of the ex...
Definition: AST.h:1207
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1240
Attributes represent any access to a primitive value, typically associated with the '@' symbol syntax...
Definition: AST.h:1874
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1912
bool inferred() const
Query whether this attribute was accessed via inferred syntax i.e. @P or @myattribute.
Definition: AST.h:1923
static char symbolseparator()
Static method returning the symbol associated with an Attribute access as defined by AX Grammar.
Definition: AST.h:1944
Attribute(const std::string &name, const std::string &token, const bool inferred=false)
Construct a new Attribute with a given name and type/token string, delegating construction to the abo...
Definition: AST.h:1896
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1914
Attribute(const std::string &name, const tokens::CoreType type, const bool inferred=false)
Construct a new Attribute with a given name and type. Optionally also mark it as inferred type creati...
Definition: AST.h:1884
const Variable * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1918
static std::string tokenFromNameType(const std::string &name, const tokens::CoreType type)
Static method returning the full unique attribute token identifier by consolidating its name and type...
Definition: AST.h:1958
static bool nametypeFromToken(const std::string &token, std::string *name, std::string *type)
Static method which splits a valid attribute token into its name and type counterparts....
Definition: AST.h:1974
Attribute * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1910
std::string tokenname() const
Construct and return the full attribute token identifier. See Attribute::tokenFromNameType.
Definition: AST.h:1937
tokens::CoreType type() const
Access the type that was used to access this attribute.
Definition: AST.h:1926
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1916
~Attribute() override=default
Attribute(const Attribute &other)
Deep copy constructor for a Attribute.
Definition: AST.h:1903
std::string typestr() const
Get the access type as a front end AX type/token string.
Definition: AST.h:1931
A BinaryOperator represents a single binary operation between a left hand side (LHS) and right hand s...
Definition: AST.h:988
BinaryOperator(Expression *left, Expression *right, const tokens::OperatorToken op)
Construct a new BinaryOperator with a given tokens::OperatorToken and a valid LHS and RHS expression,...
Definition: AST.h:999
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1037
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1039
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1047
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1045
const Expression * lhs() const
Access a const pointer to the BinaryOperator LHS as an abstract expression.
Definition: AST.h:1074
tokens::OperatorToken operation() const
Query the type of binary operation held on this node.
Definition: AST.h:1070
const Expression * rhs() const
Access a const pointer to the BinaryOperator RHS as an abstract expression.
Definition: AST.h:1078
BinaryOperator * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1033
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1043
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1053
BinaryOperator(const BinaryOperator &other)
Deep copy constructor for a BinaryOperator, performing a deep copy on both held expressions,...
Definition: AST.h:1023
~BinaryOperator() override=default
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1041
BinaryOperator(Expression *left, Expression *right, const std::string &op)
Construct a new BinaryOperator with a string, delegating construction to the above BinaryOperator con...
Definition: AST.h:1015
A Block node represents a scoped list of statements. It may comprise of 0 or more statements,...
Definition: AST.h:476
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:514
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:516
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:523
size_t size() const
Alias for Block::children.
Definition: AST.h:540
Block()
Construct a new Block with an empty list.
Definition: AST.h:480
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:520
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:525
Block(const Block &other)
Deep copy constructor for a Block, performing a deep copy on every held statement,...
Definition: AST.h:504
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:530
Block(Statement *statement)
Construct a new Block with a single statement, transferring ownership of the statement to the block a...
Definition: AST.h:486
void addStatement(Statement *stmnt)
Adds a statement to this block, transferring ownership to the block and updating parent data on the s...
Definition: AST.h:544
Block * copy() const override final
The deep copy method for a Node.
Definition: AST.h:512
std::unique_ptr< Block > UniquePtr
Definition: AST.h:477
Block(const std::vector< Statement * > &statements)
Construct a new Block from a vector of statements, transferring ownership of all valid statements to ...
Definition: AST.h:495
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:518
~Block() override=default
Cast nodes represent the conversion of an underlying expression to a target type. Cast nodes are typi...
Definition: AST.h:1464
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1494
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1496
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1504
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1502
Cast(const Cast &other)
Deep copy constructor for a Cast node, performing a deep copy on the underlying expressions,...
Definition: AST.h:1483
const Expression * expression() const
Access a const pointer to the Cast node's expression as an abstract expression.
Definition: AST.h:1531
Cast(Expression *expr, const tokens::CoreType type)
Construct a new Cast with a valid expression and a target tokens::CoreType, transferring ownership of...
Definition: AST.h:1472
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1500
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1509
Cast * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1492
tokens::CoreType type() const
Access to the target type.
Definition: AST.h:1520
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1498
std::string typestr() const
Get the target type as a front end AX type/token string.
Definition: AST.h:1525
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:651
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:653
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:662
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:660
size_t size() const
Alias for CommaOperator::children.
Definition: AST.h:676
void append(Expression *expr)
Append an expression to this CommaOperator, transferring ownership to the CommaOperator and updating ...
Definition: AST.h:683
CommaOperator(const CommaOperator &other)
Deep copy constructor for an CommaOperator, performing a deep copy on every held expression,...
Definition: AST.h:637
bool empty() const
Query whether this Expression list holds any valid expressions.
Definition: AST.h:679
CommaOperator(Expression *expression)
Construct a new CommaOperator with a single expression, transferring ownership of the expression to t...
Definition: AST.h:617
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:657
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:667
~CommaOperator() override=default
CommaOperator()
Construct a new CommaOperator with an expr set.
Definition: AST.h:611
CommaOperator(const std::vector< Expression * > &expressions)
Construct a new CommaOperator from a vector of expression, transferring ownership of all valid expres...
Definition: AST.h:626
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:655
CommaOperator * copy() const override final
The deep copy method for a Node.
Definition: AST.h:647
ConditionalStatements represents all combinations of 'if', 'else' and 'else if' syntax and semantics....
Definition: AST.h:864
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:909
~ConditionalStatement() override=default
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:911
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:918
bool hasFalse() const
Query if this ConditionalStatement has a valid 'false' branch.
Definition: AST.h:954
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:915
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:920
ConditionalStatement * copy() const override final
The deep copy method for a Node.
Definition: AST.h:905
const Block * trueBranch() const
Access a const pointer to the ConditionalStatements 'true' branch as a Block.
Definition: AST.h:970
ConditionalStatement(Expression *conditional, Block *trueBlock, Block *falseBlock=nullptr)
Construct a new ConditionalStatement with an Expression representing the primary condition,...
Definition: AST.h:877
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:927
const Block * falseBranch() const
Access a const pointer to the ConditionalStatements 'false' branch as a Block.
Definition: AST.h:974
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:913
ConditionalStatement(const ConditionalStatement &other)
Deep copy constructor for an ConditionalStatement, performing a deep copy on the condition and both h...
Definition: AST.h:894
size_t branchCount() const
Query the number of branches held by this ConditionalStatement. This is only ever 1 or 2.
Definition: AST.h:960
const Expression * condition() const
Access a const pointer to the ConditionalStatements condition as an abstract expression.
Definition: AST.h:966
A Crement node represents a single increment '++' and decrement '–' operation. As well as it's cremen...
Definition: AST.h:1294
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1331
Crement(const Crement &other)
Deep copy constructor for a Crement, performing a deep copy on the underlying expressions,...
Definition: AST.h:1320
bool decrement() const
Query if this Crement node represents an decrement –.
Definition: AST.h:1366
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1333
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1342
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1340
const Expression * expression() const
Access a const pointer to the expression being crements as an abstract Expression.
Definition: AST.h:1376
Crement * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1329
bool post() const
Query if this Crement node represents a post crement a++.
Definition: AST.h:1372
Crement(Expression *expr, const Operation op, bool post)
Construct a new Crement with a valid expression, transferring ownership of the expression to the Crem...
Definition: AST.h:1310
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1337
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1347
bool increment() const
Query if this Crement node represents an incrementation ++.
Definition: AST.h:1363
~Crement() override=default
Operation
A simple enum representing the crement type.
Definition: AST.h:1298
@ Increment
Definition: AST.h:1299
bool pre() const
Query if this Crement node represents a pre crement ++a.
Definition: AST.h:1369
Operation operation() const
Query the type of the Crement operation. This does not hold post or pre-crement information.
Definition: AST.h:1360
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1335
DeclareLocal AST nodes symbolize a single type declaration of a local variable. These store the local...
Definition: AST.h:2139
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2170
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2172
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:2180
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:2178
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2176
DeclareLocal * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2168
DeclareLocal(const DeclareLocal &other)
Deep copy constructor for a DeclareLocal.
Definition: AST.h:2158
const Local * local() const
Access a const pointer to the Local.
Definition: AST.h:2220
DeclareLocal(const tokens::CoreType type, Local *local, Expression *init=nullptr)
Construct a new DeclareLocal with a given name and type.
Definition: AST.h:2146
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:2186
const Expression * init() const
Access a const pointer to the initialiser.
Definition: AST.h:2223
tokens::CoreType type() const
Access the type that was specified at which to create the given local.
Definition: AST.h:2206
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2174
~DeclareLocal() override=default
bool hasInit() const
Query if this declaration has an initialiser.
Definition: AST.h:2216
std::string typestr() const
Get the declaration type as a front end AX type/token string.
Definition: AST.h:2211
Expressions are comprised of full or potentially partial parts of a full statement that may not neces...
Definition: AST.h:326
virtual Expression * copy() const override=0
The deep copy method for a Node.
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:330
~Expression() override=default
std::unique_ptr< Expression > UniquePtr
Definition: AST.h:327
ExternalVariable represent any access to external (custom) data, typically associated with the '$' sy...
Definition: AST.h:2002
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2033
ExternalVariable(const std::string &name, const tokens::CoreType type)
Construct a new ExternalVariable with a given name and type.
Definition: AST.h:2008
static char symbolseparator()
Static method returning the symbol associated with an ExternalVariable access as defined by AX Gramma...
Definition: AST.h:2061
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2035
const std::string tokenname() const
Construct and return the full external token identifier. See ExternalVariable::tokenFromNameType.
Definition: AST.h:2054
ExternalVariable(const std::string &name, const std::string &token)
Construct a new ExternalVariable with a given name and type/token string, delegating construction to ...
Definition: AST.h:2016
ExternalVariable(const ExternalVariable &other)
Deep copy constructor for a ExternalVariable.
Definition: AST.h:2023
const Variable * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2039
static std::string tokenFromNameType(const std::string &name, const tokens::CoreType type)
Static method returning the full unique external token identifier by consolidating its name and type ...
Definition: AST.h:2075
static bool nametypeFromToken(const std::string &token, std::string *name, std::string *type)
Static method which splits a valid external token into its name and type counterparts....
Definition: AST.h:2091
tokens::CoreType type() const
Access the type that was used to access this external variable.
Definition: AST.h:2043
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2037
ExternalVariable * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2029
~ExternalVariable() override=default
std::string typestr() const
Get the access type as a front end AX type/token string.
Definition: AST.h:2048
FunctionCalls represent a single call to a function and any provided arguments. The argument list can...
Definition: AST.h:1541
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1588
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1590
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1598
const std::string & name() const
Access the function name/identifier.
Definition: AST.h:1613
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1596
size_t size() const
Alias for FunctionCall::children.
Definition: AST.h:1619
size_t numArgs() const
Query the total number of arguments stored on this function.
Definition: AST.h:1616
FunctionCall(const std::string &function, const std::vector< Expression * > &arguments)
Construct a new FunctionCall with a given function identifier and optional argument list,...
Definition: AST.h:1562
void append(Expression *expr)
Appends an argument to this function call, transferring ownership to the FunctionCall and updating pa...
Definition: AST.h:1626
bool empty() const
Query whether this Expression list holds any valid expressions.
Definition: AST.h:1622
~FunctionCall() override=default
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1594
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1603
FunctionCall * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1586
FunctionCall(const FunctionCall &other)
Deep copy constructor for a FunctionCall, performing a deep copy on all held function arguments,...
Definition: AST.h:1575
FunctionCall(const std::string &function, Expression *argument=nullptr)
Construct a new FunctionCall with a given function identifier and an optional argument,...
Definition: AST.h:1550
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1592
Keywords represent keyword statements defining changes in execution. These include those that define ...
Definition: AST.h:1641
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1657
~Keyword() override=default
tokens::KeywordToken keyword() const
Query the keyword held on this node.
Definition: AST.h:1672
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1659
Keyword(const tokens::KeywordToken keyw)
Construct a new Keyword with a given tokens::KeywordToken.
Definition: AST.h:1646
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1665
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1663
Keyword * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1655
const Node * child(const size_t) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1667
Keyword(const Keyword &other)
Deep copy constructor for a Keyword.
Definition: AST.h:1650
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1661
Local AST nodes represent a single accesses to a local variable. The only store the name of the varia...
Definition: AST.h:2112
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2124
Local(const std::string &name)
Construct a Local with a given name.
Definition: AST.h:2117
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2126
std::unique_ptr< Local > UniquePtr
Definition: AST.h:2113
const Variable * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2130
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2128
Local * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2122
~Local() override=default
Loops represent for, while and do-while loop constructs. These all consist of a condition - evaluated...
Definition: AST.h:708
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:771
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:773
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:780
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:777
const Statement * condition() const
Access a const pointer to the Loop condition as an abstract statement.
Definition: AST.h:834
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:782
Loop(const Loop &other)
Deep copy constructor for an Loop, performing a deep copy on the condition, body and initial Statemen...
Definition: AST.h:749
Loop * copy() const override final
The deep copy method for a Node.
Definition: AST.h:769
Loop(const tokens::LoopToken loopType, Statement *condition, Block *body, Statement *init=nullptr, Expression *iter=nullptr)
Construct a new Loop with the type defined by a tokens::LoopToken, a condition Statement,...
Definition: AST.h:722
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:790
bool hasIter() const
Query if this Loop has a valid iteration expression list.
Definition: AST.h:830
tokens::LoopToken loopType() const
Query the type of loop held on this node.
Definition: AST.h:824
const Statement * initial() const
Access a const pointer to the Loop initial statement as an abstract statement.
Definition: AST.h:841
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:775
const Expression * iteration() const
Access a const pointer to the Loop iteration Expression.
Definition: AST.h:844
bool hasInit() const
Query if this Loop has a valid initial statement.
Definition: AST.h:827
const Block * body() const
Access a const pointer to the Loop body as a Block.
Definition: AST.h:837
The base abstract node which determines the interface and required methods for all derived concrete n...
Definition: AST.h:102
bool replace(Node *node)
In place replacement. Attempts to replace this node at its specific location within its Abstract Synt...
Definition: AST.h:247
std::unique_ptr< Node > UniquePtr
Definition: AST.h:104
virtual size_t children() const =0
Virtual method for accessing child information. Returns the number of children a given AST node owns.
bool isType() const
Query whether or not this node is of a specific (derived) type. This method should be used to check i...
Definition: AST.h:184
virtual const Node * child(const size_t index) const =0
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
int64_t childidx() const
Returns the child index of this node in relation to its parent, or -1 if no valid index is found (usu...
Definition: AST.h:211
virtual Node * copy() const =0
The deep copy method for a Node.
virtual const char * subname() const =0
Virtual method for accessing node name information.
virtual const char * nodename() const =0
Virtual method for accessing node name information.
std::shared_ptr< Node > Ptr
Definition: AST.h:103
NodeType
An enumerated list of node types for all concrete node types. These can be used for faster evaluation...
Definition: AST.h:117
@ TernaryOperatorNode
Definition: AST.h:129
@ BinaryOperatorNode
Definition: AST.h:128
@ LoopNode
Definition: AST.h:123
@ BlockNode
Definition: AST.h:120
@ StatementListNode
Definition: AST.h:119
@ ConditionalStatementNode
Definition: AST.h:121
@ LocalNode
Definition: AST.h:137
@ FunctionCallNode
Definition: AST.h:132
@ UnaryOperatorNode
Definition: AST.h:127
@ ArrayPackNode
Definition: AST.h:135
@ TreeNode
Definition: AST.h:118
@ ValueInt32Node
Definition: AST.h:140
@ AttributeNode
Definition: AST.h:131
@ ValueInt16Node
Definition: AST.h:139
@ ExternalVariableNode
Definition: AST.h:133
@ CommaOperatorNode
Definition: AST.h:122
@ ArrayUnpackNode
Definition: AST.h:136
@ KeywordNode
Definition: AST.h:124
@ DeclareLocalNode
Definition: AST.h:134
@ ValueBoolNode
Definition: AST.h:138
@ ValueDoubleNode
Definition: AST.h:143
@ ValueFloatNode
Definition: AST.h:142
@ CrementNode
Definition: AST.h:126
@ AssignExpressionNode
Definition: AST.h:125
@ ValueInt64Node
Definition: AST.h:141
@ CastNode
Definition: AST.h:130
void setParent(Node *parent)
Set this node's parent. This is used during construction of an AST and should not be used.
Definition: AST.h:276
virtual const Node * basetype() const
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:175
const Node * parent() const
Access a const pointer to this nodes parent.
Definition: AST.h:271
virtual NodeType nodetype() const =0
Virtual method for accessing node type information.
Concrete AST nodes.
Definition: AST.h:386
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:425
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:427
StatementList(const std::vector< Statement * > &statements)
Construct a new StatementList from a vector of statements, transferring ownership of all valid statem...
Definition: AST.h:405
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:434
size_t size() const
Alias for StatementList::children.
Definition: AST.h:451
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:431
StatementList(const StatementList &other)
Deep copy constructor for a StatementList, performing a deep copy on every held statement,...
Definition: AST.h:415
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:436
~StatementList() override=default
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:441
void addStatement(Statement *stmnt)
Adds a statement to this statement list, transferring ownership to the statement list and updating pa...
Definition: AST.h:455
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:429
StatementList * copy() const override
The deep copy method for a Node.
Definition: AST.h:423
StatementList(Statement *statement)
Construct a new StatementList with a single statement, transferring ownership of the statement to the...
Definition: AST.h:396
StatementList()
Construct a new StatementList with an empty list.
Definition: AST.h:390
Abstract (pure-virtual) AST nodes.
Definition: AST.h:312
const Node * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:316
~Statement() override=default
std::unique_ptr< Statement > UniquePtr
Definition: AST.h:313
virtual Statement * copy() const override=0
The deep copy method for a Node.
A TernaryOperator represents a ternary (conditional) expression 'a ? b : c' which evaluates to 'b' if...
Definition: AST.h:1092
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1135
~TernaryOperator() override=default
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1137
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1145
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1143
TernaryOperator * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1131
TernaryOperator(const TernaryOperator &other)
Deep copy constructor for a TernaryOperator, performing a deep copy on held expressions,...
Definition: AST.h:1120
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1141
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1152
const Expression * trueBranch() const
Access a const pointer to the TernaryOperator true expression as an abstract expression.
Definition: AST.h:1180
const Expression * falseBranch() const
Access a const pointer to the TernaryOperator false expression as an abstract expression.
Definition: AST.h:1184
bool hasTrue() const
Query whether or not this has an optional if-true branch.
Definition: AST.h:1172
TernaryOperator(Expression *conditional, Expression *trueExpression, Expression *falseExpression)
Construct a new TernaryOperator with a conditional expression and true (optional) and false expressio...
Definition: AST.h:1104
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1139
const Expression * condition() const
Access a const pointer to the TernaryOperator conditional as an abstract expression.
Definition: AST.h:1176
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy....
Definition: AST.h:562
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:587
Tree(const Tree &other)
Deep copy constructor for a Tree, performing a deep copy on the held Block, ensuring parent informati...
Definition: AST.h:578
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:589
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:596
Tree(Block *block=new Block())
Construct a new Tree from a given Block, transferring ownership of the Block to the tree and updating...
Definition: AST.h:571
const Node * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:593
Tree * copy() const override final
The deep copy method for a Node.
Definition: AST.h:585
std::shared_ptr< const Tree > ConstPtr
Definition: AST.h:564
const Block * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:598
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:591
A UnaryOperator represents a single unary operation on an expression. The operation type is stored as...
Definition: AST.h:1389
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1423
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1425
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1433
UnaryOperator(Expression *expr, const tokens::OperatorToken op)
Construct a new UnaryOperator with a given tokens::OperatorToken and a valid expression,...
Definition: AST.h:1397
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1431
tokens::OperatorToken operation() const
Query the type of unary operation held on this node.
Definition: AST.h:1449
const Expression * expression() const
Access a const pointer to the UnaryOperator expression as an abstract expression.
Definition: AST.h:1453
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1429
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1438
UnaryOperator(Expression *expr, const std::string &op)
Construct a new UnaryOperator with a string, delegating construction to the above UnaryOperator const...
Definition: AST.h:1407
UnaryOperator(const UnaryOperator &other)
Deep copy constructor for a UnaryOperator, performing a deep copy on the underlying expressions,...
Definition: AST.h:1413
~UnaryOperator() override=default
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1427
UnaryOperator * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1421
ValueBases are a base class for anything that holds a value (literal). Derived classes store the actu...
Definition: AST.h:361
virtual Expression * copy() const override=0
The deep copy method for a Node.
size_t children() const override
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:367
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:365
~ValueBase() override=default
const Node * child(const size_t) const override
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:368
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2350
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2351
Value< Type > * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2349
Value(const Type &value)
Construct a new Value string from a string.
Definition: AST.h:2341
const ValueBase * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2353
const std::string & value() const
Access the string.
Definition: AST.h:2357
~Value() override=default
Value(const Value< Type > &other)
Deep copy constructor for a Value string.
Definition: AST.h:2346
std::string Type
Definition: AST.h:2338
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2352
A Value (literal) AST node holds either literal text or absolute value information on all numerical,...
Definition: AST.h:2253
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2290
Value(const Value< T > &other)
Deep copy constructor for a Value.
Definition: AST.h:2283
T Type
Definition: AST.h:2256
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2299
Value< Type > * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2288
typename std::conditional< std::is_integral< T >::value, uint64_t, T >::type ContainerType
Integers and Floats store their value as ContainerType, which is guaranteed to be at least large enou...
Definition: AST.h:2261
const ValueBase * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2317
~Value() override=default
Value(const ContainerType value)
Directly construct a Value from a source integer, float or boolean, guaranteeing valid construction....
Definition: AST.h:2277
ContainerType asContainerType() const
Access the value as its stored type.
Definition: AST.h:2321
T value() const
Access the value as its requested (templated) type.
Definition: AST.h:2324
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2308
Variables are a base type for Locals, Attributes and ExternalVariables. Unlike other abstract types,...
Definition: AST.h:337
size_t children() const override
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:349
const std::string & name() const
Definition: AST.h:352
Variable(const std::string &name)
Definition: AST.h:340
~Variable() override=default
virtual Variable * copy() const override=0
The deep copy method for a Node.
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:347
const Node * child(const size_t) const override
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:350
Variable(const Variable &other)
Definition: AST.h:342
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202