From c75e6b5b26f869642796483d9028bb0fc383a80c Mon Sep 17 00:00:00 2001 From: Silas Wrinker Date: Tue, 23 Jul 2024 17:46:53 -0400 Subject: [PATCH] Update parse.cpp --- src/crate/parse.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/crate/parse.cpp b/src/crate/parse.cpp index 5700c89..1369bd7 100644 --- a/src/crate/parse.cpp +++ b/src/crate/parse.cpp @@ -10,8 +10,9 @@ Program parse(vector tlist) { bool complex = false; bool ok = true; - list id {"id", "const", "importid", "importct", "packid", "packct"}; - list sky {"id", "const", "import", "importid", "importct", "packid", "packct"}; + vector id {"id", "const", "importid", "importct", "packid", "packct"}; + vector sky {"id", "const", "import", "importid", "importct", "pack", "packid", "packct"}; + vector semi {"import", "pack"}; string load_type = ""; vector load_var; @@ -49,7 +50,7 @@ Program parse(vector 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"; @@ -70,7 +71,7 @@ Program parse(vector 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"; @@ -85,7 +86,7 @@ Program parse(vector 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"; @@ -100,7 +101,7 @@ Program parse(vector 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"; @@ -160,7 +161,7 @@ Program parse(vector 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";