--- branches/mmeineke/OOPSE/libBASS/parse_tree.c 2003/03/21 17:42:12 377 +++ trunk/OOPSE/libBASS/parse_tree.c 2004/01/19 16:08:21 957 @@ -1,12 +1,12 @@ #include #include -#include -#include +#include "parse_tree.h" +#include "simError.h" #ifdef IS_MPI #define __is_lex__ -#include +#include "mpiBASS.h" #endif void walk_down( struct node_tag* the_node, struct namespc the_namespc ); @@ -98,12 +98,25 @@ void walk_down( struct node_tag* the_node, struct name break; case ATOM_HEAD: + if( the_namespc.type != MOLECULE_HEAD && the_namespc.type != RIGIDBODY_HEAD ){ + print_tree_error( the_node, + "The atom block is not in a molecule or rigidBody namespace" ); + } + else{ + init_atom( the_node->index ); + current_namespc.index = the_node->index; + current_namespc.type = the_node->type; + walk_down( the_node->stmt_list, current_namespc ); + } + break; + + case RIGIDBODY_HEAD: if( the_namespc.type != MOLECULE_HEAD ){ print_tree_error( the_node, - "The atom block is not in a molecule namespace" ); + "The rigid body block is not in a molecule namespace" ); } else{ - init_atom( the_node->index ); + init_rigidbody( the_node->index ); current_namespc.index = the_node->index; current_namespc.type = the_node->type; walk_down( the_node->stmt_list, current_namespc ); @@ -149,6 +162,20 @@ void walk_down( struct node_tag* the_node, struct name walk_down( the_node->stmt_list, current_namespc ); } break; + + case ZCONSTRAINT_HEAD: + if( the_namespc.type != GLOBAL_HEAD ){ + print_tree_error( the_node, + "The Zconstraint block is not in " + "the global namespace" ); + } + else{ + init_zconstraint( the_node->index ); + current_namespc.index = the_node->index; + current_namespc.type = the_node->type; + walk_down( the_node->stmt_list, current_namespc ); + } + break; default: print_tree_error( the_node, "Not a valid code block" ); @@ -198,35 +225,25 @@ void walk_down( struct node_tag* the_node, struct name break; case POSITION_STMT: - if( the_namespc.type != ATOM_HEAD ){ + if( the_namespc.type != ATOM_HEAD && the_namespc.type != RIGIDBODY_HEAD){ print_tree_error( the_node, "position statement is not located in an " - "atom block" ); + "atom or rigidBody block" ); } init_position( the_node, the_namespc ); break; case ORIENTATION_STMT: - if( the_namespc.type != ATOM_HEAD ){ + if( the_namespc.type != ATOM_HEAD && the_namespc.type != RIGIDBODY_HEAD){ print_tree_error( the_node, "orientation statement is not located in an " - "atom block" ); + "atom or rigidBody block" ); } init_orientation( the_node, the_namespc ); break; - case START_INDEX_STMT: - if( the_namespc.type != COMPONENT_HEAD ){ - print_tree_error( the_node, - "start_index statement is not located in an " - "component block" ); - } - - //init_start_index( the_node, the_namespc ); - break; - default: print_tree_error( the_node, "unrecognized statement" ); break; @@ -273,6 +290,12 @@ void print_tree_error( struct node_tag* err_node, char err_msg ); break; + case RIGIDBODY_HEAD: + sprintf( painCave.errMsg, + "Parse tree error: rigidBody head node error -> %s\n", + err_msg ); + break; + case ATOM_HEAD: sprintf( painCave.errMsg, "Parse tree error: atom head node error [%d] -> %s\n", @@ -300,7 +323,14 @@ void print_tree_error( struct node_tag* err_node, char err_node->index, err_msg ); break; - + + case ZCONSTRAINT_HEAD: + sprintf( painCave.errMsg, + "Parse tree error: Zconstraint head node error [%d] -> %s\n", + err_node->index, + err_msg ); + break; + case MEMBER_STMT: sprintf( painCave.errMsg, "Parse tree error: member node error => ( %d, %d, %d, %d )\n" @@ -373,13 +403,6 @@ void print_tree_error( struct node_tag* err_node, char err_msg ); break; - case START_INDEX_STMT: - sprintf( painCave.errMsg, - "Parse tree error: start_index error -> %s\n", - err_msg ); - break; - - default: sprintf( painCave.errMsg, "Parse tree error: unknown node type -> %s\n", @@ -402,12 +425,7 @@ void kill_tree( struct node_tag* the_node ){ void kill_tree( struct node_tag* the_node ){ - // These two are needed to get rid of the integer list - struct integer_list_tag* current_il; - struct integer_list_tag* temp_il; - - if( the_node != NULL ){ if( the_node->stmt_list != NULL ){ @@ -431,17 +449,6 @@ void kill_tree( struct node_tag* the_node ){ free( the_node->the_data.asmt.identifier ); break; - case START_INDEX_STMT: - - current_il = the_node->the_data.il_head; - while( current_il != NULL ){ - temp_il = current_il->next; - free( current_il ); - current_il = temp_il; - } - the_node->the_data.il_head = NULL; - break; - default: // nothing to do here, everyone else can be freed normally. break;