diff --git a/ExitStatement.cpp b/ExitStatement.cpp index 8d010aa..5884f08 100644 --- a/ExitStatement.cpp +++ b/ExitStatement.cpp @@ -14,6 +14,10 @@ ExitStatement::ExitStatement() { } +void ExitStatement::Execute(){ + throw new ExitCondition(); +} + ExitStatement::~ExitStatement() { // TODO Auto-generated destructor stub } diff --git a/ExitStatement.h b/ExitStatement.h index 9609220..bb57b4b 100644 --- a/ExitStatement.h +++ b/ExitStatement.h @@ -12,9 +12,14 @@ namespace ParseTree { +class ExitCondition { + +}; + class ExitStatement: public ParseTree::Statement { public: ExitStatement(); + void Execute(); virtual ~ExitStatement(); }; diff --git a/Util.cpp b/Util.cpp index 32f662b..e653dde 100644 --- a/Util.cpp +++ b/Util.cpp @@ -38,8 +38,12 @@ extern ParseTree::Program *theProg; int main(int argc, char *argv[]) { theProg = new ParseTree::Program(); - yyparse(); - theProg->run(); + try{ + yyparse(); + theProg->run(); + }catch(ParseTree::ExitCondition *ex){ + cout<<"Program terminated"<