| 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. |
| 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; |
| 38 |
|
|
| 39 |
|
mol_index = 0; |
| 40 |
|
comp_index = 0; |
| 41 |
< |
walk_down( head_node->next_stmt, global_namespc ); |
| 41 |
> |
walk_down( head_node->next_stmt, global_namespc ); |
| 42 |
> |
// closed global namespace and exit |
| 43 |
> |
|
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
/* |
| 61 |
|
|
| 62 |
|
if( the_node->type == GLOBAL_HEAD ){ |
| 63 |
|
print_tree_error( the_node, "Too many global regions" ); |
| 51 |
– |
exit(0); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
if( the_node->stmt_list != NULL ){ |
| 73 |
|
if( the_namespc.type != GLOBAL_HEAD ){ |
| 74 |
|
print_tree_error( the_node, |
| 75 |
|
"component block is not in the global namespace" ); |
| 64 |
– |
exit(0); |
| 76 |
|
} |
| 77 |
|
else{ |
| 78 |
|
init_component( comp_index ); |
| 87 |
|
if( the_namespc.type != GLOBAL_HEAD ){ |
| 88 |
|
print_tree_error( the_node, |
| 89 |
|
"Molecule block is not in the global namespace" ); |
| 79 |
– |
exit(0); |
| 90 |
|
} |
| 91 |
|
else{ |
| 92 |
|
init_molecule( mol_index ); |
| 101 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
| 102 |
|
print_tree_error( the_node, |
| 103 |
|
"The atom block is not in a molecule namespace" ); |
| 94 |
– |
exit(0); |
| 104 |
|
} |
| 105 |
|
else{ |
| 106 |
|
init_atom( the_node->index ); |
| 114 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
| 115 |
|
print_tree_error( the_node, |
| 116 |
|
"The bond block is not in a molecule namespace" ); |
| 108 |
– |
exit(0); |
| 117 |
|
} |
| 118 |
|
else{ |
| 119 |
|
init_bond( the_node->index ); |
| 127 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
| 128 |
|
print_tree_error( the_node, |
| 129 |
|
"The bend block is not in a molecule namespace" ); |
| 122 |
– |
exit(0); |
| 130 |
|
} |
| 131 |
|
else{ |
| 132 |
|
init_bend( the_node->index ); |
| 141 |
|
print_tree_error( the_node, |
| 142 |
|
"The torsion block is not in " |
| 143 |
|
"a molecule namespace" ); |
| 137 |
– |
exit(0); |
| 144 |
|
} |
| 145 |
|
else{ |
| 146 |
|
init_torsion( the_node->index ); |
| 152 |
|
|
| 153 |
|
default: |
| 154 |
|
print_tree_error( the_node, "Not a valid code block" ); |
| 149 |
– |
exit(0); |
| 155 |
|
} |
| 156 |
|
} |
| 157 |
|
|
| 173 |
|
print_tree_error( the_node, |
| 174 |
|
"Member statement not in a bond, bend, " |
| 175 |
|
"or torsion" ); |
| 171 |
– |
exit(0); |
| 176 |
|
break; |
| 177 |
|
} |
| 178 |
|
break; |
| 189 |
|
print_tree_error( the_node, |
| 190 |
|
"Constraint statement not in a bond, bend, " |
| 191 |
|
"or torsion" ); |
| 188 |
– |
exit(0); |
| 192 |
|
break; |
| 193 |
|
} |
| 194 |
|
break; |
| 202 |
|
print_tree_error( the_node, |
| 203 |
|
"position statement is not located in an " |
| 204 |
|
"atom block" ); |
| 202 |
– |
exit(0); |
| 205 |
|
} |
| 206 |
|
|
| 207 |
|
init_position( the_node, the_namespc ); |
| 212 |
|
print_tree_error( the_node, |
| 213 |
|
"orientation statement is not located in an " |
| 214 |
|
"atom block" ); |
| 213 |
– |
exit(0); |
| 215 |
|
} |
| 216 |
|
|
| 217 |
|
init_orientation( the_node, the_namespc ); |
| 222 |
|
print_tree_error( the_node, |
| 223 |
|
"start_index statement is not located in an " |
| 224 |
|
"component block" ); |
| 224 |
– |
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" ); |
| 232 |
– |
exit(0); |
| 232 |
|
break; |
| 233 |
|
} |
| 234 |
|
} |
| 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, |
| 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, |
| 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 ); |
| 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 ); |
| 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 ); |
| 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 ); |
| 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, |
| 361 |
+ |
err_node->the_data.pos.y, |
| 362 |
+ |
err_node->the_data.pos.z, |
| 363 |
|
err_msg ); |
| 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, |
| 371 |
+ |
err_node->the_data.ort.y, |
| 372 |
+ |
err_node->the_data.ort.z, |
| 373 |
|
err_msg ); |
| 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 |
+ |
painCave.isFatal = 1; |
| 390 |
+ |
simError(); |
| 391 |
+ |
#ifdef IS_MPI |
| 392 |
+ |
mpiInterfaceExit(); |
| 393 |
+ |
#endif //is_mpi |
| 394 |
+ |
|
| 395 |
|
} |
| 396 |
|
|
| 397 |
|
|