// File: main3.C // // A calculator program #include #include #include "bstring4.h" #include "token.h" #include "parse.h" main() { BString bs ; TokenStream *tkptr ; ETree *Tptr ; cout << "A calculator program. Enter blank line to quit.\n" ; while (true) { cout << "? " ; cin >> bs ; if (bs.length() == 0) break ; tkptr = new TokenStream(bs) ; if (tkptr == NULL) { cerr << "Out of memory!" << endl ; exit(1) ; } Tptr = Parse(*tkptr) ; if (Tptr != NULL) { cout << "= " << Evaluate(*Tptr) << endl ; } delete tkptr ; delete Tptr ; } }