Listing 2 mixcalc.c - a rational number calculator

/* mixcalc.c */
/* Copyright 1992 by P.J. LaBrocca */

#include "mixed.h"
#include "mixcalc.h"
#include <stdio.h>

#ifdef __ZTC__          /* For Zortech Compiler */
      _stack = 15000;
#endif

enum token_value curr_tok;

void main()
{
    mixed_t ans;
       mixed_t work;

       init_primes();

       mix_clear( &ans );
       mix_init( &work, 3, 1, 7 );

    setjmp( startup );
    M = &work;
    while(1) {
              printf("> ");
       curr_tok = gettok();
              if(curr_tok == END) {
           break;
       }
              if(curr_tok == PRINT)
                     continue;
       ans = expr( );

              mix_print( mix_reduce( &ans) );
    }
}

/* End of File */