Use a reference as the parseString function's parameter instead of a unuseful pointer.

This commit is contained in:
Username404-59 2021-03-25 21:15:21 +01:00
parent a4e42f752f
commit 9869f73e35
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
4 changed files with 4 additions and 6 deletions

View File

@ -1,7 +1,6 @@
#ifndef YERBACON_LEX_H #ifndef YERBACON_LEX_H
#define YERBACON_LEX_H #define YERBACON_LEX_H
#include <memory>
#include <vector> #include <vector>
#include <string> #include <string>
#include <ostream> #include <ostream>

View File

@ -11,7 +11,7 @@ string getFileContent(const string& file);
void setOutputFileContent(const string& language, const string& file, const string& content); void setOutputFileContent(const string& language, const string& file, const string& content);
#include "src/headers/parsing/ParseComponents.hpp" #include "src/headers/parsing/ParseComponents.hpp"
ParseTree parseString(const unique_ptr<string>& toParse); ParseTree parseString(const string& toParse);
string transpile(ParseTree toTranspile, string language); string transpile(ParseTree toTranspile, string language);
#endif //YERBACON_MISC_HPP #endif //YERBACON_MISC_HPP

View File

@ -1,5 +1,4 @@
#include <iostream> #include <iostream>
#include <memory>
using namespace std; using namespace std;
#include "headers/misc.hpp" #include "headers/misc.hpp"
@ -18,7 +17,7 @@ int main(int argc, char* argv[]) {
if ((currentArg == "--printresult") || (currentArg == "-p")) printResult = true; if ((currentArg == "--printresult") || (currentArg == "-p")) printResult = true;
else if (currentArg.starts_with("--target=")) target = '.' + currentArg.erase(0, 9); else if (currentArg.starts_with("--target=")) target = '.' + currentArg.erase(0, 9);
} }
const auto parsedTree = parseString(make_unique<string>(getFileContent(fileName))); const auto parsedTree = parseString(getFileContent(fileName));
const string transpiledString = transpile(parsedTree, target); const string transpiledString = transpile(parsedTree, target);
if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n"; if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n" << "[WIP]\n" << transpiledString << "\n\n";
setOutputFileContent(target, fileName.erase(fileName.find(".ybcon")) + target, transpiledString); setOutputFileContent(target, fileName.erase(fileName.find(".ybcon")) + target, transpiledString);

View File

@ -4,9 +4,9 @@
using namespace std; using namespace std;
ParseTree parseString(const unique_ptr<string>& toParse) { ParseTree parseString(const string& toParse) {
ParseTree parseTree = ParseTree(); ParseTree parseTree = ParseTree();
auto lexed = lex(*toParse); auto lexed = lex(toParse);
for (const tok& token: lexed) { for (const tok& token: lexed) {
} }