First you need to install the C compiler, the lexer, and the LALR parser generator for this project.
It also helps to install the readline wrapper utility.
Build system
You need to create the file Makefile.dist with the following content.
Then you create the file configure.ac with the following content.
Finally you create the file Makefile.am with the following content.
This completes the setup of the build system.
Implementation
First create the file calc_bison.y with the implementation of the parser.
Then create the file calc_flex.l with the implementation of the lexer (tokenizer).
Then create the header file calculator.h for the parser.
Finally create the file calculator.c with the main program.
Compiling and running it
Above program is built using the following steps.
You can run the calculator as follows.
Alternatively you can run the interpreter with rlwrap to get command line history.
Here is a sample session using the calculator program.