From 9ade88b6aaeefc07038e9a73b58330c994e4fe63 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Thu, 1 Apr 2021 16:20:14 +0200 Subject: [PATCH] Make the lex function return a value instead of a reference. --- src/etc/lexer.cpp | 5 ++--- src/headers/lex.hpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/etc/lexer.cpp b/src/etc/lexer.cpp index 184109f..c04532a 100644 --- a/src/etc/lexer.cpp +++ b/src/etc/lexer.cpp @@ -2,8 +2,6 @@ #include using namespace std; -vector resVal; - tok::type getIdentifierCharType(const char& Char) { if (isalpha(Char)) return tok::IDENTIFIER; else if (isdigit(Char)) return tok::NUMBER; @@ -11,8 +9,9 @@ tok::type getIdentifierCharType(const char& Char) { else return tok::UNEXPECTED; } -vector& lex(const string& in) +vector lex(const string& in) { + vector resVal; bool longLex = false; pair generated; for (const char& current : in) { diff --git a/src/headers/lex.hpp b/src/headers/lex.hpp index c1997ff..cae5aea 100644 --- a/src/headers/lex.hpp +++ b/src/headers/lex.hpp @@ -18,6 +18,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); +std::vector lex(const std::string& in); #endif //YERBACON_TEST_H \ No newline at end of file