| 1 | 
  | 
#include <stdlib.h> | 
| 2 | 
  | 
#include <stdio.h> | 
| 3 | 
  | 
 | 
| 4 | 
< | 
#include <parse_tree.h> | 
| 5 | 
< | 
#include <simError.h> | 
| 4 | 
> | 
#include "parse_tree.h" | 
| 5 | 
> | 
#include "simError.h" | 
| 6 | 
  | 
 | 
| 7 | 
  | 
#ifdef IS_MPI | 
| 8 | 
  | 
#define __is_lex__ | 
| 9 | 
< | 
#include <mpiBASS.h> | 
| 9 | 
> | 
#include "mpiBASS.h" | 
| 10 | 
  | 
#endif | 
| 11 | 
  | 
 | 
| 12 | 
  | 
void walk_down( struct node_tag* the_node, struct namespc the_namespc ); | 
| 98 | 
  | 
        break; | 
| 99 | 
  | 
 | 
| 100 | 
  | 
      case ATOM_HEAD: | 
| 101 | 
+ | 
        if( the_namespc.type != MOLECULE_HEAD && the_namespc.type != RIGIDBODY_HEAD ){ | 
| 102 | 
+ | 
             print_tree_error( the_node, | 
| 103 | 
+ | 
                            "The atom block is not in a molecule or rigidBody namespace" ); | 
| 104 | 
+ | 
        } | 
| 105 | 
+ | 
        else{ | 
| 106 | 
+ | 
          init_atom( the_node->index ); | 
| 107 | 
+ | 
          current_namespc.index = the_node->index; | 
| 108 | 
+ | 
          current_namespc.type = the_node->type; | 
| 109 | 
+ | 
          walk_down( the_node->stmt_list, current_namespc ); | 
| 110 | 
+ | 
        } | 
| 111 | 
+ | 
        break; | 
| 112 | 
+ | 
 | 
| 113 | 
+ | 
      case RIGIDBODY_HEAD: | 
| 114 | 
  | 
        if( the_namespc.type != MOLECULE_HEAD ){ | 
| 115 | 
  | 
          print_tree_error( the_node, | 
| 116 | 
< | 
                            "The atom block is not in a molecule namespace" ); | 
| 116 | 
> | 
                            "The rigid body block is not in a molecule namespace" ); | 
| 117 | 
  | 
        } | 
| 118 | 
  | 
        else{ | 
| 119 | 
< | 
          init_atom( the_node->index ); | 
| 119 | 
> | 
          init_rigidbody( the_node->index ); | 
| 120 | 
  | 
          current_namespc.index = the_node->index; | 
| 121 | 
  | 
          current_namespc.type = the_node->type; | 
| 122 | 
  | 
          walk_down( the_node->stmt_list, current_namespc ); | 
| 162 | 
  | 
          walk_down( the_node->stmt_list, current_namespc ); | 
| 163 | 
  | 
        } | 
| 164 | 
  | 
        break; | 
| 165 | 
+ | 
       | 
| 166 | 
+ | 
      case ZCONSTRAINT_HEAD: | 
| 167 | 
+ | 
        if( the_namespc.type != GLOBAL_HEAD ){ | 
| 168 | 
+ | 
          print_tree_error( the_node, | 
| 169 | 
+ | 
                            "The Zconstraint block is not in " | 
| 170 | 
+ | 
                            "the global namespace" ); | 
| 171 | 
+ | 
        } | 
| 172 | 
+ | 
        else{ | 
| 173 | 
+ | 
          init_zconstraint( the_node->index ); | 
| 174 | 
+ | 
          current_namespc.index = the_node->index; | 
| 175 | 
+ | 
          current_namespc.type = the_node->type; | 
| 176 | 
+ | 
          walk_down( the_node->stmt_list, current_namespc ); | 
| 177 | 
+ | 
        } | 
| 178 | 
+ | 
        break; | 
| 179 | 
  | 
         | 
| 180 | 
  | 
      default: | 
| 181 | 
  | 
        print_tree_error( the_node, "Not a valid code block" ); | 
| 188 | 
  | 
 | 
