--- trunk/OOPSE/libBASS/parse_tree.c 2003/03/21 17:42:12 378 +++ trunk/OOPSE/libBASS/parse_tree.c 2004/01/27 19:37:48 988 @@ -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,34 @@ void walk_down( struct node_tag* the_node, struct name walk_down( the_node->stmt_list, current_namespc ); } break; + + case MEMBER_HEAD: + if( the_namespc.type != RIGIDBODY_HEAD ){ + print_tree_error( the_node, + "The Member block is not in " + "a rigidBody namespace" ); + } + else{ + init_member( 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 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" ); @@ -161,7 +202,7 @@ void walk_down( struct node_tag* the_node, struct name switch( the_node->type ){ - case MEMBER_STMT: + case MEMBERS_STMT: switch( the_namespc.type ){ case BOND_HEAD: // fall through case BEND_HEAD: // fall through @@ -171,7 +212,7 @@ void walk_down( struct node_tag* the_node, struct name default: print_tree_error( the_node, - "Member statement not in a bond, bend, " + "Members statement not in a bond, bend, " "or torsion" ); break; } @@ -198,35 +239,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 +304,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", @@ -293,22 +330,29 @@ void print_tree_error( struct node_tag* err_node, char err_node->index, err_msg ); break; - - case TORSION_HEAD: + + case ZCONSTRAINT_HEAD: sprintf( painCave.errMsg, - "Parse tree error: torsion head node error [%d] -> %s\n", + "Parse tree error: Zconstraint head node error [%d] -> %s\n", err_node->index, err_msg ); break; - - case MEMBER_STMT: + + case MEMBER_HEAD: sprintf( painCave.errMsg, - "Parse tree error: member node error => ( %d, %d, %d, %d )\n" + "Parse tree error: member head node error [%d] -> %s\n", + err_node->index, + err_msg ); + break; + + case MEMBERS_STMT: + sprintf( painCave.errMsg, + "Parse tree error: members node error => ( %d, %d, %d, %d )\n" " -> %s\n", - err_node->the_data.mbr.a, - err_node->the_data.mbr.b, - err_node->the_data.mbr.c, - err_node->the_data.mbr.d, + err_node->the_data.mbrs.a, + err_node->the_data.mbrs.b, + err_node->the_data.mbrs.c, + err_node->the_data.mbrs.d, err_msg ); break; @@ -373,13 +417,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 +439,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 +463,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;