Make the lex function return a value instead of a reference.
This commit is contained in:
parent
c190e308f8
commit
9ade88b6aa
|
@ -2,8 +2,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
vector<tok> resVal;
|
|
||||||
|
|
||||||
tok::type getIdentifierCharType(const char& Char) {
|
tok::type getIdentifierCharType(const char& Char) {
|
||||||
if (isalpha(Char)) return tok::IDENTIFIER;
|
if (isalpha(Char)) return tok::IDENTIFIER;
|
||||||
else if (isdigit(Char)) return tok::NUMBER;
|
else if (isdigit(Char)) return tok::NUMBER;
|
||||||
|
@ -11,8 +9,9 @@ tok::type getIdentifierCharType(const char& Char) {
|
||||||
else return tok::UNEXPECTED;
|
else return tok::UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<tok>& lex(const string& in)
|
vector<tok> lex(const string& in)
|
||||||
{
|
{
|
||||||
|
vector<tok> resVal;
|
||||||
bool longLex = false;
|
bool longLex = false;
|
||||||
pair<tok::type, string> generated;
|
pair<tok::type, string> generated;
|
||||||
for (const char& current : in) {
|
for (const char& current : in) {
|
||||||
|
|
|
@ -18,6 +18,6 @@ struct tok {
|
||||||
tok(type Type, std::string Text): toktype(Type), toktext(Text) {}
|
tok(type Type, std::string Text): toktype(Type), toktext(Text) {}
|
||||||
friend std::ostream& operator<<(std::ostream& output, const tok& it) { return output << it.toktext; }
|
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
|
#endif //YERBACON_TEST_H
|
Loading…
Reference in New Issue