Finally, the main
function is almost identical to the previous function.
Main.cpp:
#include <QApplication> #include <QMessageBox> #include <IOStream> using namespace std; #include "Action.h" #include "Error.h" #include "Scanner.h" #include "Parser.h" #include "Evaluator.h" #include "ViewerWidget.h" int main(int argc, char *argv[]) { Scanner::init(); QApplication application(argc, argv); try { QString path = "C:\Input.dsl"; QFile file(path); if (!file.open(QIODevice::ReadOnly)) { error("Cannot open file "" + path + "" for reading."); } QString buffer(file.readAll()); Scanner scanner(buffer);
The only difference is that the parser generates a sequence of directives rather than actions, as well as a function map, which is sent to the evaluator that generates the final action list that is read and executed by the viewer that displays the graphical objects:
QList<Directive> directiveList...