--- trunk/OOPSE/libBASS/parse_tree.c 2003/03/21 17:42:12 378 +++ trunk/OOPSE/libBASS/parse_tree.c 2004/01/29 23:01:17 998 @@ -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" ); @@ -161,18 +188,19 @@ 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 case TORSION_HEAD: // same for the first three + case RIGIDBODY_HEAD: init_members( the_node, the_namespc ); break; default: print_tree_error( the_node, - "Member statement not in a bond, bend, " - "or torsion" ); + "Members statement not in a bond, bend, " + "torsion, or rigidBody." ); break; } break; @@ -198,33 +226,23 @@ 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: @@ -273,6 +291,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 +317,19 @@ 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 MEMBERS_STMT: sprintf( painCave.errMsg, - "Parse tree error: member node error => ( %d, %d, %d, %d )\n" + "Parse tree error: members node error (nMembers = %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.nMembers, err_msg ); break; @@ -367,19 +388,12 @@ void print_tree_error( struct node_tag* err_node, char sprintf( painCave.errMsg, "Parse tree error: orientation node error => ( %lf, %lf, %lf )\n" " -> %s\n", - err_node->the_data.ort.x, - err_node->the_data.ort.y, - err_node->the_data.ort.z, + err_node->the_data.ort.phi, + err_node->the_data.ort.theta, + err_node->the_data.ort.psi, 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 +416,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 +440,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;