ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/io/parse_tree.c
(Generate patch)

Comparing trunk/src/io/parse_tree.c (file contents):
Revision 3 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
Revision 564 by tim, Wed Jul 13 15:54:00 2005 UTC

# Line 1 | Line 1
1 + /*
2 + * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 + *
4 + * The University of Notre Dame grants you ("Licensee") a
5 + * non-exclusive, royalty free, license to use, modify and
6 + * redistribute this software in source and binary code form, provided
7 + * that the following conditions are met:
8 + *
9 + * 1. Acknowledgement of the program authors must be made in any
10 + *    publication of scientific results based in part on use of the
11 + *    program.  An acceptable form of acknowledgement is citation of
12 + *    the article in which the program was described (Matthew
13 + *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 + *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 + *    Parallel Simulation Engine for Molecular Dynamics,"
16 + *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 + *
18 + * 2. Redistributions of source code must retain the above copyright
19 + *    notice, this list of conditions and the following disclaimer.
20 + *
21 + * 3. Redistributions in binary form must reproduce the above copyright
22 + *    notice, this list of conditions and the following disclaimer in the
23 + *    documentation and/or other materials provided with the
24 + *    distribution.
25 + *
26 + * This software is provided "AS IS," without a warranty of any
27 + * kind. All express or implied conditions, representations and
28 + * warranties, including any implied warranty of merchantability,
29 + * fitness for a particular purpose or non-infringement, are hereby
30 + * excluded.  The University of Notre Dame and its licensors shall not
31 + * be liable for any damages suffered by licensee as a result of
32 + * using, modifying or distributing the software or its
33 + * derivatives. In no event will the University of Notre Dame or its
34 + * licensors be liable for any lost revenue, profit or data, or for
35 + * direct, indirect, special, consequential, incidental or punitive
36 + * damages, however caused and regardless of the theory of liability,
37 + * arising out of the use of or inability to use software, even if the
38 + * University of Notre Dame has been advised of the possibility of
39 + * such damages.
40 + */
41 +
42   #include <stdlib.h>
43   #include <stdio.h>
44  
# Line 10 | Line 51 | void walk_down( struct node_tag* the_node, struct name
51   #endif
52  
53   void walk_down( struct node_tag* the_node, struct namespc the_namespc );
54 < int mol_index; // keeps track of the number of molecules
55 < int comp_index; // keeps track of the number of components.
54 > int mol_index; /* keeps track of the number of molecules*/
55 > int comp_index; /* keeps track of the number of components.*/
56  
57   /*
58   * This is the parse tree function that is called by the yacc
# Line 30 | Line 71 | void pt_me( struct node_tag* head_node ){
71      simError();
72   #ifdef IS_MPI
73      mpiInterfaceExit();
74 < #endif //is_mpi
74 > #endif /*is_mpi*/
75    }
76  
77    global_namespc.index = 0;
# Line 39 | Line 80 | void pt_me( struct node_tag* head_node ){
80    mol_index = 0;
81    comp_index = 0;
82    walk_down( head_node->next_stmt, global_namespc );
83 <  // closed global namespace and exit
83 >  /* closed global namespace and exit*/
84  
85   }
86  
# Line 65 | Line 106 | void walk_down( struct node_tag* the_node, struct name
106  
107      if( the_node->stmt_list != NULL ){
108  
109 <      // the statement is a block node of some sort
109 >      /* the statement is a block node of some sort*/
110        
111        switch( the_node->type ){
112  
# Line 99 | Line 140 | void walk_down( struct node_tag* the_node, struct name
140  
141        case ATOM_HEAD:
142          if( the_namespc.type != MOLECULE_HEAD ){
143 <             print_tree_error( the_node,
143 >          print_tree_error( the_node,
144                              "The atom block is not in a molecule namespace" );
145          }
146          else{
# Line 197 | Line 238 | void walk_down( struct node_tag* the_node, struct name
238      
239      else{
240        
241 <      // the node is a statement
241 >      /* the node is a statement */
242  
243        switch( the_node->type ){
244  
245        case MEMBERS_STMT:
246          switch( the_namespc.type ){
247 <        case BOND_HEAD: // fall through
248 <        case BEND_HEAD: // fall through
247 >        case BOND_HEAD: /* fall through*/
248 >        case BEND_HEAD: /* fall through*/
249          case TORSION_HEAD:
250          case RIGIDBODY_HEAD:
251 <        case CUTOFFGROUP_HEAD: // same for the first four
251 >        case CUTOFFGROUP_HEAD: /* same for the first four*/
252            init_members( the_node, the_namespc );
253            break;
254  
# Line 221 | Line 262 | void walk_down( struct node_tag* the_node, struct name
262  
263        case CONSTRAINT_STMT:
264          switch( the_namespc.type ){
265 <        case BOND_HEAD: // fall through
266 <        case BEND_HEAD: // fall through
267 <        case TORSION_HEAD: // same for the first three
265 >        case BOND_HEAD: /* fall through*/
266 >        case BEND_HEAD: /* fall through*/
267 >        case TORSION_HEAD: /* same for the first three*/
268            init_constraint( the_node, the_namespc );
269            break;
270  
# Line 265 | Line 306 | void walk_down( struct node_tag* the_node, struct name
306        }
307      }
308      
309 <    // recurse down to the next node
309 >    /* recurse down to the next node*/
310  
311      walk_down( the_node->next_stmt, the_namespc );
312    }
313  
314 <  // send an end of block signal
314 >  /* send an end of block signal*/
315    else end_of_block();
316    
317 <  // we're done
317 >  /* we're done*/
318   }
319  
320  
# Line 355 | Line 396 | void print_tree_error( struct node_tag* err_node, char
396  
397    case CONSTRAINT_STMT:
398      sprintf( painCave.errMsg,
399 <            "Parse tree error: constraint node error => ( %lf )\n"
400 <            "                 -> %s\n",
401 <            err_node->the_data.cnstr.constraint_val,
402 <            err_msg );
399 >             "Parse tree error: constraint node error => ( %lf )\n"
400 >             "                 -> %s\n",
401 >             err_node->the_data.cnstr.constraint_val,
402 >             err_msg );
403      break;
404      
405    case ASSIGNMENT_STMT:
# Line 424 | Line 465 | void print_tree_error( struct node_tag* err_node, char
465    simError();
466   #ifdef IS_MPI
467    mpiInterfaceExit();
468 < #endif //is_mpi
468 > #endif /*is_mpi*/
469  
470   }
471  
# Line 441 | Line 482 | void kill_tree( struct node_tag* the_node ){
482      
483      if( the_node->stmt_list != NULL ){
484  
485 <      // the statement is a block node of some sort
485 >      /* the statement is a block node of some sort*/
486        
487        kill_tree( the_node->stmt_list );
488      }
489      
490      else{
491        
492 <      // the node is a statement
492 >      /* the node is a statement */
493  
494        switch( the_node->type ){
495  
# Line 460 | Line 501 | void kill_tree( struct node_tag* the_node ){
501          free( the_node->the_data.asmt.identifier );
502          break;
503  
504 +      case MEMBERS_STMT:
505 +
506 +        if (the_node->the_data.mbrs.nMembers >0 ){
507 +          free(the_node->the_data.mbrs.memberList);
508 +        }
509 +        break;
510 +      
511        default:
512 <        // nothing to do here, everyone else can be freed normally.
512 >        /* nothing to do here, everyone else can be freed normally.*/
513          break;
514        }
515      }
516      
517 <    // recurse down to the next node
517 >    /* recurse down to the next node*/
518  
519      kill_tree( the_node->next_stmt );
520      free( the_node );    
521    }
522  
523 <  // we're done
523 >  /* we're done*/
524   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines