#include #include #include #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" int main(int argc, char **argv) { if (argc < 2 || argc > 2) { std::cout << "Wrong argument count (one argument should be provided - " "source file)\n"; return 0; } std::string filename = argv[1]; std::ifstream in; in.open(filename); std::stringstream source_stream; 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); }