| 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 |
|
} |
| 32 |
|
|
| 33 |
|
global_namespc.index = 0; |
| 35 |
|
|
| 36 |
|
mol_index = 0; |
| 37 |
|
comp_index = 0; |
| 38 |
< |
walk_down( head_node->next_stmt, global_namespc ); |
| 38 |
> |
walk_down( head_node->next_stmt, global_namespc ); // closed global namespace + exit |
| 39 |
> |
|
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
/* |
| 57 |
|
|
| 58 |
|
if( the_node->type == GLOBAL_HEAD ){ |
| 59 |
|
print_tree_error( the_node, "Too many global regions" ); |
| 51 |
– |
exit(0); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
if( the_node->stmt_list != NULL ){ |
| 69 |
|
if( the_namespc.type != GLOBAL_HEAD ){ |
| 70 |
|
print_tree_error( the_node, |
| 71 |
|
"component block is not in the global namespace" ); |
| 64 |
– |
exit(0); |
| 72 |
|
} |
| 73 |
|
else{ |
| 74 |
|
init_component( comp_index ); |
| 83 |
|
if( the_namespc.type != GLOBAL_HEAD ){ |
| 84 |
|
print_tree_error( the_node, |
| 85 |
|
"Molecule block is not in the global namespace" ); |
| 79 |
– |
exit(0); |
| 86 |
|
} |
| 87 |
|
else{ |
| 88 |
|
init_molecule( mol_index ); |
| 97 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
| 98 |
|
print_tree_error( the_node, |
| 99 |
|
"The atom block is not in a molecule namespace" ); |
| 94 |
– |
exit(0); |
| 100 |
|
} |
| 101 |
|
else{ |
| 102 |
|
init_atom( the_node->index ); |
| 110 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
| 111 |
|
print_tree_error( the_node, |
| 112 |
|
"The bond block is not in a molecule namespace" ); |
| 108 |
– |
exit(0); |
| 113 |
|
} |
| 114 |
|
else{ |
| 115 |
|
init_bond( the_node->index ); |
| 123 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
| 124 |
|
print_tree_error( the_node, |
| 125 |
|
"The bend block is not in a molecule namespace" ); |
| 122 |
– |
exit(0); |
| 126 |
|
} |
| 127 |
|
else{ |
| 128 |
|
init_bend( the_node->index ); |
| 137 |
|
print_tree_error( the_node, |
| 138 |
|
"The torsion block is not in " |
| 139 |
|
"a molecule namespace" ); |
| 137 |
– |
exit(0); |
| 140 |
|
} |
| 141 |
|
else{ |
| 142 |
|
init_torsion( the_node->index ); |
| 148 |
|
|
| 149 |
|
default: |
| 150 |
|
print_tree_error( the_node, "Not a valid code block" ); |
| 149 |
– |
exit(0); |
| 151 |
|
} |
| 152 |
|
} |
| 153 |
|
|
| 169 |
|
print_tree_error( the_node, |
| 170 |
|
"Member statement not in a bond, bend, " |
| 171 |
|
"or torsion" ); |
| 171 |
– |
exit(0); |
| 172 |
|
break; |
| 173 |
|
} |
| 174 |
|
break; |
| 185 |
|
print_tree_error( the_node, |
| 186 |
|
"Constraint statement not in a bond, bend, " |
| 187 |
|
"or torsion" ); |
| 188 |
– |
exit(0); |
| 188 |
|
break; |
| 189 |
|
} |
| 190 |
|
break; |
| 198 |
|
print_tree_error( the_node, |
| 199 |
|
"position statement is not located in an " |
| 200 |
|
"atom block" ); |
| 202 |
– |
exit(0); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
init_position( the_node, the_namespc ); |
| 208 |
|
print_tree_error( the_node, |
| 209 |
|
"orientation statement is not located in an " |
| 210 |
|
"atom block" ); |
| 213 |
– |
exit(0); |
| 211 |
|
} |
| 212 |
|
|
| 213 |
|
init_orientation( the_node, the_namespc ); |
| 218 |
|
print_tree_error( the_node, |
| 219 |
|
"start_index statement is not located in an " |
| 220 |
|
"component block" ); |
| 224 |
– |
exit(0); |
| 221 |
|
} |
| 222 |
|
|
| 223 |
< |
init_start_index( the_node, the_namespc ); |
| 223 |
> |
//init_start_index( the_node, the_namespc ); |
| 224 |
|
break; |
| 225 |
|
|
| 226 |
|
default: |
| 227 |
|
print_tree_error( the_node, "unrecognized statement" ); |
| 232 |
– |
exit(0); |
| 228 |
|
break; |
| 229 |
|
} |
| 230 |
|
} |
| 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, |
| 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, |
| 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 ); |
| 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 ); |
| 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 ); |
| 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 ); |
| 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, |
| 357 |
+ |
err_node->the_data.pos.y, |
| 358 |
+ |
err_node->the_data.pos.z, |
| 359 |
|
err_msg ); |
| 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, |
| 367 |
+ |
err_node->the_data.ort.y, |
| 368 |
+ |
err_node->the_data.ort.z, |
| 369 |
|
err_msg ); |
| 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 |
+ |
painCave.isFatal = 1; |
| 386 |
+ |
simError(); |
| 387 |
|
} |
| 388 |
|
|
| 389 |
|
|