[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.1 Reverse Polish Notation Calculator
The first example is that of a simple double-precision reverse polish notation calculator (a calculator using postfix operators). This example provides a good starting point, since operator precedence is not an issue. The second example will illustrate how operator precedence is handled.
The source code for this calculator is named ‘rpcalc.y’. The ‘.y’ extension is a convention used for Bison input files.
2.1.1 Declarations for rpcalc | Prologue (declarations) for rpcalc. | |
2.1.2 Grammar Rules for rpcalc | Grammar Rules for rpcalc, with explanation. | |
2.1.3 The rpcalc Lexical Analyzer | The lexical analyzer. | |
2.1.4 The Controlling Function | The controlling function. | |
2.1.5 The Error Reporting Routine | The error reporting function. | |
2.1.6 Running Bison to Make the Parser | Running Bison on the grammar file. | |
2.1.7 Compiling the Parser File | Run the C compiler on the output code. |