diff --git a/LangS.ypp b/LangS.ypp index 333aef3..975db78 100644 --- a/LangS.ypp +++ b/LangS.ypp @@ -30,7 +30,7 @@ Program *theProg; %% Prog: Stm ';' Prog { theProg->add((Statement *)$1); } - | Stm ';' { theProg->add((Statement *)$1); } + | Stm ';' { theProg = new ParseTree::Program(); theProg->add((Statement *)$1); } Stm: Exit { $$ = new ExitStatement();} | Ident '=' Value { $$ = new AssingmentStatement((Identifier*)$1,(Value*)$3); } diff --git a/Util.cpp b/Util.cpp index d3374e0..78db1de 100644 --- a/Util.cpp +++ b/Util.cpp @@ -38,7 +38,6 @@ string num2str(double val){ extern ParseTree::Program *theProg; int main(int argc, char *argv[]) { - theProg = new ParseTree::Program(); try{ yyparse(); theProg->run(); @@ -50,4 +49,3 @@ int main(int argc, char *argv[]) { RunTime::cleanScalars(); return 0; }//end main -