[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |

# 2 Examples

Now we show and explain several sample programs written using Bison: a reverse polish notation calculator, an algebraic (infix) notation calculator — later extended to track “locations” — and a multi-function calculator. All produce usable, though limited, interactive desk-top calculators.

These examples are simple, but Bison grammars for real programming languages are written the same way. You can copy these examples into a source file to try them.

2.1 Reverse Polish Notation Calculator | Reverse polish notation calculator; a first example with no operator precedence. | |

2.2 Infix Notation Calculator: `calc` | Infix (algebraic) notation calculator. Operator precedence is introduced. | |

2.3 Simple Error Recovery | Continuing after syntax errors. | |

2.4 Location Tracking Calculator: `ltcalc` | Demonstrating the use of @n and @$.
| |

2.5 Multi-Function Calculator: `mfcalc` | Calculator with memory and trig functions. It uses multiple data-types for semantic values. | |

2.6 Exercises | Ideas for improving the multi-function calculator. |

[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |

This document was generated on *December 1, 2013* using *texi2html 5.0*.