Make the lex function return a value instead of a reference.

This commit is contained in:
Username404-59 2021-04-01 16:20:14 +02:00
parent c190e308f8
commit 9ade88b6aa
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 3 additions and 4 deletions

View File

@ -2,8 +2,6 @@
#include <iostream>
using namespace std;
vector<tok> 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<tok>& lex(const string& in)
vector<tok> lex(const string& in)
{
vector<tok> resVal;
bool longLex = false;
pair<tok::type, string> generated;
for (const char& current : in) {

View File

@ -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<tok>& lex(const std::string& in);
std::vector<tok> lex(const std::string& in);
#endif //YERBACON_TEST_H