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 118 by chuckv, Wed Sep 25 22:51:14 2002 UTC vs.
Revision 170 by mmeineke, Mon Nov 11 15:16:09 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__
9 + #include "../headers/mpiBASS.h"
10 + #endif
11 +
12   void walk_down( struct node_tag* the_node, struct namespc the_namespc );
13   int mol_index; // keeps track of the number of molecules
14   int comp_index; // keeps track of the number of components.
# Line 18 | 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 > #ifdef IS_MPI
32 >    mpiInterfaceExit();
33 > #endif //is_mpi
34    }
35  
36    global_namespc.index = 0;
# Line 27 | Line 38 | void pt_me( struct node_tag* head_node ){
38  
39    mol_index = 0;
40    comp_index = 0;
41 <  walk_down( head_node->next_stmt, global_namespc ); // closed global namespace + exit
41 >  walk_down( head_node->next_stmt, global_namespc );
42 >  // closed global namespace and exit
43  
44   }
45  
# Line 49 | Line 61 | void walk_down( struct node_tag* the_node, struct name
61      
62      if( the_node->type == GLOBAL_HEAD ){
63        print_tree_error( the_node, "Too many global regions" );
52      exit(0);
64      }
65  
66      if( the_node->stmt_list != NULL ){
# Line 62 | Line 73 | void walk_down( struct node_tag* the_node, struct name
73          if( the_namespc.type != GLOBAL_HEAD ){
74            print_tree_error( the_node,
75                              "component block is not in the global namespace" );
65          exit(0);
76          }
77          else{
78            init_component( comp_index );
# Line 77 | Line 87 | void walk_down( struct node_tag* the_node, struct name
87          if( the_namespc.type != GLOBAL_HEAD ){
88            print_tree_error( the_node,
89                              "Molecule block is not in the global namespace" );
80          exit(0);
90          }
91          else{
92            init_molecule( mol_index );
# Line 92 | Line 101 | void walk_down( struct node_tag* the_node, struct name
101          if( the_namespc.type != MOLECULE_HEAD ){
102            print_tree_error( the_node,
103                              "The atom block is not in a molecule namespace" );
95          exit(0);
104          }
105          else{
106            init_atom( the_node->index );
# Line 106 | Line 114 | void walk_down( struct node_tag* the_node, struct name
114          if( the_namespc.type != MOLECULE_HEAD ){
115            print_tree_error( the_node,
116                              "The bond block is not in a molecule namespace" );
109          exit(0);
117          }
118          else{
119            init_bond( the_node->index );
# Line 120 | Line 127 | void walk_down( struct node_tag* the_node, struct name
127          if( the_namespc.type != MOLECULE_HEAD ){
128            print_tree_error( the_node,
129                              "The bend block is not in a molecule namespace" );
123          exit(0);
130          }
131          else{
132            init_bend( the_node->index );
# Line 135 | Line 141 | void walk_down( struct node_tag* the_node, struct name
141            print_tree_error( the_node,
142                              "The torsion block is not in "
143                              "a molecule namespace" );
138          exit(0);
144          }
145          else{
146            init_torsion( the_node->index );
# Line 147 | Line 152 | void walk_down( struct node_tag* the_node, struct name
152          
153        default:
154          print_tree_error( the_node, "Not a valid code block" );
150        exit(0);
155        }
156      }
157      
# Line 169 | Line 173 | void walk_down( struct node_tag* the_node, struct name
173            print_tree_error( the_node,
174                              "Member statement not in a bond, bend, "
175                              "or torsion" );
172          exit(0);
176            break;
177          }
178          break;
# Line 186 | Line 189 | void walk_down( struct node_tag* the_node, struct name
189            print_tree_error( the_node,
190                              "Constraint statement not in a bond, bend, "
191                              "or torsion" );
189          exit(0);
192            break;
193          }
194          break;
# Line 200 | Line 202 | void walk_down( struct node_tag* the_node, struct name
202            print_tree_error( the_node,
203                              "position statement is not located in an "
204                              "atom block" );
203          exit(0);
205          }
206          
207          init_position( the_node, the_namespc );
# Line 211 | Line 212 | void walk_down( struct node_tag* the_node, struct name
212            print_tree_error( the_node,
213                              "orientation statement is not located in an "
214                              "atom block" );
214          exit(0);
215          }
216          
217          init_orientation( the_node, the_namespc );
# Line 222 | Line 222 | void walk_down( struct node_tag* the_node, struct name
222            print_tree_error( the_node,
223                              "start_index statement is not located in an "
224                              "component block" );
225          exit(0);
225          }
226          
227 <        init_start_index( the_node, the_namespc );
227 >        //init_start_index( the_node, the_namespc );
228          break;
229  
230        default:
231          print_tree_error( the_node, "unrecognized statement" );
233        exit(0);
232          break;
233        }
234      }
# Line 258 | Line 256 | void print_tree_error( struct node_tag* err_node, char
256    switch( err_node->type ){
257  
258    case GLOBAL_HEAD:
259 <    fprintf( stderr,
259 >    sprintf( painCave.errMsg,
260               "Parse tree error: global head node error -> %s\n",
261               err_msg );
262      break;
263      
264    case COMPONENT_HEAD:
265 <    fprintf( stderr,
265 >    sprintf( painCave.errMsg,
266               "Parse tree error: component head node error -> %s\n",
267               err_msg );
268      break;
269  
270    case MOLECULE_HEAD:
271 <    fprintf( stderr,
271 >    sprintf( painCave.errMsg,
272               "Parse tree error: molecule head node error -> %s\n",
273               err_msg );
274      break;
275  
276    case ATOM_HEAD:
277 <    fprintf( stderr,
277 >    sprintf( painCave.errMsg,
278               "Parse tree error: atom head node error [%d] -> %s\n",
279               err_node->index,
280               err_msg );
281      break;
282      
283    case BOND_HEAD:
284 <    fprintf( stderr,
284 >    sprintf( painCave.errMsg,
285               "Parse tree error: bond head node error [%d] -> %s\n",
286               err_node->index,
287               err_msg );
288      break;
289      
290    case BEND_HEAD:
291 <    fprintf( stderr,
291 >    sprintf( painCave.errMsg,
292               "Parse tree error: bend head node error [%d] -> %s\n",
293               err_node->index,
294               err_msg );
295      break;
296      
297    case TORSION_HEAD:
298 <    fprintf( stderr,
298 >    sprintf( painCave.errMsg,
299               "Parse tree error: torsion head node error [%d] -> %s\n",
300               err_node->index,
301               err_msg );
302      break;
303      
304    case MEMBER_STMT:
305 <    fprintf( stderr,
305 >    sprintf( painCave.errMsg,
306               "Parse tree error: member node error => ( %d, %d, %d, %d )\n"
307               "                  -> %s\n",
308               err_node->the_data.mbr.a,
# Line 315 | Line 313 | void print_tree_error( struct node_tag* err_node, char
313      break;
314  
315    case CONSTRAINT_STMT:
316 <    fprintf( stderr,
316 >    sprintf( painCave.errMsg,
317              "Parse tree error: constraint node error => ( %lf )\n"
318              "                 -> %s\n",
319              err_node->the_data.cnstr.constraint_val,
# Line 323 | Line 321 | void print_tree_error( struct node_tag* err_node, char
321      break;
322      
323    case ASSIGNMENT_STMT:
324 <    fprintf( stderr,
324 >    sprintf( painCave.errMsg,
325               "Parse tree error: assignment node error\n"
326               "                  => %s = ",
327               err_node->the_data.asmt.identifier );
# Line 331 | Line 329 | void print_tree_error( struct node_tag* err_node, char
329      switch( err_node->the_data.asmt.type ){
330        
331      case STR_ASSN:
332 <      fprintf( stderr,
332 >      sprintf( painCave.errMsg,
333                 "%s",
334                 err_node->the_data.asmt.rhs.str_ptr );
335        break;
336        
337      case INT_ASSN:
338 <      fprintf( stderr,
338 >      sprintf( painCave.errMsg,
339                 "%d",
340                 err_node->the_data.asmt.rhs.i_val );
341        break;
342        
343      case DOUBLE_ASSN:
344 <      fprintf( stderr,
344 >      sprintf( painCave.errMsg,
345                 "%lf",
346                 err_node->the_data.asmt.rhs.d_val );
347        break;
348      }
349      
350 <    fprintf( stderr,
350 >    sprintf( painCave.errMsg,
351               "\n"
352               "                  -> %s\n",
353               err_msg );
354      break;
355  
356    case POSITION_STMT:
357 <    fprintf( stderr,
357 >    sprintf( painCave.errMsg,
358               "Parse tree error: position node error => ( %lf, %lf, %lf )\n"
359               "                  -> %s\n",
360               err_node->the_data.pos.x,
# Line 366 | Line 364 | void print_tree_error( struct node_tag* err_node, char
364      break;
365  
366    case ORIENTATION_STMT:
367 <    fprintf( stderr,
367 >    sprintf( painCave.errMsg,
368               "Parse tree error: orientation node error => ( %lf, %lf, %lf )\n"
369               "                  -> %s\n",
370               err_node->the_data.ort.x,
# Line 376 | Line 374 | void print_tree_error( struct node_tag* err_node, char
374      break;
375  
376    case START_INDEX_STMT:
377 <    fprintf( stderr,
377 >    sprintf( painCave.errMsg,
378               "Parse tree error: start_index error -> %s\n",
379               err_msg );
380      break;
381  
382  
383    default:
384 <    fprintf( stderr,
384 >    sprintf( painCave.errMsg,
385               "Parse tree error: unknown node type -> %s\n",
386               err_msg );
387    }
388  
389 < #ifdef MPI
389 >  painCave.isFatal = 1;
390 >  simError();
391 > #ifdef IS_MPI
392    mpiInterfaceExit();
393 < #endif
393 > #endif //is_mpi
394  
395   }
396  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines