Remove separator tokens, and move a boolean variable.
This commit is contained in:
parent
b37250492a
commit
c190e308f8
|
@ -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) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ struct tok {
|
||||||
SQUOTE,
|
SQUOTE,
|
||||||
STRING,
|
STRING,
|
||||||
IDENTIFIER,
|
IDENTIFIER,
|
||||||
SEPARATOR,
|
|
||||||
UNEXPECTED
|
UNEXPECTED
|
||||||
};
|
};
|
||||||
type toktype;
|
type toktype;
|
||||||
|
|
Loading…
Reference in New Issue