From 6d2c23bb39f667b569a0047a1585bd1e9251759a Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Wed, 3 Mar 2021 19:47:25 +0100 Subject: [PATCH] Add a misc.hpp file. --- src/headers/lex.hpp | 8 +++++++- src/headers/misc.hpp | 15 +++++++++++++++ src/main.cpp | 9 +++------ src/parser/MainParse.cpp | 3 +-- 4 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 src/headers/misc.hpp diff --git a/src/headers/lex.hpp b/src/headers/lex.hpp index b4a519c..7e08092 100644 --- a/src/headers/lex.hpp +++ b/src/headers/lex.hpp @@ -1,6 +1,10 @@ // // Created by doggo on 04/02/2021. // + +#ifndef YERBACON_LEX_H +#define YERBACON_LEX_H + #include #include #include @@ -19,4 +23,6 @@ struct tok { tok(type Type, std::string Text): toktype(Type), toktext(Text) {} friend std::ostream& operator<<(std::ostream& output, const tok& it) { return output << it.toktext; } }; -std::vector& lex(const std::string& in); \ No newline at end of file +std::vector& lex(const std::string& in); + +#endif //YERBACON_TEST_H \ No newline at end of file diff --git a/src/headers/misc.hpp b/src/headers/misc.hpp new file mode 100644 index 0000000..411d33d --- /dev/null +++ b/src/headers/misc.hpp @@ -0,0 +1,15 @@ +// +// Created by doggo on 03/03/2021. +// + +#ifndef YERBACON_MISC_HPP +#define YERBACON_MISC_HPP + +#ifndef YBCON_VERSION +#define YBCON_VERSION "UNKNOWN" +#endif + +#include +std::string getVersion() noexcept { return YBCON_VERSION; } + +#endif //YERBACON_MISC_HPP diff --git a/src/main.cpp b/src/main.cpp index 7f5317d..7b83d36 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,18 +2,15 @@ #include using namespace std; -#ifndef YBCON_VERSION -#define YBCON_VERSION "UNKNOWN" -#endif - extern string getFileContent(const string& file); extern void setOutputFileContent(const string& language, const string& file, const string& content); extern string parseString(unique_ptr toParse); - extern string transpile(string toTranspile, string language); +#include "headers/misc.hpp" + int main(int argc, char* argv[]) { - if ((argc == 2) && (((string) argv[1]) == "--version")) { cout << YBCON_VERSION << endl; exit(EXIT_SUCCESS); } + if ((argc == 2) && (((string) argv[1]) == "--version")) { cout << getVersion() << endl; exit(EXIT_SUCCESS); } string fileName = (argv[argc - 1] != nullptr) ? argv[argc - 1] : "none" ; if (fileName != "none" and fileName.ends_with(".ybcon")) { diff --git a/src/parser/MainParse.cpp b/src/parser/MainParse.cpp index f050f7e..d81b201 100644 --- a/src/parser/MainParse.cpp +++ b/src/parser/MainParse.cpp @@ -2,14 +2,13 @@ // Created by username404 on 11/12/2020. // #include "../headers/lex.hpp" -#include using namespace std; string parseString(unique_ptr toParse) { stringstream tmpStream; auto lexed = lex(*toParse); - for (auto& token: lexed) { + for (tok& token: lexed) { tmpStream << token; } *toParse = tmpStream.str();