Create a generic type for types with an error list

This commit is contained in:
2025-03-12 00:23:51 +01:00
parent f739194e06
commit c9a8ecdc0a
13 changed files with 79 additions and 46 deletions

View File

@ -79,12 +79,7 @@ static void elna_parse_file(const char *filename)
linemap_add(line_table, LC_ENTER, 0, filename, 1);
if (parser())
{
for (const auto& error : driver.errors())
{
auto gcc_location = elna::gcc::get_location(&error->position);
error_at(gcc_location, error->what().c_str());
}
elna::gcc::report_errors(driver.errors());
}
else
{
@ -98,10 +93,17 @@ static void elna_parse_file(const char *filename)
symbol_table->enter("Float", elna_float_type_node);
symbol_table->enter("String", elna_string_type_node);
elna::gcc::do_semantic_analysis(filename, driver.tree, symbol_table);
elna::gcc::generic_visitor generic_visitor{ symbol_table };
auto semantic_errors = elna::gcc::do_semantic_analysis(filename, driver.tree, symbol_table);
generic_visitor.visit(driver.tree.get());
if (semantic_errors.empty())
{
elna::gcc::generic_visitor generic_visitor{ symbol_table };
generic_visitor.visit(driver.tree.get());
}
else
{
elna::gcc::report_errors(semantic_errors);
}
}
linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
}