diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-10-04 01:23:49 +0200 |
---|---|---|
committer | George L. Albany <Megacake1234@gmail.com> | 2023-10-05 01:35:42 +0200 |
commit | 7b1e33c26b4d36be2e3d1292dc539ff17e358589 (patch) | |
tree | 4456832acce290261f5839a083018afbd154ba16 /src/openvic-dataloader/v2script/AbstractSyntaxTree.cpp | |
parent | 02c30fdda7b775782af1163b2321e7d6fcf01fcc (diff) |
Make File contents optional
Add lexy::nullopt support to String and List nodes
Diffstat (limited to 'src/openvic-dataloader/v2script/AbstractSyntaxTree.cpp')
-rw-r--r-- | src/openvic-dataloader/v2script/AbstractSyntaxTree.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/openvic-dataloader/v2script/AbstractSyntaxTree.cpp b/src/openvic-dataloader/v2script/AbstractSyntaxTree.cpp index 8dc1800..c7a325b 100644 --- a/src/openvic-dataloader/v2script/AbstractSyntaxTree.cpp +++ b/src/openvic-dataloader/v2script/AbstractSyntaxTree.cpp @@ -9,6 +9,7 @@ #include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp> +#include <lexy/dsl/option.hpp> #include <lexy/input_location.hpp> using namespace ovdl::v2script::ast; @@ -21,8 +22,10 @@ void ovdl::v2script::ast::copy_into_node_ptr_vector(const std::vector<NodePtr>& } } +AbstractStringNode::AbstractStringNode() : Node({}) {} AbstractStringNode::AbstractStringNode(NodeLocation location, std::string&& name) : Node(location), _name(std::move(name)) {} +AbstractStringNode::AbstractStringNode(NodeLocation location) : Node(location) {} AbstractStringNode::AbstractStringNode(std::string&& name) : AbstractStringNode({}, std::move(name)) {} std::ostream& AbstractStringNode::print(std::ostream& stream, size_t indent) const { @@ -30,8 +33,12 @@ std::ostream& AbstractStringNode::print(std::ostream& stream, size_t indent) con } #define OVDL_AST_STRING_NODE_DEF(NAME, ...) \ + NAME::NAME() : AbstractStringNode() {} \ NAME::NAME(std::string&& name) : AbstractStringNode(std::move(name)) {} \ + NAME::NAME(lexy::nullopt) : AbstractStringNode() {} \ + NAME::NAME(NodeLocation location) : AbstractStringNode(location) {} \ NAME::NAME(NodeLocation location, std::string&& name) : AbstractStringNode(location, std::move(name)) {} \ + NAME::NAME(NodeLocation location, lexy::nullopt) : AbstractStringNode(location, {}) {} \ std::ostream& NAME::print(std::ostream& stream, size_t indent) const __VA_ARGS__ OVDL_AST_STRING_NODE_DEF(IdentifierNode, { @@ -124,7 +131,9 @@ std::ostream& AbstractListNode::print(std::ostream& stream, size_t indent) const #define OVDL_AST_LIST_NODE_DEF(NAME, ...) \ NAME::NAME(const std::vector<NodePtr>& statements) : AbstractListNode(statements) {} \ + NAME::NAME(lexy::nullopt) : AbstractListNode() {} \ NAME::NAME(NodeLocation location, const std::vector<NodePtr>& statements) : AbstractListNode(location, statements) {} \ + NAME::NAME(NodeLocation location, lexy::nullopt) : AbstractListNode(location, {}) {} \ std::ostream& NAME::print(std::ostream& stream, size_t indent) const __VA_ARGS__ OVDL_AST_LIST_NODE_DEF(FileNode, { |