mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-13 10:28:45 +00:00
statement builders finished
This commit is contained in:
parent
64a91299ff
commit
4470454838
19 changed files with 682 additions and 255 deletions
43
src/main.cpp
43
src/main.cpp
|
|
@ -1,3 +1,42 @@
|
|||
int main() {
|
||||
return 0;
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "error_handling.hpp"
|
||||
#include "expression_nodes.hpp"
|
||||
#include "statement_builders.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;
|
||||
|
||||
builders::build_source_file(parse_tree.get_root(), expression_storage,
|
||||
type_storage);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue