Skip to content

Commit

Permalink
Update parse.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
silas-wr authored Jul 23, 2024
1 parent e069d34 commit a9da420
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/crate/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,30 @@ Program parse(vector<Token> tlist) {
if (load_type == "") {
load_var.push_back(tok);
load_type = "id";
} else if (load_type == "id") {
} else if (load_type == "id" | load_type == "const") {
load_var.clear();
load_type = "id";
load_type = "";
cout << "[" << tok.row << ", " << tok.col << "] unexpected id. (unexpected-id-with-" << load_type << ")\n";
ok = false;
} else {
cout << "[" << tok.row << ", " << tok.col << "] we're so sorry. something went wrong with the parser. tell us at silas-wr/crate on github. (unknown-type)\n";
cout << "[" << tok.row << ", " << tok.col << "] we're so sorry. something went wrong with the parser. tell us at silas-wr/crate on github. (unknown-type-" << load_type << ")\n";
ok = false;
}
} else if (tok.ttype == 1) {
;
eol = false;
eof = false;
if (load_type == "") {
load_var.push_back(tok);
load_type = "const";
} else if (load_type == "id" | load_type == "const") {
load_var.clear();
load_type = "";
cout << "[" << tok.row << ", " << tok.col << "] unexpected const. (unexpected-const-with-" << load_type << ")\n";
ok = false;
} else {
cout << "[" << tok.row << ", " << tok.col << "] we're so sorry. something went wrong with the parser. tell us at silas-wr/crate on github. (unknown-type-" << load_type << ")\n";
ok = false;
}
} else if (tok.ttype == 2) {
;
} else if (tok.ttype == 102) {
Expand All @@ -69,12 +82,19 @@ Program parse(vector<Token> tlist) {
ultimate.push_back(cur);
load_var.clear();
load_type = "";
} else if (load_type == "const") {
load_var.push_back(tok);
cur.tokens = load_var;
cur.ntype = BLANDCT;
ultimate.push_back(cur);
load_var.clear();
load_type = "";
} else {
cout << "[" << tok.row << ", " << tok.col << "] we're so sorry. something went wrong with the parser. tell us at silas-wr/crate on github. (unknown-type)\n";
cout << "[" << tok.row << ", " << tok.col << "] we're so sorry. something went wrong with the parser. tell us at silas-wr/crate on github. (unknown-type-" << load_type << ")\n";
ok = false;
}
} else {
cout << "[" << tok.row << ", " << tok.col << "] " << "we're so sorry. something went wrong with the parser. tell us at silas-wr/crate on github. (unknown-token)\n";
cout << "[" << tok.row << ", " << tok.col << "] " << "we're so sorry. something went wrong with the parser. tell us at silas-wr/crate on github. (unknown-token-" << tok.ttype << ")\n";
ok = false;
}
}
Expand Down

0 comments on commit a9da420

Please sign in to comment.