From f384fdc3a9e4acccac2e4d322676e34115a168f7 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 4 Jun 2024 12:13:52 +0200 Subject: WIP meer nadenk --- main.cpp | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 05ec033..01b78b2 100644 --- a/main.cpp +++ b/main.cpp @@ -1,17 +1,39 @@ -#include -// #include "Observer.h" -#include "Net.h" -#include "Gate.h" +#include +#include +#include + +#include "Parser.h" +#include "Circuit.h" + +using std::cout; +using std::endl; +using std::fstream; +using std::exception; int main(int argc, char** argv) { - // Observer ob(); - Net n; - Gate *g = new GateAnd; - g->addInput(&n); - n.setLevel(HIGH); - int level = 22; - level = n.getLevel(); - printf("hello world! %d\n", level); - return 0; + Parser main_parser; + Circuit circuit; + + main_parser.setCircuit(circuit); + + fstream file{"circuits/full-adder.txt", file.out}; + + try { + main_parser << file; + } catch (exception e) { + cout << "Parser error: " << e.what() << endl; + return EXIT_FAILURE; + } + + try { + circuit.run(); + } catch (exception e) { + cout << "Circuit error: " << e.what() << endl; + return EXIT_FAILURE; + } + + cout << "Circuit output: " << circuit.getOutput() << endl; + + return EXIT_SUCCESS; } -- cgit v1.2.3