mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-17 20:38:44 +00:00
debug
This commit is contained in:
parent
582ad5668e
commit
0d62ae0814
29 changed files with 99479 additions and 1166 deletions
40
src/main.cpp
Normal file
40
src/main.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
// for clangd
|
||||
#include "../include/parse_tree.hpp"
|
||||
#include "../include/interpreter_tree.hpp"
|
||||
#include "../include/build_visitor.hpp"
|
||||
#include "../include/print_visitor.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);
|
||||
|
||||
std::unique_ptr<interpreter::tokens::SourceFile> source_file =
|
||||
std::make_unique<interpreter::tokens::SourceFile>();
|
||||
|
||||
interpreter::BuildVisitor build_visitor(parse_tree);
|
||||
interpreter::PrintVisitor print_visitor(std::cout);
|
||||
|
||||
build_visitor.VisitSourceFile(source_file.get());
|
||||
//print_visitor.VisitSourceFile(source_file.get());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue