diff --git a/nasal_hash.cpp b/nasal_hash.cpp index f048ee2..83fb8dc 100644 --- a/nasal_hash.cpp +++ b/nasal_hash.cpp @@ -445,5 +445,36 @@ NasalHash& NasalHash::operator=(const NasalHash &Source) return *this; } +void NasalHash::SearchElement(std::string &ElementName) +{ + HashUnit *temp=head; + while(temp->next) + { + temp=temp->next; + if(temp->VarName==ElementName) + { + if(temp->Type=="int") + std::cout<<*((int *)temp->data); + else if(temp->Type=="float") + std::cout<<*((float *)temp->data); + else if(temp->Type=="double") + std::cout<<*((double *)temp->data); + else if(temp->Type=="char") + std::cout<<*((char *)temp->data); + else if(temp->Type=="long long int") + std::cout<<*((long long int *)temp->data); + else if(temp->Type=="string") + std::cout<<*((std::string *)temp->data); + else if(temp->Type=="array") + ((NasalList *)temp->data)->PrintList(); + else if(temp->Type=="hash") + ((NasalHash *)temp->data)->PrintHash(); + return; + } + } + std::cout<<"[Error] Could not find \""<next) + { + temp=temp->next; + cnt++; + if(cnt==n) + { + return; + } + } + std::cout<<"[Error] Out of range: real end: "<line=0; - head->Name="InterpreterInfo"; + head->name="InterpreterInfo"; + head->format_type="Info"; head->global=false; - head->type="information"; head->unitdata.Type="string"; head->unitdata.data=new std::string; *((std::string *)head->unitdata.data)="# Nasal language for FlightGear."; @@ -68,9 +68,9 @@ class process_stack last_node->next=temp; temp->next=NULL; - temp->Name=p.Name; + temp->name=p.name; temp->line=p.line; - temp->type=p.type; + temp->format_type=p.format_type; temp->global=p.global; temp->unitdata=p.unitdata; @@ -80,28 +80,57 @@ class process_stack { process_stack_unit *temp=head; std::cout<<"In stack: "<line<<": |"<type<<"| \""<Name<<"\""<next) - { - temp=temp->next; - std::cout<line<<": |"<type<<"| \""<Name<<"\""<next) + temp=temp->next; while(temp->last) { - std::cout<line<<": |"<type<<"| \""<Name<<"\""<line<<": |"<format_type<<"|"<name<<"|\n\t|"; + temp->unitdata.Print(); + std::cout<last; } + std::cout<<"line "<line<<": |"<format_type<<"|"<name<<"|\n\t|"; + temp->unitdata.Print(); + std::cout<line<<": |"<format_type<<"|"<name<<"|\n\t|"; + temp->unitdata.Print(); + std::cout<next) + { + temp=temp->next; + std::cout<<"line "<line<<": |"<format_type<<"|"<name<<"|\n\t|"; + temp->unitdata.Print(); + std::cout<next) + { + last_node=temp; + temp=temp->next; + } + last_node->next=NULL; + delete temp; + return; + } bool check_stack(std::string &ElementName) { process_stack_unit *temp=head; while(temp->next) { temp=temp->next; - if(temp->Name==ElementName) + if(temp->name==ElementName) return true; } return false; @@ -112,7 +141,7 @@ class process_stack while(temp->next) { temp=temp->next; - if(temp->Name==ElementName) + if(temp->name==ElementName) { temp->unitdata.Print(); return;