types for typecheck, sources manager

This commit is contained in:
ProgramSnail 2023-08-02 17:54:39 +03:00
parent 4714a05467
commit ef88e6af86
9 changed files with 353 additions and 104 deletions

View file

@ -1,14 +1,4 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include "basic_printers.hpp"
#include "error_handling.hpp"
#include "expression_nodes.hpp"
#include "name_tree.hpp"
#include "statement_builders.hpp"
#include "statement_printers.hpp"
#include "type_nodes.hpp"
#include "sources_manager.hpp"
int main(int argc, char **argv) {
if (argc < 2 || argc > 2) {
@ -19,31 +9,10 @@ int main(int argc, char **argv) {
std::string filename = argv[1];
std::ifstream in;
in.open(filename);
//
std::stringstream source_stream;
SourcesManager sources_manager;
source_stream << in.rdbuf();
in.close();
std::string source = source_stream.str();
parser::ParseTree parse_tree(source);
if (!parse_tree.is_properly_parsed()) {
error_handling::handle_parsing_error(
"There are some parsing errors in file", parse_tree.get_root());
}
nodes::ExpressionStorage expression_storage;
nodes::TypeStorage type_storage;
names::NameTree name_tree;
auto statements = builders::build_source_file(
parse_tree.get_root(), expression_storage, type_storage, name_tree);
printers::Printer printer(std::cout, 2, 80, true);
printers::print_source_file(statements, printer);
sources_manager.add_file(filename);
sources_manager.print(std::cout);
}