#include #include #include // for clangd #include "../include/parse_tree.hpp" #include "../include/interpreter_tree.hpp" #include "../include/build_visitor.hpp" #include "../include/print_visitor.hpp" #include "../include/error_handling.hpp" int main(int argc, char** argv) { // TODO, only test version if (argc < 2 || argc > 2) { std::cout << "Wrong argument count (provide one argument - source file)\n"; return 0; } std::string filename = argv[1]; std::ifstream in; in.open(filename); // TODO handle errors std::stringstream source_stream; source_stream << in.rdbuf(); in.close(); std::string source = source_stream.str(); parser::ParseTree parse_tree(source); if (!parse_tree.IsProperlyParsed()) { error_handling::HandleParsingError("There are some parsing errors in file.", {0, 0}); } std::unique_ptr source_file = std::make_unique(); interpreter::BuildVisitor build_visitor(parse_tree); interpreter::PrintVisitor print_visitor(std::cout); build_visitor.VisitSourceFile(source_file.get()); print_visitor.VisitSourceFile(source_file.get()); }