Skip to content

Commit 9b6ff71

Browse files
authored
Added: error text for symbols (#41)
1 parent 9f119cc commit 9b6ff71

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,13 @@ auto main(int argc, char *argv[]) -> int {
9797
}
9898

9999
/* Check for symbol table errors and exit if errors exist */
100-
std::vector<std::string> errors = lexer.GetUndeclaredSymbolErrors();
101-
errors.insert(errors.end(), lexer.GetDuplicateSymbolErrors().begin(), lexer.GetDuplicateSymbolErrors().end());
100+
std::vector<std::string> errors;
101+
for (const auto &symbol : lexer.GetUndeclaredSymbolErrors()) {
102+
errors.push_back("undeclared symbol: " + symbol);
103+
}
104+
for (const auto &symbol : lexer.GetDuplicateSymbolErrors()) {
105+
errors.push_back("duplicate symbol: " + symbol);
106+
}
102107
if (!errors.empty()) {
103108
std::cout << "jucc: ";
104109
for (auto &e : errors) {
@@ -127,7 +132,6 @@ auto main(int argc, char *argv[]) -> int {
127132
}
128133

129134
/* If there are no parser errors then proceed to generate the parse tree */
130-
131135
parser.BuildParseTree();
132136
if (!parser.WriteParseTree(output_file)) {
133137
std::cout << "jucc: could not write parse tree to " + output_file + '\n';

0 commit comments

Comments
 (0)