24.12.2012 Views

CSC322 C Programming and UNIX - Department of Computer ...

CSC322 C Programming and UNIX - Department of Computer ...

CSC322 C Programming and UNIX - Department of Computer ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Basic idea:<br />

Implementation<br />

– Input is a sequence <strong>of</strong> numbers <strong>and</strong> operators<br />

– If a number is read, it is pushed onto a stack<br />

– If an operator is read, the necessary number or arguments is popped <strong>of</strong> the<br />

stack, the operation is performed, <strong>and</strong> the result is placed in the stack<br />

Input <strong>and</strong> output can happen in any representation from base 2-16<br />

– There is a strong convention for representing these numbers:<br />

∗ Digits are 0-9 with nominal value, A-F (or a-f) with values 10-15<br />

– Input <strong>and</strong> output use independent bases (base conversion made easy)<br />

Recognizing numbers <strong>and</strong> operators<br />

– Any string <strong>of</strong> valid digits in the current input base is a number<br />

– Any string starting with - <strong>and</strong> directly followed by valid digits in the current<br />

input base is a number<br />

– Everything else is treated as an operator<br />

Stephan Schulz 188

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!