From 9869f73e35a26beb1bbcc3787fc6b7fa407cef3d Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Thu, 25 Mar 2021 21:15:21 +0100 Subject: [PATCH] Use a reference as the parseString function's parameter instead of a unuseful pointer. --- src/headers/lex.hpp | 1 - src/headers/misc.hpp | 2 +- src/main.cpp | 3 +-- src/parser/MainParse.cpp | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/headers/lex.hpp b/src/headers/lex.hpp index 21e081b..a5924b1 100644 --- a/src/headers/lex.hpp +++ b/src/headers/lex.hpp @@ -1,7 +1,6 @@ #ifndef YERBACON_LEX_H #define YERBACON_LEX_H -#include #include #include #include diff --git a/src/headers/misc.hpp b/src/headers/misc.hpp index 64b6309..de054d4 100644 --- a/src/headers/misc.hpp +++ b/src/headers/misc.hpp @@ -11,7 +11,7 @@ string getFileContent(const string& file); void setOutputFileContent(const string& language, const string& file, const string& content); #include "src/headers/parsing/ParseComponents.hpp" -ParseTree parseString(const unique_ptr& toParse); +ParseTree parseString(const string& toParse); string transpile(ParseTree toTranspile, string language); #endif //YERBACON_MISC_HPP diff --git a/src/main.cpp b/src/main.cpp index b323001..ec98688 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,4 @@ #include -#include using namespace std; #include "headers/misc.hpp" @@ -18,7 +17,7 @@ int main(int argc, char* argv[]) { if ((currentArg == "--printresult") || (currentArg == "-p")) printResult = true; else if (currentArg.starts_with("--target=")) target = '.' + currentArg.erase(0, 9); } - const auto parsedTree = parseString(make_unique(getFileContent(fileName))); + const auto parsedTree = parseString(getFileContent(fileName)); const string transpiledString = transpile(parsedTree, target); if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n"; setOutputFileContent(target, fileName.erase(fileName.find(".ybcon")) + target, transpiledString); diff --git a/src/parser/MainParse.cpp b/src/parser/MainParse.cpp index 92a6806..9dc8f05 100644 --- a/src/parser/MainParse.cpp +++ b/src/parser/MainParse.cpp @@ -4,9 +4,9 @@ using namespace std; -ParseTree parseString(const unique_ptr& toParse) { +ParseTree parseString(const string& toParse) { ParseTree parseTree = ParseTree(); - auto lexed = lex(*toParse); + auto lexed = lex(toParse); for (const tok& token: lexed) { }