| 1 |
Now we show and explain three sample programs written using b(): a reverse |
| 2 |
polish notation calculator, an algebraic (infix) notation calculator, and a |
| 3 |
multi-function calculator. All three have been tested using the Gnu bf(C++) |
| 4 |
compiler version 5.3.1. Each example results in a usable, though limited, |
| 5 |
interactive desk-top calculator. |
| 6 |
|
| 7 |
These examples are simple, but b() grammars for real programming languages are |
| 8 |
written the same way. You can copy the examples from this document into source |
| 9 |
files to create your own versions of these programs. In addition, the b() |
| 10 |
source archive contains the various source files ready for use. |
| 11 |
|
| 12 |
itemization( |
| 13 |
it() Reverse Polish Notation Calculator (section ref(RPN)): |
| 14 |
a first example of a calculator not requiring any operator precedence. |
| 15 |
it() Infix Notation Calculator (section ref(CALC)): |
| 16 |
infix (algebraic) notation calculator, introducing. operator |
| 17 |
precedence. |
| 18 |
it() Simple Error Recovery (section ref(ERROR)): |
| 19 |
how to continue after syntactic errors. |
| 20 |
it() Multi-Function Calculator (section ref(MFCALC)): |
| 21 |
calculator having memory and trigonometrical functions. It uses |
| 22 |
multiple data-types for semantic values. |
| 23 |
it() Suggested Exercises (section ref(EXERCISES)): Ideas for improving |
| 24 |
the multi-function calculator. |
| 25 |
) |