Remove separator tokens, and move a boolean variable.

This commit is contained in:
Username404-59 2021-04-01 15:32:31 +02:00
parent b37250492a
commit c190e308f8
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 2 additions and 6 deletions

View File

@ -4,10 +4,6 @@ using namespace std;
vector<tok> resVal; vector<tok> resVal;
void separate() {resVal.emplace_back(tok::SEPARATOR, "");}
bool longLex = false;
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;
@ -17,6 +13,7 @@ tok::type getIdentifierCharType(const char& Char) {
vector<tok>& lex(const string& in) vector<tok>& lex(const string& in)
{ {
bool longLex = false;
pair<tok::type, string> generated; pair<tok::type, string> generated;
for (const char& current : in) { for (const char& current : in) {
if (!longLex) { if (!longLex) {
@ -39,7 +36,7 @@ vector<tok>& lex(const string& in)
case '<': resVal.emplace_back(tok::RCOMP, "<"); break; case '<': resVal.emplace_back(tok::RCOMP, "<"); break;
case '\'': resVal.emplace_back(tok::SQUOTE, "\'"); break; case '\'': resVal.emplace_back(tok::SQUOTE, "\'"); break;
case ' ': case '\t': case '\r': case ' ': case '\t': case '\r':
case '\n': separate(); break; case '\n': break;
default: { default: {
tok::type type = getIdentifierCharType(current); tok::type type = getIdentifierCharType(current);
switch (type) { switch (type) {

View File

@ -11,7 +11,6 @@ struct tok {
SQUOTE, SQUOTE,
STRING, STRING,
IDENTIFIER, IDENTIFIER,
SEPARATOR,
UNEXPECTED UNEXPECTED
}; };
type toktype; type toktype;