diff --git a/cppcheck.suppress b/cppcheck.suppress index 512357e..5d9588d 100644 --- a/cppcheck.suppress +++ b/cppcheck.suppress @@ -13,6 +13,9 @@ missingIncludeSystem unusedStructMember unmatchedSuppression +// Ignore debug methods +unusedFunction + // libpython uses this a lot, unfortunately cstyleCast diff --git a/roxas/ast.cc b/roxas/ast.cc new file mode 100644 index 0000000..a4ac709 --- /dev/null +++ b/roxas/ast.cc @@ -0,0 +1,22 @@ +#include +#include + +namespace roxas { + +namespace ast { + +node::node(std::string const& type) + : type_(std::move(type)) + , literal_({ literal::UNKNOWN, "unknown" }) + , children_({}) +{ +} + +void node::print() +{ + std::cout << "node type: " << type_; +} + +} // namespace ast + +} // namespace roxas \ No newline at end of file diff --git a/roxas/ast.h b/roxas/ast.h new file mode 100644 index 0000000..ceb3fd9 --- /dev/null +++ b/roxas/ast.h @@ -0,0 +1,61 @@ +#pragma once + +#include +#include +#include +#include + +namespace roxas { + +namespace ast { + +class node; +struct definition; + +} // namespace ast + +using AST = std::vector; + +AST parse_tree_to_ast(std::string const& parse_tree); + +namespace ast { + +enum class literal : int +{ + NUMBER, + CONSTANT, + STRING, + UNKNOWN +}; + +using literal_datatype = std::tuple; + +struct definition +{ + enum class type : int + { + FUNCTION, + VECTOR + }; + + type type{ type::FUNCTION }; + std::vector children{}; +}; + +class node +{ + public: + node(node const&) = delete; + node& operator=(node const&) = delete; + + explicit node(std::string const& type); + void print(); + + private: + std::string type_; + std::optional literal_; + std::optional> children_; +}; + +} // namespace ast +} // namespace roxas diff --git a/roxas/main.cc b/roxas/main.cc index ed17f52..3932c6a 100644 --- a/roxas/main.cc +++ b/roxas/main.cc @@ -16,6 +16,7 @@ #include #include +#include #include int main(int argc, const char* argv[])