diff --git a/src/globals.cpp b/src/globals.cpp index 47d79e4..d1e3686 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -7,10 +7,10 @@ std::map G_vars; std::multimap G_funcs; // List of objects to save -std::list G_tosave; +std::list G_tosave; // List of objects to print -std::list G_toprint; +std::list G_toprint; void ClearGlobals() { diff --git a/src/globals.h b/src/globals.h index 76c296a..0b8c5c1 100644 --- a/src/globals.h +++ b/src/globals.h @@ -13,10 +13,10 @@ typedef ObjectBase* (*Func)(ObjectList*); extern EXPORT std::multimap G_funcs; // List of objects to save -extern EXPORT std::list EXPORT G_tosave; +extern EXPORT std::list EXPORT G_tosave; // List of objects to print -extern EXPORT std::list EXPORT G_toprint; +extern EXPORT std::list EXPORT G_toprint; void ClearGlobals(); diff --git a/src/main.cpp b/src/main.cpp index 3efaf9f..ac754ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,7 +10,7 @@ int main(int argc, char** argv) SetDebugLevel(INFO); COUT(INFO)<<"Parse config file "< object %type pair %type list + +%destructor {} REAL INTEGER BOOL STRING +%destructor {delete $$;} <*> + %% input: %empty {COUT(DEBUG)<<"Empty input\n";} @@ -65,8 +69,32 @@ input: line: NAME ASSIGN object ENDL {COUT(DEBUG)<<" NAME ASSIGN object ENDL\n"; if(G_vars.count(*$1)!=0) delete G_vars[*$1]; G_vars[*$1]=$3; delete $1;} | NAME ASSIGN list ENDL {COUT(DEBUG)<<" NAME ASSIGN list ENDL\n"; if(G_vars.count(*$1)!=0) delete G_vars[*$1]; G_vars[*$1]=$3; delete $1;} - | NAME OBRACE list CBRACE ENDL {COUT(DEBUG)<<" NAME OBRACE list CBRACE ENDL\n"; transform($1->begin(),$1->end(),$1->begin(),::tolower); if(*$1=="save") G_tosave.push_back($3); if(*$1=="print") G_toprint.push_back($3); delete $1;} - | NAME OBRACE object CBRACE ENDL {COUT(DEBUG)<<" NAME OBRACE object CBRACE ENDL\n"; transform($1->begin(),$1->end(),$1->begin(),::tolower); if(*$1=="save") G_tosave.push_back($3); if(*$1=="print") G_toprint.push_back($3); delete $1;} + | NAME OBRACE list CBRACE ENDL {COUT(DEBUG)<<" NAME OBRACE list CBRACE ENDL\n"; + transform($1->begin(),$1->end(),$1->begin(),::tolower); + ObjectList* ol=dynamic_cast($3); + if(*$1=="save") G_tosave.push_back(ol); + else if(*$1=="print") G_toprint.push_back(ol); + else + { + COUT(ERROR)<begin(),$1->end(),$1->begin(),::tolower); + ObjectList* ol=new ObjectList($3); + if(*$1=="save") G_tosave.push_back(ol); + else if(*$1=="print") G_toprint.push_back(ol); + else + { + COUT(ERROR)<