| 189 | 
  | 
      switch( the_node->type ){ | 
| 190 | 
  | 
 | 
| 191 | 
< | 
      case MEMBER_STMT: | 
| 191 | 
> | 
      case MEMBERS_STMT: | 
| 192 | 
  | 
        switch( the_namespc.type ){ | 
| 193 | 
  | 
        case BOND_HEAD: // fall through | 
| 194 | 
  | 
        case BEND_HEAD: // fall through | 
| 195 | 
  | 
        case TORSION_HEAD: // same for the first three | 
| 196 | 
+ | 
        case RIGIDBODY_HEAD: | 
| 197 | 
  | 
          init_members( the_node, the_namespc ); | 
| 198 | 
  | 
          break; | 
| 199 | 
  | 
 | 
| 200 | 
  | 
        default: | 
| 201 | 
  | 
          print_tree_error( the_node,  | 
| 202 | 
< | 
                            "Member statement not in a bond, bend, " | 
| 203 | 
< | 
                            "or torsion" ); | 
| 202 | 
> | 
                            "Members statement not in a bond, bend, " | 
| 203 | 
> | 
                            "torsion, or rigidBody." ); | 
| 204 | 
  | 
          break; | 
| 205 | 
  | 
        } | 
| 206 | 
  | 
        break; | 
| 226 | 
  | 
        break; | 
| 227 | 
  | 
 | 
| 228 | 
  | 
      case POSITION_STMT: | 
| 229 | 
< | 
        if( the_namespc.type != ATOM_HEAD ){ | 
| 229 | 
> | 
        if( the_namespc.type != ATOM_HEAD && the_namespc.type != RIGIDBODY_HEAD){ | 
| 230 | 
  | 
          print_tree_error( the_node, | 
| 231 | 
  | 
                            "position statement is not located in an " | 
| 232 | 
< | 
                            "atom block" ); | 
| 232 | 
> | 
                            "atom or rigidBody block" ); | 
| 233 | 
  | 
        } | 
| 234 | 
  | 
         | 
| 235 | 
  | 
        init_position( the_node, the_namespc ); | 
| 236 | 
  | 
        break; | 
| 237 | 
  | 
 | 
| 238 | 
  | 
      case ORIENTATION_STMT: | 
| 239 | 
< | 
        if( the_namespc.type != ATOM_HEAD ){ | 
| 239 | 
> | 
        if( the_namespc.type != ATOM_HEAD && the_namespc.type != RIGIDBODY_HEAD){ | 
| 240 | 
  | 
          print_tree_error( the_node, | 
| 241 | 
  | 
                            "orientation statement is not located in an " | 
| 242 | 
< | 
                            "atom block" ); | 
| 242 | 
> | 
                            "atom or rigidBody block" ); | 
| 243 | 
  | 
        } | 
| 244 | 
  | 
         | 
| 245 | 
  | 
        init_orientation( the_node, the_namespc ); | 
| 218 | 
– | 
        break; | 
| 219 | 
– | 
 | 
| 220 | 
– | 
      case START_INDEX_STMT: | 
| 221 | 
– | 
        if( the_namespc.type != COMPONENT_HEAD ){ | 
| 222 | 
– | 
          print_tree_error( the_node, | 
| 223 | 
– | 
                            "start_index statement is not located in an " | 
| 224 | 
– | 
                            "component block" ); | 
| 225 | 
– | 
        } | 
| 226 | 
– | 
         | 
| 227 | 
– | 
        //init_start_index( the_node, the_namespc ); | 
| 246 | 
  | 
        break; | 
| 247 | 
  | 
 | 
| 248 | 
  | 
      default: | 
| 291 | 
  | 
             err_msg ); | 
| 292 | 
  | 
    break; | 
| 293 | 
  | 
 | 
| 294 | 
+ | 
  case RIGIDBODY_HEAD: | 
| 295 | 
+ | 
    sprintf( painCave.errMsg, | 
| 296 | 
+ | 
             "Parse tree error: rigidBody head node error -> %s\n", | 
| 297 | 
+ | 
             err_msg ); | 
| 298 | 
+ | 
    break; | 
| 299 | 
+ | 
 | 
| 300 | 
  | 
  case ATOM_HEAD: | 
| 301 | 
  | 
    sprintf( painCave.errMsg, | 
| 302 | 
  | 
             "Parse tree error: atom head node error [%d] -> %s\n", | 
| 317 | 
  | 
             err_node->index, | 
| 318 | 
  | 
             err_msg ); | 
| 319 | 
  | 
    break; | 
| 320 | 
< | 
     | 
| 321 | 
< | 
  case TORSION_HEAD: | 
| 320 | 
> | 
       | 
| 321 | 
> | 
  case ZCONSTRAINT_HEAD: | 
