--- trunk/mdtools/BASS_parse/parse_tree.c 2002/10/30 22:38:18 159 +++ trunk/mdtools/BASS_parse/parse_tree.c 2002/10/30 22:38:22 160 @@ -2,6 +2,7 @@ #include #include "parse_tree.h" +#include "../headers/simError.h" #ifdef IS_MPI #define __is_lex__ @@ -23,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; @@ -54,7 +57,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 ){ @@ -67,7 +69,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 ); @@ -82,7 +83,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 ); @@ -97,7 +97,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 ); @@ -111,7 +110,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 ); @@ -125,7 +123,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 ); @@ -140,7 +137,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 ); @@ -152,7 +148,6 @@ void walk_down( struct node_tag* the_node, struct name default: print_tree_error( the_node, "Not a valid code block" ); - exit(0); } } @@ -174,7 +169,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; @@ -191,7 +185,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; @@ -205,7 +198,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 ); @@ -216,7 +208,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 ); @@ -227,7 +218,6 @@ 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 ); @@ -235,7 +225,6 @@ void walk_down( struct node_tag* the_node, struct name default: print_tree_error( the_node, "unrecognized statement" ); - exit(0); break; } } @@ -263,53 +252,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, @@ -320,7 +309,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, @@ -328,7 +317,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 ); @@ -336,32 +325,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, @@ -371,7 +360,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, @@ -381,22 +370,20 @@ 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 ); } -#ifdef IS_MPI - mpiInterfaceExit(); -#endif - + painCave.isFatal = 1; + simError(); }