Skip to content

Commit

Permalink
Update lex.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
silas-wr authored Jul 26, 2024
1 parent 7dd1b80 commit 28b3023
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/crate/lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ vector<Token> lex(const string src)
cur.row = row;
cur.col = col;
tlist.push_back(cur);
load_type = "";
load_var = "";
load_type = "alpha";
load_var += c;
} else if (load_type == "splat") {
cur.ttype = KWARGS;
cur.value = load_var;
Expand All @@ -199,6 +203,8 @@ vector<Token> lex(const string src)

load_type = "";
load_var = "";
load_type = "alpha";
load_var += c;
} else {
cout << "[" << row << ", " << col << "] we're so sorry. something went wrong with the lexical analyzer. \n\tplease notify me at silas-wr/crate on github.\n";
ok = false; // make it uncompilable
Expand All @@ -223,9 +229,8 @@ vector<Token> lex(const string src)
} else {
cout << "[" << row << ", " << col << "] Invalid operator " << load_var << " .\n";
ok = false;

load_type = "";
load_var = "";
load_type = "";
load_var = "";
}

load_type = "";
Expand Down Expand Up @@ -361,6 +366,10 @@ vector<Token> lex(const string src)
load_type = "";
load_var = "";
}
load_type = "";
load_var = "";
load_type = "period";
load_var += c;
} else if (load_type == "alpha") {
if (keys.find(load_var) != keys.end()) {
cur.ttype = keys[load_var];
Expand All @@ -376,6 +385,8 @@ vector<Token> lex(const string src)
tlist.push_back(cur);
}

load_type = "";
load_var = "";
load_type = "period";
load_var += c;
} else {
Expand Down

0 comments on commit 28b3023

Please sign in to comment.