| 322 | 
  | 
    sprintf( painCave.errMsg, | 
| 323 | 
< | 
             "Parse tree error: torsion head node error [%d] -> %s\n", | 
| 323 | 
> | 
             "Parse tree error: Zconstraint head node error [%d] -> %s\n", | 
| 324 | 
  | 
             err_node->index, | 
| 325 | 
  | 
             err_msg ); | 
| 326 | 
  | 
    break; | 
| 327 | 
< | 
     | 
| 328 | 
< | 
  case MEMBER_STMT: | 
| 327 | 
> | 
 | 
| 328 | 
> | 
  case MEMBERS_STMT: | 
| 329 | 
  | 
    sprintf( painCave.errMsg, | 
| 330 | 
< | 
             "Parse tree error: member node error => ( %d, %d, %d, %d )\n" | 
| 330 | 
> | 
             "Parse tree error: members node error (nMembers = %d)\n" | 
| 331 | 
  | 
             "                  -> %s\n", | 
| 332 | 
< | 
             err_node->the_data.mbr.a, | 
| 309 | 
< | 
             err_node->the_data.mbr.b, | 
| 310 | 
< | 
             err_node->the_data.mbr.c, | 
| 311 | 
< | 
             err_node->the_data.mbr.d, | 
| 332 | 
> | 
             err_node->the_data.mbrs.nMembers, | 
| 333 | 
  | 
             err_msg ); | 
| 334 | 
  | 
    break; | 
| 335 | 
  | 
 | 
| 388 | 
  | 
    sprintf( painCave.errMsg, | 
| 389 | 
  | 
             "Parse tree error: orientation node error => ( %lf, %lf, %lf )\n" | 
| 390 | 
  | 
             "                  -> %s\n", | 
| 391 | 
< | 
             err_node->the_data.ort.x,  | 
| 392 | 
< | 
             err_node->the_data.ort.y,  | 
| 393 | 
< | 
             err_node->the_data.ort.z,  | 
| 391 | 
> | 
             err_node->the_data.ort.phi,  | 
| 392 | 
> | 
             err_node->the_data.ort.theta,  | 
| 393 | 
> | 
             err_node->the_data.ort.psi,  | 
| 394 | 
  | 
             err_msg ); | 
| 395 | 
  | 
    break; | 
| 396 | 
  | 
 | 
| 376 | 
– | 
  case START_INDEX_STMT: | 
| 377 | 
– | 
    sprintf( painCave.errMsg, | 
| 378 | 
– | 
             "Parse tree error: start_index error -> %s\n", | 
| 379 | 
– | 
             err_msg ); | 
| 380 | 
– | 
    break; | 
| 381 | 
– | 
 | 
| 382 | 
– | 
 | 
| 397 | 
  | 
  default: | 
| 398 | 
  | 
    sprintf( painCave.errMsg, | 
| 399 | 
  | 
             "Parse tree error: unknown node type -> %s\n", | 
| 416 | 
  | 
   | 
| 417 | 
  | 
void kill_tree( struct node_tag* the_node ){ | 
| 418 | 
  | 
   | 
| 405 | 
– | 
  // These two are needed to get rid of the integer list | 
| 419 | 
  | 
 | 
| 407 | 
– | 
  struct integer_list_tag* current_il; | 
| 408 | 
– | 
  struct integer_list_tag* temp_il; | 
| 409 | 
– | 
 | 
| 410 | 
– | 
 | 
| 420 | 
  | 
  if( the_node != NULL ){ | 
| 421 | 
  | 
     | 
| 422 | 
  | 
    if( the_node->stmt_list != NULL ){ | 
| 440 | 
  | 
        free( the_node->the_data.asmt.identifier ); | 
| 441 | 
  | 
        break; | 
| 442 | 
  | 
 | 
| 434 | 
– | 
      case START_INDEX_STMT: | 
| 435 | 
– | 
         | 
| 436 | 
– | 
        current_il = the_node->the_data.il_head; | 
| 437 | 
– | 
        while( current_il != NULL ){ | 
| 438 | 
– | 
          temp_il = current_il->next; | 
| 439 | 
– | 
          free( current_il ); | 
| 440 | 
– | 
          current_il = temp_il; | 
| 441 | 
– | 
        } | 
| 442 | 
– | 
        the_node->the_data.il_head = NULL; | 
| 443 | 
– | 
        break; | 
| 444 | 
– | 
 | 
| 443 | 
  | 
      default: | 
| 444 | 
  | 
        // nothing to do here, everyone else can be freed normally. | 
| 445 | 
  | 
        break; |