diff --git a/CMakeLists.txt b/CMakeLists.txt index c7b3919..f6ba242 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${TI set(CPACK_STRIP_FILES TRUE) include_directories(${CMAKE_CURRENT_LIST_DIR}) -add_executable(ybcon src/main.cpp resources/Yerbacon.rc src/parser/MainParse.cpp src/transpiler/MainTranspile.cpp src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp src/headers/misc.hpp src/headers/ParseComponents.hpp) +add_executable(ybcon src/main.cpp resources/Yerbacon.rc src/parser/MainParse.cpp src/transpiler/MainTranspile.cpp src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp src/headers/misc.hpp src/headers/parsing/ParseComponents.hpp src/headers/parsing/StandardComponents.hpp) target_compile_definitions(ybcon PRIVATE YBCON_VERSION="${PROJECT_VERSION}") # lpkg = linux package, wpkg = windows package diff --git a/src/headers/misc.hpp b/src/headers/misc.hpp index 569692f..c6fe3f9 100644 --- a/src/headers/misc.hpp +++ b/src/headers/misc.hpp @@ -10,12 +10,12 @@ #endif #include -std::string getVersion() noexcept { return YBCON_VERSION; } +string getVersion() noexcept { return YBCON_VERSION; } string getFileContent(const string& file); void setOutputFileContent(const string& language, const string& file, const string& content); -#include "ParseComponents.hpp" +#include "src/headers/parsing/ParseComponents.hpp" ParseTree parseString(const unique_ptr& toParse); string transpile(ParseTree toTranspile, string language); diff --git a/src/headers/ParseComponents.hpp b/src/headers/parsing/ParseComponents.hpp similarity index 73% rename from src/headers/ParseComponents.hpp rename to src/headers/parsing/ParseComponents.hpp index d493d30..40cc5b8 100644 --- a/src/headers/ParseComponents.hpp +++ b/src/headers/parsing/ParseComponents.hpp @@ -9,7 +9,11 @@ #include using namespace std; -class ParseComponent { +#include "../lex.hpp" + +class ParseComponent {}; + +struct ParseTree: public ParseComponent { private: unsigned int compCount = 0; protected: @@ -19,10 +23,9 @@ public: auto& getComponents() { return subComponents; } void add(const ParseComponent& component) { subComponents.push_back(component); ++compCount; }; void addAll(const vector& components) { for (const auto& comp: components) add(comp); } - ParseComponent(): subComponents() {}; - ~ParseComponent() = default; + void operator<<(const ParseComponent& component) { this->add(component); } + ParseTree(): subComponents() {}; + ~ParseTree() = default; }; -struct ParseTree: public ParseComponent {}; - #endif //YERBACON_PARSECOMPONENTS_HPP diff --git a/src/headers/parsing/StandardComponents.hpp b/src/headers/parsing/StandardComponents.hpp new file mode 100644 index 0000000..bc9ee83 --- /dev/null +++ b/src/headers/parsing/StandardComponents.hpp @@ -0,0 +1,18 @@ +// +// Created by doggo on 05/03/2021. +// + +#ifndef YERBACON_STANDARDCOMPONENTS_HPP +#define YERBACON_STANDARDCOMPONENTS_HPP +#include "ParseComponents.hpp" + +namespace comp { + namespace types { + struct String: public ParseComponent { + string content; + explicit String(const string& str) { content = str; } + }; + } +} + +#endif //YERBACON_STANDARDCOMPONENTS_HPP diff --git a/src/parser/MainParse.cpp b/src/parser/MainParse.cpp index f4cfca0..3ec4be2 100644 --- a/src/parser/MainParse.cpp +++ b/src/parser/MainParse.cpp @@ -2,14 +2,15 @@ // Created by username404 on 11/12/2020. // #include "../headers/lex.hpp" -#include "../headers/ParseComponents.hpp" +#include "../headers/parsing/ParseComponents.hpp" +#include "../headers/parsing/StandardComponents.hpp" using namespace std; ParseTree parseString(const unique_ptr& toParse) { ParseTree parseTree = ParseTree(); auto lexed = lex(*toParse); - for (tok& token: lexed) { + for (const tok& token: lexed) { } return parseTree; diff --git a/src/transpiler/MainTranspile.cpp b/src/transpiler/MainTranspile.cpp index 1916056..0f71eb4 100644 --- a/src/transpiler/MainTranspile.cpp +++ b/src/transpiler/MainTranspile.cpp @@ -20,7 +20,7 @@ pair validLanguage(const string& it) { } return pair(selected, valid); } -#include "../headers/ParseComponents.hpp" +#include "src/headers/parsing/ParseComponents.hpp" string transpile(ParseTree tree, string language) {