Move source reading into a function
This commit is contained in:
@ -43,6 +43,7 @@ elna_OBJS = \
|
||||
elna/elna-tree.o \
|
||||
elna/elna-builtins.o \
|
||||
elna/ast.o \
|
||||
elna/dependency.o \
|
||||
elna/driver.o \
|
||||
elna/lexer.o \
|
||||
elna/parser.o \
|
||||
|
@ -100,7 +100,7 @@ namespace elna::gcc
|
||||
}
|
||||
|
||||
std::deque<std::unique_ptr<boot::error>> do_semantic_analysis(const char *path,
|
||||
std::unique_ptr<boot::program>& ast, std::shared_ptr<boot::symbol_table> info_table,
|
||||
const std::unique_ptr<boot::program>& ast, std::shared_ptr<boot::symbol_table> info_table,
|
||||
std::shared_ptr<symbol_table> symbols, std::unordered_map<std::string, tree>& unresolved)
|
||||
{
|
||||
boot::declaration_visitor declaration_visitor(path, info_table);
|
||||
|
42
gcc/elna1.cc
42
gcc/elna1.cc
@ -29,12 +29,11 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "langhooks-def.h"
|
||||
|
||||
#include <fstream>
|
||||
#include "elna/boot/driver.h"
|
||||
#include "elna/boot/dependency.h"
|
||||
#include "elna/gcc/elna-tree.h"
|
||||
#include "elna/gcc/elna-generic.h"
|
||||
#include "elna/gcc/elna-diagnostic.h"
|
||||
#include "elna/gcc/elna-builtins.h"
|
||||
#include "parser.hh"
|
||||
|
||||
tree elna_global_trees[ELNA_TI_MAX];
|
||||
hash_map<nofree_string_hash, tree> *elna_global_decls = nullptr;
|
||||
@ -71,33 +70,34 @@ static void elna_parse_file(const char *filename)
|
||||
{
|
||||
fatal_error(UNKNOWN_LOCATION, "cannot open filename %s: %m", filename);
|
||||
}
|
||||
elna::boot::dependency_graph outcome = elna::boot::read_sources(file, filename);
|
||||
|
||||
elna::boot::driver driver{ filename };
|
||||
elna::boot::lexer lexer(file);
|
||||
yy::parser parser(lexer, driver);
|
||||
std::shared_ptr<elna::boot::symbol_table> info_table = elna::boot::builtin_symbol_table();
|
||||
std::shared_ptr<elna::gcc::symbol_table> symbol_table = elna::gcc::builtin_symbol_table();
|
||||
|
||||
linemap_add(line_table, LC_ENTER, 0, filename, 1);
|
||||
if (parser())
|
||||
if (outcome.has_errors())
|
||||
{
|
||||
elna::gcc::report_errors(driver.errors());
|
||||
elna::gcc::report_errors(outcome.errors());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<elna::boot::symbol_table> info_table = elna::boot::builtin_symbol_table();
|
||||
std::shared_ptr<elna::gcc::symbol_table> symbol_table = elna::gcc::builtin_symbol_table();
|
||||
std::unordered_map<std::string, tree> unresolved;
|
||||
|
||||
auto semantic_errors = elna::gcc::do_semantic_analysis(filename, driver.tree,
|
||||
info_table, symbol_table, unresolved);
|
||||
|
||||
if (semantic_errors.empty())
|
||||
for (const std::unique_ptr<elna::boot::program>& module_tree : outcome.modules)
|
||||
{
|
||||
elna::gcc::generic_visitor generic_visitor{ symbol_table, std::move(unresolved) };
|
||||
generic_visitor.visit(driver.tree.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
elna::gcc::report_errors(semantic_errors);
|
||||
std::unordered_map<std::string, tree> unresolved;
|
||||
|
||||
auto semantic_errors = elna::gcc::do_semantic_analysis(filename, module_tree,
|
||||
info_table, symbol_table, unresolved);
|
||||
|
||||
if (semantic_errors.empty())
|
||||
{
|
||||
elna::gcc::generic_visitor generic_visitor{ symbol_table, std::move(unresolved) };
|
||||
generic_visitor.visit(module_tree.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
elna::gcc::report_errors(semantic_errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
|
||||
|
Reference in New Issue
Block a user