ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/BASS_parse/parse_tree.c
(Generate patch)

Comparing trunk/mdtools/BASS_parse/parse_tree.c (file contents):
Revision 138 by chuckv, Wed Oct 16 21:07:02 2002 UTC vs.
Revision 160 by mmeineke, Wed Oct 30 22:38:22 2002 UTC

# Line 2 | Line 2
2   #include <stdio.h>
3  
4   #include "parse_tree.h"
5 + #include "../headers/simError.h"
6  
7   #ifdef IS_MPI
8   #define __is_lex__
# Line 23 | Line 24 | void pt_me( struct node_tag* head_node ){
24    struct namespc global_namespc;
25    
26    if( head_node->type != GLOBAL_HEAD ){
27 <    fprintf( stderr, "Parse tree error: "
28 <             "The head node was not the global node.\n" );
27 >    sprintf( painCave.errMsg,
28 >             "Parse tree error: The head node was not the global node.\n" );
29 >    painCave.isFatal = 1;
30 >    simError();
31    }
32  
33    global_namespc.index = 0;
# Line 54 | Line 57 | void walk_down( struct node_tag* the_node, struct name
57      
58      if( the_node->type == GLOBAL_HEAD ){
59        print_tree_error( the_node, "Too many global regions" );
57      exit(0);
60      }
61  
62      if( the_node->stmt_list != NULL ){
# Line 67 | Line 69 | void walk_down( struct node_tag* the_node, struct name
69          if( the_namespc.type != GLOBAL_HEAD ){
70            print_tree_error( the_node,
71                              "component block is not in the global namespace" );
70          exit(0);
72          }
73          else{
74            init_component( comp_index );
# Line 82 | Line 83 | void walk_down( struct node_tag* the_node, struct name
83          if( the_namespc.type != GLOBAL_HEAD ){
84            print_tree_error( the_node,
85                              "Molecule block is not in the global namespace" );
85          exit(0);
86          }
87          else{
88            init_molecule( mol_index );
# Line 97 | Line 97 | void walk_down( struct node_tag* the_node, struct name
97          if( the_namespc.type != MOLECULE_HEAD ){
98            print_tree_error( the_node,
99                              "The atom block is not in a molecule namespace" );
100          exit(0);
100          }
101          else{
102            init_atom( the_node->index );
# Line 111 | Line 110 | void walk_down( struct node_tag* the_node, struct name
110          if( the_namespc.type != MOLECULE_HEAD ){
111            print_tree_error( the_node,
112                              "The bond block is not in a molecule namespace" );
114          exit(0);
113          }
114          else{
115            init_bond( the_node->index );
# Line 125 | Line 123 | void walk_down( struct node_tag* the_node, struct name
123          if( the_namespc.type != MOLECULE_HEAD ){
124            print_tree_error( the_node,
125                              "The bend block is not in a molecule namespace" );
128          exit(0);
126          }
127          else{
128            init_bend( the_node->index );
# Line 140 | Line 137 | void walk_down( struct node_tag* the_node, struct name
137            print_tree_error( the_node,
138                              "The torsion block is not in "
139                              "a molecule namespace" );
143          exit(0);
140          }
141          else{
142            init_torsion( the_node->index );
# Line 152 | Line 148 | void walk_down( struct node_tag* the_node, struct name
148          
149        default:
150          print_tree_error( the_node, "Not a valid code block" );
155        exit(0);
151        }
152      }
153      
# Line 174 | Line 169 | void walk_down( struct node_tag* the_node, struct name
169            print_tree_error( the_node,
170                              "Member statement not in a bond, bend, "
171                              "or torsion" );
177          exit(0);
172            break;
173          }
174          break;
# Line 191 | Line 185 | void walk_down( struct node_tag* the_node, struct name
185            print_tree_error( the_node,
186                              "Constraint statement not in a bond, bend, "
187                              "or torsion" );
194          exit(0);
188            break;
189          }
190          break;
# Line 205 | Line 198 | void walk_down( struct node_tag* the_node, struct name
198            print_tree_error( the_node,
199                              "position statement is not located in an "
200                              "atom block" );
208          exit(0);
201          }
202          
203          init_position( the_node, the_namespc );
# Line 216 | Line 208 | void walk_down( struct node_tag* the_node, struct name
208            print_tree_error( the_node,
209                              "orientation statement is not located in an "
210                              "atom block" );
219          exit(0);
211          }
212          
213          init_orientation( the_node, the_namespc );
# Line 227 | Line 218 | void walk_down( struct node_tag* the_node, struct name
218            print_tree_error( the_node,
219                              "start_index statement is not located in an "
220                              "component block" );
230          exit(0);
221          }
222          
223          //init_start_index( the_node, the_namespc );
# Line 235 | Line 225 | void walk_down( struct node_tag* the_node, struct name
225  
226        default:
227          print_tree_error( the_node, "unrecognized statement" );
238        exit(0);
228          break;
229        }
230      }
# Line 263 | Line 252 | void print_tree_error( struct node_tag* err_node, char
252    switch( err_node->type ){
253  
254    case GLOBAL_HEAD:
255 <    fprintf( stderr,
255 >    sprintf( painCave.errMsg,
256               "Parse tree error: global head node error -> %s\n",
257               err_msg );
258      break;
259      
260    case COMPONENT_HEAD:
261 <    fprintf( stderr,
261 >    sprintf( painCave.errMsg,
262               "Parse tree error: component head node error -> %s\n",
263               err_msg );
264      break;
265  
266    case MOLECULE_HEAD:
267 <    fprintf( stderr,
267 >    sprintf( painCave.errMsg,
268               "Parse tree error: molecule head node error -> %s\n",
269               err_msg );
270      break;
271  
272    case ATOM_HEAD:
273 <    fprintf( stderr,
273 >    sprintf( painCave.errMsg,
274               "Parse tree error: atom head node error [%d] -> %s\n",
275               err_node->index,
276               err_msg );
277      break;
278      
279    case BOND_HEAD:
280 <    fprintf( stderr,
280 >    sprintf( painCave.errMsg,
281               "Parse tree error: bond head node error [%d] -> %s\n",
282               err_node->index,
283               err_msg );
284      break;
285      
286    case BEND_HEAD:
287 <    fprintf( stderr,
287 >    sprintf( painCave.errMsg,
288               "Parse tree error: bend head node error [%d] -> %s\n",
289               err_node->index,
290               err_msg );
291      break;
292      
293    case TORSION_HEAD:
294 <    fprintf( stderr,
294 >    sprintf( painCave.errMsg,
295               "Parse tree error: torsion head node error [%d] -> %s\n",
296               err_node->index,
297               err_msg );
298      break;
299      
300    case MEMBER_STMT:
301 <    fprintf( stderr,
301 >    sprintf( painCave.errMsg,
302               "Parse tree error: member node error => ( %d, %d, %d, %d )\n"
303               "                  -> %s\n",
304               err_node->the_data.mbr.a,
# Line 320 | Line 309 | void print_tree_error( struct node_tag* err_node, char
309      break;
310  
311    case CONSTRAINT_STMT:
312 <    fprintf( stderr,
312 >    sprintf( painCave.errMsg,
313              "Parse tree error: constraint node error => ( %lf )\n"
314              "                 -> %s\n",
315              err_node->the_data.cnstr.constraint_val,
# Line 328 | Line 317 | void print_tree_error( struct node_tag* err_node, char
317      break;
318      
319    case ASSIGNMENT_STMT:
320 <    fprintf( stderr,
320 >    sprintf( painCave.errMsg,
321               "Parse tree error: assignment node error\n"
322               "                  => %s = ",
323               err_node->the_data.asmt.identifier );
# Line 336 | Line 325 | void print_tree_error( struct node_tag* err_node, char
325      switch( err_node->the_data.asmt.type ){
326        
327      case STR_ASSN:
328 <      fprintf( stderr,
328 >      sprintf( painCave.errMsg,
329                 "%s",
330                 err_node->the_data.asmt.rhs.str_ptr );
331        break;
332        
333      case INT_ASSN:
334 <      fprintf( stderr,
334 >      sprintf( painCave.errMsg,
335                 "%d",
336                 err_node->the_data.asmt.rhs.i_val );
337        break;
338        
339      case DOUBLE_ASSN:
340 <      fprintf( stderr,
340 >      sprintf( painCave.errMsg,
341                 "%lf",
342                 err_node->the_data.asmt.rhs.d_val );
343        break;
344      }
345      
346 <    fprintf( stderr,
346 >    sprintf( painCave.errMsg,
347               "\n"
348               "                  -> %s\n",
349               err_msg );
350      break;
351  
352    case POSITION_STMT:
353 <    fprintf( stderr,
353 >    sprintf( painCave.errMsg,
354               "Parse tree error: position node error => ( %lf, %lf, %lf )\n"
355               "                  -> %s\n",
356               err_node->the_data.pos.x,
# Line 371 | Line 360 | void print_tree_error( struct node_tag* err_node, char
360      break;
361  
362    case ORIENTATION_STMT:
363 <    fprintf( stderr,
363 >    sprintf( painCave.errMsg,
364               "Parse tree error: orientation node error => ( %lf, %lf, %lf )\n"
365               "                  -> %s\n",
366               err_node->the_data.ort.x,
# Line 381 | Line 370 | void print_tree_error( struct node_tag* err_node, char
370      break;
371  
372    case START_INDEX_STMT:
373 <    fprintf( stderr,
373 >    sprintf( painCave.errMsg,
374               "Parse tree error: start_index error -> %s\n",
375               err_msg );
376      break;
377  
378  
379    default:
380 <    fprintf( stderr,
380 >    sprintf( painCave.errMsg,
381               "Parse tree error: unknown node type -> %s\n",
382               err_msg );
383    }
384  
385 < #ifdef IS_MPI
386 <  mpiInterfaceExit();
398 < #endif
399 <
385 >  painCave.isFatal = 1;
386 >  simError();
387   }
388  
389  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines