X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/45409c781a9e35df68c43b1e2f028d30bf90c0a0..c4231c6faf4e1b4650b075c641b0bb8c053739e4:/src/main.cpp?ds=sidebyside diff --git a/src/main.cpp b/src/main.cpp index a7742ac..5b53b10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,12 +7,15 @@ #include "toc.h" #include "repr.h" #include "repr_get.h" +#include "generic.h" +//#include "check.h" using namespace antlr4; -int main(int argc, const char * argv[]) { - std::ifstream ifs("test.toc"); +int main(int argc, const char * argv[]) +{ + std::ifstream ifs("test/test.toc"); ANTLRInputStream input(ifs); @@ -23,28 +26,30 @@ 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; } - std::string s = tree->toStringTree(&parser) + "\n"; - + //std::string s = tree->toStringTree(&parser) + "\n"; //std::cout << "Parse Tree: " << s << std::endl; - //toc(std::cout, prog); + Program prg = getProgram(prog, nullptr); + instantiateGenerics(prg); - //std::ofstream ofs("output.c"); - //toc(ofs, prog); - //ofs.close(); + try + { + tocProgram(std::cout, prg); - 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; + std::ofstream ofs("output.c"); + tocProgram(ofs, prg); + ofs.close(); + } + catch (const char * e) + { + std::cerr << "Error: " << e << std::endl; + } return 0; } \ No newline at end of file