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 ); |
39 |
> |
// closed global namespace and exit |
40 |
> |
|
41 |
|
} |
42 |
|
|
43 |
|
/* |
58 |
|
|
59 |
|
if( the_node->type == GLOBAL_HEAD ){ |
60 |
|
print_tree_error( the_node, "Too many global regions" ); |
51 |
– |
exit(0); |
61 |
|
} |
62 |
|
|
63 |
|
if( the_node->stmt_list != NULL ){ |
70 |
|
if( the_namespc.type != GLOBAL_HEAD ){ |
71 |
|
print_tree_error( the_node, |
72 |
|
"component block is not in the global namespace" ); |
64 |
– |
exit(0); |
73 |
|
} |
74 |
|
else{ |
75 |
|
init_component( comp_index ); |
84 |
|
if( the_namespc.type != GLOBAL_HEAD ){ |
85 |
|
print_tree_error( the_node, |
86 |
|
"Molecule block is not in the global namespace" ); |
79 |
– |
exit(0); |
87 |
|
} |
88 |
|
else{ |
89 |
|
init_molecule( mol_index ); |
98 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
99 |
|
print_tree_error( the_node, |
100 |
|
"The atom block is not in a molecule namespace" ); |
94 |
– |
exit(0); |
101 |
|
} |
102 |
|
else{ |
103 |
|
init_atom( the_node->index ); |
111 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
112 |
|
print_tree_error( the_node, |
113 |
|
"The bond block is not in a molecule namespace" ); |
108 |
– |
exit(0); |
114 |
|
} |
115 |
|
else{ |
116 |
|
init_bond( the_node->index ); |
124 |
|
if( the_namespc.type != MOLECULE_HEAD ){ |
125 |
|
print_tree_error( the_node, |
126 |
|
"The bend block is not in a molecule namespace" ); |
122 |
– |
exit(0); |
127 |
|
} |
128 |
|
else{ |
129 |
|
init_bend( the_node->index ); |
138 |
|
print_tree_error( the_node, |
139 |
|
"The torsion block is not in " |
140 |
|
"a molecule namespace" ); |
137 |
– |
exit(0); |
141 |
|
} |
142 |
|
else{ |
143 |
|
init_torsion( the_node->index ); |
149 |
|
|
150 |
|
default: |
151 |
|
print_tree_error( the_node, "Not a valid code block" ); |
149 |
– |
exit(0); |
152 |
|
} |
153 |
|
} |
154 |
|
|
170 |
|
print_tree_error( the_node, |
171 |
|
"Member statement not in a bond, bend, " |
172 |
|
"or torsion" ); |
171 |
– |
exit(0); |
173 |
|
break; |
174 |
|
} |
175 |
|
break; |
186 |
|
print_tree_error( the_node, |
187 |
|
"Constraint statement not in a bond, bend, " |
188 |
|
"or torsion" ); |
188 |
– |
exit(0); |
189 |
|
break; |
190 |
|
} |
191 |
|
break; |
199 |
|
print_tree_error( the_node, |
200 |
|
"position statement is not located in an " |
201 |
|
"atom block" ); |
202 |
– |
exit(0); |
202 |
|
} |
203 |
|
|
204 |
|
init_position( the_node, the_namespc ); |
209 |
|
print_tree_error( the_node, |
210 |
|
"orientation statement is not located in an " |
211 |
|
"atom block" ); |
213 |
– |
exit(0); |
212 |
|
} |
213 |
|
|
214 |
|
init_orientation( the_node, the_namespc ); |
219 |
|
print_tree_error( the_node, |
220 |
|
"start_index statement is not located in an " |
221 |
|
"component block" ); |
224 |
– |
exit(0); |
222 |
|
} |
223 |
|
|
224 |
< |
init_start_index( the_node, the_namespc ); |
224 |
> |
//init_start_index( the_node, the_namespc ); |
225 |
|
break; |
226 |
|
|
227 |
|
default: |
228 |
|
print_tree_error( the_node, "unrecognized statement" ); |
232 |
– |
exit(0); |
229 |
|
break; |
230 |
|
} |
231 |
|
} |
253 |
|
switch( err_node->type ){ |
254 |
|
|
255 |
|
case GLOBAL_HEAD: |
256 |
< |
fprintf( stderr, |
256 |
> |
sprintf( painCave.errMsg, |
257 |
|
"Parse tree error: global head node error -> %s\n", |
258 |
|
err_msg ); |
259 |
|
break; |
260 |
|
|
261 |
|
case COMPONENT_HEAD: |
262 |
< |
fprintf( stderr, |
262 |
> |
sprintf( painCave.errMsg, |
263 |
|
"Parse tree error: component head node error -> %s\n", |
264 |
|
err_msg ); |
265 |
|
break; |
266 |
|
|
267 |
|
case MOLECULE_HEAD: |
268 |
< |
fprintf( stderr, |
268 |
> |
sprintf( painCave.errMsg, |
269 |
|
"Parse tree error: molecule head node error -> %s\n", |
270 |
|
err_msg ); |
271 |
|
break; |
272 |
|
|
273 |
|
case ATOM_HEAD: |
274 |
< |
fprintf( stderr, |
274 |
> |
sprintf( painCave.errMsg, |
275 |
|
"Parse tree error: atom head node error [%d] -> %s\n", |
276 |
|
err_node->index, |
277 |
|
err_msg ); |
278 |
|
break; |
279 |
|
|
280 |
|
case BOND_HEAD: |
281 |
< |
fprintf( stderr, |
281 |
> |
sprintf( painCave.errMsg, |
282 |
|
"Parse tree error: bond head node error [%d] -> %s\n", |
283 |
|
err_node->index, |
284 |
|
err_msg ); |
285 |
|
break; |
286 |
|
|
287 |
|
case BEND_HEAD: |
288 |
< |
fprintf( stderr, |
288 |
> |
sprintf( painCave.errMsg, |
289 |
|
"Parse tree error: bend head node error [%d] -> %s\n", |
290 |
|
err_node->index, |
291 |
|
err_msg ); |
292 |
|
break; |
293 |
|
|
294 |
|
case TORSION_HEAD: |
295 |
< |
fprintf( stderr, |
295 |
> |
sprintf( painCave.errMsg, |
296 |
|
"Parse tree error: torsion head node error [%d] -> %s\n", |
297 |
|
err_node->index, |
298 |
|
err_msg ); |
299 |
|
break; |
300 |
|
|
301 |
|
case MEMBER_STMT: |
302 |
< |
fprintf( stderr, |
302 |
> |
sprintf( painCave.errMsg, |
303 |
|
"Parse tree error: member node error => ( %d, %d, %d, %d )\n" |
304 |
|
" -> %s\n", |
305 |
|
err_node->the_data.mbr.a, |
310 |
|
break; |
311 |
|
|
312 |
|
case CONSTRAINT_STMT: |
313 |
< |
fprintf( stderr, |
313 |
> |
sprintf( painCave.errMsg, |
314 |
|
"Parse tree error: constraint node error => ( %lf )\n" |
315 |
|
" -> %s\n", |
316 |
|
err_node->the_data.cnstr.constraint_val, |
318 |
|
break; |
319 |
|
|
320 |
|
case ASSIGNMENT_STMT: |
321 |
< |
fprintf( stderr, |
321 |
> |
sprintf( painCave.errMsg, |
322 |
|
"Parse tree error: assignment node error\n" |
323 |
|
" => %s = ", |
324 |
|
err_node->the_data.asmt.identifier ); |
326 |
|
switch( err_node->the_data.asmt.type ){ |
327 |
|
|
328 |
|
case STR_ASSN: |
329 |
< |
fprintf( stderr, |
329 |
> |
sprintf( painCave.errMsg, |
330 |
|
"%s", |
331 |
|
err_node->the_data.asmt.rhs.str_ptr ); |
332 |
|
break; |
333 |
|
|
334 |
|
case INT_ASSN: |
335 |
< |
fprintf( stderr, |
335 |
> |
sprintf( painCave.errMsg, |
336 |
|
"%d", |
337 |
|
err_node->the_data.asmt.rhs.i_val ); |
338 |
|
break; |
339 |
|
|
340 |
|
case DOUBLE_ASSN: |
341 |
< |
fprintf( stderr, |
341 |
> |
sprintf( painCave.errMsg, |
342 |
|
"%lf", |
343 |
|
err_node->the_data.asmt.rhs.d_val ); |
344 |
|
break; |
345 |
|
} |
346 |
|
|
347 |
< |
fprintf( stderr, |
347 |
> |
sprintf( painCave.errMsg, |
348 |
|
"\n" |
349 |
|
" -> %s\n", |
350 |
|
err_msg ); |
351 |
|
break; |
352 |
|
|
353 |
|
case POSITION_STMT: |
354 |
< |
fprintf( stderr, |
354 |
> |
sprintf( painCave.errMsg, |
355 |
|
"Parse tree error: position node error => ( %lf, %lf, %lf )\n" |
356 |
|
" -> %s\n", |
357 |
|
err_node->the_data.pos.x, |
361 |
|
break; |
362 |
|
|
363 |
|
case ORIENTATION_STMT: |
364 |
< |
fprintf( stderr, |
364 |
> |
sprintf( painCave.errMsg, |
365 |
|
"Parse tree error: orientation node error => ( %lf, %lf, %lf )\n" |
366 |
|
" -> %s\n", |
367 |
|
err_node->the_data.ort.x, |
371 |
|
break; |
372 |
|
|
373 |
|
case START_INDEX_STMT: |
374 |
< |
fprintf( stderr, |
374 |
> |
sprintf( painCave.errMsg, |
375 |
|
"Parse tree error: start_index error -> %s\n", |
376 |
|
err_msg ); |
377 |
|
break; |
378 |
|
|
379 |
|
|
380 |
|
default: |
381 |
< |
fprintf( stderr, |
381 |
> |
sprintf( painCave.errMsg, |
382 |
|
"Parse tree error: unknown node type -> %s\n", |
383 |
|
err_msg ); |
384 |
|
} |
385 |
+ |
|
386 |
+ |
painCave.isFatal = 1; |
387 |
+ |
simError(); |
388 |
+ |
#ifdef IS_MPI |
389 |
+ |
mpiInterfaceExit(); |
390 |
+ |
#endif //is_mpi |
391 |
+ |
|
392 |
|
} |
393 |
|
|
394 |
|
|