main - / $Id: main.cc,v 1.3 2010-01-22 17:26:00-08 - - $...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// $Id: main.cc,v 1.3 2010-01-22 17:26:00-08 - - $ #include <deque> #include <exception> #include <map> #include <iostream> #include <utility> using namespace std; #include "bigint.h" #include "iterstack.h" #include "util.h" #include "scanner.h" #include "trace.h" #define DO_BINOP(FN_NAME,TFLAG,OPER) \ bigint right = stack.pop(); \ TRACE (TFLAG, "right = " << right); \ bigint left = stack.pop(); \ TRACE (TFLAG, "left = " << left); \ bigint result = left OPER (right); \ TRACE (TFLAG, "result = " << result); \ stack.push (result); \ } DO_BINOP(do_add, '+', + ) DO_BINOP(do_sub, '-', - ) DO_BINOP(do_mul, '*', * ) DO_BINOP(do_div, '/', / ) DO_BINOP(do_rem, '%', % ) DO_BINOP(do_pow, '^', .pow) // option Y - debug cout << "Y not implemented" << endl; } // command c - all values on the stack are popped TRACE ('c', ""); stack.clear(); } // command d - the top values on the stack is duplicated
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/26/2010 for the course CMPS 109 taught by Professor Bailey,d during the Spring '08 term at UCSC.

Page1 / 3

main - / $Id: main.cc,v 1.3 2010-01-22 17:26:00-08 - - $...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online