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 60deb4f commit c75e6b5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/crate/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Program parse(vector<Token> tlist) {
bool complex = false;
bool ok = true;

list<string> id {"id", "const", "importid", "importct", "packid", "packct"};
list<string> sky {"id", "const", "import", "importid", "importct", "packid", "packct"};
vector<string> id {"id", "const", "importid", "importct", "packid", "packct"};
vector<string> sky {"id", "const", "import", "importid", "importct", "pack", "packid", "packct"};
vector<string> semi {"import", "pack"};

string load_type = "";
vector<Token> load_var;
Expand Down Expand Up @@ -49,7 +50,7 @@ Program parse(vector<Token> tlist) {
} else if (load_type == "pack") {
load_var.push_back(tok);
load_type = "packid";
} else if (find(id.begin(), id.end(), load_type)) {
} else if (find(id.begin(), id.end(), load_type) != -1) {
load_var.clear();
load_type = "";
cout << "[" << tok.row << ", " << tok.col << "] unexpected id. (unexpected-id-with-" << load_type << ")\n";
Expand All @@ -70,7 +71,7 @@ Program parse(vector<Token> tlist) {
} else if (load_type == "pack") {
load_var.push_back(tok);
load_type = "packct";
} else if (find(id.begin(), id.end(), load_type)) {
} else if (find(id.begin(), id.end(), load_type) != -1) {
load_var.clear();
load_type = "";
cout << "[" << tok.row << ", " << tok.col << "] unexpected const. (unexpected-const-with-" << load_type << ")\n";
Expand All @@ -85,7 +86,7 @@ Program parse(vector<Token> tlist) {
if (load_type == "") {
load_var.push_back(tok);
load_type = "import";
} else if (find(sky.begin(), sky.end(), load_type)) {
} else if (find(sky.begin(), sky.end(), load_type) != -1) {
load_var.clear();
load_type = "";
cout << "[" << tok.row << ", " << tok.col << "] unexpected import. (unexpected-import-with-" << load_type << ")\n";
Expand All @@ -100,7 +101,7 @@ Program parse(vector<Token> tlist) {
if (load_type == "") {
load_var.push_back(tok);
load_type = "pack";
} else if (find(sky.begin(), sky.end(), load_type)) {
} else if (find(sky.begin(), sky.end(), load_type) != -1) {
load_var.clear();
load_type = "";
cout << "[" << tok.row << ", " << tok.col << "] unexpected package. (unexpected-pack-with-" << load_type << ")\n";
Expand Down Expand Up @@ -160,7 +161,7 @@ Program parse(vector<Token> tlist) {
ultimate.push_back(cur);
load_var.clear();
load_type = "";
} else if (load_type == "import" | load_type == "pack") {
} else if (find(semi.begin(), semi.end(), load_type) != -1) {
load_var.clear();
load_type = "";
cout << "[" << tok.row << ", " << tok.col << "] unexpected semi. (unexpected-semi-with-" << load_type << ")\n";
Expand Down

0 comments on commit c75e6b5

Please sign in to comment.