--- trunk/mdtools/BASS_parse/parse_tree.c 2002/09/24 22:10:55 117 +++ trunk/mdtools/BASS_parse/parse_tree.c 2002/11/05 22:04:42 163 @@ -2,7 +2,13 @@ #include #include "parse_tree.h" +#include "../headers/simError.h" +#ifdef IS_MPI +#define __is_lex__ +#include "../headers/mpiBASS.h" +#endif + void walk_down( struct node_tag* the_node, struct namespc the_namespc ); int mol_index; // keeps track of the number of molecules int comp_index; // keeps track of the number of components. @@ -18,8 +24,10 @@ void pt_me( struct node_tag* head_node ){ struct namespc global_namespc; if( head_node->type != GLOBAL_HEAD ){ - fprintf( stderr, "Parse tree error: " - "The head node was not the global node.\n" ); + sprintf( painCave.errMsg, + "Parse tree error: The head node was not the global node.\n" ); + painCave.isFatal = 1; + simError(); } global_namespc.index = 0; @@ -27,7 +35,9 @@ void pt_me( struct node_tag* head_node ){ mol_index = 0; comp_index = 0; - walk_down( head_node->next_stmt, global_namespc ); + walk_down( head_node->next_stmt, global_namespc ); + // closed global namespace and exit + } /* @@ -48,7 +58,6 @@ void walk_down( struct node_tag* the_node, struct name if( the_node->type == GLOBAL_HEAD ){ print_tree_error( the_node, "Too many global regions" ); - exit(0); } if( the_node->stmt_list != NULL ){ @@ -61,7 +70,6 @@ void walk_down( struct node_tag* the_node, struct name if( the_namespc.type != GLOBAL_HEAD ){ print_tree_error( the_node, "component block is not in the global namespace" ); - exit(0); } else{ init_component( comp_index ); @@ -76,7 +84,6 @@ void walk_down( struct node_tag* the_node, struct name if( the_namespc.type != GLOBAL_HEAD ){ print_tree_error( the_node, "Molecule block is not in the global namespace" ); - exit(0); } else{ init_molecule( mol_index ); @@ -91,7 +98,6 @@ void walk_down( struct node_tag* the_node, struct name if( the_namespc.type != MOLECULE_HEAD ){ print_tree_error( the_node, "The atom block is not in a molecule namespace" ); - exit(0); } else{ init_atom( the_node->index ); @@ -105,7 +111,6 @@ void walk_down( struct node_tag* the_node, struct name if( the_namespc.type != MOLECULE_HEAD ){ print_tree_error( the_node, "The bond block is not in a molecule namespace" ); - exit(0); } else{ init_bond( the_node->index ); @@ -119,7 +124,6 @@ void walk_down( struct node_tag* the_node, struct name if( the_namespc.type != MOLECULE_HEAD ){ print_tree_error( the_node, "The bend block is not in a molecule namespace" ); - exit(0); } else{ init_bend( the_node->index ); @@ -134,7 +138,6 @@ void walk_down( struct node_tag* the_node, struct name print_tree_error( the_node, "The torsion block is not in " "a molecule namespace" ); - exit(0); } else{ init_torsion( the_node->index ); @@ -146,7 +149,6 @@ void walk_down( struct node_tag* the_node, struct name default: print_tree_error( the_node, "Not a valid code block" ); - exit(0); } } @@ -168,7 +170,6 @@ void walk_down( struct node_tag* the_node, struct name print_tree_error( the_node, "Member statement not in a bond, bend, " "or torsion" ); - exit(0); break; } break; @@ -185,7 +186,6 @@ void walk_down( struct node_tag* the_node, struct name print_tree_error( the_node, "Constraint statement not in a bond, bend, " "or torsion" ); - exit(0); break; } break; @@ -199,7 +199,6 @@ void walk_down( struct node_tag* the_node, struct name print_tree_error( the_node, "position statement is not located in an " "atom block" ); - exit(0); } init_position( the_node, the_namespc ); @@ -210,7 +209,6 @@ void walk_down( struct node_tag* the_node, struct name print_tree_error( the_node, "orientation statement is not located in an " "atom block" ); - exit(0); } init_orientation( the_node, the_namespc ); @@ -221,15 +219,13 @@ void walk_down( struct node_tag* the_node, struct name print_tree_error( the_node, "start_index statement is not located in an " "component block" ); - exit(0); } - init_start_index( the_node, the_namespc ); + //init_start_index( the_node, the_namespc ); break; default: print_tree_error( the_node, "unrecognized statement" ); - exit(0); break; } } @@ -257,53 +253,53 @@ void print_tree_error( struct node_tag* err_node, char switch( err_node->type ){ case GLOBAL_HEAD: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: global head node error -> %s\n", err_msg ); break; case COMPONENT_HEAD: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: component head node error -> %s\n", err_msg ); break; case MOLECULE_HEAD: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: molecule head node error -> %s\n", err_msg ); break; case ATOM_HEAD: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: atom head node error [%d] -> %s\n", err_node->index, err_msg ); break; case BOND_HEAD: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: bond head node error [%d] -> %s\n", err_node->index, err_msg ); break; case BEND_HEAD: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: bend head node error [%d] -> %s\n", err_node->index, err_msg ); break; case TORSION_HEAD: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: torsion head node error [%d] -> %s\n", err_node->index, err_msg ); break; case MEMBER_STMT: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: member node error => ( %d, %d, %d, %d )\n" " -> %s\n", err_node->the_data.mbr.a, @@ -314,7 +310,7 @@ void print_tree_error( struct node_tag* err_node, char break; case CONSTRAINT_STMT: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: constraint node error => ( %lf )\n" " -> %s\n", err_node->the_data.cnstr.constraint_val, @@ -322,7 +318,7 @@ void print_tree_error( struct node_tag* err_node, char break; case ASSIGNMENT_STMT: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: assignment node error\n" " => %s = ", err_node->the_data.asmt.identifier ); @@ -330,32 +326,32 @@ void print_tree_error( struct node_tag* err_node, char switch( err_node->the_data.asmt.type ){ case STR_ASSN: - fprintf( stderr, + sprintf( painCave.errMsg, "%s", err_node->the_data.asmt.rhs.str_ptr ); break; case INT_ASSN: - fprintf( stderr, + sprintf( painCave.errMsg, "%d", err_node->the_data.asmt.rhs.i_val ); break; case DOUBLE_ASSN: - fprintf( stderr, + sprintf( painCave.errMsg, "%lf", err_node->the_data.asmt.rhs.d_val ); break; } - fprintf( stderr, + sprintf( painCave.errMsg, "\n" " -> %s\n", err_msg ); break; case POSITION_STMT: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: position node error => ( %lf, %lf, %lf )\n" " -> %s\n", err_node->the_data.pos.x, @@ -365,7 +361,7 @@ void print_tree_error( struct node_tag* err_node, char break; case ORIENTATION_STMT: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: orientation node error => ( %lf, %lf, %lf )\n" " -> %s\n", err_node->the_data.ort.x, @@ -375,17 +371,24 @@ void print_tree_error( struct node_tag* err_node, char break; case START_INDEX_STMT: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: start_index error -> %s\n", err_msg ); break; default: - fprintf( stderr, + sprintf( painCave.errMsg, "Parse tree error: unknown node type -> %s\n", err_msg ); } + + painCave.isFatal = 1; + simError(); +#ifdef IS_MPI + mpiInterfaceExit(); +#endif //is_mpi + }