X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/45409c781a9e35df68c43b1e2f028d30bf90c0a0..71a20a4f3d4e5f5278f7d004af710af89dfd7ebc:/src/main.cpp diff --git a/src/main.cpp b/src/main.cpp index a7742ac..4c78f5b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,11 +7,13 @@ #include "toc.h" #include "repr.h" #include "repr_get.h" +#include "check.h" using namespace antlr4; -int main(int argc, const char * argv[]) { +int main(int argc, const char * argv[]) +{ std::ifstream ifs("test.toc"); ANTLRInputStream input(ifs); @@ -23,7 +25,8 @@ int main(int argc, const char * argv[]) { TocParser::ProgContext * prog = parser.prog(); tree::ParseTree * tree = prog; - if (parser.getNumberOfSyntaxErrors() > 0) { + if (parser.getNumberOfSyntaxErrors() > 0) + { std::cerr << "Parsing error" << std::endl; return 1; } @@ -32,19 +35,16 @@ int main(int argc, const char * argv[]) { //std::cout << "Parse Tree: " << s << std::endl; - //toc(std::cout, prog); + Program prg = getProgram(prog); + + tocProgram(std::cout, prg); + + if (!checkProgram(prg)) + std::cerr << "Error" << std::endl; //std::ofstream ofs("output.c"); - //toc(ofs, prog); + //tocProg(ofs, prg); //ofs.close(); - Program prg = getProgram(prog); - std::cout << "Variables:\n"; - for (auto v : prg.variables) - std::cout << " " << v.name << endl; - std::cout << "Functions:\n"; - for (auto f : prg.functions) - std::cout << " " << f.name << endl; - return 0; } \ No newline at end of file