165 |
printf("\n"); |
printf("\n"); |
166 |
} |
} |
167 |
|
|
168 |
void prin(stackitem** stack_head) |
void print_(stackitem** stack_head) |
169 |
{ |
{ |
170 |
if((*stack_head)==NULL) |
if((*stack_head)==NULL) |
171 |
return; |
return; |
189 |
|
|
190 |
extern void print(stackitem** stack_head) |
extern void print(stackitem** stack_head) |
191 |
{ |
{ |
192 |
prin(stack_head); |
print_(stack_head); |
193 |
toss(stack_head); |
toss(stack_head); |
194 |
} |
} |
195 |
|
|
200 |
print_st(stack_head->next, counter+1); |
print_st(stack_head->next, counter+1); |
201 |
|
|
202 |
printf("%ld: ", counter); |
printf("%ld: ", counter); |
203 |
prin(&stack_head); |
print_(&stack_head); |
204 |
nl(); |
nl(); |
205 |
} |
} |
206 |
|
|
308 |
*stack_head= new_head; |
*stack_head= new_head; |
309 |
} |
} |
310 |
|
|
311 |
|
extern void swap(stackitem** stack_head) |
312 |
|
{ |
313 |
|
stackitem* temp= (*stack_head); |
314 |
|
|
315 |
|
if((*stack_head)==NULL || (*stack_head)->next==NULL) |
316 |
|
return; |
317 |
|
|
318 |
|
*stack_head= (*stack_head)->next; |
319 |
|
temp->next= (*stack_head)->next; |
320 |
|
(*stack_head)->next= temp; |
321 |
|
} |
322 |
|
|
323 |
|
extern void eq(stackitem** stack_head) |
324 |
|
{ |
325 |
|
void *left, *right; |
326 |
|
int result; |
327 |
|
|
328 |
|
if((*stack_head)==NULL || (*stack_head)->next==NULL) |
329 |
|
return; |
330 |
|
|
331 |
|
left= (*stack_head)->content.ptr; |
332 |
|
swap(stack_head); |
333 |
|
right= (*stack_head)->content.ptr; |
334 |
|
result= (left==right); |
335 |
|
|
336 |
|
toss(stack_head); toss(stack_head); |
337 |
|
push_val(stack_head, (left==right)); |
338 |
|
} |
339 |
|
|
340 |
|
extern void not(stackitem** stack_head) |
341 |
|
{ |
342 |
|
int value; |
343 |
|
|
344 |
|
if((*stack_head)==NULL) |
345 |
|
return; |
346 |
|
|
347 |
|
value= (*stack_head)->content.val; |
348 |
|
toss(stack_head); |
349 |
|
push_val(stack_head, !value); |
350 |
|
} |
351 |
|
|
352 |
|
extern void neq(stackitem** stack_head) |
353 |
|
{ |
354 |
|
eq(stack_head); |
355 |
|
not(stack_head); |
356 |
|
} |
357 |
|
|
358 |
|
extern void def(stackitem** stack_head) |
359 |
|
{ |
360 |
|
stackitem *temp, *value; |
361 |
|
|
362 |
|
if(*stack_head==NULL || (*stack_head)->next==NULL |
363 |
|
|| (*stack_head)->type!=ref) |
364 |
|
return; |
365 |
|
|
366 |
|
temp= (*stack_head)->content.ptr; |
367 |
|
value= (*stack_head)->next; |
368 |
|
temp->content= value->content; |
369 |
|
value->content.ptr=NULL; |
370 |
|
temp->type= value->type; |
371 |
|
|
372 |
|
toss(stack_head); toss(stack_head); |
373 |
|
} |
374 |
|
|
375 |
extern void quit() |
extern void quit() |
376 |
{ |
{ |
377 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
392 |
printf("okidok\n "); |
printf("okidok\n "); |
393 |
} |
} |
394 |
|
|
395 |
|
exit(EXIT_SUCCESS); |
|
return EXIT_SUCCESS; |
|
396 |
} |
} |
397 |
|
|
398 |
/* Local Variables: */ |
/* Local Variables: */ |