CS345 - Program 01 sample code 1. There are two Makefiles. One for using Flex/Bison and one for Lex/Yacc. They are similar, but there are differences between the two tool sets. Choose the makefile you want to use and rename it to Makefile or use the -f flag to the 'make' program as follows: % make -f Makefile.bison 2. The file icalc.l contains a lexical specification for a very simple integer calculator that operates like the Linux 'bc' calculator. 3. The file icalc.y contains a context free grammar specification in YACC/Bison BNF for the calclulator. 4. I've tested this code using Linux on CS lab machines, and using Mac OS X 10.4 or later. 5. This code should work on Windows if you have the Cygwin toolset installed. See http://www.cygwin.com/ and be sure to download the developer tools including flex/bison and/or lex/yacc. To terminate the input loop on Windows, use instead of . 6. If everything makes correctly, you should be left with an executable file called 'icalc'. A successful build and executable should look like this: redeyedfly:~/$ make -f Makefile.bison bison -dv -bicalc icalc.y gcc -g -O -c -o icalc.o icalc.c flex -t icalc.l > scan.c gcc -g -O -c -o scan.o scan.c gcc -g -O icalc.o scan.o -o icalc redeyedfly:~/$ icalc Welcome to iCalc 1.0. Copyright 2007. Use to quit. iCalc# 1+2*3 7 icalc> exiting...